Files
suaveplan/openspec/archive/2026-05-25-enterprise-form-builder/tasks.md
2026-05-27 23:29:53 +01:00

124 lines
5.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Tasks — enterprise-form-builder
> Tick each box as work lands. Every requirement in `specs/form-builder/spec.md` is reflected
> below. **Never silently skip a requirement because "tests already pass without it."**
## 1. Scaffold
- [ ] Create `packages/ui/forms/form-builder/` (package.json `0.1.0`, tsconfig.lib.json,
vite.config.ts, vitest.config.ts, tests/setup/polyfills.ts).
- [ ] Add canonical subpath exports in `package.json` for every feature module.
- [ ] Add catalog deps (`@opentelemetry/api`, `zod`, `tslib`).
## 2. Types & constants
- [ ] `src/types/form.types.ts` — `FieldType`, `FieldDefinition`, `FormSection`, `FormSchema`,
`FormValues`, `FormState`, `FormEventMap`, `ValidationRule`, `ValidationError`,
`ConditionalRule`, `SelectOption`, `LeafOperator`.
- [ ] `src/constants/index.ts` — `FIELD_TYPES`, `LEAF_OPERATORS`, `BUILT_IN_RULES`,
`DEFAULT_UNDO_CAPACITY`.
## 3. Errors
- [ ] `src/errors/form-error/form-error.ts` — `FORM_BUILDER_CODES` (`defineCodes`), `FormError`
extends `SuaveplanError<FormBuilderCode>`; factory helpers `fieldNotFound`,
`sectionNotFound`, `duplicateId`, `configInvalid`, `validationFailed`, `cyclicDependency`.
- [ ] `form-error.test.ts` — every factory + code reachable.
## 4. Schema (Zod boundary)
- [ ] `src/schema/schema/schema.ts` — Zod schemas for `FieldDefinition`, `FormSection`,
`FormSchema`, `ValidationRule`, `ConditionalRule`; `parseFormSchema(raw)`.
- [ ] `schema.test.ts` — valid + invalid inputs raise `FORM_BUILDER.CONFIG_INVALID`.
## 5. Field registry
- [ ] `src/fields/field-registry/field-registry.ts` — `FieldRegistry` class, 17 built-in field
types registered out-of-the-box; `register`, `unregister`, `has`, `get`, `list`.
- [ ] `field-registry.test.ts`.
## 6. Validators
- [ ] `src/validation/validators/validators.ts` — 11 rule runners
(`required`, `minLength`, `maxLength`, `min`, `max`, `pattern`, `email`, `url`, `oneOf`,
`equalsField`, `custom`); async-friendly contract via `Promise<ValidationError | null>`.
- [ ] `validators.test.ts`.
## 7. Validation engine
- [ ] `src/validation/validation/validation.ts` — `runFieldValidation`, `runFormValidation`,
`AbortSignal` propagation, OTel counter + histogram emission.
- [ ] `validation.test.ts`.
## 8. Conditional logic
- [ ] `src/conditional/conditional/conditional.ts` — `evaluateConditional(rule, values)`; 9 leaf
operators + `and` / `or` / `not`.
- [ ] `conditional.test.ts`.
## 9. Dependency graph
- [ ] `src/conditional/dependency-graph/dependency-graph.ts` — `DependencyGraph`: build from
fields, topo sort, cycle detection (`FORM_BUILDER.CYCLIC_DEPENDENCY`).
- [ ] `dependency-graph.test.ts`.
## 10. State + undo/redo
- [ ] `src/state/form-state/form-state.ts` — `FormState` machine: `setValue`, `setValues`,
`touch`, `reset`, dirty + valid flags.
- [ ] `src/state/undo-redo/undo-redo.ts` — bounded `UndoRedoStack`.
- [ ] `form-state.test.ts`, `undo-redo.test.ts`.
## 11. Serialise + Zod-schema generator
- [ ] `src/serialise/serialise/serialise.ts` — `serialiseForm` / `deserialiseForm`; versioned
wire format with Zod validation on `deserialiseForm`.
- [ ] `src/zod-schema/zod-schema/zod-schema.ts` — `toZodSchema(form)`.
- [ ] Round-trip + cross-check tests.
## 12. Submission
- [ ] `src/submission/submission/submission.ts` — `submit({ form, values, submitter, signal })`;
`prepare → validate → transform → submit`; OTel counter + histogram emission.
- [ ] `submission.test.ts`.
## 13. OTel instruments
- [ ] `src/otel/instruments/instruments.ts` — lazy `Counter`s + `Histogram`s.
- [ ] `instruments.test.ts` — every instrument emits at least once under a real
`MeterProvider` from `@opentelemetry/sdk-metrics`.
## 14. Builder
- [ ] `src/builder/form-builder/form-builder.ts` — `FormBuilder<TEvents>` aggregating the above;
`createSchema`, `addField`, `removeField`, `updateField`, `addSection`, `removeSection`,
`getField`, `getSchema`, `validateField`, `validateForm`, `getVisibleFields`, `setValues`,
`resetForm`, `getState`, `toJSON`, `getSectionById`, `enableHistory`, `undo`, `redo`,
`submit`. EventBus emission.
- [ ] `form-builder.test.ts` — every behaviour scenario from the spec delta.
## 15. README + barrel
- [ ] Package `README.md` (purpose, install, full feature list, examples).
- [ ] `src/index.ts` — explicit named re-exports per §6a.
## 16. Pre-publish gate
- [ ] `bunx turbo lint typecheck test build --filter=@suaveplan/form-builder` green.
- [ ] `bunx turbo test:coverage --filter=@suaveplan/form-builder` — 100 / 100 / 100 / 100.
- [ ] `grep -rnE "from ['\"](vitest|bun:test)['\"]" packages/ui/forms/form-builder/src/` zero.
- [ ] `grep -rnE "biome-ignore" packages/ui/forms/form-builder/src/` zero.
## 17. Refresh & archive
- [ ] `bun scripts/folder-reorg/generate-manifest.ts` to refresh `MANIFEST.md`.
- [ ] Flip `@suaveplan/form-builder` row in `STATUS.md` from `–` to `✅`; update counter
(+1 migrated / -1 pending).
- [ ] Fold `specs/form-builder/spec.md` into `openspec/specs/form-builder/spec.md`.
- [ ] Move change folder to `openspec/archive/2026-05-25-enterprise-form-builder/`.
## 18. Commit
- [ ] Branch `feat/migrate-form-builder`; conventional commit; Claude co-author footer; **do
not push**.