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
@@ -21,31 +21,40 @@
21
21
  */
22
22
  import { Buffer } from 'buffer';
23
23
  import { EventEmitter } from 'eventemitter3';
24
- import ioc from '../structure/io/binary/GraphBinary.js';
24
+ import ioc, { createPreciseReader } from '../structure/io/binary/GraphBinary.js';
25
+ import GraphBinaryReader from '../structure/io/binary/internals/GraphBinaryReader.js';
26
+ import StreamReader from '../structure/io/binary/internals/StreamReader.js';
25
27
  import * as utils from '../utils.js';
26
28
  import ResultSet from './result-set.js';
29
+ import { RequestMessage } from "./request-message.js";
30
+ import { HttpRequest } from './http-request.js';
27
31
  import ResponseError from './response-error.js';
28
32
  import { Traverser } from '../process/traversal.js';
29
- const { DeferredPromise } = utils;
30
- const { graphBinaryReader, graphBinaryWriter } = ioc;
33
+ import { buildDispatcher, httpFetch } from './dispatcher.js';
34
+ import { normalizeLogger } from './logger.js';
31
35
  const responseStatusCode = {
32
36
  success: 200,
33
37
  noContent: 204,
34
38
  partialContent: 206,
35
- authenticationChallenge: 407,
36
39
  };
40
+ /** The default per-request batch size used when neither the request nor the connection sets one. */
41
+ export const DEFAULT_BATCH_SIZE = 64;
37
42
  /**
38
43
  * Represents a single connection to a Gremlin Server.
39
44
  */
40
45
  export default class Connection extends EventEmitter {
41
46
  url;
42
47
  options;
43
- _reader;
44
- _writer;
48
+ _responseSerializer;
45
49
  isOpen = true;
46
50
  traversalSource;
47
51
  _enableUserAgentOnConnect;
48
52
  _interceptors;
53
+ _dispatcher;
54
+ _compression;
55
+ _batchSize;
56
+ _bulkResults;
57
+ _log;
49
58
  /**
50
59
  * Creates a new instance of {@link Connection}.
51
60
  * @param {String} url The resource uri.
@@ -55,16 +64,41 @@ export default class Connection extends EventEmitter {
55
64
  super();
56
65
  this.url = url;
57
66
  this.options = options;
58
- this._reader = options.reader || graphBinaryReader;
59
- this._writer = 'writer' in options ? options.writer : graphBinaryWriter;
67
+ this._responseSerializer =
68
+ options.responseSerializer || (options.preciseNumbers === true ? createPreciseReader() : new GraphBinaryReader(ioc));
69
+ if (options.pdtRegistry) {
70
+ this._responseSerializer.pdtRegistry = options.pdtRegistry;
71
+ }
60
72
  this.traversalSource = options.traversalSource || 'g';
61
73
  this._enableUserAgentOnConnect = options.enableUserAgentOnConnect !== false;
74
+ this._log = normalizeLogger(options.logger);
75
+ if (options.compression === undefined) {
76
+ this._compression = 'deflate';
77
+ }
78
+ else if (options.compression === 'none' || options.compression === 'deflate') {
79
+ this._compression = options.compression;
80
+ }
81
+ else {
82
+ throw new TypeError(`compression must be 'none' or 'deflate'`);
83
+ }
84
+ this._batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;
85
+ this._bulkResults = options.bulkResults ?? false;
86
+ // The driver builds and owns the undici dispatcher from the discrete options.
87
+ // TLS is configured through the Node/undici runtime (e.g. NODE_EXTRA_CA_CERTS),
88
+ // not through a driver option.
89
+ this._dispatcher = buildDispatcher({
90
+ maxConnections: options.maxConnections,
91
+ readTimeoutMillis: options.readTimeoutMillis,
92
+ maxResponseHeaderBytes: options.maxResponseHeaderBytes,
93
+ keepAliveTimeMillis: options.keepAliveTimeMillis,
94
+ proxy: options.proxy,
95
+ });
62
96
  const interceptors = options.interceptors;
63
97
  if (typeof interceptors === 'function') {
64
98
  this._interceptors = [interceptors];
65
99
  }
66
100
  else if (Array.isArray(interceptors)) {
67
- this._interceptors = interceptors;
101
+ this._interceptors = [...interceptors];
68
102
  }
69
103
  else if (interceptors === undefined || interceptors === null) {
70
104
  this._interceptors = [];
@@ -72,6 +106,24 @@ export default class Connection extends EventEmitter {
72
106
  else {
73
107
  throw new TypeError('interceptors must be a function, array, or undefined');
74
108
  }
109
+ // Auth interceptor is always last so it runs after user interceptors
110
+ if (options.auth) {
111
+ this._interceptors.push(options.auth);
112
+ }
113
+ this._log('debug', `Connection created for ${this.url}`);
114
+ }
115
+ /**
116
+ * The connection-level default batch size, used to fill a request's `batchSize` when unset.
117
+ */
118
+ get batchSize() {
119
+ return this._batchSize;
120
+ }
121
+ /**
122
+ * The connection-level default for `bulkResults`, applied to every request unless overridden
123
+ * per-request. Defaults to `false`.
124
+ */
125
+ get bulkResults() {
126
+ return this._bulkResults;
75
127
  }
76
128
  /**
77
129
  * Opens the connection, if its not already opened.
@@ -81,34 +133,99 @@ export default class Connection extends EventEmitter {
81
133
  // No-op for HTTP connections
82
134
  return Promise.resolve();
83
135
  }
84
- /** @override */
85
- submit(request) {
86
- // The user may not want the body to be serialized if they are using an interceptor.
87
- const body = this._writer ? this._writer.writeRequest(request) : request;
88
- return this.#makeHttpRequest(body)
89
- .then((response) => {
90
- return this.#handleResponse(response);
91
- });
136
+ /**
137
+ * Send a request and buffer the entire response. Returns a Promise<ResultSet>.
138
+ */
139
+ async submit(request) {
140
+ const response = await this.#makeHttpRequest(request);
141
+ return this.#handleResponse(response);
92
142
  }
93
- /** @override */
94
- stream(request) {
95
- throw new Error('stream() is not yet implemented');
143
+ /**
144
+ * Send a request and stream the response incrementally.
145
+ * Returns an AsyncGenerator that yields deserialized result items.
146
+ * For bulked responses, yields Traverser objects.
147
+ *
148
+ * In the GraphBinary v4 streaming protocol, the server sends the status after all
149
+ * result data. If the server encounters an error mid-traversal, values yielded before
150
+ * the error are valid partial results. A ResponseError is thrown after the last value
151
+ * has been yielded.
152
+ *
153
+ * @param {RequestMessage} request
154
+ * @returns {AsyncGenerator<any>}
155
+ */
156
+ async *stream(request) {
157
+ const abortController = new AbortController();
158
+ let response;
159
+ try {
160
+ response = await this.#makeHttpRequest(request, abortController.signal);
161
+ }
162
+ catch (e) {
163
+ throw new Error(`Stream request failed: ${e.message}`, { cause: e });
164
+ }
165
+ if (!response.ok) {
166
+ // For error responses, buffer and parse the error body
167
+ const buffer = Buffer.from(await response.arrayBuffer());
168
+ const errorMessage = `Server returned HTTP ${response.status}: ${response.statusText}`;
169
+ const contentType = response.headers.get("Content-Type");
170
+ const reader = this.#getReaderForContentType(contentType);
171
+ try {
172
+ if (reader) {
173
+ const deserialized = await reader.readResponse(buffer);
174
+ throw new ResponseError(errorMessage, {
175
+ code: deserialized.status.code,
176
+ message: deserialized.status.message || response.statusText,
177
+ exception: deserialized.status.exception,
178
+ });
179
+ }
180
+ else if (contentType === 'application/json') {
181
+ const errorBody = JSON.parse(buffer.toString());
182
+ throw new ResponseError(errorMessage, {
183
+ code: response.status,
184
+ message: errorBody.message || errorBody.error || response.statusText,
185
+ });
186
+ }
187
+ }
188
+ catch (err) {
189
+ if (err instanceof ResponseError)
190
+ throw err;
191
+ }
192
+ throw new ResponseError(errorMessage, {
193
+ code: response.status,
194
+ message: response.statusText,
195
+ });
196
+ }
197
+ if (!response.body) {
198
+ // 204 No Content - nothing to yield
199
+ return;
200
+ }
201
+ const streamReader = StreamReader.fromReadableStream(response.body);
202
+ let completed = false;
203
+ try {
204
+ yield* this._responseSerializer.readResponseStream(streamReader);
205
+ completed = true;
206
+ }
207
+ finally {
208
+ if (!completed) {
209
+ // Consumer broke out early or an error occurred - abort to release the connection
210
+ abortController.abort();
211
+ }
212
+ }
96
213
  }
97
214
  #getReaderForContentType(contentType) {
98
215
  if (!contentType) {
99
- return this._reader;
216
+ return this._responseSerializer;
100
217
  }
101
- if (contentType === this._reader.mimeType) {
102
- return this._reader;
218
+ if (contentType === this._responseSerializer.mimeType) {
219
+ return this._responseSerializer;
103
220
  }
104
221
  return null;
105
222
  }
106
- async #makeHttpRequest(body) {
223
+ async #makeHttpRequest(request, signal) {
107
224
  const headers = {
108
- 'Accept': this._reader.mimeType
225
+ 'Accept': this._responseSerializer.mimeType,
109
226
  };
110
- if (this._writer) {
111
- headers['Content-Type'] = this._writer.mimeType;
227
+ if (this._compression === 'deflate') {
228
+ headers['Accept-Encoding'] = 'deflate';
112
229
  }
113
230
  if (this._enableUserAgentOnConnect) {
114
231
  const userAgent = await utils.getUserAgent();
@@ -116,29 +233,35 @@ export default class Connection extends EventEmitter {
116
233
  headers[utils.getUserAgentHeader()] = userAgent;
117
234
  }
118
235
  }
119
- if (this.options.headers) {
120
- Object.entries(this.options.headers).forEach(([key, value]) => {
121
- headers[key] = Array.isArray(value) ? value.join(', ') : value;
122
- });
236
+ const httpRequest = new HttpRequest('POST', this.url, headers, request);
237
+ // Promote transactionId to HTTP header before interceptors run.
238
+ // The field remains in the serialized body as well (dual transmission
239
+ // per the HTTP transaction protocol specification).
240
+ if (request instanceof RequestMessage) {
241
+ const fields = request.getFields();
242
+ if (fields.has('transactionId')) {
243
+ httpRequest.headers['X-Transaction-Id'] = fields.get('transactionId');
244
+ }
123
245
  }
124
- let httpRequest = {
125
- url: this.url,
126
- method: 'POST',
127
- headers,
128
- body,
129
- };
130
246
  for (let i = 0; i < this._interceptors.length; i++) {
131
247
  try {
132
- httpRequest = await this._interceptors[i](httpRequest);
248
+ await this._interceptors[i](httpRequest);
133
249
  }
134
250
  catch (e) {
135
251
  throw new Error(`Request interceptor at index ${i} failed: ${e.message}`, { cause: e });
136
252
  }
137
253
  }
138
- return fetch(httpRequest.url, {
254
+ // Auto-serialize body to JSON after interceptors run (idempotent if already serialized)
255
+ httpRequest.serializeBody();
256
+ this._log('debug', `Sending ${httpRequest.method} request to ${httpRequest.url}`);
257
+ return httpFetch.fetch(httpRequest.url, {
139
258
  method: httpRequest.method,
140
259
  headers: httpRequest.headers,
141
260
  body: httpRequest.body,
261
+ signal,
262
+ // Node only: the undici dispatcher carries the connection-pool options. In the browser
263
+ // it is undefined and the field is omitted, letting the user agent manage the transport.
264
+ ...(this._dispatcher ? { dispatcher: this._dispatcher } : {}),
142
265
  });
143
266
  }
144
267
  async #handleResponse(response) {
@@ -149,16 +272,11 @@ export default class Connection extends EventEmitter {
149
272
  const errorMessage = `Server returned HTTP ${response.status}: ${response.statusText}`;
150
273
  try {
151
274
  if (reader) {
152
- const deserialized = reader.readResponse(buffer);
153
- const attributes = new Map();
154
- if (deserialized.status.exception) {
155
- attributes.set('exceptions', deserialized.status.exception);
156
- attributes.set('stackTrace', deserialized.status.exception);
157
- }
275
+ const deserialized = await reader.readResponse(buffer);
158
276
  throw new ResponseError(errorMessage, {
159
277
  code: deserialized.status.code,
160
278
  message: deserialized.status.message || response.statusText,
161
- attributes: attributes,
279
+ exception: deserialized.status.exception,
162
280
  });
163
281
  }
164
282
  else if (contentType === 'application/json') {
@@ -166,7 +284,6 @@ export default class Connection extends EventEmitter {
166
284
  throw new ResponseError(errorMessage, {
167
285
  code: response.status,
168
286
  message: errorBody.message || errorBody.error || response.statusText,
169
- attributes: new Map(),
170
287
  });
171
288
  }
172
289
  }
@@ -178,23 +295,17 @@ export default class Connection extends EventEmitter {
178
295
  throw new ResponseError(errorMessage, {
179
296
  code: response.status,
180
297
  message: response.statusText,
181
- attributes: new Map(),
182
298
  });
183
299
  }
184
300
  if (!reader) {
185
- throw new Error(`Response Content-Type '${contentType}' does not match the configured reader (expected '${this._reader.mimeType}')`);
186
- }
187
- const deserialized = reader.readResponse(buffer);
188
- if (deserialized.status.code && deserialized.status.code !== 200 && deserialized.status.code !== 204 && deserialized.status.code !== 206) {
189
- const attributes = new Map();
190
- if (deserialized.status.exception) {
191
- attributes.set('exceptions', deserialized.status.exception);
192
- attributes.set('stackTrace', deserialized.status.exception);
193
- }
301
+ throw new Error(`Response Content-Type '${contentType}' does not match the configured response serializer (expected '${this._responseSerializer.mimeType}')`);
302
+ }
303
+ const deserialized = await reader.readResponse(buffer);
304
+ if (deserialized.status.code && deserialized.status.code !== responseStatusCode.success && deserialized.status.code !== responseStatusCode.noContent && deserialized.status.code !== responseStatusCode.partialContent) {
194
305
  throw new ResponseError(`Server error: ${deserialized.status.message || 'Unknown error'} (${deserialized.status.code})`, {
195
306
  code: deserialized.status.code,
196
307
  message: deserialized.status.message || '',
197
- attributes: attributes,
308
+ exception: deserialized.status.exception,
198
309
  });
199
310
  }
200
311
  return new ResultSet(deserialized.result.bulked
@@ -205,7 +316,8 @@ export default class Connection extends EventEmitter {
205
316
  * Closes the Connection.
206
317
  * @return {Promise}
207
318
  */
208
- close() {
209
- return Promise.resolve();
319
+ async close() {
320
+ this._log('debug', `Closing connection to ${this.url}`);
321
+ await this._dispatcher?.close();
210
322
  }
211
323
  }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Browser counterpart of {@link ./dispatcher.ts}. The Node build configures the underlying HTTP
3
+ * transport through an `undici` dispatcher, but `undici` is built on `node:net`/`node:tls` and
4
+ * cannot run in a browser. Bundlers pick this file up via the `"browser"` field in `package.json`,
5
+ * so a browser bundle never imports `undici`.
6
+ *
7
+ * The browser's HTTP stack manages the connection-pool options that the Node dispatcher carries,
8
+ * so {@link buildDispatcher} throws if any is set explicitly (rather than silently ignoring it)
9
+ * and otherwise returns `undefined`, leaving the connection to issue a plain `fetch`. It is the
10
+ * only export the connection imports through the swapped `./dispatcher.js` path.
11
+ */
12
+ /** Transport options accepted by {@link buildDispatcher}; mirrors the Node dispatcher's options. */
13
+ type DispatcherOptions = {
14
+ maxConnections?: number;
15
+ readTimeoutMillis?: number;
16
+ maxResponseHeaderBytes?: number;
17
+ keepAliveTimeMillis?: number;
18
+ proxy?: string;
19
+ };
20
+ /**
21
+ * In the browser there is no `undici` dispatcher, so `fetch` is issued without one and the browser
22
+ * manages the transport. Any {@link NODE_ONLY_OPTIONS} set explicitly cannot be honored and throws,
23
+ * so a misconfiguration surfaces immediately instead of being silently dropped. With none set this
24
+ * returns `undefined` and the connection omits the `dispatcher` field.
25
+ */
26
+ export declare function buildDispatcher(options?: DispatcherOptions): undefined;
27
+ /**
28
+ * Browser counterpart of the Node `httpFetch` holder. There is no `undici` in the browser, so
29
+ * requests use the global `fetch` and the user agent manages the transport. Same holder shape as
30
+ * the Node build.
31
+ */
32
+ export declare const httpFetch: {
33
+ fetch: typeof globalThis.fetch;
34
+ };
35
+ export {};
@@ -0,0 +1,53 @@
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
+ * Connection-pool / transport options that only the Node (`undici`) dispatcher can honor. The
21
+ * browser's HTTP stack owns these concerns and exposes no `fetch` API to configure them, so they
22
+ * are rejected here rather than silently ignored. `readTimeoutMillis` is intentionally not in this list:
23
+ * it has a browser analog (an `AbortSignal`-based timeout) and is handled by the connection.
24
+ */
25
+ const NODE_ONLY_OPTIONS = [
26
+ 'maxConnections',
27
+ 'keepAliveTimeMillis',
28
+ 'maxResponseHeaderBytes',
29
+ 'proxy',
30
+ ];
31
+ /**
32
+ * In the browser there is no `undici` dispatcher, so `fetch` is issued without one and the browser
33
+ * manages the transport. Any {@link NODE_ONLY_OPTIONS} set explicitly cannot be honored and throws,
34
+ * so a misconfiguration surfaces immediately instead of being silently dropped. With none set this
35
+ * returns `undefined` and the connection omits the `dispatcher` field.
36
+ */
37
+ export function buildDispatcher(options = {}) {
38
+ const unsupported = NODE_ONLY_OPTIONS.filter((key) => options[key] !== undefined);
39
+ if (unsupported.length > 0) {
40
+ throw new Error(`The following connection options are not supported in the browser and are managed by the ` +
41
+ `browser's HTTP stack: ${unsupported.join(', ')}. Remove them when running in a browser ` +
42
+ `(they are supported in Node).`);
43
+ }
44
+ return undefined;
45
+ }
46
+ /**
47
+ * Browser counterpart of the Node `httpFetch` holder. There is no `undici` in the browser, so
48
+ * requests use the global `fetch` and the user agent manages the transport. Same holder shape as
49
+ * the Node build.
50
+ */
51
+ export const httpFetch = {
52
+ fetch: globalThis.fetch.bind(globalThis),
53
+ };
@@ -0,0 +1,48 @@
1
+ import { Agent, buildConnector, Dispatcher } from 'undici';
2
+ /** Default concurrent-connections-per-origin cap (Node's global fetch is uncapped). */
3
+ export declare const DEFAULT_MAX_CONNECTIONS = 128;
4
+ /** Canonical TinkerPop 4.x default TCP keep-alive idle time (30s), shared across the GLVs. */
5
+ export declare const DEFAULT_KEEP_ALIVE_TIME = 30000;
6
+ /** Options for the default undici {@link Dispatcher}; unset fields use undici defaults. */
7
+ export type DispatcherOptions = {
8
+ /** Max concurrent connections per origin. Defaults to {@link DEFAULT_MAX_CONNECTIONS}. */
9
+ maxConnections?: number;
10
+ /** Read timeout in ms. Maps to undici `headersTimeout` (wait for first response byte) and `bodyTimeout` (idle between body chunks). */
11
+ readTimeoutMillis?: number;
12
+ /** Max response header size in bytes. Maps to undici `maxHeaderSize`. */
13
+ maxResponseHeaderBytes?: number;
14
+ /** Idle ms before TCP keep-alive probes begin. Defaults to 30s; `0` disables keep-alive. */
15
+ keepAliveTimeMillis?: number;
16
+ /** HTTP proxy URI. When set, a {@link ProxyAgent} is built instead of an {@link Agent}. */
17
+ proxy?: string;
18
+ };
19
+ /**
20
+ * Resolves the effective keep-alive idle delay: unset falls back to {@link DEFAULT_KEEP_ALIVE_TIME},
21
+ * a non-positive value disables keep-alive (returns `null`).
22
+ */
23
+ export declare function resolveKeepAliveTime(keepAliveTime?: number): number | null;
24
+ /**
25
+ * Builds an undici connector that sets `SO_KEEPALIVE` with the given idle delay on each new socket.
26
+ * `baseConnector` is parameterised so the wiring can be unit-tested with a fake connector.
27
+ */
28
+ export declare function buildKeepAliveConnector(delay: number, baseConnector?: ReturnType<typeof buildConnector>): ReturnType<typeof buildConnector>;
29
+ /**
30
+ * Maps the discrete driver options onto undici {@link Agent.Options} (the single source of truth
31
+ * for that mapping). Exported as a seam so the mapping can be asserted in unit tests.
32
+ */
33
+ export declare function buildAgentOptions(options?: DispatcherOptions): Agent.Options;
34
+ /**
35
+ * Builds the default undici {@link Dispatcher}: a {@link ProxyAgent} when `proxy` is set, otherwise
36
+ * a plain {@link Agent}. (Agent and ProxyAgent share one dispatcher slot, so only one is built.)
37
+ */
38
+ export declare function buildDispatcher(options?: DispatcherOptions): Dispatcher;
39
+ /**
40
+ * HTTP `fetch` for the Node build. Uses undici's own `fetch` (not the global one) so `fetch` and the
41
+ * {@link buildDispatcher} dispatcher share one undici version, whatever undici the Node runtime
42
+ * bundles (e.g. Node 26 ships undici 8, incompatible with an undici 6 dispatcher). A holder object,
43
+ * not a bare export, so tests can swap `fetch` (an ESM export can't be reassigned, an object
44
+ * property can). The cast aligns undici's `fetch` type with the global one.
45
+ */
46
+ export declare const httpFetch: {
47
+ fetch: typeof globalThis.fetch;
48
+ };
@@ -0,0 +1,94 @@
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 { Agent, ProxyAgent, buildConnector, fetch as undiciFetch } from 'undici';
20
+ /** Default concurrent-connections-per-origin cap (Node's global fetch is uncapped). */
21
+ export const DEFAULT_MAX_CONNECTIONS = 128;
22
+ /** Canonical TinkerPop 4.x default TCP keep-alive idle time (30s), shared across the GLVs. */
23
+ export const DEFAULT_KEEP_ALIVE_TIME = 30000;
24
+ /**
25
+ * Resolves the effective keep-alive idle delay: unset falls back to {@link DEFAULT_KEEP_ALIVE_TIME},
26
+ * a non-positive value disables keep-alive (returns `null`).
27
+ */
28
+ export function resolveKeepAliveTime(keepAliveTime) {
29
+ const effective = keepAliveTime ?? DEFAULT_KEEP_ALIVE_TIME;
30
+ return effective > 0 ? effective : null;
31
+ }
32
+ /**
33
+ * Builds an undici connector that sets `SO_KEEPALIVE` with the given idle delay on each new socket.
34
+ * `baseConnector` is parameterised so the wiring can be unit-tested with a fake connector.
35
+ */
36
+ export function buildKeepAliveConnector(delay, baseConnector = buildConnector({})) {
37
+ return (connectOptions, callback) => {
38
+ baseConnector(connectOptions, (err, socket) => {
39
+ if (err) {
40
+ callback(err, null);
41
+ return;
42
+ }
43
+ if (socket) {
44
+ socket.setKeepAlive(true, delay);
45
+ }
46
+ callback(null, socket);
47
+ });
48
+ };
49
+ }
50
+ /**
51
+ * Maps the discrete driver options onto undici {@link Agent.Options} (the single source of truth
52
+ * for that mapping). Exported as a seam so the mapping can be asserted in unit tests.
53
+ */
54
+ export function buildAgentOptions(options = {}) {
55
+ const maxConnections = options.maxConnections ?? DEFAULT_MAX_CONNECTIONS;
56
+ const agentOptions = {
57
+ connections: maxConnections,
58
+ };
59
+ // Connect/idle timeouts are intentionally left to undici defaults (the GLV spec marks the JS
60
+ // connect/idle timeout as N/A), not exposed as driver options.
61
+ if (options.readTimeoutMillis !== undefined) {
62
+ agentOptions.headersTimeout = options.readTimeoutMillis;
63
+ agentOptions.bodyTimeout = options.readTimeoutMillis;
64
+ }
65
+ if (options.maxResponseHeaderBytes !== undefined) {
66
+ agentOptions.maxHeaderSize = options.maxResponseHeaderBytes;
67
+ }
68
+ const keepAliveDelay = resolveKeepAliveTime(options.keepAliveTimeMillis);
69
+ if (keepAliveDelay !== null) {
70
+ agentOptions.connect = buildKeepAliveConnector(keepAliveDelay);
71
+ }
72
+ return agentOptions;
73
+ }
74
+ /**
75
+ * Builds the default undici {@link Dispatcher}: a {@link ProxyAgent} when `proxy` is set, otherwise
76
+ * a plain {@link Agent}. (Agent and ProxyAgent share one dispatcher slot, so only one is built.)
77
+ */
78
+ export function buildDispatcher(options = {}) {
79
+ const agentOptions = buildAgentOptions(options);
80
+ if (options.proxy) {
81
+ return new ProxyAgent({ uri: options.proxy, ...agentOptions });
82
+ }
83
+ return new Agent(agentOptions);
84
+ }
85
+ /**
86
+ * HTTP `fetch` for the Node build. Uses undici's own `fetch` (not the global one) so `fetch` and the
87
+ * {@link buildDispatcher} dispatcher share one undici version, whatever undici the Node runtime
88
+ * bundles (e.g. Node 26 ships undici 8, incompatible with an undici 6 dispatcher). A holder object,
89
+ * not a bare export, so tests can swap `fetch` (an ESM export can't be reassigned, an object
90
+ * property can). The cast aligns undici's `fetch` type with the global one.
91
+ */
92
+ export const httpFetch = {
93
+ fetch: undiciFetch,
94
+ };
@@ -3,27 +3,33 @@
3
3
  */
4
4
  import * as rcModule from './remote-connection.js';
5
5
  declare const RemoteConnection: typeof rcModule.RemoteConnection;
6
+ import Client from './client.js';
6
7
  import GremlinLang from '../process/gremlin-lang.js';
7
8
  import { ConnectionOptions } from './connection.js';
8
9
  /**
9
10
  * Represents the default `RemoteConnection` implementation.
10
11
  */
11
12
  export default class DriverRemoteConnection extends RemoteConnection {
12
- private readonly _client;
13
+ #private;
14
+ readonly _client: Client;
15
+ private _transactionId?;
13
16
  /**
14
17
  * Creates a new instance of {@link DriverRemoteConnection}.
15
18
  * @param {String} url The resource uri.
16
19
  * @param {ConnectionOptions} [options] The connection options.
20
+ * @param {String} [transactionId] Optional transaction ID to attach to all requests.
17
21
  */
18
- constructor(url: string, options?: ConnectionOptions);
22
+ constructor(url: string, options?: ConnectionOptions, transactionId?: string);
23
+ /**
24
+ * Returns the transaction ID if this connection is bound to a transaction, undefined otherwise.
25
+ */
26
+ get transactionId(): string | undefined;
19
27
  /** @override */
20
28
  open(): Promise<void>;
21
29
  /** @override */
22
30
  get isOpen(): boolean;
23
31
  /** @override */
24
32
  submit(gremlinLang: GremlinLang): Promise<rcModule.RemoteTraversal>;
25
- commit(): Promise<any>;
26
- rollback(): Promise<any>;
27
33
  close(): Promise<void>;
28
34
  /** @override */
29
35
  addListener(event: string, handler: (...args: any[]) => unknown): void;