@geodedb/client 1.0.0-alpha.13 → 1.0.0-alpha.14
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.mts +23 -5
- package/dist/index.d.ts +23 -5
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -381,11 +381,23 @@ interface GQLRange<T = unknown> {
|
|
|
381
381
|
lowerInclusive: boolean;
|
|
382
382
|
upperInclusive: boolean;
|
|
383
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Type alias for node/edge IDs.
|
|
386
|
+
*
|
|
387
|
+
* IDs can be:
|
|
388
|
+
* - string: String-based IDs or hex format IDs
|
|
389
|
+
* - number: Integer IDs within JavaScript's safe integer range
|
|
390
|
+
* - bigint: Integer IDs larger than Number.MAX_SAFE_INTEGER (2^53 - 1)
|
|
391
|
+
*
|
|
392
|
+
* Note: Geode's internal IDs often exceed JavaScript's safe integer limit,
|
|
393
|
+
* so bigint is used to preserve full precision.
|
|
394
|
+
*/
|
|
395
|
+
type GQLId = string | number | bigint;
|
|
384
396
|
/**
|
|
385
397
|
* Node structure from graph queries.
|
|
386
398
|
*/
|
|
387
399
|
interface GQLNode {
|
|
388
|
-
id:
|
|
400
|
+
id: GQLId;
|
|
389
401
|
labels: string[];
|
|
390
402
|
properties: Record<string, unknown>;
|
|
391
403
|
}
|
|
@@ -393,10 +405,10 @@ interface GQLNode {
|
|
|
393
405
|
* Edge structure from graph queries.
|
|
394
406
|
*/
|
|
395
407
|
interface GQLEdge {
|
|
396
|
-
id:
|
|
408
|
+
id: GQLId;
|
|
397
409
|
type: string;
|
|
398
|
-
startNode:
|
|
399
|
-
endNode:
|
|
410
|
+
startNode: GQLId;
|
|
411
|
+
endNode: GQLId;
|
|
400
412
|
properties: Record<string, unknown>;
|
|
401
413
|
}
|
|
402
414
|
/**
|
|
@@ -1934,6 +1946,9 @@ interface Frame {
|
|
|
1934
1946
|
}
|
|
1935
1947
|
/**
|
|
1936
1948
|
* Parse a JSON frame from raw bytes.
|
|
1949
|
+
*
|
|
1950
|
+
* Uses lossless-json to preserve precision for large integers (> Number.MAX_SAFE_INTEGER).
|
|
1951
|
+
* This is critical for node/edge IDs which may be 18+ digit integers.
|
|
1937
1952
|
*/
|
|
1938
1953
|
declare function parseFrame(data: Buffer | string): Frame;
|
|
1939
1954
|
/**
|
|
@@ -1998,6 +2013,9 @@ declare function buildRollbackToMessage(name: string): Record<string, unknown>;
|
|
|
1998
2013
|
declare function buildPingMessage(): Record<string, unknown>;
|
|
1999
2014
|
/**
|
|
2000
2015
|
* Serialize a message to JSON line format.
|
|
2016
|
+
*
|
|
2017
|
+
* Uses lossless-json with a custom BigInt stringifier to properly serialize
|
|
2018
|
+
* BigInt values as numbers without quotes, maintaining wire protocol compatibility.
|
|
2001
2019
|
*/
|
|
2002
2020
|
declare function serializeMessage(msg: Record<string, unknown>): Buffer;
|
|
2003
2021
|
/**
|
|
@@ -2431,4 +2449,4 @@ declare function node(): NodePatternBuilder;
|
|
|
2431
2449
|
*/
|
|
2432
2450
|
declare function edge(): EdgePatternBuilder;
|
|
2433
2451
|
|
|
2434
|
-
export { type AdditionalInfo, AuthClient, BaseTransport, type BatchOptions, type BatchQuery, type BatchResult, type BatchSummary, type ClientOptions, type ColumnDef, type ColumnInfo, ConfigError, Connection, ConnectionPool, type ConnectionState, type CreateRLSPolicyOptions, type CreateRoleOptions, type CreateUserOptions, DEFAULT_CONFORMANCE, DEFAULT_HELLO_NAME, DEFAULT_HELLO_VERSION, DEFAULT_PAGE_SIZE, DEFAULT_PORT, DriverError, type EdgeDirection, type EdgePattern, EdgePatternBuilder, ErrBadConn, ErrClosed, ErrNoTx, ErrQueryInProgress, ErrRowsClosed, ErrTxDone, ErrTxInProgress, type ExplainOptions, type Frame, type FrameResult, type GQLEdge, type GQLNode, type GQLPath, type GQLRange, type GQLType, GQLValue, type GQLValueKind, GeodeClient, type GeodeConfig, type GeodeError, MAX_PAGE_SIZE, MAX_QUERY_LENGTH, MockTransport, MsgType, type NodePattern, NodePatternBuilder, type OperationTiming, type ParameterInfo, PatternBuilder, type PatternElement, type Permission, type PlanOperation, type PoolConfig, PredicateBuilder, type PredicateOp, PreparedStatement, QueryBuilder, type QueryOptions, type QueryParams, type QueryPlan, type QueryProfile, QueryResult, QueryResultIterator, MatrixQuicTransport as QuicheTransport, type RLSPolicy, RespType, type Role, type Row, SecurityError, type SortDirection, StateError, StatusClass, type StatusClassType, Transaction, type Transport, TransportError, type User, batch, batchAll, batchFirst, batchMap, batchParallel, buildBeginMessage, buildCommitMessage, buildHelloMessage, buildPingMessage, buildPullMessage, buildRollbackMessage, buildRollbackToMessage, buildRunGQLMessage, buildSavepointMessage, buildTLSConfig, cloneConfig, countPlaceholders, createAuthClient, createClient, createClientWithConfig, createTransport, defaultConfig, edge, explain, extractParameters, formatPlan, formatProfile, frameToError, fromJSON, getAddress, getColumnsFromSchema, isBindingsFrame, isDriverError, isErrorFrame, isFinalFrame, isGeodeError, isRetryableError, isSchemaFrame, mergeParams, node, parseDSN, parseFrame, parseGQLType, parseRow, pattern, predicate, prepare, profile, query, rewritePlaceholders, rowToObject, sanitizeForLog, serializeMessage, validateConfig, validateHostname, validatePageSize, validateParamName, validateParamValue, validatePort, validateQuery, validateSavepointName, withTransaction };
|
|
2452
|
+
export { type AdditionalInfo, AuthClient, BaseTransport, type BatchOptions, type BatchQuery, type BatchResult, type BatchSummary, type ClientOptions, type ColumnDef, type ColumnInfo, ConfigError, Connection, ConnectionPool, type ConnectionState, type CreateRLSPolicyOptions, type CreateRoleOptions, type CreateUserOptions, DEFAULT_CONFORMANCE, DEFAULT_HELLO_NAME, DEFAULT_HELLO_VERSION, DEFAULT_PAGE_SIZE, DEFAULT_PORT, DriverError, type EdgeDirection, type EdgePattern, EdgePatternBuilder, ErrBadConn, ErrClosed, ErrNoTx, ErrQueryInProgress, ErrRowsClosed, ErrTxDone, ErrTxInProgress, type ExplainOptions, type Frame, type FrameResult, type GQLEdge, type GQLId, type GQLNode, type GQLPath, type GQLRange, type GQLType, GQLValue, type GQLValueKind, GeodeClient, type GeodeConfig, type GeodeError, MAX_PAGE_SIZE, MAX_QUERY_LENGTH, MockTransport, MsgType, type NodePattern, NodePatternBuilder, type OperationTiming, type ParameterInfo, PatternBuilder, type PatternElement, type Permission, type PlanOperation, type PoolConfig, PredicateBuilder, type PredicateOp, PreparedStatement, QueryBuilder, type QueryOptions, type QueryParams, type QueryPlan, type QueryProfile, QueryResult, QueryResultIterator, MatrixQuicTransport as QuicheTransport, type RLSPolicy, RespType, type Role, type Row, SecurityError, type SortDirection, StateError, StatusClass, type StatusClassType, Transaction, type Transport, TransportError, type User, batch, batchAll, batchFirst, batchMap, batchParallel, buildBeginMessage, buildCommitMessage, buildHelloMessage, buildPingMessage, buildPullMessage, buildRollbackMessage, buildRollbackToMessage, buildRunGQLMessage, buildSavepointMessage, buildTLSConfig, cloneConfig, countPlaceholders, createAuthClient, createClient, createClientWithConfig, createTransport, defaultConfig, edge, explain, extractParameters, formatPlan, formatProfile, frameToError, fromJSON, getAddress, getColumnsFromSchema, isBindingsFrame, isDriverError, isErrorFrame, isFinalFrame, isGeodeError, isRetryableError, isSchemaFrame, mergeParams, node, parseDSN, parseFrame, parseGQLType, parseRow, pattern, predicate, prepare, profile, query, rewritePlaceholders, rowToObject, sanitizeForLog, serializeMessage, validateConfig, validateHostname, validatePageSize, validateParamName, validateParamValue, validatePort, validateQuery, validateSavepointName, withTransaction };
|
package/dist/index.d.ts
CHANGED
|
@@ -381,11 +381,23 @@ interface GQLRange<T = unknown> {
|
|
|
381
381
|
lowerInclusive: boolean;
|
|
382
382
|
upperInclusive: boolean;
|
|
383
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Type alias for node/edge IDs.
|
|
386
|
+
*
|
|
387
|
+
* IDs can be:
|
|
388
|
+
* - string: String-based IDs or hex format IDs
|
|
389
|
+
* - number: Integer IDs within JavaScript's safe integer range
|
|
390
|
+
* - bigint: Integer IDs larger than Number.MAX_SAFE_INTEGER (2^53 - 1)
|
|
391
|
+
*
|
|
392
|
+
* Note: Geode's internal IDs often exceed JavaScript's safe integer limit,
|
|
393
|
+
* so bigint is used to preserve full precision.
|
|
394
|
+
*/
|
|
395
|
+
type GQLId = string | number | bigint;
|
|
384
396
|
/**
|
|
385
397
|
* Node structure from graph queries.
|
|
386
398
|
*/
|
|
387
399
|
interface GQLNode {
|
|
388
|
-
id:
|
|
400
|
+
id: GQLId;
|
|
389
401
|
labels: string[];
|
|
390
402
|
properties: Record<string, unknown>;
|
|
391
403
|
}
|
|
@@ -393,10 +405,10 @@ interface GQLNode {
|
|
|
393
405
|
* Edge structure from graph queries.
|
|
394
406
|
*/
|
|
395
407
|
interface GQLEdge {
|
|
396
|
-
id:
|
|
408
|
+
id: GQLId;
|
|
397
409
|
type: string;
|
|
398
|
-
startNode:
|
|
399
|
-
endNode:
|
|
410
|
+
startNode: GQLId;
|
|
411
|
+
endNode: GQLId;
|
|
400
412
|
properties: Record<string, unknown>;
|
|
401
413
|
}
|
|
402
414
|
/**
|
|
@@ -1934,6 +1946,9 @@ interface Frame {
|
|
|
1934
1946
|
}
|
|
1935
1947
|
/**
|
|
1936
1948
|
* Parse a JSON frame from raw bytes.
|
|
1949
|
+
*
|
|
1950
|
+
* Uses lossless-json to preserve precision for large integers (> Number.MAX_SAFE_INTEGER).
|
|
1951
|
+
* This is critical for node/edge IDs which may be 18+ digit integers.
|
|
1937
1952
|
*/
|
|
1938
1953
|
declare function parseFrame(data: Buffer | string): Frame;
|
|
1939
1954
|
/**
|
|
@@ -1998,6 +2013,9 @@ declare function buildRollbackToMessage(name: string): Record<string, unknown>;
|
|
|
1998
2013
|
declare function buildPingMessage(): Record<string, unknown>;
|
|
1999
2014
|
/**
|
|
2000
2015
|
* Serialize a message to JSON line format.
|
|
2016
|
+
*
|
|
2017
|
+
* Uses lossless-json with a custom BigInt stringifier to properly serialize
|
|
2018
|
+
* BigInt values as numbers without quotes, maintaining wire protocol compatibility.
|
|
2001
2019
|
*/
|
|
2002
2020
|
declare function serializeMessage(msg: Record<string, unknown>): Buffer;
|
|
2003
2021
|
/**
|
|
@@ -2431,4 +2449,4 @@ declare function node(): NodePatternBuilder;
|
|
|
2431
2449
|
*/
|
|
2432
2450
|
declare function edge(): EdgePatternBuilder;
|
|
2433
2451
|
|
|
2434
|
-
export { type AdditionalInfo, AuthClient, BaseTransport, type BatchOptions, type BatchQuery, type BatchResult, type BatchSummary, type ClientOptions, type ColumnDef, type ColumnInfo, ConfigError, Connection, ConnectionPool, type ConnectionState, type CreateRLSPolicyOptions, type CreateRoleOptions, type CreateUserOptions, DEFAULT_CONFORMANCE, DEFAULT_HELLO_NAME, DEFAULT_HELLO_VERSION, DEFAULT_PAGE_SIZE, DEFAULT_PORT, DriverError, type EdgeDirection, type EdgePattern, EdgePatternBuilder, ErrBadConn, ErrClosed, ErrNoTx, ErrQueryInProgress, ErrRowsClosed, ErrTxDone, ErrTxInProgress, type ExplainOptions, type Frame, type FrameResult, type GQLEdge, type GQLNode, type GQLPath, type GQLRange, type GQLType, GQLValue, type GQLValueKind, GeodeClient, type GeodeConfig, type GeodeError, MAX_PAGE_SIZE, MAX_QUERY_LENGTH, MockTransport, MsgType, type NodePattern, NodePatternBuilder, type OperationTiming, type ParameterInfo, PatternBuilder, type PatternElement, type Permission, type PlanOperation, type PoolConfig, PredicateBuilder, type PredicateOp, PreparedStatement, QueryBuilder, type QueryOptions, type QueryParams, type QueryPlan, type QueryProfile, QueryResult, QueryResultIterator, MatrixQuicTransport as QuicheTransport, type RLSPolicy, RespType, type Role, type Row, SecurityError, type SortDirection, StateError, StatusClass, type StatusClassType, Transaction, type Transport, TransportError, type User, batch, batchAll, batchFirst, batchMap, batchParallel, buildBeginMessage, buildCommitMessage, buildHelloMessage, buildPingMessage, buildPullMessage, buildRollbackMessage, buildRollbackToMessage, buildRunGQLMessage, buildSavepointMessage, buildTLSConfig, cloneConfig, countPlaceholders, createAuthClient, createClient, createClientWithConfig, createTransport, defaultConfig, edge, explain, extractParameters, formatPlan, formatProfile, frameToError, fromJSON, getAddress, getColumnsFromSchema, isBindingsFrame, isDriverError, isErrorFrame, isFinalFrame, isGeodeError, isRetryableError, isSchemaFrame, mergeParams, node, parseDSN, parseFrame, parseGQLType, parseRow, pattern, predicate, prepare, profile, query, rewritePlaceholders, rowToObject, sanitizeForLog, serializeMessage, validateConfig, validateHostname, validatePageSize, validateParamName, validateParamValue, validatePort, validateQuery, validateSavepointName, withTransaction };
|
|
2452
|
+
export { type AdditionalInfo, AuthClient, BaseTransport, type BatchOptions, type BatchQuery, type BatchResult, type BatchSummary, type ClientOptions, type ColumnDef, type ColumnInfo, ConfigError, Connection, ConnectionPool, type ConnectionState, type CreateRLSPolicyOptions, type CreateRoleOptions, type CreateUserOptions, DEFAULT_CONFORMANCE, DEFAULT_HELLO_NAME, DEFAULT_HELLO_VERSION, DEFAULT_PAGE_SIZE, DEFAULT_PORT, DriverError, type EdgeDirection, type EdgePattern, EdgePatternBuilder, ErrBadConn, ErrClosed, ErrNoTx, ErrQueryInProgress, ErrRowsClosed, ErrTxDone, ErrTxInProgress, type ExplainOptions, type Frame, type FrameResult, type GQLEdge, type GQLId, type GQLNode, type GQLPath, type GQLRange, type GQLType, GQLValue, type GQLValueKind, GeodeClient, type GeodeConfig, type GeodeError, MAX_PAGE_SIZE, MAX_QUERY_LENGTH, MockTransport, MsgType, type NodePattern, NodePatternBuilder, type OperationTiming, type ParameterInfo, PatternBuilder, type PatternElement, type Permission, type PlanOperation, type PoolConfig, PredicateBuilder, type PredicateOp, PreparedStatement, QueryBuilder, type QueryOptions, type QueryParams, type QueryPlan, type QueryProfile, QueryResult, QueryResultIterator, MatrixQuicTransport as QuicheTransport, type RLSPolicy, RespType, type Role, type Row, SecurityError, type SortDirection, StateError, StatusClass, type StatusClassType, Transaction, type Transport, TransportError, type User, batch, batchAll, batchFirst, batchMap, batchParallel, buildBeginMessage, buildCommitMessage, buildHelloMessage, buildPingMessage, buildPullMessage, buildRollbackMessage, buildRollbackToMessage, buildRunGQLMessage, buildSavepointMessage, buildTLSConfig, cloneConfig, countPlaceholders, createAuthClient, createClient, createClientWithConfig, createTransport, defaultConfig, edge, explain, extractParameters, formatPlan, formatProfile, frameToError, fromJSON, getAddress, getColumnsFromSchema, isBindingsFrame, isDriverError, isErrorFrame, isFinalFrame, isGeodeError, isRetryableError, isSchemaFrame, mergeParams, node, parseDSN, parseFrame, parseGQLType, parseRow, pattern, predicate, prepare, profile, query, rewritePlaceholders, rowToObject, sanitizeForLog, serializeMessage, validateConfig, validateHostname, validatePageSize, validateParamName, validateParamValue, validatePort, validateQuery, validateSavepointName, withTransaction };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Decimal = require('decimal.js-light');
|
|
4
|
+
var losslessJson = require('lossless-json');
|
|
4
5
|
var fs = require('fs');
|
|
5
6
|
var crypto = require('crypto');
|
|
6
7
|
|
|
@@ -1014,8 +1015,20 @@ var init_types = __esm({
|
|
|
1014
1015
|
};
|
|
1015
1016
|
}
|
|
1016
1017
|
});
|
|
1017
|
-
|
|
1018
|
-
|
|
1018
|
+
function bigIntReviver(_key, value) {
|
|
1019
|
+
if (losslessJson.isLosslessNumber(value)) {
|
|
1020
|
+
const str = value.value;
|
|
1021
|
+
if (/^-?\d+$/.test(str)) {
|
|
1022
|
+
const num = Number(str);
|
|
1023
|
+
if (Number.isSafeInteger(num)) {
|
|
1024
|
+
return num;
|
|
1025
|
+
}
|
|
1026
|
+
return BigInt(str);
|
|
1027
|
+
}
|
|
1028
|
+
return Number(str);
|
|
1029
|
+
}
|
|
1030
|
+
return value;
|
|
1031
|
+
}
|
|
1019
1032
|
function parseFrame(data) {
|
|
1020
1033
|
let str;
|
|
1021
1034
|
if (Buffer.isBuffer(data)) {
|
|
@@ -1024,7 +1037,7 @@ function parseFrame(data) {
|
|
|
1024
1037
|
str = data;
|
|
1025
1038
|
}
|
|
1026
1039
|
try {
|
|
1027
|
-
const frame =
|
|
1040
|
+
const frame = losslessJson.parse(str, bigIntReviver);
|
|
1028
1041
|
if (!frame.result || typeof frame.result.type !== "string") {
|
|
1029
1042
|
const topLevel = frame;
|
|
1030
1043
|
if (typeof topLevel.type === "string") {
|
|
@@ -1173,7 +1186,7 @@ function buildPingMessage() {
|
|
|
1173
1186
|
};
|
|
1174
1187
|
}
|
|
1175
1188
|
function serializeMessage(msg) {
|
|
1176
|
-
const json =
|
|
1189
|
+
const json = losslessJson.stringify(msg, void 0, void 0, [bigIntStringifier]);
|
|
1177
1190
|
return Buffer.from(json + "\n", "utf-8");
|
|
1178
1191
|
}
|
|
1179
1192
|
function rewritePlaceholders(query2, args) {
|
|
@@ -1246,7 +1259,7 @@ function mergeParams(positionalParams, namedParams) {
|
|
|
1246
1259
|
}
|
|
1247
1260
|
return { ...positionalParams, ...namedParams };
|
|
1248
1261
|
}
|
|
1249
|
-
exports.MsgType = void 0; exports.RespType = void 0;
|
|
1262
|
+
exports.MsgType = void 0; exports.RespType = void 0; var bigIntStringifier;
|
|
1250
1263
|
var init_protocol = __esm({
|
|
1251
1264
|
"src/protocol.ts"() {
|
|
1252
1265
|
init_errors();
|
|
@@ -1272,6 +1285,10 @@ var init_protocol = __esm({
|
|
|
1272
1285
|
RESULT: "RESULT",
|
|
1273
1286
|
STATUS: "STATUS"
|
|
1274
1287
|
};
|
|
1288
|
+
bigIntStringifier = {
|
|
1289
|
+
test: (value) => typeof value === "bigint",
|
|
1290
|
+
stringify: (value) => value.toString()
|
|
1291
|
+
};
|
|
1275
1292
|
}
|
|
1276
1293
|
});
|
|
1277
1294
|
|