Skip to content

refactor: update CMS service methods to use getBlockConfig for block retrieval#759

Merged
lukasz-hycom merged 6 commits intomainfrom
feature/refactor-cms-getblockconfig
Mar 31, 2026
Merged

refactor: update CMS service methods to use getBlockConfig for block retrieval#759
lukasz-hycom merged 6 commits intomainfrom
feature/refactor-cms-getblockconfig

Conversation

@lukasz-hycom
Copy link
Copy Markdown
Contributor

@lukasz-hycom lukasz-hycom commented Mar 9, 2026

Key Changes

  • Replaced block-specific methods (getFaqBlock, getTicketListBlock, etc.) with a single generic method getBlockConfig(params) that takes a blockType parameter. Implementations (mocked, strapi, contentful) branch on blockType, and all block services now call getBlockConfig with the appropriate type.

Summary by CodeRabbit

  • Refactor
    • Centralized many per-block CMS endpoints into a single generic block-config retrieval, preserving existing outputs.
  • New Features
    • Added broader support for additional block types (including checkout and organization-related blocks).
  • Documentation
    • Updated CMS integration guides and examples to show the new generic block-config approach.
  • Chores
    • Applied synchronized minor version bumps across CMS integration and block packages.

@lukasz-hycom lukasz-hycom self-assigned this Mar 9, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 9, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
o2s-docs Skipped Skipped Mar 9, 2026 10:20am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 9, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1b9ac719-f8f0-45b8-8e51-6ee03d52fbe3

📥 Commits

Reviewing files that changed from the base of the PR and between adbfb0d and 1ddd85d.

📒 Files selected for processing (1)
  • apps/docs/docs/guides/integrations/extending-framework-modules.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/docs/docs/guides/integrations/extending-framework-modules.md

Walkthrough

Consolidates CMS access by replacing many block-specific CmsService getters with a single generic getBlockConfig(options) dispatcher; request types gained a blockType discriminator and controllers/integrations/block consumers were updated to call getBlockConfig with corresponding blockType.

Changes

Cohort / File(s) Summary
Framework: Request types, Controller & Service
packages/framework/src/modules/cms/cms.request.ts, packages/framework/src/modules/cms/cms.controller.ts, packages/framework/src/modules/cms/cms.service.ts
Added CmsBlockType and GetCmsBlockConfigParams; replaced many abstract per-block getters with getBlockConfig<T>(...); controllers updated to call getBlockConfig with blockType.
Contentful integration
packages/integrations/contentful-cms/src/modules/cms/cms.service.ts
Removed many specific block getters; implemented getBlockConfig<T> switching on blockType, returning mapped/cached blocks or throwing NotFound for unknown types.
Strapi integration
packages/integrations/strapi-cms/src/modules/cms/cms.service.ts
Replaced per-block methods with getBlockConfig<T> dispatcher; added OrganizationList case and centralized cache/mapper routing.
Mocked integration
packages/integrations/mocked/src/modules/cms/cms.service.ts
Replaced many mocked block getters with a switch-based getBlockConfig<T> that dispatches to mappers with responseDelay and throws NotFound for unknown block types.
API Harmonization / Block consumers
apps/api-harmonization/src/modules/organizations/organizations.service.ts, packages/blocks/account/user-account/src/api-harmonization/user-account.service.ts, packages/blocks/billing/invoice-list/src/api-harmonization/invoice-list.service.ts, packages/blocks/billing/payments-history/src/api-harmonization/payments-history.service.ts
Updated callers to use cmsService.getBlockConfig<T>({ id, locale, blockType: '...' }); adjusted forkJoin usage to object form and destructured results where applicable.
Docs & Changesets
apps/docs/..., .changeset/*
Documentation examples updated to the generic getBlockConfig pattern; multiple changesets added to record version bumps and the migration to getBlockConfig, including added checkout block types in mocked integration.

Sequence Diagram(s)

sequenceDiagram
    participant Client as "Client"
    participant Controller as "CMSController"
    participant Service as "CmsService"
    participant Provider as "IntegrationProvider"
    participant Cache as "MapperCache"

    Client->>Controller: GET /cms/block?id,locale,blockType
    Controller->>Service: getBlockConfig({ id, locale, blockType })
    Service->>Provider: fetch raw entry / GraphQL by id/locale
    Provider->>Cache: check cache / map entry
    Cache-->>Provider: mapped block (or miss)
    Provider-->>Service: Observable<T> (mapped block)
    Service-->>Controller: Observable<T>
    Controller-->>Client: HTTP response with block payload
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • marcinkrasowski

Poem

🐰
I hopped through mappers, one by one,
Gathered blocks beneath one sun.
A single route now hums and streams,
Clean paths for code and brighter dreams.
🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete and fails to follow the required template. It lacks sections for 'What does this PR do?', 'Related Ticket(s)', side effects analysis, testing instructions, and media. Complete the PR description using the provided template, including a checklist item, related ticket reference, comprehensive side effects analysis, and detailed testing steps.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactoring: replacing block-specific CMS methods with a generic getBlockConfig approach for block retrieval.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor-cms-getblockconfig

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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: 3

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

22-22: Minor: forkJoin wrapping a single observable is unnecessary.

Since there's only one observable source, you could simplify to cms.pipe(map(...)) directly. However, if this pattern is intentional for consistency across block services or future extensibility, feel free to keep it.

♻️ Optional simplification
-        return forkJoin([cms]).pipe(map(([cms]) => mapSurveyjs(cms, headers['x-locale'])));
+        return cms.pipe(map((cmsResult) => mapSurveyjs(cmsResult, headers['x-locale'])));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/blocks/surveyjs-form/src/api-harmonization/surveyjs.service.ts` at
line 22, The code uses forkJoin to wrap a single observable (cms) which is
unnecessary; replace the forkJoin([cms]).pipe(map(([cms]) => mapSurveyjs(cms,
headers['x-locale']))) with a direct cms.pipe(map(cms => mapSurveyjs(cms,
headers['x-locale']))) call (or keep forkJoin if you intentionally want
uniformity), locating the change around the forkJoin usage in
surveyjs.service.ts where mapSurveyjs and headers['x-locale'] are referenced.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/framework/src/modules/cms/cms.controller.ts`:
- Around line 103-109: The getArticleDetailsBlock handler currently calls
this.cms.getBlockConfig with blockType hard-coded to 'ArticleListBlock' (see
getArticleDetailsBlock and Model.ArticleListBlock.ArticleListBlock) which is
incorrect; update the blockType argument to the correct value (e.g.
'ArticleDetailsBlock') in the this.cms.getBlockConfig call so the
/blocks/article-details route dispatches to the proper block, or if the
ArticleDetails block isn't implemented yet, restore/keep the old implementation
used previously instead of calling getBlockConfig.

In `@packages/integrations/contentful-cms/src/modules/cms/cms.service.ts`:
- Around line 452-523: The getBlockConfig method is missing cases for the
CmsBlockType variants TicketSummaryBlock, NotificationSummaryBlock,
BentoGridBlock, CtaSectionBlock, DocumentListBlock, FeatureSectionBlock,
FeatureSectionGridBlock, HeroSectionBlock, MediaSectionBlock, and
PricingSectionBlock which causes valid requests to hit the default
NotFoundException branch; update getBlockConfig to add case branches for each
missing block and route them to the appropriate mapping functions (e.g.,
mapTicketSummaryBlock, mapNotificationSummaryBlock, mapBentoGridBlock,
mapCtaSectionBlock, mapDocumentListBlock, mapFeatureSectionBlock,
mapFeatureSectionGridBlock, mapHeroSectionBlock, mapMediaSectionBlock,
mapPricingSectionBlock) using the same pattern as other blocks (either
of(mapX(...)) when no network call is needed or this.getCachedBlock(key, () =>
this.getBlock(options).pipe(map(mapX))) when mapping requires the fetched
block), and ensure the corresponding map* functions are imported or created to
restore parity with the shared CmsBlockType contract.

In `@packages/integrations/strapi-cms/src/modules/cms/cms.service.ts`:
- Around line 299-416: getBlockConfig is missing switch cases for ten CMS block
types causing NotFoundException; add cases for BentoGridBlock, CtaSectionBlock,
DocumentListBlock, FeatureSectionBlock, FeatureSectionGridBlock,
HeroSectionBlock, MediaSectionBlock, NotificationSummaryBlock,
PricingSectionBlock, and TicketSummaryBlock inside the getBlockConfig<T> method
so each returns the appropriate Observable (use this.getCachedBlock(key, () =>
this.getBlock(options).pipe(map(mapXBlock))) or of(mapXBlock(...)) consistent
with existing patterns); reference the existing mapping helper names (e.g.,
mapBentoGridBlock, mapCtaSectionBlock, mapDocumentListBlock,
mapFeatureSectionBlock, mapFeatureSectionGridBlock, mapHeroSectionBlock,
mapMediaSectionBlock, mapNotificationSummaryBlock, mapPricingSectionBlock,
mapTicketSummaryBlock) and ensure locales/baseUrl are passed when other mappings
require them, keeping the default NotFoundException fallback intact.

---

Nitpick comments:
In `@packages/blocks/surveyjs-form/src/api-harmonization/surveyjs.service.ts`:
- Line 22: The code uses forkJoin to wrap a single observable (cms) which is
unnecessary; replace the forkJoin([cms]).pipe(map(([cms]) => mapSurveyjs(cms,
headers['x-locale']))) with a direct cms.pipe(map(cms => mapSurveyjs(cms,
headers['x-locale']))) call (or keep forkJoin if you intentionally want
uniformity), locating the change around the forkJoin usage in
surveyjs.service.ts where mapSurveyjs and headers['x-locale'] are referenced.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 751bddfd-6f9d-4d0c-ba18-3cc2f7e52953

📥 Commits

Reviewing files that changed from the base of the PR and between 4c390a3 and 5128703.

📒 Files selected for processing (42)
  • apps/api-harmonization/src/modules/organizations/organizations.service.ts
  • packages/blocks/article-list/src/api-harmonization/article-list.service.ts
  • packages/blocks/article-search/src/api-harmonization/article-search.service.ts
  • packages/blocks/bento-grid/src/api-harmonization/bento-grid.service.ts
  • packages/blocks/category-list/src/api-harmonization/category-list.service.ts
  • packages/blocks/category/src/api-harmonization/category.service.ts
  • packages/blocks/cta-section/src/api-harmonization/cta-section.service.ts
  • packages/blocks/document-list/src/api-harmonization/document-list.service.ts
  • packages/blocks/faq/src/api-harmonization/faq.service.ts
  • packages/blocks/feature-section-grid/src/api-harmonization/feature-section-grid.service.ts
  • packages/blocks/feature-section/src/api-harmonization/feature-section.service.ts
  • packages/blocks/featured-service-list/src/api-harmonization/featured-service-list.service.ts
  • packages/blocks/hero-section/src/api-harmonization/hero-section.service.ts
  • packages/blocks/invoice-list/src/api-harmonization/invoice-list.service.ts
  • packages/blocks/media-section/src/api-harmonization/media-section.service.ts
  • packages/blocks/notification-details/src/api-harmonization/notification-details.service.ts
  • packages/blocks/notification-list/src/api-harmonization/notification-list.service.ts
  • packages/blocks/notification-summary/src/api-harmonization/notification-summary.service.ts
  • packages/blocks/order-details/src/api-harmonization/order-details.service.ts
  • packages/blocks/order-list/src/api-harmonization/order-list.service.ts
  • packages/blocks/orders-summary/src/api-harmonization/orders-summary.service.ts
  • packages/blocks/payments-history/src/api-harmonization/payments-history.service.ts
  • packages/blocks/payments-summary/src/api-harmonization/payments-summary.service.ts
  • packages/blocks/pricing-section/src/api-harmonization/pricing-section.service.ts
  • packages/blocks/product-details/src/api-harmonization/product-details.service.ts
  • packages/blocks/product-list/src/api-harmonization/product-list.service.ts
  • packages/blocks/quick-links/src/api-harmonization/quick-links.service.ts
  • packages/blocks/recommended-products/src/api-harmonization/recommended-products.service.ts
  • packages/blocks/service-details/src/api-harmonization/service-details.service.ts
  • packages/blocks/service-list/src/api-harmonization/service-list.service.ts
  • packages/blocks/surveyjs-form/src/api-harmonization/surveyjs.service.ts
  • packages/blocks/ticket-details/src/api-harmonization/ticket-details.service.ts
  • packages/blocks/ticket-list/src/api-harmonization/ticket-list.service.ts
  • packages/blocks/ticket-recent/src/api-harmonization/ticket-recent.service.ts
  • packages/blocks/ticket-summary/src/api-harmonization/ticket-summary.service.ts
  • packages/blocks/user-account/src/api-harmonization/user-account.service.ts
  • packages/framework/src/modules/cms/cms.controller.ts
  • packages/framework/src/modules/cms/cms.request.ts
  • packages/framework/src/modules/cms/cms.service.ts
  • packages/integrations/contentful-cms/src/modules/cms/cms.service.ts
  • packages/integrations/mocked/src/modules/cms/cms.service.ts
  • packages/integrations/strapi-cms/src/modules/cms/cms.service.ts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

Coverage Report for packages/configs/vitest-config

Status Category Percentage Covered / Total
🔵 Lines 78.51% 1739 / 2215
🔵 Statements 77.43% 1829 / 2362
🔵 Functions 75% 519 / 692
🔵 Branches 65.9% 1148 / 1742
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/blocks/knowledge-base/article-list/src/api-harmonization/article-list.service.ts 30% 50% 20% 30% 21-42
packages/blocks/checkout/cart/src/api-harmonization/cart.service.ts 66.66% 100% 50% 66.66% 18-24
packages/blocks/checkout/checkout-billing-payment/src/api-harmonization/checkout-billing-payment.service.ts 66.66% 100% 50% 66.66% 21-27
packages/blocks/checkout/checkout-company-data/src/api-harmonization/checkout-company-data.service.ts 66.66% 100% 50% 66.66% 25-31
packages/blocks/checkout/checkout-shipping-address/src/api-harmonization/checkout-shipping-address.service.ts 40% 100% 33.33% 40% 25-47
packages/blocks/checkout/checkout-summary/src/api-harmonization/checkout-summary.service.ts 66.66% 100% 50% 66.66% 27-33
packages/integrations/mocked-dxp/src/modules/cms/cms.service.ts 73.07% 60% 90.9% 73.07% 52, 94-104
packages/blocks/checkout/order-confirmation/src/api-harmonization/order-confirmation.service.ts 30% 50% 25% 33.33% 28-45
packages/blocks/products/product-details/src/api-harmonization/product-details.service.ts 27.27% 44.44% 25% 27.27% 26-53
packages/blocks/products/recommended-products/src/api-harmonization/recommended-products.service.ts 20% 33.33% 14.28% 20% 24-69
Generated in workflow #605 for commit 1ddd85d by the Vitest Coverage Report Action

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: 2

🧹 Nitpick comments (1)
.changeset/eleven-rabbits-laugh.md (1)

8-8: Expand the changeset description to clearly communicate the main API refactoring.

The current description focuses narrowly on checkout blocks and mocked-dxp, but doesn't explain the fundamental API change affecting all four packages. Consumers need to understand that block-specific methods (e.g., getFaqBlock, getTicketListBlock) have been replaced with a single generic getBlockConfig<T>(options) method that accepts a blockType parameter.

📝 Suggested comprehensive changeset description
-Added checkout block type cases (Cart, CheckoutCompanyData, CheckoutShippingAddress, CheckoutBillingPayment, CheckoutSummary, OrderConfirmation) to the getBlockConfig switch in mocked CMS service. Refactored mocked-dxp to use getBlockConfig override instead of individual block method overrides.
+Refactored CMS service API to consolidate block-specific methods into a single generic `getBlockConfig<T>(options)` method. All CMS integrations (Contentful, Strapi, Mocked) now use a `blockType` parameter to dispatch to the appropriate block configuration. 
+
+**Breaking change**: Replace calls to specific methods (e.g., `getFaqBlock()`, `getTicketListBlock()`) with `getBlockConfig({ blockType: 'FaqBlock', ... })`.
+
+Additional changes:
+- Added checkout block type cases (Cart, CheckoutCompanyData, CheckoutShippingAddress, CheckoutBillingPayment, CheckoutSummary, OrderConfirmation) to mocked CMS service
+- Updated mocked-dxp to use `getBlockConfig` override pattern with `super.getBlockConfig()` delegation
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/eleven-rabbits-laugh.md at line 8, Update the changeset text to
clearly describe the API refactor: explain that block-specific methods such as
getFaqBlock and getTicketListBlock have been removed and replaced across all
four packages with a single generic getBlockConfig<T>(options) method that takes
a blockType parameter; mention that the mocked-dxp implementation was refactored
to override getBlockConfig instead of individual block methods and list the
newly added checkout block types (Cart, CheckoutCompanyData,
CheckoutShippingAddress, CheckoutBillingPayment, CheckoutSummary,
OrderConfirmation) so consumers understand the breaking change and how to
migrate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/quick-hoops-cheer.md:
- Around line 2-42: The changeset adds many block packages but cms.service.ts's
getBlockConfig (in
packages/integrations/contentful-cms/src/modules/cms/cms.service.ts) currently
throws for several valid CmsBlockType values (defined in
packages/framework/src/modules/cms/cms.request.ts) such as TicketSummaryBlock,
NotificationSummaryBlock, BentoGridBlock, CtaSectionBlock, DocumentListBlock,
FeatureSectionBlock, FeatureSectionGridBlock, HeroSectionBlock,
MediaSectionBlock, PricingSectionBlock, CartBlock, CheckoutCompanyDataBlock,
CheckoutShippingAddressBlock, CheckoutBillingPaymentBlock, and
OrderConfirmationBlock; either extend getBlockConfig to handle these
CmsBlockType enum values by adding corresponding case branches that return the
proper block config (or a safe default) for each named block type, or
remove/defer the related package bumps from the changeset so the release does
not include blocks that cms.service.ts cannot handle.

In @.changeset/tired-brooms-start.md:
- Around line 2-3: The changeset currently marks '@o2s/framework' and
'@o2s/api-harmonization' as minor, but replacing many CmsService abstract
methods with a single getBlockConfig<T>() is a breaking API change; update the
changeset to use "major" for '@o2s/framework' (and also set
'@o2s/api-harmonization' to "major" if its public API is affected), update the
summary text to reflect the breaking change to CmsService and
getBlockConfig<T>(), and re-run your changeset/versioning commands so the
package releases reflect a major bump.

---

Nitpick comments:
In @.changeset/eleven-rabbits-laugh.md:
- Line 8: Update the changeset text to clearly describe the API refactor:
explain that block-specific methods such as getFaqBlock and getTicketListBlock
have been removed and replaced across all four packages with a single generic
getBlockConfig<T>(options) method that takes a blockType parameter; mention that
the mocked-dxp implementation was refactored to override getBlockConfig instead
of individual block methods and list the newly added checkout block types (Cart,
CheckoutCompanyData, CheckoutShippingAddress, CheckoutBillingPayment,
CheckoutSummary, OrderConfirmation) so consumers understand the breaking change
and how to migrate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6dcef44a-173c-4a0d-a4be-5a7dd59a8452

📥 Commits

Reviewing files that changed from the base of the PR and between 26240d2 and 34898a8.

📒 Files selected for processing (3)
  • .changeset/eleven-rabbits-laugh.md
  • .changeset/quick-hoops-cheer.md
  • .changeset/tired-brooms-start.md

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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/docs/docs/guides/integrations/extending-framework-modules.md`:
- Around line 330-332: The example snippet uses headers[H.Locale] but does not
import H; update the snippet header to add the missing import for H so the
reference resolves (ensure the snippet shows the import alongside other
imports), then verify the example including cmsService.getBlockConfig and
CMS.Model.TicketListBlock.TicketListBlock still compiles when copy-pasted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f9269734-a7c0-4d44-aa9b-ef2a857c709c

📥 Commits

Reviewing files that changed from the base of the PR and between 34898a8 and adbfb0d.

📒 Files selected for processing (2)
  • apps/docs/docs/guides/integrations/extending-framework-modules.md
  • apps/docs/docs/integrations/cms/strapi/blocks.md

@lukasz-hycom lukasz-hycom merged commit 6edc9ca into main Mar 31, 2026
13 checks passed
@lukasz-hycom lukasz-hycom deleted the feature/refactor-cms-getblockconfig branch March 31, 2026 14:08
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