Skip to content

fix(blocks-cli): keep _-prefixed props and $ref recursive types in the CMS schema - #637

Merged
aline-pereira merged 4 commits into
mainfrom
fix/schema-underscore-props-and-recursive-refs
Oct 8, 2026
Merged

aline-pereira merged 4 commits into
mainfrom
fix/schema-underscore-props-and-recursive-refs

Conversation

@aline-pereira

@aline-pereira aline-pereira commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

generate-schema drops or collapses props that deco-cx/deco (Fresh) emits, so a migrated site's admin loses fields its production admin has. Found while validating the Oficina Reserva PLP (deco-sites/oficina-tanstack#475) against the Fresh /deco/meta.

  1. _-prefixed props kept (fix(blocks-cli): keep _-prefixed props). The generator skipped every prop starting with _, so __title (labels of FAQ entries and pathRules) and _id (the regulation picker on notification bars / banners) vanished from the form. Only __resolveType is skipped now. String literals also carry default next to const, as deco-cx/deco does (all 479 consts in the Fresh meta have it).
  2. Recursive types referenced (fix(blocks-cli): reference recursive types). interface NavigationPillLink { submenu?: NavigationPillLink[] } hit the cycle guard and became { type: "object", nullable: true }, so the submenu was edited as an object instead of a list. The cycle now emits a $ref to <file id>@<TypeName>, registered by the outer occurrence. Anonymous/generic types keep the old fallback. A JSDoc tag written with a colon (@description: text) is ignored, as deco-cx/deco's /@(\w+)\s+/ does, instead of becoming ": text".
  3. Hidden prop with a default stays required, matching deco-cx/deco (e.g. /** @hide true */ __title: "…").
  4. apps-vtex: __pagePath / __pageUrl are marked @ignore — they are resolver-injected, and with (1) they would otherwise show up as editable fields on every PLP loader.

Evidence

  • generate-schema.test.ts: 44/44, 6 new tests; 3 of them fail against the current generator.
  • blocks-cli and apps-vtex suites pass (three subprocess-spawning files can hit the 5 s timeout when run in parallel; 15/15 in isolation). No new tsc/lint errors.
  • On oficina-tanstack, schema points diffed against production /deco/meta: 15 differences across 13 types → 0 (FAQList, PathRules, NotificationBarType, Banner/BannerType, Regulation*, ConditionalPageInfoAndSEO, page-not-found Props, RichContentDBProps, NavigationPillLink). The served /deco/meta from a preview build also diffs to 0, with no dangling $ref.
  • Side effects, all toward deco-cx/deco output: some commerce cycles (image↔video, FilterToggle) now $ref instead of collapsing, and Sanity _-fields reappear.

Not fixed here: #568 (inline FAQ values), auto titles from the type name, @type.

🤖 Generated with Claude Code


Summary by cubic

Fixes generate-schema so migrated sites keep fields their production admin has: _-prefixed props were dropped entirely, and recursive types collapsed to a bare object, losing editable data like FAQ labels, regulation pickers, and navigation submenus.

  • Only __resolveType (the framework's block-reference discriminator) is skipped now; __title, _id, and hidden literal discriminators like __type: "image" are emitted.
  • String literals carry default next to const, as deco-cx/deco does, so the admin writes discriminator values into new entries.
  • Recursive named types (for example interface Link { submenu?: Link[] }) emit a $ref to a shared definition instead of { type: "object" }; anonymous and generic types keep the old fallback.
  • Hidden props with a default stay in required; hidden props without one stay optional.
  • A JSDoc tag with a colon after the name (@description: text) is ignored rather than turned into a description starting with ": ".
  • packages/apps-vtex marks the resolver-injected __pagePath / __pageUrl as @ignore so they never appear as editable fields.

Schema diff against a production /deco/meta on a migrated site drops from 15 differences across 13 types to 0.

Written for commit 6cb3bfa. Summary will update on new commits.

View guided diff Turn on auto-fix

aline-pereira and others added 4 commits October 8, 2026 08:53
…e CMS form

The PLP loader declares `__pagePath` and `__pageUrl` on its Props for
the resolver to fill in. They stay out of the admin today only because
the schema generator drops every `_`-prefixed prop, which also drops
real user data (`__title`, `_id`) and is fixed next. Mark these two
`@ignore` so the admin never offers them as editable fields on a PLP
loader.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
generate-schema skipped every property whose name starts with `_`. Those
are user data in deco-cx/deco sites, and the Fresh admin edits them:

- `__title` labels a list entry (`@title {{__title}}` on FAQ lists,
  PathRules, notification bars, banners) — the label kept rendering
  from the saved value but could no longer be edited;
- `_id` on a regulation is a `dynamic-options` picker — without it the
  admin cannot choose which regulation a bar or banner shows;
- hidden literal discriminators (`/** @hide true */ __type: "image"`)
  the components branch on.

Skip only `__resolveType`, the block-reference discriminator the
framework owns. Also emit `default` next to the `const` of a string
literal, as deco-cx/deco does for all 479 `const`s in a production
/deco/meta: that is what makes the admin write the discriminator into
a new entry.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A recursive prop type (`interface NavigationPillLink { submenu?:
NavigationPillLink[] }`) hit the generator's cycle guard and came out
as `{ type: "object" }`, so the admin edited the submenu as an object
instead of a list of links. deco-cx/deco emits such a type once as a
definition and `$ref`s it from inside the cycle.

When the cycle guard fires, look through the array / `| null` wrapper
it fired on and, for a named object type, emit a `$ref` to
`<file id>@<TypeName>`; the outer occurrence of the type registers that
definition when it finishes. Every pass now shares one definitions
sink, including site and app loaders, which had no context before.
Anonymous and generic types keep the old `{ type: "object" }` fallback.

Also ignore a JSDoc tag written with a colon (`@description: text`).
deco-cx/deco reads tags with /@(\w+)\s+/, so such a tag never reached
the admin; the TS parser turned it into a description starting with
": ".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Hidden props were always dropped from `required` so the form could not
deadlock on a field the user cannot see. A hidden literal now carries
its value as `default` (the admin fills it in), so there is no deadlock
to avoid, and deco-cx/deco lists it as required — e.g. the
`/** @hide true */ __title: "…"` that keeps a loader's props distinct
from its return type. Hidden props without a default stay optional.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@aline-pereira
aline-pereira requested a review from a team October 8, 2026 12:51
@aline-pereira
aline-pereira merged commit 93bcd05 into main Oct 8, 2026
1 check passed
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 7.77.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants