UNPKG

pg-server

Version:

Postgres DB server emulator, proxy or honeypot

154 lines 4.95 kB
/// <reference types="node" /> /// <reference types="node" /> import { Socket } from 'net'; /** Send low level responses to client */ export interface IResponseWriter { /** The underlying socket (connection to client) */ readonly socket: Socket; command(cmd: DbResponse): void; authenticationOk(): void; readyForQuery(): void; bindComplete(): void; parseComplete(): void; closeComplete(): void; noData(): void; portalSuspended(): void; copyDone(): void; replicationStart(): void; emptyQuery(): void; error(message: string | Error | NoticeOrError): void; notice(message: string | NoticeOrError): void; dataRow(row: string[]): void; commandComplete(message: string): void; notificationResponse(pid: number, channel: string, payload: string): void; parameterStatus(name: string, value: string): void; parameterDescription(types: number[]): void; backendKeyData(pid: number, secretKey: number): void; rowDescription(fieldDescs: FieldDesc[]): void; copyIn(isBinary: boolean, types: number[]): void; copyOut(isBinary: boolean, types: number[]): void; copyData(data: Buffer): void; } export declare enum ResponseCode { DataRow = 68, ParseComplete = 49, BindComplete = 50, CloseComplete = 51, CommandComplete = 67, ReadyForQuery = 90, NoData = 110, NotificationResponse = 65, AuthenticationResponse = 82, ParameterStatus = 83, ParameterDescription = 116, BackendKeyData = 75, ErrorMessage = 69, NoticeMessage = 78, RowDescriptionMessage = 84, PortalSuspended = 115, ReplicationStart = 87, EmptyQuery = 73, CopyIn = 71, CopyOut = 72, CopyDone = 99, CopyData = 100 } export declare function messageToStr(code: ResponseCode): any; export declare type Mode = 'text' | 'binary'; export interface NoticeOrError { message?: string | undefined; severity?: string | undefined; code?: string | undefined; detail?: string | undefined; hint?: string | undefined; position?: string | undefined; internalPosition?: string | undefined; internalQuery?: string | undefined; where?: string | undefined; schema?: string | undefined; table?: string | undefined; column?: string | undefined; dataType?: string | undefined; constraint?: string | undefined; file?: string | undefined; line?: string | undefined; routine?: string | undefined; } export type DbResponse = CodeOnlyResponse | ReadyForQueryResponse | CommandCompleteResponse | CopyDataResponse | CopyInOutResponse | NotificationResponse | RowDescriptionResponse | DataRowResponse | ParameterStatusResponse | AuthenticationResponse | BackendKeyDataResponse | NoticeOrErrorResponse; export interface NoticeOrErrorResponse { type: ResponseCode.NoticeMessage | ResponseCode.ErrorMessage; message: NoticeOrError; } export type AuthenticationResponse = { type: ResponseCode.AuthenticationResponse; kind: 'ok'; } | { type: ResponseCode.AuthenticationResponse; kind: 'cleartextPassword'; } | { type: ResponseCode.AuthenticationResponse; kind: 'md5Password'; salt: Buffer; } | { type: ResponseCode.AuthenticationResponse; kind: 'SASL'; mechanisms: string[]; } | { type: ResponseCode.AuthenticationResponse; kind: 'SASLContinue' | 'SASLFinal'; data: string; }; export interface BackendKeyDataResponse { type: ResponseCode.BackendKeyData; processID: number; secretKey: number; } export interface ParameterStatusResponse { type: ResponseCode.ParameterStatus; name: string; value: string; } export interface DataRowResponse { type: ResponseCode.DataRow; fields: (string | null)[]; } export interface FieldDesc { name: string; tableID: number; columnID: number; dataTypeID: number; dataTypeSize: number; dataTypeModifier: number; mode: Mode; } export interface RowDescriptionResponse { type: ResponseCode.RowDescriptionMessage; fields: FieldDesc[]; } export interface NotificationResponse { type: ResponseCode.NotificationResponse; processId: number; channel: string; payload: string; } export interface CopyInOutResponse { type: ResponseCode.CopyIn | ResponseCode.CopyOut; isBinary: boolean; columnTypes: number[]; } export interface CopyDataResponse { type: ResponseCode.CopyData; data: Buffer; } export interface CommandCompleteResponse { type: ResponseCode.CommandComplete; text: string; } export interface ReadyForQueryResponse { type: ResponseCode.ReadyForQuery; status: string; } export interface CodeOnlyResponse { type: ResponseCode.BindComplete | ResponseCode.ParseComplete | ResponseCode.CloseComplete | ResponseCode.NoData | ResponseCode.PortalSuspended | ResponseCode.CopyDone | ResponseCode.ReplicationStart | ResponseCode.EmptyQuery; } //# sourceMappingURL=responses.d.ts.map