Skip to content

chore(types): re-sync payload types past SahajCloud's intake cutover - #117

Merged
sydevs-bot merged 7 commits into
mainfrom
claude/chore-116-resync-payload-types
Sep 18, 2026
Merged

sydevs-bot merged 7 commits into
mainfrom
claude/chore-116-resync-payload-types

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • pnpm types:cms re-syncs server/payload-types.ts, dropping the four collections SahajCloud#801 merged into user-submissions.
  • The re-sync broke pnpm typecheck, which the ticket predicted it would not. Fixed by deriving WebTranslations from the select it was duplicating.
  • FormBuilder's two examples and its onSubmit prop doc stop naming the deleted /api/form-submissions, and now post to a route this app would own rather than to the CMS.

Changes

  • server/payload-types.ts — regenerated, byte-identical to SahajCloud main with the declare module 'payload' block stripped.
  • server/cms-types.ts — hosts WEB_TRANSLATIONS_SELECT; WebTranslations is now Pick<…, keyof typeof WEB_TRANSLATIONS_SELECT>.
  • server/cms-client.ts — imports that constant instead of declaring it.
  • components/organisms/FormBuilder/FormBuilder.tsx, README.md — the example posts to /api/submissions, and both say the CMS key is server-side only.
  • docs/rules/rest-api.md — says where the select lives, that the type derives from it, and that sync-translations.mjs is the one list that does not.

Preview

Both built green on 7cfee27. This push is docs-only on top of it.

Contract impact

Consumes SahajCloud's generated types. sydevs/SahajAtlasWeb#214 is the same drift in the other consumer, where it is a live break rather than quiet staleness. This PR is types only and changes no request this repo sends.

Test results

  • Lean gate: ✓ lint, tsc --noEmit, vitest run (70 files, 655 tests)
  • Targeted specs: none added — the change is type-level and doc-level
  • Build: ✓ pnpm build

Manual verification

  1. Open any page in the Cloudflare preview and confirm UI strings still render (the translations select moved files).
  2. Confirm the FormBuilder story description in Ladle shows the /api/submissions example.

Notes for reviewer

The ticket's central claim was wrong, and that is the judgement call worth checking. It stated the re-sync needed no code change. It does: upstream added a video translations group, WEB_TRANSLATIONS_SELECT does not fetch it, and WebTranslations required every group, so return translations as WebTranslations stopped compiling. Acceptance criterion 3 ("no file outside payload-types.ts and the two FormBuilder docs changes") cannot hold. I fixed it rather than handing the ticket back, and widened the diff by three files.

Why derive instead of excluding video. Two reviews independently flagged that adding 'video' to the Omit list just re-synchronises two hand-maintained lists. AGENTS.md states the opposite convention twice (lib/hreflang.ts, lib/urls.ts: one owner, "so the two cannot disagree"). Deriving retires the failure instead of paying it again on the next upstream group.

Trade-off this accepts: with Pick, a new upstream group no longer forces a compile error — it is simply not offered until someone adds it to the select. satisfies WmWebTranslationsSelect<true> still errors on a renamed group. If you would rather keep the hard stop on additions, say so and I will go back to the explicit list.

The submission example named a route that does not exist. server/api-routes.ts registers the live-preview populate path and two related-content paths, and nothing else, so /api/user-submissions 404s on this origin. The CMS grants user-submissions create to the wemeditate-web-client key alone, which carries no PUBLIC__ prefix and must not reach a browser. /api/form-submissions was wrong the same way, so the flaw is inherited, but the line was rewritten here. The example now posts to a route this app owns and names server/api-routes.ts as its home. Nothing registers that route yet — no page in this repo supplies onSubmit, so nothing is broken today, and wiring a real submission route is its own ticket.

Dismissed findings:

  • Add video to NON_GROUP_KEYS in scripts/sync-translations.mjs — rejected. That set names document metadata (id, _status, …), not groups the site skips. Adding a real group there conflates the two.
  • Replace the JSDoc @example with a pointer to README.md — rejected. It is the component's API doc; removing a working example to avoid duplication costs the reader more than the duplication does.
  • Have sync-translations.mjs filter by WEB_TRANSLATIONS_SELECT — not taken. The script is plain node with no TypeScript loader, so it cannot import the constant, and adding one widens a types chore into tooling. The rule now names the mirror as the exception instead.
Detail

Verification against the ticket's checklist

  • git diff --stat server/payload-types.ts → 576 insertions, 575 deletions. The ticket predicted 558/557 against 07e3e40; SahajCloud main has moved since.
  • Byte-identity re-checked against raw.githubusercontent.com/sydevs/SahajCloud/refs/heads/main/src/payload-types.ts after every later commit.
  • grep -nE "'(event-submissions|user-messages|form-submissions)'" → nothing. The four dead types (Registration, EventSubmission, UserMessage, FormSubmission) are gone.
  • The ticket's \bregistrations: grep does not return nothing, and should not: collectionsJoins.events.registrations: 'user-submissions' is the join field on Event, pointing at the new collection. That criterion was written against the old shape.
  • grep -rn "form-submissions" components/ → nothing.

Why the example body changed shape. UserSubmission requires type ('contact' | 'subscribe' | 'registration' | 'proposal') and carries answers under submissionData. FormBuilderSubmission already supplies form and submissionData, so the example spreads it and adds type.

Pre-existing mismatch, not fixed here: FormBuilderSubmission.form is string while UserSubmission.form is number | Form, and submissionData[].value is string | boolean | number here vs string in the CMS. No page in this repo supplies onSubmit, so nothing exercises either.

What the snapshot mirror costs. scripts/sync-translations.mjs:107 keeps every response key outside NON_GROUP_KEYS, so the next pnpm sync:translations writes the 41 video.* keys into lib/translations.en.json. They are dead weight and nothing more: EN_TRANSLATIONS is cast to WebTranslations, which derives from the select, so no unfetched group becomes addressable through useT().

Not run, deliberately: pnpm sync:translations. It fetches the whole global with no select, so it would pull those keys in and turn a types chore into an i18n change. Wiring the player to useT is the ticket's open question.

Security review: ran (the diff matches ^server/). No findings. The live-preview populate allowlist (COLLECTION_BY_ID_CONFIG) is a hand-written literal of three slugs and is not derived from the generated Config, so user-submissions and its PII fields stay unreachable. getWebTranslations sends a byte-identical request.

Closes #116

🤖 Written by the sydevs autonomous loop — see what this is

🤖 Generated with Claude Code

https://claude.ai/code/session_017298GTLqXj1XHr2bvWv7bc

`pnpm types:cms` against SahajCloud main. SahajCloud#801 merged
`registrations`, `event-submissions`, `user-messages` and
`form-submissions` into one `user-submissions` collection, and this
repo's copy still declared all four.

The re-sync also adds a `video` translations group upstream, which
`WEB_TRANSLATIONS_SELECT` does not fetch. `WebTranslations` marks every
group required, so the assertion in `getWebTranslations` stopped
compiling. Excluding `video` from the type keeps it describing what the
site actually reads, and keeps `t('video.…')` keys out of
`TranslationKey` until the player is wired to `useT`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QuGTovRApxWuW3PARMJLFp
Both the JSDoc `@example` Ladle renders and the README Usage block POST
to `/api/form-submissions`, which no longer exists. `UserSubmission`
also requires `type`, so swapping the path alone would leave a body the
collection rejects.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QuGTovRApxWuW3PARMJLFp
`WEB_TRANSLATIONS_SELECT` and `WebTranslations` both answered "which
translation groups does this site have", and the re-sync made them
disagree: upstream added a `video` group the site does not fetch, and
the type demanded it.

Moving the select into cms-types.ts and deriving the type from it leaves
one answer. cms-client.ts already imported from cms-types.ts, so the
dependency stays one-way. The `Pick` also drops the metadata keys the
`Omit` had to name.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QuGTovRApxWuW3PARMJLFp
The `onSubmit` prop doc still named the deleted collection, five lines
from the example that no longer does.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QuGTovRApxWuW3PARMJLFp
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Deploying wemeditate-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8b53875
Status: ✅  Deploy successful!
Preview URL: https://8a7c567b.wm-design.pages.dev
Branch Preview URL: https://claude-chore-116-resync-payl.wm-design.pages.dev

View logs

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 18, 2026
@sydevs-bot

sydevs-bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 17:29Z address-review · attempt 1 · session · done
  • 17:29Z address-review · attempt 1 · session
  • 17:21Z adversarial-review · attempt 1 · session · done
  • 17:21Z adversarial-review · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-web 8b53875 Commit Preview URL

Branch Preview URL
Sep 18 2026, 05:35 PM

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

The re-sync is right, and the widening past the ticket is earned. Deriving WebTranslations from WEB_TRANSLATIONS_SELECT buys more than the body claims: under the old Omit, video would have entered TranslationKey, so t('video.general.play') would compile and render as its key path (lib/i18n.ts:199).

The gap is the producer's other half. The FormBuilder examples were repointed from SahajCloud's new schema without reading its access rules.

Findings

  • should-fix — the rewritten @example POST is unauthenticated and same-origin. Neither works. FormBuilder.tsx:248, README.md:35.
  • consider — the new rule promises one owner of the list, yet a third list survives. docs/rules/rest-api.md:69.

What was checked

  • AC 1 ✓ stripped SahajCloud main (9669347) vs this branch's payload-types.ts: byte-identical. AC 2 ✓ no dead slug or type survives.
  • SahajCloud roles.ts:95, plugins/formBuilder/index.ts; here, lib/i18n.ts and server/api-routes.ts, which registers no submissions path.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread docs/rules/rest-api.md Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 18, 2026
sydevs-bot and others added 2 commits September 18, 2026 17:33
The rewritten @example posted to `/api/user-submissions` from the browser.
Neither half works: `server/api-routes.ts` registers no such path, and the
CMS grants `user-submissions` create to the `wemeditate-web-client` key,
which has no `PUBLIC__` prefix and must not reach a browser.

The example now posts to a route this app owns, and says which file would
own it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017298GTLqXj1XHr2bvWv7bc
The new rule promised one owner of the group list while a third list
survived in `sync-translations.mjs`. That script is plain node and cannot
import a TypeScript constant, so the mirror stays. Naming it, and what it
costs, is what the rule owed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017298GTLqXj1XHr2bvWv7bc
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both adversarial-review threads adopted. Pushed 8b53875.

  • should-fix — the @example POST → e3b4c37. It posts to /api/submissions, a route this app owns, and says the CMS key is server-side only. README.md matches.
  • consider — the surviving third list → 8b53875. The rule now names sync-translations.mjs as the one mirror that does not derive from the select.

Not taken: filtering that script by WEB_TRANSLATIONS_SELECT. It is plain node and cannot import a TypeScript constant.

Lean gate green: lint, tsc --noEmit, 655 tests. PR body refreshed.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 18, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 18, 2026 17:37
@sydevs-bot
sydevs-bot requested a review from Ardnived September 18, 2026 17:37
@sydevs-bot
sydevs-bot added this pull request to the merge queue Sep 18, 2026
Merged via the queue into main with commit bf5b82f Sep 18, 2026
30 of 32 checks passed
@sydevs-bot
sydevs-bot deleted the claude/chore-116-resync-payload-types branch September 18, 2026 19:10
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Sep 18, 2026
sydevs-bot pushed a commit that referenced this pull request Sep 18, 2026
#117 landed the same payload-types re-sync this branch carries, and answered
the new upstream `video` translations group differently. It moved
`WEB_TRANSLATIONS_SELECT` into `cms-types.ts` and derives `WebTranslations`
from it, so the query and the type have one owner. Took that structure and
dropped this branch's `video: true`, which existed only to satisfy the old
all-groups-required assertion that #117 removed. Nothing reads `video.*`.

FormBuilder's JSDoc and README conflicted on prose describing the `onSubmit`
prop and `FormBuilderConfig`, both deleted on this branch. Kept this branch's
docs: #117's substantive point — stop naming the deleted
`/api/form-submissions` and forward through a route this app owns — is what
`server/api-routes.ts` implements here as `POST /api/submissions`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014voCFQ728iowXEZwFzw42N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

chore(types): re-sync payload types past SahajCloud's intake cutover

3 participants