/** * SQL Connection Management — PostgreSQL, MySQL, MSSQL, SQLite * * Singleton pool, connect/close, transactions. * Extracted from sql.ts — pure code movement. */ export interface PoolOptions { pool?: 'high' | 'standard' | 'low'; label?: string; } export interface ResultSet { rowCount: number; rows?: unknown[]; } export interface PoolClient { query(sql: string, params?: unknown[]): Promise<{ rows: unknown[]; rowCount: number; }>; release(): void; } interface Pool { query(sql: string, params?: unknown[]): Promise<{ rows: unknown[]; rowCount: number; }>; connect(): Promise; end(): Promise; } /** * Connect to the SQL database. Auto-detects driver from DATABASE_URL scheme. * * @param uri - Connection string (defaults to process.env.DATABASE_URL) * @param opts - Pool size preset and label * * @example * await connect(); // uses DATABASE_URL from .env * await connect(undefined, { pool: 'high', label: 'API' }); */ export declare function connect(uri?: string, opts?: PoolOptions): Promise; /** Get the active connection pool. Throws if not connected. */ export declare function getPool(): Pool; /** Close the connection pool. */ export declare function closePool(): Promise; /** Idempotent shutdown — safe to call from multiple signal handlers. */ export declare function gracefulShutdown(exitCode?: number): void; /** * Execute a function within a database transaction. * Automatically commits on success, rolls back on error. * * @example * const result = await withTransaction(async (client) => { * await client.query('UPDATE accounts SET balance = balance - $1 WHERE id = $2', [100, fromId]); * await client.query('UPDATE accounts SET balance = balance + $1 WHERE id = $2', [100, toId]); * return { success: true }; * }); */ export declare function withTransaction(fn: (client: PoolClient) => Promise, dialect?: 'pg' | 'mysql2' | 'mssql' | 'sqlite'): Promise; export {}; //# sourceMappingURL=sql-connection.d.ts.map