refactor(form-builder): drop custom purpose escape from schemas

Reduces the FormPurpose vocabulary from 22 variants + a `custom` escape
to the seven v1.0 purposes registered in the new PurposeRegistry.

- Purge migration deletes any form_schemas row whose `purpose` is not
  in the v1.0 set (cascades through form_fields, form_submissions,
  form_values, form_value_options, form_schema_sections,
  form_submission_section_statuses, form_submission_delegations,
  form_schema_webhooks, form_webhook_deliveries via existing FK).
- Drop migration removes the `custom_purpose_slug` column + its index.
- Both migrations declare their `down()` as a hard failure — we do not
  support reversing a purge (pre-launch, no production data).
- `FormPurpose` enum slims to the seven cases; the legacy helpers
  (defaultSubmissionMode / defaultSubjectType / allowsPublicAccess)
  now delegate to PurposeRegistry so callers keep working.
- FormSchema fillable / FormSchemaResource / StoreFormSchemaRequest /
  UpdateFormSchemaRequest / FormSchemaFactory drop every reference to
  `custom_purpose_slug` and the `custom` purpose.
- VerifyFormsDataIntegrity drops the custom-slug mismatch check and
  sources the subject-type allow-list from PurposeRegistry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-24 14:35:37 +02:00
parent e93207765b
commit b9343f6eec
9 changed files with 162 additions and 120 deletions

View File

@@ -30,7 +30,6 @@ final class StoreFormSchemaRequest extends FormRequest
'name' => ['required', 'string', 'max:150'],
'slug' => ['nullable', 'string', 'max:150'],
'purpose' => ['required', Rule::in(FormPurpose::values())],
'custom_purpose_slug' => ['nullable', 'string', 'max:150', 'required_if:purpose,custom'],
'description' => ['nullable', 'string'],
'is_published' => ['boolean'],
'submission_mode' => ['nullable', Rule::in(FormSubmissionMode::cases() ? array_map(fn ($c) => $c->value, FormSubmissionMode::cases()) : [])],

View File

@@ -26,7 +26,6 @@ final class UpdateFormSchemaRequest extends FormRequest
'name' => ['sometimes', 'string', 'max:150'],
'slug' => ['sometimes', 'string', 'max:150'],
'purpose' => ['sometimes', Rule::in(FormPurpose::values())],
'custom_purpose_slug' => ['nullable', 'string', 'max:150'],
'description' => ['nullable', 'string'],
'is_published' => ['sometimes', 'boolean'],
'submission_mode' => ['sometimes', Rule::in(array_map(fn ($c) => $c->value, FormSubmissionMode::cases()))],