gremlin 3.5.3 → 3.6.1

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.
Files changed (108) hide show
  1. package/.eslintrc.js +3 -2
  2. package/README.md +2 -2
  3. package/doc/AnonymousTraversalSource.html +2 -2
  4. package/doc/Authenticator.html +2 -2
  5. package/doc/Bytecode.html +2 -2
  6. package/doc/Client.html +2 -2
  7. package/doc/Connection.html +10 -10
  8. package/doc/DriverRemoteConnection.html +2 -2
  9. package/doc/EdgeLabelVerificationStrategy.html +2 -2
  10. package/doc/Graph.html +2 -2
  11. package/doc/GraphSON2Reader.html +2 -2
  12. package/doc/GraphSON2Writer.html +2 -2
  13. package/doc/GraphSON3Reader.html +2 -2
  14. package/doc/GraphSON3Writer.html +2 -2
  15. package/doc/GraphTraversal.html +1006 -171
  16. package/doc/GraphTraversalSource.html +517 -16
  17. package/doc/HaltedTraverserStrategy.html +2 -2
  18. package/doc/MatchAlgorithmStrategy.html +2 -2
  19. package/doc/P.html +2 -2
  20. package/doc/PartitionStrategy.html +2 -2
  21. package/doc/Path.html +2 -2
  22. package/doc/PlainTextSaslAuthenticator.html +2 -2
  23. package/doc/ProductiveByStrategy.html +2 -2
  24. package/doc/RemoteConnection.html +2 -2
  25. package/doc/RemoteStrategy.html +2 -2
  26. package/doc/RemoteTraversal.html +2 -2
  27. package/doc/ReservedKeysVerificationStrategy.html +2 -2
  28. package/doc/ResponseError.html +2 -2
  29. package/doc/ResultSet.html +2 -2
  30. package/doc/SaslAuthenticator.html +2 -2
  31. package/doc/SaslMechanismBase.html +2 -2
  32. package/doc/SaslMechanismPlain.html +2 -2
  33. package/doc/SeedStrategy.html +2 -2
  34. package/doc/SubgraphStrategy.html +2 -2
  35. package/doc/TextP.html +292 -2
  36. package/doc/Transaction.html +2 -2
  37. package/doc/Translator.html +2 -2
  38. package/doc/TraversalStrategies.html +2 -2
  39. package/doc/TraversalStrategy.html +2 -2
  40. package/doc/TypeSerializer.html +2 -2
  41. package/doc/driver_auth_authenticator.js.html +2 -2
  42. package/doc/driver_auth_mechanisms_sasl-mechanism-base.js.html +2 -2
  43. package/doc/driver_auth_mechanisms_sasl-mechanism-plain.js.html +2 -2
  44. package/doc/driver_auth_plain-text-sasl-authenticator.js.html +2 -2
  45. package/doc/driver_auth_sasl-authenticator.js.html +2 -2
  46. package/doc/driver_client.js.html +2 -2
  47. package/doc/driver_connection.js.html +32 -9
  48. package/doc/driver_driver-remote-connection.js.html +2 -2
  49. package/doc/driver_remote-connection.js.html +2 -2
  50. package/doc/driver_response-error.js.html +2 -2
  51. package/doc/driver_result-set.js.html +2 -2
  52. package/doc/global.html +67 -3
  53. package/doc/index.html +4 -4
  54. package/doc/module.exports.html +301 -0
  55. package/doc/process_anonymous-traversal.js.html +2 -2
  56. package/doc/process_bytecode.js.html +2 -2
  57. package/doc/process_graph-traversal.js.html +108 -13
  58. package/doc/process_transaction.js.html +2 -2
  59. package/doc/process_translator.js.html +2 -2
  60. package/doc/process_traversal-strategy.js.html +16 -3
  61. package/doc/process_traversal.js.html +14 -3
  62. package/doc/structure_graph.js.html +2 -2
  63. package/doc/structure_io_binary_internals_DataType.js.html +149 -0
  64. package/doc/structure_io_binary_internals_GraphBinaryReader.js.html +131 -0
  65. package/doc/structure_io_binary_internals_GraphBinaryWriter.js.html +134 -0
  66. package/doc/structure_io_graph-serializer.js.html +2 -2
  67. package/doc/structure_io_type-serializers.js.html +2 -2
  68. package/lib/driver/connection.js +30 -7
  69. package/lib/process/graph-traversal.js +106 -11
  70. package/lib/process/traversal-strategy.js +14 -1
  71. package/lib/process/traversal.js +12 -1
  72. package/lib/structure/io/binary/GraphBinary.js +109 -0
  73. package/lib/structure/io/binary/internals/AnySerializer.js +95 -0
  74. package/lib/structure/io/binary/internals/ArraySerializer.js +135 -0
  75. package/lib/structure/io/binary/internals/BigIntegerSerializer.js +151 -0
  76. package/lib/structure/io/binary/internals/BooleanSerializer.js +103 -0
  77. package/lib/structure/io/binary/internals/BulkSetSerializer.js +124 -0
  78. package/lib/structure/io/binary/internals/ByteBufferSerializer.js +124 -0
  79. package/lib/structure/io/binary/internals/ByteSerializer.js +95 -0
  80. package/lib/structure/io/binary/internals/BytecodeSerializer.js +249 -0
  81. package/lib/structure/io/binary/internals/DataType.js +98 -0
  82. package/lib/structure/io/binary/internals/DateSerializer.js +103 -0
  83. package/lib/structure/io/binary/internals/DoubleSerializer.js +99 -0
  84. package/lib/structure/io/binary/internals/EdgeSerializer.js +215 -0
  85. package/lib/structure/io/binary/internals/EnumSerializer.js +149 -0
  86. package/lib/structure/io/binary/internals/FloatSerializer.js +99 -0
  87. package/lib/structure/io/binary/internals/GraphBinaryReader.js +80 -0
  88. package/lib/structure/io/binary/internals/GraphBinaryWriter.js +83 -0
  89. package/lib/structure/io/binary/internals/IntSerializer.js +112 -0
  90. package/lib/structure/io/binary/internals/LambdaSerializer.js +70 -0
  91. package/lib/structure/io/binary/internals/LongSerializer.js +107 -0
  92. package/lib/structure/io/binary/internals/LongSerializerNg.js +102 -0
  93. package/lib/structure/io/binary/internals/MapSerializer.js +153 -0
  94. package/lib/structure/io/binary/internals/NumberSerializationStrategy.js +68 -0
  95. package/lib/structure/io/binary/internals/PSerializer.js +151 -0
  96. package/lib/structure/io/binary/internals/PathSerializer.js +123 -0
  97. package/lib/structure/io/binary/internals/PropertySerializer.js +141 -0
  98. package/lib/structure/io/binary/internals/ShortSerializer.js +99 -0
  99. package/lib/structure/io/binary/internals/StringSerializer.js +114 -0
  100. package/lib/structure/io/binary/internals/TextPSerializer.js +145 -0
  101. package/lib/structure/io/binary/internals/TraversalStrategySerializer.js +72 -0
  102. package/lib/structure/io/binary/internals/TraverserSerializer.js +123 -0
  103. package/lib/structure/io/binary/internals/UnspecifiedNullSerializer.js +75 -0
  104. package/lib/structure/io/binary/internals/UuidSerializer.js +119 -0
  105. package/lib/structure/io/binary/internals/VertexPropertySerializer.js +172 -0
  106. package/lib/structure/io/binary/internals/VertexSerializer.js +135 -0
  107. package/lib/structure/io/binary/internals/utils.js +59 -0
  108. package/package.json +12 -4
@@ -540,13 +540,13 @@ module.exports = {
540
540
  </div>
541
541
 
542
542
  <nav>
543
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AnonymousTraversalSource.html">AnonymousTraversalSource</a></li><li><a href="Authenticator.html">Authenticator</a></li><li><a href="Bytecode.html">Bytecode</a></li><li><a href="Client.html">Client</a></li><li><a href="Connection.html">Connection</a></li><li><a href="DriverRemoteConnection.html">DriverRemoteConnection</a></li><li><a href="EdgeLabelVerificationStrategy.html">EdgeLabelVerificationStrategy</a></li><li><a href="Graph.html">Graph</a></li><li><a href="GraphSON2Reader.html">GraphSON2Reader</a></li><li><a href="GraphSON2Writer.html">GraphSON2Writer</a></li><li><a href="GraphSON3Reader.html">GraphSON3Reader</a></li><li><a href="GraphSON3Writer.html">GraphSON3Writer</a></li><li><a href="GraphTraversal.html">GraphTraversal</a></li><li><a href="GraphTraversalSource.html">GraphTraversalSource</a></li><li><a href="HaltedTraverserStrategy.html">HaltedTraverserStrategy</a></li><li><a href="MatchAlgorithmStrategy.html">MatchAlgorithmStrategy</a></li><li><a href="P.html">P</a></li><li><a href="PartitionStrategy.html">PartitionStrategy</a></li><li><a href="Path.html">Path</a></li><li><a href="PlainTextSaslAuthenticator.html">PlainTextSaslAuthenticator</a></li><li><a href="ProductiveByStrategy.html">ProductiveByStrategy</a></li><li><a href="RemoteConnection.html">RemoteConnection</a></li><li><a href="RemoteStrategy.html">RemoteStrategy</a></li><li><a href="RemoteTraversal.html">RemoteTraversal</a></li><li><a href="ReservedKeysVerificationStrategy.html">ReservedKeysVerificationStrategy</a></li><li><a href="ResponseError.html">ResponseError</a></li><li><a href="ResultSet.html">ResultSet</a></li><li><a href="SaslAuthenticator.html">SaslAuthenticator</a></li><li><a href="SaslMechanismBase.html">SaslMechanismBase</a></li><li><a href="SaslMechanismPlain.html">SaslMechanismPlain</a></li><li><a href="SubgraphStrategy.html">SubgraphStrategy</a></li><li><a href="TextP.html">TextP</a></li><li><a href="Transaction.html">Transaction</a></li><li><a href="Translator.html">Translator</a></li><li><a href="TraversalStrategies.html">TraversalStrategies</a></li><li><a href="TraversalStrategy.html">TraversalStrategy</a></li><li><a href="TypeSerializer.html">TypeSerializer</a></li></ul><h3>Global</h3><ul><li><a href="global.html#statics">statics</a></li></ul>
543
+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AnonymousTraversalSource.html">AnonymousTraversalSource</a></li><li><a href="Authenticator.html">Authenticator</a></li><li><a href="Bytecode.html">Bytecode</a></li><li><a href="Client.html">Client</a></li><li><a href="Connection.html">Connection</a></li><li><a href="DriverRemoteConnection.html">DriverRemoteConnection</a></li><li><a href="EdgeLabelVerificationStrategy.html">EdgeLabelVerificationStrategy</a></li><li><a href="Graph.html">Graph</a></li><li><a href="GraphSON2Reader.html">GraphSON2Reader</a></li><li><a href="GraphSON2Writer.html">GraphSON2Writer</a></li><li><a href="GraphSON3Reader.html">GraphSON3Reader</a></li><li><a href="GraphSON3Writer.html">GraphSON3Writer</a></li><li><a href="GraphTraversal.html">GraphTraversal</a></li><li><a href="GraphTraversalSource.html">GraphTraversalSource</a></li><li><a href="HaltedTraverserStrategy.html">HaltedTraverserStrategy</a></li><li><a href="MatchAlgorithmStrategy.html">MatchAlgorithmStrategy</a></li><li><a href="module.exports.html">exports</a></li><li><a href="P.html">P</a></li><li><a href="PartitionStrategy.html">PartitionStrategy</a></li><li><a href="Path.html">Path</a></li><li><a href="PlainTextSaslAuthenticator.html">PlainTextSaslAuthenticator</a></li><li><a href="ProductiveByStrategy.html">ProductiveByStrategy</a></li><li><a href="RemoteConnection.html">RemoteConnection</a></li><li><a href="RemoteStrategy.html">RemoteStrategy</a></li><li><a href="RemoteTraversal.html">RemoteTraversal</a></li><li><a href="ReservedKeysVerificationStrategy.html">ReservedKeysVerificationStrategy</a></li><li><a href="ResponseError.html">ResponseError</a></li><li><a href="ResultSet.html">ResultSet</a></li><li><a href="SaslAuthenticator.html">SaslAuthenticator</a></li><li><a href="SaslMechanismBase.html">SaslMechanismBase</a></li><li><a href="SaslMechanismPlain.html">SaslMechanismPlain</a></li><li><a href="SeedStrategy.html">SeedStrategy</a></li><li><a href="SubgraphStrategy.html">SubgraphStrategy</a></li><li><a href="TextP.html">TextP</a></li><li><a href="Transaction.html">Transaction</a></li><li><a href="Translator.html">Translator</a></li><li><a href="TraversalStrategies.html">TraversalStrategies</a></li><li><a href="TraversalStrategy.html">TraversalStrategy</a></li><li><a href="TypeSerializer.html">TypeSerializer</a></li></ul><h3>Global</h3><ul><li><a href="global.html#DataType">DataType</a></li><li><a href="global.html#statics">statics</a></li></ul>
544
544
  </nav>
545
545
 
546
546
  <br class="clear">
547
547
 
548
548
  <footer>
549
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Mon Apr 11 2022 07:21:14 GMT-0400 (Eastern Daylight Time)
549
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue Jul 26 2022 16:12:54 GMT-0400 (Eastern Daylight Time)
550
550
  </footer>
551
551
 
552
552
  <script> prettyPrint(); </script>
@@ -28,6 +28,7 @@ const WebSocket = require('ws');
28
28
  const util = require('util');
29
29
  const utils = require('../utils');
30
30
  const serializer = require('../structure/io/graph-serializer');
31
+ const { graphBinaryReader, graphBinaryWriter } = require('../structure/io/binary/GraphBinary');
31
32
  const ResultSet = require('./result-set');
32
33
  const ResponseError = require('./response-error');
33
34
 
@@ -40,6 +41,7 @@ const responseStatusCode = {
40
41
 
41
42
  const defaultMimeType = 'application/vnd.gremlin-v3.0+json';
42
43
  const graphSON2MimeType = 'application/vnd.gremlin-v2.0+json';
44
+ const graphBinaryMimeType = 'application/vnd.graphbinary-v1.0';
43
45
 
44
46
  const pingIntervalDelay = 60 * 1000;
45
47
  const pongTimeoutDelay = 30 * 1000;
@@ -65,7 +67,7 @@ class Connection extends EventEmitter {
65
67
  * @param {Boolean} [options.pingEnabled] Setup ping interval. Defaults to: true.
66
68
  * @param {Number} [options.pingInterval] Ping request interval in ms if ping enabled. Defaults to: 60000.
67
69
  * @param {Number} [options.pongTimeout] Timeout of pong response in ms after sending a ping. Defaults to: 30000.
68
- * @param {Boolean} [options.connectOnStartup] Open websocket on startup. Defaults to: true.
70
+ * @param {Boolean} [options.connectOnStartup] Deprecated and non-functional. Open websocket on startup.
69
71
  * @constructor
70
72
  */
71
73
  constructor(url, options) {
@@ -101,8 +103,10 @@ class Connection extends EventEmitter {
101
103
  this._pingIntervalDelay = this.options.pingInterval || pingIntervalDelay;
102
104
  this._pongTimeoutDelay = this.options.pongTimeout || pongTimeoutDelay;
103
105
 
104
- if (this.options.connectOnStartup !== false) {
105
- this.open();
106
+ if (this.options.connectOnStartup) {
107
+ console.warn(
108
+ 'connectOnStartup is now deprecated and non-functional. To open a connection, please call open() after instantiating connection object.',
109
+ );
106
110
  }
107
111
  }
108
112
 
@@ -180,7 +184,7 @@ class Connection extends EventEmitter {
180
184
  };
181
185
 
182
186
  const request_buf = this._writer.writeRequest(request);
183
- const message = Buffer.concat([this._header_buf, request_buf], this._header_buf.length + request_buf.length);
187
+ const message = Buffer.concat([this._header_buf, request_buf]);
184
188
  this._ws.send(message);
185
189
  }),
186
190
  );
@@ -211,7 +215,7 @@ class Connection extends EventEmitter {
211
215
  };
212
216
 
213
217
  const request_buf = this._writer.writeRequest(request);
214
- const message = Buffer.concat([this._header_buf, request_buf], this._header_buf.length + request_buf.length);
218
+ const message = Buffer.concat([this._header_buf, request_buf]);
215
219
  this._ws.send(message);
216
220
  })
217
221
  .catch((err) => readableStream.destroy(err));
@@ -220,10 +224,18 @@ class Connection extends EventEmitter {
220
224
  }
221
225
 
222
226
  _getDefaultReader(mimeType) {
227
+ if (mimeType === graphBinaryMimeType) {
228
+ return graphBinaryReader;
229
+ }
230
+
223
231
  return mimeType === graphSON2MimeType ? new serializer.GraphSON2Reader() : new serializer.GraphSONReader();
224
232
  }
225
233
 
226
234
  _getDefaultWriter(mimeType) {
235
+ if (mimeType === graphBinaryMimeType) {
236
+ return graphBinaryWriter;
237
+ }
238
+
227
239
  return mimeType === graphSON2MimeType ? new serializer.GraphSON2Writer() : new serializer.GraphSONWriter();
228
240
  }
229
241
 
@@ -252,7 +264,7 @@ class Connection extends EventEmitter {
252
264
 
253
265
  _handleError(err) {
254
266
  this.emit('log', `ws error ${err}`);
255
- this._cleanupWebsocket();
267
+ this._cleanupWebsocket(err);
256
268
  this.emit('socketError', err);
257
269
  }
258
270
 
@@ -356,7 +368,7 @@ class Connection extends EventEmitter {
356
368
  /**
357
369
  * clean websocket context
358
370
  */
359
- _cleanupWebsocket() {
371
+ _cleanupWebsocket(err) {
360
372
  if (this._pingInterval) {
361
373
  clearInterval(this._pingInterval);
362
374
  }
@@ -366,6 +378,17 @@ class Connection extends EventEmitter {
366
378
  }
367
379
  this._pongTimeout = null;
368
380
 
381
+ // Invoke waiting callbacks to complete Promises when closing the websocket
382
+ Object.keys(this._responseHandlers).forEach((requestId) => {
383
+ const handler = this._responseHandlers[requestId];
384
+ const isStreamingResponse = handler.result instanceof Stream.Readable;
385
+ if (isStreamingResponse) {
386
+ handler.callback(null);
387
+ } else {
388
+ const cause = err ? err : new Error('Connection has been closed.');
389
+ handler.callback(cause);
390
+ }
391
+ });
369
392
  this._ws.removeAllListeners();
370
393
  this._openPromise = null;
371
394
  this._closePromise = null;
@@ -94,17 +94,29 @@ class GraphTraversalSource {
94
94
  * @returns {GraphTraversalSource}
95
95
  */
96
96
  withComputer(graphComputer, workers, result, persist, vertices, edges, configuration) {
97
- return this.withStrategies(
98
- new VertexProgramStrategy({
99
- graphComputer: graphComputer,
100
- workers: workers,
101
- result: result,
102
- persist: persist,
103
- vertices: vertices,
104
- edges: edges,
105
- configuration: configuration,
106
- }),
107
- );
97
+ const m = {};
98
+ if (graphComputer !== undefined) {
99
+ m.graphComputer = graphComputer;
100
+ }
101
+ if (workers !== undefined) {
102
+ m.workers = workers;
103
+ }
104
+ if (result !== undefined) {
105
+ m.result = result;
106
+ }
107
+ if (persist !== undefined) {
108
+ m.graphComputer = persist;
109
+ }
110
+ if (vertices !== undefined) {
111
+ m.vertices = vertices;
112
+ }
113
+ if (edges !== undefined) {
114
+ m.edges = edges;
115
+ }
116
+ if (configuration !== undefined) {
117
+ m.configuration = configuration;
118
+ }
119
+ return this.withStrategies(new VertexProgramStrategy(m));
108
120
  }
109
121
 
110
122
  /**
@@ -266,6 +278,16 @@ class GraphTraversalSource {
266
278
  return new this.graphTraversalClass(this.graph, new TraversalStrategies(this.traversalStrategies), b);
267
279
  }
268
280
 
281
+ /**
282
+ * mergeV GraphTraversalSource step method.
283
+ * @param {...Object} args
284
+ * @returns {GraphTraversal}
285
+ */
286
+ mergeE(...args) {
287
+ const b = new Bytecode(this.bytecode).addStep('mergeE', args);
288
+ return new this.graphTraversalClass(this.graph, new TraversalStrategies(this.traversalStrategies), b);
289
+ }
290
+
269
291
  /**
270
292
  * addV GraphTraversalSource step method.
271
293
  * @param {...Object} args
@@ -276,6 +298,16 @@ class GraphTraversalSource {
276
298
  return new this.graphTraversalClass(this.graph, new TraversalStrategies(this.traversalStrategies), b);
277
299
  }
278
300
 
301
+ /**
302
+ * mergeV GraphTraversalSource step method.
303
+ * @param {...Object} args
304
+ * @returns {GraphTraversal}
305
+ */
306
+ mergeV(...args) {
307
+ const b = new Bytecode(this.bytecode).addStep('mergeV', args);
308
+ return new this.graphTraversalClass(this.graph, new TraversalStrategies(this.traversalStrategies), b);
309
+ }
310
+
279
311
  /**
280
312
  * inject GraphTraversalSource step method.
281
313
  * @param {...Object} args
@@ -295,6 +327,16 @@ class GraphTraversalSource {
295
327
  const b = new Bytecode(this.bytecode).addStep('io', args);
296
328
  return new this.graphTraversalClass(this.graph, new TraversalStrategies(this.traversalStrategies), b);
297
329
  }
330
+
331
+ /**
332
+ * call GraphTraversalSource step method.
333
+ * @param {...Object} args
334
+ * @returns {GraphTraversal}
335
+ */
336
+ call(...args) {
337
+ const b = new Bytecode(this.bytecode).addStep('call', args);
338
+ return new this.graphTraversalClass(this.graph, new TraversalStrategies(this.traversalStrategies), b);
339
+ }
298
340
  }
299
341
 
300
342
  /**
@@ -432,6 +474,15 @@ class GraphTraversal extends Traversal {
432
474
  return this;
433
475
  }
434
476
 
477
+ /**
478
+ * Graph traversal call method.
479
+ * @param {...Object} args
480
+ * @returns {GraphTraversal}
481
+ */
482
+ call(...args) {
483
+ this.bytecode.addStep('call', args);
484
+ return this;
485
+ }
435
486
  /**
436
487
  * Graph traversal cap method.
437
488
  * @param {...Object} args
@@ -532,6 +583,15 @@ class GraphTraversal extends Traversal {
532
583
  return this;
533
584
  }
534
585
 
586
+ /**
587
+ * Graph traversal element method.
588
+ * @param {...Object} args
589
+ * @returns {GraphTraversal}
590
+ */
591
+ element(...args) {
592
+ this.bytecode.addStep('element', args);
593
+ return this;
594
+ }
535
595
  /**
536
596
  * Graph traversal elementMap method.
537
597
  * @param {...Object} args
@@ -552,6 +612,16 @@ class GraphTraversal extends Traversal {
552
612
  return this;
553
613
  }
554
614
 
615
+ /**
616
+ * Graph traversal fa method.
617
+ * @param {...Object} args
618
+ * @returns {GraphTraversal}
619
+ */
620
+ fail(...args) {
621
+ this.bytecode.addStep('fail', args);
622
+ return this;
623
+ }
624
+
555
625
  /**
556
626
  * Graph traversal filter method.
557
627
  * @param {...Object} args
@@ -852,6 +922,26 @@ class GraphTraversal extends Traversal {
852
922
  return this;
853
923
  }
854
924
 
925
+ /**
926
+ * Graph traversal mergeE method.
927
+ * @param {...Object} args
928
+ * @returns {GraphTraversal}
929
+ */
930
+ mergeE(...args) {
931
+ this.bytecode.addStep('mergeE', args);
932
+ return this;
933
+ }
934
+
935
+ /**
936
+ * Graph traversal mergeV method.
937
+ * @param {...Object} args
938
+ * @returns {GraphTraversal}
939
+ */
940
+ mergeV(...args) {
941
+ this.bytecode.addStep('mergeV', args);
942
+ return this;
943
+ }
944
+
855
945
  /**
856
946
  * Graph traversal min method.
857
947
  * @param {...Object} args
@@ -1364,6 +1454,7 @@ const statics = {
1364
1454
  bothE: (...args) => callOnEmptyTraversal('bothE', args),
1365
1455
  bothV: (...args) => callOnEmptyTraversal('bothV', args),
1366
1456
  branch: (...args) => callOnEmptyTraversal('branch', args),
1457
+ call: (...args) => callOnEmptyTraversal('call', args),
1367
1458
  cap: (...args) => callOnEmptyTraversal('cap', args),
1368
1459
  choose: (...args) => callOnEmptyTraversal('choose', args),
1369
1460
  coalesce: (...args) => callOnEmptyTraversal('coalesce', args),
@@ -1373,8 +1464,10 @@ const statics = {
1373
1464
  cyclicPath: (...args) => callOnEmptyTraversal('cyclicPath', args),
1374
1465
  dedup: (...args) => callOnEmptyTraversal('dedup', args),
1375
1466
  drop: (...args) => callOnEmptyTraversal('drop', args),
1467
+ element: (...args) => callOnEmptyTraversal('element', args),
1376
1468
  elementMap: (...args) => callOnEmptyTraversal('elementMap', args),
1377
1469
  emit: (...args) => callOnEmptyTraversal('emit', args),
1470
+ fail: (...args) => callOnEmptyTraversal('fail', args),
1378
1471
  filter: (...args) => callOnEmptyTraversal('filter', args),
1379
1472
  flatMap: (...args) => callOnEmptyTraversal('flatMap', args),
1380
1473
  fold: (...args) => callOnEmptyTraversal('fold', args),
@@ -1404,6 +1497,8 @@ const statics = {
1404
1497
  math: (...args) => callOnEmptyTraversal('math', args),
1405
1498
  max: (...args) => callOnEmptyTraversal('max', args),
1406
1499
  mean: (...args) => callOnEmptyTraversal('mean', args),
1500
+ mergeE: (...args) => callOnEmptyTraversal('mergeE', args),
1501
+ mergeV: (...args) => callOnEmptyTraversal('mergeV', args),
1407
1502
  min: (...args) => callOnEmptyTraversal('min', args),
1408
1503
  not: (...args) => callOnEmptyTraversal('not', args),
1409
1504
  optional: (...args) => callOnEmptyTraversal('optional', args),
@@ -295,7 +295,7 @@ class ReservedKeysVerificationStrategy extends TraversalStrategy {
295
295
  * @param {Array<String>} keys the list of reserved keys to verify
296
296
  */
297
297
  constructor(logWarnings = false, throwException = false, keys = ['id', 'label']) {
298
- super('org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy', {
298
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReservedKeysVerificationStrategy', {
299
299
  logWarnings: logWarnings,
300
300
  throwException: throwException,
301
301
  keys: keys,
@@ -303,6 +303,18 @@ class ReservedKeysVerificationStrategy extends TraversalStrategy {
303
303
  }
304
304
  }
305
305
 
306
+ class SeedStrategy extends TraversalStrategy {
307
+ /**
308
+ * @param {Object} [options]
309
+ * @param {number} [options.seed] the seed to provide to the random number generator for the traversal
310
+ */
311
+ constructor(options) {
312
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SeedStrategy', {
313
+ seed: options.seed,
314
+ });
315
+ }
316
+ }
317
+
306
318
  module.exports = {
307
319
  TraversalStrategies: TraversalStrategies,
308
320
  TraversalStrategy: TraversalStrategy,
@@ -312,6 +324,7 @@ module.exports = {
312
324
  HaltedTraverserStrategy: HaltedTraverserStrategy,
313
325
  OptionsStrategy: OptionsStrategy,
314
326
  PartitionStrategy: PartitionStrategy,
327
+ SeedStrategy: SeedStrategy,
315
328
  SubgraphStrategy: SubgraphStrategy,
316
329
  VertexProgramStrategy: VertexProgramStrategy,
317
330
  // finalization
@@ -422,6 +422,16 @@ class TextP {
422
422
  static startingWith(...args) {
423
423
  return createTextP('startingWith', args);
424
424
  }
425
+
426
+ /** @param {...Object} args */
427
+ static regex(...args) {
428
+ return createTextP('regex', args);
429
+ }
430
+
431
+ /** @param {...Object} args */
432
+ static notRegex(...args) {
433
+ return createTextP('notRegex', args);
434
+ }
425
435
  }
426
436
 
427
437
  function createTextP(operator, args) {
@@ -486,9 +496,10 @@ module.exports = {
486
496
  barrier: toEnum('Barrier', 'normSack'),
487
497
  cardinality: toEnum('Cardinality', 'list set single'),
488
498
  column: toEnum('Column', 'keys values'),
489
- direction: toEnum('Direction', 'BOTH IN OUT'),
499
+ direction: toEnum('Direction', 'BOTH IN OUT from_ to'),
490
500
  graphSONVersion: toEnum('GraphSONVersion', 'V1_0 V2_0 V3_0'),
491
501
  gryoVersion: toEnum('GryoVersion', 'V1_0 V3_0'),
502
+ merge: toEnum('Merge', 'onCreate onMatch'),
492
503
  operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
493
504
  order: toEnum('Order', 'asc desc shuffle'),
494
505
  pick: toEnum('Pick', 'any none'),
@@ -0,0 +1,109 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ /**
21
+ * GraphBinary 1.0 support implementation.
22
+ *
23
+ * The officially expected entrypoint is GraphBinaryReader/GraphBinaryWriter pair of classes,
24
+ * examine lib/driver/** for use cases.
25
+ *
26
+ * See AnySerializer.serialize() for the mechanism of serializer selection for a given JavaScript value,
27
+ * also consider AnySerializer.serialize() unit tests for real examples.
28
+ * See NumberSerializationStrategy to understand how it deals with JavaScript numbers' serialization.
29
+ *
30
+ * Consider AnySerializer.serialize()/deserialize() unit tests to see what is not implemented,
31
+ * what is ignored, what is not expected to be (de)serialized, etc.
32
+ *
33
+ * TODO: it has the following open topics:
34
+ * - [] Should we do anything for application/vnd.graphbinary-v1.0-stringd mime type support?
35
+ * Core Data Types support:
36
+ * - [] 0x22: BigDecimal
37
+ * - [] 0x2b: Tree
38
+ * - [] 0x2c: Metrics
39
+ * - [] 0x2d: TraversalMetrics
40
+ * - [] 0x00: Custom
41
+ * Extended Types support:
42
+ * - [] 0x80: Char
43
+ * - [] 0x81: Duration
44
+ * - [] 0x82: InetAddress
45
+ * - [] 0x83: Instant
46
+ * - [] 0x84: LocalDate
47
+ * - [] 0x85: LocalDateTime
48
+ * - [] 0x86: LocalTime
49
+ * - [] 0x87: MonthDay
50
+ * - [] 0x88: OffsetDateTime
51
+ * - [] 0x89: OffsetTime
52
+ * - [] 0x8a: Period
53
+ * - [] 0x8b: Year
54
+ * - [] 0x8c: YearMonth
55
+ * - [] 0x8d: ZonedDateTime
56
+ * - [] 0x8e: ZoneOffset
57
+ *
58
+ * @author Igor Ostapenko
59
+ */
60
+ /*eslint-disable*/
61
+ 'use strict';
62
+
63
+ const ioc = {};
64
+
65
+ ioc.DataType = require('./internals/DataType');
66
+ ioc.utils = require('./internals/utils');
67
+
68
+ ioc.serializers = {};
69
+
70
+ ioc.intSerializer = new (require('./internals/IntSerializer'))(ioc);
71
+ ioc.longSerializer = new (require('./internals/LongSerializer'))(ioc);
72
+ ioc.longSerializerNg = new (require('./internals/LongSerializerNg'))(ioc);
73
+ ioc.stringSerializer = new (require('./internals/StringSerializer'))(ioc, ioc.DataType.STRING);
74
+ ioc.dateSerializer = new (require('./internals/DateSerializer'))(ioc, ioc.DataType.DATE);
75
+ ioc.timestampSerializer = new (require('./internals/DateSerializer'))(ioc, ioc.DataType.TIMESTAMP);
76
+ ioc.classSerializer = new (require('./internals/StringSerializer'))(ioc, ioc.DataType.CLASS);
77
+ ioc.doubleSerializer = new (require('./internals/DoubleSerializer'))(ioc);
78
+ ioc.floatSerializer = new (require('./internals/FloatSerializer'))(ioc);
79
+ ioc.listSerializer = new (require('./internals/ArraySerializer'))(ioc, ioc.DataType.LIST);
80
+ ioc.mapSerializer = new (require('./internals/MapSerializer'))(ioc);
81
+ ioc.setSerializer = new (require('./internals/ArraySerializer'))(ioc, ioc.DataType.SET);
82
+ ioc.uuidSerializer = new (require('./internals/UuidSerializer'))(ioc);
83
+ ioc.edgeSerializer = new (require('./internals/EdgeSerializer'))(ioc);
84
+ ioc.pathSerializer = new (require('./internals/PathSerializer'))(ioc);
85
+ ioc.propertySerializer = new (require('./internals/PropertySerializer'))(ioc);
86
+ ioc.vertexSerializer = new (require('./internals/VertexSerializer'))(ioc);
87
+ ioc.vertexPropertySerializer = new (require('./internals/VertexPropertySerializer'))(ioc);
88
+ ioc.bytecodeSerializer = new (require('./internals/BytecodeSerializer'))(ioc);
89
+ ioc.pSerializer = new (require('./internals/PSerializer'))(ioc);
90
+ ioc.traverserSerializer = new (require('./internals/TraverserSerializer'))(ioc);
91
+ ioc.enumSerializer = new (require('./internals/EnumSerializer'))(ioc);
92
+ ioc.lambdaSerializer = new (require('./internals/LambdaSerializer'))(ioc);
93
+ ioc.bigIntegerSerializer = new (require('./internals/BigIntegerSerializer'))(ioc);
94
+ ioc.byteSerializer = new (require('./internals/ByteSerializer'))(ioc);
95
+ ioc.byteBufferSerializer = new (require('./internals/ByteBufferSerializer'))(ioc);
96
+ ioc.shortSerializer = new (require('./internals/ShortSerializer'))(ioc);
97
+ ioc.booleanSerializer = new (require('./internals/BooleanSerializer'))(ioc);
98
+ ioc.textPSerializer = new (require('./internals/TextPSerializer'))(ioc);
99
+ ioc.traversalStrategySerializer = new (require('./internals/TraversalStrategySerializer'))(ioc);
100
+ ioc.bulkSetSerializer = new (require('./internals/BulkSetSerializer'))(ioc);
101
+ ioc.unspecifiedNullSerializer = new (require('./internals/UnspecifiedNullSerializer'))(ioc);
102
+
103
+ ioc.numberSerializationStrategy = new (require('./internals/NumberSerializationStrategy'))(ioc);
104
+ ioc.anySerializer = new (require('./internals/AnySerializer'))(ioc);
105
+
106
+ ioc.graphBinaryReader = new (require('./internals/GraphBinaryReader.js'))(ioc);
107
+ ioc.graphBinaryWriter = new (require('./internals/GraphBinaryWriter'))(ioc);
108
+
109
+ module.exports = ioc;
@@ -0,0 +1,95 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ /**
21
+ * @author Igor Ostapenko
22
+ */
23
+ 'use strict';
24
+
25
+ module.exports = class AnySerializer {
26
+ constructor(ioc) {
27
+ this.ioc = ioc;
28
+
29
+ // specifically ordered, the first canBeUsedFor=true wins
30
+ this.serializers = [
31
+ ioc.unspecifiedNullSerializer,
32
+
33
+ ioc.numberSerializationStrategy,
34
+
35
+ ioc.booleanSerializer,
36
+ ioc.dateSerializer,
37
+ ioc.bytecodeSerializer,
38
+ ioc.pSerializer,
39
+ ioc.traverserSerializer,
40
+ ioc.enumSerializer,
41
+ ioc.listSerializer,
42
+ ioc.uuidSerializer,
43
+ ioc.edgeSerializer,
44
+ ioc.pathSerializer,
45
+ ioc.propertySerializer,
46
+ ioc.vertexSerializer,
47
+ ioc.vertexPropertySerializer,
48
+ ioc.stringSerializer,
49
+ ioc.textPSerializer,
50
+ ioc.traversalStrategySerializer,
51
+
52
+ ioc.byteBufferSerializer, // Buffer instance
53
+ ioc.lambdaSerializer, // any function
54
+ ioc.mapSerializer, // Map or any Object
55
+ ];
56
+ }
57
+
58
+ getSerializerCanBeUsedFor(item) {
59
+ for (let i = 0; i < this.serializers.length; i++) {
60
+ if (this.serializers[i].canBeUsedFor(item)) {
61
+ return this.serializers[i];
62
+ }
63
+ }
64
+
65
+ throw new Error(
66
+ `No serializer found to support item where typeof(item)='${typeof item}' and String(item)='${String(item)}'.`,
67
+ );
68
+ }
69
+
70
+ serialize(item, fullyQualifiedFormat = true) {
71
+ return this.getSerializerCanBeUsedFor(item).serialize(item, fullyQualifiedFormat);
72
+ }
73
+
74
+ deserialize(buffer) {
75
+ // obviously, fullyQualifiedFormat always is true
76
+ try {
77
+ if (buffer === undefined || buffer === null || !(buffer instanceof Buffer)) {
78
+ throw new Error('buffer is missing');
79
+ }
80
+ if (buffer.length < 1) {
81
+ throw new Error('buffer is empty');
82
+ }
83
+
84
+ const type_code = buffer.readUInt8();
85
+ const serializer = this.ioc.serializers[type_code];
86
+ if (!serializer) {
87
+ throw new Error('unknown {type_code}');
88
+ }
89
+
90
+ return serializer.deserialize(buffer);
91
+ } catch (err) {
92
+ throw this.ioc.utils.des_error({ serializer: this, args: arguments, err });
93
+ }
94
+ }
95
+ };