/** * ToonDB IPC Client * * Connects to a ToonDB IPC server via Unix domain socket. * * @packageDocumentation */ import { Query } from './query'; /** * Wire protocol opcodes. */ export declare const OpCode: { readonly Put: 1; readonly Get: 2; readonly Delete: 3; readonly BeginTxn: 4; readonly CommitTxn: 5; readonly AbortTxn: 6; readonly Query: 7; readonly CreateTable: 8; readonly PutPath: 9; readonly GetPath: 10; readonly Scan: 11; readonly Checkpoint: 12; readonly Stats: 13; readonly Ping: 14; readonly OK: 128; readonly Error: 129; readonly Value: 130; readonly TxnId: 131; readonly Row: 132; readonly EndStream: 133; readonly StatsResp: 134; readonly Pong: 135; }; /** * Configuration options for IpcClient. */ export interface IpcClientConfig { /** Path to Unix domain socket */ socketPath: string; /** Connection timeout in milliseconds (default: 5000) */ connectTimeout?: number; /** Read timeout in milliseconds (default: 30000) */ readTimeout?: number; } /** * IPC Client for ToonDB. * * Connects to a ToonDB server via Unix domain socket. * * @example * ```typescript * import { IpcClient } from '@sushanth/toondb'; * * const client = await IpcClient.connect('/tmp/toondb.sock'); * * await client.put(Buffer.from('key'), Buffer.from('value')); * const value = await client.get(Buffer.from('key')); * * await client.close(); * ``` */ export declare class IpcClient { private _socket; private _config; private _pendingReads; private _readBuffer; private _closed; private constructor(); /** * Connect to a ToonDB IPC server. * * @param socketPath - Path to the Unix domain socket * @returns A connected IpcClient instance * * @example * ```typescript * const client = await IpcClient.connect('/tmp/toondb.sock'); * ``` */ static connect(socketPath: string): Promise; private _connect; private _processBuffer; private _send; private _parseResponse; /** * Encode a key for the wire protocol. * @internal */ static encodeKey(key: Buffer): Buffer; /** * Encode a key-value pair for the wire protocol. * @internal */ static encodeKeyValue(key: Buffer, value: Buffer): Buffer; /** * Get a value by key. */ get(key: Buffer): Promise; /** * Put a key-value pair. */ put(key: Buffer, value: Buffer): Promise; /** * Delete a key. */ delete(key: Buffer): Promise; /** * Get a value by path. * Wire format: path_count(2 LE) + [path_len(2 LE) + path_segment]... */ getPath(path: string): Promise; /** * Put a value at a path. * Wire format: path_count(2 LE) + [path_len(2 LE) + path_segment]... + value */ putPath(path: string, value: Buffer): Promise; /** * Execute a query and return TOON-formatted results. * * Wire format: path_len(2) + path + limit(4) + offset(4) + cols_count(2) + [col_len(2) + col]... */ query(pathPrefix: string, options?: { limit?: number; offset?: number; columns?: string[]; }): Promise; /** * Scan for keys with a prefix, returning key-value pairs. * This is the preferred method for simple prefix-based iteration. * * Wire format: prefix string * Response format: count(4 LE) + [key_len(2 LE) + key + val_len(4 LE) + val]... */ scan(prefix: string): Promise>; /** * Create a query builder. */ queryBuilder(pathPrefix: string): Query; /** * Begin a new transaction. */ beginTransaction(): Promise; /** * Commit a transaction. */ commitTransaction(txnId: bigint): Promise; /** * Abort a transaction. */ abortTransaction(txnId: bigint): Promise; /** * Force a checkpoint. */ checkpoint(): Promise; /** * Get storage statistics. */ stats(): Promise<{ memtableSizeBytes: number; walSizeBytes: number; activeTransactions: number; }>; /** * Ping the server. */ ping(): Promise; /** * Close the connection. */ close(): Promise; } //# sourceMappingURL=ipc-client.d.ts.map