falkordb 6.3.1 → 6.4.0

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.
@@ -5,7 +5,7 @@ import { ConstraintType, EntityType } from "./commands/CONSTRAINT_CREATE";
5
5
  import { Client } from "./clients/client";
6
6
  import { MemoryUsageOptions } from "./commands/MEMORY_USAGE";
7
7
  export { ConstraintType, EntityType };
8
- export type GraphReply<T> = Omit<QueryReply, 'headers' | 'data'> & {
8
+ export type GraphReply<T> = Omit<QueryReply, "headers" | "data"> & {
9
9
  data?: Array<T>;
10
10
  };
11
11
  export default class Graph {
package/dist/src/graph.js CHANGED
@@ -4,6 +4,7 @@ exports.EntityType = exports.ConstraintType = void 0;
4
4
  const CONSTRAINT_CREATE_1 = require("./commands/CONSTRAINT_CREATE");
5
5
  Object.defineProperty(exports, "ConstraintType", { enumerable: true, get: function () { return CONSTRAINT_CREATE_1.ConstraintType; } });
6
6
  Object.defineProperty(exports, "EntityType", { enumerable: true, get: function () { return CONSTRAINT_CREATE_1.EntityType; } });
7
+ const polyfill_1 = require("@js-temporal/polyfill");
7
8
  // https://github.com/FalkorDB/FalkorDB/blob/master/src/resultset/formatters/resultset_formatter.h#L20
8
9
  var GraphValueTypes;
9
10
  (function (GraphValueTypes) {
@@ -20,6 +21,10 @@ var GraphValueTypes;
20
21
  GraphValueTypes[GraphValueTypes["MAP"] = 10] = "MAP";
21
22
  GraphValueTypes[GraphValueTypes["POINT"] = 11] = "POINT";
22
23
  GraphValueTypes[GraphValueTypes["VECTORF32"] = 12] = "VECTORF32";
24
+ GraphValueTypes[GraphValueTypes["DATETIME"] = 13] = "DATETIME";
25
+ GraphValueTypes[GraphValueTypes["DATE"] = 14] = "DATE";
26
+ GraphValueTypes[GraphValueTypes["TIME"] = 15] = "TIME";
27
+ GraphValueTypes[GraphValueTypes["DURATION"] = 16] = "DURATION";
23
28
  })(GraphValueTypes || (GraphValueTypes = {}));
24
29
  // export type GraphConnection = SingleGraphConnection | ClusterGraphConnection;
25
30
  class Graph {
@@ -64,21 +69,20 @@ class Graph {
64
69
  }
65
70
  #setMetadataPromise;
66
71
  #updateMetadata() {
67
- this.#setMetadataPromise ??= this.#setMetadata()
68
- .finally(() => this.#setMetadataPromise = undefined);
72
+ this.#setMetadataPromise ??= this.#setMetadata().finally(() => (this.#setMetadataPromise = undefined));
69
73
  return this.#setMetadataPromise;
70
74
  }
71
75
  // DO NOT use directly, use #updateMetadata instead
72
76
  async #setMetadata() {
73
77
  const [labels, relationshipTypes, propertyKeys] = await Promise.all([
74
- this.#client.roQuery(this.#name, 'CALL db.labels()', undefined, false),
75
- this.#client.roQuery(this.#name, 'CALL db.relationshipTypes()', undefined, false),
76
- this.#client.roQuery(this.#name, 'CALL db.propertyKeys()', undefined, false)
78
+ this.#client.roQuery(this.#name, "CALL db.labels()", undefined, false),
79
+ this.#client.roQuery(this.#name, "CALL db.relationshipTypes()", undefined, false),
80
+ this.#client.roQuery(this.#name, "CALL db.propertyKeys()", undefined, false),
77
81
  ]);
78
82
  this.#metadata = {
79
83
  labels: this.#cleanMetadataArray(labels.data),
80
84
  relationshipTypes: this.#cleanMetadataArray(relationshipTypes.data),
81
- propertyKeys: this.#cleanMetadataArray(propertyKeys.data)
85
+ propertyKeys: this.#cleanMetadataArray(propertyKeys.data),
82
86
  };
83
87
  return this.#metadata;
84
88
  }
@@ -109,7 +113,7 @@ class Graph {
109
113
  }
110
114
  }
111
115
  return data;
112
- })
116
+ }),
113
117
  };
114
118
  if (promises.length)
115
119
  await Promise.all(promises);
@@ -123,11 +127,11 @@ class Graph {
123
127
  case GraphValueTypes.INTEGER:
124
128
  return value;
125
129
  case GraphValueTypes.BOOLEAN:
126
- return value === 'true';
130
+ return value === "true";
127
131
  case GraphValueTypes.DOUBLE:
128
132
  return parseFloat(value);
129
133
  case GraphValueTypes.ARRAY:
130
- return value.map(x => this.#parseValue(x, promises));
134
+ return value.map((x) => this.#parseValue(x, promises));
131
135
  case GraphValueTypes.EDGE:
132
136
  return this.#parseEdge(value, promises);
133
137
  case GraphValueTypes.NODE:
@@ -135,7 +139,7 @@ class Graph {
135
139
  case GraphValueTypes.PATH:
136
140
  return {
137
141
  nodes: value[0][1].map(([, node]) => this.#parseNode(node, promises)),
138
- edges: value[1][1].map(([, edge]) => this.#parseEdge(edge, promises))
142
+ edges: value[1][1].map(([, edge]) => this.#parseEdge(edge, promises)),
139
143
  };
140
144
  case GraphValueTypes.MAP: {
141
145
  const map = {};
@@ -147,24 +151,44 @@ class Graph {
147
151
  case GraphValueTypes.POINT:
148
152
  return {
149
153
  latitude: parseFloat(value[0]),
150
- longitude: parseFloat(value[1])
154
+ longitude: parseFloat(value[1]),
151
155
  };
152
156
  case GraphValueTypes.VECTORF32:
153
- return value.map(x => Number(x));
157
+ return value.map((x) => Number(x));
158
+ case GraphValueTypes.DATETIME:
159
+ return polyfill_1.Temporal.Instant.fromEpochMilliseconds(value * 1000)
160
+ .toZonedDateTimeISO("UTC")
161
+ .toPlainDateTime();
162
+ case GraphValueTypes.DATE:
163
+ return polyfill_1.Temporal.Instant.fromEpochMilliseconds(value * 1000)
164
+ .toZonedDateTimeISO("UTC")
165
+ .toPlainDate();
166
+ case GraphValueTypes.TIME:
167
+ return polyfill_1.Temporal.Instant.fromEpochMilliseconds(value * 1000)
168
+ .toZonedDateTimeISO("UTC")
169
+ .toPlainTime();
170
+ case GraphValueTypes.DURATION:
171
+ const time = polyfill_1.Temporal.Instant.fromEpochMilliseconds(value * 1000);
172
+ const epoch = polyfill_1.Temporal.Instant.fromEpochMilliseconds(0);
173
+ return epoch
174
+ .toZonedDateTimeISO("UTC")
175
+ .until(time.toZonedDateTimeISO("UTC"), {
176
+ largestUnit: "years",
177
+ });
154
178
  default:
155
179
  throw new Error(`unknown scalar type: ${valueType}`);
156
180
  }
157
181
  }
158
- #parseEdge([id, relationshipTypeId, sourceId, destinationId, properties], promises) {
182
+ #parseEdge([id, relationshipTypeId, sourceId, destinationId, properties,], promises) {
159
183
  const edge = {
160
184
  id,
161
185
  sourceId,
162
186
  destinationId,
163
- properties: this.#parseProperties(properties, promises)
187
+ properties: this.#parseProperties(properties, promises),
164
188
  };
165
- const relationshipType = this.#getMetadata('relationshipTypes', relationshipTypeId);
189
+ const relationshipType = this.#getMetadata("relationshipTypes", relationshipTypeId);
166
190
  if (relationshipType instanceof Promise) {
167
- promises.push(relationshipType.then(value => edge.relationshipType = value));
191
+ promises.push(relationshipType.then((value) => (edge.relationshipType = value)));
168
192
  }
169
193
  else {
170
194
  edge.relationshipType = relationshipType;
@@ -174,9 +198,9 @@ class Graph {
174
198
  #parseNode([id, labelIds, properties], promises) {
175
199
  const labels = new Array(labelIds.length);
176
200
  for (let i = 0; i < labelIds.length; i++) {
177
- const value = this.#getMetadata('labels', labelIds[i]);
201
+ const value = this.#getMetadata("labels", labelIds[i]);
178
202
  if (value instanceof Promise) {
179
- promises.push(value.then(value => labels[i] = value));
203
+ promises.push(value.then((value) => (labels[i] = value)));
180
204
  }
181
205
  else {
182
206
  labels[i] = value;
@@ -185,15 +209,15 @@ class Graph {
185
209
  return {
186
210
  id,
187
211
  labels,
188
- properties: this.#parseProperties(properties, promises)
212
+ properties: this.#parseProperties(properties, promises),
189
213
  };
190
214
  }
191
215
  #parseProperties(raw, promises) {
192
216
  const parsed = {};
193
217
  for (const [id, type, value] of raw) {
194
- const parsedValue = this.#parseValue([type, value], promises), key = this.#getMetadata('propertyKeys', id);
218
+ const parsedValue = this.#parseValue([type, value], promises), key = this.#getMetadata("propertyKeys", id);
195
219
  if (key instanceof Promise) {
196
- promises.push(key.then(key => parsed[key] = parsedValue));
220
+ promises.push(key.then((key) => (parsed[key] = parsedValue)));
197
221
  }
198
222
  else {
199
223
  parsed[key] = parsedValue;
@@ -207,7 +231,7 @@ class Graph {
207
231
  idxType = "";
208
232
  }
209
233
  let query = `CREATE ${idxType ? idxType + " " : ""}INDEX FOR ${pattern} ON (${properties
210
- .map(prop => `e.${prop}`)
234
+ .map((prop) => `e.${prop}`)
211
235
  .join(", ")})`;
212
236
  if (options) {
213
237
  const optionsMap = Object.entries(options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "falkordb",
3
- "version": "6.3.1",
3
+ "version": "6.4.0",
4
4
  "description": "A FalkorDB javascript library",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -47,9 +47,10 @@
47
47
  "jest": "^29.7.0",
48
48
  "release-it": "^19.0.3",
49
49
  "ts-jest": "^29.2.5",
50
- "typescript": "^5.7.2"
50
+ "typescript": "^5.9.3"
51
51
  },
52
52
  "dependencies": {
53
+ "@js-temporal/polyfill": "^0.5.1",
53
54
  "@redis/client": "^1.6.0",
54
55
  "cluster-key-slot": "1.1.2",
55
56
  "generic-pool": "^3.9.0",