Repository navigation
refactor(types): read the content block types from SahajCloud's generated schema - #294
Merged
Merged
Conversation
…ck interfaces lib/content-blocks.ts hand-mirrored the field shapes of every custom Lexical block, on the premise that payload-types.ts did not generate them. It does: TextBoxBlock, LayoutBlock, ImageGalleryBlock, ShowcaseBlock, ButtonBlock, QuoteBlock, TableOfContentsBlock, ContentIndexBlock, SubtleSystemBlock and SplashBlock are all exported there, and nothing read them. So `pnpm types:cms` could change a block upstream and no converter would notice. Each `*BlockFields` name is now an alias over the generated interface, minus the `id`/`blockName`/`blockType` envelope, and `ShowcaseItem`, `ShowcaseRelationTo`, `LayoutItem` and `TocHeading` are indexed out of them, so every existing import keeps compiling. ContentIndexBlockFields extends the generated block and keeps only its `type` union restated, because #293 widens that line; `extends` already refuses a member the schema lacks. Where the two disagreed, the generated type was checked against production (66 pages, every locale, depth 0 and the site's depth-3 populate) before it won: - textbox `image` and all twelve subtle-system relationships were optional and nullable by hand; the schema requires them, and every stored block carries them. The converters keep their runtime guards, since live preview renders a block before it is saved. - table-of-contents `headings` lost `| null`; every stored block has an array. Its entries gain the generated `[k: string]: unknown`. - textbox `textPosition`/`textColor` and a layout item's `id` gained `| null`, which the converters already absorb with `??`. - showcase entries become the generated discriminated union. No showcase block exists in production, so that one rests on the schema alone. - splash `textColor` is authored upstream now, so the note saying it was not goes with the hand-written interface. The subtle-system test fixture now names all twelve relationships, as the schema requires. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
…ader handles ContentIndexBlockFields restates `type` instead of deriving it, and `extends` only checks one direction: the restated union may not name a type the schema lacks. A type `pnpm types:cms` adds upstream would pass that check and reach neither the converter nor QUERY_BY_TYPE. Adding 'albums' to the generated union makes this assertion the only error tsc reports. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
…rges clean Deriving ContentIndexBlockFields from the generated block put an `extends` header and five deleted lines right beside the `type` union #293 widens, so the two branches conflicted in lib/content-blocks.ts. The interface body goes back to main's text, with a `shortcut:` to derive it once #293 lands. The type test now compares the whole stored shape both ways: `Omit<ContentIndexBlockFields, resolved*>` must equal the generated block minus its envelope. A field or content-index type the schema adds, drops or retypes fails tsc, which the `type`-only check missed for fields. The `resolved${string}` key filter leaves #293's resolvedMoods out, so the guard holds after that merge too. Also drops the dead `Ref<T>` export (no reader on main or any open branch), narrows the header's claim to what a derived type really catches, and corrects server/AGENTS.md: `pnpm types:cms` generates blocks and globals as well as collections. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | c0c22b6 | Commit Preview URL Branch Preview URL |
Nov 20 2026, 12:02 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-design | 3811d5b | Commit Preview URL Branch Preview URL |
Nov 19 2026, 11:59 PM |
This was referenced Nov 19, 2026
Open
Ardnived
requested changes
Nov 19, 2026
Contributor
Author
The `*BlockFields` aliases in `lib/content-blocks.ts` renamed interfaces `payload-types.ts` already exports, so a reader had to follow one more hop to learn what a converter casts to. Every consumer now imports the generated `*Block` interface itself. `TocHeading` goes the same way: the generated `TableOfContentsHeadings` is that array, and `TableOfContents` takes it. `ShowcaseRelationTo` had no consumer and is dropped. Two names stay, because the generated schema leaves the shape anonymous and there is nothing to import: `ShowcaseItem` beside the helper that maps it, and `LayoutItem` in `LayoutBlock`, whose props declare it. Both are indexed straight out of the generated interface. `SUBTLE_SYSTEM_NODE_IDS` was `Record<string, string>`, so a renamed relationship silently resolved to `undefined` and dropped its node. It now satisfies `Record<SubtleSystemField, string>`, which fails the build instead. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjX2WYRPpjwPSxNWYFL
Payload leaves a `layout` block's array member anonymous, so no consumer can import that shape from `payload-types.ts`. Moving the name into the component would have broken every open branch that reads it for nothing in return. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjX2WYRPpjwPSxNWYFL
Contributor
Author
|
Addressed the one open thread, on a freshly merged Adopted — don't re-export under new names. The nine Two things that fell out, both in the refreshed body:
Gate on 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Ardnived
approved these changes
Nov 20, 2026
sydevs-bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
…ofix `lib/content-blocks.ts` conflicted. #294 replaced the local `SplashBlockFields` with the generated `SplashBlock`, and this branch had only re-wrapped the old cast. The local type no longer exists, so main's line stands. The 24 files main brought in need no second mechanical commit: `pnpm lint` exits 0 on the merge as it stands. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXX3XS7FBnDYruefGT
sydevs-bot
pushed a commit
that referenced
this pull request
Nov 20, 2026
#294 replaced the hand-written `*BlockFields` interfaces with the generated `*Block` ones, so the ornament work now reads `TextBoxBlock` from `server/payload-types`. The `blockType` envelope comes with that interface, so `renderedTextBox` no longer intersects one in, and the decoration fixtures name it. Both sides' additions to the converter's import block and its `textbox` converter are kept: main's generated type, this branch's `parent` read and `textBoxDecorationAt` call. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWFS9Qzu3VyRSDarNq
This was referenced Nov 20, 2026
Closed
sydevs-bot
pushed a commit
that referenced
this pull request
Nov 21, 2026
main's only textual conflict was blockConverters.test.tsx's import block. main dropped `enT`, because #269 removed the ornate sidetext its one caller asserted. This branch widened the markup-helper import beside it. Both are kept: the helpers stay, `enT` goes, and nothing in the merged file reads it. The silent conflict was in lib/content-blocks.ts. main (#294) deleted the hand-written `*BlockFields` interfaces and moved every consumer to the generated `*Block` types, while this branch added `splashTitle` over `Pick<SplashBlockFields, 'layout' | 'title'>`. git merged both cleanly into a file naming a type that no longer exists. `splashTitle` now takes `Pick<SplashBlock, 'layout' | 'title'>`, the same move main made for `splashSurface` and `getLeadSplash`. The generated interface carries both fields with the same union, so the behaviour is unchanged. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVNeCVXMGgzzZjZ4n9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Nothing changes for a visitor or an editor. The JavaScript that
lib/content-blocks.tsemits is identical tomain's. The change is to types only.For a developer: the field types of the custom rich-text blocks (text box, quote, button, gallery, showcase, subtle system, splash, layout and table of contents) used to be copied by hand from SahajCloud into
*BlockFieldsinterfaces.pnpm types:cmsalready generates each one as a*Blockinterface inserver/payload-types.ts, so every reader now imports that interface directly and the hand copies are gone. When upstream renames or removes a block field, every converter that reads it fails to compile.Findings addressed
F10a: the block field types were hand-mirrored on a false premise.
lib/content-blocks.ts:5-9onmainsaid the block shapes are "not in the generatedpayload-types.ts". In factserver/payload-types.tsexports all ten of them (TextBoxBlock…SplashBlock), and nothing imported them.blockConverters.tsxcastsnode.fieldstoTextBoxBlock,QuoteBlock,ButtonBlock,ImageGalleryBlock,LayoutBlock,TableOfContentsBlock,ShowcaseBlock,SubtleSystemBlockandSplashBlock, imported fromserver/payload-types. The helpers inlib/content-blocks.tstake the same interfaces.LayoutBlockarrives asLayoutBlockSchemain the two files whose own molecule owns the unprefixed name.TocHeadingis gone. The generatedTableOfContentsHeadingsis that array, soTableOfContentstakes it as itsheadingsprop.ShowcaseRelationTois dropped. It had no consumer onmainor on any openclaude/*branch.ShowcaseItemandLayoutItem, both indexed straight out of the generated interface inlib/content-blocks.ts.SUBTLE_SYSTEM_NODE_IDSwasRecord<string, string>, so an upstream rename resolved toundefinedand silently dropped that node from the chart. It nowsatisfies Record<SubtleSystemField, string>, whereSubtleSystemFieldis keyed off the generated block, so a rename, an addition or a removal fails the build.server/AGENTS.md. Lines 150-154 repeated the same premise ("generates collection types only"). They now say the command generates the collection, global and block schema.ContentIndexBlockFieldsis the one type that is not a generated block. The server's pre-resolve pass in+dataattachesresolvedItemsandresolvedTracks, which the editor never stores, so this interface is app-side by nature. Its stored half stays hand-written while #293 edits the same lines, under ashortcut:line atlib/content-blocks.tsand the type testContentIndexBlockFields › restates exactly the stored fields the SahajCloud schema defines. That test assertsOmit<ContentIndexBlockFields, `resolved${string}`>equalsContentIndexBlockminus its envelope, andtscenforces it both ways. I checked thattscfails on that line, and only that line, in three cases:'albums'added to the generatedtypeunion, amoodFiltersfield added upstream, andapiEndpointremoved upstream.Where the generated and hand-written types disagreed. I checked each case against production before letting the generated type win: 66 pages, all 16 locales, read at depth 0 and at the site's depth-3 populate.
textbox.imageand all 12subtle-systemrelationships were optional by hand, but the schema requires them. All 55 production text boxes and the only subtle-system block carry them. The converters keep their runtime guards, because live preview renders unsaved blocks. ThesubtleSystemItemsfixture now names all 12 relationships, with bare ids for unpublished pages. Its expectations are unchanged.table-of-contents.headingslost| null. All 9 production blocks store an array. Entries gain[k: string]: unknown; production entries hold onlyslug,textandlevel.textbox.textPosition,textbox.textColorand the layout itemidgained| null. Production always has strings, and the converters already read them with??.importDatafield now. All 55 production text boxes have it, and no reader uses it.pageFiltersare strings, anduserChoiceFiltersandsongFiltersare numbers at both depths.Not in this PR
ContentIndexBlockFields. It should extendContentIndexBlockonce feat(components): a MeditationLibrary for the meditations index block #293 lands, and theshortcut:line marks that. Until then the type test keeps the two in step, including after that PR merges: theresolved${string}key pattern filters out itsresolvedMoods.ShowcaseBlock,SubtleSystemBlock,TextBoxBlockandSplashBlockstill claim fullPage,ImageandMeditationdocuments, whilePAGE_POPULATEnarrows them. The hand-written types made the same claim, so this is not a regression, and it is out of scope here.Reconciled with open PRs
I ran
git merge-treeof this branch against all 20 other open PRs, and type-checked the merged tree where one touches the same files.LayoutItemten times, which is why that name stays inlib/content-blocks.ts.TextBoxBlockFields→TextBoxBlock.LayoutBlockFields→LayoutBlock, and one ofSplashBlockFields→SplashBlock. ItscontentBlocks<ContentIndexBlockFields>is unaffected.getLeadSplashcast this PR rewrites, and carries oneSplashBlockFields.origin/mainis merged into this branch, cleanly, so the gate below ran on the merged tree.Test results
I ran the gate,
.claude/skills/pr-prep/check.sh, on the pushed headc0c22b6.tscpnpm buildThe warnings in the touched files are on lines this PR does not change: the prettier warnings in
lib/content-blocks.test.ts, theperfectionist/sort-jsx-propsone inblockConverters.tsx, and the unuseduseColumnsOnDesktopinLayoutBlock.tsx.🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjX2WYRPpjwPSxNWYFL