@geodedb/client 1.0.0-alpha.13 → 1.0.0-alpha.15

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 CHANGED
@@ -381,24 +381,55 @@ 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: string | number;
400
+ id: GQLId;
389
401
  labels: string[];
390
402
  properties: Record<string, unknown>;
391
403
  }
392
404
  /**
393
405
  * Edge structure from graph queries.
406
+ *
407
+ * Note: The server may return edge endpoints as either:
408
+ * - `startNode`/`endNode` (normalized form used by the client)
409
+ * - `from`/`to` (alternative wire format)
410
+ *
411
+ * The client normalizes both formats to `startNode`/`endNode`.
394
412
  */
395
413
  interface GQLEdge {
396
- id: string | number;
414
+ id: GQLId;
397
415
  type: string;
398
- startNode: string | number;
399
- endNode: string | number;
416
+ startNode: GQLId;
417
+ endNode: GQLId;
400
418
  properties: Record<string, unknown>;
401
419
  }
420
+ /**
421
+ * Raw edge structure as it may appear in wire format.
422
+ * Used internally for parsing before normalization.
423
+ */
424
+ interface RawEdge {
425
+ id: GQLId;
426
+ type: string;
427
+ startNode?: GQLId;
428
+ endNode?: GQLId;
429
+ from?: GQLId;
430
+ to?: GQLId;
431
+ properties?: Record<string, unknown>;
432
+ }
402
433
  /**
403
434
  * Path structure from graph queries.
404
435
  */
@@ -1934,6 +1965,9 @@ interface Frame {
1934
1965
  }
1935
1966
  /**
1936
1967
  * Parse a JSON frame from raw bytes.
1968
+ *
1969
+ * Uses lossless-json to preserve precision for large integers (> Number.MAX_SAFE_INTEGER).
1970
+ * This is critical for node/edge IDs which may be 18+ digit integers.
1937
1971
  */
1938
1972
  declare function parseFrame(data: Buffer | string): Frame;
1939
1973
  /**
@@ -1998,6 +2032,9 @@ declare function buildRollbackToMessage(name: string): Record<string, unknown>;
1998
2032
  declare function buildPingMessage(): Record<string, unknown>;
1999
2033
  /**
2000
2034
  * Serialize a message to JSON line format.
2035
+ *
2036
+ * Uses lossless-json with a custom BigInt stringifier to properly serialize
2037
+ * BigInt values as numbers without quotes, maintaining wire protocol compatibility.
2001
2038
  */
2002
2039
  declare function serializeMessage(msg: Record<string, unknown>): Buffer;
2003
2040
  /**
@@ -2431,4 +2468,4 @@ declare function node(): NodePatternBuilder;
2431
2468
  */
2432
2469
  declare function edge(): EdgePatternBuilder;
2433
2470
 
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 };
2471
+ 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, type RawEdge, 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,24 +381,55 @@ 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: string | number;
400
+ id: GQLId;
389
401
  labels: string[];
390
402
  properties: Record<string, unknown>;
391
403
  }
392
404
  /**
393
405
  * Edge structure from graph queries.
406
+ *
407
+ * Note: The server may return edge endpoints as either:
408
+ * - `startNode`/`endNode` (normalized form used by the client)
409
+ * - `from`/`to` (alternative wire format)
410
+ *
411
+ * The client normalizes both formats to `startNode`/`endNode`.
394
412
  */
395
413
  interface GQLEdge {
396
- id: string | number;
414
+ id: GQLId;
397
415
  type: string;
398
- startNode: string | number;
399
- endNode: string | number;
416
+ startNode: GQLId;
417
+ endNode: GQLId;
400
418
  properties: Record<string, unknown>;
401
419
  }
420
+ /**
421
+ * Raw edge structure as it may appear in wire format.
422
+ * Used internally for parsing before normalization.
423
+ */
424
+ interface RawEdge {
425
+ id: GQLId;
426
+ type: string;
427
+ startNode?: GQLId;
428
+ endNode?: GQLId;
429
+ from?: GQLId;
430
+ to?: GQLId;
431
+ properties?: Record<string, unknown>;
432
+ }
402
433
  /**
403
434
  * Path structure from graph queries.
404
435
  */
@@ -1934,6 +1965,9 @@ interface Frame {
1934
1965
  }
1935
1966
  /**
1936
1967
  * Parse a JSON frame from raw bytes.
1968
+ *
1969
+ * Uses lossless-json to preserve precision for large integers (> Number.MAX_SAFE_INTEGER).
1970
+ * This is critical for node/edge IDs which may be 18+ digit integers.
1937
1971
  */
1938
1972
  declare function parseFrame(data: Buffer | string): Frame;
1939
1973
  /**
@@ -1998,6 +2032,9 @@ declare function buildRollbackToMessage(name: string): Record<string, unknown>;
1998
2032
  declare function buildPingMessage(): Record<string, unknown>;
1999
2033
  /**
2000
2034
  * Serialize a message to JSON line format.
2035
+ *
2036
+ * Uses lossless-json with a custom BigInt stringifier to properly serialize
2037
+ * BigInt values as numbers without quotes, maintaining wire protocol compatibility.
2001
2038
  */
2002
2039
  declare function serializeMessage(msg: Record<string, unknown>): Buffer;
2003
2040
  /**
@@ -2431,4 +2468,4 @@ declare function node(): NodePatternBuilder;
2431
2468
  */
2432
2469
  declare function edge(): EdgePatternBuilder;
2433
2470
 
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 };
2471
+ 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, type RawEdge, 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
 
@@ -579,8 +580,20 @@ function fromJSON(value, typeHint) {
579
580
  if ("id" in obj && "labels" in obj && "properties" in obj) {
580
581
  return exports.GQLValue.node(obj);
581
582
  }
582
- if ("id" in obj && "type" in obj && "startNode" in obj && "endNode" in obj) {
583
- return exports.GQLValue.edge(obj);
583
+ if ("id" in obj && "type" in obj) {
584
+ const hasStartEnd = "startNode" in obj && "endNode" in obj;
585
+ const hasFromTo = "from" in obj && "to" in obj;
586
+ if (hasStartEnd || hasFromTo) {
587
+ const rawEdge = obj;
588
+ const normalizedEdge = {
589
+ id: rawEdge.id,
590
+ type: rawEdge.type,
591
+ startNode: rawEdge.startNode ?? rawEdge.from ?? "",
592
+ endNode: rawEdge.endNode ?? rawEdge.to ?? "",
593
+ properties: rawEdge.properties ?? {}
594
+ };
595
+ return exports.GQLValue.edge(normalizedEdge);
596
+ }
584
597
  }
585
598
  if ("nodes" in obj && "edges" in obj && Array.isArray(obj.nodes)) {
586
599
  return exports.GQLValue.path(obj);
@@ -675,8 +688,17 @@ function convertWithType(value, type) {
675
688
  return fromJSON(value);
676
689
  case "NODE":
677
690
  return exports.GQLValue.node(value);
678
- case "EDGE":
679
- return exports.GQLValue.edge(value);
691
+ case "EDGE": {
692
+ const rawEdge = value;
693
+ const normalizedEdge = {
694
+ id: rawEdge.id,
695
+ type: rawEdge.type,
696
+ startNode: rawEdge.startNode ?? rawEdge.from ?? "",
697
+ endNode: rawEdge.endNode ?? rawEdge.to ?? "",
698
+ properties: rawEdge.properties ?? {}
699
+ };
700
+ return exports.GQLValue.edge(normalizedEdge);
701
+ }
680
702
  case "PATH":
681
703
  return exports.GQLValue.path(value);
682
704
  default:
@@ -1014,8 +1036,20 @@ var init_types = __esm({
1014
1036
  };
1015
1037
  }
1016
1038
  });
1017
-
1018
- // src/protocol.ts
1039
+ function bigIntReviver(_key, value) {
1040
+ if (losslessJson.isLosslessNumber(value)) {
1041
+ const str = value.value;
1042
+ if (/^-?\d+$/.test(str)) {
1043
+ const num = Number(str);
1044
+ if (Number.isSafeInteger(num)) {
1045
+ return num;
1046
+ }
1047
+ return BigInt(str);
1048
+ }
1049
+ return Number(str);
1050
+ }
1051
+ return value;
1052
+ }
1019
1053
  function parseFrame(data) {
1020
1054
  let str;
1021
1055
  if (Buffer.isBuffer(data)) {
@@ -1024,7 +1058,7 @@ function parseFrame(data) {
1024
1058
  str = data;
1025
1059
  }
1026
1060
  try {
1027
- const frame = JSON.parse(str);
1061
+ const frame = losslessJson.parse(str, bigIntReviver);
1028
1062
  if (!frame.result || typeof frame.result.type !== "string") {
1029
1063
  const topLevel = frame;
1030
1064
  if (typeof topLevel.type === "string") {
@@ -1173,7 +1207,7 @@ function buildPingMessage() {
1173
1207
  };
1174
1208
  }
1175
1209
  function serializeMessage(msg) {
1176
- const json = JSON.stringify(msg);
1210
+ const json = losslessJson.stringify(msg, void 0, void 0, [bigIntStringifier]);
1177
1211
  return Buffer.from(json + "\n", "utf-8");
1178
1212
  }
1179
1213
  function rewritePlaceholders(query2, args) {
@@ -1246,7 +1280,7 @@ function mergeParams(positionalParams, namedParams) {
1246
1280
  }
1247
1281
  return { ...positionalParams, ...namedParams };
1248
1282
  }
1249
- exports.MsgType = void 0; exports.RespType = void 0;
1283
+ exports.MsgType = void 0; exports.RespType = void 0; var bigIntStringifier;
1250
1284
  var init_protocol = __esm({
1251
1285
  "src/protocol.ts"() {
1252
1286
  init_errors();
@@ -1272,6 +1306,10 @@ var init_protocol = __esm({
1272
1306
  RESULT: "RESULT",
1273
1307
  STATUS: "STATUS"
1274
1308
  };
1309
+ bigIntStringifier = {
1310
+ test: (value) => typeof value === "bigint",
1311
+ stringify: (value) => value.toString()
1312
+ };
1275
1313
  }
1276
1314
  });
1277
1315