import * as AWSXRay from 'aws-xray-sdk-core'; import * as PG from 'pg'; export function capturePostgres(pg: typeof PG): capturePostgres.PatchedPostgres; declare namespace capturePostgres { interface CaptureQueryMethod { (queryStream: T, segment?: AWSXRay.SegmentLike): T; ( queryConfig: PG.QueryArrayConfig, values?: I, segment?: AWSXRay.SegmentLike ): Promise>; ( queryConfig: PG.QueryConfig, segment?: AWSXRay.SegmentLike ): Promise>; ( queryTextOrConfig: string | PG.QueryConfig, values?: I, segment?: AWSXRay.SegmentLike ): Promise>; ( queryConfig: PG.QueryArrayConfig, callback: (err: Error, result: PG.QueryArrayResult) => void, segment?: AWSXRay.SegmentLike ): void; ( queryTextOrConfig: string | PG.QueryConfig, callback: (err: Error, result: PG.QueryResult) => void, segment?: AWSXRay.SegmentLike ): void; ( queryText: string, values: I, callback: (err: Error, result: PG.QueryResult) => void, segment?: AWSXRay.SegmentLike ): void; } type PatchedClientBase = { [K in keyof T]: K extends 'query' ? CaptureQueryMethod : T[K]; }; interface PatchedClientBaseConstructor { new(config?: string | PG.ClientConfig): PatchedClientBase; } type PatchedClient = PatchedClientBase; type PatchedClientConstructor = PatchedClientBaseConstructor; type PatchedPoolClient = PatchedClientBase; type PatchedPoolClientConstructor = PatchedClientBaseConstructor; interface PatchedPoolConnectMethod { (): Promise; (callback: (err: Error, client: PatchedPoolClient, done: (release?: any) => void) => void): void; } interface PatchedPoolOnMethod { (event: 'error', listener: (err: Error, client: PatchedPoolClient) => void): PatchedPool; (event: 'connect' | 'acquire' | 'remove', listener: (client: PatchedPoolClient) => void): PatchedPool; } type PatchedPool = { [K in keyof T]: K extends 'connect' ? PatchedPoolConnectMethod : K extends 'on' ? PatchedPoolOnMethod : T[K]; }; interface PatchedPoolConstructor { new(config?: PG.PoolConfig): PatchedPool; } interface PatchedEventsOnMethod { (event: 'error', listener: (err: Error, client: PatchedClient) => void): PatchedEvents; } type PatchedEvents = { [K in keyof T]: K extends 'on' ? PatchedEventsOnMethod : T[K]; }; interface PatchedEventsConstructor { new(): PatchedEvents; } type PatchedPostgres = { [K in keyof T]: K extends 'Client' ? PatchedClientConstructor : K extends 'PoolClient' ? PatchedPoolClientConstructor : K extends 'Pool' ? PatchedPoolConstructor : K extends 'Events' ? PatchedEventsConstructor : T[K]; }; }