Skip to content

feature/list blocks update with initialFilters option#409

Merged
lukasz-hycom merged 9 commits intomainfrom
feature/list-blocks-update-with-new-option
Nov 25, 2025
Merged

feature/list blocks update with initialFilters option#409
lukasz-hycom merged 9 commits intomainfrom
feature/list-blocks-update-with-new-option

Conversation

@lukasz-hycom
Copy link
Copy Markdown
Contributor

@lukasz-hycom lukasz-hycom commented Nov 24, 2025

What does this PR do?

  • Added initialFilters support to list blocks (Ticket, Invoice, Notification, Order), allowing default filters to be configured in CMS.

Key Changes

  • Extended CMS and API Harmonization models with initialFilters in all list blocks.
  • API Harmonization services merge initialFilters from CMS with user queries before calling integrations.
  • Frontend uses initialFilters to initialize filter state.
  • Mock CMS includes example initialFilters values for each locale.

Summary by CodeRabbit

  • New Features

    • List blocks (invoices, notifications, orders, tickets) now surface CMS-configurable initial filters.
    • Invoice list queries accept locale for locale-specific results.
  • Updates

    • Notification priority labels standardized (case/values consistency).
  • Chores

    • Changelog entries and package version bumps added to reflect the changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
o2s-docs Skipped Skipped Nov 25, 2025 11:01am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 24, 2025

Walkthrough

The diff adds an optional initialFilters property to invoice, notification, order and ticket list blocks across models, mappers, services and CMS integrations, and propagates CMS-provided initialFilters into list-service API calls; invoice list request also gains an optional locale field.

Changes

Cohort / File(s) Summary
Blocks — models + mappers + services
packages/blocks/invoice-list/src/api-harmonization/invoice-list.model.ts, packages/blocks/invoice-list/src/api-harmonization/invoice-list.mapper.ts, packages/blocks/invoice-list/src/api-harmonization/invoice-list.service.ts, packages/blocks/notification-list/src/api-harmonization/notification-list.model.ts, packages/blocks/notification-list/src/api-harmonization/notification-list.mapper.ts, packages/blocks/notification-list/src/api-harmonization/notification-list.service.ts, packages/blocks/order-list/src/api-harmonization/order-list.model.ts, packages/blocks/order-list/src/api-harmonization/order-list.mapper.ts, packages/blocks/order-list/src/api-harmonization/order-list.service.ts, packages/blocks/ticket-list/src/api-harmonization/ticket-list.model.ts, packages/blocks/ticket-list/src/api-harmonization/ticket-list.mapper.ts, packages/blocks/ticket-list/src/api-harmonization/ticket-list.service.ts
Added optional initialFilters to block models and mapper outputs; services now spread cms.initialFilters into API call parameters and adjust limit/offset/locale composition (invoice service adds locale and default offset)
Framework — CMS block models
packages/framework/src/modules/cms/models/blocks/invoice-list.model.ts, packages/framework/src/modules/cms/models/blocks/notification-list.model.ts, packages/framework/src/modules/cms/models/blocks/order-list.model.ts, packages/framework/src/modules/cms/models/blocks/ticket-list.model.ts
Added optional initialFilters?: Partial<... & { sort?: string }> to each exported block class
CMS integrations — Strapi mappers
packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.invoice-list.mapper.ts, packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.notification-list.mapper.ts, packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.order-list.mapper.ts, packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.ticket-list.mapper.ts
Added initialFilters: undefined placeholders (with TODOs) to mapped CMS block objects to surface the field in CMS outputs
CMS integrations — mocked
packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.notification-list.mapper.ts
Normalized priority option strings to uppercase constants (LOW/MEDIUM/HIGH/CRITICAL)
API request type
packages/framework/src/modules/invoices/invoices.request.ts
Added optional locale?: string to GetInvoiceListQuery
Changelog
.changeset/common-brooms-search.md
Added changelog entry noting "adding initial filters support to list blocks."

Sequence Diagram

sequenceDiagram
    autonumber
    participant CMS as CMS Block
    participant Mapper as Block Mapper
    participant Service as List Service
    participant API as Backend API

    CMS->>Mapper: block data + cms.initialFilters
    Mapper->>Service: mappedBlock { ..., initialFilters }
    Service->>Service: params = { ...(cms.initialFilters||{}), ...query, locale?, limit, offset }
    Service->>API: getList(params)
    API-->>Service: results
    Service-->>Mapper: mapped results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to parameter merge order in each service (ensure explicit query fields override initialFilters as intended).
  • Verify pagination fallback logic differences (limit/offset) across services for consistency.
  • Review Strapi mapper TODO placeholders to confirm expected future data shape and avoid typing regressions.

Possibly related PRs

Suggested reviewers

  • marcinkrasowski

Poem

🐇 I nibbled through CMS rows tonight,
Placed initial filters snug and tight.
From mapper hop to service bound,
Queries pre-filter, results are found.
A rabbit’s cheer — lists now take flight! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description covers the primary objective and key changes but lacks critical sections: no Related Ticket(s), no detailed testing instructions, and no media documentation. Add related ticket reference, detailed testing steps with setup requirements, and specify how to verify initialFilters functionality across all list blocks.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding initialFilters support to list blocks as a new feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/list-blocks-update-with-new-option

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 062c59d and 337be1a.

📒 Files selected for processing (1)
  • .changeset/common-brooms-search.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/common-brooms-search.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: deploy-preview

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (3)
packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.order-list.mapper.ts (1)

42-42: Placeholder initialFilters is fine; remember to wire real CMS field later

Setting initialFilters: undefined keeps the type in sync without changing behavior, which is appropriate while Strapi lacks this field. Once the CMS schema exposes initialFilters, this mapper should be updated to map the actual value (likely via a dedicated mapper, mirroring other blocks) and the TODO can be removed.

packages/blocks/notification-list/src/api-harmonization/notification-list.model.ts (1)

22-22: initialFilters type is reasonable and consistent with domain model

Using Partial<Notifications.Model.Notification & { sort?: string }> for initialFilters aligns the default filter shape with the underlying notification domain plus the extra sort field, and matches patterns used in other list blocks. Just ensure any future filter fields that aren’t part of Notifications.Model.Notification (e.g. additional synthetic filter keys) are reflected here if they are meant to be configurable as initial filters.

packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.ticket-list.mapper.ts (1)

43-43: Consistent initialFilters placeholder; update once Strapi exposes the field

As with the order-list mapper, explicitly setting initialFilters: undefined keeps the CMS TicketListBlock shape aligned with the rest of the system without altering behavior. When Strapi adds this field, this mapper should be updated to map the real value and the TODO can be cleaned up.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec80202 and 6ff1920.

📒 Files selected for processing (24)
  • packages/blocks/invoice-list/src/api-harmonization/invoice-list.mapper.ts (1 hunks)
  • packages/blocks/invoice-list/src/api-harmonization/invoice-list.model.ts (1 hunks)
  • packages/blocks/invoice-list/src/api-harmonization/invoice-list.service.ts (1 hunks)
  • packages/blocks/notification-list/src/api-harmonization/notification-list.mapper.ts (1 hunks)
  • packages/blocks/notification-list/src/api-harmonization/notification-list.model.ts (1 hunks)
  • packages/blocks/notification-list/src/api-harmonization/notification-list.service.ts (1 hunks)
  • packages/blocks/order-list/src/api-harmonization/order-list.mapper.ts (1 hunks)
  • packages/blocks/order-list/src/api-harmonization/order-list.model.ts (1 hunks)
  • packages/blocks/order-list/src/api-harmonization/order-list.service.ts (1 hunks)
  • packages/blocks/ticket-list/src/api-harmonization/ticket-list.mapper.ts (1 hunks)
  • packages/blocks/ticket-list/src/api-harmonization/ticket-list.model.ts (1 hunks)
  • packages/blocks/ticket-list/src/api-harmonization/ticket-list.service.ts (1 hunks)
  • packages/framework/src/modules/cms/models/blocks/invoice-list.model.ts (1 hunks)
  • packages/framework/src/modules/cms/models/blocks/notification-list.model.ts (1 hunks)
  • packages/framework/src/modules/cms/models/blocks/order-list.model.ts (1 hunks)
  • packages/framework/src/modules/cms/models/blocks/ticket-list.model.ts (1 hunks)
  • packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.invoice-list.mapper.ts (3 hunks)
  • packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.notification-list.mapper.ts (3 hunks)
  • packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.order-list.mapper.ts (3 hunks)
  • packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.ticket-list.mapper.ts (3 hunks)
  • packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.invoice-list.mapper.ts (1 hunks)
  • packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.notification-list.mapper.ts (1 hunks)
  • packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.order-list.mapper.ts (1 hunks)
  • packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.ticket-list.mapper.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-13T15:35:13.879Z
Learnt from: marcinkrasowski
Repo: o2sdev/openselfservice PR: 348
File: packages/blocks/notification-summary/src/api-harmonization/notification-summary.service.ts:23-27
Timestamp: 2025-11-13T15:35:13.879Z
Learning: In the notification-summary block service (packages/blocks/notification-summary/src/api-harmonization/notification-summary.service.ts), the hardcoded limit of 1000 notifications when calling notificationService.getNotificationList() is intentional, as there is no server-side aggregation API available for fetching notification counts by priority.

Applied to files:

  • packages/blocks/notification-list/src/api-harmonization/notification-list.service.ts
  • packages/blocks/notification-list/src/api-harmonization/notification-list.model.ts
  • packages/framework/src/modules/cms/models/blocks/notification-list.model.ts
🧬 Code graph analysis (4)
packages/framework/src/modules/cms/models/blocks/notification-list.model.ts (1)
packages/blocks/notification-list/src/api-harmonization/notification-list.model.ts (1)
  • Notification (25-43)
packages/framework/src/modules/cms/models/blocks/ticket-list.model.ts (1)
packages/blocks/ticket-list/src/api-harmonization/ticket-list.model.ts (1)
  • Ticket (30-47)
packages/framework/src/modules/cms/models/blocks/invoice-list.model.ts (1)
packages/blocks/invoice-list/src/api-harmonization/invoice-list.model.ts (1)
  • Invoice (29-50)
packages/blocks/order-list/src/api-harmonization/order-list.model.ts (1)
packages/framework/src/modules/orders/orders.model.ts (1)
  • Orders (84-84)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: deploy-preview
🔇 Additional comments (19)
packages/framework/src/modules/cms/models/blocks/notification-list.model.ts (1)

22-22: LGTM! Type definition aligns with similar blocks.

The initialFilters property is properly typed as optional and uses Partial<Notification & { sort?: string }>, consistent with the filter patterns used in other list blocks (invoice, order, ticket).

packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.notification-list.mapper.ts (1)

42-42: LGTM! Placeholder is appropriate.

Setting initialFilters: undefined with a TODO comment is a safe approach until the CMS schema is updated to support this field.

packages/blocks/notification-list/src/api-harmonization/notification-list.service.ts (1)

28-33: LGTM! Parameter precedence is correct.

The spread order ensures that:

  1. initialFilters provides defaults
  2. query parameters override defaults
  3. Explicit limit, offset, and locale take final precedence

This correctly implements the intended behavior where user queries override CMS defaults.

packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.invoice-list.mapper.ts (1)

41-41: LGTM! Placeholder consistent with other mappers.

Setting initialFilters: undefined with a TODO is appropriate until CMS schema support is added.

packages/blocks/ticket-list/src/api-harmonization/ticket-list.service.ts (1)

28-33: LGTM! Implementation consistent with notification-list.

The parameter merging and precedence logic matches the notification-list block, correctly prioritizing user queries over CMS defaults.

packages/framework/src/modules/cms/models/blocks/ticket-list.model.ts (1)

25-25: LGTM! Type definition consistent across blocks.

The initialFilters property uses the same type pattern as other list blocks, maintaining consistency.

packages/framework/src/modules/cms/models/blocks/order-list.model.ts (1)

24-24: LGTM! Type definition follows established pattern.

The initialFilters property is properly typed and consistent with the other list blocks in this PR.

packages/blocks/invoice-list/src/api-harmonization/invoice-list.model.ts (1)

26-26: Expose initialFilters on InvoiceListBlock

initialFilters type is consistent with the invoice model and allows a sort field for query defaults; matches the pattern used across other list blocks.

packages/blocks/order-list/src/api-harmonization/order-list.model.ts (1)

27-27: Expose initialFilters on OrderListBlock

Type and naming align with filters and the underlying Orders.Model.Order plus optional sort, so this looks consistent and safe.

packages/blocks/ticket-list/src/api-harmonization/ticket-list.model.ts (1)

27-27: Expose initialFilters on TicketListBlock

This is a straightforward, consistent addition matching the other list blocks’ initialFilters shape.

packages/blocks/invoice-list/src/api-harmonization/invoice-list.mapper.ts (1)

30-30: Propagate CMS initialFilters in mapInvoiceList

Passing through cms.initialFilters cleanly exposes CMS-configured defaults on the block without changing existing behavior.

packages/blocks/order-list/src/api-harmonization/order-list.mapper.ts (1)

29-29: Propagate CMS initialFilters in mapOrderList

initialFilters is correctly forwarded from CMS to the block model, matching the other list mappers.

packages/framework/src/modules/cms/models/blocks/invoice-list.model.ts (1)

23-23: Add initialFilters to CMS InvoiceListBlock

CMS block now exposes initialFilters with a type compatible with the harmonization layer; this cleanly enables CMS-configured defaults.

packages/blocks/order-list/src/api-harmonization/order-list.service.ts (1)

29-34: Correct precedence when merging CMS defaults and user query

Merging { ...(cms.initialFilters || {}), ...query } and then explicitly overriding limit, offset, and locale gives the right precedence: CMS defaults apply only when the user hasn’t specified a value, and pagination/locale stay authoritative from query/headers.

packages/blocks/ticket-list/src/api-harmonization/ticket-list.mapper.ts (1)

29-29: Propagate CMS initialFilters in mapTicketList

The mapper now correctly exposes cms.initialFilters on the TicketListBlock, consistent with the other list mappers.

packages/blocks/notification-list/src/api-harmonization/notification-list.mapper.ts (1)

27-27: Pass-through of initialFilters from CMS looks correct

Propagating cms.initialFilters into the mapped NotificationListBlock keeps the public API aligned with the CMS model and lets callers access configured defaults without changing existing behavior.

packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.order-list.mapper.ts (1)

94-97: Mock initialFilters values are consistent with defined filters

The added initialFilters for EN/DE/PL all use keys (status, sort) and values that exist in the corresponding filter option lists and domain enums, so they should work well as realistic defaults and good examples for consumers of the mocked CMS.

Also applies to: 203-206, 312-315

packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.ticket-list.mapper.ts (1)

154-158: Ticket mock initialFilters align with field mappings and filter options

The initial filter presets for EN/DE/PL all use valid domain values for status, topic, type, and sort that are present in both the field mappings and the configured filter items, so they should behave correctly and give predictable default views per locale.

Also applies to: 314-318, 475-480

packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.invoice-list.mapper.ts (1)

114-117: Invoice mock initialFilters are consistent and useful defaults

The added initialFilters for EN/DE/PL correctly reference existing paymentStatus and sort options, providing sensible default views (due, paid, past due) per locale. This keeps mocks aligned with the public model and should help exercise the new initial-filters behavior end-to-end.

Also applies to: 242-245, 370-373

@vercel vercel Bot temporarily deployed to Preview – o2s-docs November 24, 2025 15:21 Inactive
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/blocks/invoice-list/src/api-harmonization/invoice-list.service.ts (1)

28-33: Past review issue resolved: limit precedence now consistent.

The limit logic has been updated to query.limit || cms.pagination?.limit || 1, which addresses the previous review comment and aligns with the pattern used in other list blocks (Notification, Ticket, Order). The parameter precedence is now consistent:

  1. cms.initialFilters provides CMS-configured defaults
  2. query params allow user overrides
  3. Explicit limit, offset, and locale ensure required fields are set

The spreading order correctly prioritizes user query parameters over CMS defaults.

Based on learnings, if there's any concern about the initialFilters spreading introducing unexpected fields, consider adding type constraints in the CMS model definition to ensure only valid invoice list query parameters can be configured as initialFilters.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b09518 and e771c88.

📒 Files selected for processing (2)
  • packages/blocks/invoice-list/src/api-harmonization/invoice-list.service.ts (1 hunks)
  • packages/framework/src/modules/invoices/invoices.request.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-13T15:35:13.879Z
Learnt from: marcinkrasowski
Repo: o2sdev/openselfservice PR: 348
File: packages/blocks/notification-summary/src/api-harmonization/notification-summary.service.ts:23-27
Timestamp: 2025-11-13T15:35:13.879Z
Learning: In the notification-summary block service (packages/blocks/notification-summary/src/api-harmonization/notification-summary.service.ts), the hardcoded limit of 1000 notifications when calling notificationService.getNotificationList() is intentional, as there is no server-side aggregation API available for fetching notification counts by priority.

Applied to files:

  • packages/blocks/invoice-list/src/api-harmonization/invoice-list.service.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: deploy-preview
🔇 Additional comments (1)
packages/framework/src/modules/invoices/invoices.request.ts (1)

15-15: LGTM! Locale support added to invoice list queries.

The optional locale field integrates cleanly with the existing GetInvoiceListQuery interface and supports the PR's objective of enabling locale-specific invoice listings.

Copy link
Copy Markdown
Collaborator

@marcinkrasowski marcinkrasowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please run npm run changeset and mark modified blocks and integrations as new minor versions

@vercel vercel Bot temporarily deployed to Preview – o2s-docs November 25, 2025 11:01 Inactive
@lukasz-hycom lukasz-hycom merged commit ac245c5 into main Nov 25, 2025
7 checks passed
@lukasz-hycom lukasz-hycom deleted the feature/list-blocks-update-with-new-option branch November 25, 2025 11:28
@coderabbitai coderabbitai Bot mentioned this pull request Nov 26, 2025
1 task
@coderabbitai coderabbitai Bot mentioned this pull request Dec 18, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants