@pgxsinkit/pgwasm
Version:
194 lines • 8.01 kB
TypeScript
import type { Mode } from "./types";
export type MessageName = "parseComplete" | "bindComplete" | "closeComplete" | "noData" | "portalSuspended" | "replicationStart" | "emptyQuery" | "copyDone" | "copyData" | "rowDescription" | "parameterDescription" | "parameterStatus" | "backendKeyData" | "notification" | "readyForQuery" | "commandComplete" | "dataRow" | "copyInResponse" | "copyOutResponse" | "authenticationOk" | "authenticationMD5Password" | "authenticationCleartextPassword" | "authenticationSASL" | "authenticationSASLContinue" | "authenticationSASLFinal" | "error" | "notice";
/** Every backend message: its name and the length its header declared (excluding the type byte). */
export interface BackendMessage {
readonly name: MessageName;
readonly length: number;
}
export declare const parseComplete: BackendMessage;
export declare const bindComplete: BackendMessage;
export declare const closeComplete: BackendMessage;
export declare const noData: BackendMessage;
export declare const portalSuspended: BackendMessage;
export declare const replicationStart: BackendMessage;
export declare const emptyQuery: BackendMessage;
export declare const copyDone: BackendMessage;
export declare class AuthenticationOk implements BackendMessage {
readonly name = "authenticationOk";
readonly length: number;
constructor(length: number);
}
export declare class AuthenticationCleartextPassword implements BackendMessage {
readonly name = "authenticationCleartextPassword";
readonly length: number;
constructor(length: number);
}
export declare class AuthenticationMD5Password implements BackendMessage {
readonly name = "authenticationMD5Password";
readonly length: number;
readonly salt: Uint8Array;
constructor(length: number, salt: Uint8Array);
}
export declare class AuthenticationSASL implements BackendMessage {
readonly name = "authenticationSASL";
readonly length: number;
readonly mechanisms: string[];
constructor(length: number, mechanisms: string[]);
}
export declare class AuthenticationSASLContinue implements BackendMessage {
readonly name = "authenticationSASLContinue";
readonly length: number;
readonly data: string;
constructor(length: number, data: string);
}
export declare class AuthenticationSASLFinal implements BackendMessage {
readonly name = "authenticationSASLFinal";
readonly length: number;
readonly data: string;
constructor(length: number, data: string);
}
export type AuthenticationMessage = AuthenticationOk | AuthenticationCleartextPassword | AuthenticationMD5Password | AuthenticationSASL | AuthenticationSASLContinue | AuthenticationSASLFinal;
/** The fields an ErrorResponse and a NoticeResponse share. */
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;
}
/** An ErrorResponse from Postgres: an SQL error. `code` is the SQLSTATE. */
export declare class DatabaseError extends Error implements NoticeOrError {
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;
readonly length: number;
readonly name: MessageName;
constructor(message: string, length: number, name: MessageName);
}
export declare class CopyDataMessage implements BackendMessage {
readonly name = "copyData";
readonly length: number;
readonly chunk: Uint8Array;
constructor(length: number, chunk: Uint8Array);
}
export declare class CopyResponse implements BackendMessage {
readonly length: number;
readonly name: MessageName;
readonly binary: boolean;
readonly columnTypes: number[];
constructor(length: number, name: MessageName, binary: boolean, columnCount: number);
}
export declare class Field {
readonly name: string;
readonly tableID: number;
readonly columnID: number;
readonly dataTypeID: number;
readonly dataTypeSize: number;
readonly dataTypeModifier: number;
readonly format: Mode;
constructor(name: string, tableID: number, columnID: number, dataTypeID: number, dataTypeSize: number, dataTypeModifier: number, format: Mode);
}
export declare class RowDescriptionMessage implements BackendMessage {
readonly name: MessageName;
readonly length: number;
readonly fieldCount: number;
readonly fields: Field[];
constructor(length: number, fields: Field[]);
}
export declare class ParameterDescriptionMessage implements BackendMessage {
readonly name: MessageName;
readonly length: number;
readonly parameterCount: number;
readonly dataTypeIDs: number[];
constructor(length: number, dataTypeIDs: number[]);
}
export declare class ParameterStatusMessage implements BackendMessage {
readonly name: MessageName;
readonly length: number;
readonly parameterName: string;
readonly parameterValue: string;
constructor(length: number, parameterName: string, parameterValue: string);
}
export declare class BackendKeyDataMessage implements BackendMessage {
readonly name: MessageName;
readonly length: number;
readonly processID: number;
readonly secretKey: number;
constructor(length: number, processID: number, secretKey: number);
}
export declare class NotificationResponseMessage implements BackendMessage {
readonly name: MessageName;
readonly length: number;
readonly processId: number;
readonly channel: string;
readonly payload: string;
constructor(length: number, processId: number, channel: string, payload: string);
}
export declare class ReadyForQueryMessage implements BackendMessage {
readonly name: MessageName;
readonly length: number;
/** `I` idle, `T` in a transaction block, `E` in a failed transaction block. */
readonly status: string;
constructor(length: number, status: string);
}
export declare class CommandCompleteMessage implements BackendMessage {
readonly name: MessageName;
readonly length: number;
readonly text: string;
constructor(length: number, text: string);
}
export declare class DataRowMessage implements BackendMessage {
readonly name: MessageName;
readonly length: number;
readonly fieldCount: number;
readonly fields: (string | null)[];
constructor(length: number, fields: (string | null)[]);
}
export declare class NoticeMessage implements BackendMessage, NoticeOrError {
readonly name = "notice";
readonly length: number;
readonly 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;
constructor(length: number, message: string | undefined);
}
//# sourceMappingURL=messages.d.ts.map