import type { PoolConfig } from "@neondatabase/serverless"; /** * Timeout knobs applied across `createDbClient` adapters. All values are * milliseconds. Pass `false` to disable a specific timeout entirely. * * Adapter coverage: * - `serverless` (Neon WebSocket `Pool`): `statementMs` → `statement_timeout` * (server-side), `queryMs` → `query_timeout` (client-side backstop), * `connectMs` → `connectionTimeoutMillis`. * - `node` (postgres-js): `statementMs` → `connection.statement_timeout` * (server-side startup parameter), `connectMs` → `connect_timeout` * (rounded up to whole seconds). `queryMs` has no postgres-js equivalent * and is ignored. * - `edge` (neon-http): per-query timeouts are not configurable on the Neon * HTTP client; queries rely on the server-side default `statement_timeout` * and the Workers runtime's own request limits. All fields are ignored. */ export interface DbTimeoutOptions { /** * Server-side `statement_timeout` in ms. Default `10_000`. * `false` disables it (server default applies). */ statementMs?: number | false; /** * Client-side query timeout in ms (serverless `Pool` only). Default * `15_000`. `false` disables it. */ queryMs?: number | false; /** * Connection-establishment timeout in ms. Default `10_000`. * `false` disables it. */ connectMs?: number | false; } /** Default timeouts applied when no override is provided. */ export declare const DEFAULT_DB_TIMEOUTS: { readonly statementMs: 10000; readonly queryMs: 15000; readonly connectMs: 10000; }; /** * Build the `PoolConfig` for the `serverless` adapter (Neon WebSocket Pool). * * Defaults are applied first and caller-supplied `pool` values spread after, * so explicit pool config always wins. `connectionString` is pinned last and * cannot be overridden through `pool`. * * Why BOTH `statement_timeout` and `query_timeout`: `statement_timeout` is a * Postgres startup parameter, and transaction-mode poolers (PgBouncer — which * Neon's `-pooler` endpoints run) may ignore startup parameters because the * pooled server session is shared across clients. `query_timeout` is enforced * client-side by node-postgres, so it acts as the backstop that still fires * when the pooler swallowed `statement_timeout`. */ export declare function resolveServerlessPoolConfig(connectionString: string, options?: { pool?: Omit; timeouts?: DbTimeoutOptions; }): PoolConfig; /** * Options accepted by postgres-js that the `node` adapter configures. * Kept structural (instead of importing postgres-js `Options`) so the * resolver stays a pure, dependency-free function that's easy to test. */ export interface NodePostgresOptions { max?: number; /** Connection-establishment timeout in SECONDS (postgres-js convention). */ connect_timeout?: number; /** Startup parameters sent to Postgres; `statement_timeout` is in ms. */ connection?: { statement_timeout: number; }; } /** * Build the postgres-js options object for the `node` adapter. * * - `statementMs` → `connection.statement_timeout` (ms, server-side). * - `connectMs` → `connect_timeout` (postgres-js takes seconds; rounded up). * - `queryMs` is ignored — postgres-js has no client-side per-query timeout. */ export declare function resolveNodePostgresOptions(options?: { max?: number; timeouts?: DbTimeoutOptions; }): NodePostgresOptions; /** Whether the connection string targets a Neon host (`*.neon.tech` etc.). */ export declare function isNeonConnectionString(connectionString: string): boolean; /** * Whether the connection string targets Neon's pooled (PgBouncer) endpoint — * the host contains the `-pooler` infix. Returns `false` for non-Neon hosts. * * Per-request pools (the `serverless` adapter on Workers) should always use * the `-pooler` host: the direct endpoint has a low `max_connections` * ceiling that per-request pools exhaust quickly. */ export declare function isPooledNeonConnectionString(connectionString: string): boolean; /** * Warn (once per unique connection string per process) when a per-request * pool is created against Neon's DIRECT endpoint instead of the `-pooler` * host. Never warns for localhost or non-Neon hosts, and never throws. */ export declare function warnIfDirectNeonEndpoint(connectionString: string): void; //# sourceMappingURL=connection-config.d.ts.map