gremlin 4.0.0-beta.2 → 4.0.0-beta.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 (261) hide show
  1. package/build/cjs/driver/auth.cjs +11 -4
  2. package/build/cjs/driver/auth.d.cts +1 -1
  3. package/build/cjs/driver/client.cjs +82 -38
  4. package/build/cjs/driver/client.d.cts +30 -27
  5. package/build/cjs/driver/connection.cjs +173 -60
  6. package/build/cjs/driver/connection.d.cts +69 -26
  7. package/build/cjs/driver/dispatcher.browser.cjs +57 -0
  8. package/build/cjs/driver/dispatcher.browser.d.cts +35 -0
  9. package/build/cjs/driver/dispatcher.cjs +101 -0
  10. package/build/cjs/driver/dispatcher.d.cts +48 -0
  11. package/build/cjs/driver/driver-remote-connection.cjs +27 -15
  12. package/build/cjs/driver/driver-remote-connection.d.cts +10 -4
  13. package/build/cjs/driver/http-request.cjs +64 -0
  14. package/build/cjs/driver/http-request.d.cts +28 -0
  15. package/build/cjs/driver/logger.cjs +45 -0
  16. package/build/cjs/driver/logger.d.cts +29 -0
  17. package/build/cjs/driver/remote-connection.cjs +5 -8
  18. package/build/cjs/driver/remote-connection.d.cts +6 -21
  19. package/build/cjs/driver/request-message.cjs +110 -21
  20. package/build/cjs/driver/request-message.d.cts +38 -8
  21. package/build/cjs/driver/response-error.cjs +3 -3
  22. package/build/cjs/driver/response-error.d.cts +2 -2
  23. package/build/cjs/index.cjs +21 -0
  24. package/build/cjs/index.d.cts +47 -0
  25. package/build/cjs/language/grammar/GremlinLexer.cjs +1669 -1615
  26. package/build/cjs/language/grammar/GremlinLexer.d.cts +325 -316
  27. package/build/cjs/language/grammar/GremlinListener.cjs +322 -8
  28. package/build/cjs/language/grammar/GremlinListener.d.cts +351 -10
  29. package/build/cjs/language/grammar/GremlinParser.cjs +8700 -5798
  30. package/build/cjs/language/grammar/GremlinParser.d.cts +998 -619
  31. package/build/cjs/language/translator/AnonymizedTranslateVisitor.cjs +9 -0
  32. package/build/cjs/language/translator/AnonymizedTranslateVisitor.d.cts +3 -0
  33. package/build/cjs/language/translator/DotNetTranslateVisitor.cjs +113 -4
  34. package/build/cjs/language/translator/DotNetTranslateVisitor.d.cts +13 -2
  35. package/build/cjs/language/translator/GoTranslateVisitor.cjs +82 -0
  36. package/build/cjs/language/translator/GoTranslateVisitor.d.cts +9 -0
  37. package/build/cjs/language/translator/GroovyTranslateVisitor.cjs +23 -0
  38. package/build/cjs/language/translator/GroovyTranslateVisitor.d.cts +3 -0
  39. package/build/cjs/language/translator/JavaTranslateVisitor.cjs +23 -0
  40. package/build/cjs/language/translator/JavaTranslateVisitor.d.cts +3 -0
  41. package/build/cjs/language/translator/JavascriptTranslateVisitor.cjs +11 -0
  42. package/build/cjs/language/translator/JavascriptTranslateVisitor.d.cts +3 -0
  43. package/build/cjs/language/translator/PythonTranslateVisitor.cjs +39 -3
  44. package/build/cjs/language/translator/PythonTranslateVisitor.d.cts +3 -0
  45. package/build/cjs/language/translator/TranslateVisitor.cjs +9 -0
  46. package/build/cjs/language/translator/TranslateVisitor.d.cts +3 -0
  47. package/build/cjs/process/anonymous-traversal.cjs +5 -1
  48. package/build/cjs/process/graph-traversal.cjs +139 -8
  49. package/build/cjs/process/graph-traversal.d.cts +84 -3
  50. package/build/cjs/process/gremlin-lang.cjs +119 -7
  51. package/build/cjs/process/gremlin-lang.d.cts +6 -1
  52. package/build/cjs/process/gvalue.cjs +42 -0
  53. package/build/cjs/process/gvalue.d.cts +7 -0
  54. package/build/cjs/process/transaction.cjs +125 -23
  55. package/build/cjs/process/transaction.d.cts +50 -14
  56. package/build/cjs/process/traversal.cjs +105 -48
  57. package/build/cjs/process/traversal.d.cts +36 -10
  58. package/build/cjs/structure/PDTRegistry.cjs +116 -0
  59. package/build/cjs/structure/PDTRegistry.d.cts +34 -0
  60. package/build/cjs/structure/graph.cjs +351 -8
  61. package/build/cjs/structure/graph.d.cts +122 -3
  62. package/build/cjs/structure/io/binary/GraphBinary.cjs +68 -39
  63. package/build/cjs/structure/io/binary/GraphBinary.d.cts +15 -1
  64. package/build/cjs/structure/io/binary/internals/AnySerializer.cjs +34 -17
  65. package/build/cjs/structure/io/binary/internals/AnySerializer.d.cts +12 -2
  66. package/build/cjs/structure/io/binary/internals/ArraySerializer.cjs +41 -72
  67. package/build/cjs/structure/io/binary/internals/ArraySerializer.d.cts +14 -7
  68. package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.cjs +34 -54
  69. package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.d.cts +12 -7
  70. package/build/cjs/structure/io/binary/internals/BinarySerializer.cjs +31 -51
  71. package/build/cjs/structure/io/binary/internals/BinarySerializer.d.cts +12 -4
  72. package/build/cjs/structure/io/binary/internals/BooleanSerializer.cjs +28 -42
  73. package/build/cjs/structure/io/binary/internals/BooleanSerializer.d.cts +12 -4
  74. package/build/cjs/structure/io/binary/internals/ByteSerializer.cjs +24 -38
  75. package/build/cjs/structure/io/binary/internals/ByteSerializer.d.cts +12 -4
  76. package/build/cjs/structure/io/binary/internals/CompositePDTSerializer.cjs +81 -0
  77. package/build/cjs/structure/io/binary/internals/CompositePDTSerializer.d.cts +10 -0
  78. package/build/cjs/structure/io/binary/internals/DateTimeSerializer.cjs +52 -69
  79. package/build/cjs/structure/io/binary/internals/DateTimeSerializer.d.cts +12 -7
  80. package/build/cjs/structure/io/binary/internals/DoubleSerializer.cjs +24 -38
  81. package/build/cjs/structure/io/binary/internals/DoubleSerializer.d.cts +12 -4
  82. package/build/cjs/structure/io/binary/internals/EdgeSerializer.cjs +69 -124
  83. package/build/cjs/structure/io/binary/internals/EdgeSerializer.d.cts +14 -12
  84. package/build/cjs/structure/io/binary/internals/EnumSerializer.cjs +47 -59
  85. package/build/cjs/structure/io/binary/internals/EnumSerializer.d.cts +19 -4
  86. package/build/cjs/structure/io/binary/internals/FloatSerializer.cjs +24 -38
  87. package/build/cjs/structure/io/binary/internals/FloatSerializer.d.cts +12 -4
  88. package/build/cjs/structure/io/binary/internals/GraphBinaryReader.cjs +111 -37
  89. package/build/cjs/structure/io/binary/internals/GraphBinaryReader.d.cts +26 -2
  90. package/build/cjs/structure/io/binary/internals/GraphBinaryWriter.cjs +6 -6
  91. package/build/cjs/structure/io/binary/internals/GraphSerializer.cjs +184 -0
  92. package/build/cjs/structure/io/binary/internals/GraphSerializer.d.cts +22 -0
  93. package/build/cjs/structure/io/binary/internals/IntSerializer.cjs +33 -38
  94. package/build/cjs/structure/io/binary/internals/IntSerializer.d.cts +19 -4
  95. package/build/cjs/structure/io/binary/internals/LongSerializer.cjs +29 -42
  96. package/build/cjs/structure/io/binary/internals/LongSerializer.d.cts +13 -4
  97. package/build/cjs/structure/io/binary/internals/MapSerializer.cjs +36 -70
  98. package/build/cjs/structure/io/binary/internals/MapSerializer.d.cts +14 -7
  99. package/build/cjs/structure/io/binary/internals/MarkerSerializer.cjs +30 -33
  100. package/build/cjs/structure/io/binary/internals/MarkerSerializer.d.cts +13 -4
  101. package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.cjs +28 -2
  102. package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.d.cts +0 -3
  103. package/build/cjs/structure/io/binary/internals/PathSerializer.cjs +30 -55
  104. package/build/cjs/structure/io/binary/internals/PathSerializer.d.cts +14 -7
  105. package/build/cjs/structure/io/binary/internals/PrimitivePDTSerializer.cjs +80 -0
  106. package/build/cjs/structure/io/binary/internals/PrimitivePDTSerializer.d.cts +10 -0
  107. package/build/cjs/structure/io/binary/internals/PropertySerializer.cjs +32 -69
  108. package/build/cjs/structure/io/binary/internals/PropertySerializer.d.cts +14 -7
  109. package/build/cjs/structure/io/binary/internals/SetSerializer.cjs +39 -73
  110. package/build/cjs/structure/io/binary/internals/SetSerializer.d.cts +14 -7
  111. package/build/cjs/structure/io/binary/internals/ShortSerializer.cjs +24 -38
  112. package/build/cjs/structure/io/binary/internals/ShortSerializer.d.cts +12 -4
  113. package/build/cjs/structure/io/binary/internals/StreamReader.cjs +184 -0
  114. package/build/cjs/structure/io/binary/internals/StreamReader.d.cts +69 -0
  115. package/build/cjs/structure/io/binary/internals/StringSerializer.cjs +34 -53
  116. package/build/cjs/structure/io/binary/internals/StringSerializer.d.cts +14 -4
  117. package/build/cjs/structure/io/binary/internals/StubSerializer.cjs +2 -1
  118. package/build/cjs/structure/io/binary/internals/StubSerializer.d.cts +1 -1
  119. package/build/cjs/structure/io/binary/internals/TreeSerializer.cjs +139 -0
  120. package/build/cjs/structure/io/binary/internals/TreeSerializer.d.cts +54 -0
  121. package/build/cjs/structure/io/binary/internals/UnspecifiedNullSerializer.cjs +8 -31
  122. package/build/cjs/structure/io/binary/internals/UnspecifiedNullSerializer.d.cts +6 -4
  123. package/build/cjs/structure/io/binary/internals/UuidSerializer.cjs +33 -49
  124. package/build/cjs/structure/io/binary/internals/UuidSerializer.d.cts +12 -7
  125. package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.cjs +37 -95
  126. package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.d.cts +14 -7
  127. package/build/cjs/structure/io/binary/internals/VertexSerializer.cjs +41 -68
  128. package/build/cjs/structure/io/binary/internals/VertexSerializer.d.cts +14 -9
  129. package/build/cjs/utils.cjs +157 -40
  130. package/build/cjs/utils.d.cts +62 -4
  131. package/build/esm/driver/auth.d.ts +1 -1
  132. package/build/esm/driver/auth.js +11 -4
  133. package/build/esm/driver/client.d.ts +30 -27
  134. package/build/esm/driver/client.js +82 -38
  135. package/build/esm/driver/connection.d.ts +69 -26
  136. package/build/esm/driver/connection.js +172 -60
  137. package/build/esm/driver/dispatcher.browser.d.ts +35 -0
  138. package/build/esm/driver/dispatcher.browser.js +53 -0
  139. package/build/esm/driver/dispatcher.d.ts +48 -0
  140. package/build/esm/driver/dispatcher.js +94 -0
  141. package/build/esm/driver/driver-remote-connection.d.ts +10 -4
  142. package/build/esm/driver/driver-remote-connection.js +27 -15
  143. package/build/esm/driver/http-request.d.ts +28 -0
  144. package/build/esm/driver/http-request.js +60 -0
  145. package/build/esm/driver/logger.d.ts +29 -0
  146. package/build/esm/driver/logger.js +42 -0
  147. package/build/esm/driver/remote-connection.d.ts +6 -21
  148. package/build/esm/driver/remote-connection.js +5 -8
  149. package/build/esm/driver/request-message.d.ts +38 -8
  150. package/build/esm/driver/request-message.js +107 -21
  151. package/build/esm/driver/response-error.d.ts +2 -2
  152. package/build/esm/driver/response-error.js +3 -3
  153. package/build/esm/index.d.ts +47 -0
  154. package/build/esm/index.js +21 -0
  155. package/build/esm/language/grammar/GremlinLexer.d.ts +325 -316
  156. package/build/esm/language/grammar/GremlinLexer.js +1669 -1615
  157. package/build/esm/language/grammar/GremlinListener.d.ts +351 -10
  158. package/build/esm/language/grammar/GremlinListener.js +322 -8
  159. package/build/esm/language/grammar/GremlinParser.d.ts +998 -619
  160. package/build/esm/language/grammar/GremlinParser.js +8646 -5778
  161. package/build/esm/language/translator/AnonymizedTranslateVisitor.d.ts +3 -0
  162. package/build/esm/language/translator/AnonymizedTranslateVisitor.js +9 -0
  163. package/build/esm/language/translator/DotNetTranslateVisitor.d.ts +13 -2
  164. package/build/esm/language/translator/DotNetTranslateVisitor.js +113 -4
  165. package/build/esm/language/translator/GoTranslateVisitor.d.ts +9 -0
  166. package/build/esm/language/translator/GoTranslateVisitor.js +82 -0
  167. package/build/esm/language/translator/GroovyTranslateVisitor.d.ts +3 -0
  168. package/build/esm/language/translator/GroovyTranslateVisitor.js +23 -0
  169. package/build/esm/language/translator/JavaTranslateVisitor.d.ts +3 -0
  170. package/build/esm/language/translator/JavaTranslateVisitor.js +23 -0
  171. package/build/esm/language/translator/JavascriptTranslateVisitor.d.ts +3 -0
  172. package/build/esm/language/translator/JavascriptTranslateVisitor.js +11 -0
  173. package/build/esm/language/translator/PythonTranslateVisitor.d.ts +3 -0
  174. package/build/esm/language/translator/PythonTranslateVisitor.js +39 -3
  175. package/build/esm/language/translator/TranslateVisitor.d.ts +3 -0
  176. package/build/esm/language/translator/TranslateVisitor.js +9 -0
  177. package/build/esm/process/anonymous-traversal.js +5 -1
  178. package/build/esm/process/graph-traversal.d.ts +84 -3
  179. package/build/esm/process/graph-traversal.js +139 -8
  180. package/build/esm/process/gremlin-lang.d.ts +6 -1
  181. package/build/esm/process/gremlin-lang.js +121 -9
  182. package/build/esm/process/gvalue.d.ts +7 -0
  183. package/build/esm/process/gvalue.js +38 -0
  184. package/build/esm/process/transaction.d.ts +50 -14
  185. package/build/esm/process/transaction.js +122 -23
  186. package/build/esm/process/traversal.d.ts +36 -10
  187. package/build/esm/process/traversal.js +104 -47
  188. package/build/esm/structure/PDTRegistry.d.ts +34 -0
  189. package/build/esm/structure/PDTRegistry.js +112 -0
  190. package/build/esm/structure/graph.d.ts +122 -3
  191. package/build/esm/structure/graph.js +347 -7
  192. package/build/esm/structure/io/binary/GraphBinary.d.ts +15 -1
  193. package/build/esm/structure/io/binary/GraphBinary.js +66 -38
  194. package/build/esm/structure/io/binary/internals/AnySerializer.d.ts +12 -2
  195. package/build/esm/structure/io/binary/internals/AnySerializer.js +34 -17
  196. package/build/esm/structure/io/binary/internals/ArraySerializer.d.ts +14 -7
  197. package/build/esm/structure/io/binary/internals/ArraySerializer.js +41 -72
  198. package/build/esm/structure/io/binary/internals/BigIntegerSerializer.d.ts +12 -7
  199. package/build/esm/structure/io/binary/internals/BigIntegerSerializer.js +34 -54
  200. package/build/esm/structure/io/binary/internals/BinarySerializer.d.ts +12 -4
  201. package/build/esm/structure/io/binary/internals/BinarySerializer.js +31 -51
  202. package/build/esm/structure/io/binary/internals/BooleanSerializer.d.ts +12 -4
  203. package/build/esm/structure/io/binary/internals/BooleanSerializer.js +28 -42
  204. package/build/esm/structure/io/binary/internals/ByteSerializer.d.ts +12 -4
  205. package/build/esm/structure/io/binary/internals/ByteSerializer.js +24 -38
  206. package/build/esm/structure/io/binary/internals/CompositePDTSerializer.d.ts +10 -0
  207. package/build/esm/structure/io/binary/internals/CompositePDTSerializer.js +78 -0
  208. package/build/esm/structure/io/binary/internals/DateTimeSerializer.d.ts +12 -7
  209. package/build/esm/structure/io/binary/internals/DateTimeSerializer.js +52 -69
  210. package/build/esm/structure/io/binary/internals/DoubleSerializer.d.ts +12 -4
  211. package/build/esm/structure/io/binary/internals/DoubleSerializer.js +24 -38
  212. package/build/esm/structure/io/binary/internals/EdgeSerializer.d.ts +14 -12
  213. package/build/esm/structure/io/binary/internals/EdgeSerializer.js +69 -124
  214. package/build/esm/structure/io/binary/internals/EnumSerializer.d.ts +19 -4
  215. package/build/esm/structure/io/binary/internals/EnumSerializer.js +47 -59
  216. package/build/esm/structure/io/binary/internals/FloatSerializer.d.ts +12 -4
  217. package/build/esm/structure/io/binary/internals/FloatSerializer.js +24 -38
  218. package/build/esm/structure/io/binary/internals/GraphBinaryReader.d.ts +26 -2
  219. package/build/esm/structure/io/binary/internals/GraphBinaryReader.js +108 -37
  220. package/build/esm/structure/io/binary/internals/GraphBinaryWriter.js +6 -6
  221. package/build/esm/structure/io/binary/internals/GraphSerializer.d.ts +22 -0
  222. package/build/esm/structure/io/binary/internals/GraphSerializer.js +181 -0
  223. package/build/esm/structure/io/binary/internals/IntSerializer.d.ts +19 -4
  224. package/build/esm/structure/io/binary/internals/IntSerializer.js +33 -38
  225. package/build/esm/structure/io/binary/internals/LongSerializer.d.ts +13 -4
  226. package/build/esm/structure/io/binary/internals/LongSerializer.js +29 -42
  227. package/build/esm/structure/io/binary/internals/MapSerializer.d.ts +14 -7
  228. package/build/esm/structure/io/binary/internals/MapSerializer.js +36 -70
  229. package/build/esm/structure/io/binary/internals/MarkerSerializer.d.ts +13 -4
  230. package/build/esm/structure/io/binary/internals/MarkerSerializer.js +29 -33
  231. package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.d.ts +0 -3
  232. package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.js +28 -2
  233. package/build/esm/structure/io/binary/internals/PathSerializer.d.ts +14 -7
  234. package/build/esm/structure/io/binary/internals/PathSerializer.js +30 -55
  235. package/build/esm/structure/io/binary/internals/PrimitivePDTSerializer.d.ts +10 -0
  236. package/build/esm/structure/io/binary/internals/PrimitivePDTSerializer.js +77 -0
  237. package/build/esm/structure/io/binary/internals/PropertySerializer.d.ts +14 -7
  238. package/build/esm/structure/io/binary/internals/PropertySerializer.js +32 -69
  239. package/build/esm/structure/io/binary/internals/SetSerializer.d.ts +14 -7
  240. package/build/esm/structure/io/binary/internals/SetSerializer.js +39 -73
  241. package/build/esm/structure/io/binary/internals/ShortSerializer.d.ts +12 -4
  242. package/build/esm/structure/io/binary/internals/ShortSerializer.js +24 -38
  243. package/build/esm/structure/io/binary/internals/StreamReader.d.ts +69 -0
  244. package/build/esm/structure/io/binary/internals/StreamReader.js +181 -0
  245. package/build/esm/structure/io/binary/internals/StringSerializer.d.ts +14 -4
  246. package/build/esm/structure/io/binary/internals/StringSerializer.js +34 -53
  247. package/build/esm/structure/io/binary/internals/StubSerializer.d.ts +1 -1
  248. package/build/esm/structure/io/binary/internals/StubSerializer.js +2 -1
  249. package/build/esm/structure/io/binary/internals/TreeSerializer.d.ts +54 -0
  250. package/build/esm/structure/io/binary/internals/TreeSerializer.js +136 -0
  251. package/build/esm/structure/io/binary/internals/UnspecifiedNullSerializer.d.ts +6 -4
  252. package/build/esm/structure/io/binary/internals/UnspecifiedNullSerializer.js +8 -31
  253. package/build/esm/structure/io/binary/internals/UuidSerializer.d.ts +12 -7
  254. package/build/esm/structure/io/binary/internals/UuidSerializer.js +33 -49
  255. package/build/esm/structure/io/binary/internals/VertexPropertySerializer.d.ts +14 -7
  256. package/build/esm/structure/io/binary/internals/VertexPropertySerializer.js +37 -95
  257. package/build/esm/structure/io/binary/internals/VertexSerializer.d.ts +14 -9
  258. package/build/esm/structure/io/binary/internals/VertexSerializer.js +41 -68
  259. package/build/esm/utils.d.ts +62 -4
  260. package/build/esm/utils.js +145 -6
  261. package/package.json +27 -18
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const buffer_1 = require("node:buffer");
22
+ const graph_js_1 = require("../../../graph.cjs");
23
+ class PrimitivePDTSerializer {
24
+ constructor(ioc) {
25
+ this.ioc = ioc;
26
+ this.ioc.serializers[ioc.DataType.PRIMITIVEPDT] = this;
27
+ }
28
+ canBeUsedFor(value) {
29
+ return value instanceof graph_js_1.PrimitivePDT;
30
+ }
31
+ serialize(item, fullyQualifiedFormat = true) {
32
+ if (item === undefined || item === null) {
33
+ if (fullyQualifiedFormat) {
34
+ return buffer_1.Buffer.from([this.ioc.DataType.PRIMITIVEPDT, 0x01]);
35
+ }
36
+ const bufs = [];
37
+ bufs.push(this.ioc.stringSerializer.serialize('', false));
38
+ bufs.push(this.ioc.stringSerializer.serialize('', false));
39
+ return buffer_1.Buffer.concat(bufs);
40
+ }
41
+ const bufs = [];
42
+ if (fullyQualifiedFormat) {
43
+ bufs.push(buffer_1.Buffer.from([this.ioc.DataType.PRIMITIVEPDT, 0x00]));
44
+ }
45
+ bufs.push(this.ioc.stringSerializer.serialize(item.name, true));
46
+ bufs.push(this.ioc.stringSerializer.serialize(item.value, true));
47
+ return buffer_1.Buffer.concat(bufs);
48
+ }
49
+ async deserializeValue(reader, valueFlag, typeCode) {
50
+ const name = await this.ioc.anySerializer.deserialize(reader);
51
+ if (!name) {
52
+ throw new Error('PrimitivePDTSerializer: name cannot be null or empty');
53
+ }
54
+ const value = await this.ioc.anySerializer.deserialize(reader);
55
+ const pdt = new graph_js_1.PrimitivePDT(name, value != null ? String(value) : '');
56
+ const pdtRegistry = reader.pdtRegistry;
57
+ if (pdtRegistry) {
58
+ const hydrated = pdtRegistry.hydratePrimitive(pdt);
59
+ if (!(hydrated instanceof graph_js_1.PrimitivePDT)) {
60
+ return hydrated;
61
+ }
62
+ }
63
+ return pdt;
64
+ }
65
+ async deserialize(reader) {
66
+ const type_code = await reader.readUInt8();
67
+ if (type_code !== this.ioc.DataType.PRIMITIVEPDT) {
68
+ throw new Error(`PrimitivePDTSerializer: unexpected {type_code}=0x${type_code.toString(16)}`);
69
+ }
70
+ const value_flag = await reader.readUInt8();
71
+ if (value_flag === 0x01) {
72
+ return null;
73
+ }
74
+ if (value_flag !== 0x00) {
75
+ throw new Error(`PrimitivePDTSerializer: unexpected {value_flag}=0x${value_flag.toString(16)}`);
76
+ }
77
+ return this.deserializeValue(reader, value_flag, type_code);
78
+ }
79
+ }
80
+ exports.default = PrimitivePDTSerializer;
@@ -0,0 +1,10 @@
1
+ export default class PrimitivePDTSerializer {
2
+ constructor(ioc: any);
3
+ ioc: any;
4
+ canBeUsedFor(value: any): value is PrimitivePDT;
5
+ serialize(item: any, fullyQualifiedFormat?: boolean): Buffer<ArrayBuffer>;
6
+ deserializeValue(reader: any, valueFlag: any, typeCode: any): Promise<any>;
7
+ deserialize(reader: any): Promise<any>;
8
+ }
9
+ import { PrimitivePDT } from '../../../graph.cjs';
10
+ import { Buffer } from 'buffer';
@@ -54,77 +54,40 @@ class PropertySerializer {
54
54
  bufs.push(this.ioc.unspecifiedNullSerializer.serialize(null));
55
55
  return buffer_1.Buffer.concat(bufs);
56
56
  }
57
- deserialize(buffer, fullyQualifiedFormat = true) {
58
- let len = 0;
59
- let cursor = buffer;
60
- try {
61
- if (buffer === undefined || buffer === null || !(buffer instanceof buffer_1.Buffer)) {
62
- throw new Error('buffer is missing');
63
- }
64
- if (buffer.length < 1) {
65
- throw new Error('buffer is empty');
66
- }
67
- if (fullyQualifiedFormat) {
68
- const type_code = cursor.readUInt8();
69
- len++;
70
- if (type_code !== this.ioc.DataType.PROPERTY) {
71
- throw new Error('unexpected {type_code}');
72
- }
73
- cursor = cursor.slice(1);
74
- if (cursor.length < 1) {
75
- throw new Error('{value_flag} is missing');
76
- }
77
- const value_flag = cursor.readUInt8();
78
- len++;
79
- if (value_flag === 1) {
80
- return { v: null, len };
81
- }
82
- if (value_flag !== 0) {
83
- throw new Error('unexpected {value_flag}');
84
- }
85
- cursor = cursor.slice(1);
86
- }
87
- // {key} is a String value
88
- let key, key_len;
89
- try {
90
- ({ v: key, len: key_len } = this.ioc.stringSerializer.deserialize(cursor, false));
91
- len += key_len;
92
- }
93
- catch (err) {
94
- err.message = '{key}: ' + err.message;
95
- throw err;
96
- }
97
- cursor = cursor.slice(key_len);
98
- // {value} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value}
99
- let value, value_len;
100
- try {
101
- ({ v: value, len: value_len } = this.ioc.anySerializer.deserialize(cursor));
102
- len += value_len;
103
- }
104
- catch (err) {
105
- err.message = '{value}: ' + err.message;
106
- throw err;
107
- }
108
- cursor = cursor.slice(value_len);
109
- // {parent} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value} which is either an Edge or VertexProperty.
110
- // Note that as TinkerPop currently sends "references" only this value will always be null.
111
- let parent_len;
112
- try {
113
- ({ len: parent_len } = this.ioc.unspecifiedNullSerializer.deserialize(cursor));
114
- len += parent_len;
115
- }
116
- catch (err) {
117
- err.message = '{parent}: ' + err.message;
118
- throw err;
119
- }
120
- // TODO: should we verify that parent is null?
121
- cursor = cursor.slice(parent_len);
122
- const v = new graph_js_1.Property(key, value);
123
- return { v, len };
57
+ /**
58
+ * Async deserialization of property value bytes from a StreamReader.
59
+ * @param {StreamReader} reader
60
+ * @param {number} valueFlag
61
+ * @param {number} typeCode
62
+ * @returns {Promise<Property>}
63
+ */
64
+ async deserializeValue(reader, valueFlag, typeCode) {
65
+ // {key} bare string (length + text_value)
66
+ const key = await this.ioc.stringSerializer.deserializeValue(reader, 0x00, typeCode);
67
+ // {value} fully qualified
68
+ const value = await this.ioc.anySerializer.deserialize(reader);
69
+ // {parent} fully qualified (always null in current TinkerPop)
70
+ await this.ioc.anySerializer.deserialize(reader);
71
+ return new graph_js_1.Property(key, value);
72
+ }
73
+ /**
74
+ * Async fully-qualified deserialization from a StreamReader.
75
+ * @param {StreamReader} reader
76
+ * @returns {Promise<Property|null>}
77
+ */
78
+ async deserialize(reader) {
79
+ const type_code = await reader.readUInt8();
80
+ if (type_code !== this.ioc.DataType.PROPERTY) {
81
+ throw new Error(`PropertySerializer: unexpected {type_code}=0x${type_code.toString(16)}`);
82
+ }
83
+ const value_flag = await reader.readUInt8();
84
+ if (value_flag === 0x01) {
85
+ return null;
124
86
  }
125
- catch (err) {
126
- throw this.ioc.utils.des_error({ serializer: this, args: arguments, cursor, err });
87
+ if (value_flag !== 0x00) {
88
+ throw new Error(`PropertySerializer: unexpected {value_flag}=0x${value_flag.toString(16)}`);
127
89
  }
90
+ return this.deserializeValue(reader, value_flag, type_code);
128
91
  }
129
92
  }
130
93
  exports.default = PropertySerializer;
@@ -3,13 +3,20 @@ export default class PropertySerializer {
3
3
  ioc: any;
4
4
  canBeUsedFor(value: any): value is Property<any>;
5
5
  serialize(item: any, fullyQualifiedFormat?: boolean): Buffer<ArrayBuffer>;
6
- deserialize(buffer: any, fullyQualifiedFormat?: boolean, ...args: any[]): {
7
- v: null;
8
- len: number;
9
- } | {
10
- v: Property<any>;
11
- len: number;
12
- };
6
+ /**
7
+ * Async deserialization of property value bytes from a StreamReader.
8
+ * @param {StreamReader} reader
9
+ * @param {number} valueFlag
10
+ * @param {number} typeCode
11
+ * @returns {Promise<Property>}
12
+ */
13
+ deserializeValue(reader: StreamReader, valueFlag: number, typeCode: number): Promise<Property>;
14
+ /**
15
+ * Async fully-qualified deserialization from a StreamReader.
16
+ * @param {StreamReader} reader
17
+ * @returns {Promise<Property|null>}
18
+ */
19
+ deserialize(reader: StreamReader): Promise<Property | null>;
13
20
  }
14
21
  import { Property } from '../../../graph.cjs';
15
22
  import { Buffer } from 'buffer';
@@ -57,82 +57,48 @@ class SetSerializer {
57
57
  }
58
58
  return buffer_1.Buffer.concat(bufs);
59
59
  }
60
- deserialize(buffer, fullyQualifiedFormat = true) {
61
- let len = 0;
62
- let cursor = buffer;
63
- let isBulked = false;
64
- try {
65
- if (buffer === undefined || buffer === null || !(buffer instanceof buffer_1.Buffer)) {
66
- throw new Error('buffer is missing');
67
- }
68
- if (buffer.length < 1) {
69
- throw new Error('buffer is empty');
70
- }
71
- if (fullyQualifiedFormat) {
72
- const typeCode = cursor.readUInt8();
73
- len++;
74
- if (typeCode !== this.ID) {
75
- throw new Error('unexpected {type_code}');
76
- }
77
- cursor = cursor.slice(1);
78
- if (cursor.length < 1) {
79
- throw new Error('{value_flag} is missing');
80
- }
81
- const valueFlag = cursor.readUInt8();
82
- len++;
83
- if (valueFlag === 1) {
84
- return { v: null, len };
85
- }
86
- if (valueFlag !== 0 && valueFlag !== 2) {
87
- throw new Error('unexpected {value_flag}');
88
- }
89
- isBulked = valueFlag === 2;
90
- cursor = cursor.slice(1);
91
- }
92
- let length, lengthLen;
93
- try {
94
- ({ v: length, len: lengthLen } = this.ioc.intSerializer.deserialize(cursor, false));
95
- len += lengthLen;
96
- }
97
- catch (err) {
98
- err.message = '{length}: ' + err.message;
99
- throw err;
100
- }
101
- if (length < 0) {
102
- throw new Error('{length} is less than zero');
103
- }
104
- cursor = cursor.slice(lengthLen);
105
- const v = new Set();
106
- for (let i = 0; i < length; i++) {
107
- let value, valueLen;
108
- try {
109
- ({ v: value, len: valueLen } = this.ioc.anySerializer.deserialize(cursor));
110
- len += valueLen;
111
- }
112
- catch (err) {
113
- err.message = `{item_${i}}: ` + err.message;
114
- throw err;
115
- }
116
- cursor = cursor.slice(valueLen);
117
- if (isBulked) {
118
- if (cursor.length < 8) {
119
- throw new Error(`{item_${i}}: bulk count is missing`);
120
- }
121
- cursor.readBigInt64BE();
122
- len += 8;
123
- cursor = cursor.slice(8);
124
- // Set.add is idempotent; bulk count only affects cardinality, not Set membership
125
- v.add(value);
126
- }
127
- else {
128
- v.add(value);
129
- }
60
+ /**
61
+ * Async deserialization of set value bytes from a StreamReader.
62
+ * @param {StreamReader} reader
63
+ * @param {number} valueFlag - 0x00 for normal, 0x02 for bulked
64
+ * @param {number} typeCode
65
+ * @returns {Promise<Set>}
66
+ */
67
+ async deserializeValue(reader, valueFlag, typeCode) {
68
+ const isBulked = valueFlag === 0x02;
69
+ const length = await this.ioc.intSerializer.deserializeBare(reader);
70
+ if (length < 0) {
71
+ throw new Error(`SetSerializer: {length}=${length} is less than zero`);
72
+ }
73
+ const v = new Set();
74
+ for (let i = 0; i < length; i++) {
75
+ const value = await this.ioc.anySerializer.deserialize(reader);
76
+ if (isBulked) {
77
+ // consume the bulk count; Set.add is idempotent so count doesn't matter
78
+ await reader.readBigInt64BE();
130
79
  }
131
- return { v, len };
80
+ v.add(value);
81
+ }
82
+ return v;
83
+ }
84
+ /**
85
+ * Async fully-qualified deserialization from a StreamReader.
86
+ * @param {StreamReader} reader
87
+ * @returns {Promise<Set|null>}
88
+ */
89
+ async deserialize(reader) {
90
+ const type_code = await reader.readUInt8();
91
+ if (type_code !== this.ID) {
92
+ throw new Error(`SetSerializer: unexpected {type_code}=0x${type_code.toString(16)}`);
93
+ }
94
+ const value_flag = await reader.readUInt8();
95
+ if (value_flag === 0x01) {
96
+ return null;
132
97
  }
133
- catch (err) {
134
- throw this.ioc.utils.des_error({ serializer: this, args: arguments, cursor, err });
98
+ if (value_flag !== 0x00 && value_flag !== 0x02) {
99
+ throw new Error(`SetSerializer: unexpected {value_flag}=0x${value_flag.toString(16)}`);
135
100
  }
101
+ return this.deserializeValue(reader, value_flag, type_code);
136
102
  }
137
103
  }
138
104
  exports.default = SetSerializer;
@@ -4,12 +4,19 @@ export default class SetSerializer {
4
4
  ID: any;
5
5
  canBeUsedFor(value: any): value is Set<any>;
6
6
  serialize(item: any, fullyQualifiedFormat?: boolean): Buffer<ArrayBuffer>;
7
- deserialize(buffer: any, fullyQualifiedFormat?: boolean, ...args: any[]): {
8
- v: null;
9
- len: number;
10
- } | {
11
- v: Set<any>;
12
- len: number;
13
- };
7
+ /**
8
+ * Async deserialization of set value bytes from a StreamReader.
9
+ * @param {StreamReader} reader
10
+ * @param {number} valueFlag - 0x00 for normal, 0x02 for bulked
11
+ * @param {number} typeCode
12
+ * @returns {Promise<Set>}
13
+ */
14
+ deserializeValue(reader: StreamReader, valueFlag: number, typeCode: number): Promise<Set<any>>;
15
+ /**
16
+ * Async fully-qualified deserialization from a StreamReader.
17
+ * @param {StreamReader} reader
18
+ * @returns {Promise<Set|null>}
19
+ */
20
+ deserialize(reader: StreamReader): Promise<Set<any> | null>;
14
21
  }
15
22
  import { Buffer } from 'buffer';
@@ -46,46 +46,32 @@ class ShortSerializer {
46
46
  bufs.push(v);
47
47
  return buffer_1.Buffer.concat(bufs);
48
48
  }
49
- deserialize(buffer, fullyQualifiedFormat = true) {
50
- let len = 0;
51
- let cursor = buffer;
52
- try {
53
- if (buffer === undefined || buffer === null || !(buffer instanceof buffer_1.Buffer)) {
54
- throw new Error('buffer is missing');
55
- }
56
- if (buffer.length < 1) {
57
- throw new Error('buffer is empty');
58
- }
59
- if (fullyQualifiedFormat) {
60
- const type_code = cursor.readUInt8();
61
- len++;
62
- if (type_code !== this.ioc.DataType.SHORT) {
63
- throw new Error('unexpected {type_code}');
64
- }
65
- cursor = cursor.slice(1);
66
- if (cursor.length < 1) {
67
- throw new Error('{value_flag} is missing');
68
- }
69
- const value_flag = cursor.readUInt8();
70
- len++;
71
- if (value_flag === 1) {
72
- return { v: null, len };
73
- }
74
- if (value_flag !== 0) {
75
- throw new Error('unexpected {value_flag}');
76
- }
77
- cursor = cursor.slice(1);
78
- }
79
- if (cursor.length < 2) {
80
- throw new Error('unexpected {value} length');
81
- }
82
- len += 2;
83
- const v = cursor.readInt16BE();
84
- return { v, len };
49
+ /**
50
+ * @param {StreamReader} reader
51
+ * @param {number} valueFlag
52
+ * @param {number} typeCode
53
+ * @returns {Promise<number>}
54
+ */
55
+ async deserializeValue(reader, valueFlag, typeCode) {
56
+ return await reader.readInt16BE();
57
+ }
58
+ /**
59
+ * @param {StreamReader} reader
60
+ * @returns {Promise<number|null>}
61
+ */
62
+ async deserialize(reader) {
63
+ const type_code = await reader.readUInt8();
64
+ if (type_code !== this.ioc.DataType.SHORT) {
65
+ throw new Error(`ShortSerializer: unexpected {type_code}=0x${type_code.toString(16)}`);
66
+ }
67
+ const value_flag = await reader.readUInt8();
68
+ if (value_flag === 0x01) {
69
+ return null;
85
70
  }
86
- catch (err) {
87
- throw this.ioc.utils.des_error({ serializer: this, args: arguments, cursor, err });
71
+ if (value_flag !== 0x00) {
72
+ throw new Error(`ShortSerializer: unexpected {value_flag}=0x${value_flag.toString(16)}`);
88
73
  }
74
+ return this.deserializeValue(reader, value_flag, type_code);
89
75
  }
90
76
  }
91
77
  exports.default = ShortSerializer;
@@ -3,9 +3,17 @@ export default class ShortSerializer {
3
3
  ioc: any;
4
4
  canBeUsedFor(value: any): void;
5
5
  serialize(item: any, fullyQualifiedFormat?: boolean): Buffer<ArrayBuffer>;
6
- deserialize(buffer: any, fullyQualifiedFormat?: boolean, ...args: any[]): {
7
- v: any;
8
- len: number;
9
- };
6
+ /**
7
+ * @param {StreamReader} reader
8
+ * @param {number} valueFlag
9
+ * @param {number} typeCode
10
+ * @returns {Promise<number>}
11
+ */
12
+ deserializeValue(reader: StreamReader, valueFlag: number, typeCode: number): Promise<number>;
13
+ /**
14
+ * @param {StreamReader} reader
15
+ * @returns {Promise<number|null>}
16
+ */
17
+ deserialize(reader: StreamReader): Promise<number | null>;
10
18
  }
11
19
  import { Buffer } from 'buffer';
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const buffer_1 = require("node:buffer");
22
+ /**
23
+ * Async byte reader that provides a uniform interface over both a complete Buffer
24
+ * (for non-streaming submit()) and a ReadableStream (for streaming HTTP responses).
25
+ *
26
+ * Handles chunk boundaries transparently and blocks (awaits) until the requested bytes are available.
27
+ */
28
+ class StreamReader {
29
+ /** @type {Buffer} */
30
+ #buffer;
31
+ /** @type {number} */
32
+ #offset;
33
+ /** @type {ReadableStreamDefaultReader|null} */
34
+ #reader;
35
+ /** @type {number} Total bytes consumed (monotonically increasing, survives chunk reassembly) */
36
+ #position;
37
+ /**
38
+ * @param {Buffer} initialBuffer
39
+ * @param {ReadableStreamDefaultReader|null} reader
40
+ */
41
+ constructor(initialBuffer, reader) {
42
+ this.#buffer = initialBuffer;
43
+ this.#offset = 0;
44
+ this.#reader = reader;
45
+ this.#position = 0;
46
+ }
47
+ /**
48
+ * Create a StreamReader backed by a complete Buffer.
49
+ * All reads are satisfied from the buffer; no async I/O occurs.
50
+ * @param {Buffer} buffer
51
+ * @returns {StreamReader}
52
+ */
53
+ static fromBuffer(buffer) {
54
+ return new StreamReader(buffer, null);
55
+ }
56
+ /**
57
+ * Create a StreamReader backed by a ReadableStream (e.g. fetch response.body).
58
+ * Reads pull chunks from the stream as needed.
59
+ * @param {ReadableStream} readableStream
60
+ * @returns {StreamReader}
61
+ */
62
+ static fromReadableStream(readableStream) {
63
+ return new StreamReader(buffer_1.Buffer.alloc(0), readableStream.getReader());
64
+ }
65
+ /**
66
+ * Ensure at least `n` bytes are available in the buffer from the current offset.
67
+ * For buffer-backed readers this is a bounds check. For stream-backed readers
68
+ * this pulls chunks until enough data is buffered.
69
+ * @param {number} n
70
+ */
71
+ async #ensure(n) {
72
+ const available = this.#buffer.length - this.#offset;
73
+ if (available >= n) {
74
+ return;
75
+ }
76
+ if (this.#reader === null) {
77
+ throw new Error(`Unexpected end of buffer at position ${this.#position}: needed ${n} bytes, ${available} available`);
78
+ }
79
+ // Collect chunks until we have enough
80
+ const chunks = [this.#buffer.subarray(this.#offset)];
81
+ let total = available;
82
+ while (total < n) {
83
+ const { value, done } = await this.#reader.read();
84
+ if (done) {
85
+ break;
86
+ }
87
+ const chunk = buffer_1.Buffer.isBuffer(value) ? value : buffer_1.Buffer.from(value);
88
+ chunks.push(chunk);
89
+ total += chunk.length;
90
+ }
91
+ if (total < n) {
92
+ throw new Error(`Unexpected end of stream at position ${this.#position}: needed ${n} bytes, ${total} available`);
93
+ }
94
+ this.#buffer = buffer_1.Buffer.concat(chunks);
95
+ this.#offset = 0;
96
+ }
97
+ /**
98
+ * Total number of bytes consumed so far (monotonically increasing).
99
+ * Useful for error diagnostics.
100
+ * @returns {number}
101
+ */
102
+ get position() {
103
+ return this.#position;
104
+ }
105
+ /**
106
+ * Read exactly `n` bytes and return them as a Buffer.
107
+ * @param {number} n
108
+ * @returns {Promise<Buffer>}
109
+ */
110
+ async readBytes(n) {
111
+ await this.#ensure(n);
112
+ const result = this.#buffer.subarray(this.#offset, this.#offset + n);
113
+ this.#offset += n;
114
+ this.#position += n;
115
+ return result;
116
+ }
117
+ /**
118
+ * @returns {Promise<number>} unsigned 8-bit integer
119
+ */
120
+ async readUInt8() {
121
+ await this.#ensure(1);
122
+ this.#position++;
123
+ return this.#buffer[this.#offset++];
124
+ }
125
+ /**
126
+ * @returns {Promise<number>} signed 8-bit integer
127
+ */
128
+ async readByte() {
129
+ await this.#ensure(1);
130
+ this.#position++;
131
+ return this.#buffer.readInt8(this.#offset++);
132
+ }
133
+ /**
134
+ * @returns {Promise<number>} signed 16-bit big-endian integer
135
+ */
136
+ async readInt16BE() {
137
+ await this.#ensure(2);
138
+ const v = this.#buffer.readInt16BE(this.#offset);
139
+ this.#offset += 2;
140
+ this.#position += 2;
141
+ return v;
142
+ }
143
+ /**
144
+ * @returns {Promise<number>} signed 32-bit big-endian integer
145
+ */
146
+ async readInt32BE() {
147
+ await this.#ensure(4);
148
+ const v = this.#buffer.readInt32BE(this.#offset);
149
+ this.#offset += 4;
150
+ this.#position += 4;
151
+ return v;
152
+ }
153
+ /**
154
+ * @returns {Promise<bigint>} signed 64-bit big-endian integer
155
+ */
156
+ async readBigInt64BE() {
157
+ await this.#ensure(8);
158
+ const v = this.#buffer.readBigInt64BE(this.#offset);
159
+ this.#offset += 8;
160
+ this.#position += 8;
161
+ return v;
162
+ }
163
+ /**
164
+ * @returns {Promise<number>} 32-bit big-endian float
165
+ */
166
+ async readFloatBE() {
167
+ await this.#ensure(4);
168
+ const v = this.#buffer.readFloatBE(this.#offset);
169
+ this.#offset += 4;
170
+ this.#position += 4;
171
+ return v;
172
+ }
173
+ /**
174
+ * @returns {Promise<number>} 64-bit big-endian double
175
+ */
176
+ async readDoubleBE() {
177
+ await this.#ensure(8);
178
+ const v = this.#buffer.readDoubleBE(this.#offset);
179
+ this.#offset += 8;
180
+ this.#position += 8;
181
+ return v;
182
+ }
183
+ }
184
+ exports.default = StreamReader;