feat(supabase): clients M2 with RPCs, search and per-workspace budget

V1-1.2 (contract V1-1_OWNERS_ANIMALS.md §5, §9, §10). public.clients (person or organization, display name only, optional contact, folded search keys), create/update/set_archived as definer RPCs (identical not_found, idempotent create with divergent-replay refusal, revisions, archive read-only), search_clients invoker with keyset pages and phone search, write budget per workspace in UTC hour/day windows under a row lock, 20 000-client cap, ids-only audit hidden from platform staff (N9), nothing for anon or service_role. pgTAP 013 (130), field-limits parity test, sandbox suite (concurrency, budget races, 20 000-client search), types regenerated.
This commit is contained in:
bchanot committed 2026-10-25 21:09:45 +01:00
1 parent 2c0531d638
commit 4adbfcb608
9 files changed
+1916 -2

No files matched your search

+3 -1
View File
@@ -11,6 +11,7 @@ import { resolve, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { PGlite } from '@electric-sql/pglite'
import { pgtap } from '@electric-sql/pglite/pgtap'
import { unaccent } from '@electric-sql/pglite/contrib/unaccent'
const here = fileURLToPath(new URL('.', import.meta.url))
export const repoRoot = resolve(here, '../../../..')
@@ -41,7 +42,8 @@ export async function listSeeds(): Promise<string[]> {
/** Boots PGlite, installs the shim and applies all migrations. */
export async function createMigratedDatabase(): Promise<PGlite> {
const db = await PGlite.create({ extensions: { pgtap } })
// unaccent: created by the clients migration (search keys), as on the real image.
const db = await PGlite.create({ extensions: { pgtap, unaccent } })
await db.exec(await readFile(join(here, 'supabase-shim.sql'), 'utf8'))
// Same placement as `supabase test db`: pgTAP lives in extensions, out of public.
await db.exec('create extension if not exists pgtap with schema extensions;')