/** * Connection pool configuration options for PostgreSQL */ export interface PostgresPoolConfig { /** Maximum number of connections in the pool (default: 10) */ max?: number; /** Maximum lifetime in seconds for connections (default: random between 45-90 minutes) */ max_lifetime?: number; /** Idle connection timeout in seconds (default: 0 - no timeout) */ idle_timeout?: number; /** Connect timeout in seconds (default: 30) */ connect_timeout?: number; } /** * Configuration for PostgreSQL connection using a connection string */ export interface PostgresConnectionStringConfig { /** Complete PostgreSQL connection string (e.g., postgres://user:password@host:port/database?sslmode=require) */ connectionString: string; /** These properties are not used when a connection string is provided */ host?: never; port?: never; user?: never; password?: never; database?: never; ssl?: never; /** Connection pool configuration */ pool?: PostgresPoolConfig; } /** * Configuration for PostgreSQL connection using individual parameters */ export interface PostgresParametersConfig { /** Not used when individual parameters are provided */ connectionString?: never; /** PostgreSQL server hostname */ host: string; /** PostgreSQL server port */ port: number; /** PostgreSQL username */ user: string; /** PostgreSQL password */ password: string; /** PostgreSQL database name */ database: string; /** Whether to use SSL for the connection */ ssl?: boolean; /** Connection pool configuration */ pool?: PostgresPoolConfig; } /** * Configuration options for PostgreSQL connection * * Can provide either: * 1. A complete connection string, or * 2. Individual connection parameters (host, port, user, etc.) */ export type PostgresConfig = PostgresConnectionStringConfig | PostgresParametersConfig; /** * Interface for PostgreSQL database operations * * Provides methods for connecting, querying, and executing SQL statements */ export interface PostgresAdapter { /** * Establishes a connection to the PostgreSQL database * @returns Promise that resolves when the connection is established */ connect(): Promise; /** * Closes the connection to the PostgreSQL database * @returns Promise that resolves when the connection is closed */ disconnect(): Promise; /** * Executes a SQL query and returns the results * @template T The expected result type * @param sql The SQL query to execute * @param params Optional parameters for the query * @returns Promise that resolves to the query results */ query(sql: string, params?: unknown[]): Promise; /** * Executes a SQL statement without returning results * @param sql The SQL statement to execute * @param params Optional parameters for the statement * @returns Promise that resolves when the statement has been executed */ execute(sql: string, params?: unknown[]): Promise; } /** * Implementation of PostgresAdapter using the postgres.js library */ export declare class PostgresJsAdapter implements PostgresAdapter { /** The postgres.js client factory function */ private postgres; /** The active postgres.js client */ private sql; /** The PostgreSQL configuration */ private config; /** The connection string built from the configuration */ private connectionString; /** * Creates a new PostgresJsAdapter instance * * @param config The PostgreSQL connection configuration */ constructor(config: PostgresConfig); /** * Establishes a connection to the PostgreSQL database * * @returns Promise that resolves when connection is established * @throws Error if connection fails */ connect(): Promise; /** * Closes the connection to the PostgreSQL database * @returns Promise that resolves when the connection is closed */ disconnect(): Promise; /** * Executes a SQL query and returns the results * @template T The expected result type * @param sql The SQL query to execute * @param params Optional parameters for the query * @returns Promise that resolves to the query results */ query(sql: string, params?: unknown[]): Promise; /** * Executes a SQL statement without returning results * @param sql The SQL statement to execute * @param params Optional parameters for the statement * @returns Promise that resolves when the statement has been executed */ execute(sql: string, params?: unknown[]): Promise; } /** * Creates and initializes a PostgreSQL adapter * * @param config The PostgreSQL connection configuration (either connectionString or individual parameters) * @returns An initialized PostgreSQL adapter */ export declare function createPostgresAdapter(config: PostgresConfig): Promise; //# sourceMappingURL=postgres-adapter.d.ts.map