gremlin 3.5.0 → 3.5.3

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 (91) hide show
  1. package/.eslintrc.js +154 -0
  2. package/.prettierrc.js +29 -0
  3. package/Gruntfile.js +15 -16
  4. package/NOTICE +1 -1
  5. package/doc/AnonymousTraversalSource.html +7 -7
  6. package/doc/Authenticator.html +3 -3
  7. package/doc/Bytecode.html +249 -5
  8. package/doc/Client.html +139 -65
  9. package/doc/Connection.html +90 -6
  10. package/doc/DriverRemoteConnection.html +380 -8
  11. package/doc/EdgeLabelVerificationStrategy.html +3 -3
  12. package/doc/Graph.html +2 -2
  13. package/doc/GraphSON2Reader.html +4 -4
  14. package/doc/GraphSON2Writer.html +3 -3
  15. package/doc/GraphSON3Reader.html +3 -3
  16. package/doc/GraphSON3Writer.html +3 -3
  17. package/doc/GraphTraversal.html +107 -107
  18. package/doc/GraphTraversalSource.html +130 -19
  19. package/doc/HaltedTraverserStrategy.html +3 -3
  20. package/doc/MatchAlgorithmStrategy.html +3 -3
  21. package/doc/P.html +13 -13
  22. package/doc/PartitionStrategy.html +3 -3
  23. package/doc/Path.html +2 -2
  24. package/doc/PlainTextSaslAuthenticator.html +2 -2
  25. package/doc/ProductiveByStrategy.html +288 -0
  26. package/doc/RemoteConnection.html +484 -10
  27. package/doc/RemoteStrategy.html +4 -4
  28. package/doc/RemoteTraversal.html +3 -3
  29. package/doc/ReservedKeysVerificationStrategy.html +3 -3
  30. package/doc/ResponseError.html +3 -3
  31. package/doc/ResultSet.html +8 -8
  32. package/doc/SaslAuthenticator.html +2 -2
  33. package/doc/SaslMechanismBase.html +3 -3
  34. package/doc/SaslMechanismPlain.html +6 -6
  35. package/doc/{GraphSONReader.html → SeedStrategy.html} +12 -15
  36. package/doc/SubgraphStrategy.html +3 -3
  37. package/doc/TextP.html +10 -10
  38. package/doc/Transaction.html +655 -0
  39. package/doc/Translator.html +200 -6
  40. package/doc/TraversalStrategies.html +137 -4
  41. package/doc/TraversalStrategy.html +4 -4
  42. package/doc/TypeSerializer.html +2 -2
  43. package/doc/driver_auth_authenticator.js.html +4 -4
  44. package/doc/driver_auth_mechanisms_sasl-mechanism-base.js.html +3 -3
  45. package/doc/driver_auth_mechanisms_sasl-mechanism-plain.js.html +26 -17
  46. package/doc/driver_auth_plain-text-sasl-authenticator.js.html +7 -7
  47. package/doc/driver_auth_sasl-authenticator.js.html +3 -3
  48. package/doc/driver_client.js.html +75 -25
  49. package/doc/driver_connection.js.html +108 -89
  50. package/doc/driver_driver-remote-connection.js.html +40 -9
  51. package/doc/driver_remote-connection.js.html +47 -6
  52. package/doc/driver_response-error.js.html +5 -4
  53. package/doc/driver_result-set.js.html +4 -4
  54. package/doc/global.html +200 -3
  55. package/doc/index.html +2 -2
  56. package/doc/process_anonymous-traversal.js.html +5 -5
  57. package/doc/process_bytecode.js.html +32 -7
  58. package/doc/process_graph-traversal.js.html +213 -143
  59. package/doc/process_transaction.js.html +143 -0
  60. package/doc/process_translator.js.html +58 -39
  61. package/doc/process_traversal-strategy.js.html +79 -52
  62. package/doc/process_traversal.js.html +101 -108
  63. package/doc/structure_graph.js.html +7 -7
  64. package/doc/structure_io_graph-serializer.js.html +65 -18
  65. package/doc/structure_io_type-serializers.js.html +86 -89
  66. package/index.js +5 -5
  67. package/lib/driver/auth/authenticator.js +2 -2
  68. package/lib/driver/auth/mechanisms/sasl-mechanism-base.js +1 -1
  69. package/lib/driver/auth/mechanisms/sasl-mechanism-plain.js +24 -15
  70. package/lib/driver/auth/plain-text-sasl-authenticator.js +5 -5
  71. package/lib/driver/auth/sasl-authenticator.js +1 -1
  72. package/lib/driver/client.js +73 -23
  73. package/lib/driver/connection.js +106 -87
  74. package/lib/driver/driver-remote-connection.js +38 -7
  75. package/lib/driver/remote-connection.js +45 -4
  76. package/lib/driver/response-error.js +2 -2
  77. package/lib/driver/result-set.js +1 -2
  78. package/lib/process/anonymous-traversal.js +2 -3
  79. package/lib/process/bytecode.js +30 -5
  80. package/lib/process/graph-traversal.js +210 -141
  81. package/lib/process/transaction.js +92 -0
  82. package/lib/process/translator.js +55 -37
  83. package/lib/process/traversal-strategy.js +76 -50
  84. package/lib/process/traversal.js +99 -106
  85. package/lib/structure/graph.js +5 -5
  86. package/lib/structure/io/graph-serializer.js +62 -16
  87. package/lib/structure/io/type-serializers.js +84 -87
  88. package/lib/utils.js +15 -10
  89. package/package.json +11 -5
  90. package/doc/GraphSONWriter.html +0 -436
  91. package/gremlin-javascript.iml +0 -9
@@ -0,0 +1,143 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: process/transaction.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: process/transaction.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>/*
30
+ * Licensed to the Apache Software Foundation (ASF) under one
31
+ * or more contributor license agreements. See the NOTICE file
32
+ * distributed with this work for additional information
33
+ * regarding copyright ownership. The ASF licenses this file
34
+ * to you under the Apache License, Version 2.0 (the
35
+ * "License"); you may not use this file except in compliance
36
+ * with the License. You may obtain a copy of the License at
37
+ *
38
+ * http://www.apache.org/licenses/LICENSE-2.0
39
+ *
40
+ * Unless required by applicable law or agreed to in writing,
41
+ * software distributed under the License is distributed on an
42
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
43
+ * KIND, either express or implied. See the License for the
44
+ * specific language governing permissions and limitations
45
+ * under the License.
46
+ */
47
+ 'use strict';
48
+
49
+ const remote = require('../driver/remote-connection');
50
+ const Bytecode = require('./bytecode');
51
+ const { TraversalStrategies } = require('./traversal-strategy');
52
+
53
+ /**
54
+ * A controller for a remote transaction that is constructed from &lt;code>g.tx()&lt;/code>. Calling &lt;code>begin()&lt;/code>
55
+ * on this object will produce a new &lt;code>GraphTraversalSource&lt;/code> that is bound to a remote transaction over which
56
+ * multiple traversals may be executed in that context. Calling &lt;code>commit()&lt;/code> or &lt;code>rollback()&lt;/code> will
57
+ * then close the transaction and thus, the session. This feature only works with transaction enabled graphs.
58
+ */
59
+ class Transaction {
60
+ constructor(g) {
61
+ this._g = g;
62
+ this._sessionBasedConnection = undefined;
63
+ }
64
+
65
+ /**
66
+ * Spawns a &lt;code>GraphTraversalSource&lt;/code> that is bound to a remote session which enables a transaction.
67
+ * @returns {*}
68
+ */
69
+ begin() {
70
+ if (this._sessionBasedConnection) {
71
+ throw new Error('Transaction already started on this object');
72
+ }
73
+
74
+ this._sessionBasedConnection = this._g.remoteConnection.createSession();
75
+ const traversalStrategy = new TraversalStrategies();
76
+ traversalStrategy.addStrategy(new remote.RemoteStrategy(this._sessionBasedConnection));
77
+ return new this._g.graphTraversalSourceClass(
78
+ this._g.graph,
79
+ traversalStrategy,
80
+ new Bytecode(this._g.bytecode),
81
+ this._g.graphTraversalSourceClass,
82
+ this._g.graphTraversalClass,
83
+ );
84
+ }
85
+
86
+ /**
87
+ * @returns {Promise}
88
+ */
89
+ commit() {
90
+ return this._sessionBasedConnection.commit().then(() => this.close());
91
+ }
92
+
93
+ /**
94
+ * @returns {Promise}
95
+ */
96
+ rollback() {
97
+ return this._sessionBasedConnection.rollback().then(() => this.close());
98
+ }
99
+
100
+ /**
101
+ * Returns true if transaction is open.
102
+ * @returns {Boolean}
103
+ */
104
+ get isOpen() {
105
+ return this._sessionBasedConnection.isOpen;
106
+ }
107
+
108
+ /**
109
+ * @returns {Promise}
110
+ */
111
+ close() {
112
+ if (this._sessionBasedConnection) {
113
+ this._sessionBasedConnection.close();
114
+ }
115
+ }
116
+ }
117
+
118
+ module.exports = {
119
+ Transaction,
120
+ };
121
+ </code></pre>
122
+ </article>
123
+ </section>
124
+
125
+
126
+
127
+
128
+ </div>
129
+
130
+ <nav>
131
+ <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>
132
+ </nav>
133
+
134
+ <br class="clear">
135
+
136
+ <footer>
137
+ 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)
138
+ </footer>
139
+
140
+ <script> prettyPrint(); </script>
141
+ <script src="scripts/linenumber.js"> </script>
142
+ </body>
143
+ </html>
@@ -47,6 +47,7 @@
47
47
  'use strict';
48
48
 
49
49
  const Traversal = require('./traversal').Traversal;
50
+ const Bytecode = require('./bytecode');
50
51
 
51
52
  /**
52
53
  * Class to translate glv bytecode steps into executable Gremlin-Groovy script
@@ -61,7 +62,7 @@ class Translator {
61
62
  }
62
63
 
63
64
  getTargetLanguage() {
64
- return "gremlin-groovy";
65
+ return 'gremlin-groovy';
65
66
  }
66
67
 
67
68
  of(traversalSource) {
@@ -70,12 +71,15 @@ class Translator {
70
71
 
71
72
  /**
72
73
  * Returns a script representation of the given bytecode instructions.
73
- * @param {Object} bytecode The bytecode object containing step instructions.
74
+ * @param {Object} bytecodeOrTraversal The traversal or bytecode of a traversal containing step instructions.
75
+ * @param {boolean} child Determines if a traversal object should be treated as an anonymous child or if it is a spawn from "g"
74
76
  * @returns {string} Gremlin-Groovy script
75
77
  */
76
- translate(bytecode, child = false) {
77
- let script = child ? "__" : this._traversalSource;
78
- let instructions = bytecode.stepInstructions;
78
+ translate(bytecodeOrTraversal, child = false) {
79
+ let script = child ? '__' : this._traversalSource;
80
+ const bc = bytecodeOrTraversal instanceof Bytecode ? bytecodeOrTraversal : bytecodeOrTraversal.getBytecode();
81
+
82
+ const instructions = bc.stepInstructions;
79
83
 
80
84
  // build the script from the glv instructions.
81
85
  for (let i = 0; i &lt; instructions.length; i++) {
@@ -88,47 +92,62 @@ class Translator {
88
92
  script += ', ';
89
93
  }
90
94
 
91
- if (Object(params[k]) === params[k]) {
92
- if (params[k] instanceof Traversal) {
93
- script += this.translate(params[k].getBytecode(), true);
94
- } else if (params[k].toString() === '[object Object]') {
95
- Object.keys(params[k]).forEach(function (key, index) {
96
- if (index > 0) script += ', ';
97
- script += '(\'' + key + '\', ';
98
- if (params[k][key] instanceof String || typeof params[k][key] === 'string') {
99
- script += '\'' + params[k][key] + '\'';
100
- } else {
101
- script += params[k][key];
102
- }
103
- script += ')';
104
- });
105
- } else if (Array.isArray(params[k])) {
106
- const parts = [];
107
- for (const param of params[k]) {
108
- parts.push(translate(param.getBytecode(), true));
109
- }
110
- script += parts.join(",");
111
- } else {
112
- script += params[k].toString();
113
- }
114
- } else if (params[k] === undefined) {
115
- script += '';
116
- } else if (typeof params[k] === 'number' || typeof params[k] === 'boolean') {
117
- script += params[k];
118
- } else {
119
- script += '\'' + params[k] + '\'';
120
- }
95
+ script += this.convert(params[k]);
121
96
  }
122
97
  }
123
98
 
124
99
  script += ')';
125
100
  }
126
-
101
+
102
+ return script;
103
+ }
104
+
105
+ /**
106
+ * Converts an object to a Gremlin script representation.
107
+ * @param {Object} anyObject The object to convert to a script representation
108
+ * @returns {string} The Gremlin script representation
109
+ */
110
+ convert(anyObject) {
111
+ let script = '';
112
+ if (Object(anyObject) === anyObject) {
113
+ if (anyObject instanceof Traversal) {
114
+ script += this.translate(anyObject.getBytecode(), true);
115
+ } else if (anyObject.toString() === '[object Object]') {
116
+ Object.keys(anyObject).forEach(function (key, index) {
117
+ if (index > 0) {
118
+ script += ', ';
119
+ }
120
+ script += `('${key}', `;
121
+ if (anyObject[key] instanceof String || typeof anyObject[key] === 'string') {
122
+ script += `'${anyObject[key]}'`;
123
+ } else {
124
+ script += anyObject[key];
125
+ }
126
+ script += ')';
127
+ });
128
+ } else if (Array.isArray(anyObject)) {
129
+ const parts = [];
130
+ for (const item of anyObject) {
131
+ parts.push(this.convert(item));
132
+ }
133
+ script += '[' + parts.join(', ') + ']';
134
+ } else {
135
+ script += anyObject.toString();
136
+ }
137
+ } else if (anyObject === undefined) {
138
+ script += '';
139
+ } else if (typeof anyObject === 'number' || typeof anyObject === 'boolean') {
140
+ script += anyObject;
141
+ } else {
142
+ script += `'${anyObject}'`;
143
+ }
144
+
127
145
  return script;
128
146
  }
129
147
  }
130
148
 
131
- module.exports = Translator;</code></pre>
149
+ module.exports = Translator;
150
+ </code></pre>
132
151
  </article>
133
152
  </section>
134
153
 
@@ -138,13 +157,13 @@ module.exports = Translator;</code></pre>
138
157
  </div>
139
158
 
140
159
  <nav>
141
- <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="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="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>
160
+ <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>
142
161
  </nav>
143
162
 
144
163
  <br class="clear">
145
164
 
146
165
  <footer>
147
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.5</a> on Mon May 10 2021 08:06:59 GMT-0400 (Eastern Daylight Time)
166
+ 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)
148
167
  </footer>
149
168
 
150
169
  <script> prettyPrint(); </script>
@@ -62,8 +62,7 @@ class TraversalStrategies {
62
62
  if (parent) {
63
63
  // Clone the strategies
64
64
  this.strategies = [...parent.strategies];
65
- }
66
- else {
65
+ } else {
67
66
  this.strategies = [];
68
67
  }
69
68
  }
@@ -73,21 +72,31 @@ class TraversalStrategies {
73
72
  this.strategies.push(strategy);
74
73
  }
75
74
 
75
+ /** @param {TraversalStrategy} strategy */
76
+ removeStrategy(strategy) {
77
+ const idx = this.strategies.findIndex((s) => s.fqcn === strategy.fqcn);
78
+ if (idx !== -1) {
79
+ return this.strategies.splice(idx, 1)[0];
80
+ }
81
+
82
+ return undefined;
83
+ }
84
+
76
85
  /**
77
86
  * @param {Traversal} traversal
78
87
  * @returns {Promise}
79
88
  */
80
89
  applyStrategies(traversal) {
81
90
  // Apply all strategies serially
82
- return this.strategies.reduce((promise, strategy) => {
83
- return promise.then(() => strategy.apply(traversal));
84
- }, Promise.resolve());
91
+ return this.strategies.reduce(
92
+ (promise, strategy) => promise.then(() => strategy.apply(traversal)),
93
+ Promise.resolve(),
94
+ );
85
95
  }
86
96
  }
87
97
 
88
98
  /** @abstract */
89
99
  class TraversalStrategy {
90
-
91
100
  /**
92
101
  * @param {String} fqcn fully qualified class name in Java of the strategy
93
102
  * @param {Object} configuration for the strategy
@@ -102,38 +111,36 @@ class TraversalStrategy {
102
111
  * @param {Traversal} traversal
103
112
  * @returns {Promise}
104
113
  */
105
- apply(traversal) {
106
-
107
- }
114
+ apply(traversal) {}
108
115
  }
109
116
 
110
117
  class ConnectiveStrategy extends TraversalStrategy {
111
118
  constructor() {
112
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ConnectiveStrategy");
119
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ConnectiveStrategy');
113
120
  }
114
121
  }
115
122
 
116
123
  class ElementIdStrategy extends TraversalStrategy {
117
124
  constructor() {
118
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategy");
125
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategy');
119
126
  }
120
127
  }
121
128
 
122
129
  class HaltedTraverserStrategy extends TraversalStrategy {
123
-
124
130
  /**
125
131
  * @param {String} haltedTraverserFactory full qualified class name in Java of a {@code HaltedTraverserFactory} implementation
126
132
  */
127
133
  constructor(haltedTraverserFactory) {
128
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy");
129
- if (haltedTraverserFactory !== undefined)
130
- this.configuration["haltedTraverserFactory"] = haltedTraverserFactory;
134
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy');
135
+ if (haltedTraverserFactory !== undefined) {
136
+ this.configuration['haltedTraverserFactory'] = haltedTraverserFactory;
137
+ }
131
138
  }
132
139
  }
133
140
 
134
141
  class OptionsStrategy extends TraversalStrategy {
135
142
  constructor(options) {
136
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy", options);
143
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy', options);
137
144
  }
138
145
  }
139
146
 
@@ -146,7 +153,7 @@ class PartitionStrategy extends TraversalStrategy {
146
153
  * @param {boolean} [options.includeMetaProperties] determines if meta-properties should be included in partitioning defaulting to false
147
154
  */
148
155
  constructor(options) {
149
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy", options);
156
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy', options);
150
157
  }
151
158
  }
152
159
 
@@ -159,20 +166,32 @@ class SubgraphStrategy extends TraversalStrategy {
159
166
  * @param {boolean} [options.checkAdjacentVertices] enables the strategy to apply the {@code vertices} filter to the adjacent vertices of an edge.
160
167
  */
161
168
  constructor(options) {
162
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy", options);
163
- if (this.configuration.vertices instanceof Traversal)
169
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy', options);
170
+ if (this.configuration.vertices instanceof Traversal) {
164
171
  this.configuration.vertices = this.configuration.vertices.bytecode;
165
- if (this.configuration.edges instanceof Traversal)
172
+ }
173
+ if (this.configuration.edges instanceof Traversal) {
166
174
  this.configuration.edges = this.configuration.edges.bytecode;
167
- if (this.configuration.vertexProperties instanceof Traversal)
175
+ }
176
+ if (this.configuration.vertexProperties instanceof Traversal) {
168
177
  this.configuration.vertexProperties = this.configuration.vertexProperties.bytecode;
178
+ }
169
179
  }
170
180
  }
171
181
 
172
- class VertexProgramStrategy extends TraversalStrategy {
182
+ class ProductiveByStrategy extends TraversalStrategy {
183
+ /**
184
+ * @param {Object} [options]
185
+ * @param {Array&lt;String>} [options.productiveKeys] set of keys that will always be productive
186
+ */
187
+ constructor(options) {
188
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.ProductiveByStrategy', options);
189
+ }
190
+ }
173
191
 
192
+ class VertexProgramStrategy extends TraversalStrategy {
174
193
  constructor(options) {
175
- super("org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy", options);
194
+ super('org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy', options);
176
195
  }
177
196
  }
178
197
 
@@ -181,105 +200,106 @@ class MatchAlgorithmStrategy extends TraversalStrategy {
181
200
  * @param matchAlgorithm
182
201
  */
183
202
  constructor(matchAlgorithm) {
184
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.MatchAlgorithmStrategy");
185
- if (matchAlgorithm !== undefined)
186
- this.configuration["matchAlgorithm"] = matchAlgorithm;
203
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.MatchAlgorithmStrategy');
204
+ if (matchAlgorithm !== undefined) {
205
+ this.configuration['matchAlgorithm'] = matchAlgorithm;
206
+ }
187
207
  }
188
208
  }
189
209
 
190
210
  class AdjacentToIncidentStrategy extends TraversalStrategy {
191
211
  constructor() {
192
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.AdjacentToIncidentStrategy");
212
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.AdjacentToIncidentStrategy');
193
213
  }
194
214
  }
195
215
 
196
216
  class FilterRankingStrategy extends TraversalStrategy {
197
217
  constructor() {
198
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.FilterRankingStrategy");
218
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.FilterRankingStrategy');
199
219
  }
200
220
  }
201
221
 
202
222
  class IdentityRemovalStrategy extends TraversalStrategy {
203
223
  constructor() {
204
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IdentityRemovalStrategy");
224
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IdentityRemovalStrategy');
205
225
  }
206
226
  }
207
227
 
208
228
  class IncidentToAdjacentStrategy extends TraversalStrategy {
209
229
  constructor() {
210
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IncidentToAdjacentStrategy");
230
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IncidentToAdjacentStrategy');
211
231
  }
212
232
  }
213
233
 
214
234
  class InlineFilterStrategy extends TraversalStrategy {
215
235
  constructor() {
216
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.InlineFilterStrategy");
236
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.InlineFilterStrategy');
217
237
  }
218
238
  }
219
239
 
220
240
  class LazyBarrierStrategy extends TraversalStrategy {
221
241
  constructor() {
222
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy");
242
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy');
223
243
  }
224
244
  }
225
245
 
226
246
  class MatchPredicateStrategy extends TraversalStrategy {
227
247
  constructor() {
228
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.MatchPredicateStrategy");
248
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.MatchPredicateStrategy');
229
249
  }
230
250
  }
231
251
 
232
252
  class OrderLimitStrategy extends TraversalStrategy {
233
253
  constructor() {
234
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.OrderLimitStrategy");
254
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.OrderLimitStrategy');
235
255
  }
236
256
  }
237
257
 
238
258
  class PathProcessorStrategy extends TraversalStrategy {
239
259
  constructor() {
240
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy");
260
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy');
241
261
  }
242
262
  }
243
263
 
244
264
  class PathRetractionStrategy extends TraversalStrategy {
245
265
  constructor() {
246
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathRetractionStrategy");
266
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathRetractionStrategy');
247
267
  }
248
268
  }
249
269
 
250
270
  class CountStrategy extends TraversalStrategy {
251
271
  constructor() {
252
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy");
272
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy');
253
273
  }
254
274
  }
255
275
 
256
276
  class RepeatUnrollStrategy extends TraversalStrategy {
257
277
  constructor() {
258
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy");
278
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy');
259
279
  }
260
280
  }
261
281
 
262
282
  class GraphFilterStrategy extends TraversalStrategy {
263
283
  constructor() {
264
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.GraphFilterStrategy");
284
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.GraphFilterStrategy');
265
285
  }
266
286
  }
267
287
 
268
288
  class EarlyLimitStrategy extends TraversalStrategy {
269
289
  constructor() {
270
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.EarlyLimitStrategy");
290
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.EarlyLimitStrategy');
271
291
  }
272
292
  }
273
293
 
274
294
  class LambdaRestrictionStrategy extends TraversalStrategy {
275
295
  constructor() {
276
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.LambdaRestrictionStrategy");
296
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.LambdaRestrictionStrategy');
277
297
  }
278
298
  }
279
299
 
280
300
  class ReadOnlyStrategy extends TraversalStrategy {
281
301
  constructor() {
282
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy");
302
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy');
283
303
  }
284
304
  }
285
305
 
@@ -288,9 +308,11 @@ class EdgeLabelVerificationStrategy extends TraversalStrategy {
288
308
  * @param {boolean} logWarnings determines if warnings should be written to the logger when verification fails
289
309
  * @param {boolean} throwException determines if exceptions should be thrown when verifications fails
290
310
  */
291
- constructor(logWarnings = false, throwException=false) {
292
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy",
293
- {logWarnings: logWarnings, throwException: throwException});
311
+ constructor(logWarnings = false, throwException = false) {
312
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy', {
313
+ logWarnings: logWarnings,
314
+ throwException: throwException,
315
+ });
294
316
  }
295
317
  }
296
318
 
@@ -300,9 +322,12 @@ class ReservedKeysVerificationStrategy extends TraversalStrategy {
300
322
  * @param {boolean} throwException determines if exceptions should be thrown when verifications fails
301
323
  * @param {Array&lt;String>} keys the list of reserved keys to verify
302
324
  */
303
- constructor(logWarnings = false, throwException=false, keys=["id", "label"]) {
304
- super("org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy",
305
- {logWarnings: logWarnings, throwException: throwException, keys: keys});
325
+ constructor(logWarnings = false, throwException = false, keys = ['id', 'label']) {
326
+ super('org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy', {
327
+ logWarnings: logWarnings,
328
+ throwException: throwException,
329
+ keys: keys,
330
+ });
306
331
  }
307
332
  }
308
333
 
@@ -330,6 +355,7 @@ module.exports = {
330
355
  OrderLimitStrategy: OrderLimitStrategy,
331
356
  PathProcessorStrategy: PathProcessorStrategy,
332
357
  PathRetractionStrategy: PathRetractionStrategy,
358
+ ProductiveByStrategy: ProductiveByStrategy,
333
359
  CountStrategy: CountStrategy,
334
360
  RepeatUnrollStrategy: RepeatUnrollStrategy,
335
361
  GraphFilterStrategy: GraphFilterStrategy,
@@ -338,8 +364,9 @@ module.exports = {
338
364
  EdgeLabelVerificationStrategy: EdgeLabelVerificationStrategy,
339
365
  LambdaRestrictionStrategy: LambdaRestrictionStrategy,
340
366
  ReadOnlyStrategy: ReadOnlyStrategy,
341
- ReservedKeysVerificationStrategy: ReservedKeysVerificationStrategy
342
- };</code></pre>
367
+ ReservedKeysVerificationStrategy: ReservedKeysVerificationStrategy,
368
+ };
369
+ </code></pre>
343
370
  </article>
344
371
  </section>
345
372
 
@@ -349,13 +376,13 @@ module.exports = {
349
376
  </div>
350
377
 
351
378
  <nav>
352
- <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="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="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>
379
+ <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>
353
380
  </nav>
354
381
 
355
382
  <br class="clear">
356
383
 
357
384
  <footer>
358
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.5</a> on Mon May 10 2021 08:06:59 GMT-0400 (Eastern Daylight Time)
385
+ 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)
359
386
  </footer>
360
387
 
361
388
  <script> prettyPrint(); </script>