Skip to content

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).

  • BE-M0-25 is Done. You are on the branch tools/e2e-types-reference in ~/opleet-v2/opleet, git status --short prints nothing, and the stack is running with every migration applied.
Terminal window
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”
Terminal window
pnpm db:types
shasum -a 256 packages/db-types/src/database.ts
pnpm db:types
shasum -a 256 packages/db-types/src/database.ts

3 · Typecheck the package, and see what it exports

Section titled “3 · Typecheck the package, and see what it exports”
Terminal window
pnpm --filter @opleet/db-types typecheck
grep -nE '^export (type|const) ' packages/db-types/src/database.ts
Terminal window
git add package.json packages/db-types/src/database.ts
git commit -m "build(db-types): the first generated types from schema V13"
  • 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.
Terminal window
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”.

  • “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.