work-hub-server/openspec/changes/add-shared-schema-package/tasks.md
Nicolas HOARAU 9314e72f3e feat(schema): add shared schema package with Drizzle ORM and Valibot validation
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.
2026-06-04 12:46:51 +04:00

39 lines
2.2 KiB
Markdown

## 1. Package scaffolding
- [x] 1.1 Create `packages/schema/package.json` with name `@workspace/schema`, private: true, and TypeScript build script
- [x] 1.2 Create `packages/schema/tsconfig.json` extending the API's config pattern (nodenext, ES2023, strictNullChecks, declaration)
- [x] 1.3 Add `drizzle-orm`, `superstruct`, and `@types/node` as dependencies in the new package
- [x] 1.4 Create `packages/schema/src/index.ts` barrel file re-exporting from sub-modules
- [x] 1.5 Add `@workspace/schema` as a workspace dependency in `apps/api/package.json`
- [x] 1.6 Add `@workspace/schema` as a workspace dependency in `apps/web/package.json`
- [x] 1.7 Verify `pnpm install` resolves the workspace dependency and `pnpm build` compiles the package
## 2. Drizzle schema definitions
- [x] 2.1 Create `packages/schema/src/drizzle/` directory structure
- [x] 2.2 Define `pgEnum` exports for any PostgreSQL enums needed
- [x] 2.3 Define initial Drizzle tables with `pgTable`, proper column types, constraints, and defaults
- [x] 2.4 Define `relations()` between tables for relational queries
- [x] 2.5 Export all table definitions, enums, and relations from the Drizzle sub-module barrel
## 3. Superstruct validation schemas
- [x] 3.1 Create `packages/schema/src/validation/` directory structure
- [x] 3.2 Define Superstruct schemas for data shapes, with proper type constraints
- [x] 3.3 Support nested/optional/defaulted fields via Superstruct combinators
- [x] 3.4 Export all validation schemas from the validation sub-module barrel
## 4. Shared TypeScript types
- [x] 4.1 Create `packages/schema/src/types/` directory structure
- [x] 4.2 Export `InferSelectModel` and `InferInsertModel` types derived from all Drizzle tables
- [x] 4.3 Export `Infer` types derived from all Superstruct schemas
- [x] 4.4 Re-export all types through the top-level `src/index.ts` barrel
## 5. Wire into monorepo
- [x] 5.1 Verify Turborepo topological build order — `turbo.json` `^build` should already handle `schema``api`/`web`
- [x] 5.2 Run `pnpm build` from root to confirm clean compilation
- [x] 5.3 Run `pnpm --filter=api test` to confirm no regressions
- [x] 5.4 Run `pnpm check-types` to confirm type-checking passes across all workspaces