Moheeb Zara
|
897fa30ec1
|
feat(forms): server actions, Zod schemas, and dynamic answer validation (Phase 2)
- lib/validations.ts: form field/array schemas (8 field types,
duplicate-key and select-options refinements) and create/update/
status/submit/link envelope schemas; slug immutable on update
- lib/forms-schema.ts: pure parseFormSchema + validateAnswers; unknown
answer keys are discarded so a caller cannot inject arbitrary jsonb
- lib/actions/forms.ts: create/update/setStatus/delete/list/results/
CSV export (forms.manage via user_has_permission + RLS), submitForm
(service-client read+write, visibility + waiver consent enforced,
schema/legal/version snapshot, IP/UA capture), and
linkSubmissionsForMember (manual admin link; auto path is Phase 5)
- updateForm bumps a published waiver's version on legal/schema change
(non-blocking; existing submissions stay valid against their snapshot)
- deleteForm refuses when submissions exist (immutable records)
- types/database.ts: type user_has_permission/user_effective_roles
(stale since migration 023)
- __tests__/forms.test.ts (14); API_REFERENCE + HANDOFF updated
285/285 tests, build clean. No deploy.
|
2026-05-16 14:51:20 -07:00 |
|