Skip to content

v3.0.0 — TypeScript port

Choose a tag to compare

@SamMaxwell SamMaxwell released this 09 Apr 21:41

TypeScript port of v2.x. No API changes — same default connect export, same withClient, updateMutation, and friendlyError. Consumers upgrade by swapping @mabulu-inc/db@smplcty/db.

What changed

  • Source is now TypeScript (src/*.ts), compiled to dist/ via tsc. Type declarations ship in the package.
  • pg is now a peer dependency (was a direct dep). Install pg in the consuming service.
  • No more dotenv. Load .env at the edge of your application, not inside a library.
  • Tests migrated to vitest — unit tests for updateMutation and friendlyError, integration tests against a real Postgres (docker-compose locally, service container in CI) for withClient and friendlyError round-tripping real pg error codes.
  • withClient is now generically typedwithClient<T>(pool, fn) infers T from the callback's return type.
  • updateMutation exports a FieldSpec tuple type so consumers get type-checked fieldsets.
  • friendlyError exports PgErrorLike, ERROR_CODES, and MESSAGES so consumers can extend or override the mapping.
  • CI and publish workflows matching the fleet baseline: lint, typecheck, gitleaks full-history scan, build, tests against a Postgres service container, OIDC trusted publishing with provenance, and a non-blocking pnpm outdated advisory.

Scope

@smplcty/db stays a thin pg helper. It does not know about sessions, roles, RLS, or GUCs — that layering lives in @smplcty/auth via withSession. Use withClient for background jobs and migrations; use withSession for anything that talks to tenant data.

Migration

  1. pnpm remove @mabulu-inc/db && pnpm add @smplcty/db
  2. Ensure pg is a direct dependency of your service (was previously transitive).
  3. If you were relying on the package to load .env, switch to node --env-file=.env or load dotenv explicitly at your entry point.
  4. Update imports from @mabulu-inc/db to @smplcty/db.