BE-M0-26 · pnpm db:types and the first generated types
ID BE-M0-26 · Level L0 · Pack Pack E · Logins, types and the acceptance check · Run order row 22 · Issue #14
pnpm db:types writes the public schema's types from the local database into packages/db-types/src/database.ts (D4, D22), replacing the placeholder; the first generated types typecheck and are committed (FE-R1).
Before
Section titled “Before”- BE-M0-25 is Done. You are on the branch tools/e2e-types-reference in ~/opleet-v2/opleet,
git status --shortprints nothing, and the stack is running with every migration applied.
1 · The root script
Section titled “1 · The root script”pnpm pkg set 'scripts["db:types"]=supabase gen types typescript --local --schema public > packages/db-types/src/database.ts'2 · Write the types, then write them again to show the output is stable
Section titled “2 · Write the types, then write them again to show the output is stable”pnpm db:typesshasum -a 256 packages/db-types/src/database.tspnpm db:typesshasum -a 256 packages/db-types/src/database.ts3 · Typecheck the package, and see what it exports
Section titled “3 · Typecheck the package, and see what it exports”pnpm --filter @opleet/db-types typecheckgrep -nE '^export (type|const) ' packages/db-types/src/database.ts4 · Commit
Section titled “4 · Commit”git add package.json packages/db-types/src/database.tsgit commit -m "build(db-types): the first generated types from schema V13"Expect
Section titled “Expect”- Block 1 prints nothing.
- Block 2: the same hash twice. pnpm prints the script line; the file starts with
export type Json =. - Block 3: tsc prints nothing. The exports include the types Json, Database, Tables, TablesInsert, TablesUpdate and Enums, and one value:
export const Constants, which lists every enum's values. Paste this block's output in the run log: it settles FE-R1. - Block 4: Lefthook runs Biome on package.json (database.ts is excluded in biome.json) and shows ✔️ commitlint, then the commit line with 2 files changed.
pnpm db:types && git diff --exit-code packages/db-types && echo "types are current"git log --oneline -1“types are current”, then “build(db-types): the first generated types from schema V13”.
If it fails
Section titled “If it fails”- “Cannot connect to the Docker daemon” or “supabase start is not running”: start Docker Desktop and the stack (
pnpm supabase start), then block 2 again. - The file is empty or holds an error message: don't commit. Paste the first lines of the file and the output of
pnpm supabase --version. - tsc reports errors: paste them. Don't commit.
Not committed yet: git checkout -- package.json packages/db-types/src/database.ts. Committed: git reset --hard HEAD~1. Nothing has been pushed.
Not run yet. Log each run as a comment on #14.