/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ /** The pool surface the lab uses: parameterized query, the error listener, and teardown. */ export interface PgPoolLike { query(text: string, values?: readonly unknown[]): Promise<{ rows: Record[]; rowCount: number | null; }>; on(event: 'error', listener: (error: unknown) => void): unknown; end(): Promise; } /** The single-connection surface, for one-shot administrative work. */ export interface PgClientLike { connect(): Promise; query(text: string, values?: readonly unknown[]): Promise<{ rows: Record[]; rowCount: number | null; }>; end(): Promise; } export interface PgPoolConfig { connectionString: string; max?: number; connectionTimeoutMillis?: number; /** Startup parameter string (e.g. `-c search_path=...`), applied to every connection. */ options?: string; } interface PgModule { Pool: new (config: PgPoolConfig) => PgPoolLike; Client: new (config: { connectionString: string; }) => PgClientLike; } export declare function loadPg(): Promise; /** * Opens a pool with the error listener every consumer must attach — a dropped idle connection * emits 'error' on the pool, and an unlistened 'error' event would crash the process. */ export declare function openPgPool(config: PgPoolConfig): Promise; export {};