gremlin 3.5.4 → 3.5.6

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 (72) hide show
  1. package/NOTICE +1 -1
  2. package/doc/AnonymousTraversalSource.html +1 -1
  3. package/doc/Authenticator.html +1 -1
  4. package/doc/Bytecode.html +1 -1
  5. package/doc/Client.html +173 -8
  6. package/doc/Connection.html +40 -7
  7. package/doc/DriverRemoteConnection.html +143 -11
  8. package/doc/EdgeLabelVerificationStrategy.html +1 -1
  9. package/doc/Graph.html +1 -1
  10. package/doc/GraphSON2Reader.html +1 -1
  11. package/doc/GraphSON2Writer.html +1 -1
  12. package/doc/GraphSON3Reader.html +1 -1
  13. package/doc/GraphSON3Writer.html +1 -1
  14. package/doc/GraphTraversal.html +1 -1
  15. package/doc/GraphTraversalSource.html +1 -1
  16. package/doc/HaltedTraverserStrategy.html +1 -1
  17. package/doc/MatchAlgorithmStrategy.html +1 -1
  18. package/doc/P.html +1 -1
  19. package/doc/PartitionStrategy.html +1 -1
  20. package/doc/Path.html +1 -1
  21. package/doc/PlainTextSaslAuthenticator.html +1 -1
  22. package/doc/ProductiveByStrategy.html +1 -1
  23. package/doc/RemoteConnection.html +1 -1
  24. package/doc/RemoteStrategy.html +1 -1
  25. package/doc/RemoteTraversal.html +1 -1
  26. package/doc/ReservedKeysVerificationStrategy.html +1 -1
  27. package/doc/ResponseError.html +1 -1
  28. package/doc/ResultSet.html +1 -1
  29. package/doc/SaslAuthenticator.html +1 -1
  30. package/doc/SaslMechanismBase.html +1 -1
  31. package/doc/SaslMechanismPlain.html +1 -1
  32. package/doc/SeedStrategy.html +1 -1
  33. package/doc/SubgraphStrategy.html +1 -1
  34. package/doc/TextP.html +1 -1
  35. package/doc/Transaction.html +1 -1
  36. package/doc/Translator.html +1 -1
  37. package/doc/TraversalStrategies.html +1 -1
  38. package/doc/TraversalStrategy.html +1 -1
  39. package/doc/TypeSerializer.html +1 -1
  40. package/doc/driver_auth_authenticator.js.html +1 -1
  41. package/doc/driver_auth_mechanisms_sasl-mechanism-base.js.html +1 -1
  42. package/doc/driver_auth_mechanisms_sasl-mechanism-plain.js.html +1 -1
  43. package/doc/driver_auth_plain-text-sasl-authenticator.js.html +1 -1
  44. package/doc/driver_auth_sasl-authenticator.js.html +1 -1
  45. package/doc/driver_client.js.html +6 -1
  46. package/doc/driver_connection.js.html +18 -5
  47. package/doc/driver_driver-remote-connection.js.html +5 -1
  48. package/doc/driver_remote-connection.js.html +1 -1
  49. package/doc/driver_response-error.js.html +1 -1
  50. package/doc/driver_result-set.js.html +1 -1
  51. package/doc/global.html +2 -2
  52. package/doc/index.html +1 -1
  53. package/doc/module.exports.html +1 -1
  54. package/doc/process_anonymous-traversal.js.html +1 -1
  55. package/doc/process_bytecode.js.html +1 -1
  56. package/doc/process_graph-traversal.js.html +1 -1
  57. package/doc/process_transaction.js.html +1 -1
  58. package/doc/process_translator.js.html +1 -1
  59. package/doc/process_traversal-strategy.js.html +1 -1
  60. package/doc/process_traversal.js.html +1 -1
  61. package/doc/structure_graph.js.html +1 -1
  62. package/doc/structure_io_binary_internals_DataType.js.html +1 -1
  63. package/doc/structure_io_binary_internals_GraphBinaryReader.js.html +1 -1
  64. package/doc/structure_io_binary_internals_GraphBinaryWriter.js.html +1 -1
  65. package/doc/structure_io_graph-serializer.js.html +1 -1
  66. package/doc/structure_io_type-serializers.js.html +1 -1
  67. package/docker-compose.yml +62 -0
  68. package/lib/driver/client.js +5 -0
  69. package/lib/driver/connection.js +17 -4
  70. package/lib/driver/driver-remote-connection.js +4 -0
  71. package/lib/utils.js +43 -0
  72. package/package.json +9 -5
@@ -540,7 +540,7 @@ module.exports = {
540
540
  <br class="clear">
541
541
 
542
542
  <footer>
543
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue Jul 26 2022 15:51:52 GMT-0400 (Eastern Daylight Time)
543
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri May 05 2023 12:08:53 GMT-0700 (Pacific Daylight Time)
544
544
  </footer>
545
545
 
546
546
  <script> prettyPrint(); </script>
@@ -232,7 +232,7 @@ module.exports = {
232
232
  <br class="clear">
233
233
 
234
234
  <footer>
235
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue Jul 26 2022 15:51:52 GMT-0400 (Eastern Daylight Time)
235
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri May 05 2023 12:08:53 GMT-0700 (Pacific Daylight Time)
236
236
  </footer>
237
237
 
238
238
  <script> prettyPrint(); </script>
@@ -139,7 +139,7 @@ module.exports = DataType;
139
139
  <br class="clear">
140
140
 
141
141
  <footer>
142
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue Jul 26 2022 15:51:52 GMT-0400 (Eastern Daylight Time)
142
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri May 05 2023 12:08:53 GMT-0700 (Pacific Daylight Time)
143
143
  </footer>
144
144
 
145
145
  <script> prettyPrint(); </script>
@@ -122,7 +122,7 @@ module.exports = class GraphBinaryReader {
122
122
  <br class="clear">
123
123
 
124
124
  <footer>
125
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue Jul 26 2022 15:51:52 GMT-0400 (Eastern Daylight Time)
125
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri May 05 2023 12:08:53 GMT-0700 (Pacific Daylight Time)
126
126
  </footer>
127
127
 
128
128
  <script> prettyPrint(); </script>
@@ -125,7 +125,7 @@ module.exports = class GraphBinaryWriter {
125
125
  <br class="clear">
126
126
 
127
127
  <footer>
128
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue Jul 26 2022 15:51:52 GMT-0400 (Eastern Daylight Time)
128
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri May 05 2023 12:08:53 GMT-0700 (Pacific Daylight Time)
129
129
  </footer>
130
130
 
131
131
  <script> prettyPrint(); </script>
@@ -342,7 +342,7 @@ module.exports = {
342
342
  <br class="clear">
343
343
 
344
344
  <footer>
345
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue Jul 26 2022 15:51:52 GMT-0400 (Eastern Daylight Time)
345
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri May 05 2023 12:08:53 GMT-0700 (Pacific Daylight Time)
346
346
  </footer>
347
347
 
348
348
  <script> prettyPrint(); </script>
@@ -546,7 +546,7 @@ module.exports = {
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 Tue Jul 26 2022 15:51:52 GMT-0400 (Eastern Daylight Time)
549
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri May 05 2023 12:08:53 GMT-0700 (Pacific Daylight Time)
550
550
  </footer>
551
551
 
552
552
  <script> prettyPrint(); </script>
@@ -0,0 +1,62 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ version: "3.8"
19
+
20
+ services:
21
+
22
+ gremlin-server-test-js:
23
+ container_name: gremlin-server-test-js
24
+ image: tinkerpop/gremlin-server-test:${GREMLIN_SERVER}
25
+ build:
26
+ context: ../../../../../
27
+ dockerfile: docker/gremlin-test-server/Dockerfile
28
+ args:
29
+ - GREMLIN_SERVER=${GREMLIN_SERVER}
30
+ ports:
31
+ - "45940:45940"
32
+ - "45941:45941"
33
+ - "45942:45942"
34
+ - "4588:4588"
35
+ volumes:
36
+ - ${HOME}/.groovy:/root/.groovy
37
+ - ${HOME}/.m2:/root/.m2
38
+ - ${ABS_PROJECT_HOME}/gremlin-test/target:/opt/gremlin-test
39
+ healthcheck:
40
+ test: [ "CMD-SHELL", "apk add curl && curl -f http://localhost:45940?gremlin=100-1" ]
41
+ interval: 30s
42
+ timeout: 10s
43
+ retries: 30
44
+ start_period: 30s
45
+
46
+ gremlin-js-integration-tests:
47
+ container_name: gremlin-js-integration-tests
48
+ image: node:16
49
+ volumes:
50
+ - .:/js_app
51
+ - ../../../../../gremlin-test/features:/gremlin-test
52
+ - ../../../../../docker/gremlin-test-server:/js_app/gremlin-test-server
53
+ environment:
54
+ - DOCKER_ENVIRONMENT=true
55
+ - TEST_TRANSACTIONS=true
56
+ working_dir: /js_app
57
+ command: >
58
+ bash -c "npm config set cache /tmp --global
59
+ && npm ci && npm run test && npm run features-docker"
60
+ depends_on:
61
+ gremlin-server-test-js:
62
+ condition: service_healthy
@@ -39,8 +39,13 @@ class Client {
39
39
  * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
40
40
  * @param {GraphSONWriter} [options.writer] The writer to use.
41
41
  * @param {Authenticator} [options.authenticator] The authentication handler to use.
42
+ * @param {Object} [options.headers] An associative array containing the additional header key/values for the initial request.
43
+ * @param {Boolean} [options.enableUserAgentOnConnect] Determines if a user agent will be sent during connection handshake. Defaults to: true
42
44
  * @param {String} [options.processor] The name of the opProcessor to use, leave it undefined or set 'session' when session mode.
43
45
  * @param {String} [options.session] The sessionId of Client in session mode. Defaults to null means session-less Client.
46
+ * @param {Boolean} [options.pingEnabled] Setup ping interval. Defaults to: true.
47
+ * @param {Number} [options.pingInterval] Ping request interval in ms if ping enabled. Defaults to: 60000.
48
+ * @param {Number} [options.pongTimeout] Timeout of pong response in ms after sending a ping. Defaults to: 30000.
44
49
  * @constructor
45
50
  */
46
51
  constructor(url, options = {}) {
@@ -64,6 +64,7 @@ class Connection extends EventEmitter {
64
64
  * @param {GraphSONWriter} [options.writer] The writer to use.
65
65
  * @param {Authenticator} [options.authenticator] The authentication handler to use.
66
66
  * @param {Object} [options.headers] An associative array containing the additional header key/values for the initial request.
67
+ * @param {Boolean} [options.enableUserAgentOnConnect] Determines if a user agent will be sent during connection handshake. Defaults to: true
67
68
  * @param {Boolean} [options.pingEnabled] Setup ping interval. Defaults to: true.
68
69
  * @param {Number} [options.pingInterval] Ping request interval in ms if ping enabled. Defaults to: 60000.
69
70
  * @param {Number} [options.pongTimeout] Timeout of pong response in ms after sending a ping. Defaults to: 30000.
@@ -82,7 +83,7 @@ class Connection extends EventEmitter {
82
83
  */
83
84
  this.mimeType = options.mimeType || defaultMimeType;
84
85
 
85
- // A map containing the request id and the handler
86
+ // A map containing the request id and the handler. The id should be in lower case to prevent string comparison issues.
86
87
  this._responseHandlers = {};
87
88
  this._reader = options.reader || this._getDefaultReader(this.mimeType);
88
89
  this._writer = options.writer || this._getDefaultWriter(this.mimeType);
@@ -98,6 +99,7 @@ class Connection extends EventEmitter {
98
99
  this.isOpen = false;
99
100
  this.traversalSource = options.traversalSource || 'g';
100
101
  this._authenticator = options.authenticator;
102
+ this._enableUserAgentOnConnect = options.enableUserAgentOnConnect !== false;
101
103
 
102
104
  this._pingEnabled = this.options.pingEnabled === false ? false : true;
103
105
  this._pingIntervalDelay = this.options.pingInterval || pingIntervalDelay;
@@ -123,9 +125,16 @@ class Connection extends EventEmitter {
123
125
  }
124
126
 
125
127
  this.emit('log', 'ws open');
128
+ let headers = this.options.headers;
129
+ if (this._enableUserAgentOnConnect) {
130
+ if (!headers) {
131
+ headers = [];
132
+ }
133
+ headers[utils.getUserAgentHeader()] = utils.getUserAgent();
134
+ }
126
135
 
127
136
  this._ws = new WebSocket(this.url, {
128
- headers: this.options.headers,
137
+ headers: headers,
129
138
  ca: this.options.ca,
130
139
  cert: this.options.cert,
131
140
  pfx: this.options.pfx,
@@ -164,7 +173,8 @@ class Connection extends EventEmitter {
164
173
 
165
174
  /** @override */
166
175
  submit(processor, op, args, requestId) {
167
- const rid = requestId || utils.getUuid();
176
+ // TINKERPOP-2847: Use lower case to prevent string comparison issues.
177
+ const rid = (requestId || utils.getUuid()).toLowerCase();
168
178
  return this.open().then(
169
179
  () =>
170
180
  new Promise((resolve, reject) => {
@@ -192,7 +202,8 @@ class Connection extends EventEmitter {
192
202
 
193
203
  /** @override */
194
204
  stream(processor, op, args, requestId) {
195
- const rid = requestId || utils.getUuid();
205
+ // TINKERPOP-2847: Use lower case to prevent string comparison issues.
206
+ const rid = (requestId || utils.getUuid()).toLowerCase();
196
207
 
197
208
  const readableStream = new Stream.Readable({
198
209
  objectMode: true,
@@ -306,6 +317,8 @@ class Connection extends EventEmitter {
306
317
  return;
307
318
  }
308
319
 
320
+ // TINKERPOP-2847: Use lower case to prevent string comparison issues.
321
+ response.requestId = response.requestId.toLowerCase();
309
322
  const handler = this._responseHandlers[response.requestId];
310
323
 
311
324
  if (!handler) {
@@ -48,6 +48,10 @@ class DriverRemoteConnection extends RemoteConnection {
48
48
  * @param {GraphSONWriter} [options.writer] The writer to use.
49
49
  * @param {Authenticator} [options.authenticator] The authentication handler to use.
50
50
  * @param {Object} [options.headers] An associative array containing the additional header key/values for the initial request.
51
+ * @param {Boolean} [options.enableUserAgentOnConnect] Determines if a user agent will be sent during connection handshake. Defaults to: true
52
+ * @param {Boolean} [options.pingEnabled] Setup ping interval. Defaults to: true.
53
+ * @param {Number} [options.pingInterval] Ping request interval in ms if ping enabled. Defaults to: 60000.
54
+ * @param {Number} [options.pongTimeout] Timeout of pong response in ms after sending a ping. Defaults to: 30000.
51
55
  * @constructor
52
56
  */
53
57
  constructor(url, options = {}) {
package/lib/utils.js CHANGED
@@ -24,6 +24,8 @@
24
24
  'use strict';
25
25
 
26
26
  const crypto = require('crypto');
27
+ const os = require('os');
28
+ const { readFileSync } = require('fs');
27
29
 
28
30
  exports.toLong = function toLong(value) {
29
31
  return new Long(value);
@@ -79,3 +81,44 @@ class ImmutableMap extends Map {
79
81
  }
80
82
 
81
83
  exports.ImmutableMap = ImmutableMap;
84
+
85
+ function generateUserAgent() {
86
+ const applicationName = (process.env.npm_package_name || 'NotAvailable').replace('_', ' ');
87
+ let driverVersion;
88
+ try {
89
+ driverVersion = JSON.parse(readFileSync(__dirname + '/../package.json')).version.replace('_', ' ');
90
+ } catch (e) {
91
+ driverVersion = 'NotAvailable';
92
+ }
93
+ let runtimeVersion;
94
+ let osName;
95
+ let osVersion;
96
+ let cpuArch;
97
+ runtimeVersion = osName = osVersion = cpuArch = 'NotAvailable';
98
+ if (process != null) {
99
+ if (process.version) {
100
+ runtimeVersion = process.version.replace(' ', '_');
101
+ }
102
+ if (process.arch) {
103
+ cpuArch = process.arch.replace(' ', '_');
104
+ }
105
+ }
106
+ if (os != null) {
107
+ osName = os.platform().replace(' ', '_');
108
+ osVersion = os.release().replace(' ', '_');
109
+ }
110
+
111
+ const userAgent = `${applicationName} Gremlin-Javascript.${driverVersion} ${runtimeVersion} ${osName}.${osVersion} ${cpuArch}`;
112
+
113
+ return userAgent;
114
+ }
115
+
116
+ exports.getUserAgentHeader = function getUserAgentHeader() {
117
+ return 'User-Agent';
118
+ };
119
+
120
+ const userAgent = generateUserAgent();
121
+
122
+ exports.getUserAgent = function getUserAgent() {
123
+ return userAgent;
124
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gremlin",
3
- "version": "3.5.4",
3
+ "version": "3.5.6",
4
4
  "description": "JavaScript Gremlin Language Variant",
5
5
  "author": "Apache TinkerPop team",
6
6
  "keywords": [
@@ -14,21 +14,22 @@
14
14
  ],
15
15
  "license": "Apache-2.0",
16
16
  "dependencies": {
17
- "ws": "^6.2.2"
17
+ "ws": "^8.11.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "chai": "~4.3.6",
21
+ "chai-string": "~1.5.0",
21
22
  "colors": "1.4.0",
22
23
  "cross-env": "^7.0.3",
23
- "cucumber": "~4.2.1",
24
+ "cucumber": "~6.0.7",
24
25
  "eslint": "^7.32.0",
25
26
  "eslint-config-prettier": "^8.5.0",
26
27
  "eslint-plugin-prettier": "^4.0.0",
27
- "grunt": "^1.4.1",
28
+ "grunt": "^1.5.3",
28
29
  "grunt-cli": "~1.4.3",
29
30
  "grunt-jsdoc": "~2.4.1",
30
31
  "mocha": "^9.2.2",
31
- "prettier": "^2.6.2"
32
+ "prettier": "^2.7.1"
32
33
  },
33
34
  "repository": {
34
35
  "type": "git",
@@ -48,6 +49,9 @@
48
49
  "features": "npm run features-graphson30 && npm run features-graphbinary",
49
50
  "features-graphson30": "cross-env CLIENT_MIMETYPE='application/vnd.gremlin-v3.0+json' cucumber-js --require test/cucumber ../../../../../gremlin-test/features/",
50
51
  "features-graphbinary": "cross-env CLIENT_MIMETYPE='application/vnd.graphbinary-v1.0' cucumber-js --require test/cucumber ../../../../../gremlin-test/features/",
52
+ "features-docker": "npm run features-graphson30-docker && npm run features-graphbinary-docker",
53
+ "features-graphson30-docker": "cross-env CLIENT_MIMETYPE='application/vnd.gremlin-v3.0+json' cucumber-js --require test/cucumber ../gremlin-test/",
54
+ "features-graphbinary-docker": "cross-env CLIENT_MIMETYPE='application/vnd.graphbinary-v1.0' cucumber-js --require test/cucumber ../gremlin-test/",
51
55
  "lint": "eslint --ext .js ."
52
56
  },
53
57
  "engines": {