/** * Database client singleton for iranti. * * Wraps Prisma + pg with a module-level singleton so the entire process shares * one connection pool. The singleton is intentionally strict: calling `initDb` * a second time with different credentials throws rather than silently replacing * the pool, preventing the class of bugs where two callers race to initialise * with different parameters. * * Connection configuration (via `InitDbOptions`): * - `applicationName` — sets `application_name` on the pg pool (visible in * `pg_stat_activity`; useful for distinguishing iranti vs. control-plane) * - `max` — pool size (default 10) * * Lifecycle: * - `initDb(url, opts)` — create pool + Prisma client; idempotent for same URL * - `getDb()` — get the live client; throws if not yet initialised * - `disconnectDb()` — shut down LISTEN/NOTIFY listener, disconnect Prisma, * drain the pool * - `getDbConnectionString()` — returns the URL used at init (for logging) * - `prisma` alias — legacy re-export of `getDb`, kept for compat */ import { PrismaClient } from '../generated/prisma/client'; type InitDbOptions = { applicationName?: string; max?: number; }; export declare function initDb(connectionString: string, options?: InitDbOptions): PrismaClient; export declare function getDb(): PrismaClient; export declare function getDbConnectionString(): string | null; export declare function disconnectDb(): Promise; export { getDb as prisma }; //# sourceMappingURL=client.d.ts.map