import type { PostgresPool } from './postgres-key-value-storage.ts'; /** * Options for {@link createLazyPostgresPool}. */ export type LazyPostgresPoolOptions = { /** npm package name of the driver, used in the missing-dependency error. */ readonly driverName: string; /** Adapter class name, used in the missing-dependency error. */ readonly storageName: string; /** * Import the driver and construct its connection pool for `url`. Called at most * once, on first use. Kept as a callback so this module never imports a specific * driver — Neon and Postgres pass their own. */ readonly loadPool: (url: string) => Promise; }; /** * Build a {@link PostgresPool} whose driver module is imported lazily on first use * and whose owned connection pool is torn down exactly once. Shared by * `NeonStorage` and `PostgresStorage`: both differ only in WHICH driver they load, * so the lazy-import memoization, the dispose-before/after-use guards, and the * actionable "optional peer dependency" error live here once instead of being * copy-pasted into each factory. * * Behavior: * - **Lazy + memoized:** `loadPool` runs at most once, on the first * `query`/`connect`. The injected-pool path never reaches here, so it never * imports the driver. * - **Disposed is terminal:** after `end()`, any further `query`/`connect` throws * rather than silently building a fresh, unreachable pool (which would leak * connections and keep the process alive — the bug a naive * `if (poolPromise === undefined) return` guard introduces). * - **End is safe:** `end()` before first use is a no-op (nothing was built); a * failed import leaves nothing to close. * - **Missing driver is actionable:** a module-resolution failure is rewrapped as * an install hint naming the package, matching the SQLite adapters' DX. */ export declare function createLazyPostgresPool(url: string, options: LazyPostgresPoolOptions): PostgresPool;