gremlin 3.5.3 → 3.5.4

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 (105) hide show
  1. package/.eslintrc.js +3 -2
  2. package/doc/AnonymousTraversalSource.html +2 -2
  3. package/doc/Authenticator.html +2 -2
  4. package/doc/Bytecode.html +2 -2
  5. package/doc/Client.html +2 -2
  6. package/doc/Connection.html +10 -10
  7. package/doc/DriverRemoteConnection.html +2 -2
  8. package/doc/EdgeLabelVerificationStrategy.html +2 -2
  9. package/doc/Graph.html +2 -2
  10. package/doc/GraphSON2Reader.html +2 -2
  11. package/doc/GraphSON2Writer.html +2 -2
  12. package/doc/GraphSON3Reader.html +2 -2
  13. package/doc/GraphSON3Writer.html +2 -2
  14. package/doc/GraphTraversal.html +2 -2
  15. package/doc/GraphTraversalSource.html +2 -2
  16. package/doc/HaltedTraverserStrategy.html +2 -2
  17. package/doc/MatchAlgorithmStrategy.html +2 -2
  18. package/doc/P.html +2 -2
  19. package/doc/PartitionStrategy.html +2 -2
  20. package/doc/Path.html +2 -2
  21. package/doc/PlainTextSaslAuthenticator.html +2 -2
  22. package/doc/ProductiveByStrategy.html +2 -2
  23. package/doc/RemoteConnection.html +2 -2
  24. package/doc/RemoteStrategy.html +2 -2
  25. package/doc/RemoteTraversal.html +2 -2
  26. package/doc/ReservedKeysVerificationStrategy.html +2 -2
  27. package/doc/ResponseError.html +2 -2
  28. package/doc/ResultSet.html +2 -2
  29. package/doc/SaslAuthenticator.html +2 -2
  30. package/doc/SaslMechanismBase.html +2 -2
  31. package/doc/SaslMechanismPlain.html +2 -2
  32. package/doc/SeedStrategy.html +2 -2
  33. package/doc/SubgraphStrategy.html +2 -2
  34. package/doc/TextP.html +2 -2
  35. package/doc/Transaction.html +2 -2
  36. package/doc/Translator.html +2 -2
  37. package/doc/TraversalStrategies.html +2 -2
  38. package/doc/TraversalStrategy.html +2 -2
  39. package/doc/TypeSerializer.html +2 -2
  40. package/doc/driver_auth_authenticator.js.html +2 -2
  41. package/doc/driver_auth_mechanisms_sasl-mechanism-base.js.html +2 -2
  42. package/doc/driver_auth_mechanisms_sasl-mechanism-plain.js.html +2 -2
  43. package/doc/driver_auth_plain-text-sasl-authenticator.js.html +2 -2
  44. package/doc/driver_auth_sasl-authenticator.js.html +2 -2
  45. package/doc/driver_client.js.html +2 -2
  46. package/doc/driver_connection.js.html +32 -9
  47. package/doc/driver_driver-remote-connection.js.html +2 -2
  48. package/doc/driver_remote-connection.js.html +2 -2
  49. package/doc/driver_response-error.js.html +2 -2
  50. package/doc/driver_result-set.js.html +2 -2
  51. package/doc/global.html +66 -2
  52. package/doc/index.html +2 -2
  53. package/doc/module.exports.html +301 -0
  54. package/doc/process_anonymous-traversal.js.html +2 -2
  55. package/doc/process_bytecode.js.html +2 -2
  56. package/doc/process_graph-traversal.js.html +2 -2
  57. package/doc/process_transaction.js.html +2 -2
  58. package/doc/process_translator.js.html +2 -2
  59. package/doc/process_traversal-strategy.js.html +3 -3
  60. package/doc/process_traversal.js.html +2 -2
  61. package/doc/structure_graph.js.html +2 -2
  62. package/doc/structure_io_binary_internals_DataType.js.html +148 -0
  63. package/doc/structure_io_binary_internals_GraphBinaryReader.js.html +131 -0
  64. package/doc/structure_io_binary_internals_GraphBinaryWriter.js.html +134 -0
  65. package/doc/structure_io_graph-serializer.js.html +2 -2
  66. package/doc/structure_io_type-serializers.js.html +2 -2
  67. package/lib/driver/connection.js +30 -7
  68. package/lib/process/traversal-strategy.js +1 -1
  69. package/lib/structure/io/binary/GraphBinary.js +109 -0
  70. package/lib/structure/io/binary/internals/AnySerializer.js +95 -0
  71. package/lib/structure/io/binary/internals/ArraySerializer.js +135 -0
  72. package/lib/structure/io/binary/internals/BigIntegerSerializer.js +151 -0
  73. package/lib/structure/io/binary/internals/BooleanSerializer.js +103 -0
  74. package/lib/structure/io/binary/internals/BulkSetSerializer.js +124 -0
  75. package/lib/structure/io/binary/internals/ByteBufferSerializer.js +124 -0
  76. package/lib/structure/io/binary/internals/ByteSerializer.js +95 -0
  77. package/lib/structure/io/binary/internals/BytecodeSerializer.js +249 -0
  78. package/lib/structure/io/binary/internals/DataType.js +97 -0
  79. package/lib/structure/io/binary/internals/DateSerializer.js +103 -0
  80. package/lib/structure/io/binary/internals/DoubleSerializer.js +99 -0
  81. package/lib/structure/io/binary/internals/EdgeSerializer.js +215 -0
  82. package/lib/structure/io/binary/internals/EnumSerializer.js +148 -0
  83. package/lib/structure/io/binary/internals/FloatSerializer.js +99 -0
  84. package/lib/structure/io/binary/internals/GraphBinaryReader.js +80 -0
  85. package/lib/structure/io/binary/internals/GraphBinaryWriter.js +83 -0
  86. package/lib/structure/io/binary/internals/IntSerializer.js +112 -0
  87. package/lib/structure/io/binary/internals/LambdaSerializer.js +70 -0
  88. package/lib/structure/io/binary/internals/LongSerializer.js +107 -0
  89. package/lib/structure/io/binary/internals/LongSerializerNg.js +102 -0
  90. package/lib/structure/io/binary/internals/MapSerializer.js +153 -0
  91. package/lib/structure/io/binary/internals/NumberSerializationStrategy.js +68 -0
  92. package/lib/structure/io/binary/internals/PSerializer.js +151 -0
  93. package/lib/structure/io/binary/internals/PathSerializer.js +123 -0
  94. package/lib/structure/io/binary/internals/PropertySerializer.js +141 -0
  95. package/lib/structure/io/binary/internals/ShortSerializer.js +99 -0
  96. package/lib/structure/io/binary/internals/StringSerializer.js +114 -0
  97. package/lib/structure/io/binary/internals/TextPSerializer.js +145 -0
  98. package/lib/structure/io/binary/internals/TraversalStrategySerializer.js +72 -0
  99. package/lib/structure/io/binary/internals/TraverserSerializer.js +123 -0
  100. package/lib/structure/io/binary/internals/UnspecifiedNullSerializer.js +75 -0
  101. package/lib/structure/io/binary/internals/UuidSerializer.js +119 -0
  102. package/lib/structure/io/binary/internals/VertexPropertySerializer.js +172 -0
  103. package/lib/structure/io/binary/internals/VertexSerializer.js +135 -0
  104. package/lib/structure/io/binary/internals/utils.js +59 -0
  105. package/package.json +14 -7
@@ -0,0 +1,119 @@
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 UuidSerializer {
26
+ constructor(ioc) {
27
+ this.ioc = ioc;
28
+ this.ioc.serializers[ioc.DataType.UUID] = this;
29
+ }
30
+
31
+ canBeUsedFor(value) {
32
+ // TODO: any idea to support UUID automatic serialization via AnySerializer in future?
33
+ }
34
+
35
+ serialize(item, fullyQualifiedFormat = true) {
36
+ if (item === undefined || item === null) {
37
+ if (fullyQualifiedFormat) {
38
+ return Buffer.from([this.ioc.DataType.UUID, 0x01]);
39
+ }
40
+ return Buffer.from([
41
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42
+ ]);
43
+ }
44
+
45
+ const uuid_str = String(item)
46
+ .replace(/^urn:uuid:/, '')
47
+ .replace(/[{}-]/g, '');
48
+
49
+ const bufs = [];
50
+ if (fullyQualifiedFormat) {
51
+ bufs.push(Buffer.from([this.ioc.DataType.UUID, 0x00]));
52
+ }
53
+
54
+ const v = Buffer.alloc(16, 0);
55
+ for (let i = 0; i < 16 && i * 2 < uuid_str.length; i++) {
56
+ v[i] = parseInt(uuid_str.slice(i * 2, i * 2 + 2), 16);
57
+ }
58
+ bufs.push(v);
59
+
60
+ return Buffer.concat(bufs);
61
+ }
62
+
63
+ deserialize(buffer, fullyQualifiedFormat = true, nullable = false) {
64
+ let len = 0;
65
+ let cursor = buffer;
66
+
67
+ try {
68
+ if (buffer === undefined || buffer === null || !(buffer instanceof Buffer)) {
69
+ throw new Error('buffer is missing');
70
+ }
71
+ if (buffer.length < 1) {
72
+ throw new Error('buffer is empty');
73
+ }
74
+
75
+ if (fullyQualifiedFormat) {
76
+ const type_code = cursor.readUInt8();
77
+ len++;
78
+ if (type_code !== this.ioc.DataType.UUID) {
79
+ throw new Error('unexpected {type_code}');
80
+ }
81
+ cursor = cursor.slice(1);
82
+ }
83
+ if (fullyQualifiedFormat || nullable) {
84
+ if (cursor.length < 1) {
85
+ throw new Error('{value_flag} is missing');
86
+ }
87
+ const value_flag = cursor.readUInt8();
88
+ len++;
89
+ if (value_flag === 1) {
90
+ return { v: null, len };
91
+ }
92
+ if (value_flag !== 0) {
93
+ throw new Error('unexpected {value_flag}');
94
+ }
95
+ cursor = cursor.slice(1);
96
+ }
97
+
98
+ if (cursor.length < 16) {
99
+ throw new Error('unexpected {value} length');
100
+ }
101
+ len += 16;
102
+
103
+ // Example: 2075278D-F624-4B2B-960D-25D374D57C04
104
+ const v =
105
+ cursor.slice(0, 4).toString('hex') +
106
+ '-' +
107
+ cursor.slice(4, 6).toString('hex') +
108
+ '-' +
109
+ cursor.slice(6, 8).toString('hex') +
110
+ '-' +
111
+ cursor.slice(8, 10).toString('hex') +
112
+ '-' +
113
+ cursor.slice(10, 16).toString('hex');
114
+ return { v, len };
115
+ } catch (err) {
116
+ throw this.ioc.utils.des_error({ serializer: this, args: arguments, cursor, err });
117
+ }
118
+ }
119
+ };
@@ -0,0 +1,172 @@
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
+ const g = require('../../../graph');
26
+
27
+ module.exports = class VertexPropertySerializer {
28
+ constructor(ioc) {
29
+ this.ioc = ioc;
30
+ this.ioc.serializers[ioc.DataType.VERTEXPROPERTY] = this;
31
+ }
32
+
33
+ canBeUsedFor(value) {
34
+ return value instanceof g.VertexProperty;
35
+ }
36
+
37
+ serialize(item, fullyQualifiedFormat = true) {
38
+ if (item === undefined || item === null) {
39
+ if (fullyQualifiedFormat) {
40
+ return Buffer.from([this.ioc.DataType.VERTEXPROPERTY, 0x01]);
41
+ }
42
+ return Buffer.concat([
43
+ this.ioc.unspecifiedNullSerializer.serialize(null), // {id}=null
44
+ this.ioc.stringSerializer.serialize('', false), // {label}=''
45
+ this.ioc.unspecifiedNullSerializer.serialize(null), // {value}=null
46
+ this.ioc.unspecifiedNullSerializer.serialize(null), // {parent}=null
47
+ this.ioc.unspecifiedNullSerializer.serialize(null), // {properties}=null
48
+ ]);
49
+ }
50
+
51
+ const bufs = [];
52
+ if (fullyQualifiedFormat) {
53
+ bufs.push(Buffer.from([this.ioc.DataType.VERTEXPROPERTY, 0x00]));
54
+ }
55
+
56
+ // {id}
57
+ bufs.push(this.ioc.anySerializer.serialize(item.id));
58
+
59
+ // {label}
60
+ bufs.push(this.ioc.stringSerializer.serialize(item.label, false));
61
+
62
+ // {value}
63
+ bufs.push(this.ioc.anySerializer.serialize(item.value));
64
+
65
+ // {parent}
66
+ bufs.push(this.ioc.unspecifiedNullSerializer.serialize(null));
67
+
68
+ // {properties}
69
+ bufs.push(this.ioc.anySerializer.serialize(item.properties));
70
+
71
+ return Buffer.concat(bufs);
72
+ }
73
+
74
+ deserialize(buffer, fullyQualifiedFormat = true) {
75
+ let len = 0;
76
+ let cursor = buffer;
77
+
78
+ try {
79
+ if (buffer === undefined || buffer === null || !(buffer instanceof Buffer)) {
80
+ throw new Error('buffer is missing');
81
+ }
82
+ if (buffer.length < 1) {
83
+ throw new Error('buffer is empty');
84
+ }
85
+
86
+ if (fullyQualifiedFormat) {
87
+ const type_code = cursor.readUInt8();
88
+ len++;
89
+ if (type_code !== this.ioc.DataType.VERTEXPROPERTY) {
90
+ throw new Error('unexpected {type_code}');
91
+ }
92
+ cursor = cursor.slice(1);
93
+
94
+ if (cursor.length < 1) {
95
+ throw new Error('{value_flag} is missing');
96
+ }
97
+ const value_flag = cursor.readUInt8();
98
+ len++;
99
+ if (value_flag === 1) {
100
+ return { v: null, len };
101
+ }
102
+ if (value_flag !== 0) {
103
+ throw new Error('unexpected {value_flag}');
104
+ }
105
+ cursor = cursor.slice(1);
106
+ }
107
+
108
+ // {id} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value}
109
+ let id, id_len;
110
+ try {
111
+ ({ v: id, len: id_len } = this.ioc.anySerializer.deserialize(cursor));
112
+ len += id_len;
113
+ } catch (err) {
114
+ err.message = '{id}: ' + err.message;
115
+ throw err;
116
+ }
117
+ cursor = cursor.slice(id_len);
118
+
119
+ // {label} is a String value
120
+ let label, label_len;
121
+ try {
122
+ ({ v: label, len: label_len } = this.ioc.stringSerializer.deserialize(cursor, false));
123
+ len += label_len;
124
+ } catch (err) {
125
+ err.message = '{label}: ' + err.message;
126
+ throw err;
127
+ }
128
+ cursor = cursor.slice(label_len);
129
+
130
+ // {value} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value}
131
+ let value, value_len;
132
+ try {
133
+ ({ v: value, len: value_len } = this.ioc.anySerializer.deserialize(cursor));
134
+ len += value_len;
135
+ } catch (err) {
136
+ err.message = '{value}: ' + err.message;
137
+ throw err;
138
+ }
139
+ cursor = cursor.slice(value_len);
140
+
141
+ // {parent} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value} which contains the parent Vertex.
142
+ // Note that as TinkerPop currently send "references" only, this value will always be null.
143
+ let parent_len;
144
+ try {
145
+ ({ len: parent_len } = this.ioc.unspecifiedNullSerializer.deserialize(cursor));
146
+ len += parent_len;
147
+ } catch (err) {
148
+ err.message = '{parent}: ' + err.message;
149
+ throw err;
150
+ }
151
+ // TODO: should we verify that parent is null?
152
+ cursor = cursor.slice(parent_len);
153
+
154
+ // {properties} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value} which contains properties. Note that as TinkerPop currently send "references" only, this value will always be null.
155
+ let properties, properties_len;
156
+ try {
157
+ ({ v: properties, len: properties_len } = this.ioc.unspecifiedNullSerializer.deserialize(cursor));
158
+ len += properties_len;
159
+ } catch (err) {
160
+ err.message = '{properties}: ' + err.message;
161
+ throw err;
162
+ }
163
+ // TODO: should we verify that properties is null?
164
+ cursor = cursor.slice(properties_len);
165
+
166
+ const v = new g.VertexProperty(id, label, value, properties);
167
+ return { v, len };
168
+ } catch (err) {
169
+ throw this.ioc.utils.des_error({ serializer: this, args: arguments, cursor, err });
170
+ }
171
+ }
172
+ };
@@ -0,0 +1,135 @@
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
+ const g = require('../../../graph');
26
+
27
+ module.exports = class VertexSerializer {
28
+ constructor(ioc) {
29
+ this.ioc = ioc;
30
+ this.ioc.serializers[ioc.DataType.VERTEX] = this;
31
+ }
32
+
33
+ canBeUsedFor(value) {
34
+ return value instanceof g.Vertex;
35
+ }
36
+
37
+ serialize(item, fullyQualifiedFormat = true) {
38
+ if (item === undefined || item === null) {
39
+ if (fullyQualifiedFormat) {
40
+ return Buffer.from([this.ioc.DataType.VERTEX, 0x01]);
41
+ }
42
+ const id = [0x03, 0x00, 0x00, 0x00, 0x00, 0x00]; // String ''
43
+ const label = [0x00, 0x00, 0x00, 0x00]; // ''
44
+ const properties = [0xfe, 0x01]; // null
45
+ return Buffer.from([...id, ...label, ...properties]);
46
+ }
47
+
48
+ const bufs = [];
49
+ if (fullyQualifiedFormat) {
50
+ bufs.push(Buffer.from([this.ioc.DataType.VERTEX, 0x00]));
51
+ }
52
+
53
+ // {id}
54
+ bufs.push(this.ioc.anySerializer.serialize(item.id));
55
+
56
+ // {label}
57
+ bufs.push(this.ioc.stringSerializer.serialize(item.label, false));
58
+
59
+ // {properties}
60
+ bufs.push(this.ioc.anySerializer.serialize(item.properties));
61
+
62
+ return Buffer.concat(bufs);
63
+ }
64
+
65
+ deserialize(buffer, fullyQualifiedFormat = true) {
66
+ let len = 0;
67
+ let cursor = buffer;
68
+
69
+ try {
70
+ if (buffer === undefined || buffer === null || !(buffer instanceof Buffer)) {
71
+ throw new Error('buffer is missing');
72
+ }
73
+ if (buffer.length < 1) {
74
+ throw new Error('buffer is empty');
75
+ }
76
+
77
+ if (fullyQualifiedFormat) {
78
+ const type_code = cursor.readUInt8();
79
+ len++;
80
+ if (type_code !== this.ioc.DataType.VERTEX) {
81
+ throw new Error('unexpected {type_code}');
82
+ }
83
+ cursor = cursor.slice(1);
84
+
85
+ if (cursor.length < 1) {
86
+ throw new Error('{value_flag} is missing');
87
+ }
88
+ const value_flag = cursor.readUInt8();
89
+ len++;
90
+ if (value_flag === 1) {
91
+ return { v: null, len };
92
+ }
93
+ if (value_flag !== 0) {
94
+ throw new Error('unexpected {value_flag}');
95
+ }
96
+ cursor = cursor.slice(1);
97
+ }
98
+
99
+ let id, id_len;
100
+ try {
101
+ ({ v: id, len: id_len } = this.ioc.anySerializer.deserialize(cursor));
102
+ len += id_len;
103
+ } catch (err) {
104
+ err.message = '{id}: ' + err.message;
105
+ throw err;
106
+ }
107
+ cursor = cursor.slice(id_len);
108
+
109
+ let label, label_len;
110
+ try {
111
+ ({ v: label, len: label_len } = this.ioc.stringSerializer.deserialize(cursor, false));
112
+ len += label_len;
113
+ } catch (err) {
114
+ err.message = '{label}: ' + err.message;
115
+ throw err;
116
+ }
117
+ cursor = cursor.slice(label_len);
118
+
119
+ let properties, properties_len;
120
+ try {
121
+ ({ v: properties, len: properties_len } = this.ioc.anySerializer.deserialize(cursor));
122
+ len += properties_len;
123
+ } catch (err) {
124
+ err.message = '{properties}: ' + err.message;
125
+ throw err;
126
+ }
127
+ cursor = cursor.slice(properties_len);
128
+
129
+ const v = new g.Vertex(id, label, properties);
130
+ return { v, len };
131
+ } catch (err) {
132
+ throw this.ioc.utils.des_error({ serializer: this, args: arguments, cursor, err });
133
+ }
134
+ }
135
+ };
@@ -0,0 +1,59 @@
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
+ /*
26
+ * Deserialization error general constructor.
27
+ */
28
+ const des_error = ({ serializer, args, cursor, err }) => {
29
+ if (cursor === undefined) {
30
+ cursor = args[0]; // buffer
31
+ }
32
+ let cursor_tail = '';
33
+ if (cursor instanceof Buffer) {
34
+ if (cursor.length > 32) {
35
+ cursor_tail = '...';
36
+ }
37
+ cursor = cursor.slice(0, 32).toString('hex');
38
+ }
39
+
40
+ const fullyQualifiedFormat = args[1];
41
+ const nullable = args[2];
42
+
43
+ let m = `${serializer.constructor.name}.deserialize(cursor=${cursor}${cursor_tail}`;
44
+ if (fullyQualifiedFormat !== undefined) {
45
+ m += `, fullyQualifiedFormat=${fullyQualifiedFormat}`;
46
+ }
47
+ if (nullable !== undefined) {
48
+ m += `, nullable=${nullable}`;
49
+ }
50
+ m += `): ${err.message.replace(/\.$/, '')}.`;
51
+
52
+ err.message = m;
53
+
54
+ return err;
55
+ };
56
+
57
+ module.exports = {
58
+ des_error,
59
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gremlin",
3
- "version": "3.5.3",
3
+ "version": "3.5.4",
4
4
  "description": "JavaScript Gremlin Language Variant",
5
5
  "author": "Apache TinkerPop team",
6
6
  "keywords": [
@@ -17,17 +17,18 @@
17
17
  "ws": "^6.2.2"
18
18
  },
19
19
  "devDependencies": {
20
- "chai": "~4.1.2",
20
+ "chai": "~4.3.6",
21
21
  "colors": "1.4.0",
22
+ "cross-env": "^7.0.3",
22
23
  "cucumber": "~4.2.1",
23
24
  "eslint": "^7.32.0",
24
25
  "eslint-config-prettier": "^8.5.0",
25
26
  "eslint-plugin-prettier": "^4.0.0",
26
27
  "grunt": "^1.4.1",
27
- "grunt-cli": "~1.3.2",
28
+ "grunt-cli": "~1.4.3",
28
29
  "grunt-jsdoc": "~2.4.1",
29
30
  "mocha": "^9.2.2",
30
- "prettier": "^2.5.1"
31
+ "prettier": "^2.6.2"
31
32
  },
32
33
  "repository": {
33
34
  "type": "git",
@@ -38,9 +39,15 @@
38
39
  "url": "https://issues.apache.org/jira/browse/TINKERPOP"
39
40
  },
40
41
  "scripts": {
41
- "test": "./node_modules/mocha/bin/mocha test/unit test/integration -t 5000",
42
- "features": "./node_modules/.bin/cucumber-js --require test/cucumber ../../../../../gremlin-test/features/",
43
- "unit-test": "./node_modules/mocha/bin/mocha test/unit",
42
+ "test": "npm run unit-test && npm run integration-test",
43
+ "unit-test": "mocha test/unit/*",
44
+ "integration-test": "npm run integration-test-graphson30 && npm run integration-test-graphbinary",
45
+ "integration-test-graphson30": "cross-env CLIENT_MIMETYPE='application/vnd.gremlin-v3.0+json' ./node_modules/mocha/bin/mocha test/integration -t 5000",
46
+ "integration-test-graphbinary": "cross-env CLIENT_MIMETYPE='application/vnd.graphbinary-v1.0' ./node_modules/mocha/bin/mocha test/integration -t 5000",
47
+ "TODO": "# test other mime types like graphbinary stringd",
48
+ "features": "npm run features-graphson30 && npm run features-graphbinary",
49
+ "features-graphson30": "cross-env CLIENT_MIMETYPE='application/vnd.gremlin-v3.0+json' cucumber-js --require test/cucumber ../../../../../gremlin-test/features/",
50
+ "features-graphbinary": "cross-env CLIENT_MIMETYPE='application/vnd.graphbinary-v1.0' cucumber-js --require test/cucumber ../../../../../gremlin-test/features/",
44
51
  "lint": "eslint --ext .js ."
45
52
  },
46
53
  "engines": {