Repository navigation
chore: add content platform cms schemas - CP-860 - #3071
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
934de69 to
e8d1e67
Compare
e8d1e67 to
902127f
Compare
to merchants' temp dir
lucasfp13
left a comment
There was a problem hiding this comment.
Confirmed that all the sections/content-types and its properties have a match on each of those new CMS files (double-checked using AI agent too), LGTM
lariciamota
left a comment
There was a problem hiding this comment.
question: Will we have to maintain both types of schema, this new one and the old ones: content-types.json/sections.json? Since one is for CP and the other hCMS. If so, is there already some script we could use to help replicate our changes from one to another?
Yes. We'll have to keep both updated. The new content plugin has this command to update the new files:
|
## What's the purpose of this pull request? This PR adds the schema definitions for components and content types that will be used by CMS (Content Platform). A big change introduced is regarding how we're allowing schema definitions for components to be broken into multiple json | jsonc files. A second significant change is the `base.jsonc` file. It's a special file used only by the Consumer. In this case, Faststore is a Consumer and must maintain this base file. This **must** not be sent to the clients. This PR replaces the #2742 ## How it works? This PR splits the sections.json and content-types.json file into many components. - packages/core/cms/faststore/components/.*jsonc - packages/core/cms/faststore/content-types/.*jsonc It also adds a base.jsonc exclusive for Faststore (it must not be shared with the Developer). - packages/core/cms/faststore/base.jsonc The content CLI (CMS) can combine the files, generate an output, and send it to the Schema Registry. - packages/core/cms/faststore/schema.json (final schema output) The Faststore is the base schema for all Merchants. 🚀 ## How to test it? Install the Content plugin and check the available commands ```bash vtex plugins install @vtex/cli-plugin-content ``` Migrate the **sections** from hCMS to the new CMS: ```bash vtex content split-components -i cms/faststore/sections.json -o cms/faststore/components ``` Migrate the **content-types** from hCMS to the new CMS: ```bash vtex content split-content-types -i packages/core/cms/faststore/content-types.json -s packages/core/cms/faststore/sections.json -o packages/core/cms/faststore/content-types ``` When you are ready, you can generate the final output: **IMPORTANT**: The Faststore Core Team is the only one that needs to add the `-l base.jsonc` to the output. Merchants will automatically use the base from the Schema Registry. ```bash vtex content generate-schema packages/core/cms/faststore/components packages/core/cms/faststore/content-types -l packages/core/cms/faststore/base.jsonc -o packages/core/cms/faststore/schema.json ``` Finally, send the output schema to the Schema Registry 🚀 IMPORTANT: This command is equivalent to the hCMS cms-sync function. ```bash vtex content upload-schema ``` ## References [Schema Registry for CMS (content platform)](https://github.com/vtex/content-platform/tree/main/services/schema-registry-api) [Content Plugin CLI](https://github.com/vtex/cli-plugin-content) [Split command](vtex/cli-plugin-content#13) **Documentation** - [x] For documentation changes, ping `@Mariana-Caetano` to review and update (Or submit a doc request) --------- Co-authored-by: Lucas Feijó <[email protected]>
## What's the purpose of this pull request? We noticed the slug field (for preview and page creation) is not present in the newest CMS schema for FS. ## How it works? <img width="939" height="173" alt="image" src="https://github.com/user-attachments/assets/ade6bc02-78bb-4021-9483-9b78b4bde2c7" /> ## How to test it? https://usb2bstore.myvtex.com/admin/content-platform/branches/main/form/faststore/landingPage/entries/b9a51bfe-3ce4-4f61-8e82-2542466a9728 Editing the slug and preview the page, it should work ## References [PR adding the schemas](#3071)
## What's the purpose of this pull request? We noticed the slug field (for preview and page creation) is not present in the newest CMS schema for FS. ## How it works? <img width="939" height="173" alt="image" src="https://github.com/user-attachments/assets/ade6bc02-78bb-4021-9483-9b78b4bde2c7" /> ## How to test it? https://usb2bstore.myvtex.com/admin/content-platform/branches/main/form/faststore/landingPage/entries/b9a51bfe-3ce4-4f61-8e82-2542466a9728 Editing the slug and preview the page, it should work ## References [PR adding the schemas](#3071)
## What's the purpose of this pull request? The `RegionSlider` overlay no longer opens on stores that use **Content Platform** as their content source, even when *"Should enable global filter by pickup point"* is enabled in the CMS. The trigger button on `RegionBar` correctly dispatches `openRegionSlider(...)` and `useUI().regionSlider.isOpen` transitions to `true`, but no overlay appears in the DOM and no warning is logged. The defect is the cumulative consequence of three correct-in-isolation changes that compose poorly: 1. **#2887 — Global filter by pickup point**: introduced `RegionSlider` as a global CMS section. The runtime in `RenderSections.tsx` started iterating the CMS-supplied `sections[]` array and mounting `RegionSlider` whenever a section with `name: "RegionSlider"` was present. Demo stores (`vendemo`, `storeframework`, `faststoreqa`) had the section saved into their hCMS content during this window. 2. **#2961 — fix: Remove `RegionSlider` section**: stripped the configurable props and then deleted the entire `{ name: "RegionSlider" }` block from `sections.json`, because the section had no editable per-page configuration. Stores that already had the section persisted in hCMS kept working (hCMS doesn't revalidate persisted content against the current schema), but the schema no longer offers it for new authoring. 3. **#3071 — chore: add content platform cms schemas**: generated the CP schemas from `sections.json` via `vtex content split-components`. Since `sections.json` had already been cleaned of `RegionSlider` 5 months earlier, the generator produced CP schemas without it. Every CP storefront created or migrated after this point — directly or transitively via `starter.store` — inherits this gap. The CP service strictly validates content entries against the uploaded schema, so no CP store can save the section. **Impact matrix:** | Content source | Before this fix | After this fix | | ----------------------------------------------------------------------------------------- | ---------------------------------------- | ---------------------- | | Content Platform, any state | Broken (trigger click is a silent no-op) | Works | | hCMS, section persisted in pre-#2961 content (`vendemo`, `storeframework`, `faststoreqa`) | Works | Works (no duplication) | | hCMS, fresh store or content created after #2961 | Broken | Works | ## How it works? A small pure helper `withRegionSliderSection` is added inside `packages/core/src/components/cms/RenderSections.tsx`. It inspects the CMS-supplied `sections` and `globalSections` arrays and: - Returns `sections` unchanged when **either** array already contains a `{ name: "RegionSlider" }` entry. This is the legacy hCMS path — the existing iteration mounts the component as it always has. - Appends `{ name: "RegionSlider", data: {} }` to `sections` otherwise. This is the CP path and the fresh-hCMS path — the runtime guarantees the section without depending on the CMS schema. The result is memoized as `augmentedSections` in `RenderSections` and replaces the original `sections` reference in the second `RenderSectionsBase` invocation. The injected entry then flows through the existing pipeline: - `RenderSectionsBase` resolves the component via `components[name]`, so `CUSTOM_COMPONENTS.RegionSlider` and `PLUGINS_COMPONENTS.RegionSlider` overrides are honored unchanged. - `LazyLoadingSection` keeps its existing `sectionName === 'RegionSlider' && regionSlider.isOpen && regionSlider.type !== 'none'` branch in `shouldLoad`. The chunk is therefore only downloaded when the shopper actually opens the slider (or after TTI, matching the bundle behavior of `CartSidebar` and `RegionModal`). - `RegionSlider`'s internal `if (!isOpen) return null` self-gate remains the sole source of truth for visibility — no DOM is rendered when the overlay is closed. ## How to test it? Set up a Content Platform-based storefront (you can use the one from the thread in the refs) and verify: - Enable Delivery Promise: - In `discovery.config.js`, set `deliveryPromise: { enabled: true }`. - In the CMS global settings, enable *"Should enable global filter by pickup point"* (sets `filterByPickupPoint.enabled = true`). - Open any page (home, PLP, PDP, search) and set a postal code. - Click the **Filter by Store** button on the `RegionBar`. - Expected: the `RegionSlider` overlay opens with the configured title and pickup-point list. - Close the overlay via the close button, `ESC`, or backdrop click. - Expected: the overlay closes, `regionSlider.isOpen` returns to `false`. ### Starters Deploy Preview ## References - [Jira task](https://vtex-dev.atlassian.net/browse/SO-623) - [Slack thread](https://vtex.slack.com/archives/C051B6LL91U/p1778608689625729) - Original feature PR: [#2887 — Global filter by pickup point](#2887) - Schema cleanup PR: [#2961 — fix: Remove `RegionSlider` section](#2961) - CP schemas introduction PR: [#3071 — chore: add content platform cms schemas](#3071) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * The region slider CMS section is now guaranteed to be consistently available across all CMS layouts. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/vtex/faststore/pull/3318) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
What's the purpose of this pull request?
This PR adds the schema definitions for components and content types that will be used by CMS (Content Platform).
A big change introduced is regarding how we're allowing schema definitions for components to be broken into multiple json | jsonc files.
A second significant change is the
base.jsoncfile. It's a special file used only by the Consumer. In this case, Faststore is a Consumer and must maintain this base file. This must not be sent to the clients.This PR replaces the #2742
How it works?
This PR splits the sections.json and content-types.json file into many components.
It also adds a base.jsonc exclusive for Faststore (it must not be shared with the Developer).
The content CLI (CMS) can combine the files, generate an output, and send it to the Schema Registry.
The Faststore is the base schema for all Merchants. 🚀
How to test it?
Install the Content plugin and check the available commands
Migrate the sections from hCMS to the new CMS:
Migrate the content-types from hCMS to the new CMS:
When you are ready, you can generate the final output:
IMPORTANT: The Faststore Core Team is the only one that needs to add the
-l base.jsoncto the output. Merchants will automatically use the base from the Schema Registry.Finally, send the output schema to the Schema Registry 🚀
IMPORTANT: This command is equivalent to the hCMS cms-sync function.
References
Schema Registry for CMS (content platform)
Content Plugin CLI
Split command
Documentation
@Mariana-Caetanoto review and update (Or submit a doc request)