Repository navigation
refactor(registration): align questions payload with EVENT_REGISTRATION_QUESTIONS - #63
Merged
Merged
Conversation
Regenerated via `pnpm types:cms`. SahajCloud main has advanced broadly since the last sync — this refreshes ~20 interfaces (locale enums now include en-AU/ hu/nl and pt-BR casing, Region.eventDefaults dropped, User/Frame/Form/Client shape updates, and the Registration.questions doc comment now names the EVENT_REGISTRATION_QUESTIONS keys). Typechecks cleanly; we don't reference any of the removed/renamed fields. Done here so #60 can derive the registration-question key set from the freshly synced Event['registrationQuestions']. Refs #60 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…on keys The registration `questions` payload was typed loosely as `z.record(z.string())`. SahajCloud now validates it (PR sydevs/SahajCloud#594): keys must be EVENT_REGISTRATION_QUESTIONS members and values strings, else the register endpoint 400s. Align the client to that contract before it ships. - Derive `RegistrationQuestionName` from the synced `Event['registrationQuestions']` CMS type (not a hardcoded list). A `satisfies Record<RegistrationQuestionName, …>` on `RegistrationQuestionsSchema` fails the build if a `types:cms` resync adds or drops a question, and `REGISTRATION_QUESTION_NAMES` / `RegistrationQuestionNameSchema` derive from that schema's shape — one guarded source of truth. - Tighten `RegistrationSchema.questions` to `z.record(RegistrationQuestionNameSchema, z.string())`, which rejects unknown keys / non-string values client-side, mirroring the server. - Narrow `enabledQuestions()` and the RegistrationForm `questions` prop from `string[]` to `RegistrationQuestionName[]` so `register(\`questions.<name>\`)` stays type-checked against the tightened schema (behaviour unchanged — same ordered subset). - Cover the contract in the type tests: valid subset, empty-string answer (an enabled-but-unanswered question), omitted questions, unknown key, non-string value. Closes #60 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per the /simplify pass: `REGISTRATION_QUESTION_NAMES` *is* `Object.keys( RegistrationQuestionsSchema.shape)`, so asserting them equal compared a value to itself and could never fail. The concrete-list assertion already pins the key set + order. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas with
|
| Latest commit: |
70f9a3b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a16e8e76.sahajatlas.pages.dev |
| Branch Preview URL: | https://refactor-registration-questi.sahajatlas.pages.dev |
Ardnived
added a commit
that referenced
this pull request
Jul 21, 2026
Reconcile with two PRs that landed on main during this branch's Adjust phase: - #63 refactor(registration): align questions payload with EVENT_REGISTRATION_QUESTIONS — took its tightened `questions` typing (`z.record(RegistrationQuestionNameSchema, z.string())`) and the `RegistrationQuestionName[]` prop narrowing on RegistrationForm/RegistrationView, and took its fresh SahajCloud-main `payload-types.ts` resync over this branch's local-seed sync. Kept this branch's removal of the mailing-list `subscribe` field (1f0b768) — dropped #63's adjacent re-introduction of it. Updated the RegistrationForm "With questions" story to pass CMS question keys (referralSource, priorExperience) instead of free-text labels. - #59 docs(skills): workflow parity — merged cleanly with this branch's renamed molecules list in CLAUDE.md. Lean gate green after merge: lint + typecheck + 309 unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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
questionspayload with SahajCloud's newly-enforcedEVENT_REGISTRATION_QUESTIONScontract (sydevs/SahajCloud#594): keys must be one of the five known question names and values must be strings, otherwisePOST /events/:id/registernow returns 400.Event['registrationQuestions']— not a hardcoded list — and pinned with a compile-timesatisfiesguard, so a futurepnpm types:cmsresync that adds or drops a question fails the build rather than silently drifting.z.record(z.string())let arbitrary keys (including__proto__) pass client validation onto the wire; the tightened schema rejects unknown keys / non-string values client-side, mirroring the server.Changes
src/types/event.ts— deriveRegistrationQuestionNamefromEvent['registrationQuestions']; guardRegistrationQuestionsSchemawithsatisfies Record<RegistrationQuestionName, z.ZodTypeAny>; exposeREGISTRATION_QUESTION_NAMES+RegistrationQuestionNameSchema, both derived from that schema's shape (one guarded source of truth).src/types/registration.ts—questions: z.record(RegistrationQuestionNameSchema, z.string()).optional().src/views/RegistrationView/RegistrationView.tsx,src/components/organisms/RegistrationForm/RegistrationForm.tsx— narrow thequestionstype fromstring[]toRegistrationQuestionName[]soregister(\questions.`)` stays type-checked against the tightened schema (runtime behaviour unchanged — same ordered subset of enabled questions).src/types/payload/payload-types.ts—pnpm types:cmsresync from SahajCloudmain(committed separately aschore(types)); this refreshes the generatedEvent['registrationQuestions']type the derivation reads from.event.test.ts/registration.test.ts.Verification
pnpm lint)pnpm typecheck)pnpm test:run)Confirmation of the ticket's questions (issue #60)
questions: they come fromenabledQuestions(event), which iterates the CMS boolean set; now also enforced at the zod boundary.z.string().''(not an omitted key); SahajCloud accepts empty strings and drops blanks from the notification email. Covered by a test.Registration.questionsis still a loose Payload JSON field in the generated types even after #594 (only its doc comment updated), so the derivation reads fromEvent['registrationQuestions']instead — which carries the five typed keys.Notes for reviewer
payload-types.tsresync is large and cross-collection (locale enums,Region.eventDefaultsremoval, etc.) but it is generated, typechecks cleanly, and we reference none of the removed/renamed fields. Bundled here by request; it could alternatively land as its ownchore(types)PR.public/locales/*/events.jsonstill carries stalequestions.*label keys (aspirations,experience,referral,questions) that can no longer render now that only the five canonical names are emitted — safe to prune across locales separately.Closes #60
🤖 Generated with Claude Code