@geodedb/client 1.0.0-alpha.2 → 1.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -26
- package/dist/index.d.ts +665 -236
- package/dist/index.js +2757 -1535
- package/dist/index.js.map +1 -1
- package/package.json +18 -13
- package/proto/geode.proto +577 -0
- package/dist/index.d.mts +0 -2430
- package/dist/index.mjs +0 -5101
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,42 @@
|
|
|
1
1
|
import * as tls from 'node:tls';
|
|
2
|
-
import Decimal from 'decimal.js-light';
|
|
2
|
+
import { Decimal } from 'decimal.js-light';
|
|
3
3
|
export { default as Decimal } from 'decimal.js-light';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Geode Client Configuration
|
|
7
7
|
*
|
|
8
8
|
* DSN parsing and configuration management.
|
|
9
|
+
* Supports quic:// and grpc:// transport schemes.
|
|
10
|
+
*
|
|
11
|
+
* See geode/docs/DSN.md for the complete DSN specification.
|
|
9
12
|
*/
|
|
10
13
|
declare const DEFAULT_PORT = 3141;
|
|
14
|
+
declare const DEFAULT_GRPC_PORT = 50051;
|
|
11
15
|
declare const DEFAULT_PAGE_SIZE = 1000;
|
|
12
16
|
declare const DEFAULT_HELLO_NAME = "geode-nodejs";
|
|
13
17
|
declare const DEFAULT_HELLO_VERSION = "1.0.0";
|
|
14
18
|
declare const DEFAULT_CONFORMANCE = "min";
|
|
15
19
|
declare const MAX_QUERY_LENGTH: number;
|
|
16
20
|
declare const MAX_PAGE_SIZE = 100000;
|
|
21
|
+
/**
|
|
22
|
+
* Transport type for client connections.
|
|
23
|
+
*/
|
|
24
|
+
type TransportType = 'quic' | 'grpc';
|
|
25
|
+
/**
|
|
26
|
+
* Supported DSN schemes.
|
|
27
|
+
*/
|
|
28
|
+
declare const SUPPORTED_SCHEMES: readonly ["quic", "grpc"];
|
|
29
|
+
type DSNScheme = (typeof SUPPORTED_SCHEMES)[number];
|
|
17
30
|
/**
|
|
18
31
|
* Geode connection configuration.
|
|
19
32
|
*/
|
|
20
33
|
interface GeodeConfig {
|
|
21
34
|
/** Server hostname or IP address */
|
|
22
35
|
host: string;
|
|
23
|
-
/** Server port (default: 3141) */
|
|
36
|
+
/** Server port (default: 3141 for QUIC, 50051 for gRPC) */
|
|
24
37
|
port: number;
|
|
38
|
+
/** Transport type (default: 'quic') */
|
|
39
|
+
transport: TransportType;
|
|
25
40
|
/** Number of rows per page (default: 1000) */
|
|
26
41
|
pageSize: number;
|
|
27
42
|
/** Client name sent in HELLO message */
|
|
@@ -58,14 +73,16 @@ interface GeodeConfig {
|
|
|
58
73
|
keepAliveInterval?: number;
|
|
59
74
|
/** Maximum idle time in milliseconds (default: 30000) */
|
|
60
75
|
maxIdleTime?: number;
|
|
76
|
+
/** Enable TLS for gRPC (default: true) */
|
|
77
|
+
tls?: boolean;
|
|
61
78
|
}
|
|
62
79
|
/**
|
|
63
80
|
* Connection pool configuration.
|
|
64
81
|
*/
|
|
65
82
|
interface PoolConfig extends GeodeConfig {
|
|
66
|
-
/** Minimum number of connections in pool (default:
|
|
83
|
+
/** Minimum number of connections in pool (default: 1) */
|
|
67
84
|
minConnections?: number;
|
|
68
|
-
/** Maximum number of connections in pool (default:
|
|
85
|
+
/** Maximum number of connections in pool (default: 3) */
|
|
69
86
|
maxConnections?: number;
|
|
70
87
|
/** Time to wait for connection in milliseconds (default: 30000) */
|
|
71
88
|
acquireTimeout?: number;
|
|
@@ -80,9 +97,9 @@ declare function defaultConfig(): GeodeConfig;
|
|
|
80
97
|
* Parse a DSN (Data Source Name) string into configuration.
|
|
81
98
|
*
|
|
82
99
|
* Supported formats:
|
|
83
|
-
* -
|
|
84
|
-
* -
|
|
85
|
-
* - host:port?options
|
|
100
|
+
* - quic://host:port?options (QUIC transport, default)
|
|
101
|
+
* - grpc://host:port?options (gRPC transport)
|
|
102
|
+
* - host:port?options (defaults to QUIC)
|
|
86
103
|
* - host:port
|
|
87
104
|
* - host (uses default port)
|
|
88
105
|
*
|
|
@@ -97,6 +114,7 @@ declare function defaultConfig(): GeodeConfig;
|
|
|
97
114
|
* - cert: Path to client certificate (for mTLS)
|
|
98
115
|
* - key: Path to client key (for mTLS)
|
|
99
116
|
* - insecure: Skip TLS verification (testing only)
|
|
117
|
+
* - tls: Enable/disable TLS for gRPC (default: true)
|
|
100
118
|
* - server_name: SNI server name
|
|
101
119
|
* - connect_timeout: Connection timeout in ms
|
|
102
120
|
* - request_timeout: Request timeout in ms
|
|
@@ -107,6 +125,7 @@ declare function defaultConfig(): GeodeConfig;
|
|
|
107
125
|
* - GEODE_TLS_CA: Default CA certificate path
|
|
108
126
|
* - GEODE_USERNAME: Default username
|
|
109
127
|
* - GEODE_PASSWORD: Default password
|
|
128
|
+
* - GEODE_TRANSPORT: Default transport type (quic or grpc)
|
|
110
129
|
*/
|
|
111
130
|
declare function parseDSN(dsn: string): GeodeConfig;
|
|
112
131
|
/**
|
|
@@ -121,6 +140,28 @@ declare function getAddress(cfg: GeodeConfig): string;
|
|
|
121
140
|
* Clone configuration.
|
|
122
141
|
*/
|
|
123
142
|
declare function cloneConfig(cfg: GeodeConfig): GeodeConfig;
|
|
143
|
+
/**
|
|
144
|
+
* Redact credentials from a DSN string for safe logging.
|
|
145
|
+
*
|
|
146
|
+
* Replaces username and password with '***' to prevent credential exposure
|
|
147
|
+
* in logs, error messages, or other output.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* redactDSN('quic://admin:secret@localhost:3141')
|
|
152
|
+
* // Returns: 'quic://***:***@localhost:3141'
|
|
153
|
+
*
|
|
154
|
+
* redactDSN('grpc://localhost:50051?username=admin&password=secret')
|
|
155
|
+
* // Returns: 'grpc://localhost:50051?username=***&password=***'
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
declare function redactDSN(dsn: string): string;
|
|
159
|
+
/**
|
|
160
|
+
* Redact credentials from a configuration object for safe logging.
|
|
161
|
+
*
|
|
162
|
+
* Returns a new config object with password set to '***'.
|
|
163
|
+
*/
|
|
164
|
+
declare function redactConfig(cfg: GeodeConfig): GeodeConfig;
|
|
124
165
|
|
|
125
166
|
/**
|
|
126
167
|
* Geode Client Error Types
|
|
@@ -187,9 +228,6 @@ declare class TransportError extends Error implements GeodeError {
|
|
|
187
228
|
});
|
|
188
229
|
get isRetryable(): boolean;
|
|
189
230
|
}
|
|
190
|
-
/**
|
|
191
|
-
* Configuration/DSN parsing error.
|
|
192
|
-
*/
|
|
193
231
|
declare class ConfigError extends Error implements GeodeError {
|
|
194
232
|
readonly statusClass: "22023";
|
|
195
233
|
readonly field: string;
|
|
@@ -254,19 +292,359 @@ declare function isGeodeError(err: unknown): err is GeodeError;
|
|
|
254
292
|
declare function isRetryableError(err: unknown): boolean;
|
|
255
293
|
|
|
256
294
|
/**
|
|
257
|
-
*
|
|
295
|
+
* Geode Protobuf Wire Protocol
|
|
296
|
+
*
|
|
297
|
+
* Uses protobufjs for encoding/decoding protocol messages.
|
|
298
|
+
* Wire format for QUIC: 4-byte Big Endian length prefix + protobuf message body.
|
|
299
|
+
*/
|
|
300
|
+
interface HelloRequest {
|
|
301
|
+
username: string;
|
|
302
|
+
password: string;
|
|
303
|
+
tenantId?: string;
|
|
304
|
+
clientName: string;
|
|
305
|
+
clientVersion: string;
|
|
306
|
+
wantedConformance: string;
|
|
307
|
+
}
|
|
308
|
+
interface HelloResponse {
|
|
309
|
+
success: boolean;
|
|
310
|
+
sessionId: string;
|
|
311
|
+
errorMessage: string;
|
|
312
|
+
capabilities: string[];
|
|
313
|
+
}
|
|
314
|
+
interface Param {
|
|
315
|
+
name: string;
|
|
316
|
+
value: ProtoValue;
|
|
317
|
+
}
|
|
318
|
+
interface ExecuteRequest {
|
|
319
|
+
sessionId: string;
|
|
320
|
+
query: string;
|
|
321
|
+
params: Param[];
|
|
322
|
+
}
|
|
323
|
+
interface PullRequest {
|
|
324
|
+
requestId: bigint | number;
|
|
325
|
+
pageSize: number;
|
|
326
|
+
sessionId: string;
|
|
327
|
+
}
|
|
328
|
+
interface PullResponse {
|
|
329
|
+
response?: ExecutionResponse;
|
|
330
|
+
}
|
|
331
|
+
interface Status {
|
|
332
|
+
statusClass: string;
|
|
333
|
+
statusSubclass: string;
|
|
334
|
+
additionalStatuses: string[];
|
|
335
|
+
flaggerFindings: string[];
|
|
336
|
+
}
|
|
337
|
+
interface ColumnDefinition {
|
|
338
|
+
name: string;
|
|
339
|
+
type: string;
|
|
340
|
+
}
|
|
341
|
+
interface SchemaDefinition {
|
|
342
|
+
columns: ColumnDefinition[];
|
|
343
|
+
}
|
|
344
|
+
interface ProtoValue {
|
|
345
|
+
nullVal?: NullValue;
|
|
346
|
+
intVal?: IntValue;
|
|
347
|
+
doubleVal?: DoubleValue;
|
|
348
|
+
boolVal?: boolean;
|
|
349
|
+
stringVal?: StringValue;
|
|
350
|
+
decimalVal?: DecimalValue;
|
|
351
|
+
bytesVal?: BytesValue;
|
|
352
|
+
listVal?: ListValue;
|
|
353
|
+
mapVal?: MapValue;
|
|
354
|
+
nodeVal?: NodeValue;
|
|
355
|
+
edgeVal?: EdgeValue;
|
|
356
|
+
pathVal?: PathValue;
|
|
357
|
+
extVal?: ExtendedValue;
|
|
358
|
+
}
|
|
359
|
+
interface NullValue {
|
|
360
|
+
}
|
|
361
|
+
interface IntValue {
|
|
362
|
+
value: bigint | number;
|
|
363
|
+
kind: number;
|
|
364
|
+
}
|
|
365
|
+
interface DoubleValue {
|
|
366
|
+
value: number;
|
|
367
|
+
kind: number;
|
|
368
|
+
}
|
|
369
|
+
interface StringValue {
|
|
370
|
+
value: string;
|
|
371
|
+
kind: number;
|
|
372
|
+
}
|
|
373
|
+
interface DecimalValue {
|
|
374
|
+
coeff: string;
|
|
375
|
+
scale: number;
|
|
376
|
+
origScale: number;
|
|
377
|
+
origRepr: string;
|
|
378
|
+
}
|
|
379
|
+
interface BytesValue {
|
|
380
|
+
value: Uint8Array;
|
|
381
|
+
kind: number;
|
|
382
|
+
}
|
|
383
|
+
interface ListValue {
|
|
384
|
+
values: ProtoValue[];
|
|
385
|
+
}
|
|
386
|
+
interface MapEntry {
|
|
387
|
+
key: string;
|
|
388
|
+
value: ProtoValue;
|
|
389
|
+
}
|
|
390
|
+
interface MapValue {
|
|
391
|
+
entries: MapEntry[];
|
|
392
|
+
}
|
|
393
|
+
interface NodeValue {
|
|
394
|
+
id: bigint | number;
|
|
395
|
+
labels: string[];
|
|
396
|
+
properties: MapEntry[];
|
|
397
|
+
}
|
|
398
|
+
interface EdgeValue {
|
|
399
|
+
id: bigint | number;
|
|
400
|
+
fromId: bigint | number;
|
|
401
|
+
toId: bigint | number;
|
|
402
|
+
label: string;
|
|
403
|
+
properties: MapEntry[];
|
|
404
|
+
}
|
|
405
|
+
interface PathValue {
|
|
406
|
+
nodes: NodeValue[];
|
|
407
|
+
edges: EdgeValue[];
|
|
408
|
+
}
|
|
409
|
+
interface ExtendedValue {
|
|
410
|
+
typeName: string;
|
|
411
|
+
text?: string;
|
|
412
|
+
bytes?: Uint8Array;
|
|
413
|
+
intVal?: bigint | number;
|
|
414
|
+
doubleVal?: number;
|
|
415
|
+
boolVal?: boolean;
|
|
416
|
+
}
|
|
417
|
+
interface Row$1 {
|
|
418
|
+
values: ProtoValue[];
|
|
419
|
+
}
|
|
420
|
+
interface DataPage {
|
|
421
|
+
rows: Row$1[];
|
|
422
|
+
final: boolean;
|
|
423
|
+
ordered: boolean;
|
|
424
|
+
orderKeys: string[];
|
|
425
|
+
}
|
|
426
|
+
interface ProtoError {
|
|
427
|
+
code: string;
|
|
428
|
+
message: string;
|
|
429
|
+
type: string;
|
|
430
|
+
anchor: string;
|
|
431
|
+
}
|
|
432
|
+
interface ExecutionMetrics {
|
|
433
|
+
parseDurationNs: bigint | number;
|
|
434
|
+
planDurationNs: bigint | number;
|
|
435
|
+
executeDurationNs: bigint | number;
|
|
436
|
+
totalDurationNs: bigint | number;
|
|
437
|
+
}
|
|
438
|
+
interface ExplainTotals {
|
|
439
|
+
cost?: number;
|
|
440
|
+
est_rows?: number;
|
|
441
|
+
}
|
|
442
|
+
interface ExplainPayload {
|
|
443
|
+
schema: string;
|
|
444
|
+
ops: unknown[];
|
|
445
|
+
totals?: ExplainTotals;
|
|
446
|
+
properties: unknown;
|
|
447
|
+
calibration: unknown;
|
|
448
|
+
profileVersion: number;
|
|
449
|
+
}
|
|
450
|
+
interface ProfileMemory {
|
|
451
|
+
netBytes?: number | bigint;
|
|
452
|
+
peakBytes?: number | bigint;
|
|
453
|
+
totalAllocBytes?: number | bigint;
|
|
454
|
+
}
|
|
455
|
+
interface ProfilePayload {
|
|
456
|
+
profileVersion: number;
|
|
457
|
+
ops: unknown[];
|
|
458
|
+
peakContributors: unknown[];
|
|
459
|
+
totals: unknown;
|
|
460
|
+
totalTimeNs: bigint | number;
|
|
461
|
+
spills: unknown;
|
|
462
|
+
memory?: ProfileMemory;
|
|
463
|
+
plannerEstimates: unknown;
|
|
464
|
+
memCurve: unknown[];
|
|
465
|
+
setop: unknown;
|
|
466
|
+
hashaggSpills: bigint | number;
|
|
467
|
+
hashaggSpillReason: string;
|
|
468
|
+
committedTxns: bigint | number;
|
|
469
|
+
graphStoreNodes: bigint | number;
|
|
470
|
+
graphStoreEdges: bigint | number;
|
|
471
|
+
graphStoreDirty: boolean;
|
|
472
|
+
flaggerFindings: string[];
|
|
473
|
+
compact: boolean;
|
|
474
|
+
}
|
|
475
|
+
interface Heartbeat {
|
|
476
|
+
}
|
|
477
|
+
interface ExecutionResponse {
|
|
478
|
+
status?: Status;
|
|
479
|
+
schema?: SchemaDefinition;
|
|
480
|
+
page?: DataPage;
|
|
481
|
+
error?: ProtoError;
|
|
482
|
+
metrics?: ExecutionMetrics;
|
|
483
|
+
explain?: ExplainPayload;
|
|
484
|
+
profile?: ProfilePayload;
|
|
485
|
+
heartbeat?: Heartbeat;
|
|
486
|
+
}
|
|
487
|
+
interface PingRequest {
|
|
488
|
+
}
|
|
489
|
+
interface PingResponse {
|
|
490
|
+
ok: boolean;
|
|
491
|
+
}
|
|
492
|
+
interface BeginRequest {
|
|
493
|
+
readOnly: boolean;
|
|
494
|
+
sessionId: string;
|
|
495
|
+
}
|
|
496
|
+
interface BeginResponse {
|
|
497
|
+
sessionId: string;
|
|
498
|
+
txId: string;
|
|
499
|
+
}
|
|
500
|
+
interface CommitRequest {
|
|
501
|
+
sessionId: string;
|
|
502
|
+
}
|
|
503
|
+
interface CommitResponse {
|
|
504
|
+
success: boolean;
|
|
505
|
+
}
|
|
506
|
+
interface RollbackRequest {
|
|
507
|
+
sessionId: string;
|
|
508
|
+
}
|
|
509
|
+
interface RollbackResponse {
|
|
510
|
+
success: boolean;
|
|
511
|
+
}
|
|
512
|
+
interface SavepointRequest {
|
|
513
|
+
name: string;
|
|
514
|
+
sessionId: string;
|
|
515
|
+
}
|
|
516
|
+
interface SavepointResponse {
|
|
517
|
+
success: boolean;
|
|
518
|
+
}
|
|
519
|
+
interface RollbackToRequest {
|
|
520
|
+
name: string;
|
|
521
|
+
sessionId: string;
|
|
522
|
+
}
|
|
523
|
+
interface RollbackToResponse {
|
|
524
|
+
success: boolean;
|
|
525
|
+
}
|
|
526
|
+
interface QuicClientMessage {
|
|
527
|
+
hello?: HelloRequest;
|
|
528
|
+
execute?: ExecuteRequest;
|
|
529
|
+
pull?: PullRequest;
|
|
530
|
+
ping?: PingRequest;
|
|
531
|
+
cdcDiag?: unknown;
|
|
532
|
+
cdcCtrl?: unknown;
|
|
533
|
+
begin?: BeginRequest;
|
|
534
|
+
commit?: CommitRequest;
|
|
535
|
+
rollback?: RollbackRequest;
|
|
536
|
+
savepoint?: SavepointRequest;
|
|
537
|
+
rollbackTo?: RollbackToRequest;
|
|
538
|
+
backup?: unknown;
|
|
539
|
+
restore?: unknown;
|
|
540
|
+
uploadBackup?: unknown;
|
|
541
|
+
}
|
|
542
|
+
interface QuicServerMessage {
|
|
543
|
+
hello?: HelloResponse;
|
|
544
|
+
execute?: ExecutionResponse;
|
|
545
|
+
pull?: PullResponse;
|
|
546
|
+
ping?: PingResponse;
|
|
547
|
+
cdcDiag?: unknown;
|
|
548
|
+
cdcCtrl?: unknown;
|
|
549
|
+
begin?: BeginResponse;
|
|
550
|
+
commit?: CommitResponse;
|
|
551
|
+
rollback?: RollbackResponse;
|
|
552
|
+
savepoint?: SavepointResponse;
|
|
553
|
+
rollbackTo?: RollbackToResponse;
|
|
554
|
+
backup?: unknown;
|
|
555
|
+
restore?: unknown;
|
|
556
|
+
uploadBackup?: unknown;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Ensure proto is initialized.
|
|
560
|
+
*/
|
|
561
|
+
declare function ensureProtoInitialized(): Promise<void>;
|
|
562
|
+
/**
|
|
563
|
+
* Convert a JavaScript value to a protobuf Value message.
|
|
564
|
+
*/
|
|
565
|
+
declare function jsToProtoValue(value: unknown): ProtoValue;
|
|
566
|
+
/**
|
|
567
|
+
* Convert a protobuf Value to a JavaScript value.
|
|
568
|
+
*/
|
|
569
|
+
declare function protoValueToJS(val: ProtoValue): unknown;
|
|
570
|
+
/**
|
|
571
|
+
* Encode a QuicClientMessage to protobuf bytes.
|
|
572
|
+
*/
|
|
573
|
+
declare function encodeQuicClientMessage(msg: QuicClientMessage): Buffer;
|
|
574
|
+
/**
|
|
575
|
+
* Encode a QuicClientMessage with 4-byte big-endian length prefix.
|
|
576
|
+
*/
|
|
577
|
+
declare function encodeWithLengthPrefix(msg: QuicClientMessage): Buffer;
|
|
578
|
+
/**
|
|
579
|
+
* Decode a QuicServerMessage from protobuf bytes.
|
|
580
|
+
*/
|
|
581
|
+
declare function decodeQuicServerMessage(data: Buffer | Uint8Array): QuicServerMessage;
|
|
582
|
+
/**
|
|
583
|
+
* Decode 4-byte big-endian length prefix.
|
|
584
|
+
*/
|
|
585
|
+
declare function decodeLengthPrefix(data: Buffer): number;
|
|
586
|
+
/**
|
|
587
|
+
* Build a HelloRequest message.
|
|
588
|
+
*/
|
|
589
|
+
declare function buildHelloRequest(username: string, password: string, clientName: string, clientVersion: string, conformance: string, tenantId?: string): QuicClientMessage;
|
|
590
|
+
/**
|
|
591
|
+
* Build an ExecuteRequest message.
|
|
592
|
+
*/
|
|
593
|
+
declare function buildExecuteRequest(sessionId: string, query: string, params?: Record<string, unknown>): QuicClientMessage;
|
|
594
|
+
/**
|
|
595
|
+
* Build a PullRequest message.
|
|
596
|
+
*/
|
|
597
|
+
declare function buildPullRequest(requestId: number, pageSize: number, sessionId: string): QuicClientMessage;
|
|
598
|
+
/**
|
|
599
|
+
* Build a PingRequest message.
|
|
600
|
+
*/
|
|
601
|
+
declare function buildPingRequest(): QuicClientMessage;
|
|
602
|
+
/**
|
|
603
|
+
* Build a BeginRequest message.
|
|
604
|
+
*/
|
|
605
|
+
declare function buildBeginRequest(readOnly: boolean, sessionId: string): QuicClientMessage;
|
|
606
|
+
/**
|
|
607
|
+
* Build a CommitRequest message.
|
|
608
|
+
*/
|
|
609
|
+
declare function buildCommitRequest(sessionId: string): QuicClientMessage;
|
|
610
|
+
/**
|
|
611
|
+
* Build a RollbackRequest message.
|
|
612
|
+
*/
|
|
613
|
+
declare function buildRollbackRequest(sessionId: string): QuicClientMessage;
|
|
614
|
+
/**
|
|
615
|
+
* Build a SavepointRequest message.
|
|
616
|
+
*/
|
|
617
|
+
declare function buildSavepointRequest(name: string, sessionId: string): QuicClientMessage;
|
|
618
|
+
/**
|
|
619
|
+
* Build a RollbackToRequest message.
|
|
620
|
+
*/
|
|
621
|
+
declare function buildRollbackToRequest(name: string, sessionId: string): QuicClientMessage;
|
|
622
|
+
/**
|
|
623
|
+
* Convert a DataPage row to a record of column name -> value.
|
|
624
|
+
*/
|
|
625
|
+
declare function rowToRecord(row: Row$1, columns: ColumnDefinition[]): Record<string, unknown>;
|
|
626
|
+
/**
|
|
627
|
+
* Get proto file path for gRPC loader.
|
|
628
|
+
*/
|
|
629
|
+
declare function getProtoPath(): string;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Transport Layer
|
|
633
|
+
*
|
|
634
|
+
* Provides transport abstraction for communication with Geode server.
|
|
635
|
+
* Supports both QUIC (default) and gRPC transports.
|
|
258
636
|
*
|
|
259
|
-
*
|
|
637
|
+
* Wire format for QUIC: 4-byte Big Endian length prefix + protobuf message body.
|
|
260
638
|
*/
|
|
261
639
|
|
|
262
640
|
/**
|
|
263
641
|
* Transport interface for communication with Geode server.
|
|
264
642
|
*/
|
|
265
643
|
interface Transport {
|
|
266
|
-
/** Send a message to the server */
|
|
267
|
-
|
|
268
|
-
/** Receive a message from the server */
|
|
269
|
-
|
|
644
|
+
/** Send a protobuf message to the server */
|
|
645
|
+
sendProto(msg: QuicClientMessage, signal?: AbortSignal): Promise<void>;
|
|
646
|
+
/** Receive a protobuf message from the server */
|
|
647
|
+
receiveProto(signal?: AbortSignal): Promise<QuicServerMessage>;
|
|
270
648
|
/** Close the transport */
|
|
271
649
|
close(): Promise<void>;
|
|
272
650
|
/** Check if transport is closed */
|
|
@@ -279,15 +657,14 @@ interface Transport {
|
|
|
279
657
|
*/
|
|
280
658
|
declare function buildTLSConfig(cfg: GeodeConfig): Promise<tls.SecureContextOptions>;
|
|
281
659
|
/**
|
|
282
|
-
* Abstract base class for
|
|
283
|
-
* Allows for different QUIC implementations.
|
|
660
|
+
* Abstract base class for transports.
|
|
284
661
|
*/
|
|
285
662
|
declare abstract class BaseTransport implements Transport {
|
|
286
663
|
protected _closed: boolean;
|
|
287
664
|
protected _address: string;
|
|
288
665
|
constructor(address: string);
|
|
289
|
-
abstract
|
|
290
|
-
abstract
|
|
666
|
+
abstract sendProto(msg: QuicClientMessage, signal?: AbortSignal): Promise<void>;
|
|
667
|
+
abstract receiveProto(signal?: AbortSignal): Promise<QuicServerMessage>;
|
|
291
668
|
abstract close(): Promise<void>;
|
|
292
669
|
isClosed(): boolean;
|
|
293
670
|
getAddress(): string;
|
|
@@ -297,60 +674,70 @@ declare abstract class BaseTransport implements Transport {
|
|
|
297
674
|
* QUIC transport using @matrixai/quic.
|
|
298
675
|
*
|
|
299
676
|
* This implementation uses the quiche QUIC library via native bindings.
|
|
677
|
+
* Wire format: 4-byte Big Endian length prefix + protobuf message body.
|
|
300
678
|
*/
|
|
301
|
-
declare class
|
|
679
|
+
declare class QuicTransport extends BaseTransport {
|
|
302
680
|
private _client;
|
|
303
681
|
private _stream;
|
|
304
|
-
private
|
|
305
|
-
private
|
|
306
|
-
private _pendingReads;
|
|
682
|
+
private _protoBuffer;
|
|
683
|
+
private _pendingProtoReads;
|
|
307
684
|
constructor(address: string);
|
|
308
685
|
/**
|
|
309
686
|
* Connect to the Geode server using QUIC.
|
|
310
687
|
*/
|
|
311
|
-
static connect(cfg: GeodeConfig): Promise<
|
|
688
|
+
static connect(cfg: GeodeConfig): Promise<QuicTransport>;
|
|
312
689
|
/**
|
|
313
690
|
* Start reading from the stream in the background.
|
|
314
691
|
*/
|
|
315
692
|
private startReading;
|
|
316
693
|
/**
|
|
317
|
-
*
|
|
694
|
+
* Reject all pending reads with an error.
|
|
695
|
+
*/
|
|
696
|
+
private rejectPendingReads;
|
|
697
|
+
/**
|
|
698
|
+
* Process received data (length-prefixed protobuf messages).
|
|
318
699
|
*/
|
|
319
700
|
private processData;
|
|
320
|
-
|
|
321
|
-
|
|
701
|
+
/**
|
|
702
|
+
* Send a protobuf message with length prefix.
|
|
703
|
+
*/
|
|
704
|
+
sendProto(msg: QuicClientMessage, signal?: AbortSignal): Promise<void>;
|
|
705
|
+
/**
|
|
706
|
+
* Receive a protobuf message.
|
|
707
|
+
*/
|
|
708
|
+
receiveProto(signal?: AbortSignal): Promise<QuicServerMessage>;
|
|
322
709
|
close(): Promise<void>;
|
|
323
710
|
}
|
|
324
711
|
/**
|
|
325
712
|
* Mock transport for testing purposes.
|
|
326
713
|
*
|
|
327
|
-
* This allows unit testing without a real
|
|
714
|
+
* This allows unit testing without a real connection.
|
|
328
715
|
*/
|
|
329
716
|
declare class MockTransport extends BaseTransport {
|
|
330
|
-
private
|
|
331
|
-
private
|
|
332
|
-
private
|
|
717
|
+
private _protoSendQueue;
|
|
718
|
+
private _protoReceiveQueue;
|
|
719
|
+
private _pendingProtoReads;
|
|
333
720
|
constructor(address?: string);
|
|
334
721
|
/**
|
|
335
|
-
* Queue a response
|
|
722
|
+
* Queue a protobuf response.
|
|
336
723
|
*/
|
|
337
|
-
|
|
724
|
+
queueProtoResponse(response: QuicServerMessage): void;
|
|
338
725
|
/**
|
|
339
|
-
* Get all sent messages.
|
|
726
|
+
* Get all sent protobuf messages.
|
|
340
727
|
*/
|
|
341
|
-
|
|
728
|
+
getSentProtoMessages(): QuicClientMessage[];
|
|
342
729
|
/**
|
|
343
730
|
* Clear sent messages.
|
|
344
731
|
*/
|
|
345
732
|
clearSentMessages(): void;
|
|
346
|
-
|
|
347
|
-
|
|
733
|
+
sendProto(msg: QuicClientMessage, signal?: AbortSignal): Promise<void>;
|
|
734
|
+
receiveProto(signal?: AbortSignal): Promise<QuicServerMessage>;
|
|
348
735
|
close(): Promise<void>;
|
|
349
736
|
}
|
|
350
737
|
/**
|
|
351
738
|
* Create a transport for the given configuration.
|
|
352
739
|
*
|
|
353
|
-
*
|
|
740
|
+
* Selects between QUIC and gRPC based on config.transport.
|
|
354
741
|
*/
|
|
355
742
|
declare function createTransport(cfg: GeodeConfig): Promise<Transport>;
|
|
356
743
|
|
|
@@ -377,24 +764,55 @@ interface GQLRange<T = unknown> {
|
|
|
377
764
|
lowerInclusive: boolean;
|
|
378
765
|
upperInclusive: boolean;
|
|
379
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* Type alias for node/edge IDs.
|
|
769
|
+
*
|
|
770
|
+
* IDs can be:
|
|
771
|
+
* - string: String-based IDs or hex format IDs
|
|
772
|
+
* - number: Integer IDs within JavaScript's safe integer range
|
|
773
|
+
* - bigint: Integer IDs larger than Number.MAX_SAFE_INTEGER (2^53 - 1)
|
|
774
|
+
*
|
|
775
|
+
* Note: Geode's internal IDs often exceed JavaScript's safe integer limit,
|
|
776
|
+
* so bigint is used to preserve full precision.
|
|
777
|
+
*/
|
|
778
|
+
type GQLId = string | number | bigint;
|
|
380
779
|
/**
|
|
381
780
|
* Node structure from graph queries.
|
|
382
781
|
*/
|
|
383
782
|
interface GQLNode {
|
|
384
|
-
id:
|
|
783
|
+
id: GQLId;
|
|
385
784
|
labels: string[];
|
|
386
785
|
properties: Record<string, unknown>;
|
|
387
786
|
}
|
|
388
787
|
/**
|
|
389
788
|
* Edge structure from graph queries.
|
|
789
|
+
*
|
|
790
|
+
* Note: The server may return edge endpoints as either:
|
|
791
|
+
* - `startNode`/`endNode` (normalized form used by the client)
|
|
792
|
+
* - `from`/`to` (alternative wire format)
|
|
793
|
+
*
|
|
794
|
+
* The client normalizes both formats to `startNode`/`endNode`.
|
|
390
795
|
*/
|
|
391
796
|
interface GQLEdge {
|
|
392
|
-
id:
|
|
797
|
+
id: GQLId;
|
|
393
798
|
type: string;
|
|
394
|
-
startNode:
|
|
395
|
-
endNode:
|
|
799
|
+
startNode: GQLId;
|
|
800
|
+
endNode: GQLId;
|
|
396
801
|
properties: Record<string, unknown>;
|
|
397
802
|
}
|
|
803
|
+
/**
|
|
804
|
+
* Raw edge structure as it may appear in wire format.
|
|
805
|
+
* Used internally for parsing before normalization.
|
|
806
|
+
*/
|
|
807
|
+
interface RawEdge {
|
|
808
|
+
id: GQLId;
|
|
809
|
+
type: string;
|
|
810
|
+
startNode?: GQLId;
|
|
811
|
+
endNode?: GQLId;
|
|
812
|
+
from?: GQLId;
|
|
813
|
+
to?: GQLId;
|
|
814
|
+
properties?: Record<string, unknown>;
|
|
815
|
+
}
|
|
398
816
|
/**
|
|
399
817
|
* Path structure from graph queries.
|
|
400
818
|
*/
|
|
@@ -501,6 +919,12 @@ type Row = Map<string, GQLValue>;
|
|
|
501
919
|
declare function parseRow(raw: Record<string, unknown>, columns: ColumnInfo[]): Row;
|
|
502
920
|
/**
|
|
503
921
|
* Convert Row to plain object.
|
|
922
|
+
*
|
|
923
|
+
* Security: Uses Object.create(null) to create a prototype-free object
|
|
924
|
+
* and rejects dangerous keys (__proto__, constructor, prototype) that
|
|
925
|
+
* could lead to prototype pollution attacks.
|
|
926
|
+
*
|
|
927
|
+
* @throws {Error} If a row contains a dangerous key
|
|
504
928
|
*/
|
|
505
929
|
declare function rowToObject(row: Row): Record<string, unknown>;
|
|
506
930
|
|
|
@@ -826,7 +1250,7 @@ declare function prepare(conn: Connection, query: string): PreparedStatement;
|
|
|
826
1250
|
/**
|
|
827
1251
|
* Query Explain and Profile
|
|
828
1252
|
*
|
|
829
|
-
* Support for query plan analysis and execution profiling.
|
|
1253
|
+
* Support for query plan analysis and execution profiling using protobuf protocol.
|
|
830
1254
|
*/
|
|
831
1255
|
|
|
832
1256
|
/**
|
|
@@ -908,37 +1332,10 @@ interface ExplainOptions extends Omit<QueryOptions, 'pageSize'> {
|
|
|
908
1332
|
}
|
|
909
1333
|
/**
|
|
910
1334
|
* Get the query execution plan without executing.
|
|
911
|
-
*
|
|
912
|
-
* @param conn - Connection to use
|
|
913
|
-
* @param query - Query to explain
|
|
914
|
-
* @param options - Options including parameters
|
|
915
|
-
* @returns Query execution plan
|
|
916
|
-
*
|
|
917
|
-
* @example
|
|
918
|
-
* ```typescript
|
|
919
|
-
* const plan = await explain(conn, 'MATCH (n:Person)-[:KNOWS]->(m) RETURN n, m');
|
|
920
|
-
* console.log('Plan:', plan.root.type);
|
|
921
|
-
* console.log('Estimated cost:', plan.totalCost);
|
|
922
|
-
* ```
|
|
923
1335
|
*/
|
|
924
1336
|
declare function explain(conn: Connection, query: string, options?: ExplainOptions): Promise<QueryPlan>;
|
|
925
1337
|
/**
|
|
926
1338
|
* Execute a query with profiling and return execution statistics.
|
|
927
|
-
*
|
|
928
|
-
* Unlike explain(), profile() actually executes the query and measures
|
|
929
|
-
* real performance metrics.
|
|
930
|
-
*
|
|
931
|
-
* @param conn - Connection to use
|
|
932
|
-
* @param query - Query to profile
|
|
933
|
-
* @param options - Options including parameters
|
|
934
|
-
* @returns Query execution profile
|
|
935
|
-
*
|
|
936
|
-
* @example
|
|
937
|
-
* ```typescript
|
|
938
|
-
* const profile = await profile(conn, 'MATCH (n:Person) RETURN count(n)');
|
|
939
|
-
* console.log('Execution time:', profile.totalTimeMs, 'ms');
|
|
940
|
-
* console.log('Rows processed:', profile.totalRows);
|
|
941
|
-
* ```
|
|
942
1339
|
*/
|
|
943
1340
|
declare function profile(conn: Connection, query: string, options?: ExplainOptions): Promise<QueryProfile>;
|
|
944
1341
|
/**
|
|
@@ -1096,7 +1493,7 @@ declare function batchParallel(conn: Connection, queries: BatchQuery[], options?
|
|
|
1096
1493
|
/**
|
|
1097
1494
|
* Geode Connection
|
|
1098
1495
|
*
|
|
1099
|
-
* Connection management and query execution.
|
|
1496
|
+
* Connection management and query execution using protobuf wire protocol.
|
|
1100
1497
|
*/
|
|
1101
1498
|
|
|
1102
1499
|
/**
|
|
@@ -1124,6 +1521,8 @@ declare class Connection {
|
|
|
1124
1521
|
private _inTransaction;
|
|
1125
1522
|
private _activeResult;
|
|
1126
1523
|
private _requestId;
|
|
1524
|
+
private _sessionId;
|
|
1525
|
+
private _columns;
|
|
1127
1526
|
private constructor();
|
|
1128
1527
|
/**
|
|
1129
1528
|
* Create a new connection to the Geode server.
|
|
@@ -1149,12 +1548,12 @@ declare class Connection {
|
|
|
1149
1548
|
* Check if connection is closed.
|
|
1150
1549
|
*/
|
|
1151
1550
|
get isClosed(): boolean;
|
|
1551
|
+
/**
|
|
1552
|
+
* Get session ID.
|
|
1553
|
+
*/
|
|
1554
|
+
get sessionId(): string;
|
|
1152
1555
|
/**
|
|
1153
1556
|
* Perform the HELLO handshake.
|
|
1154
|
-
*
|
|
1155
|
-
* Note: The server may return an ERROR frame with "Authentication required"
|
|
1156
|
-
* even when no authentication is configured. This is a known server behavior
|
|
1157
|
-
* that should be treated as a successful connection (matching other clients).
|
|
1158
1557
|
*/
|
|
1159
1558
|
private hello;
|
|
1160
1559
|
/**
|
|
@@ -1176,7 +1575,10 @@ declare class Connection {
|
|
|
1176
1575
|
rows: Record<string, unknown>[];
|
|
1177
1576
|
final: boolean;
|
|
1178
1577
|
}>;
|
|
1179
|
-
|
|
1578
|
+
/**
|
|
1579
|
+
* Try to receive an inline response with short timeout.
|
|
1580
|
+
*/
|
|
1581
|
+
private _tryReceiveInline;
|
|
1180
1582
|
/**
|
|
1181
1583
|
* Release active result (internal).
|
|
1182
1584
|
*/
|
|
@@ -1215,33 +1617,18 @@ declare class Connection {
|
|
|
1215
1617
|
close(): Promise<void>;
|
|
1216
1618
|
/**
|
|
1217
1619
|
* Create a prepared statement.
|
|
1218
|
-
*
|
|
1219
|
-
* @param query - Query text with parameters
|
|
1220
|
-
* @returns Prepared statement
|
|
1221
1620
|
*/
|
|
1222
1621
|
prepare(query: string): Promise<PreparedStatement>;
|
|
1223
1622
|
/**
|
|
1224
1623
|
* Get the query execution plan without executing.
|
|
1225
|
-
*
|
|
1226
|
-
* @param query - Query to explain
|
|
1227
|
-
* @param options - Options including parameters
|
|
1228
|
-
* @returns Query execution plan
|
|
1229
1624
|
*/
|
|
1230
1625
|
explain(query: string, options?: ExplainOptions): Promise<QueryPlan>;
|
|
1231
1626
|
/**
|
|
1232
1627
|
* Execute a query with profiling.
|
|
1233
|
-
*
|
|
1234
|
-
* @param query - Query to profile
|
|
1235
|
-
* @param options - Options including parameters
|
|
1236
|
-
* @returns Query execution profile
|
|
1237
1628
|
*/
|
|
1238
1629
|
profile(query: string, options?: ExplainOptions): Promise<QueryProfile>;
|
|
1239
1630
|
/**
|
|
1240
1631
|
* Execute multiple queries in a batch.
|
|
1241
|
-
*
|
|
1242
|
-
* @param queries - Array of queries to execute
|
|
1243
|
-
* @param options - Batch execution options
|
|
1244
|
-
* @returns Batch execution summary
|
|
1245
1632
|
*/
|
|
1246
1633
|
batch(queries: BatchQuery[], options?: BatchOptions): Promise<BatchSummary>;
|
|
1247
1634
|
/**
|
|
@@ -1347,6 +1734,25 @@ interface CreateRLSPolicyOptions {
|
|
|
1347
1734
|
/** Whether to enable immediately */
|
|
1348
1735
|
enabled?: boolean;
|
|
1349
1736
|
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Password policy configuration.
|
|
1739
|
+
*/
|
|
1740
|
+
interface PasswordPolicy {
|
|
1741
|
+
/** Minimum password length (default: 8) */
|
|
1742
|
+
minLength?: number;
|
|
1743
|
+
/** Maximum password length (default: 256) */
|
|
1744
|
+
maxLength?: number;
|
|
1745
|
+
/** Require at least one uppercase letter */
|
|
1746
|
+
requireUppercase?: boolean;
|
|
1747
|
+
/** Require at least one lowercase letter */
|
|
1748
|
+
requireLowercase?: boolean;
|
|
1749
|
+
/** Require at least one digit */
|
|
1750
|
+
requireDigit?: boolean;
|
|
1751
|
+
/** Require at least one special character */
|
|
1752
|
+
requireSpecialChar?: boolean;
|
|
1753
|
+
/** Special characters to accept (default: !@#$%^&*()_+-=[]{}|;:,.<>?) */
|
|
1754
|
+
specialChars?: string;
|
|
1755
|
+
}
|
|
1350
1756
|
/**
|
|
1351
1757
|
* Authentication and authorization client.
|
|
1352
1758
|
*
|
|
@@ -1370,12 +1776,22 @@ interface CreateRLSPolicyOptions {
|
|
|
1370
1776
|
*/
|
|
1371
1777
|
declare class AuthClient {
|
|
1372
1778
|
private _conn;
|
|
1779
|
+
private _passwordPolicy;
|
|
1373
1780
|
/**
|
|
1374
1781
|
* Create a new auth client.
|
|
1375
1782
|
*
|
|
1376
1783
|
* @param conn - Connection to use
|
|
1784
|
+
* @param passwordPolicy - Optional password policy configuration
|
|
1377
1785
|
*/
|
|
1378
|
-
constructor(conn: Connection);
|
|
1786
|
+
constructor(conn: Connection, passwordPolicy?: PasswordPolicy);
|
|
1787
|
+
/**
|
|
1788
|
+
* Get the current password policy.
|
|
1789
|
+
*/
|
|
1790
|
+
get passwordPolicy(): Readonly<PasswordPolicy>;
|
|
1791
|
+
/**
|
|
1792
|
+
* Update the password policy.
|
|
1793
|
+
*/
|
|
1794
|
+
setPasswordPolicy(policy: PasswordPolicy): void;
|
|
1379
1795
|
/**
|
|
1380
1796
|
* Create a new user.
|
|
1381
1797
|
*
|
|
@@ -1548,8 +1964,11 @@ declare class AuthClient {
|
|
|
1548
1964
|
}
|
|
1549
1965
|
/**
|
|
1550
1966
|
* Create an auth client from a connection.
|
|
1967
|
+
*
|
|
1968
|
+
* @param conn - Connection to use
|
|
1969
|
+
* @param passwordPolicy - Optional password policy configuration
|
|
1551
1970
|
*/
|
|
1552
|
-
declare function createAuthClient(conn: Connection): AuthClient;
|
|
1971
|
+
declare function createAuthClient(conn: Connection, passwordPolicy?: PasswordPolicy): AuthClient;
|
|
1553
1972
|
|
|
1554
1973
|
/**
|
|
1555
1974
|
* Geode Client
|
|
@@ -1769,7 +2188,7 @@ declare class GeodeClient {
|
|
|
1769
2188
|
*
|
|
1770
2189
|
* @example
|
|
1771
2190
|
* ```typescript
|
|
1772
|
-
* const client = await createClient('
|
|
2191
|
+
* const client = await createClient('quic://localhost:3141');
|
|
1773
2192
|
* const rows = await client.queryAll('MATCH (n) RETURN n LIMIT 10');
|
|
1774
2193
|
* await client.close();
|
|
1775
2194
|
* ```
|
|
@@ -1786,6 +2205,21 @@ declare function createClientWithConfig(config: GeodeConfig, options?: ClientOpt
|
|
|
1786
2205
|
* Manages a pool of connections for efficient resource utilization.
|
|
1787
2206
|
*/
|
|
1788
2207
|
|
|
2208
|
+
/**
|
|
2209
|
+
* Rate limiter configuration.
|
|
2210
|
+
*/
|
|
2211
|
+
interface RateLimiterConfig {
|
|
2212
|
+
/** Maximum number of connection attempts per window (default: 10) */
|
|
2213
|
+
maxAttempts: number;
|
|
2214
|
+
/** Time window in milliseconds (default: 1000) */
|
|
2215
|
+
windowMs: number;
|
|
2216
|
+
/** Initial backoff delay in milliseconds (default: 100) */
|
|
2217
|
+
initialBackoffMs: number;
|
|
2218
|
+
/** Maximum backoff delay in milliseconds (default: 30000) */
|
|
2219
|
+
maxBackoffMs: number;
|
|
2220
|
+
/** Backoff multiplier (default: 2) */
|
|
2221
|
+
backoffMultiplier: number;
|
|
2222
|
+
}
|
|
1789
2223
|
/**
|
|
1790
2224
|
* Connection pool for managing multiple connections.
|
|
1791
2225
|
*/
|
|
@@ -1795,11 +2229,12 @@ declare class ConnectionPool {
|
|
|
1795
2229
|
private _waitQueue;
|
|
1796
2230
|
private _closed;
|
|
1797
2231
|
private _maintenanceInterval?;
|
|
2232
|
+
private _rateLimiter;
|
|
1798
2233
|
private _minConnections;
|
|
1799
2234
|
private _maxConnections;
|
|
1800
2235
|
private _acquireTimeout;
|
|
1801
2236
|
private _idleTimeout;
|
|
1802
|
-
constructor(config: PoolConfig);
|
|
2237
|
+
constructor(config: PoolConfig, rateLimiterConfig?: Partial<RateLimiterConfig>);
|
|
1803
2238
|
/**
|
|
1804
2239
|
* Create a new connection pool.
|
|
1805
2240
|
*/
|
|
@@ -1854,7 +2289,7 @@ declare class ConnectionPool {
|
|
|
1854
2289
|
*/
|
|
1855
2290
|
close(): Promise<void>;
|
|
1856
2291
|
/**
|
|
1857
|
-
* Add a new connection to the pool.
|
|
2292
|
+
* Add a new connection to the pool with rate limiting and exponential backoff.
|
|
1858
2293
|
*/
|
|
1859
2294
|
private addConnection;
|
|
1860
2295
|
/**
|
|
@@ -1868,149 +2303,79 @@ declare class ConnectionPool {
|
|
|
1868
2303
|
}
|
|
1869
2304
|
|
|
1870
2305
|
/**
|
|
1871
|
-
*
|
|
2306
|
+
* gRPC Transport Layer
|
|
1872
2307
|
*
|
|
1873
|
-
*
|
|
2308
|
+
* Provides gRPC transport for communication with Geode server.
|
|
2309
|
+
* Uses @grpc/grpc-js with dynamic proto loading.
|
|
2310
|
+
*
|
|
2311
|
+
* Method mapping (QuicClientMessage field -> gRPC service RPC):
|
|
2312
|
+
* hello -> Handshake (unary)
|
|
2313
|
+
* execute -> Execute (server-streaming: schema + data pages)
|
|
2314
|
+
* pull -> reads next buffered message from the Execute stream
|
|
2315
|
+
* ping -> Ping (unary)
|
|
2316
|
+
* begin -> Begin (unary)
|
|
2317
|
+
* commit -> Commit (unary)
|
|
2318
|
+
* rollback -> Rollback (unary)
|
|
2319
|
+
* savepoint / rollbackTo -> not supported over gRPC
|
|
1874
2320
|
*/
|
|
1875
2321
|
|
|
1876
|
-
declare const MsgType: {
|
|
1877
|
-
readonly HELLO: "HELLO";
|
|
1878
|
-
readonly RUN_GQL: "RUN_GQL";
|
|
1879
|
-
readonly PULL: "PULL";
|
|
1880
|
-
readonly BEGIN: "BEGIN";
|
|
1881
|
-
readonly COMMIT: "COMMIT";
|
|
1882
|
-
readonly ROLLBACK: "ROLLBACK";
|
|
1883
|
-
readonly SAVEPOINT: "SAVEPOINT";
|
|
1884
|
-
readonly ROLLBACK_TO: "ROLLBACK_TO";
|
|
1885
|
-
readonly PING: "PING";
|
|
1886
|
-
};
|
|
1887
|
-
type MsgType = (typeof MsgType)[keyof typeof MsgType];
|
|
1888
|
-
declare const RespType: {
|
|
1889
|
-
readonly HELLO: "HELLO";
|
|
1890
|
-
readonly SCHEMA: "SCHEMA";
|
|
1891
|
-
readonly BINDINGS: "BINDINGS";
|
|
1892
|
-
readonly ERROR: "ERROR";
|
|
1893
|
-
readonly EXPLAIN: "EXPLAIN";
|
|
1894
|
-
readonly PROFILE: "PROFILE";
|
|
1895
|
-
readonly RESULT: "RESULT";
|
|
1896
|
-
readonly STATUS: "STATUS";
|
|
1897
|
-
};
|
|
1898
|
-
type RespType = (typeof RespType)[keyof typeof RespType];
|
|
1899
2322
|
/**
|
|
1900
|
-
*
|
|
2323
|
+
* gRPC transport for Geode database.
|
|
1901
2324
|
*/
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
2325
|
+
declare class GrpcTransport implements Transport {
|
|
2326
|
+
private _client;
|
|
2327
|
+
private _closed;
|
|
2328
|
+
private _address;
|
|
2329
|
+
private _pendingResponses;
|
|
2330
|
+
private _activeStream;
|
|
2331
|
+
constructor(address: string);
|
|
2332
|
+
/**
|
|
2333
|
+
* Connect to the Geode server using gRPC.
|
|
2334
|
+
*/
|
|
2335
|
+
static connect(cfg: GeodeConfig): Promise<GrpcTransport>;
|
|
2336
|
+
/**
|
|
2337
|
+
* Send a protobuf message and queue the response.
|
|
2338
|
+
* For gRPC, this makes the appropriate RPC call based on the message type.
|
|
2339
|
+
*/
|
|
2340
|
+
sendProto(msg: QuicClientMessage, signal?: AbortSignal): Promise<void>;
|
|
2341
|
+
/**
|
|
2342
|
+
* Receive a protobuf message from the queue.
|
|
2343
|
+
*/
|
|
2344
|
+
receiveProto(signal?: AbortSignal): Promise<QuicServerMessage>;
|
|
2345
|
+
/**
|
|
2346
|
+
* Legacy JSON send (not supported for gRPC).
|
|
2347
|
+
*/
|
|
2348
|
+
send(_msg: Record<string, unknown>, _signal?: AbortSignal): Promise<void>;
|
|
2349
|
+
/**
|
|
2350
|
+
* Legacy JSON receive (not supported for gRPC).
|
|
2351
|
+
*/
|
|
2352
|
+
receive(_signal?: AbortSignal): Promise<Buffer>;
|
|
2353
|
+
/**
|
|
2354
|
+
* Close the transport.
|
|
2355
|
+
*/
|
|
2356
|
+
close(): Promise<void>;
|
|
2357
|
+
/**
|
|
2358
|
+
* Check if transport is closed.
|
|
2359
|
+
*/
|
|
2360
|
+
isClosed(): boolean;
|
|
2361
|
+
/**
|
|
2362
|
+
* Get remote address.
|
|
2363
|
+
*/
|
|
2364
|
+
getAddress(): string;
|
|
2365
|
+
/**
|
|
2366
|
+
* Make a unary RPC call.
|
|
2367
|
+
*/
|
|
2368
|
+
private callUnary;
|
|
2369
|
+
/**
|
|
2370
|
+
* Call the server-streaming Execute RPC.
|
|
2371
|
+
* Collects all streamed ExecutionResponse messages into _pendingResponses.
|
|
2372
|
+
*/
|
|
2373
|
+
private callServerStream;
|
|
2374
|
+
/**
|
|
2375
|
+
* Check if closed and throw if so.
|
|
2376
|
+
*/
|
|
2377
|
+
private checkClosed;
|
|
1930
2378
|
}
|
|
1931
|
-
/**
|
|
1932
|
-
* Parse a JSON frame from raw bytes.
|
|
1933
|
-
*/
|
|
1934
|
-
declare function parseFrame(data: Buffer | string): Frame;
|
|
1935
|
-
/**
|
|
1936
|
-
* Check if a frame represents an error.
|
|
1937
|
-
*/
|
|
1938
|
-
declare function isErrorFrame(frame: Frame): boolean;
|
|
1939
|
-
/**
|
|
1940
|
-
* Check if a frame represents a schema.
|
|
1941
|
-
*/
|
|
1942
|
-
declare function isSchemaFrame(frame: Frame): boolean;
|
|
1943
|
-
/**
|
|
1944
|
-
* Check if a frame represents bindings (rows).
|
|
1945
|
-
*/
|
|
1946
|
-
declare function isBindingsFrame(frame: Frame): boolean;
|
|
1947
|
-
/**
|
|
1948
|
-
* Check if a frame is the final frame in a result set.
|
|
1949
|
-
*/
|
|
1950
|
-
declare function isFinalFrame(frame: Frame): boolean;
|
|
1951
|
-
/**
|
|
1952
|
-
* Convert an error frame to a DriverError.
|
|
1953
|
-
*/
|
|
1954
|
-
declare function frameToError(frame: Frame): DriverError;
|
|
1955
|
-
/**
|
|
1956
|
-
* Get column info from a schema frame.
|
|
1957
|
-
*/
|
|
1958
|
-
declare function getColumnsFromSchema(frame: Frame): ColumnInfo[];
|
|
1959
|
-
/**
|
|
1960
|
-
* Build a HELLO message.
|
|
1961
|
-
*/
|
|
1962
|
-
declare function buildHelloMessage(cfg: GeodeConfig): Record<string, unknown>;
|
|
1963
|
-
/**
|
|
1964
|
-
* Build a RUN_GQL message.
|
|
1965
|
-
*/
|
|
1966
|
-
declare function buildRunGQLMessage(query: string, params?: Record<string, unknown>): Record<string, unknown>;
|
|
1967
|
-
/**
|
|
1968
|
-
* Build a PULL message.
|
|
1969
|
-
*/
|
|
1970
|
-
declare function buildPullMessage(requestId: number, pageSize: number): Record<string, unknown>;
|
|
1971
|
-
/**
|
|
1972
|
-
* Build a BEGIN message.
|
|
1973
|
-
*/
|
|
1974
|
-
declare function buildBeginMessage(): Record<string, unknown>;
|
|
1975
|
-
/**
|
|
1976
|
-
* Build a COMMIT message.
|
|
1977
|
-
*/
|
|
1978
|
-
declare function buildCommitMessage(): Record<string, unknown>;
|
|
1979
|
-
/**
|
|
1980
|
-
* Build a ROLLBACK message.
|
|
1981
|
-
*/
|
|
1982
|
-
declare function buildRollbackMessage(): Record<string, unknown>;
|
|
1983
|
-
/**
|
|
1984
|
-
* Build a SAVEPOINT message.
|
|
1985
|
-
*/
|
|
1986
|
-
declare function buildSavepointMessage(name: string): Record<string, unknown>;
|
|
1987
|
-
/**
|
|
1988
|
-
* Build a ROLLBACK_TO message.
|
|
1989
|
-
*/
|
|
1990
|
-
declare function buildRollbackToMessage(name: string): Record<string, unknown>;
|
|
1991
|
-
/**
|
|
1992
|
-
* Build a PING message.
|
|
1993
|
-
*/
|
|
1994
|
-
declare function buildPingMessage(): Record<string, unknown>;
|
|
1995
|
-
/**
|
|
1996
|
-
* Serialize a message to JSON line format.
|
|
1997
|
-
*/
|
|
1998
|
-
declare function serializeMessage(msg: Record<string, unknown>): Buffer;
|
|
1999
|
-
/**
|
|
2000
|
-
* Rewrite positional placeholders (?) to named parameters ($p1, $p2, ...).
|
|
2001
|
-
*/
|
|
2002
|
-
declare function rewritePlaceholders(query: string, args: unknown[]): {
|
|
2003
|
-
query: string;
|
|
2004
|
-
params: Record<string, unknown>;
|
|
2005
|
-
};
|
|
2006
|
-
/**
|
|
2007
|
-
* Count the number of ? placeholders in a query.
|
|
2008
|
-
*/
|
|
2009
|
-
declare function countPlaceholders(query: string): number;
|
|
2010
|
-
/**
|
|
2011
|
-
* Merge named parameters with positional parameters.
|
|
2012
|
-
*/
|
|
2013
|
-
declare function mergeParams(positionalParams: Record<string, unknown>, namedParams?: Record<string, unknown>): Record<string, unknown>;
|
|
2014
2379
|
|
|
2015
2380
|
/**
|
|
2016
2381
|
* Input Validation Module
|
|
@@ -2293,6 +2658,28 @@ declare class PredicateBuilder {
|
|
|
2293
2658
|
isNotNull(expr: string): this;
|
|
2294
2659
|
/**
|
|
2295
2660
|
* Add a raw predicate expression.
|
|
2661
|
+
*
|
|
2662
|
+
* **⚠️ SECURITY WARNING: This method bypasses all input validation.**
|
|
2663
|
+
*
|
|
2664
|
+
* Using raw() with user-supplied input can lead to GQL injection attacks.
|
|
2665
|
+
* Only use this method when:
|
|
2666
|
+
* 1. The expression is entirely constructed from trusted, hardcoded strings
|
|
2667
|
+
* 2. All dynamic values are passed via the `params` argument (using $paramName syntax)
|
|
2668
|
+
*
|
|
2669
|
+
* @example
|
|
2670
|
+
* ```typescript
|
|
2671
|
+
* // SAFE: Using parameters for dynamic values
|
|
2672
|
+
* predicate().raw('n.custom_field CONTAINS $pattern', { pattern: userInput })
|
|
2673
|
+
*
|
|
2674
|
+
* // UNSAFE: Never interpolate user input directly
|
|
2675
|
+
* predicate().raw(`n.name = '${userInput}'`) // VULNERABLE TO INJECTION!
|
|
2676
|
+
* ```
|
|
2677
|
+
*
|
|
2678
|
+
* Consider using the typed predicate methods (eq, gt, contains, etc.) instead.
|
|
2679
|
+
*
|
|
2680
|
+
* @param expr - Raw predicate expression (MUST be trusted input)
|
|
2681
|
+
* @param params - Parameters to bind (safe for user input)
|
|
2682
|
+
* @deprecated Consider using typed predicate methods instead for better security.
|
|
2296
2683
|
*/
|
|
2297
2684
|
raw(expr: string, params?: QueryParams): this;
|
|
2298
2685
|
/**
|
|
@@ -2328,6 +2715,26 @@ declare class QueryBuilder {
|
|
|
2328
2715
|
optionalMatch(pattern: string | PatternBuilder): this;
|
|
2329
2716
|
/**
|
|
2330
2717
|
* Add a WHERE clause.
|
|
2718
|
+
*
|
|
2719
|
+
* **⚠️ SECURITY WARNING when using string predicates:**
|
|
2720
|
+
*
|
|
2721
|
+
* When passing a string predicate, this method does NOT validate or sanitize input.
|
|
2722
|
+
* Using string predicates with user-supplied data can lead to GQL injection attacks.
|
|
2723
|
+
*
|
|
2724
|
+
* @example
|
|
2725
|
+
* ```typescript
|
|
2726
|
+
* // RECOMMENDED: Use PredicateBuilder for type-safe, injection-resistant queries
|
|
2727
|
+
* query().where(predicate().eq('n.name', userInput))
|
|
2728
|
+
*
|
|
2729
|
+
* // SAFE: Using parameters with string predicates
|
|
2730
|
+
* query().where('n.name = $name', { name: userInput })
|
|
2731
|
+
*
|
|
2732
|
+
* // UNSAFE: Never interpolate user input directly in string predicates
|
|
2733
|
+
* query().where(`n.name = '${userInput}'`) // VULNERABLE TO INJECTION!
|
|
2734
|
+
* ```
|
|
2735
|
+
*
|
|
2736
|
+
* @param predicate - A PredicateBuilder (recommended) or raw predicate string
|
|
2737
|
+
* @param params - Parameters to bind when using string predicates
|
|
2331
2738
|
*/
|
|
2332
2739
|
where(predicate: string | PredicateBuilder, params?: QueryParams): this;
|
|
2333
2740
|
/**
|
|
@@ -2379,7 +2786,29 @@ declare class QueryBuilder {
|
|
|
2379
2786
|
*/
|
|
2380
2787
|
remove(...items: string[]): this;
|
|
2381
2788
|
/**
|
|
2382
|
-
* Add raw clause.
|
|
2789
|
+
* Add a raw GQL clause.
|
|
2790
|
+
*
|
|
2791
|
+
* **⚠️ SECURITY WARNING: This method bypasses all input validation.**
|
|
2792
|
+
*
|
|
2793
|
+
* Using raw() with user-supplied input can lead to GQL injection attacks.
|
|
2794
|
+
* Only use this method when:
|
|
2795
|
+
* 1. The clause is entirely constructed from trusted, hardcoded strings
|
|
2796
|
+
* 2. All dynamic values are passed via the `params` argument (using $paramName syntax)
|
|
2797
|
+
*
|
|
2798
|
+
* @example
|
|
2799
|
+
* ```typescript
|
|
2800
|
+
* // SAFE: Using parameters for dynamic values
|
|
2801
|
+
* query().raw('CALL db.index.fulltext.queryNodes("idx", $term)', { term: userInput })
|
|
2802
|
+
*
|
|
2803
|
+
* // UNSAFE: Never interpolate user input directly
|
|
2804
|
+
* query().raw(`MATCH (n:${userLabel})`) // VULNERABLE TO INJECTION!
|
|
2805
|
+
* ```
|
|
2806
|
+
*
|
|
2807
|
+
* Consider using the typed query builder methods instead.
|
|
2808
|
+
*
|
|
2809
|
+
* @param clause - Raw GQL clause (MUST be trusted input)
|
|
2810
|
+
* @param params - Parameters to bind (safe for user input)
|
|
2811
|
+
* @deprecated Consider using typed query builder methods instead for better security.
|
|
2383
2812
|
*/
|
|
2384
2813
|
raw(clause: string, params?: QueryParams): this;
|
|
2385
2814
|
/**
|
|
@@ -2427,4 +2856,4 @@ declare function node(): NodePatternBuilder;
|
|
|
2427
2856
|
*/
|
|
2428
2857
|
declare function edge(): EdgePatternBuilder;
|
|
2429
2858
|
|
|
2430
|
-
export {
|
|
2859
|
+
export { AuthClient, BaseTransport, type BatchOptions, type BatchQuery, type BatchResult, type BatchSummary, type BeginRequest, type BeginResponse, type ClientOptions, type ColumnDef, type ColumnDefinition, type ColumnInfo, type CommitRequest, type CommitResponse, ConfigError, Connection, ConnectionPool, type ConnectionState, type CreateRLSPolicyOptions, type CreateRoleOptions, type CreateUserOptions, DEFAULT_CONFORMANCE, DEFAULT_GRPC_PORT, DEFAULT_HELLO_NAME, DEFAULT_HELLO_VERSION, DEFAULT_PAGE_SIZE, DEFAULT_PORT, type DSNScheme, type DataPage, DriverError, type EdgeDirection, type EdgePattern, EdgePatternBuilder, ErrBadConn, ErrClosed, ErrNoTx, ErrQueryInProgress, ErrRowsClosed, ErrTxDone, ErrTxInProgress, type ExecuteRequest, type ExecutionResponse, type ExplainOptions, type GQLEdge, type GQLId, type GQLNode, type GQLPath, type GQLRange, type GQLType, GQLValue, type GQLValueKind, GeodeClient, type GeodeConfig, type GeodeError, GrpcTransport, type HelloRequest, type HelloResponse, MAX_PAGE_SIZE, MAX_QUERY_LENGTH, MockTransport, type NodePattern, NodePatternBuilder, type OperationTiming, type Param, type ParameterInfo, PatternBuilder, type PatternElement, type Permission, type PingRequest, type PingResponse, type PlanOperation, type PoolConfig, PredicateBuilder, type PredicateOp, PreparedStatement, type ProtoError, type Row$1 as ProtoRow, type ProtoValue, type PullRequest, type PullResponse, QueryBuilder, type QueryOptions, type QueryParams, type QueryPlan, type QueryProfile, QueryResult, QueryResultIterator, type QuicClientMessage, type QuicServerMessage, QuicTransport, QuicTransport as QuicheTransport, type RLSPolicy, type RawEdge, type Role, type RollbackRequest, type RollbackResponse, type Row, SUPPORTED_SCHEMES, type SchemaDefinition, SecurityError, type SortDirection, StateError, type Status, StatusClass, type StatusClassType, Transaction, type Transport, TransportError, type TransportType, type User, batch, batchAll, batchFirst, batchMap, batchParallel, buildBeginRequest, buildCommitRequest, buildExecuteRequest, buildHelloRequest, buildPingRequest, buildPullRequest, buildRollbackRequest, buildRollbackToRequest, buildSavepointRequest, buildTLSConfig, cloneConfig, createAuthClient, createClient, createClientWithConfig, createTransport, decodeLengthPrefix, decodeQuicServerMessage, defaultConfig, edge, encodeQuicClientMessage, encodeWithLengthPrefix, ensureProtoInitialized, explain, extractParameters, formatPlan, formatProfile, fromJSON, getAddress, getProtoPath, isDriverError, isGeodeError, isRetryableError, jsToProtoValue, node, parseDSN, parseGQLType, parseRow, pattern, predicate, prepare, profile, protoValueToJS, query, redactConfig, redactDSN, rowToObject, rowToRecord, sanitizeForLog, validateConfig, validateHostname, validatePageSize, validateParamName, validateParamValue, validatePort, validateQuery, validateSavepointName, withTransaction };
|