@queryleaf/postgres-server
Version:
PostgreSQL wire-compatible server for QueryLeaf
131 lines (130 loc) • 2.9 kB
TypeScript
import { Socket } from 'net';
import { QueryLeaf } from '@queryleaf/lib';
import { MongoClient } from 'mongodb';
interface ProtocolHandlerOptions {
authPassthrough?: boolean;
mongoClient?: MongoClient;
dbName?: string;
mongoUri?: string;
}
/**
* Handles the PostgreSQL wire protocol for a connection
*/
export declare class ProtocolHandler {
private socket;
private queryLeaf;
private user;
private database;
private serializer;
private buffer;
private authenticated;
private inTransaction;
private preparedStatements;
private authPassthrough;
private mongoClient;
private dbName;
private mongoUri;
constructor(socket: Socket, queryLeaf: QueryLeaf, options?: ProtocolHandlerOptions);
/**
* Handle incoming data from the client
*/
private handleData;
/**
* Handle a client message
*/
private handleMessage;
/**
* Handle a startup message
*/
private handleStartup;
/**
* Handle a password message
*/
private handlePassword;
/**
* Flatten a nested object into a flat structure with keys like "parent_child"
* This converts nested objects and arrays into flat structures for PostgreSQL compatibility
*/
private flattenObject;
/**
* Handle a query message
*/
private handleQuery;
/**
* Handle a parse message (for prepared statements)
*/
private handleParse;
/**
* Handle a bind message
*/
private handleBind;
/**
* Handle a describe message
*/
private handleDescribe;
/**
* Handle an execute message
*/
private handleExecute;
/**
* Handle a sync message
*/
private handleSync;
/**
* Handle a flush message
*/
private handleFlush;
/**
* Handle a terminate message
*/
private handleTerminate;
/**
* Handle socket errors
*/
private handleError;
/**
* Handle socket close
*/
private handleClose;
/**
* Send a message to the client
*/
private sendMessage;
/**
* Send authentication request (MD5 password)
*/
private sendAuthenticationRequest;
/**
* Send authentication OK message
*/
private sendAuthenticationOk;
/**
* Send parameter status messages
*/
private sendParameterStatus;
/**
* Send backend key data
*/
private sendBackendKeyData;
/**
* Send ready for query status message
*/
private sendReadyForQuery;
/**
* Send row description message
*/
private sendRowDescription;
/**
* Send data row message
*/
private sendDataRow;
/**
* Send command complete message
*/
private sendCommandComplete;
/**
* Send error response message
*/
private sendErrorResponse;
}
export {};