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
@@ -20,17 +20,34 @@
20
20
  * @author Igor Ostapenko
21
21
  */
22
22
  import { Buffer } from 'buffer';
23
+ import StreamReader from './StreamReader.js';
24
+ import { END_OF_STREAM } from './MarkerSerializer.js';
25
+ import { Traverser } from '../../../../process/traversal.js';
26
+ import ResponseError from '../../../../driver/response-error.js';
27
+ /** GraphBinary response status codes. */
28
+ const StatusCode = {
29
+ SUCCESS: 200,
30
+ NO_CONTENT: 204,
31
+ PARTIAL_CONTENT: 206,
32
+ };
23
33
  /**
24
34
  * GraphBinary reader.
25
35
  */
26
36
  export default class GraphBinaryReader {
27
37
  constructor(ioc) {
28
38
  this.ioc = ioc;
39
+ this.pdtRegistry = null;
29
40
  }
30
41
  get mimeType() {
31
42
  return 'application/vnd.graphbinary-v4.0';
32
43
  }
33
- readResponse(buffer) {
44
+ /**
45
+ * Read a complete response from a Buffer. Used by the non-streaming submit() path.
46
+ * Returns the full { status, result } object after reading all data.
47
+ * @param {Buffer} buffer
48
+ * @returns {Promise<{status: {code, message, exception}, result: {data: any[], bulked: boolean}}>}
49
+ */
50
+ async readResponse(buffer) {
34
51
  if (buffer === undefined || buffer === null) {
35
52
  throw new Error('Buffer is missing.');
36
53
  }
@@ -40,55 +57,109 @@ export default class GraphBinaryReader {
40
57
  if (buffer.length < 1) {
41
58
  throw new Error('Buffer is empty.');
42
59
  }
43
- let cursor = buffer;
44
- let len;
45
- // {version} is a Byte representing the protocol version
46
- const version = cursor[0];
60
+ const reader = StreamReader.fromBuffer(buffer);
61
+ reader.pdtRegistry = this.pdtRegistry;
62
+ return await this.#readFromReader(reader);
63
+ }
64
+ /**
65
+ * Stream results from a StreamReader, yielding each value as it's deserialized.
66
+ * Used by the streaming Connection.stream() path.
67
+ *
68
+ * Note: In the GraphBinary v4 streaming protocol, the status (including error codes)
69
+ * is sent *after* all result data. This means values are yielded to the consumer as
70
+ * they arrive, and a server error is only thrown after all values have been yielded.
71
+ * Consumers should be aware that partial results may have been processed before a
72
+ * ResponseError is thrown.
73
+ *
74
+ * @param {StreamReader} reader
75
+ * @returns {AsyncGenerator<any>}
76
+ */
77
+ async *readResponseStream(reader) {
78
+ reader.pdtRegistry = this.pdtRegistry;
79
+ // {version}
80
+ const version = await reader.readUInt8();
47
81
  if (version !== 0x84) {
48
82
  throw new Error(`Unsupported version '${version}'.`);
49
83
  }
50
- cursor = cursor.slice(1); // skip version
51
- // {bulked} is a Byte: 0x00 = not bulked, 0x01 = bulked
52
- const bulked = cursor[0] === 0x01;
53
- cursor = cursor.slice(1);
54
- // {result_data} stream - read values until marker
55
- const data = [];
56
- while (cursor[0] !== 0xfd) {
57
- const { v, len: valueLen } = this.ioc.anySerializer.deserialize(cursor);
58
- cursor = cursor.slice(valueLen);
84
+ // {bulked}
85
+ const bulked = (await reader.readUInt8()) === 0x01;
86
+ // {result_data} stream — yield values until EndOfStream marker
87
+ while (true) {
88
+ const value = await this.ioc.anySerializer.deserialize(reader);
89
+ if (value === END_OF_STREAM) {
90
+ break;
91
+ }
59
92
  if (bulked) {
60
- const { v: bulk, len: bulkLen } = this.ioc.longSerializer.deserialize(cursor, true);
61
- cursor = cursor.slice(bulkLen);
62
- data.push({ v, bulk: Number(bulk) });
93
+ const bulk = await this.ioc.longSerializer.deserialize(reader);
94
+ yield new Traverser(value, Number(bulk));
63
95
  }
64
96
  else {
65
- data.push(v);
97
+ yield value;
66
98
  }
67
99
  }
68
- // Skip marker [0xFD, 0x00, 0x00]
69
- cursor = cursor.slice(3);
70
- // {status_code} is an Int bare
71
- const { v: code, len: codeLen } = this.ioc.intSerializer.deserialize(cursor, false);
72
- cursor = cursor.slice(codeLen);
73
- // {status_message} is nullable
74
- let message = null;
75
- if (cursor[0] === 0x00) {
76
- cursor = cursor.slice(1);
77
- ({ v: message, len } = this.ioc.stringSerializer.deserialize(cursor, false));
78
- cursor = cursor.slice(len);
100
+ // {status_code} {status_message} {exception}
101
+ const status = await this.#readStatus(reader);
102
+ if (status.code &&
103
+ status.code !== StatusCode.SUCCESS &&
104
+ status.code !== StatusCode.NO_CONTENT &&
105
+ status.code !== StatusCode.PARTIAL_CONTENT) {
106
+ throw new ResponseError(`Server error: ${status.message || 'Unknown error'} (${status.code})`, {
107
+ code: status.code,
108
+ message: status.message || '',
109
+ exception: status.exception,
110
+ });
79
111
  }
80
- else {
81
- cursor = cursor.slice(1); // skip 0x01 null flag
112
+ // Attach status to the generator's return value
113
+ return status;
114
+ }
115
+ /**
116
+ * Internal: read the full response into a collected result (non-streaming).
117
+ */
118
+ async #readFromReader(reader) {
119
+ // {version}
120
+ const version = await reader.readUInt8();
121
+ if (version !== 0x84) {
122
+ throw new Error(`Unsupported version '${version}'.`);
82
123
  }
83
- // {exception} is nullable
84
- let exception = null;
85
- if (cursor[0] === 0x00) {
86
- cursor = cursor.slice(1);
87
- ({ v: exception } = this.ioc.stringSerializer.deserialize(cursor, false));
124
+ // {bulked}
125
+ const bulked = (await reader.readUInt8()) === 0x01;
126
+ // {result_data} — collect all values
127
+ const data = [];
128
+ while (true) {
129
+ const value = await this.ioc.anySerializer.deserialize(reader);
130
+ if (value === END_OF_STREAM) {
131
+ break;
132
+ }
133
+ if (bulked) {
134
+ const bulk = await this.ioc.longSerializer.deserialize(reader);
135
+ data.push({ v: value, bulk: Number(bulk) });
136
+ }
137
+ else {
138
+ data.push(value);
139
+ }
88
140
  }
141
+ // {status}
142
+ const status = await this.#readStatus(reader);
89
143
  return {
90
- status: { code, message, exception },
144
+ status,
91
145
  result: { data, bulked },
92
146
  };
93
147
  }
148
+ /**
149
+ * Read the status block: {code:Int bare}{message:nullable String}{exception:nullable String}
150
+ */
151
+ async #readStatus(reader) {
152
+ const code = await reader.readInt32BE();
153
+ let message = null;
154
+ const msgFlag = await reader.readUInt8();
155
+ if (msgFlag === 0x00) {
156
+ message = await this.ioc.stringSerializer.deserializeValue(reader, 0x00, this.ioc.DataType.STRING);
157
+ }
158
+ let exception = null;
159
+ const excFlag = await reader.readUInt8();
160
+ if (excFlag === 0x00) {
161
+ exception = await this.ioc.stringSerializer.deserializeValue(reader, 0x00, this.ioc.DataType.STRING);
162
+ }
163
+ return { code, message, exception };
164
+ }
94
165
  }
@@ -42,13 +42,13 @@ export default class GraphBinaryWriter {
42
42
  if (g) {
43
43
  fields.set('g', g);
44
44
  }
45
- const bindings = requestMessage.getBindings();
46
- if (bindings && Object.keys(bindings).length > 0) {
47
- fields.set('bindings', bindings);
45
+ const parameters = requestMessage.getParameters();
46
+ if (parameters && Object.keys(parameters).length > 0) {
47
+ fields.set('parameters', parameters);
48
48
  }
49
- const timeoutMs = requestMessage.getTimeoutMs();
50
- if (timeoutMs !== undefined) {
51
- fields.set('timeoutMs', timeoutMs);
49
+ const timeoutMillis = requestMessage.getTimeoutMillis();
50
+ if (timeoutMillis !== undefined) {
51
+ fields.set('timeoutMillis', timeoutMillis);
52
52
  }
53
53
  const materializeProperties = requestMessage.getMaterializeProperties();
54
54
  if (materializeProperties) {
@@ -0,0 +1,22 @@
1
+ export default class GraphSerializer {
2
+ constructor(ioc: any);
3
+ ioc: any;
4
+ canBeUsedFor(value: any): value is Graph;
5
+ serialize(item: any, fullyQualifiedFormat?: boolean): Buffer<ArrayBuffer>;
6
+ /**
7
+ * Async deserialization of graph value bytes from a StreamReader.
8
+ * @param {StreamReader} reader
9
+ * @param {number} valueFlag
10
+ * @param {number} typeCode
11
+ * @returns {Promise<Graph>}
12
+ */
13
+ deserializeValue(reader: StreamReader, valueFlag: number, typeCode: number): Promise<Graph>;
14
+ /**
15
+ * Async fully-qualified deserialization from a StreamReader.
16
+ * @param {StreamReader} reader
17
+ * @returns {Promise<Graph|null>}
18
+ */
19
+ deserialize(reader: StreamReader): Promise<Graph | null>;
20
+ }
21
+ import { Graph } from '../../../graph.js';
22
+ import { Buffer } from 'buffer';
@@ -0,0 +1,181 @@
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
+ import { Buffer } from 'buffer';
20
+ import { Graph, Vertex, Edge, VertexProperty } from '../../../graph.js';
21
+ export default class GraphSerializer {
22
+ constructor(ioc) {
23
+ this.ioc = ioc;
24
+ this.ioc.serializers[ioc.DataType.GRAPH] = this;
25
+ }
26
+ canBeUsedFor(value) {
27
+ return value instanceof Graph;
28
+ }
29
+ serialize(item, fullyQualifiedFormat = true) {
30
+ if (item === undefined || item === null) {
31
+ if (fullyQualifiedFormat) {
32
+ return Buffer.from([this.ioc.DataType.GRAPH, 0x01]);
33
+ }
34
+ // value-only null fallback: zero vertices + zero edges
35
+ const zeroInt = [0x00, 0x00, 0x00, 0x00];
36
+ return Buffer.from([...zeroInt, ...zeroInt]);
37
+ }
38
+ const bufs = [];
39
+ if (fullyQualifiedFormat) {
40
+ bufs.push(Buffer.from([this.ioc.DataType.GRAPH, 0x00]));
41
+ }
42
+ const vertices = item.vertices ? Array.from(item.vertices.values()) : [];
43
+ const edges = item.edges ? Array.from(item.edges.values()) : [];
44
+ // {vertex_count}
45
+ bufs.push(this.ioc.intSerializer.serialize(vertices.length, false));
46
+ // vertices
47
+ for (const v of vertices) {
48
+ // {id}
49
+ bufs.push(this.ioc.anySerializer.serialize(v.id));
50
+ // {label} as list (value-only)
51
+ const vLabels = v.labels instanceof Set ? Array.from(v.labels) : [v.label];
52
+ bufs.push(this.ioc.listSerializer.serialize(vLabels, false));
53
+ const vps = Array.isArray(v.properties) ? v.properties : [];
54
+ // {vp_count}
55
+ bufs.push(this.ioc.intSerializer.serialize(vps.length, false));
56
+ for (const vp of vps) {
57
+ // {vp_id}
58
+ bufs.push(this.ioc.anySerializer.serialize(vp.id));
59
+ // {vp_label} as 1-element list (value-only)
60
+ bufs.push(this.ioc.listSerializer.serialize([vp.label], false));
61
+ // {vp_value}
62
+ bufs.push(this.ioc.anySerializer.serialize(vp.value));
63
+ // {parent} (always null)
64
+ bufs.push(this.ioc.unspecifiedNullSerializer.serialize(null));
65
+ // {meta_props} as value-only List<Property>
66
+ const metaProps = Array.isArray(vp.properties) ? vp.properties : [];
67
+ bufs.push(this.ioc.listSerializer.serialize(metaProps, false));
68
+ }
69
+ }
70
+ // {edge_count}
71
+ bufs.push(this.ioc.intSerializer.serialize(edges.length, false));
72
+ // edges
73
+ for (const e of edges) {
74
+ // {id}
75
+ bufs.push(this.ioc.anySerializer.serialize(e.id));
76
+ // {label} as list (value-only)
77
+ const eLabels = e.labels instanceof Set ? Array.from(e.labels) : [e.label];
78
+ bufs.push(this.ioc.listSerializer.serialize(eLabels, false));
79
+ // {inV_id}
80
+ bufs.push(this.ioc.anySerializer.serialize(e.inV && e.inV.id));
81
+ // {inV_label} (always null placeholder, fully-qualified)
82
+ bufs.push(this.ioc.unspecifiedNullSerializer.serialize(null));
83
+ // {outV_id}
84
+ bufs.push(this.ioc.anySerializer.serialize(e.outV && e.outV.id));
85
+ // {outV_label} (always null placeholder, fully-qualified)
86
+ bufs.push(this.ioc.unspecifiedNullSerializer.serialize(null));
87
+ // {parent} (always null)
88
+ bufs.push(this.ioc.unspecifiedNullSerializer.serialize(null));
89
+ // {edge_props} as value-only List<Property>
90
+ const props = Array.isArray(e.properties) ? e.properties : [];
91
+ bufs.push(this.ioc.listSerializer.serialize(props, false));
92
+ }
93
+ return Buffer.concat(bufs);
94
+ }
95
+ /**
96
+ * Async deserialization of graph value bytes from a StreamReader.
97
+ * @param {StreamReader} reader
98
+ * @param {number} valueFlag
99
+ * @param {number} typeCode
100
+ * @returns {Promise<Graph>}
101
+ */
102
+ async deserializeValue(reader, valueFlag, typeCode) {
103
+ const graph = new Graph();
104
+ // {vertex_count} bare int
105
+ const vertexCount = await this.ioc.intSerializer.deserializeBare(reader);
106
+ for (let i = 0; i < vertexCount; i++) {
107
+ // {id} fully qualified
108
+ const vId = await this.ioc.anySerializer.deserialize(reader);
109
+ // {label} value-only list - full multi-label list
110
+ const vLabelList = await this.ioc.listSerializer.deserializeValue(reader, 0x00, this.ioc.DataType.LIST);
111
+ const vLabels = Array.isArray(vLabelList) ? vLabelList : vLabelList ? [vLabelList] : [];
112
+ const vLabel = vLabels.length > 0 ? vLabels[0] : 'vertex';
113
+ const vertex = new Vertex(vId, vLabel, [], vLabels);
114
+ graph.vertices.set(vId, vertex);
115
+ // {vp_count} bare int
116
+ const vpCount = await this.ioc.intSerializer.deserializeBare(reader);
117
+ for (let j = 0; j < vpCount; j++) {
118
+ // {vp_id} fully qualified
119
+ const vpId = await this.ioc.anySerializer.deserialize(reader);
120
+ // {vp_label} value-only list, first element
121
+ const vpLabelList = await this.ioc.listSerializer.deserializeValue(reader, 0x00, this.ioc.DataType.LIST);
122
+ const vpLabel = Array.isArray(vpLabelList) && vpLabelList.length > 0 ? vpLabelList[0] : vpLabelList;
123
+ // {vp_value} fully qualified
124
+ const vpValue = await this.ioc.anySerializer.deserialize(reader);
125
+ // {parent} fully qualified (always null)
126
+ await this.ioc.anySerializer.deserialize(reader);
127
+ // {meta_props} value-only list
128
+ const metaProps = await this.ioc.listSerializer.deserializeValue(reader, 0x00, this.ioc.DataType.LIST);
129
+ const vp = new VertexProperty(vpId, vpLabel, vpValue, metaProps || []);
130
+ vertex.properties.push(vp);
131
+ }
132
+ }
133
+ // {edge_count} bare int
134
+ const edgeCount = await this.ioc.intSerializer.deserializeBare(reader);
135
+ for (let i = 0; i < edgeCount; i++) {
136
+ // {id} fully qualified
137
+ const eId = await this.ioc.anySerializer.deserialize(reader);
138
+ // {label} value-only list - full multi-label list
139
+ const eLabelList = await this.ioc.listSerializer.deserializeValue(reader, 0x00, this.ioc.DataType.LIST);
140
+ const eLabels = Array.isArray(eLabelList) ? eLabelList : eLabelList ? [eLabelList] : [];
141
+ const eLabel = eLabels.length > 0 ? eLabels[0] : 'edge';
142
+ // {inV_id} fully qualified
143
+ const inVId = await this.ioc.anySerializer.deserialize(reader);
144
+ // {inV_label} fully qualified (always null placeholder) — discard
145
+ await this.ioc.anySerializer.deserialize(reader);
146
+ // {outV_id} fully qualified
147
+ const outVId = await this.ioc.anySerializer.deserialize(reader);
148
+ // {outV_label} fully qualified (always null placeholder) — discard
149
+ await this.ioc.anySerializer.deserialize(reader);
150
+ // {parent} fully qualified (always null) — discard
151
+ await this.ioc.anySerializer.deserialize(reader);
152
+ // {edge_props} value-only list
153
+ const edgeProps = await this.ioc.listSerializer.deserializeValue(reader, 0x00, this.ioc.DataType.LIST);
154
+ // Reuse vertex instances already in graph.vertices, otherwise build stand-ins
155
+ const inV = graph.vertices.get(inVId) || new Vertex(inVId, '', []);
156
+ const outV = graph.vertices.get(outVId) || new Vertex(outVId, '', []);
157
+ const edge = new Edge(eId, outV, eLabel, inV, edgeProps || [], eLabels);
158
+ graph.edges.set(eId, edge);
159
+ }
160
+ return graph;
161
+ }
162
+ /**
163
+ * Async fully-qualified deserialization from a StreamReader.
164
+ * @param {StreamReader} reader
165
+ * @returns {Promise<Graph|null>}
166
+ */
167
+ async deserialize(reader) {
168
+ const type_code = await reader.readUInt8();
169
+ if (type_code !== this.ioc.DataType.GRAPH) {
170
+ throw new Error(`GraphSerializer: unexpected {type_code}=0x${type_code.toString(16)}`);
171
+ }
172
+ const value_flag = await reader.readUInt8();
173
+ if (value_flag === 0x01) {
174
+ return null;
175
+ }
176
+ if (value_flag !== 0x00) {
177
+ throw new Error(`GraphSerializer: unexpected {value_flag}=0x${value_flag.toString(16)}`);
178
+ }
179
+ return this.deserializeValue(reader, value_flag, type_code);
180
+ }
181
+ }
@@ -5,9 +5,24 @@ export default class IntSerializer {
5
5
  ioc: any;
6
6
  canBeUsedFor(value: any): boolean;
7
7
  serialize(item: any, fullyQualifiedFormat?: boolean): Buffer<ArrayBuffer>;
8
- deserialize(buffer: any, fullyQualifiedFormat?: boolean, ...args: any[]): {
9
- v: any;
10
- len: number;
11
- };
8
+ /**
9
+ * Read a bare int32 value from the StreamReader (no type_code or value_flag).
10
+ * @param {StreamReader} reader
11
+ * @returns {Promise<number>}
12
+ */
13
+ deserializeBare(reader: StreamReader): Promise<number>;
14
+ /**
15
+ * @param {StreamReader} reader
16
+ * @param {number} valueFlag - already consumed by AnySerializer
17
+ * @param {number} typeCode
18
+ * @returns {Promise<number>}
19
+ */
20
+ deserializeValue(reader: StreamReader, valueFlag: number, typeCode: number): Promise<number>;
21
+ /**
22
+ * Read a fully-qualified int from the StreamReader (type_code + value_flag + value).
23
+ * @param {StreamReader} reader
24
+ * @returns {Promise<number|null>}
25
+ */
26
+ deserialize(reader: StreamReader): Promise<number | null>;
12
27
  }
13
28
  import { Buffer } from 'buffer';
@@ -56,45 +56,40 @@ export default class IntSerializer {
56
56
  bufs.push(v);
57
57
  return Buffer.concat(bufs);
58
58
  }
59
- deserialize(buffer, fullyQualifiedFormat = true) {
60
- let len = 0;
61
- let cursor = buffer;
62
- try {
63
- if (buffer === undefined || buffer === null || !(buffer instanceof Buffer)) {
64
- throw new Error('buffer is missing');
65
- }
66
- if (buffer.length < 1) {
67
- throw new Error('buffer is empty');
68
- }
69
- if (fullyQualifiedFormat) {
70
- const type_code = cursor.readUInt8();
71
- len++;
72
- if (type_code !== this.ioc.DataType.INT) {
73
- throw new Error('unexpected {type_code}');
74
- }
75
- cursor = cursor.slice(1);
76
- if (cursor.length < 1) {
77
- throw new Error('{value_flag} is missing');
78
- }
79
- const value_flag = cursor.readUInt8();
80
- len++;
81
- if (value_flag === 1) {
82
- return { v: null, len };
83
- }
84
- if (value_flag !== 0) {
85
- throw new Error('unexpected {value_flag}');
86
- }
87
- cursor = cursor.slice(1);
88
- }
89
- if (cursor.length < 4) {
90
- throw new Error('unexpected {value} length');
91
- }
92
- len += 4;
93
- const v = cursor.readInt32BE();
94
- return { v, len };
59
+ /**
60
+ * Read a bare int32 value from the StreamReader (no type_code or value_flag).
61
+ * @param {StreamReader} reader
62
+ * @returns {Promise<number>}
63
+ */
64
+ async deserializeBare(reader) {
65
+ return await reader.readInt32BE();
66
+ }
67
+ /**
68
+ * @param {StreamReader} reader
69
+ * @param {number} valueFlag - already consumed by AnySerializer
70
+ * @param {number} typeCode
71
+ * @returns {Promise<number>}
72
+ */
73
+ async deserializeValue(reader, valueFlag, typeCode) {
74
+ return await reader.readInt32BE();
75
+ }
76
+ /**
77
+ * Read a fully-qualified int from the StreamReader (type_code + value_flag + value).
78
+ * @param {StreamReader} reader
79
+ * @returns {Promise<number|null>}
80
+ */
81
+ async deserialize(reader) {
82
+ const type_code = await reader.readUInt8();
83
+ if (type_code !== this.ioc.DataType.INT) {
84
+ throw new Error(`IntSerializer: unexpected {type_code}=0x${type_code.toString(16)}`);
85
+ }
86
+ const value_flag = await reader.readUInt8();
87
+ if (value_flag === 0x01) {
88
+ return null;
95
89
  }
96
- catch (err) {
97
- throw this.ioc.utils.des_error({ serializer: this, args: arguments, cursor, err });
90
+ if (value_flag !== 0x00) {
91
+ throw new Error(`IntSerializer: unexpected {value_flag}=0x${value_flag.toString(16)}`);
98
92
  }
93
+ return this.deserializeValue(reader, value_flag, type_code);
99
94
  }
100
95
  }
@@ -3,9 +3,18 @@ export default class LongSerializer {
3
3
  ioc: any;
4
4
  canBeUsedFor(): 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 - already consumed by AnySerializer
9
+ * @param {number} typeCode
10
+ * @returns {Promise<number|bigint>}
11
+ */
12
+ deserializeValue(reader: StreamReader, valueFlag: number, typeCode: number): Promise<number | bigint>;
13
+ /**
14
+ * Read a fully-qualified long from the StreamReader.
15
+ * @param {StreamReader} reader
16
+ * @returns {Promise<number|bigint|null>}
17
+ */
18
+ deserialize(reader: StreamReader): Promise<number | bigint | null>;
10
19
  }
11
20
  import { Buffer } from 'buffer';
@@ -44,49 +44,36 @@ export default class LongSerializer {
44
44
  bufs.push(v);
45
45
  return Buffer.concat(bufs);
46
46
  }
47
- deserialize(buffer, fullyQualifiedFormat = true) {
48
- let len = 0;
49
- let cursor = buffer;
50
- try {
51
- if (buffer === undefined || buffer === null || !(buffer instanceof Buffer)) {
52
- throw new Error('buffer is missing');
53
- }
54
- if (buffer.length < 1) {
55
- throw new Error('buffer is empty');
56
- }
57
- if (fullyQualifiedFormat) {
58
- const type_code = cursor.readUInt8();
59
- len++;
60
- if (type_code !== this.ioc.DataType.LONG) {
61
- throw new Error('unexpected {type_code}');
62
- }
63
- cursor = cursor.slice(1);
64
- if (cursor.length < 1) {
65
- throw new Error('{value_flag} is missing');
66
- }
67
- const value_flag = cursor.readUInt8();
68
- len++;
69
- if (value_flag === 1) {
70
- return { v: null, len };
71
- }
72
- if (value_flag !== 0) {
73
- throw new Error('unexpected {value_flag}');
74
- }
75
- cursor = cursor.slice(1);
76
- }
77
- if (cursor.length < 8) {
78
- throw new Error('unexpected {value} length');
79
- }
80
- len += 8;
81
- let v = cursor.readBigInt64BE();
82
- if (v >= Number.MIN_SAFE_INTEGER && v <= Number.MAX_SAFE_INTEGER) {
83
- v = Number(v);
84
- }
85
- // Values outside safe integer range stay as BigInt to preserve precision.
86
- return { v, len };
47
+ /**
48
+ * @param {StreamReader} reader
49
+ * @param {number} valueFlag - already consumed by AnySerializer
50
+ * @param {number} typeCode
51
+ * @returns {Promise<number|bigint>}
52
+ */
53
+ async deserializeValue(reader, valueFlag, typeCode) {
54
+ let v = await reader.readBigInt64BE();
55
+ if (v >= Number.MIN_SAFE_INTEGER && v <= Number.MAX_SAFE_INTEGER) {
56
+ v = Number(v);
57
+ }
58
+ return v;
59
+ }
60
+ /**
61
+ * Read a fully-qualified long from the StreamReader.
62
+ * @param {StreamReader} reader
63
+ * @returns {Promise<number|bigint|null>}
64
+ */
65
+ async deserialize(reader) {
66
+ const type_code = await reader.readUInt8();
67
+ if (type_code !== this.ioc.DataType.LONG) {
68
+ throw new Error(`LongSerializer: unexpected {type_code}=0x${type_code.toString(16)}`);
69
+ }
70
+ const value_flag = await reader.readUInt8();
71
+ if (value_flag === 0x01) {
72
+ return null;
87
73
  }
88
- catch (err) {
89
- throw this.ioc.utils.des_error({ serializer: this, args: arguments, cursor, err });
74
+ if (value_flag !== 0x00) {
75
+ throw new Error(`LongSerializer: unexpected {value_flag}=0x${value_flag.toString(16)}`);
90
76
  }
77
+ return this.deserializeValue(reader, value_flag, type_code);
91
78
  }
92
79
  }
@@ -3,11 +3,18 @@ export default class MapSerializer {
3
3
  ioc: any;
4
4
  canBeUsedFor(value: any): boolean;
5
5
  serialize(item: any, fullyQualifiedFormat?: boolean): any;
6
- deserialize(buffer: any, fullyQualifiedFormat?: boolean, ...args: any[]): {
7
- v: null;
8
- len: number;
9
- } | {
10
- v: Map<any, any>;
11
- len: number;
12
- };
6
+ /**
7
+ * Async deserialization of map value bytes from a StreamReader.
8
+ * @param {StreamReader} reader
9
+ * @param {number} valueFlag
10
+ * @param {number} typeCode
11
+ * @returns {Promise<Map>}
12
+ */
13
+ deserializeValue(reader: StreamReader, valueFlag: number, typeCode: number): Promise<Map<any, any>>;
14
+ /**
15
+ * Async fully-qualified deserialization from a StreamReader.
16
+ * @param {StreamReader} reader
17
+ * @returns {Promise<Map|null>}
18
+ */
19
+ deserialize(reader: StreamReader): Promise<Map<any, any> | null>;
13
20
  }