@geodedb/client 1.0.0-alpha.23 → 1.0.2
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/dist/index.d.ts +432 -406
- package/dist/index.js +2321 -1875
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/proto/geode.proto +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -73,8 +73,12 @@ interface GeodeConfig {
|
|
|
73
73
|
keepAliveInterval?: number;
|
|
74
74
|
/** Maximum idle time in milliseconds (default: 30000) */
|
|
75
75
|
maxIdleTime?: number;
|
|
76
|
+
/** Inline receive timeout in milliseconds (default: 5000) */
|
|
77
|
+
inlineTimeout?: number;
|
|
76
78
|
/** Enable TLS for gRPC (default: true) */
|
|
77
79
|
tls?: boolean;
|
|
80
|
+
/** Graph name for DSN graph binding. When set, the server binds the session to this graph. */
|
|
81
|
+
graph?: string;
|
|
78
82
|
}
|
|
79
83
|
/**
|
|
80
84
|
* Connection pool configuration.
|
|
@@ -271,13 +275,24 @@ declare class StateError extends Error implements GeodeError {
|
|
|
271
275
|
* Connection state enumeration.
|
|
272
276
|
*/
|
|
273
277
|
type ConnectionState = 'idle' | 'executing' | 'in_transaction' | 'fetching' | 'closed' | 'error';
|
|
274
|
-
declare const
|
|
275
|
-
declare const
|
|
276
|
-
declare const
|
|
277
|
-
declare const
|
|
278
|
-
declare const
|
|
279
|
-
declare const
|
|
280
|
-
declare const
|
|
278
|
+
declare const ERR_CLOSED_MESSAGE = "geode: connection closed";
|
|
279
|
+
declare const ERR_QUERY_IN_PROGRESS_MESSAGE = "geode: query already in progress";
|
|
280
|
+
declare const ERR_TX_IN_PROGRESS_MESSAGE = "geode: transaction already in progress";
|
|
281
|
+
declare const ERR_NO_TX_MESSAGE = "geode: no transaction in progress";
|
|
282
|
+
declare const ERR_TX_DONE_MESSAGE = "geode: transaction already committed or rolled back";
|
|
283
|
+
declare const ERR_ROWS_CLOSED_MESSAGE = "geode: rows closed";
|
|
284
|
+
declare const ERR_BAD_CONN_MESSAGE = "geode: bad connection";
|
|
285
|
+
declare function ErrClosed(): Error;
|
|
286
|
+
declare function ErrQueryInProgress(): Error;
|
|
287
|
+
declare function ErrTxInProgress(): Error;
|
|
288
|
+
declare function ErrNoTx(): Error;
|
|
289
|
+
declare function ErrTxDone(): Error;
|
|
290
|
+
declare function ErrRowsClosed(): Error;
|
|
291
|
+
declare function ErrBadConn(): Error;
|
|
292
|
+
/**
|
|
293
|
+
* Check if an error is a specific sentinel error by message.
|
|
294
|
+
*/
|
|
295
|
+
declare function isSentinelError(err: unknown, message: string): boolean;
|
|
281
296
|
/**
|
|
282
297
|
* Type guard for DriverError.
|
|
283
298
|
*/
|
|
@@ -304,12 +319,15 @@ interface HelloRequest {
|
|
|
304
319
|
clientName: string;
|
|
305
320
|
clientVersion: string;
|
|
306
321
|
wantedConformance: string;
|
|
322
|
+
graph?: string;
|
|
307
323
|
}
|
|
308
324
|
interface HelloResponse {
|
|
309
325
|
success: boolean;
|
|
310
326
|
sessionId: string;
|
|
311
327
|
errorMessage: string;
|
|
312
328
|
capabilities: string[];
|
|
329
|
+
passwordResetRequired?: boolean;
|
|
330
|
+
graph?: string;
|
|
313
331
|
}
|
|
314
332
|
interface Param {
|
|
315
333
|
name: string;
|
|
@@ -555,6 +573,12 @@ interface QuicServerMessage {
|
|
|
555
573
|
restore?: unknown;
|
|
556
574
|
uploadBackup?: unknown;
|
|
557
575
|
}
|
|
576
|
+
/**
|
|
577
|
+
* Initialize protobuf types synchronously.
|
|
578
|
+
* Safe to call multiple times; only loads on first call.
|
|
579
|
+
* Prefer ensureProtoInitialized() in async contexts to avoid blocking the event loop.
|
|
580
|
+
*/
|
|
581
|
+
declare function initProtoSync(): void;
|
|
558
582
|
/**
|
|
559
583
|
* Ensure proto is initialized.
|
|
560
584
|
*/
|
|
@@ -586,7 +610,7 @@ declare function decodeLengthPrefix(data: Buffer): number;
|
|
|
586
610
|
/**
|
|
587
611
|
* Build a HelloRequest message.
|
|
588
612
|
*/
|
|
589
|
-
declare function buildHelloRequest(username: string, password: string, clientName: string, clientVersion: string, conformance: string, tenantId?: string): QuicClientMessage;
|
|
613
|
+
declare function buildHelloRequest(username: string, password: string, clientName: string, clientVersion: string, conformance: string, tenantId?: string, graph?: string): QuicClientMessage;
|
|
590
614
|
/**
|
|
591
615
|
* Build an ExecuteRequest message.
|
|
592
616
|
*/
|
|
@@ -679,9 +703,13 @@ declare abstract class BaseTransport implements Transport {
|
|
|
679
703
|
declare class QuicTransport extends BaseTransport {
|
|
680
704
|
private _client;
|
|
681
705
|
private _stream;
|
|
682
|
-
private
|
|
706
|
+
private _chunks;
|
|
707
|
+
private _totalLength;
|
|
708
|
+
private _maxMessageSize;
|
|
709
|
+
private _maxBufferBytes;
|
|
683
710
|
private _pendingProtoReads;
|
|
684
|
-
|
|
711
|
+
private _pendingResponses;
|
|
712
|
+
constructor(address: string, maxMessageSize?: number, maxBufferBytes?: number);
|
|
685
713
|
/**
|
|
686
714
|
* Connect to the Geode server using QUIC.
|
|
687
715
|
*/
|
|
@@ -694,10 +722,22 @@ declare class QuicTransport extends BaseTransport {
|
|
|
694
722
|
* Reject all pending reads with an error.
|
|
695
723
|
*/
|
|
696
724
|
private rejectPendingReads;
|
|
725
|
+
/**
|
|
726
|
+
* Consolidate the chunk list into a single buffer.
|
|
727
|
+
* Called only when we know we have enough data for at least one operation.
|
|
728
|
+
*/
|
|
729
|
+
private consolidateChunks;
|
|
697
730
|
/**
|
|
698
731
|
* Process received data (length-prefixed protobuf messages).
|
|
732
|
+
*
|
|
733
|
+
* Uses a chunk list pattern instead of Buffer.concat on every call
|
|
734
|
+
* to avoid O(n^2) copying of the accumulated buffer.
|
|
699
735
|
*/
|
|
700
736
|
private processData;
|
|
737
|
+
/**
|
|
738
|
+
* Handle oversized data by closing the transport.
|
|
739
|
+
*/
|
|
740
|
+
private handleOversize;
|
|
701
741
|
/**
|
|
702
742
|
* Send a protobuf message with length prefix.
|
|
703
743
|
*/
|
|
@@ -741,6 +781,80 @@ declare class MockTransport extends BaseTransport {
|
|
|
741
781
|
*/
|
|
742
782
|
declare function createTransport(cfg: GeodeConfig): Promise<Transport>;
|
|
743
783
|
|
|
784
|
+
/**
|
|
785
|
+
* GQL Value Class
|
|
786
|
+
*
|
|
787
|
+
* Type-safe wrapper for GQL values in the ISO/IEC 39075:2024 type system.
|
|
788
|
+
* Extracted from types.ts for file size management.
|
|
789
|
+
*/
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* GQL Value wrapper for type-safe value handling.
|
|
793
|
+
*/
|
|
794
|
+
declare class GQLValue {
|
|
795
|
+
readonly kind: GQLValueKind;
|
|
796
|
+
private _intValue?;
|
|
797
|
+
private _floatValue?;
|
|
798
|
+
private _boolValue?;
|
|
799
|
+
private _stringValue?;
|
|
800
|
+
private _decimalValue?;
|
|
801
|
+
private _arrayValue?;
|
|
802
|
+
private _objectValue?;
|
|
803
|
+
private _bytesValue?;
|
|
804
|
+
private _dateValue?;
|
|
805
|
+
private _rangeValue?;
|
|
806
|
+
private _nodeValue?;
|
|
807
|
+
private _edgeValue?;
|
|
808
|
+
private _pathValue?;
|
|
809
|
+
private _rawValue?;
|
|
810
|
+
private constructor();
|
|
811
|
+
static null(): GQLValue;
|
|
812
|
+
static bool(value: boolean): GQLValue;
|
|
813
|
+
static int(value: number | bigint): GQLValue;
|
|
814
|
+
static float(value: number): GQLValue;
|
|
815
|
+
static string(value: string): GQLValue;
|
|
816
|
+
static decimal(value: string | number | Decimal): GQLValue;
|
|
817
|
+
static array(values: GQLValue[]): GQLValue;
|
|
818
|
+
static object(values: Map<string, GQLValue> | Record<string, GQLValue>): GQLValue;
|
|
819
|
+
static bytes(value: Uint8Array | Buffer): GQLValue;
|
|
820
|
+
static date(value: Date): GQLValue;
|
|
821
|
+
static time(value: Date): GQLValue;
|
|
822
|
+
static timestamp(value: Date): GQLValue;
|
|
823
|
+
static uuid(value: string): GQLValue;
|
|
824
|
+
static json(value: unknown): GQLValue;
|
|
825
|
+
static node(value: GQLNode): GQLValue;
|
|
826
|
+
static edge(value: GQLEdge): GQLValue;
|
|
827
|
+
static path(value: GQLPath): GQLValue;
|
|
828
|
+
static range<T>(value: GQLRange<T>): GQLValue;
|
|
829
|
+
static unknown(value: unknown): GQLValue;
|
|
830
|
+
get isNull(): boolean;
|
|
831
|
+
get asBool(): boolean;
|
|
832
|
+
get asInt(): bigint;
|
|
833
|
+
get asNumber(): number;
|
|
834
|
+
get asFloat(): number;
|
|
835
|
+
get asString(): string;
|
|
836
|
+
get asDecimal(): Decimal;
|
|
837
|
+
get asArray(): GQLValue[];
|
|
838
|
+
get asObject(): Map<string, GQLValue>;
|
|
839
|
+
get asBytes(): Uint8Array;
|
|
840
|
+
get asDate(): Date;
|
|
841
|
+
get asNode(): GQLNode;
|
|
842
|
+
get asEdge(): GQLEdge;
|
|
843
|
+
get asPath(): GQLPath;
|
|
844
|
+
get asRange(): GQLRange;
|
|
845
|
+
get asJSON(): unknown;
|
|
846
|
+
get raw(): unknown;
|
|
847
|
+
toString(): string;
|
|
848
|
+
/**
|
|
849
|
+
* Convert to a plain JavaScript value.
|
|
850
|
+
*/
|
|
851
|
+
toJS(): unknown;
|
|
852
|
+
/**
|
|
853
|
+
* Convert to JSON-serializable format.
|
|
854
|
+
*/
|
|
855
|
+
toJSON(): unknown;
|
|
856
|
+
}
|
|
857
|
+
|
|
744
858
|
/**
|
|
745
859
|
* GQL Type System
|
|
746
860
|
*
|
|
@@ -820,72 +934,6 @@ interface GQLPath {
|
|
|
820
934
|
nodes: GQLNode[];
|
|
821
935
|
edges: GQLEdge[];
|
|
822
936
|
}
|
|
823
|
-
/**
|
|
824
|
-
* GQL Value wrapper for type-safe value handling.
|
|
825
|
-
*/
|
|
826
|
-
declare class GQLValue {
|
|
827
|
-
readonly kind: GQLValueKind;
|
|
828
|
-
private _intValue;
|
|
829
|
-
private _floatValue;
|
|
830
|
-
private _boolValue;
|
|
831
|
-
private _stringValue;
|
|
832
|
-
private _decimalValue?;
|
|
833
|
-
private _arrayValue;
|
|
834
|
-
private _objectValue;
|
|
835
|
-
private _bytesValue;
|
|
836
|
-
private _dateValue?;
|
|
837
|
-
private _rangeValue?;
|
|
838
|
-
private _nodeValue?;
|
|
839
|
-
private _edgeValue?;
|
|
840
|
-
private _pathValue?;
|
|
841
|
-
private _rawValue?;
|
|
842
|
-
private constructor();
|
|
843
|
-
static null(): GQLValue;
|
|
844
|
-
static bool(value: boolean): GQLValue;
|
|
845
|
-
static int(value: number | bigint): GQLValue;
|
|
846
|
-
static float(value: number): GQLValue;
|
|
847
|
-
static string(value: string): GQLValue;
|
|
848
|
-
static decimal(value: string | number | Decimal): GQLValue;
|
|
849
|
-
static array(values: GQLValue[]): GQLValue;
|
|
850
|
-
static object(values: Map<string, GQLValue> | Record<string, GQLValue>): GQLValue;
|
|
851
|
-
static bytes(value: Uint8Array | Buffer): GQLValue;
|
|
852
|
-
static date(value: Date): GQLValue;
|
|
853
|
-
static time(value: Date): GQLValue;
|
|
854
|
-
static timestamp(value: Date): GQLValue;
|
|
855
|
-
static uuid(value: string): GQLValue;
|
|
856
|
-
static json(value: unknown): GQLValue;
|
|
857
|
-
static node(value: GQLNode): GQLValue;
|
|
858
|
-
static edge(value: GQLEdge): GQLValue;
|
|
859
|
-
static path(value: GQLPath): GQLValue;
|
|
860
|
-
static range<T>(value: GQLRange<T>): GQLValue;
|
|
861
|
-
static unknown(value: unknown): GQLValue;
|
|
862
|
-
get isNull(): boolean;
|
|
863
|
-
get asBool(): boolean;
|
|
864
|
-
get asInt(): bigint;
|
|
865
|
-
get asNumber(): number;
|
|
866
|
-
get asFloat(): number;
|
|
867
|
-
get asString(): string;
|
|
868
|
-
get asDecimal(): Decimal;
|
|
869
|
-
get asArray(): GQLValue[];
|
|
870
|
-
get asObject(): Map<string, GQLValue>;
|
|
871
|
-
get asBytes(): Uint8Array;
|
|
872
|
-
get asDate(): Date;
|
|
873
|
-
get asNode(): GQLNode;
|
|
874
|
-
get asEdge(): GQLEdge;
|
|
875
|
-
get asPath(): GQLPath;
|
|
876
|
-
get asRange(): GQLRange;
|
|
877
|
-
get asJSON(): unknown;
|
|
878
|
-
get raw(): unknown;
|
|
879
|
-
toString(): string;
|
|
880
|
-
/**
|
|
881
|
-
* Convert to a plain JavaScript value.
|
|
882
|
-
*/
|
|
883
|
-
toJS(): unknown;
|
|
884
|
-
/**
|
|
885
|
-
* Convert to JSON-serializable format.
|
|
886
|
-
*/
|
|
887
|
-
toJSON(): unknown;
|
|
888
|
-
}
|
|
889
937
|
/**
|
|
890
938
|
* Parse a GQL type string to GQLValueKind.
|
|
891
939
|
*/
|
|
@@ -917,6 +965,7 @@ type Row = Map<string, GQLValue>;
|
|
|
917
965
|
* Convert raw row data to typed Row.
|
|
918
966
|
*/
|
|
919
967
|
declare function parseRow(raw: Record<string, unknown>, columns: ColumnInfo[]): Row;
|
|
968
|
+
|
|
920
969
|
/**
|
|
921
970
|
* Convert Row to plain object.
|
|
922
971
|
*
|
|
@@ -982,6 +1031,11 @@ declare class QueryResult implements AsyncIterable<Row> {
|
|
|
982
1031
|
* Async iterator implementation.
|
|
983
1032
|
*/
|
|
984
1033
|
[Symbol.asyncIterator](): AsyncIterator<Row>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Collect all remaining rows as raw records without GQLValue conversion.
|
|
1036
|
+
* This is the fast path used by queryAll() to avoid double-conversion.
|
|
1037
|
+
*/
|
|
1038
|
+
_collectRawRecords(): Promise<Record<string, unknown>[]>;
|
|
985
1039
|
/**
|
|
986
1040
|
* Get all remaining rows as an array.
|
|
987
1041
|
*/
|
|
@@ -1081,10 +1135,18 @@ declare class Transaction {
|
|
|
1081
1135
|
exec(query: string, options?: QueryOptions): Promise<void>;
|
|
1082
1136
|
/**
|
|
1083
1137
|
* Create a savepoint.
|
|
1138
|
+
*
|
|
1139
|
+
* Savepoints are only supported over the QUIC transport. Over gRPC this
|
|
1140
|
+
* rejects with a {@link DriverError} (statusClass `58000`) directing callers
|
|
1141
|
+
* to use `quic://`.
|
|
1084
1142
|
*/
|
|
1085
1143
|
savepoint(name: string, signal?: AbortSignal): Promise<void>;
|
|
1086
1144
|
/**
|
|
1087
1145
|
* Rollback to a savepoint.
|
|
1146
|
+
*
|
|
1147
|
+
* Savepoints are only supported over the QUIC transport. Over gRPC this
|
|
1148
|
+
* rejects with a {@link DriverError} (statusClass `58000`) directing callers
|
|
1149
|
+
* to use `quic://`.
|
|
1088
1150
|
*/
|
|
1089
1151
|
rollbackTo(name: string, signal?: AbortSignal): Promise<void>;
|
|
1090
1152
|
/**
|
|
@@ -1157,12 +1219,17 @@ declare class PreparedStatement {
|
|
|
1157
1219
|
private _query;
|
|
1158
1220
|
private _parameters;
|
|
1159
1221
|
private _closed;
|
|
1222
|
+
private _onClose?;
|
|
1160
1223
|
/**
|
|
1161
1224
|
* Create a new prepared statement.
|
|
1162
1225
|
*
|
|
1226
|
+
* @param conn - Connection to use for execution
|
|
1227
|
+
* @param query - Query text with parameters
|
|
1228
|
+
* @param onClose - Optional callback invoked when close() is called (e.g., to release a pooled connection)
|
|
1229
|
+
*
|
|
1163
1230
|
* @internal Use Connection.prepare() instead.
|
|
1164
1231
|
*/
|
|
1165
|
-
constructor(conn: Connection, query: string);
|
|
1232
|
+
constructor(conn: Connection, query: string, onClose?: () => void);
|
|
1166
1233
|
/**
|
|
1167
1234
|
* Get the query text.
|
|
1168
1235
|
*/
|
|
@@ -1221,6 +1288,8 @@ declare class PreparedStatement {
|
|
|
1221
1288
|
* Close the prepared statement.
|
|
1222
1289
|
*
|
|
1223
1290
|
* After closing, the statement cannot be executed.
|
|
1291
|
+
* If a release callback was provided (e.g., to return a pooled connection),
|
|
1292
|
+
* it is invoked exactly once on the first call to close().
|
|
1224
1293
|
*/
|
|
1225
1294
|
close(): void;
|
|
1226
1295
|
/**
|
|
@@ -1415,6 +1484,14 @@ interface BatchOptions {
|
|
|
1415
1484
|
* By default, queries are executed sequentially and all results are collected.
|
|
1416
1485
|
* Set stopOnError to true to abort on the first failure.
|
|
1417
1486
|
*
|
|
1487
|
+
* When `options.concurrency` is greater than 1, the batch delegates to
|
|
1488
|
+
* {@link batchParallel} for concurrent execution. Note that a single
|
|
1489
|
+
* `Connection` can only execute one query at a time due to the connection
|
|
1490
|
+
* state machine, so `batchParallel` will automatically fall back to
|
|
1491
|
+
* sequential execution (concurrency=1) when given a single connection.
|
|
1492
|
+
* For true parallelism, use a `ConnectionPool` to acquire separate
|
|
1493
|
+
* connections per concurrent query.
|
|
1494
|
+
*
|
|
1418
1495
|
* @param conn - Connection to use
|
|
1419
1496
|
* @param queries - Array of queries to execute
|
|
1420
1497
|
* @param options - Batch execution options
|
|
@@ -1479,12 +1556,22 @@ declare function batchMap(conn: Connection, queryTemplate: string, items: QueryP
|
|
|
1479
1556
|
* Unlike the sequential batch(), this executes multiple queries concurrently
|
|
1480
1557
|
* up to the specified limit.
|
|
1481
1558
|
*
|
|
1482
|
-
*
|
|
1559
|
+
* **Important:** A single `Connection` can only execute one query at a time
|
|
1560
|
+
* (the connection state machine throws `ErrQueryInProgress` for concurrent
|
|
1561
|
+
* queries). When a single connection is provided with concurrency > 1, this
|
|
1562
|
+
* function automatically falls back to sequential execution (concurrency=1)
|
|
1563
|
+
* to prevent runtime errors.
|
|
1483
1564
|
*
|
|
1484
|
-
*
|
|
1565
|
+
* For true parallel execution, use a connection pool or connection factory
|
|
1566
|
+
* that provides separate connections per concurrent query.
|
|
1567
|
+
*
|
|
1568
|
+
* Note: When executing concurrently, results may arrive out of order but
|
|
1569
|
+
* are sorted by index before returning.
|
|
1570
|
+
*
|
|
1571
|
+
* @param conn - Connection to use (single connection forces sequential execution)
|
|
1485
1572
|
* @param queries - Array of queries to execute
|
|
1486
1573
|
* @param options - Batch execution options with concurrency
|
|
1487
|
-
* @returns Batch summary (results
|
|
1574
|
+
* @returns Batch summary (results sorted by query index)
|
|
1488
1575
|
*/
|
|
1489
1576
|
declare function batchParallel(conn: Connection, queries: BatchQuery[], options?: BatchOptions & {
|
|
1490
1577
|
concurrency: number;
|
|
@@ -1532,109 +1619,70 @@ declare class Connection {
|
|
|
1532
1619
|
* Create a connection with a custom transport (for testing).
|
|
1533
1620
|
*/
|
|
1534
1621
|
static connectWithTransport(config: GeodeConfig, transport: Transport): Promise<Connection>;
|
|
1535
|
-
/**
|
|
1536
|
-
* Get connection configuration.
|
|
1537
|
-
*/
|
|
1622
|
+
/** Get connection configuration. */
|
|
1538
1623
|
get config(): Readonly<GeodeConfig>;
|
|
1539
|
-
/**
|
|
1540
|
-
* Get current connection state.
|
|
1541
|
-
*/
|
|
1624
|
+
/** Get current connection state. */
|
|
1542
1625
|
get state(): ConnectionState;
|
|
1543
|
-
/**
|
|
1544
|
-
* Check if connection is in a transaction.
|
|
1545
|
-
*/
|
|
1626
|
+
/** Check if connection is in a transaction. */
|
|
1546
1627
|
get inTransaction(): boolean;
|
|
1547
|
-
/**
|
|
1548
|
-
* Check if connection is closed.
|
|
1549
|
-
*/
|
|
1628
|
+
/** Check if connection is closed. */
|
|
1550
1629
|
get isClosed(): boolean;
|
|
1551
|
-
/**
|
|
1552
|
-
* Get session ID.
|
|
1553
|
-
*/
|
|
1630
|
+
/** Get session ID. */
|
|
1554
1631
|
get sessionId(): string;
|
|
1555
|
-
/**
|
|
1556
|
-
* Perform the HELLO handshake.
|
|
1557
|
-
*/
|
|
1632
|
+
/** Perform the HELLO handshake. */
|
|
1558
1633
|
private hello;
|
|
1559
|
-
/**
|
|
1560
|
-
* Execute a query that returns rows.
|
|
1561
|
-
*/
|
|
1634
|
+
/** Execute a query that returns rows. */
|
|
1562
1635
|
query(query: string, options?: QueryOptions): Promise<QueryResult>;
|
|
1563
|
-
/**
|
|
1564
|
-
* Execute a query and return all rows as an array.
|
|
1565
|
-
*/
|
|
1636
|
+
/** Execute a query and return all rows as an array. */
|
|
1566
1637
|
queryAll(query: string, options?: QueryOptions): Promise<Record<string, unknown>[]>;
|
|
1567
|
-
/**
|
|
1568
|
-
* Execute a query that doesn't return rows.
|
|
1569
|
-
*/
|
|
1638
|
+
/** Execute a query that doesn't return rows. */
|
|
1570
1639
|
exec(query: string, options?: QueryOptions): Promise<void>;
|
|
1571
|
-
/**
|
|
1572
|
-
* Fetch the next page of results (internal).
|
|
1573
|
-
*/
|
|
1640
|
+
/** @internal Fetch the next page of results. Called by QueryResult. */
|
|
1574
1641
|
_fetchNextPage(pageSize: number, signal?: AbortSignal): Promise<{
|
|
1575
1642
|
rows: Record<string, unknown>[];
|
|
1576
1643
|
final: boolean;
|
|
1577
1644
|
}>;
|
|
1578
|
-
/**
|
|
1579
|
-
* Try to receive an inline response with short timeout.
|
|
1580
|
-
*/
|
|
1645
|
+
/** Try to receive an inline response with short timeout. */
|
|
1581
1646
|
private _tryReceiveInline;
|
|
1582
|
-
/**
|
|
1583
|
-
|
|
1584
|
-
|
|
1647
|
+
/** Read inline execute responses until a page, error, heartbeat, or timeout arrives. */
|
|
1648
|
+
private _readInlineExecute;
|
|
1649
|
+
/** Drain remaining data pages until final=true to prevent query corruption (QUAL-T7). */
|
|
1650
|
+
private _drainRemainingPages;
|
|
1651
|
+
/** @internal Release the active result, returning the connection to idle. */
|
|
1585
1652
|
_releaseResult(result: QueryResult): void;
|
|
1586
|
-
/**
|
|
1587
|
-
* Begin a transaction.
|
|
1588
|
-
*/
|
|
1653
|
+
/** Begin a transaction. */
|
|
1589
1654
|
begin(signal?: AbortSignal): Promise<Transaction>;
|
|
1590
|
-
/**
|
|
1591
|
-
* Commit the current transaction (internal).
|
|
1592
|
-
*/
|
|
1655
|
+
/** @internal Commit the current transaction. Called by Transaction. */
|
|
1593
1656
|
_commit(signal?: AbortSignal): Promise<void>;
|
|
1594
|
-
/**
|
|
1595
|
-
* Rollback the current transaction (internal).
|
|
1596
|
-
*/
|
|
1657
|
+
/** @internal Rollback the current transaction. Called by Transaction. */
|
|
1597
1658
|
_rollback(signal?: AbortSignal): Promise<void>;
|
|
1598
|
-
/**
|
|
1599
|
-
* Create a savepoint (internal).
|
|
1600
|
-
*/
|
|
1659
|
+
/** @internal Create a named savepoint. Called by Transaction. */
|
|
1601
1660
|
_savepoint(name: string, signal?: AbortSignal): Promise<void>;
|
|
1602
|
-
/**
|
|
1603
|
-
* Rollback to a savepoint (internal).
|
|
1604
|
-
*/
|
|
1661
|
+
/** @internal Rollback to a previously created savepoint. Called by Transaction. */
|
|
1605
1662
|
_rollbackTo(name: string, signal?: AbortSignal): Promise<void>;
|
|
1606
|
-
/**
|
|
1607
|
-
* Ping the server to check connection health.
|
|
1608
|
-
*/
|
|
1663
|
+
/** Ping the server to check connection health. */
|
|
1609
1664
|
ping(signal?: AbortSignal): Promise<void>;
|
|
1610
|
-
/**
|
|
1611
|
-
* Reset the connection session.
|
|
1612
|
-
*/
|
|
1665
|
+
/** Reset the connection session. */
|
|
1613
1666
|
reset(signal?: AbortSignal): Promise<void>;
|
|
1614
|
-
/**
|
|
1615
|
-
* Close the connection.
|
|
1616
|
-
*/
|
|
1667
|
+
/** Close the connection. */
|
|
1617
1668
|
close(): Promise<void>;
|
|
1618
|
-
/**
|
|
1619
|
-
* Create a prepared statement.
|
|
1620
|
-
*/
|
|
1669
|
+
/** Create a prepared statement. */
|
|
1621
1670
|
prepare(query: string): Promise<PreparedStatement>;
|
|
1622
|
-
/**
|
|
1623
|
-
* Get the query execution plan without executing.
|
|
1624
|
-
*/
|
|
1671
|
+
/** Get the query execution plan without executing. */
|
|
1625
1672
|
explain(query: string, options?: ExplainOptions): Promise<QueryPlan>;
|
|
1626
|
-
/**
|
|
1627
|
-
* Execute a query with profiling.
|
|
1628
|
-
*/
|
|
1673
|
+
/** Execute a query with profiling. */
|
|
1629
1674
|
profile(query: string, options?: ExplainOptions): Promise<QueryProfile>;
|
|
1630
|
-
/**
|
|
1631
|
-
* Execute multiple queries in a batch.
|
|
1632
|
-
*/
|
|
1675
|
+
/** Execute multiple queries in a batch. */
|
|
1633
1676
|
batch(queries: BatchQuery[], options?: BatchOptions): Promise<BatchSummary>;
|
|
1634
|
-
/**
|
|
1635
|
-
* Check connection state before operation.
|
|
1636
|
-
*/
|
|
1677
|
+
/** Check connection state before operation. */
|
|
1637
1678
|
private checkState;
|
|
1679
|
+
/** Send a protobuf message with request timeout enforcement. */
|
|
1680
|
+
private _sendWithTimeout;
|
|
1681
|
+
/** Receive a protobuf message with request timeout enforcement. */
|
|
1682
|
+
private _receiveWithTimeout;
|
|
1683
|
+
/** Create a combined abort signal from requestTimeout and optional caller signal (CWE-703). */
|
|
1684
|
+
private _withRequestTimeout;
|
|
1685
|
+
private _closeOnTransportError;
|
|
1638
1686
|
}
|
|
1639
1687
|
|
|
1640
1688
|
/**
|
|
@@ -1777,13 +1825,23 @@ interface PasswordPolicy {
|
|
|
1777
1825
|
declare class AuthClient {
|
|
1778
1826
|
private _conn;
|
|
1779
1827
|
private _passwordPolicy;
|
|
1828
|
+
private _onClose?;
|
|
1829
|
+
private _closed;
|
|
1780
1830
|
/**
|
|
1781
1831
|
* Create a new auth client.
|
|
1782
1832
|
*
|
|
1783
1833
|
* @param conn - Connection to use
|
|
1784
1834
|
* @param passwordPolicy - Optional password policy configuration
|
|
1835
|
+
* @param onClose - Optional callback invoked when close() is called (e.g., to release a pooled connection)
|
|
1836
|
+
*/
|
|
1837
|
+
constructor(conn: Connection, passwordPolicy?: PasswordPolicy, onClose?: () => void);
|
|
1838
|
+
/**
|
|
1839
|
+
* Close the auth client and release the underlying connection.
|
|
1840
|
+
*
|
|
1841
|
+
* If a release callback was provided (e.g., to return a pooled connection),
|
|
1842
|
+
* it is invoked exactly once on the first call to close().
|
|
1785
1843
|
*/
|
|
1786
|
-
|
|
1844
|
+
close(): void;
|
|
1787
1845
|
/**
|
|
1788
1846
|
* Get the current password policy.
|
|
1789
1847
|
*/
|
|
@@ -1792,104 +1850,35 @@ declare class AuthClient {
|
|
|
1792
1850
|
* Update the password policy.
|
|
1793
1851
|
*/
|
|
1794
1852
|
setPasswordPolicy(policy: PasswordPolicy): void;
|
|
1795
|
-
/**
|
|
1796
|
-
* Create a new user.
|
|
1797
|
-
*
|
|
1798
|
-
* @param username - Username for the new user
|
|
1799
|
-
* @param options - User creation options
|
|
1800
|
-
*/
|
|
1853
|
+
/** Create a new user. */
|
|
1801
1854
|
createUser(username: string, options: CreateUserOptions): Promise<void>;
|
|
1802
|
-
/**
|
|
1803
|
-
* Delete a user.
|
|
1804
|
-
*
|
|
1805
|
-
* @param username - Username to delete
|
|
1806
|
-
*/
|
|
1855
|
+
/** Delete a user. */
|
|
1807
1856
|
deleteUser(username: string): Promise<void>;
|
|
1808
|
-
/**
|
|
1809
|
-
* Get user information.
|
|
1810
|
-
*
|
|
1811
|
-
* @param username - Username to look up
|
|
1812
|
-
* @returns User information or null if not found
|
|
1813
|
-
*/
|
|
1857
|
+
/** Get user information, or null if not found. */
|
|
1814
1858
|
getUser(username: string): Promise<User | null>;
|
|
1815
|
-
/**
|
|
1816
|
-
* List all users.
|
|
1817
|
-
*
|
|
1818
|
-
* @returns Array of users
|
|
1819
|
-
*/
|
|
1859
|
+
/** List all users. */
|
|
1820
1860
|
listUsers(): Promise<User[]>;
|
|
1821
|
-
/**
|
|
1822
|
-
* Change a user's password.
|
|
1823
|
-
*
|
|
1824
|
-
* @param username - Username
|
|
1825
|
-
* @param newPassword - New password
|
|
1826
|
-
*/
|
|
1861
|
+
/** Change a user's password. */
|
|
1827
1862
|
changePassword(username: string, newPassword: string): Promise<void>;
|
|
1828
|
-
/**
|
|
1829
|
-
* Activate a user.
|
|
1830
|
-
*
|
|
1831
|
-
* @param username - Username to activate
|
|
1832
|
-
*/
|
|
1863
|
+
/** Activate a user. */
|
|
1833
1864
|
activateUser(username: string): Promise<void>;
|
|
1834
|
-
/**
|
|
1835
|
-
* Deactivate a user.
|
|
1836
|
-
*
|
|
1837
|
-
* @param username - Username to deactivate
|
|
1838
|
-
*/
|
|
1865
|
+
/** Deactivate a user. */
|
|
1839
1866
|
deactivateUser(username: string): Promise<void>;
|
|
1840
|
-
/**
|
|
1841
|
-
* Create a new role.
|
|
1842
|
-
*
|
|
1843
|
-
* @param name - Role name
|
|
1844
|
-
* @param options - Role creation options
|
|
1845
|
-
*/
|
|
1867
|
+
/** Create a new role. */
|
|
1846
1868
|
createRole(name: string, options?: CreateRoleOptions): Promise<void>;
|
|
1847
|
-
/**
|
|
1848
|
-
* Delete a role.
|
|
1849
|
-
*
|
|
1850
|
-
* @param name - Role name to delete
|
|
1851
|
-
*/
|
|
1869
|
+
/** Delete a role. */
|
|
1852
1870
|
deleteRole(name: string): Promise<void>;
|
|
1853
|
-
/**
|
|
1854
|
-
* Get role information.
|
|
1855
|
-
*
|
|
1856
|
-
* @param name - Role name
|
|
1857
|
-
* @returns Role information or null if not found
|
|
1858
|
-
*/
|
|
1871
|
+
/** Get role information, or null if not found. */
|
|
1859
1872
|
getRole(name: string): Promise<Role | null>;
|
|
1860
|
-
/**
|
|
1861
|
-
* List all roles.
|
|
1862
|
-
*
|
|
1863
|
-
* @returns Array of roles
|
|
1864
|
-
*/
|
|
1873
|
+
/** List all roles. */
|
|
1865
1874
|
listRoles(): Promise<Role[]>;
|
|
1866
|
-
/**
|
|
1867
|
-
* Assign a role to a user.
|
|
1868
|
-
*
|
|
1869
|
-
* @param username - Username
|
|
1870
|
-
* @param roleName - Role to assign
|
|
1871
|
-
*/
|
|
1875
|
+
/** Assign a role to a user. */
|
|
1872
1876
|
assignRole(username: string, roleName: string): Promise<void>;
|
|
1873
|
-
/**
|
|
1874
|
-
* Revoke a role from a user.
|
|
1875
|
-
*
|
|
1876
|
-
* @param username - Username
|
|
1877
|
-
* @param roleName - Role to revoke
|
|
1878
|
-
*/
|
|
1877
|
+
/** Revoke a role from a user. */
|
|
1879
1878
|
revokeRole(username: string, roleName: string): Promise<void>;
|
|
1880
|
-
/**
|
|
1881
|
-
* Grant a permission to a role.
|
|
1882
|
-
*
|
|
1883
|
-
* @param roleName - Role name
|
|
1884
|
-
* @param permission - Permission to grant
|
|
1885
|
-
*/
|
|
1879
|
+
/** Grant a permission to a role. */
|
|
1886
1880
|
grantPermission(roleName: string, permission: Permission): Promise<void>;
|
|
1887
|
-
/**
|
|
1888
|
-
* Revoke a permission from a role.
|
|
1889
|
-
*
|
|
1890
|
-
* @param roleName - Role name
|
|
1891
|
-
* @param permission - Permission to revoke
|
|
1892
|
-
*/
|
|
1881
|
+
/** Revoke a permission from a role. */
|
|
1893
1882
|
revokePermission(roleName: string, permission: Permission): Promise<void>;
|
|
1894
1883
|
/**
|
|
1895
1884
|
* Create an RLS policy.
|
|
@@ -1957,9 +1946,7 @@ declare class AuthClient {
|
|
|
1957
1946
|
* @returns Whether permission is granted
|
|
1958
1947
|
*/
|
|
1959
1948
|
hasPermission(resource: string, action: string, label?: string): Promise<boolean>;
|
|
1960
|
-
private validateUsername;
|
|
1961
1949
|
private validatePassword;
|
|
1962
|
-
private validateRoleName;
|
|
1963
1950
|
private validatePolicyName;
|
|
1964
1951
|
}
|
|
1965
1952
|
/**
|
|
@@ -2045,6 +2032,14 @@ declare class GeodeClient {
|
|
|
2045
2032
|
exec(query: string, options?: QueryOptions): Promise<void>;
|
|
2046
2033
|
/**
|
|
2047
2034
|
* Execute multiple statements.
|
|
2035
|
+
*
|
|
2036
|
+
* When a connection pool is available, all queries are executed within a
|
|
2037
|
+
* single transaction to reduce round-trips (one BEGIN + N queries + COMMIT
|
|
2038
|
+
* instead of N independent round-trips with connection acquire/release).
|
|
2039
|
+
*
|
|
2040
|
+
* For non-pooled (single connection) clients, queries are executed
|
|
2041
|
+
* sequentially without an implicit transaction wrapper, preserving the
|
|
2042
|
+
* caller's control over transaction boundaries.
|
|
2048
2043
|
*/
|
|
2049
2044
|
execBatch(queries: Array<{
|
|
2050
2045
|
query: string;
|
|
@@ -2226,6 +2221,7 @@ interface RateLimiterConfig {
|
|
|
2226
2221
|
declare class ConnectionPool {
|
|
2227
2222
|
private _config;
|
|
2228
2223
|
private _connections;
|
|
2224
|
+
private _pendingConnections;
|
|
2229
2225
|
private _waitQueue;
|
|
2230
2226
|
private _closed;
|
|
2231
2227
|
private _maintenanceInterval?;
|
|
@@ -2296,6 +2292,7 @@ declare class ConnectionPool {
|
|
|
2296
2292
|
* Remove a connection from the pool.
|
|
2297
2293
|
*/
|
|
2298
2294
|
private removeConnection;
|
|
2295
|
+
private fulfillWaiters;
|
|
2299
2296
|
/**
|
|
2300
2297
|
* Perform pool maintenance.
|
|
2301
2298
|
*/
|
|
@@ -2303,14 +2300,57 @@ declare class ConnectionPool {
|
|
|
2303
2300
|
}
|
|
2304
2301
|
|
|
2305
2302
|
/**
|
|
2306
|
-
*
|
|
2307
|
-
*
|
|
2308
|
-
* Provides gRPC transport for communication with Geode server.
|
|
2309
|
-
* Uses @grpc/grpc-js with dynamic proto loading.
|
|
2303
|
+
* Client-level retry wrapper for transient errors.
|
|
2310
2304
|
*
|
|
2311
|
-
*
|
|
2312
|
-
*
|
|
2313
|
-
*
|
|
2305
|
+
* Mirrors the Go reference client's `RetryPolicy`/`Retry` (see
|
|
2306
|
+
* `geode-client-go/retry.go`): retries only when {@link isRetryableError}
|
|
2307
|
+
* returns true, with exponential backoff capped at `maxBackoffMs`.
|
|
2308
|
+
*/
|
|
2309
|
+
/**
|
|
2310
|
+
* Configures retry behavior for transient errors.
|
|
2311
|
+
*/
|
|
2312
|
+
interface RetryPolicy {
|
|
2313
|
+
/**
|
|
2314
|
+
* Maximum number of attempts including the initial call.
|
|
2315
|
+
* Values less than 1 are treated as 1.
|
|
2316
|
+
*/
|
|
2317
|
+
maxAttempts: number;
|
|
2318
|
+
/** Delay in milliseconds before the first retry. */
|
|
2319
|
+
initialBackoffMs: number;
|
|
2320
|
+
/**
|
|
2321
|
+
* Maximum backoff in milliseconds. The exponential backoff is clamped to
|
|
2322
|
+
* this value.
|
|
2323
|
+
*/
|
|
2324
|
+
maxBackoffMs: number;
|
|
2325
|
+
/** Exponential backoff multiplier applied on each retry. */
|
|
2326
|
+
multiplier: number;
|
|
2327
|
+
}
|
|
2328
|
+
/**
|
|
2329
|
+
* Returns a {@link RetryPolicy} with sensible defaults:
|
|
2330
|
+
* 3 max attempts, 1000ms initial backoff, 30000ms max backoff, 2.0 multiplier.
|
|
2331
|
+
*/
|
|
2332
|
+
declare function defaultRetryPolicy(): RetryPolicy;
|
|
2333
|
+
/**
|
|
2334
|
+
* Executes `fn` up to `policy.maxAttempts` times, retrying only when
|
|
2335
|
+
* {@link isRetryableError} returns true for the rejection reason. Non-retryable
|
|
2336
|
+
* errors and non-Geode errors are propagated immediately without further
|
|
2337
|
+
* attempts. Between attempts the wrapper waits using exponential backoff
|
|
2338
|
+
* clamped to `policy.maxBackoffMs`.
|
|
2339
|
+
*
|
|
2340
|
+
* @param fn The operation to run. Re-invoked on each retry.
|
|
2341
|
+
* @param policy Optional retry policy. Defaults to {@link defaultRetryPolicy}.
|
|
2342
|
+
*/
|
|
2343
|
+
declare function withRetry<T>(fn: () => Promise<T>, policy?: RetryPolicy): Promise<T>;
|
|
2344
|
+
|
|
2345
|
+
/**
|
|
2346
|
+
* gRPC Transport Layer
|
|
2347
|
+
*
|
|
2348
|
+
* Provides gRPC transport for communication with Geode server.
|
|
2349
|
+
* Uses @grpc/grpc-js with dynamic proto loading.
|
|
2350
|
+
*
|
|
2351
|
+
* Method mapping (QuicClientMessage field -> gRPC service RPC):
|
|
2352
|
+
* hello -> Handshake (unary)
|
|
2353
|
+
* execute -> Execute (server-streaming: schema + data pages)
|
|
2314
2354
|
* pull -> reads next buffered message from the Execute stream
|
|
2315
2355
|
* ping -> Ping (unary)
|
|
2316
2356
|
* begin -> Begin (unary)
|
|
@@ -2327,7 +2367,13 @@ declare class GrpcTransport implements Transport {
|
|
|
2327
2367
|
private _closed;
|
|
2328
2368
|
private _address;
|
|
2329
2369
|
private _pendingResponses;
|
|
2370
|
+
private _pendingProtoReads;
|
|
2330
2371
|
private _activeStream;
|
|
2372
|
+
private _streamPaused;
|
|
2373
|
+
private _backpressureThreshold;
|
|
2374
|
+
private _streamTimeoutMs;
|
|
2375
|
+
private _streamTimeoutTimer;
|
|
2376
|
+
private _streamComplete;
|
|
2331
2377
|
constructor(address: string);
|
|
2332
2378
|
/**
|
|
2333
2379
|
* Connect to the Geode server using gRPC.
|
|
@@ -2340,16 +2386,9 @@ declare class GrpcTransport implements Transport {
|
|
|
2340
2386
|
sendProto(msg: QuicClientMessage, signal?: AbortSignal): Promise<void>;
|
|
2341
2387
|
/**
|
|
2342
2388
|
* Receive a protobuf message from the queue.
|
|
2389
|
+
* If no response is buffered, waits for the next streamed message.
|
|
2343
2390
|
*/
|
|
2344
2391
|
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
2392
|
/**
|
|
2354
2393
|
* Close the transport.
|
|
2355
2394
|
*/
|
|
@@ -2362,15 +2401,30 @@ declare class GrpcTransport implements Transport {
|
|
|
2362
2401
|
* Get remote address.
|
|
2363
2402
|
*/
|
|
2364
2403
|
getAddress(): string;
|
|
2404
|
+
/**
|
|
2405
|
+
* Enqueue a response, resolving a pending read if one exists.
|
|
2406
|
+
*/
|
|
2407
|
+
private enqueueResponse;
|
|
2365
2408
|
/**
|
|
2366
2409
|
* Make a unary RPC call.
|
|
2367
2410
|
*/
|
|
2368
2411
|
private callUnary;
|
|
2369
2412
|
/**
|
|
2370
2413
|
* Call the server-streaming Execute RPC.
|
|
2371
|
-
*
|
|
2414
|
+
* Uses backpressure to prevent unbounded buffering: pauses the stream when
|
|
2415
|
+
* the pending response buffer exceeds the threshold, resumes when drained.
|
|
2416
|
+
* Enforces a configurable timeout that fires when no data arrives within the period.
|
|
2372
2417
|
*/
|
|
2373
2418
|
private callServerStream;
|
|
2419
|
+
/**
|
|
2420
|
+
* Reset the stream inactivity timeout. If no data arrives within
|
|
2421
|
+
* _streamTimeoutMs, the stream is cancelled and the promise rejected.
|
|
2422
|
+
*/
|
|
2423
|
+
private resetStreamTimeout;
|
|
2424
|
+
/**
|
|
2425
|
+
* Clear any active stream inactivity timeout.
|
|
2426
|
+
*/
|
|
2427
|
+
private clearStreamTimeout;
|
|
2374
2428
|
/**
|
|
2375
2429
|
* Check if closed and throw if so.
|
|
2376
2430
|
*/
|
|
@@ -2429,6 +2483,124 @@ declare function validateSavepointName(name: string): void;
|
|
|
2429
2483
|
*/
|
|
2430
2484
|
declare function sanitizeForLog(value: string): string;
|
|
2431
2485
|
|
|
2486
|
+
/**
|
|
2487
|
+
* Predicate Builder
|
|
2488
|
+
*
|
|
2489
|
+
* Fluent API for building WHERE clause predicates in GQL queries.
|
|
2490
|
+
* Extracted from query-builder.ts for file size management.
|
|
2491
|
+
*/
|
|
2492
|
+
|
|
2493
|
+
/**
|
|
2494
|
+
* Predicate operator.
|
|
2495
|
+
*/
|
|
2496
|
+
type PredicateOp = '=' | '<>' | '!=' | '<' | '<=' | '>' | '>=' | 'IN' | 'NOT IN' | 'CONTAINS' | 'STARTS WITH' | 'ENDS WITH' | 'IS NULL' | 'IS NOT NULL';
|
|
2497
|
+
/**
|
|
2498
|
+
* Build a predicate for WHERE clauses.
|
|
2499
|
+
*/
|
|
2500
|
+
declare class PredicateBuilder {
|
|
2501
|
+
private _predicates;
|
|
2502
|
+
private _params;
|
|
2503
|
+
private _paramCounter;
|
|
2504
|
+
/**
|
|
2505
|
+
* Add a comparison predicate.
|
|
2506
|
+
*/
|
|
2507
|
+
compare(left: string, op: PredicateOp, right: unknown): this;
|
|
2508
|
+
/**
|
|
2509
|
+
* Add an equality predicate.
|
|
2510
|
+
*/
|
|
2511
|
+
eq(left: string, right: unknown): this;
|
|
2512
|
+
/**
|
|
2513
|
+
* Add a not-equal predicate.
|
|
2514
|
+
*/
|
|
2515
|
+
neq(left: string, right: unknown): this;
|
|
2516
|
+
/**
|
|
2517
|
+
* Add a less-than predicate.
|
|
2518
|
+
*/
|
|
2519
|
+
lt(left: string, right: unknown): this;
|
|
2520
|
+
/**
|
|
2521
|
+
* Add a less-than-or-equal predicate.
|
|
2522
|
+
*/
|
|
2523
|
+
lte(left: string, right: unknown): this;
|
|
2524
|
+
/**
|
|
2525
|
+
* Add a greater-than predicate.
|
|
2526
|
+
*/
|
|
2527
|
+
gt(left: string, right: unknown): this;
|
|
2528
|
+
/**
|
|
2529
|
+
* Add a greater-than-or-equal predicate.
|
|
2530
|
+
*/
|
|
2531
|
+
gte(left: string, right: unknown): this;
|
|
2532
|
+
/**
|
|
2533
|
+
* Add an IN predicate.
|
|
2534
|
+
*/
|
|
2535
|
+
in(left: string, values: unknown[]): this;
|
|
2536
|
+
/**
|
|
2537
|
+
* Add a NOT IN predicate.
|
|
2538
|
+
*/
|
|
2539
|
+
notIn(left: string, values: unknown[]): this;
|
|
2540
|
+
/**
|
|
2541
|
+
* Add a CONTAINS predicate.
|
|
2542
|
+
*/
|
|
2543
|
+
contains(left: string, value: string): this;
|
|
2544
|
+
/**
|
|
2545
|
+
* Add a STARTS WITH predicate.
|
|
2546
|
+
*/
|
|
2547
|
+
startsWith(left: string, value: string): this;
|
|
2548
|
+
/**
|
|
2549
|
+
* Add an ENDS WITH predicate.
|
|
2550
|
+
*/
|
|
2551
|
+
endsWith(left: string, value: string): this;
|
|
2552
|
+
/**
|
|
2553
|
+
* Add an IS NULL predicate.
|
|
2554
|
+
*/
|
|
2555
|
+
isNull(expr: string): this;
|
|
2556
|
+
/**
|
|
2557
|
+
* Add an IS NOT NULL predicate.
|
|
2558
|
+
*/
|
|
2559
|
+
isNotNull(expr: string): this;
|
|
2560
|
+
/**
|
|
2561
|
+
* Add a raw predicate expression.
|
|
2562
|
+
*
|
|
2563
|
+
* **SECURITY WARNING: This method bypasses all input validation.**
|
|
2564
|
+
*
|
|
2565
|
+
* Using raw() with user-supplied input can lead to GQL injection attacks.
|
|
2566
|
+
* Only use this method when:
|
|
2567
|
+
* 1. The expression is entirely constructed from trusted, hardcoded strings
|
|
2568
|
+
* 2. All dynamic values are passed via the `params` argument (using $paramName syntax)
|
|
2569
|
+
*
|
|
2570
|
+
* @example
|
|
2571
|
+
* ```typescript
|
|
2572
|
+
* // SAFE: Using parameters for dynamic values
|
|
2573
|
+
* predicate().raw('n.custom_field CONTAINS $pattern', { pattern: userInput })
|
|
2574
|
+
*
|
|
2575
|
+
* // UNSAFE: Never interpolate user input directly
|
|
2576
|
+
* predicate().raw(`n.name = '${userInput}'`) // VULNERABLE TO INJECTION!
|
|
2577
|
+
* ```
|
|
2578
|
+
*
|
|
2579
|
+
* Consider using the typed predicate methods (eq, gt, contains, etc.) instead.
|
|
2580
|
+
*
|
|
2581
|
+
* @param expr - Raw predicate expression (MUST be trusted input)
|
|
2582
|
+
* @param params - Parameters to bind (safe for user input)
|
|
2583
|
+
* @deprecated Consider using typed predicate methods instead for better security.
|
|
2584
|
+
*/
|
|
2585
|
+
raw(expr: string, params?: QueryParams): this;
|
|
2586
|
+
/**
|
|
2587
|
+
* Combine predicates with AND.
|
|
2588
|
+
*/
|
|
2589
|
+
and(builder: PredicateBuilder): this;
|
|
2590
|
+
/**
|
|
2591
|
+
* Combine predicates with OR.
|
|
2592
|
+
*/
|
|
2593
|
+
or(builder: PredicateBuilder): this;
|
|
2594
|
+
/**
|
|
2595
|
+
* Build the predicate.
|
|
2596
|
+
*/
|
|
2597
|
+
build(): {
|
|
2598
|
+
predicate: string;
|
|
2599
|
+
params: QueryParams;
|
|
2600
|
+
};
|
|
2601
|
+
private nextParam;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2432
2604
|
/**
|
|
2433
2605
|
* Query Builder
|
|
2434
2606
|
*
|
|
@@ -2443,10 +2615,6 @@ type EdgeDirection = 'outgoing' | 'incoming' | 'both';
|
|
|
2443
2615
|
* Sort direction.
|
|
2444
2616
|
*/
|
|
2445
2617
|
type SortDirection = 'ASC' | 'DESC';
|
|
2446
|
-
/**
|
|
2447
|
-
* Predicate operator.
|
|
2448
|
-
*/
|
|
2449
|
-
type PredicateOp = '=' | '<>' | '!=' | '<' | '<=' | '>' | '>=' | 'IN' | 'NOT IN' | 'CONTAINS' | 'STARTS WITH' | 'ENDS WITH' | 'IS NULL' | 'IS NOT NULL';
|
|
2450
2618
|
/**
|
|
2451
2619
|
* Node pattern for MATCH clauses.
|
|
2452
2620
|
*/
|
|
@@ -2593,112 +2761,6 @@ declare class PatternBuilder {
|
|
|
2593
2761
|
*/
|
|
2594
2762
|
toGQL(): string;
|
|
2595
2763
|
}
|
|
2596
|
-
/**
|
|
2597
|
-
* Build a predicate for WHERE clauses.
|
|
2598
|
-
*/
|
|
2599
|
-
declare class PredicateBuilder {
|
|
2600
|
-
private _predicates;
|
|
2601
|
-
private _params;
|
|
2602
|
-
private _paramCounter;
|
|
2603
|
-
/**
|
|
2604
|
-
* Add a comparison predicate.
|
|
2605
|
-
*/
|
|
2606
|
-
compare(left: string, op: PredicateOp, right: unknown): this;
|
|
2607
|
-
/**
|
|
2608
|
-
* Add an equality predicate.
|
|
2609
|
-
*/
|
|
2610
|
-
eq(left: string, right: unknown): this;
|
|
2611
|
-
/**
|
|
2612
|
-
* Add a not-equal predicate.
|
|
2613
|
-
*/
|
|
2614
|
-
neq(left: string, right: unknown): this;
|
|
2615
|
-
/**
|
|
2616
|
-
* Add a less-than predicate.
|
|
2617
|
-
*/
|
|
2618
|
-
lt(left: string, right: unknown): this;
|
|
2619
|
-
/**
|
|
2620
|
-
* Add a less-than-or-equal predicate.
|
|
2621
|
-
*/
|
|
2622
|
-
lte(left: string, right: unknown): this;
|
|
2623
|
-
/**
|
|
2624
|
-
* Add a greater-than predicate.
|
|
2625
|
-
*/
|
|
2626
|
-
gt(left: string, right: unknown): this;
|
|
2627
|
-
/**
|
|
2628
|
-
* Add a greater-than-or-equal predicate.
|
|
2629
|
-
*/
|
|
2630
|
-
gte(left: string, right: unknown): this;
|
|
2631
|
-
/**
|
|
2632
|
-
* Add an IN predicate.
|
|
2633
|
-
*/
|
|
2634
|
-
in(left: string, values: unknown[]): this;
|
|
2635
|
-
/**
|
|
2636
|
-
* Add a NOT IN predicate.
|
|
2637
|
-
*/
|
|
2638
|
-
notIn(left: string, values: unknown[]): this;
|
|
2639
|
-
/**
|
|
2640
|
-
* Add a CONTAINS predicate.
|
|
2641
|
-
*/
|
|
2642
|
-
contains(left: string, value: string): this;
|
|
2643
|
-
/**
|
|
2644
|
-
* Add a STARTS WITH predicate.
|
|
2645
|
-
*/
|
|
2646
|
-
startsWith(left: string, value: string): this;
|
|
2647
|
-
/**
|
|
2648
|
-
* Add an ENDS WITH predicate.
|
|
2649
|
-
*/
|
|
2650
|
-
endsWith(left: string, value: string): this;
|
|
2651
|
-
/**
|
|
2652
|
-
* Add an IS NULL predicate.
|
|
2653
|
-
*/
|
|
2654
|
-
isNull(expr: string): this;
|
|
2655
|
-
/**
|
|
2656
|
-
* Add an IS NOT NULL predicate.
|
|
2657
|
-
*/
|
|
2658
|
-
isNotNull(expr: string): this;
|
|
2659
|
-
/**
|
|
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.
|
|
2683
|
-
*/
|
|
2684
|
-
raw(expr: string, params?: QueryParams): this;
|
|
2685
|
-
/**
|
|
2686
|
-
* Combine predicates with AND.
|
|
2687
|
-
*/
|
|
2688
|
-
and(builder: PredicateBuilder): this;
|
|
2689
|
-
/**
|
|
2690
|
-
* Combine predicates with OR.
|
|
2691
|
-
*/
|
|
2692
|
-
or(builder: PredicateBuilder): this;
|
|
2693
|
-
/**
|
|
2694
|
-
* Build the predicate.
|
|
2695
|
-
*/
|
|
2696
|
-
build(): {
|
|
2697
|
-
predicate: string;
|
|
2698
|
-
params: QueryParams;
|
|
2699
|
-
};
|
|
2700
|
-
private nextParam;
|
|
2701
|
-
}
|
|
2702
2764
|
/**
|
|
2703
2765
|
* GQL Query Builder.
|
|
2704
2766
|
*/
|
|
@@ -2715,26 +2777,6 @@ declare class QueryBuilder {
|
|
|
2715
2777
|
optionalMatch(pattern: string | PatternBuilder): this;
|
|
2716
2778
|
/**
|
|
2717
2779
|
* 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
|
|
2738
2780
|
*/
|
|
2739
2781
|
where(predicate: string | PredicateBuilder, params?: QueryParams): this;
|
|
2740
2782
|
/**
|
|
@@ -2788,23 +2830,7 @@ declare class QueryBuilder {
|
|
|
2788
2830
|
/**
|
|
2789
2831
|
* Add a raw GQL clause.
|
|
2790
2832
|
*
|
|
2791
|
-
*
|
|
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.
|
|
2833
|
+
* **SECURITY WARNING: This method bypasses all input validation.**
|
|
2808
2834
|
*
|
|
2809
2835
|
* @param clause - Raw GQL clause (MUST be trusted input)
|
|
2810
2836
|
* @param params - Parameters to bind (safe for user input)
|
|
@@ -2856,4 +2882,4 @@ declare function node(): NodePatternBuilder;
|
|
|
2856
2882
|
*/
|
|
2857
2883
|
declare function edge(): EdgePatternBuilder;
|
|
2858
2884
|
|
|
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 };
|
|
2885
|
+
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, ERR_BAD_CONN_MESSAGE, ERR_CLOSED_MESSAGE, ERR_NO_TX_MESSAGE, ERR_QUERY_IN_PROGRESS_MESSAGE, ERR_ROWS_CLOSED_MESSAGE, ERR_TX_DONE_MESSAGE, ERR_TX_IN_PROGRESS_MESSAGE, 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 RetryPolicy, 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, defaultRetryPolicy, edge, encodeQuicClientMessage, encodeWithLengthPrefix, ensureProtoInitialized, explain, extractParameters, formatPlan, formatProfile, fromJSON, getAddress, getProtoPath, initProtoSync, isDriverError, isGeodeError, isRetryableError, isSentinelError, jsToProtoValue, node, parseDSN, parseGQLType, parseRow, pattern, predicate, prepare, profile, protoValueToJS, query, redactConfig, redactDSN, rowToObject, rowToRecord, sanitizeForLog, validateConfig, validateHostname, validatePageSize, validateParamName, validateParamValue, validatePort, validateQuery, validateSavepointName, withRetry, withTransaction };
|