Create @workspace/schema package with Project and Task table definitions, Drizzle relations, Valibot validation schemas (select/insert/update), and wire as workspace dependency in API and Web apps.
1.9 KiB
1.9 KiB
Why
The schema package currently duplicates validation logic: Superstruct schemas mirror Drizzle table definitions by hand. This is error-prone (they can drift) and requires maintaining a separate validation/ and types/ module. Drizzle provides first-class Valibot integration (drizzle-orm/valibot) that derives insert/update/select schemas directly from table definitions, eliminating duplication entirely. Valibot is also tree-shakeable, which benefits the web app's bundle.
What Changes
- BREAKING: Replace Superstruct with Valibot across
@workspace/schema - Remove
packages/schema/src/validation/module (hand-written Superstruct schemas) - Remove
packages/schema/src/types/module (manual type re-exports no longer needed) - Add Valibot-derived schemas via
createInsertSchemaandcreateUpdateSchemafromdrizzle-orm/valibot - Add
valibotdependency; removesuperstructdependency - Update main barrel export in
src/index.ts - Validation schemas for enum fields (
status,priority) will usepicklist()refinements derived from the existing constant arrays indrizzle/enums.ts
Capabilities
New Capabilities
None — this is a modification of existing capabilities.
Modified Capabilities
validation: Hand-written Superstruct schemas → auto-derived Valibot schemas from Drizzle tablesshared-types: Manually maintained Infer types → inferred automatically from Valibot schemas viav.InferOutput
Impact
packages/schema/package.json— replacesuperstructwithvalibotin dependenciespackages/schema/src/validation/— entire directory removedpackages/schema/src/types/— entire directory removedpackages/schema/src/index.ts— exports change to drizzle tables + valibot schemas onlyapps/apiandapps/webimport from@workspace/schema— no import path changes, but consumers may need to adapt to new API if they used Superstruct directly