/** * PostgreSQL Adapter * * Database adapter for PostgreSQL databases using the 'pg' library. * Implements all methods from BaseAdapter with PostgreSQL-specific optimizations. */ import { BaseAdapter, DatabaseFeature } from './base.adapter'; import { DatabaseType, IsolationLevel } from '../types/enums'; import { IAdapterConnectionOptions, IAdapterConnectionResult } from '../types/connection.interface'; import { IQueryResult, IRawQueryOptions, IRawQueryResult, IBuiltQuery } from '../types/query.interface'; import { IInsertOptions, IInsertResult, IUpdateOptions, IUpdateResult, IDeleteOptions, IDeleteResult, IUpsertOptions, IUpsertResult } from '../types/write.interface'; import { ITransactionContext, ISavepoint } from '../types/transaction.interface'; import { ICountOptions, ISumOptions, IAvgOptions, IMinMaxOptions, IAggregateResult, IGroupByResult, IBuiltAggregation } from '../types/aggregation.interface'; import { ITableDefinition, IAlterTableOperation, ITableSchema, ITableInfo, IIndexDefinition, IIndexInfo, IIndexStatistics, ICreateTableOptions } from '../types/schema.interface'; /** * PostgreSQL database adapter * Provides PostgreSQL-specific implementations for all database operations */ export declare class PostgreSQLAdapter extends BaseAdapter { protected readonly databaseType = DatabaseType.POSTGRESQL; private pool; connect(options: IAdapterConnectionOptions): Promise; testConnection(options: IAdapterConnectionOptions): Promise; disconnect(): Promise; query(query: IBuiltQuery): Promise>; raw(options: IRawQueryOptions): Promise>; insert(options: IInsertOptions): Promise>; update(options: IUpdateOptions): Promise>; delete(options: IDeleteOptions): Promise; upsert(options: IUpsertOptions): Promise>; count(options: ICountOptions): Promise; sum(options: ISumOptions): Promise; avg(options: IAvgOptions): Promise; min(options: IMinMaxOptions): Promise; max(options: IMinMaxOptions): Promise; aggregate(builtAggregation: IBuiltAggregation): Promise; groupBy(builtGroupBy: IBuiltAggregation): Promise[]>; beginTransaction(isolationLevel?: IsolationLevel, readOnly?: boolean, timeout?: number): Promise; commitTransaction(context: ITransactionContext): Promise; rollbackTransaction(context: ITransactionContext): Promise; createSavepoint(context: ITransactionContext, name: string): Promise; releaseSavepoint(context: ITransactionContext, savepoint: ISavepoint): Promise; rollbackToSavepoint(context: ITransactionContext, savepoint: ISavepoint): Promise; supportsSavepoints(): boolean; createTable(definition: ITableDefinition, options?: ICreateTableOptions): Promise; alterTable(tableName: string, operations: IAlterTableOperation[]): Promise; dropTable(tableName: string, ifExists?: boolean, cascade?: boolean): Promise; listTables(): Promise; listTablesWithInfo(): Promise; tableExists(tableName: string): Promise; getTableSchema(tableName: string): Promise; createIndex(index: IIndexDefinition, ifNotExists?: boolean, concurrent?: boolean): Promise; dropIndex(tableName: string, indexName: string, ifExists?: boolean, concurrent?: boolean, cascade?: boolean): Promise; listIndexes(tableName: string, includeSystem?: boolean): Promise; getIndexStatistics(tableName: string, indexName?: string): Promise; escapeIdentifier(identifier: string): string; /** * Format a field reference for use in WHERE clauses. * Handles JSON path notation (e.g., "metadata.role" becomes "metadata"->>'role') */ private formatFieldRef; escapeValue(value: any): string; /** * Check if value is an update operator object * Supports both lowercase (new) and uppercase (legacy) operators */ private isUpdateOperator; getParameterPlaceholder(index: number): string; getColumnTypeString(columnType: string, options?: { minLength?: number; maxLength?: number; precision?: number; scale?: number; enumValues?: string[]; arrayType?: string; }): string; getSupportedFeatures(): DatabaseFeature[]; parseError(error: any): { type: string; message: string; code?: string; details?: Record; }; private ensureConnected; private buildWhereClause; private buildCountQuery; private buildColumnDefinition; private buildConstraintDefinition; /** * Detect whether SSL should be enabled based on the connection URL and explicit option. * * Auto-enables for managed cloud PostgreSQL services that enforce SSL: * Azure — *.postgres.database.azure.com * GCP — *.sql.goog (Cloud SQL Private Service Connect) * *.cloudsql.google.com (Cloud SQL with custom DNS) * AWS — *.rds.amazonaws.com (RDS/Aurora) * * Users can also opt in explicitly via ?ssl=true or ?sslmode=require in the URL. * Note: pg natively reads ?sslmode from the connection string, but the pool-level * ssl config is still needed for consistent behaviour across pg versions. */ private detectSsl; private mapIsolationLevel; }