gremlin 3.8.1 → 4.0.0-beta.2

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 (411) hide show
  1. package/README.md +18 -4
  2. package/build/cjs/driver/auth.cjs +69 -0
  3. package/build/cjs/driver/auth.d.cts +9 -0
  4. package/build/cjs/driver/client.cjs +134 -0
  5. package/build/cjs/driver/client.d.cts +85 -0
  6. package/build/cjs/driver/connection.cjs +250 -0
  7. package/build/cjs/driver/connection.d.cts +63 -0
  8. package/build/cjs/driver/driver-remote-connection.cjs +141 -0
  9. package/build/cjs/driver/driver-remote-connection.d.cts +33 -0
  10. package/build/cjs/driver/remote-connection.cjs +75 -0
  11. package/build/cjs/driver/remote-connection.d.cts +72 -0
  12. package/build/cjs/driver/request-message.cjs +157 -0
  13. package/build/cjs/driver/request-message.d.cts +49 -0
  14. package/build/cjs/driver/response-error.cjs +45 -0
  15. package/build/cjs/driver/response-error.d.cts +13 -0
  16. package/build/cjs/driver/result-set.cjs +111 -0
  17. package/build/cjs/driver/result-set.d.cts +29 -0
  18. package/build/cjs/index.cjs +125 -0
  19. package/build/cjs/index.d.cts +393 -0
  20. package/build/cjs/language/grammar/GremlinLexer.cjs +1851 -0
  21. package/build/cjs/language/grammar/GremlinLexer.d.cts +340 -0
  22. package/build/cjs/language/grammar/GremlinListener.cjs +4490 -0
  23. package/build/cjs/language/grammar/GremlinListener.d.cts +4898 -0
  24. package/build/cjs/language/grammar/GremlinParser.cjs +35244 -0
  25. package/build/cjs/language/grammar/GremlinParser.d.cts +5881 -0
  26. package/build/cjs/language/index.cjs +48 -0
  27. package/build/cjs/language/index.d.cts +12 -0
  28. package/build/cjs/language/translator/AnonymizedTranslateVisitor.cjs +157 -0
  29. package/build/cjs/language/translator/AnonymizedTranslateVisitor.d.cts +36 -0
  30. package/build/cjs/language/translator/DotNetTranslateVisitor.cjs +826 -0
  31. package/build/cjs/language/translator/DotNetTranslateVisitor.d.cts +155 -0
  32. package/build/cjs/language/translator/GoTranslateVisitor.cjs +339 -0
  33. package/build/cjs/language/translator/GoTranslateVisitor.d.cts +31 -0
  34. package/build/cjs/language/translator/GremlinTranslator.cjs +96 -0
  35. package/build/cjs/language/translator/GremlinTranslator.d.cts +18 -0
  36. package/build/cjs/language/translator/GroovyTranslateVisitor.cjs +287 -0
  37. package/build/cjs/language/translator/GroovyTranslateVisitor.d.cts +34 -0
  38. package/build/cjs/language/translator/JavaTranslateVisitor.cjs +247 -0
  39. package/build/cjs/language/translator/JavaTranslateVisitor.d.cts +23 -0
  40. package/build/cjs/language/translator/JavascriptTranslateVisitor.cjs +220 -0
  41. package/build/cjs/language/translator/JavascriptTranslateVisitor.d.cts +25 -0
  42. package/build/cjs/language/translator/PythonTranslateVisitor.cjs +304 -0
  43. package/build/cjs/language/translator/PythonTranslateVisitor.d.cts +28 -0
  44. package/build/cjs/language/translator/TranslateVisitor.cjs +389 -0
  45. package/build/cjs/language/translator/TranslateVisitor.d.cts +91 -0
  46. package/build/cjs/language/translator/Translation.cjs +47 -0
  47. package/build/cjs/language/translator/Translation.d.cts +13 -0
  48. package/build/cjs/language/translator/Translator.cjs +46 -0
  49. package/build/cjs/language/translator/Translator.d.cts +24 -0
  50. package/build/cjs/language/translator/TranslatorException.cjs +31 -0
  51. package/build/cjs/language/translator/TranslatorException.d.cts +6 -0
  52. package/build/cjs/process/anonymous-traversal.cjs +78 -0
  53. package/build/cjs/process/anonymous-traversal.d.cts +40 -0
  54. package/build/cjs/process/graph-traversal.cjs +1702 -0
  55. package/build/cjs/process/graph-traversal.d.cts +1134 -0
  56. package/build/cjs/process/gremlin-lang.cjs +196 -0
  57. package/build/cjs/process/gremlin-lang.d.cts +15 -0
  58. package/build/cjs/process/transaction.cjs +69 -0
  59. package/build/cjs/process/transaction.d.cts +34 -0
  60. package/build/cjs/process/traversal-strategy.cjs +360 -0
  61. package/build/cjs/process/traversal-strategy.d.cts +211 -0
  62. package/build/cjs/process/traversal.cjs +482 -0
  63. package/build/cjs/process/traversal.d.cts +186 -0
  64. package/build/cjs/structure/graph.cjs +157 -0
  65. package/build/cjs/structure/graph.d.cts +57 -0
  66. package/build/cjs/structure/io/binary/GraphBinary.cjs +148 -0
  67. package/build/cjs/structure/io/binary/GraphBinary.d.cts +91 -0
  68. package/build/cjs/structure/io/binary/internals/AnySerializer.cjs +80 -0
  69. package/build/cjs/structure/io/binary/internals/AnySerializer.d.cts +8 -0
  70. package/build/cjs/structure/io/binary/internals/ArraySerializer.cjs +139 -0
  71. package/build/cjs/structure/io/binary/internals/ArraySerializer.d.cts +15 -0
  72. package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.cjs +136 -0
  73. package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.d.cts +14 -0
  74. package/build/cjs/structure/io/binary/internals/BinarySerializer.cjs +112 -0
  75. package/build/cjs/structure/io/binary/internals/BinarySerializer.d.cts +11 -0
  76. package/build/cjs/structure/io/binary/internals/BooleanSerializer.cjs +93 -0
  77. package/build/cjs/structure/io/binary/internals/BooleanSerializer.d.cts +11 -0
  78. package/build/cjs/structure/io/binary/internals/ByteSerializer.cjs +88 -0
  79. package/build/cjs/structure/io/binary/internals/ByteSerializer.d.cts +10 -0
  80. package/build/cjs/structure/io/binary/internals/DataType.cjs +63 -0
  81. package/build/cjs/structure/io/binary/internals/DataType.d.cts +35 -0
  82. package/build/cjs/structure/io/binary/internals/DateTimeSerializer.cjs +139 -0
  83. package/build/cjs/structure/io/binary/internals/DateTimeSerializer.d.cts +15 -0
  84. package/build/cjs/structure/io/binary/internals/DoubleSerializer.cjs +91 -0
  85. package/build/cjs/structure/io/binary/internals/DoubleSerializer.d.cts +11 -0
  86. package/build/cjs/structure/io/binary/internals/EdgeSerializer.cjs +201 -0
  87. package/build/cjs/structure/io/binary/internals/EdgeSerializer.d.cts +20 -0
  88. package/build/cjs/structure/io/binary/internals/EnumSerializer.cjs +127 -0
  89. package/build/cjs/structure/io/binary/internals/EnumSerializer.d.cts +24 -0
  90. package/build/cjs/structure/io/binary/internals/FloatSerializer.cjs +91 -0
  91. package/build/cjs/structure/io/binary/internals/FloatSerializer.d.cts +11 -0
  92. package/build/cjs/structure/io/binary/internals/GraphBinaryReader.cjs +97 -0
  93. package/build/cjs/structure/io/binary/internals/GraphBinaryReader.d.cts +19 -0
  94. package/build/cjs/structure/io/binary/internals/GraphBinaryWriter.cjs +85 -0
  95. package/build/cjs/structure/io/binary/internals/GraphBinaryWriter.d.cts +9 -0
  96. package/build/cjs/structure/io/binary/internals/IntSerializer.cjs +103 -0
  97. package/build/cjs/structure/io/binary/internals/IntSerializer.d.cts +13 -0
  98. package/build/cjs/structure/io/binary/internals/LongSerializer.cjs +95 -0
  99. package/build/cjs/structure/io/binary/internals/LongSerializer.d.cts +11 -0
  100. package/build/cjs/structure/io/binary/internals/MapSerializer.cjs +144 -0
  101. package/build/cjs/structure/io/binary/internals/MapSerializer.d.cts +13 -0
  102. package/build/cjs/structure/io/binary/internals/MarkerSerializer.cjs +63 -0
  103. package/build/cjs/structure/io/binary/internals/MarkerSerializer.d.cts +8 -0
  104. package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.cjs +66 -0
  105. package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.d.cts +9 -0
  106. package/build/cjs/structure/io/binary/internals/PathSerializer.cjs +113 -0
  107. package/build/cjs/structure/io/binary/internals/PathSerializer.d.cts +15 -0
  108. package/build/cjs/structure/io/binary/internals/PropertySerializer.cjs +130 -0
  109. package/build/cjs/structure/io/binary/internals/PropertySerializer.d.cts +15 -0
  110. package/build/cjs/structure/io/binary/internals/SetSerializer.cjs +138 -0
  111. package/build/cjs/structure/io/binary/internals/SetSerializer.d.cts +15 -0
  112. package/build/cjs/structure/io/binary/internals/ShortSerializer.cjs +91 -0
  113. package/build/cjs/structure/io/binary/internals/ShortSerializer.d.cts +11 -0
  114. package/build/cjs/structure/io/binary/internals/StringSerializer.cjs +107 -0
  115. package/build/cjs/structure/io/binary/internals/StringSerializer.d.cts +11 -0
  116. package/{lib/driver/auth/authenticator.js → build/cjs/structure/io/binary/internals/StubSerializer.cjs} +14 -20
  117. package/build/cjs/structure/io/binary/internals/StubSerializer.d.cts +7 -0
  118. package/build/cjs/structure/io/binary/internals/UnspecifiedNullSerializer.cjs +70 -0
  119. package/build/cjs/structure/io/binary/internals/UnspecifiedNullSerializer.d.cts +11 -0
  120. package/build/cjs/structure/io/binary/internals/UuidSerializer.cjs +109 -0
  121. package/build/cjs/structure/io/binary/internals/UuidSerializer.d.cts +14 -0
  122. package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.cjs +163 -0
  123. package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.d.cts +15 -0
  124. package/build/cjs/structure/io/binary/internals/VertexSerializer.cjs +128 -0
  125. package/build/cjs/structure/io/binary/internals/VertexSerializer.d.cts +17 -0
  126. package/build/cjs/structure/io/binary/internals/utils.cjs +53 -0
  127. package/build/cjs/structure/io/binary/internals/utils.d.cts +6 -0
  128. package/build/cjs/utils.cjs +142 -0
  129. package/build/cjs/utils.d.cts +20 -0
  130. package/build/esm/driver/auth.d.ts +9 -0
  131. package/build/esm/driver/auth.js +65 -0
  132. package/build/esm/driver/client.d.ts +85 -0
  133. package/build/esm/driver/client.js +128 -0
  134. package/build/esm/driver/connection.d.ts +63 -0
  135. package/build/esm/driver/connection.js +211 -0
  136. package/build/esm/driver/driver-remote-connection.d.ts +33 -0
  137. package/build/esm/driver/driver-remote-connection.js +102 -0
  138. package/build/esm/driver/remote-connection.d.ts +72 -0
  139. package/build/esm/driver/remote-connection.js +69 -0
  140. package/build/esm/driver/request-message.d.ts +49 -0
  141. package/build/esm/driver/request-message.js +152 -0
  142. package/build/esm/driver/response-error.d.ts +13 -0
  143. package/{lib → build/esm}/driver/response-error.js +21 -26
  144. package/build/esm/driver/result-set.d.ts +29 -0
  145. package/build/esm/driver/result-set.js +75 -0
  146. package/build/esm/index.d.ts +393 -0
  147. package/{index.js → build/esm/index.js} +23 -33
  148. package/build/esm/language/grammar/GremlinLexer.d.ts +340 -0
  149. package/build/esm/language/grammar/GremlinLexer.js +1814 -0
  150. package/build/esm/language/grammar/GremlinListener.d.ts +4898 -0
  151. package/build/esm/language/grammar/GremlinListener.js +4486 -0
  152. package/build/esm/language/grammar/GremlinParser.d.ts +5881 -0
  153. package/build/esm/language/grammar/GremlinParser.js +34711 -0
  154. package/build/esm/language/index.d.ts +12 -0
  155. package/build/esm/language/index.js +30 -0
  156. package/build/esm/language/translator/AnonymizedTranslateVisitor.d.ts +36 -0
  157. package/build/esm/language/translator/AnonymizedTranslateVisitor.js +151 -0
  158. package/build/esm/language/translator/DotNetTranslateVisitor.d.ts +155 -0
  159. package/build/esm/language/translator/DotNetTranslateVisitor.js +820 -0
  160. package/build/esm/language/translator/GoTranslateVisitor.d.ts +31 -0
  161. package/build/esm/language/translator/GoTranslateVisitor.js +333 -0
  162. package/build/esm/language/translator/GremlinTranslator.d.ts +18 -0
  163. package/build/esm/language/translator/GremlinTranslator.js +89 -0
  164. package/build/esm/language/translator/GroovyTranslateVisitor.d.ts +34 -0
  165. package/build/esm/language/translator/GroovyTranslateVisitor.js +281 -0
  166. package/build/esm/language/translator/JavaTranslateVisitor.d.ts +23 -0
  167. package/build/esm/language/translator/JavaTranslateVisitor.js +241 -0
  168. package/build/esm/language/translator/JavascriptTranslateVisitor.d.ts +25 -0
  169. package/build/esm/language/translator/JavascriptTranslateVisitor.js +214 -0
  170. package/build/esm/language/translator/PythonTranslateVisitor.d.ts +28 -0
  171. package/build/esm/language/translator/PythonTranslateVisitor.js +298 -0
  172. package/build/esm/language/translator/TranslateVisitor.d.ts +91 -0
  173. package/build/esm/language/translator/TranslateVisitor.js +386 -0
  174. package/build/esm/language/translator/Translation.d.ts +13 -0
  175. package/build/esm/language/translator/Translation.js +43 -0
  176. package/build/esm/language/translator/Translator.d.ts +24 -0
  177. package/build/esm/language/translator/Translator.js +40 -0
  178. package/build/esm/language/translator/TranslatorException.d.ts +6 -0
  179. package/build/esm/language/translator/TranslatorException.js +27 -0
  180. package/build/esm/process/anonymous-traversal.d.ts +40 -0
  181. package/build/esm/process/anonymous-traversal.js +72 -0
  182. package/build/esm/process/graph-traversal.d.ts +1134 -0
  183. package/build/esm/process/graph-traversal.js +1693 -0
  184. package/build/esm/process/gremlin-lang.d.ts +15 -0
  185. package/build/esm/process/gremlin-lang.js +193 -0
  186. package/build/esm/process/transaction.d.ts +34 -0
  187. package/build/esm/process/transaction.js +65 -0
  188. package/build/esm/process/traversal-strategy.d.ts +211 -0
  189. package/build/esm/process/traversal-strategy.js +319 -0
  190. package/build/esm/process/traversal.d.ts +186 -0
  191. package/build/esm/process/traversal.js +469 -0
  192. package/build/esm/structure/graph.d.ts +57 -0
  193. package/build/esm/structure/graph.js +148 -0
  194. package/build/esm/structure/io/binary/GraphBinary.d.ts +91 -0
  195. package/build/esm/structure/io/binary/GraphBinary.js +108 -0
  196. package/build/esm/structure/io/binary/internals/AnySerializer.d.ts +8 -0
  197. package/build/esm/structure/io/binary/internals/AnySerializer.js +77 -0
  198. package/build/esm/structure/io/binary/internals/ArraySerializer.d.ts +15 -0
  199. package/build/esm/structure/io/binary/internals/ArraySerializer.js +136 -0
  200. package/build/esm/structure/io/binary/internals/BigIntegerSerializer.d.ts +14 -0
  201. package/build/esm/structure/io/binary/internals/BigIntegerSerializer.js +133 -0
  202. package/build/esm/structure/io/binary/internals/BinarySerializer.d.ts +11 -0
  203. package/build/esm/structure/io/binary/internals/BinarySerializer.js +109 -0
  204. package/build/esm/structure/io/binary/internals/BooleanSerializer.d.ts +11 -0
  205. package/build/esm/structure/io/binary/internals/BooleanSerializer.js +90 -0
  206. package/build/esm/structure/io/binary/internals/ByteSerializer.d.ts +10 -0
  207. package/build/esm/structure/io/binary/internals/ByteSerializer.js +85 -0
  208. package/build/esm/structure/io/binary/internals/DataType.d.ts +35 -0
  209. package/{lib/driver/auth/mechanisms/sasl-mechanism-base.js → build/esm/structure/io/binary/internals/DataType.js} +43 -34
  210. package/build/esm/structure/io/binary/internals/DateTimeSerializer.d.ts +15 -0
  211. package/build/esm/structure/io/binary/internals/DateTimeSerializer.js +136 -0
  212. package/build/esm/structure/io/binary/internals/DoubleSerializer.d.ts +11 -0
  213. package/build/esm/structure/io/binary/internals/DoubleSerializer.js +88 -0
  214. package/build/esm/structure/io/binary/internals/EdgeSerializer.d.ts +20 -0
  215. package/build/esm/structure/io/binary/internals/EdgeSerializer.js +198 -0
  216. package/build/esm/structure/io/binary/internals/EnumSerializer.d.ts +24 -0
  217. package/build/esm/structure/io/binary/internals/EnumSerializer.js +124 -0
  218. package/build/esm/structure/io/binary/internals/FloatSerializer.d.ts +11 -0
  219. package/build/esm/structure/io/binary/internals/FloatSerializer.js +88 -0
  220. package/build/esm/structure/io/binary/internals/GraphBinaryReader.d.ts +19 -0
  221. package/build/esm/structure/io/binary/internals/GraphBinaryReader.js +94 -0
  222. package/build/esm/structure/io/binary/internals/GraphBinaryWriter.d.ts +9 -0
  223. package/build/esm/structure/io/binary/internals/GraphBinaryWriter.js +82 -0
  224. package/build/esm/structure/io/binary/internals/IntSerializer.d.ts +13 -0
  225. package/build/esm/structure/io/binary/internals/IntSerializer.js +100 -0
  226. package/build/esm/structure/io/binary/internals/LongSerializer.d.ts +11 -0
  227. package/build/esm/structure/io/binary/internals/LongSerializer.js +92 -0
  228. package/build/esm/structure/io/binary/internals/MapSerializer.d.ts +13 -0
  229. package/build/esm/structure/io/binary/internals/MapSerializer.js +141 -0
  230. package/build/esm/structure/io/binary/internals/MarkerSerializer.d.ts +8 -0
  231. package/build/esm/structure/io/binary/internals/MarkerSerializer.js +60 -0
  232. package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.d.ts +9 -0
  233. package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.js +63 -0
  234. package/build/esm/structure/io/binary/internals/PathSerializer.d.ts +15 -0
  235. package/build/esm/structure/io/binary/internals/PathSerializer.js +110 -0
  236. package/build/esm/structure/io/binary/internals/PropertySerializer.d.ts +15 -0
  237. package/build/esm/structure/io/binary/internals/PropertySerializer.js +127 -0
  238. package/build/esm/structure/io/binary/internals/SetSerializer.d.ts +15 -0
  239. package/build/esm/structure/io/binary/internals/SetSerializer.js +135 -0
  240. package/build/esm/structure/io/binary/internals/ShortSerializer.d.ts +11 -0
  241. package/build/esm/structure/io/binary/internals/ShortSerializer.js +88 -0
  242. package/build/esm/structure/io/binary/internals/StringSerializer.d.ts +11 -0
  243. package/build/esm/structure/io/binary/internals/StringSerializer.js +104 -0
  244. package/build/esm/structure/io/binary/internals/StubSerializer.d.ts +7 -0
  245. package/{.prettierrc.js → build/esm/structure/io/binary/internals/StubSerializer.js} +11 -11
  246. package/build/esm/structure/io/binary/internals/UnspecifiedNullSerializer.d.ts +11 -0
  247. package/build/esm/structure/io/binary/internals/UnspecifiedNullSerializer.js +67 -0
  248. package/build/esm/structure/io/binary/internals/UuidSerializer.d.ts +14 -0
  249. package/build/esm/structure/io/binary/internals/UuidSerializer.js +106 -0
  250. package/build/esm/structure/io/binary/internals/VertexPropertySerializer.d.ts +15 -0
  251. package/build/esm/structure/io/binary/internals/VertexPropertySerializer.js +160 -0
  252. package/build/esm/structure/io/binary/internals/VertexSerializer.d.ts +17 -0
  253. package/build/esm/structure/io/binary/internals/VertexSerializer.js +125 -0
  254. package/build/esm/structure/io/binary/internals/utils.d.ts +6 -0
  255. package/{lib → build/esm}/structure/io/binary/internals/utils.js +23 -35
  256. package/build/esm/utils.d.ts +20 -0
  257. package/build/esm/utils.js +98 -0
  258. package/package.json +56 -20
  259. package/.nvmrc +0 -1
  260. package/NOTICE +0 -5
  261. package/doc/AnonymousTraversalSource.html +0 -793
  262. package/doc/Authenticator.html +0 -303
  263. package/doc/Bytecode.html +0 -941
  264. package/doc/CardinalityValue.html +0 -711
  265. package/doc/Client.html +0 -1869
  266. package/doc/Connection.html +0 -1192
  267. package/doc/DriverRemoteConnection.html +0 -1528
  268. package/doc/EdgeLabelVerificationStrategy.html +0 -238
  269. package/doc/Graph.html +0 -343
  270. package/doc/GraphSON2Reader.html +0 -407
  271. package/doc/GraphSON2Writer.html +0 -558
  272. package/doc/GraphSON3Reader.html +0 -170
  273. package/doc/GraphSON3Writer.html +0 -170
  274. package/doc/GraphTraversal.html +0 -22974
  275. package/doc/GraphTraversalSource.html +0 -3683
  276. package/doc/HaltedTraverserStrategy.html +0 -215
  277. package/doc/MatchAlgorithmStrategy.html +0 -210
  278. package/doc/P.html +0 -2020
  279. package/doc/PartitionStrategy.html +0 -387
  280. package/doc/Path.html +0 -242
  281. package/doc/PlainTextSaslAuthenticator.html +0 -456
  282. package/doc/ProductiveByStrategy.html +0 -258
  283. package/doc/RemoteConnection.html +0 -1086
  284. package/doc/RemoteStrategy.html +0 -307
  285. package/doc/RemoteTraversal.html +0 -170
  286. package/doc/ReservedKeysVerificationStrategy.html +0 -261
  287. package/doc/ResponseError.html +0 -360
  288. package/doc/ResultSet.html +0 -633
  289. package/doc/SaslAuthenticator.html +0 -455
  290. package/doc/SaslMechanismBase.html +0 -506
  291. package/doc/SaslMechanismPlain.html +0 -925
  292. package/doc/SeedStrategy.html +0 -288
  293. package/doc/SubgraphStrategy.html +0 -387
  294. package/doc/TextP.html +0 -1440
  295. package/doc/Transaction.html +0 -655
  296. package/doc/Translator.html +0 -527
  297. package/doc/TraversalStrategies.html +0 -652
  298. package/doc/TraversalStrategy.html +0 -393
  299. package/doc/TypeSerializer.html +0 -166
  300. package/doc/driver_auth_authenticator.js.html +0 -89
  301. package/doc/driver_auth_mechanisms_sasl-mechanism-base.js.html +0 -103
  302. package/doc/driver_auth_mechanisms_sasl-mechanism-plain.js.html +0 -157
  303. package/doc/driver_auth_plain-text-sasl-authenticator.js.html +0 -106
  304. package/doc/driver_auth_sasl-authenticator.js.html +0 -100
  305. package/doc/driver_client.js.html +0 -250
  306. package/doc/driver_connection.js.html +0 -518
  307. package/doc/driver_driver-remote-connection.js.html +0 -193
  308. package/doc/driver_remote-connection.js.html +0 -198
  309. package/doc/driver_response-error.js.html +0 -98
  310. package/doc/driver_result-set.js.html +0 -134
  311. package/doc/fonts/OpenSans-Bold-webfont.eot +0 -0
  312. package/doc/fonts/OpenSans-Bold-webfont.svg +0 -1830
  313. package/doc/fonts/OpenSans-Bold-webfont.woff +0 -0
  314. package/doc/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  315. package/doc/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  316. package/doc/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  317. package/doc/fonts/OpenSans-Italic-webfont.eot +0 -0
  318. package/doc/fonts/OpenSans-Italic-webfont.svg +0 -1830
  319. package/doc/fonts/OpenSans-Italic-webfont.woff +0 -0
  320. package/doc/fonts/OpenSans-Light-webfont.eot +0 -0
  321. package/doc/fonts/OpenSans-Light-webfont.svg +0 -1831
  322. package/doc/fonts/OpenSans-Light-webfont.woff +0 -0
  323. package/doc/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  324. package/doc/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  325. package/doc/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  326. package/doc/fonts/OpenSans-Regular-webfont.eot +0 -0
  327. package/doc/fonts/OpenSans-Regular-webfont.svg +0 -1831
  328. package/doc/fonts/OpenSans-Regular-webfont.woff +0 -0
  329. package/doc/global.html +0 -728
  330. package/doc/index.html +0 -185
  331. package/doc/module.exports.html +0 -301
  332. package/doc/process_anonymous-traversal.js.html +0 -138
  333. package/doc/process_bytecode.js.html +0 -175
  334. package/doc/process_graph-traversal.js.html +0 -1936
  335. package/doc/process_transaction.js.html +0 -151
  336. package/doc/process_translator.js.html +0 -172
  337. package/doc/process_traversal-strategy.js.html +0 -466
  338. package/doc/process_traversal.js.html +0 -592
  339. package/doc/scripts/linenumber.js +0 -25
  340. package/doc/scripts/prettify/Apache-License-2.0.txt +0 -202
  341. package/doc/scripts/prettify/lang-css.js +0 -2
  342. package/doc/scripts/prettify/prettify.js +0 -28
  343. package/doc/structure_graph.js.html +0 -233
  344. package/doc/structure_io_binary_internals_DataType.js.html +0 -151
  345. package/doc/structure_io_binary_internals_GraphBinaryReader.js.html +0 -133
  346. package/doc/structure_io_binary_internals_GraphBinaryWriter.js.html +0 -136
  347. package/doc/structure_io_graph-serializer.js.html +0 -354
  348. package/doc/structure_io_type-serializers.js.html +0 -617
  349. package/doc/styles/jsdoc-default.css +0 -358
  350. package/doc/styles/prettify-jsdoc.css +0 -111
  351. package/doc/styles/prettify-tomorrow.css +0 -132
  352. package/doc/utils.js.html +0 -181
  353. package/docker-compose.yml +0 -76
  354. package/eslint.config.mjs +0 -143
  355. package/lib/driver/auth/mechanisms/sasl-mechanism-plain.js +0 -106
  356. package/lib/driver/auth/plain-text-sasl-authenticator.js +0 -55
  357. package/lib/driver/auth/sasl-authenticator.js +0 -49
  358. package/lib/driver/client.js +0 -199
  359. package/lib/driver/connection.js +0 -467
  360. package/lib/driver/driver-remote-connection.js +0 -142
  361. package/lib/driver/remote-connection.js +0 -147
  362. package/lib/driver/result-set.js +0 -83
  363. package/lib/process/anonymous-traversal.js +0 -87
  364. package/lib/process/bytecode.js +0 -124
  365. package/lib/process/graph-traversal.js +0 -1885
  366. package/lib/process/transaction.js +0 -100
  367. package/lib/process/translator.js +0 -121
  368. package/lib/process/traversal-strategy.js +0 -415
  369. package/lib/process/traversal.js +0 -541
  370. package/lib/structure/graph.js +0 -182
  371. package/lib/structure/io/binary/GraphBinary.js +0 -110
  372. package/lib/structure/io/binary/internals/AnySerializer.js +0 -100
  373. package/lib/structure/io/binary/internals/ArraySerializer.js +0 -137
  374. package/lib/structure/io/binary/internals/BigIntegerSerializer.js +0 -153
  375. package/lib/structure/io/binary/internals/BooleanSerializer.js +0 -105
  376. package/lib/structure/io/binary/internals/BulkSetSerializer.js +0 -126
  377. package/lib/structure/io/binary/internals/ByteBufferSerializer.js +0 -126
  378. package/lib/structure/io/binary/internals/ByteSerializer.js +0 -97
  379. package/lib/structure/io/binary/internals/BytecodeSerializer.js +0 -250
  380. package/lib/structure/io/binary/internals/ClassSerializer.js +0 -60
  381. package/lib/structure/io/binary/internals/DataType.js +0 -100
  382. package/lib/structure/io/binary/internals/DateSerializer.js +0 -105
  383. package/lib/structure/io/binary/internals/DoubleSerializer.js +0 -101
  384. package/lib/structure/io/binary/internals/EdgeSerializer.js +0 -216
  385. package/lib/structure/io/binary/internals/EnumSerializer.js +0 -152
  386. package/lib/structure/io/binary/internals/FloatSerializer.js +0 -101
  387. package/lib/structure/io/binary/internals/GraphBinaryReader.js +0 -82
  388. package/lib/structure/io/binary/internals/GraphBinaryWriter.js +0 -85
  389. package/lib/structure/io/binary/internals/IntSerializer.js +0 -114
  390. package/lib/structure/io/binary/internals/LambdaSerializer.js +0 -71
  391. package/lib/structure/io/binary/internals/LongSerializer.js +0 -109
  392. package/lib/structure/io/binary/internals/LongSerializerNg.js +0 -104
  393. package/lib/structure/io/binary/internals/MapSerializer.js +0 -155
  394. package/lib/structure/io/binary/internals/NumberSerializationStrategy.js +0 -73
  395. package/lib/structure/io/binary/internals/OffsetDateTimeSerializer.js +0 -151
  396. package/lib/structure/io/binary/internals/PSerializer.js +0 -152
  397. package/lib/structure/io/binary/internals/PathSerializer.js +0 -124
  398. package/lib/structure/io/binary/internals/PropertySerializer.js +0 -142
  399. package/lib/structure/io/binary/internals/SetSerializer.js +0 -134
  400. package/lib/structure/io/binary/internals/ShortSerializer.js +0 -101
  401. package/lib/structure/io/binary/internals/StringSerializer.js +0 -116
  402. package/lib/structure/io/binary/internals/TextPSerializer.js +0 -146
  403. package/lib/structure/io/binary/internals/TraversalStrategySerializer.js +0 -69
  404. package/lib/structure/io/binary/internals/TraverserSerializer.js +0 -124
  405. package/lib/structure/io/binary/internals/UnspecifiedNullSerializer.js +0 -77
  406. package/lib/structure/io/binary/internals/UuidSerializer.js +0 -121
  407. package/lib/structure/io/binary/internals/VertexPropertySerializer.js +0 -176
  408. package/lib/structure/io/binary/internals/VertexSerializer.js +0 -139
  409. package/lib/structure/io/graph-serializer.js +0 -303
  410. package/lib/structure/io/type-serializers.js +0 -566
  411. package/lib/utils.js +0 -130
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  "License"); you may not use this file except in compliance
9
9
  with the License. You may obtain a copy of the License at
10
10
 
11
- http://www.apache.org/licenses/LICENSE-2.0
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
12
 
13
13
  Unless required by applicable law or agreed to in writing,
14
14
  software distributed under the License is distributed on an
@@ -36,17 +36,31 @@ Gremlin-Javascript is designed to connect to a "server" that is hosting a Tinker
36
36
  could be [Gremlin Server][gs] or a [remote Gremlin provider][rgp] that exposes protocols by which Gremlin-Javascript
37
37
  can connect.
38
38
 
39
- A typical connection to a server running on "localhost" that supports the Gremlin Server protocol using websockets
40
- looks like this:
39
+ A typical connection to a server running on "localhost" that supports the Gremlin Server protocol looks like this:
41
40
 
42
41
  ```javascript
43
42
  const gremlin = require('gremlin');
44
43
  const traversal = gremlin.process.AnonymousTraversalSource.traversal;
45
44
  const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
46
45
 
47
- const g = traversal().with_(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
46
+ const g = traversal().with_(new DriverRemoteConnection('http://localhost:8182/gremlin'));
48
47
  ```
49
48
 
49
+ Some graph providers may require additional request customization to connect. The driver supports request interceptors
50
+ for these cases. For example, to connect with basic authentication:
51
+
52
+ ```javascript
53
+ const gremlin = require('gremlin');
54
+ const traversal = gremlin.process.AnonymousTraversalSource.traversal;
55
+ const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
56
+
57
+ const g = traversal().with_(new DriverRemoteConnection('http://localhost:8182/gremlin', {
58
+ interceptors: gremlin.driver.auth.basic('username', 'password')
59
+ }));
60
+ ```
61
+
62
+ Refer to your graph provider's documentation for specific connection requirements.
63
+
50
64
  Once "g" has been created using a connection, it is then possible to start writing Gremlin traversals to query the
51
65
  remote graph:
52
66
 
@@ -0,0 +1,69 @@
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
+ exports.basic = basic;
22
+ exports.sigv4 = sigv4;
23
+ const buffer_1 = require("node:buffer");
24
+ function basic(username, password) {
25
+ return (request) => {
26
+ request.headers['authorization'] = 'Basic ' + buffer_1.Buffer.from(`${username}:${password}`).toString('base64');
27
+ return request;
28
+ };
29
+ }
30
+ function sigv4(region, service, credentialsProvider) {
31
+ let signer;
32
+ let resolvedProvider;
33
+ return async (request) => {
34
+ // Lazy-initialize signer and credentials provider on first use
35
+ if (!signer) {
36
+ const { SignatureV4 } = await import('@smithy/signature-v4');
37
+ const { Hash } = await import('@smithy/hash-node');
38
+ if (credentialsProvider) {
39
+ resolvedProvider = credentialsProvider;
40
+ }
41
+ else {
42
+ const { fromNodeProviderChain } = await import('@aws-sdk/credential-providers');
43
+ const chain = fromNodeProviderChain({ clientConfig: { region } });
44
+ resolvedProvider = () => chain();
45
+ }
46
+ signer = new SignatureV4({
47
+ service,
48
+ region,
49
+ sha256: Hash.bind(null, 'sha256'),
50
+ credentials: () => Promise.resolve(resolvedProvider()),
51
+ });
52
+ }
53
+ const url = new URL(request.url);
54
+ const signed = await signer.sign({
55
+ method: request.method,
56
+ protocol: url.protocol,
57
+ hostname: url.hostname,
58
+ port: url.port ? Number(url.port) : undefined,
59
+ path: url.pathname + url.search,
60
+ headers: {
61
+ ...request.headers,
62
+ host: url.host,
63
+ },
64
+ body: request.body,
65
+ });
66
+ request.headers = signed.headers;
67
+ return request;
68
+ };
69
+ }
@@ -0,0 +1,9 @@
1
+ import type { RequestInterceptor } from './connection.cjs';
2
+ export declare function basic(username: string, password: string): RequestInterceptor;
3
+ export interface AwsCredentials {
4
+ accessKeyId: string;
5
+ secretAccessKey: string;
6
+ sessionToken?: string;
7
+ }
8
+ export type AwsCredentialsProvider = () => AwsCredentials | Promise<AwsCredentials>;
9
+ export declare function sigv4(region: string, service: string, credentialsProvider?: AwsCredentialsProvider): RequestInterceptor;
@@ -0,0 +1,134 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const connection_js_1 = __importDefault(require("./connection.cjs"));
25
+ const request_message_js_1 = require("./request-message.cjs");
26
+ /**
27
+ * A {@link Client} contains methods to send messages to a Gremlin Server.
28
+ */
29
+ class Client {
30
+ options;
31
+ _connection;
32
+ /**
33
+ * Creates a new instance of {@link Client}.
34
+ * @param {String} url The resource uri.
35
+ * @param {ClientOptions} [options] The connection options.
36
+ */
37
+ constructor(url, options = {}) {
38
+ this.options = options;
39
+ this._connection = new connection_js_1.default(url, options);
40
+ }
41
+ /**
42
+ * Opens the underlying connection to the Gremlin Server, if it's not already opened.
43
+ * @returns {Promise}
44
+ */
45
+ open() {
46
+ return this._connection.open();
47
+ }
48
+ /**
49
+ * Returns true if the underlying connection is open
50
+ * @returns {Boolean}
51
+ */
52
+ get isOpen() {
53
+ return this._connection.isOpen;
54
+ }
55
+ /**
56
+ * Configuration specific to the current request.
57
+ * @typedef {Object} RequestOptions
58
+ * @property {any} bindings - The parameter bindings to apply to the script.
59
+ * @property {String} language - The language of the script to execute. Defaults to 'gremlin-lang'.
60
+ * @property {String} accept - The MIME type expected in the response.
61
+ * @property {Boolean} bulkResults - Indicates whether results should be returned in bulk format.
62
+ * @property {Object} params - Additional parameters to include with the request.
63
+ * @property {Number} batchSize - The size in which the result of a request is to be 'batched' back to the client.
64
+ * @property {String} userAgent - The user agent string to send with the request.
65
+ * @property {Number} evaluationTimeout - The timeout for the evaluation of the request.
66
+ * @property {String} materializeProperties - Indicates whether element properties should be returned or not.
67
+ */
68
+ /**
69
+ * Send a request to the Gremlin Server.
70
+ * @param {string} message The script to send
71
+ * @param {Object|null} [bindings] The script bindings, if any.
72
+ * @param {RequestOptions} [requestOptions] Configuration specific to the current request.
73
+ * @returns {Promise}
74
+ */ //TODO:: tighten return type to Promise<ResultSet>
75
+ submit(message, bindings, requestOptions) {
76
+ const requestBuilder = request_message_js_1.RequestMessage.build(message)
77
+ .addG(this.options.traversalSource || 'g');
78
+ if (requestOptions?.language) {
79
+ requestBuilder.addLanguage(requestOptions.language);
80
+ }
81
+ if (requestOptions?.bindings) {
82
+ requestBuilder.addBindings(requestOptions.bindings);
83
+ }
84
+ if (bindings) {
85
+ requestBuilder.addBindings(bindings);
86
+ }
87
+ if (requestOptions?.materializeProperties) {
88
+ requestBuilder.addMaterializeProperties(requestOptions.materializeProperties);
89
+ }
90
+ if (requestOptions?.evaluationTimeout) {
91
+ requestBuilder.addTimeoutMillis(requestOptions.evaluationTimeout);
92
+ }
93
+ if (requestOptions?.bulkResults) {
94
+ requestBuilder.addBulkResults(requestOptions.bulkResults);
95
+ }
96
+ return this._connection.submit(requestBuilder.create());
97
+ }
98
+ /**
99
+ * Send a request to the Gremlin Server and receive a stream for the results.
100
+ * @param {string} message The script to send
101
+ * @param {Object} [bindings] The script bindings, if any.
102
+ * @param {RequestOptions} [requestOptions] Configuration specific to the current request.
103
+ * @returns {ReadableStream}
104
+ */
105
+ //TODO:: Update stream() to mirror submit()
106
+ stream(message, bindings, requestOptions) {
107
+ throw new Error("Stream not yet implemented");
108
+ }
109
+ /**
110
+ * Closes the underlying connection
111
+ * send session close request before connection close if session mode
112
+ * @returns {Promise}
113
+ */
114
+ close() {
115
+ return this._connection.close();
116
+ }
117
+ /**
118
+ * Adds an event listener to the connection
119
+ * @param {String} event The event name that you want to listen to.
120
+ * @param {Function} handler The callback to be called when the event occurs.
121
+ */
122
+ addListener(event, handler) {
123
+ this._connection.on(event, handler);
124
+ }
125
+ /**
126
+ * Removes a previowsly added event listener to the connection
127
+ * @param {String} event The event name that you want to listen to.
128
+ * @param {Function} handler The event handler to be removed.
129
+ */
130
+ removeListener(event, handler) {
131
+ this._connection.removeListener(event, handler);
132
+ }
133
+ }
134
+ exports.default = Client;
@@ -0,0 +1,85 @@
1
+ import { ConnectionOptions } from './connection.cjs';
2
+ import { Readable } from 'stream';
3
+ export type RequestOptions = {
4
+ bindings?: any;
5
+ language?: string;
6
+ accept?: string;
7
+ evaluationTimeout?: number;
8
+ batchSize?: number;
9
+ userAgent?: string;
10
+ materializeProperties?: string;
11
+ bulkResults?: boolean;
12
+ params?: Record<string, any>;
13
+ };
14
+ export type ClientOptions = ConnectionOptions & RequestOptions & {
15
+ processor?: string;
16
+ };
17
+ /**
18
+ * A {@link Client} contains methods to send messages to a Gremlin Server.
19
+ */
20
+ export default class Client {
21
+ private readonly options;
22
+ private readonly _connection;
23
+ /**
24
+ * Creates a new instance of {@link Client}.
25
+ * @param {String} url The resource uri.
26
+ * @param {ClientOptions} [options] The connection options.
27
+ */
28
+ constructor(url: string, options?: ClientOptions);
29
+ /**
30
+ * Opens the underlying connection to the Gremlin Server, if it's not already opened.
31
+ * @returns {Promise}
32
+ */
33
+ open(): Promise<void>;
34
+ /**
35
+ * Returns true if the underlying connection is open
36
+ * @returns {Boolean}
37
+ */
38
+ get isOpen(): boolean;
39
+ /**
40
+ * Configuration specific to the current request.
41
+ * @typedef {Object} RequestOptions
42
+ * @property {any} bindings - The parameter bindings to apply to the script.
43
+ * @property {String} language - The language of the script to execute. Defaults to 'gremlin-lang'.
44
+ * @property {String} accept - The MIME type expected in the response.
45
+ * @property {Boolean} bulkResults - Indicates whether results should be returned in bulk format.
46
+ * @property {Object} params - Additional parameters to include with the request.
47
+ * @property {Number} batchSize - The size in which the result of a request is to be 'batched' back to the client.
48
+ * @property {String} userAgent - The user agent string to send with the request.
49
+ * @property {Number} evaluationTimeout - The timeout for the evaluation of the request.
50
+ * @property {String} materializeProperties - Indicates whether element properties should be returned or not.
51
+ */
52
+ /**
53
+ * Send a request to the Gremlin Server.
54
+ * @param {string} message The script to send
55
+ * @param {Object|null} [bindings] The script bindings, if any.
56
+ * @param {RequestOptions} [requestOptions] Configuration specific to the current request.
57
+ * @returns {Promise}
58
+ */ submit(message: string, bindings: any | null, requestOptions?: RequestOptions): Promise<any>;
59
+ /**
60
+ * Send a request to the Gremlin Server and receive a stream for the results.
61
+ * @param {string} message The script to send
62
+ * @param {Object} [bindings] The script bindings, if any.
63
+ * @param {RequestOptions} [requestOptions] Configuration specific to the current request.
64
+ * @returns {ReadableStream}
65
+ */
66
+ stream(message: string, bindings: any, requestOptions?: RequestOptions): Readable;
67
+ /**
68
+ * Closes the underlying connection
69
+ * send session close request before connection close if session mode
70
+ * @returns {Promise}
71
+ */
72
+ close(): Promise<void>;
73
+ /**
74
+ * Adds an event listener to the connection
75
+ * @param {String} event The event name that you want to listen to.
76
+ * @param {Function} handler The callback to be called when the event occurs.
77
+ */
78
+ addListener(event: string, handler: (...args: any[]) => unknown): void;
79
+ /**
80
+ * Removes a previowsly added event listener to the connection
81
+ * @param {String} event The event name that you want to listen to.
82
+ * @param {Function} handler The event handler to be removed.
83
+ */
84
+ removeListener(event: string, handler: (...args: any[]) => unknown): void;
85
+ }
@@ -0,0 +1,250 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
32
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
33
+ }) : function(o, v) {
34
+ o["default"] = v;
35
+ });
36
+ var __importStar = (this && this.__importStar) || (function () {
37
+ var ownKeys = function(o) {
38
+ ownKeys = Object.getOwnPropertyNames || function (o) {
39
+ var ar = [];
40
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
41
+ return ar;
42
+ };
43
+ return ownKeys(o);
44
+ };
45
+ return function (mod) {
46
+ if (mod && mod.__esModule) return mod;
47
+ var result = {};
48
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
49
+ __setModuleDefault(result, mod);
50
+ return result;
51
+ };
52
+ })();
53
+ var __importDefault = (this && this.__importDefault) || function (mod) {
54
+ return (mod && mod.__esModule) ? mod : { "default": mod };
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ /**
58
+ * @author Jorge Bay Gondra
59
+ */
60
+ const buffer_1 = require("node:buffer");
61
+ const eventemitter3_1 = require("eventemitter3");
62
+ const GraphBinary_js_1 = __importDefault(require("../structure/io/binary/GraphBinary.cjs"));
63
+ const utils = __importStar(require("../utils.cjs"));
64
+ const result_set_js_1 = __importDefault(require("./result-set.cjs"));
65
+ const response_error_js_1 = __importDefault(require("./response-error.cjs"));
66
+ const traversal_js_1 = require("../process/traversal.cjs");
67
+ const { DeferredPromise } = utils;
68
+ const { graphBinaryReader, graphBinaryWriter } = GraphBinary_js_1.default;
69
+ const responseStatusCode = {
70
+ success: 200,
71
+ noContent: 204,
72
+ partialContent: 206,
73
+ authenticationChallenge: 407,
74
+ };
75
+ /**
76
+ * Represents a single connection to a Gremlin Server.
77
+ */
78
+ class Connection extends eventemitter3_1.EventEmitter {
79
+ url;
80
+ options;
81
+ _reader;
82
+ _writer;
83
+ isOpen = true;
84
+ traversalSource;
85
+ _enableUserAgentOnConnect;
86
+ _interceptors;
87
+ /**
88
+ * Creates a new instance of {@link Connection}.
89
+ * @param {String} url The resource uri.
90
+ * @param {ConnectionOptions} [options] The connection options.
91
+ */
92
+ constructor(url, options = {}) {
93
+ super();
94
+ this.url = url;
95
+ this.options = options;
96
+ this._reader = options.reader || graphBinaryReader;
97
+ this._writer = 'writer' in options ? options.writer : graphBinaryWriter;
98
+ this.traversalSource = options.traversalSource || 'g';
99
+ this._enableUserAgentOnConnect = options.enableUserAgentOnConnect !== false;
100
+ const interceptors = options.interceptors;
101
+ if (typeof interceptors === 'function') {
102
+ this._interceptors = [interceptors];
103
+ }
104
+ else if (Array.isArray(interceptors)) {
105
+ this._interceptors = interceptors;
106
+ }
107
+ else if (interceptors === undefined || interceptors === null) {
108
+ this._interceptors = [];
109
+ }
110
+ else {
111
+ throw new TypeError('interceptors must be a function, array, or undefined');
112
+ }
113
+ }
114
+ /**
115
+ * Opens the connection, if its not already opened.
116
+ * @returns {Promise}
117
+ */
118
+ async open() {
119
+ // No-op for HTTP connections
120
+ return Promise.resolve();
121
+ }
122
+ /** @override */
123
+ submit(request) {
124
+ // The user may not want the body to be serialized if they are using an interceptor.
125
+ const body = this._writer ? this._writer.writeRequest(request) : request;
126
+ return this.#makeHttpRequest(body)
127
+ .then((response) => {
128
+ return this.#handleResponse(response);
129
+ });
130
+ }
131
+ /** @override */
132
+ stream(request) {
133
+ throw new Error('stream() is not yet implemented');
134
+ }
135
+ #getReaderForContentType(contentType) {
136
+ if (!contentType) {
137
+ return this._reader;
138
+ }
139
+ if (contentType === this._reader.mimeType) {
140
+ return this._reader;
141
+ }
142
+ return null;
143
+ }
144
+ async #makeHttpRequest(body) {
145
+ const headers = {
146
+ 'Accept': this._reader.mimeType
147
+ };
148
+ if (this._writer) {
149
+ headers['Content-Type'] = this._writer.mimeType;
150
+ }
151
+ if (this._enableUserAgentOnConnect) {
152
+ const userAgent = await utils.getUserAgent();
153
+ if (userAgent !== undefined) {
154
+ headers[utils.getUserAgentHeader()] = userAgent;
155
+ }
156
+ }
157
+ if (this.options.headers) {
158
+ Object.entries(this.options.headers).forEach(([key, value]) => {
159
+ headers[key] = Array.isArray(value) ? value.join(', ') : value;
160
+ });
161
+ }
162
+ let httpRequest = {
163
+ url: this.url,
164
+ method: 'POST',
165
+ headers,
166
+ body,
167
+ };
168
+ for (let i = 0; i < this._interceptors.length; i++) {
169
+ try {
170
+ httpRequest = await this._interceptors[i](httpRequest);
171
+ }
172
+ catch (e) {
173
+ throw new Error(`Request interceptor at index ${i} failed: ${e.message}`, { cause: e });
174
+ }
175
+ }
176
+ return fetch(httpRequest.url, {
177
+ method: httpRequest.method,
178
+ headers: httpRequest.headers,
179
+ body: httpRequest.body,
180
+ });
181
+ }
182
+ async #handleResponse(response) {
183
+ const contentType = response.headers.get("Content-Type");
184
+ const buffer = buffer_1.Buffer.from(await response.arrayBuffer());
185
+ const reader = this.#getReaderForContentType(contentType);
186
+ if (!response.ok) {
187
+ const errorMessage = `Server returned HTTP ${response.status}: ${response.statusText}`;
188
+ try {
189
+ if (reader) {
190
+ const deserialized = reader.readResponse(buffer);
191
+ const attributes = new Map();
192
+ if (deserialized.status.exception) {
193
+ attributes.set('exceptions', deserialized.status.exception);
194
+ attributes.set('stackTrace', deserialized.status.exception);
195
+ }
196
+ throw new response_error_js_1.default(errorMessage, {
197
+ code: deserialized.status.code,
198
+ message: deserialized.status.message || response.statusText,
199
+ attributes: attributes,
200
+ });
201
+ }
202
+ else if (contentType === 'application/json') {
203
+ const errorBody = JSON.parse(buffer.toString());
204
+ throw new response_error_js_1.default(errorMessage, {
205
+ code: response.status,
206
+ message: errorBody.message || errorBody.error || response.statusText,
207
+ attributes: new Map(),
208
+ });
209
+ }
210
+ }
211
+ catch (err) {
212
+ if (err instanceof response_error_js_1.default) {
213
+ throw err;
214
+ }
215
+ }
216
+ throw new response_error_js_1.default(errorMessage, {
217
+ code: response.status,
218
+ message: response.statusText,
219
+ attributes: new Map(),
220
+ });
221
+ }
222
+ if (!reader) {
223
+ throw new Error(`Response Content-Type '${contentType}' does not match the configured reader (expected '${this._reader.mimeType}')`);
224
+ }
225
+ const deserialized = reader.readResponse(buffer);
226
+ if (deserialized.status.code && deserialized.status.code !== 200 && deserialized.status.code !== 204 && deserialized.status.code !== 206) {
227
+ const attributes = new Map();
228
+ if (deserialized.status.exception) {
229
+ attributes.set('exceptions', deserialized.status.exception);
230
+ attributes.set('stackTrace', deserialized.status.exception);
231
+ }
232
+ throw new response_error_js_1.default(`Server error: ${deserialized.status.message || 'Unknown error'} (${deserialized.status.code})`, {
233
+ code: deserialized.status.code,
234
+ message: deserialized.status.message || '',
235
+ attributes: attributes,
236
+ });
237
+ }
238
+ return new result_set_js_1.default(deserialized.result.bulked
239
+ ? deserialized.result.data.map((item) => new traversal_js_1.Traverser(item.v, item.bulk))
240
+ : deserialized.result.data, new Map());
241
+ }
242
+ /**
243
+ * Closes the Connection.
244
+ * @return {Promise}
245
+ */
246
+ close() {
247
+ return Promise.resolve();
248
+ }
249
+ }
250
+ exports.default = Connection;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @author Jorge Bay Gondra
3
+ */
4
+ import { Buffer } from 'buffer';
5
+ import { EventEmitter } from 'eventemitter3';
6
+ import type { Agent } from 'node:http';
7
+ import ResultSet from './result-set.cjs';
8
+ import { RequestMessage } from "./request-message.cjs";
9
+ import { Readable } from "stream";
10
+ export type HttpRequest = {
11
+ url: string;
12
+ method: string;
13
+ headers: Record<string, string>;
14
+ body: any;
15
+ };
16
+ export type RequestInterceptor = (request: HttpRequest) => HttpRequest | Promise<HttpRequest>;
17
+ export type ConnectionOptions = {
18
+ ca?: string[];
19
+ cert?: string | string[] | Buffer;
20
+ pfx?: string | Buffer;
21
+ reader?: any;
22
+ rejectUnauthorized?: boolean;
23
+ traversalSource?: string;
24
+ writer?: any | null;
25
+ headers?: Record<string, string | string[]>;
26
+ enableUserAgentOnConnect?: boolean;
27
+ agent?: Agent;
28
+ interceptors?: RequestInterceptor | RequestInterceptor[];
29
+ };
30
+ /**
31
+ * Represents a single connection to a Gremlin Server.
32
+ */
33
+ export default class Connection extends EventEmitter {
34
+ #private;
35
+ readonly url: string;
36
+ readonly options: ConnectionOptions;
37
+ private readonly _reader;
38
+ private readonly _writer;
39
+ isOpen: boolean;
40
+ traversalSource: string;
41
+ private readonly _enableUserAgentOnConnect;
42
+ private readonly _interceptors;
43
+ /**
44
+ * Creates a new instance of {@link Connection}.
45
+ * @param {String} url The resource uri.
46
+ * @param {ConnectionOptions} [options] The connection options.
47
+ */
48
+ constructor(url: string, options?: ConnectionOptions);
49
+ /**
50
+ * Opens the connection, if its not already opened.
51
+ * @returns {Promise}
52
+ */
53
+ open(): Promise<void>;
54
+ /** @override */
55
+ submit(request: RequestMessage): Promise<ResultSet>;
56
+ /** @override */
57
+ stream(request: RequestMessage): Readable;
58
+ /**
59
+ * Closes the Connection.
60
+ * @return {Promise}
61
+ */
62
+ close(): Promise<void>;
63
+ }