feat(forms): onboarding form/waiver step with required enforcement (Phase 4)

- scripts/027 (idempotent CHECK replace) + schema.sql Section 14: allow
  space_onboarding_steps.step_type = 'form'; referenced form id lives in
  the step's existing config.form_id (no new column)
- finishOnboarding: a required form step is satisfied when a submission
  for config.form_id by the member exists (any version — re-sign is
  non-blocking / auto-satisfy); fails open if the form is missing or
  unpublished so a misconfig cannot trap a member. Probe uses the
  service client (submissions are forms.manage-only under RLS)
- onboarding page enriches form steps with the published form def +
  prior-submission flag; onboarding-flow renders FormRenderer + waiver
  legal text/consent and submits via submitForm then marks the step done
- customize: forms fetched and threaded to the onboarding panel; new
  "+ Form step" button + form picker writing config.form_id
- validations/types/casts include 'form'; forms.test.ts +2
- docs: DATABASE_SCHEMA/DB_SCHEMA_MAP/API_REFERENCE/ARCHITECTURE/HANDOFF

287/287 tests, build exit 0. No deploy.
This commit is contained in:
Moheeb Zara
2026-05-16 15:15:17 -07:00
parent 01b924b2f5
commit 295d220849
16 changed files with 355 additions and 47 deletions
+4 -3
View File
@@ -422,10 +422,11 @@ forms + waivers).
### Forms & waivers (migration 026 — Phase 1: schema + RLS)
`forms` and `form_submissions` back a custom form/waiver builder. Phases 1-3
`forms` and `form_submissions` back a custom form/waiver builder. Phases 1-4
are done (schema + RLS; server actions in `lib/actions/forms.ts`; the builder
UI under `/forms` + the public `/f/[slug]` page). Onboarding integration and
automatic retro-linking are Phases 4-5. Security shape:
UI under `/forms` + the public `/f/[slug]` page; onboarding `form` step type
with required-waiver enforcement + auto-satisfy, migration 027). Automatic
retro-linking on email verification is Phase 5. Security shape:
all submissions (anonymous, public-authenticated, or members) are written by a
single validated server action using the service client AFTER server-side
schema validation and snapshotting (same pattern as `finishOnboarding`); the