@frequencyads/db
v0.1.4
Published
The single entry point for typed Supabase clients. Apps import a client factory and get full autocomplete on `.from('table')`, column types, and RPCs with zero setup, because every client is pre-configured with the generated `Database` generic.
Keywords
Readme
@frequencyads/db
The single entry point for typed Supabase clients. Apps import a client factory
and get full autocomplete on .from('table'), column types, and RPCs with zero
setup, because every client is pre-configured with the generated Database
generic.
import { createServerClient } from '@frequencyads/db/server';
import { createBrowserClient } from '@frequencyads/db/client';
import type { Database } from '@frequencyads/db/types';Subpaths: ./server, ./client, ./config, ./cookies, ./prefix, ./types.
(./admin exists but must not be used in application code — it bypasses RLS.
See the root CLAUDE.md.)
Generated types
src/types.generated.ts holds the Supabase types. It is produced by
introspecting the local database (not the LinkML schemas) and is never
hand-edited — it is overwritten on every regeneration.
pnpm db:types # from the repo root — runs scripts/gen-types.mjsdbsync also runs the same generator automatically after every successful schema
sync, so the two paths can never drift. Both call scripts/gen-types.mjs, which
reads the schema list from scripts/type-gen-schemas.mjs.
Adding a new Postgres schema
The Postgres schemas to include in the generated types are listed in
scripts/type-gen-schemas.mjs (TYPE_GEN_SCHEMAS) — the single source of
truth shared by both db:types and dbsync.
When you add a new Postgres schema (e.g. audit, events), add its name to
TYPE_GEN_SCHEMAS and regenerate. A schema missing from that list is silently
omitted from the generated types — symptom: its tables have no
Database['<schema>'] entry, and RPCs returning their rows resolve to
unknown[].
