import postgres from 'postgres'; import { type PostgresJsDatabase } from '../query/postgres-js/index.js'; import type { ResolvedDatabase } from '../../core/config/load.js'; import type { ResolvedObservability } from '../../core/config/load.js'; /** Which database role a pooled connection authenticates as. `owner` runs migrations/bootstrap and owns tables (bypasses RLS); `app` is the non-owner, non-BYPASSRLS runtime role that RLS policies enforce against. */ export type ConnectionRole = 'owner' | 'app'; /** A standalone pooled connection: the raw postgres.js client, its drizzle handle, and a `close()` that ends the pool. */ export interface ManagedConnection { readonly name: string; /** * The raw postgres.js client — deliberately unmediated. With * `observability.onStatement` configured, queries issued through it fall * outside pipework's driver error boundary, so their errors serialize bind * parameters; `connection.drizzle` does not. Reading this on an observed * connection logs a warning once per database. */ readonly client: postgres.Sql; readonly drizzle: PostgresJsDatabase; close(): Promise; } /** Options for `tap()` — pool size (default 1) and idle timeout in seconds. */ export interface ConnectOptions { readonly max?: number; readonly idleTimeout?: number; } /** * Opens a standalone managed connection outside the manifold's pools — the * sanctioned door for contexts where `pipe()` structurally cannot resolve: * `worker_threads`, detached monitors, one-off scripts. Callers own the * lifecycle: always `await conn.close()`. */ export declare function tap(url: string, options?: ConnectOptions): ManagedConnection; /** Builds the pooled connection for one resolved database — used by the manifold's pool manager; consumers outside a managed context use `tap()` or `pool.getOrCreate()`. */ export declare function createManagedConnection(config: ResolvedDatabase, onClose: () => void, observability?: ResolvedObservability): ManagedConnection; //# sourceMappingURL=pool.d.ts.map