UNPKG

@ultipa-graph/ultipa-driver

Version:

NodeJS SDK for Ultipa GQL

74 lines (73 loc) 2.93 kB
/** * Configuration for GQLDB Node.js driver. */ import * as tls from 'tls'; /** Configuration options for GqldbClient */ export interface GqldbConfig { /** Server hosts in format "host:port" */ hosts: string[]; /** Username for authentication */ username?: string; /** Password for authentication */ password?: string; /** Default graph to use */ defaultGraph?: string; /** Query timeout in milliseconds (default 30000ms = 30s) */ timeout?: number; /** Maximum receive message size in bytes (default 64MB) */ maxRecvSize?: number; /** TLS options for secure connections */ tlsOptions?: tls.ConnectionOptions; /** Connection pool size per host */ poolSize?: number; /** Health check interval in milliseconds (default 30000ms = 30s) */ healthCheckInterval?: number; /** Number of retries for failed requests */ retryCount?: number; /** Delay between retries in milliseconds (default 100ms) */ retryDelay?: number; /** * Optional stable per-client logical session id used by the * transaction-branch model (sent as `x-ultipa-session-id` metadata * when §2.1 opt-in is enabled in TRANSACTIONS_DRIVER_GUIDE.md). * When omitted, the driver auto-generates a random hex string at * client construction time. */ sessionId?: string; } /** Default configuration values */ export declare const DEFAULT_CONFIG: Required<Omit<GqldbConfig, 'username' | 'password' | 'defaultGraph' | 'tlsOptions' | 'sessionId'>>; /** Builder for creating GqldbConfig */ export declare class ConfigBuilder { private config; /** Set the server hosts */ hosts(...hosts: string[]): this; /** Set the username for authentication */ username(username: string): this; /** Set the password for authentication */ password(password: string): this; /** Set the default graph */ defaultGraph(graph: string): this; /** Set the query timeout in milliseconds */ timeout(ms: number): this; /** Set the query timeout in seconds (convenience method) */ timeoutSeconds(seconds: number): this; /** Set the maximum receive message size */ maxRecvSize(bytes: number): this; /** Set TLS options */ tls(options: tls.ConnectionOptions): this; /** Set the connection pool size per host */ poolSize(size: number): this; /** Set the health check interval in milliseconds */ healthCheckInterval(ms: number): this; /** Set the number of retries */ retryCount(count: number): this; /** Set the delay between retries in milliseconds */ retryDelay(ms: number): this; /** Build and return the configuration */ build(): GqldbConfig; } /** Validate the configuration */ export declare function validateConfig(config: GqldbConfig): void; /** Create a configuration with defaults */ export declare function createConfig(options?: Partial<GqldbConfig>): GqldbConfig;