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.
- package/README.md +18 -4
- package/build/cjs/driver/auth.cjs +69 -0
- package/build/cjs/driver/auth.d.cts +9 -0
- package/build/cjs/driver/client.cjs +134 -0
- package/build/cjs/driver/client.d.cts +85 -0
- package/build/cjs/driver/connection.cjs +250 -0
- package/build/cjs/driver/connection.d.cts +63 -0
- package/build/cjs/driver/driver-remote-connection.cjs +141 -0
- package/build/cjs/driver/driver-remote-connection.d.cts +33 -0
- package/build/cjs/driver/remote-connection.cjs +75 -0
- package/build/cjs/driver/remote-connection.d.cts +72 -0
- package/build/cjs/driver/request-message.cjs +157 -0
- package/build/cjs/driver/request-message.d.cts +49 -0
- package/build/cjs/driver/response-error.cjs +45 -0
- package/build/cjs/driver/response-error.d.cts +13 -0
- package/build/cjs/driver/result-set.cjs +111 -0
- package/build/cjs/driver/result-set.d.cts +29 -0
- package/build/cjs/index.cjs +125 -0
- package/build/cjs/index.d.cts +393 -0
- package/build/cjs/language/grammar/GremlinLexer.cjs +1851 -0
- package/build/cjs/language/grammar/GremlinLexer.d.cts +340 -0
- package/build/cjs/language/grammar/GremlinListener.cjs +4490 -0
- package/build/cjs/language/grammar/GremlinListener.d.cts +4898 -0
- package/build/cjs/language/grammar/GremlinParser.cjs +35244 -0
- package/build/cjs/language/grammar/GremlinParser.d.cts +5881 -0
- package/build/cjs/language/index.cjs +48 -0
- package/build/cjs/language/index.d.cts +12 -0
- package/build/cjs/language/translator/AnonymizedTranslateVisitor.cjs +157 -0
- package/build/cjs/language/translator/AnonymizedTranslateVisitor.d.cts +36 -0
- package/build/cjs/language/translator/DotNetTranslateVisitor.cjs +826 -0
- package/build/cjs/language/translator/DotNetTranslateVisitor.d.cts +155 -0
- package/build/cjs/language/translator/GoTranslateVisitor.cjs +339 -0
- package/build/cjs/language/translator/GoTranslateVisitor.d.cts +31 -0
- package/build/cjs/language/translator/GremlinTranslator.cjs +96 -0
- package/build/cjs/language/translator/GremlinTranslator.d.cts +18 -0
- package/build/cjs/language/translator/GroovyTranslateVisitor.cjs +287 -0
- package/build/cjs/language/translator/GroovyTranslateVisitor.d.cts +34 -0
- package/build/cjs/language/translator/JavaTranslateVisitor.cjs +247 -0
- package/build/cjs/language/translator/JavaTranslateVisitor.d.cts +23 -0
- package/build/cjs/language/translator/JavascriptTranslateVisitor.cjs +220 -0
- package/build/cjs/language/translator/JavascriptTranslateVisitor.d.cts +25 -0
- package/build/cjs/language/translator/PythonTranslateVisitor.cjs +304 -0
- package/build/cjs/language/translator/PythonTranslateVisitor.d.cts +28 -0
- package/build/cjs/language/translator/TranslateVisitor.cjs +389 -0
- package/build/cjs/language/translator/TranslateVisitor.d.cts +91 -0
- package/build/cjs/language/translator/Translation.cjs +47 -0
- package/build/cjs/language/translator/Translation.d.cts +13 -0
- package/build/cjs/language/translator/Translator.cjs +46 -0
- package/build/cjs/language/translator/Translator.d.cts +24 -0
- package/build/cjs/language/translator/TranslatorException.cjs +31 -0
- package/build/cjs/language/translator/TranslatorException.d.cts +6 -0
- package/build/cjs/process/anonymous-traversal.cjs +78 -0
- package/build/cjs/process/anonymous-traversal.d.cts +40 -0
- package/build/cjs/process/graph-traversal.cjs +1702 -0
- package/build/cjs/process/graph-traversal.d.cts +1134 -0
- package/build/cjs/process/gremlin-lang.cjs +196 -0
- package/build/cjs/process/gremlin-lang.d.cts +15 -0
- package/build/cjs/process/transaction.cjs +69 -0
- package/build/cjs/process/transaction.d.cts +34 -0
- package/build/cjs/process/traversal-strategy.cjs +360 -0
- package/build/cjs/process/traversal-strategy.d.cts +211 -0
- package/build/cjs/process/traversal.cjs +482 -0
- package/build/cjs/process/traversal.d.cts +186 -0
- package/build/cjs/structure/graph.cjs +157 -0
- package/build/cjs/structure/graph.d.cts +57 -0
- package/build/cjs/structure/io/binary/GraphBinary.cjs +148 -0
- package/build/cjs/structure/io/binary/GraphBinary.d.cts +91 -0
- package/build/cjs/structure/io/binary/internals/AnySerializer.cjs +80 -0
- package/build/cjs/structure/io/binary/internals/AnySerializer.d.cts +8 -0
- package/build/cjs/structure/io/binary/internals/ArraySerializer.cjs +139 -0
- package/build/cjs/structure/io/binary/internals/ArraySerializer.d.cts +15 -0
- package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.cjs +136 -0
- package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.d.cts +14 -0
- package/build/cjs/structure/io/binary/internals/BinarySerializer.cjs +112 -0
- package/build/cjs/structure/io/binary/internals/BinarySerializer.d.cts +11 -0
- package/build/cjs/structure/io/binary/internals/BooleanSerializer.cjs +93 -0
- package/build/cjs/structure/io/binary/internals/BooleanSerializer.d.cts +11 -0
- package/build/cjs/structure/io/binary/internals/ByteSerializer.cjs +88 -0
- package/build/cjs/structure/io/binary/internals/ByteSerializer.d.cts +10 -0
- package/build/cjs/structure/io/binary/internals/DataType.cjs +63 -0
- package/build/cjs/structure/io/binary/internals/DataType.d.cts +35 -0
- package/build/cjs/structure/io/binary/internals/DateTimeSerializer.cjs +139 -0
- package/build/cjs/structure/io/binary/internals/DateTimeSerializer.d.cts +15 -0
- package/build/cjs/structure/io/binary/internals/DoubleSerializer.cjs +91 -0
- package/build/cjs/structure/io/binary/internals/DoubleSerializer.d.cts +11 -0
- package/build/cjs/structure/io/binary/internals/EdgeSerializer.cjs +201 -0
- package/build/cjs/structure/io/binary/internals/EdgeSerializer.d.cts +20 -0
- package/build/cjs/structure/io/binary/internals/EnumSerializer.cjs +127 -0
- package/build/cjs/structure/io/binary/internals/EnumSerializer.d.cts +24 -0
- package/build/cjs/structure/io/binary/internals/FloatSerializer.cjs +91 -0
- package/build/cjs/structure/io/binary/internals/FloatSerializer.d.cts +11 -0
- package/build/cjs/structure/io/binary/internals/GraphBinaryReader.cjs +97 -0
- package/build/cjs/structure/io/binary/internals/GraphBinaryReader.d.cts +19 -0
- package/build/cjs/structure/io/binary/internals/GraphBinaryWriter.cjs +85 -0
- package/build/cjs/structure/io/binary/internals/GraphBinaryWriter.d.cts +9 -0
- package/build/cjs/structure/io/binary/internals/IntSerializer.cjs +103 -0
- package/build/cjs/structure/io/binary/internals/IntSerializer.d.cts +13 -0
- package/build/cjs/structure/io/binary/internals/LongSerializer.cjs +95 -0
- package/build/cjs/structure/io/binary/internals/LongSerializer.d.cts +11 -0
- package/build/cjs/structure/io/binary/internals/MapSerializer.cjs +144 -0
- package/build/cjs/structure/io/binary/internals/MapSerializer.d.cts +13 -0
- package/build/cjs/structure/io/binary/internals/MarkerSerializer.cjs +63 -0
- package/build/cjs/structure/io/binary/internals/MarkerSerializer.d.cts +8 -0
- package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.cjs +66 -0
- package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.d.cts +9 -0
- package/build/cjs/structure/io/binary/internals/PathSerializer.cjs +113 -0
- package/build/cjs/structure/io/binary/internals/PathSerializer.d.cts +15 -0
- package/build/cjs/structure/io/binary/internals/PropertySerializer.cjs +130 -0
- package/build/cjs/structure/io/binary/internals/PropertySerializer.d.cts +15 -0
- package/build/cjs/structure/io/binary/internals/SetSerializer.cjs +138 -0
- package/build/cjs/structure/io/binary/internals/SetSerializer.d.cts +15 -0
- package/build/cjs/structure/io/binary/internals/ShortSerializer.cjs +91 -0
- package/build/cjs/structure/io/binary/internals/ShortSerializer.d.cts +11 -0
- package/build/cjs/structure/io/binary/internals/StringSerializer.cjs +107 -0
- package/build/cjs/structure/io/binary/internals/StringSerializer.d.cts +11 -0
- package/{lib/driver/auth/authenticator.js → build/cjs/structure/io/binary/internals/StubSerializer.cjs} +14 -20
- package/build/cjs/structure/io/binary/internals/StubSerializer.d.cts +7 -0
- package/build/cjs/structure/io/binary/internals/UnspecifiedNullSerializer.cjs +70 -0
- package/build/cjs/structure/io/binary/internals/UnspecifiedNullSerializer.d.cts +11 -0
- package/build/cjs/structure/io/binary/internals/UuidSerializer.cjs +109 -0
- package/build/cjs/structure/io/binary/internals/UuidSerializer.d.cts +14 -0
- package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.cjs +163 -0
- package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.d.cts +15 -0
- package/build/cjs/structure/io/binary/internals/VertexSerializer.cjs +128 -0
- package/build/cjs/structure/io/binary/internals/VertexSerializer.d.cts +17 -0
- package/build/cjs/structure/io/binary/internals/utils.cjs +53 -0
- package/build/cjs/structure/io/binary/internals/utils.d.cts +6 -0
- package/build/cjs/utils.cjs +142 -0
- package/build/cjs/utils.d.cts +20 -0
- package/build/esm/driver/auth.d.ts +9 -0
- package/build/esm/driver/auth.js +65 -0
- package/build/esm/driver/client.d.ts +85 -0
- package/build/esm/driver/client.js +128 -0
- package/build/esm/driver/connection.d.ts +63 -0
- package/build/esm/driver/connection.js +211 -0
- package/build/esm/driver/driver-remote-connection.d.ts +33 -0
- package/build/esm/driver/driver-remote-connection.js +102 -0
- package/build/esm/driver/remote-connection.d.ts +72 -0
- package/build/esm/driver/remote-connection.js +69 -0
- package/build/esm/driver/request-message.d.ts +49 -0
- package/build/esm/driver/request-message.js +152 -0
- package/build/esm/driver/response-error.d.ts +13 -0
- package/{lib → build/esm}/driver/response-error.js +21 -26
- package/build/esm/driver/result-set.d.ts +29 -0
- package/build/esm/driver/result-set.js +75 -0
- package/build/esm/index.d.ts +393 -0
- package/{index.js → build/esm/index.js} +23 -33
- package/build/esm/language/grammar/GremlinLexer.d.ts +340 -0
- package/build/esm/language/grammar/GremlinLexer.js +1814 -0
- package/build/esm/language/grammar/GremlinListener.d.ts +4898 -0
- package/build/esm/language/grammar/GremlinListener.js +4486 -0
- package/build/esm/language/grammar/GremlinParser.d.ts +5881 -0
- package/build/esm/language/grammar/GremlinParser.js +34711 -0
- package/build/esm/language/index.d.ts +12 -0
- package/build/esm/language/index.js +30 -0
- package/build/esm/language/translator/AnonymizedTranslateVisitor.d.ts +36 -0
- package/build/esm/language/translator/AnonymizedTranslateVisitor.js +151 -0
- package/build/esm/language/translator/DotNetTranslateVisitor.d.ts +155 -0
- package/build/esm/language/translator/DotNetTranslateVisitor.js +820 -0
- package/build/esm/language/translator/GoTranslateVisitor.d.ts +31 -0
- package/build/esm/language/translator/GoTranslateVisitor.js +333 -0
- package/build/esm/language/translator/GremlinTranslator.d.ts +18 -0
- package/build/esm/language/translator/GremlinTranslator.js +89 -0
- package/build/esm/language/translator/GroovyTranslateVisitor.d.ts +34 -0
- package/build/esm/language/translator/GroovyTranslateVisitor.js +281 -0
- package/build/esm/language/translator/JavaTranslateVisitor.d.ts +23 -0
- package/build/esm/language/translator/JavaTranslateVisitor.js +241 -0
- package/build/esm/language/translator/JavascriptTranslateVisitor.d.ts +25 -0
- package/build/esm/language/translator/JavascriptTranslateVisitor.js +214 -0
- package/build/esm/language/translator/PythonTranslateVisitor.d.ts +28 -0
- package/build/esm/language/translator/PythonTranslateVisitor.js +298 -0
- package/build/esm/language/translator/TranslateVisitor.d.ts +91 -0
- package/build/esm/language/translator/TranslateVisitor.js +386 -0
- package/build/esm/language/translator/Translation.d.ts +13 -0
- package/build/esm/language/translator/Translation.js +43 -0
- package/build/esm/language/translator/Translator.d.ts +24 -0
- package/build/esm/language/translator/Translator.js +40 -0
- package/build/esm/language/translator/TranslatorException.d.ts +6 -0
- package/build/esm/language/translator/TranslatorException.js +27 -0
- package/build/esm/process/anonymous-traversal.d.ts +40 -0
- package/build/esm/process/anonymous-traversal.js +72 -0
- package/build/esm/process/graph-traversal.d.ts +1134 -0
- package/build/esm/process/graph-traversal.js +1693 -0
- package/build/esm/process/gremlin-lang.d.ts +15 -0
- package/build/esm/process/gremlin-lang.js +193 -0
- package/build/esm/process/transaction.d.ts +34 -0
- package/build/esm/process/transaction.js +65 -0
- package/build/esm/process/traversal-strategy.d.ts +211 -0
- package/build/esm/process/traversal-strategy.js +319 -0
- package/build/esm/process/traversal.d.ts +186 -0
- package/build/esm/process/traversal.js +469 -0
- package/build/esm/structure/graph.d.ts +57 -0
- package/build/esm/structure/graph.js +148 -0
- package/build/esm/structure/io/binary/GraphBinary.d.ts +91 -0
- package/build/esm/structure/io/binary/GraphBinary.js +108 -0
- package/build/esm/structure/io/binary/internals/AnySerializer.d.ts +8 -0
- package/build/esm/structure/io/binary/internals/AnySerializer.js +77 -0
- package/build/esm/structure/io/binary/internals/ArraySerializer.d.ts +15 -0
- package/build/esm/structure/io/binary/internals/ArraySerializer.js +136 -0
- package/build/esm/structure/io/binary/internals/BigIntegerSerializer.d.ts +14 -0
- package/build/esm/structure/io/binary/internals/BigIntegerSerializer.js +133 -0
- package/build/esm/structure/io/binary/internals/BinarySerializer.d.ts +11 -0
- package/build/esm/structure/io/binary/internals/BinarySerializer.js +109 -0
- package/build/esm/structure/io/binary/internals/BooleanSerializer.d.ts +11 -0
- package/build/esm/structure/io/binary/internals/BooleanSerializer.js +90 -0
- package/build/esm/structure/io/binary/internals/ByteSerializer.d.ts +10 -0
- package/build/esm/structure/io/binary/internals/ByteSerializer.js +85 -0
- package/build/esm/structure/io/binary/internals/DataType.d.ts +35 -0
- package/{lib/driver/auth/mechanisms/sasl-mechanism-base.js → build/esm/structure/io/binary/internals/DataType.js} +43 -34
- package/build/esm/structure/io/binary/internals/DateTimeSerializer.d.ts +15 -0
- package/build/esm/structure/io/binary/internals/DateTimeSerializer.js +136 -0
- package/build/esm/structure/io/binary/internals/DoubleSerializer.d.ts +11 -0
- package/build/esm/structure/io/binary/internals/DoubleSerializer.js +88 -0
- package/build/esm/structure/io/binary/internals/EdgeSerializer.d.ts +20 -0
- package/build/esm/structure/io/binary/internals/EdgeSerializer.js +198 -0
- package/build/esm/structure/io/binary/internals/EnumSerializer.d.ts +24 -0
- package/build/esm/structure/io/binary/internals/EnumSerializer.js +124 -0
- package/build/esm/structure/io/binary/internals/FloatSerializer.d.ts +11 -0
- package/build/esm/structure/io/binary/internals/FloatSerializer.js +88 -0
- package/build/esm/structure/io/binary/internals/GraphBinaryReader.d.ts +19 -0
- package/build/esm/structure/io/binary/internals/GraphBinaryReader.js +94 -0
- package/build/esm/structure/io/binary/internals/GraphBinaryWriter.d.ts +9 -0
- package/build/esm/structure/io/binary/internals/GraphBinaryWriter.js +82 -0
- package/build/esm/structure/io/binary/internals/IntSerializer.d.ts +13 -0
- package/build/esm/structure/io/binary/internals/IntSerializer.js +100 -0
- package/build/esm/structure/io/binary/internals/LongSerializer.d.ts +11 -0
- package/build/esm/structure/io/binary/internals/LongSerializer.js +92 -0
- package/build/esm/structure/io/binary/internals/MapSerializer.d.ts +13 -0
- package/build/esm/structure/io/binary/internals/MapSerializer.js +141 -0
- package/build/esm/structure/io/binary/internals/MarkerSerializer.d.ts +8 -0
- package/build/esm/structure/io/binary/internals/MarkerSerializer.js +60 -0
- package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.d.ts +9 -0
- package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.js +63 -0
- package/build/esm/structure/io/binary/internals/PathSerializer.d.ts +15 -0
- package/build/esm/structure/io/binary/internals/PathSerializer.js +110 -0
- package/build/esm/structure/io/binary/internals/PropertySerializer.d.ts +15 -0
- package/build/esm/structure/io/binary/internals/PropertySerializer.js +127 -0
- package/build/esm/structure/io/binary/internals/SetSerializer.d.ts +15 -0
- package/build/esm/structure/io/binary/internals/SetSerializer.js +135 -0
- package/build/esm/structure/io/binary/internals/ShortSerializer.d.ts +11 -0
- package/build/esm/structure/io/binary/internals/ShortSerializer.js +88 -0
- package/build/esm/structure/io/binary/internals/StringSerializer.d.ts +11 -0
- package/build/esm/structure/io/binary/internals/StringSerializer.js +104 -0
- package/build/esm/structure/io/binary/internals/StubSerializer.d.ts +7 -0
- package/{.prettierrc.js → build/esm/structure/io/binary/internals/StubSerializer.js} +11 -11
- package/build/esm/structure/io/binary/internals/UnspecifiedNullSerializer.d.ts +11 -0
- package/build/esm/structure/io/binary/internals/UnspecifiedNullSerializer.js +67 -0
- package/build/esm/structure/io/binary/internals/UuidSerializer.d.ts +14 -0
- package/build/esm/structure/io/binary/internals/UuidSerializer.js +106 -0
- package/build/esm/structure/io/binary/internals/VertexPropertySerializer.d.ts +15 -0
- package/build/esm/structure/io/binary/internals/VertexPropertySerializer.js +160 -0
- package/build/esm/structure/io/binary/internals/VertexSerializer.d.ts +17 -0
- package/build/esm/structure/io/binary/internals/VertexSerializer.js +125 -0
- package/build/esm/structure/io/binary/internals/utils.d.ts +6 -0
- package/{lib → build/esm}/structure/io/binary/internals/utils.js +23 -35
- package/build/esm/utils.d.ts +20 -0
- package/build/esm/utils.js +98 -0
- package/package.json +56 -20
- package/.nvmrc +0 -1
- package/NOTICE +0 -5
- package/doc/AnonymousTraversalSource.html +0 -793
- package/doc/Authenticator.html +0 -303
- package/doc/Bytecode.html +0 -941
- package/doc/CardinalityValue.html +0 -711
- package/doc/Client.html +0 -1869
- package/doc/Connection.html +0 -1192
- package/doc/DriverRemoteConnection.html +0 -1528
- package/doc/EdgeLabelVerificationStrategy.html +0 -238
- package/doc/Graph.html +0 -343
- package/doc/GraphSON2Reader.html +0 -407
- package/doc/GraphSON2Writer.html +0 -558
- package/doc/GraphSON3Reader.html +0 -170
- package/doc/GraphSON3Writer.html +0 -170
- package/doc/GraphTraversal.html +0 -22974
- package/doc/GraphTraversalSource.html +0 -3683
- package/doc/HaltedTraverserStrategy.html +0 -215
- package/doc/MatchAlgorithmStrategy.html +0 -210
- package/doc/P.html +0 -2020
- package/doc/PartitionStrategy.html +0 -387
- package/doc/Path.html +0 -242
- package/doc/PlainTextSaslAuthenticator.html +0 -456
- package/doc/ProductiveByStrategy.html +0 -258
- package/doc/RemoteConnection.html +0 -1086
- package/doc/RemoteStrategy.html +0 -307
- package/doc/RemoteTraversal.html +0 -170
- package/doc/ReservedKeysVerificationStrategy.html +0 -261
- package/doc/ResponseError.html +0 -360
- package/doc/ResultSet.html +0 -633
- package/doc/SaslAuthenticator.html +0 -455
- package/doc/SaslMechanismBase.html +0 -506
- package/doc/SaslMechanismPlain.html +0 -925
- package/doc/SeedStrategy.html +0 -288
- package/doc/SubgraphStrategy.html +0 -387
- package/doc/TextP.html +0 -1440
- package/doc/Transaction.html +0 -655
- package/doc/Translator.html +0 -527
- package/doc/TraversalStrategies.html +0 -652
- package/doc/TraversalStrategy.html +0 -393
- package/doc/TypeSerializer.html +0 -166
- package/doc/driver_auth_authenticator.js.html +0 -89
- package/doc/driver_auth_mechanisms_sasl-mechanism-base.js.html +0 -103
- package/doc/driver_auth_mechanisms_sasl-mechanism-plain.js.html +0 -157
- package/doc/driver_auth_plain-text-sasl-authenticator.js.html +0 -106
- package/doc/driver_auth_sasl-authenticator.js.html +0 -100
- package/doc/driver_client.js.html +0 -250
- package/doc/driver_connection.js.html +0 -518
- package/doc/driver_driver-remote-connection.js.html +0 -193
- package/doc/driver_remote-connection.js.html +0 -198
- package/doc/driver_response-error.js.html +0 -98
- package/doc/driver_result-set.js.html +0 -134
- package/doc/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/doc/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/doc/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/doc/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/doc/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/doc/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/doc/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/doc/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/doc/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/doc/fonts/OpenSans-Light-webfont.eot +0 -0
- package/doc/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/doc/fonts/OpenSans-Light-webfont.woff +0 -0
- package/doc/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/doc/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/doc/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/doc/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/doc/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/doc/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/doc/global.html +0 -728
- package/doc/index.html +0 -185
- package/doc/module.exports.html +0 -301
- package/doc/process_anonymous-traversal.js.html +0 -138
- package/doc/process_bytecode.js.html +0 -175
- package/doc/process_graph-traversal.js.html +0 -1936
- package/doc/process_transaction.js.html +0 -151
- package/doc/process_translator.js.html +0 -172
- package/doc/process_traversal-strategy.js.html +0 -466
- package/doc/process_traversal.js.html +0 -592
- package/doc/scripts/linenumber.js +0 -25
- package/doc/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/doc/scripts/prettify/lang-css.js +0 -2
- package/doc/scripts/prettify/prettify.js +0 -28
- package/doc/structure_graph.js.html +0 -233
- package/doc/structure_io_binary_internals_DataType.js.html +0 -151
- package/doc/structure_io_binary_internals_GraphBinaryReader.js.html +0 -133
- package/doc/structure_io_binary_internals_GraphBinaryWriter.js.html +0 -136
- package/doc/structure_io_graph-serializer.js.html +0 -354
- package/doc/structure_io_type-serializers.js.html +0 -617
- package/doc/styles/jsdoc-default.css +0 -358
- package/doc/styles/prettify-jsdoc.css +0 -111
- package/doc/styles/prettify-tomorrow.css +0 -132
- package/doc/utils.js.html +0 -181
- package/docker-compose.yml +0 -76
- package/eslint.config.mjs +0 -143
- package/lib/driver/auth/mechanisms/sasl-mechanism-plain.js +0 -106
- package/lib/driver/auth/plain-text-sasl-authenticator.js +0 -55
- package/lib/driver/auth/sasl-authenticator.js +0 -49
- package/lib/driver/client.js +0 -199
- package/lib/driver/connection.js +0 -467
- package/lib/driver/driver-remote-connection.js +0 -142
- package/lib/driver/remote-connection.js +0 -147
- package/lib/driver/result-set.js +0 -83
- package/lib/process/anonymous-traversal.js +0 -87
- package/lib/process/bytecode.js +0 -124
- package/lib/process/graph-traversal.js +0 -1885
- package/lib/process/transaction.js +0 -100
- package/lib/process/translator.js +0 -121
- package/lib/process/traversal-strategy.js +0 -415
- package/lib/process/traversal.js +0 -541
- package/lib/structure/graph.js +0 -182
- package/lib/structure/io/binary/GraphBinary.js +0 -110
- package/lib/structure/io/binary/internals/AnySerializer.js +0 -100
- package/lib/structure/io/binary/internals/ArraySerializer.js +0 -137
- package/lib/structure/io/binary/internals/BigIntegerSerializer.js +0 -153
- package/lib/structure/io/binary/internals/BooleanSerializer.js +0 -105
- package/lib/structure/io/binary/internals/BulkSetSerializer.js +0 -126
- package/lib/structure/io/binary/internals/ByteBufferSerializer.js +0 -126
- package/lib/structure/io/binary/internals/ByteSerializer.js +0 -97
- package/lib/structure/io/binary/internals/BytecodeSerializer.js +0 -250
- package/lib/structure/io/binary/internals/ClassSerializer.js +0 -60
- package/lib/structure/io/binary/internals/DataType.js +0 -100
- package/lib/structure/io/binary/internals/DateSerializer.js +0 -105
- package/lib/structure/io/binary/internals/DoubleSerializer.js +0 -101
- package/lib/structure/io/binary/internals/EdgeSerializer.js +0 -216
- package/lib/structure/io/binary/internals/EnumSerializer.js +0 -152
- package/lib/structure/io/binary/internals/FloatSerializer.js +0 -101
- package/lib/structure/io/binary/internals/GraphBinaryReader.js +0 -82
- package/lib/structure/io/binary/internals/GraphBinaryWriter.js +0 -85
- package/lib/structure/io/binary/internals/IntSerializer.js +0 -114
- package/lib/structure/io/binary/internals/LambdaSerializer.js +0 -71
- package/lib/structure/io/binary/internals/LongSerializer.js +0 -109
- package/lib/structure/io/binary/internals/LongSerializerNg.js +0 -104
- package/lib/structure/io/binary/internals/MapSerializer.js +0 -155
- package/lib/structure/io/binary/internals/NumberSerializationStrategy.js +0 -73
- package/lib/structure/io/binary/internals/OffsetDateTimeSerializer.js +0 -151
- package/lib/structure/io/binary/internals/PSerializer.js +0 -152
- package/lib/structure/io/binary/internals/PathSerializer.js +0 -124
- package/lib/structure/io/binary/internals/PropertySerializer.js +0 -142
- package/lib/structure/io/binary/internals/SetSerializer.js +0 -134
- package/lib/structure/io/binary/internals/ShortSerializer.js +0 -101
- package/lib/structure/io/binary/internals/StringSerializer.js +0 -116
- package/lib/structure/io/binary/internals/TextPSerializer.js +0 -146
- package/lib/structure/io/binary/internals/TraversalStrategySerializer.js +0 -69
- package/lib/structure/io/binary/internals/TraverserSerializer.js +0 -124
- package/lib/structure/io/binary/internals/UnspecifiedNullSerializer.js +0 -77
- package/lib/structure/io/binary/internals/UuidSerializer.js +0 -121
- package/lib/structure/io/binary/internals/VertexPropertySerializer.js +0 -176
- package/lib/structure/io/binary/internals/VertexSerializer.js +0 -139
- package/lib/structure/io/graph-serializer.js +0 -303
- package/lib/structure/io/type-serializers.js +0 -566
- package/lib/utils.js +0 -130
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ConnectionOptions } from './connection.js';
|
|
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,128 @@
|
|
|
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 Connection from './connection.js';
|
|
20
|
+
import { RequestMessage } from "./request-message.js";
|
|
21
|
+
/**
|
|
22
|
+
* A {@link Client} contains methods to send messages to a Gremlin Server.
|
|
23
|
+
*/
|
|
24
|
+
export default class Client {
|
|
25
|
+
options;
|
|
26
|
+
_connection;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new instance of {@link Client}.
|
|
29
|
+
* @param {String} url The resource uri.
|
|
30
|
+
* @param {ClientOptions} [options] The connection options.
|
|
31
|
+
*/
|
|
32
|
+
constructor(url, options = {}) {
|
|
33
|
+
this.options = options;
|
|
34
|
+
this._connection = new Connection(url, options);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Opens the underlying connection to the Gremlin Server, if it's not already opened.
|
|
38
|
+
* @returns {Promise}
|
|
39
|
+
*/
|
|
40
|
+
open() {
|
|
41
|
+
return this._connection.open();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns true if the underlying connection is open
|
|
45
|
+
* @returns {Boolean}
|
|
46
|
+
*/
|
|
47
|
+
get isOpen() {
|
|
48
|
+
return this._connection.isOpen;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Configuration specific to the current request.
|
|
52
|
+
* @typedef {Object} RequestOptions
|
|
53
|
+
* @property {any} bindings - The parameter bindings to apply to the script.
|
|
54
|
+
* @property {String} language - The language of the script to execute. Defaults to 'gremlin-lang'.
|
|
55
|
+
* @property {String} accept - The MIME type expected in the response.
|
|
56
|
+
* @property {Boolean} bulkResults - Indicates whether results should be returned in bulk format.
|
|
57
|
+
* @property {Object} params - Additional parameters to include with the request.
|
|
58
|
+
* @property {Number} batchSize - The size in which the result of a request is to be 'batched' back to the client.
|
|
59
|
+
* @property {String} userAgent - The user agent string to send with the request.
|
|
60
|
+
* @property {Number} evaluationTimeout - The timeout for the evaluation of the request.
|
|
61
|
+
* @property {String} materializeProperties - Indicates whether element properties should be returned or not.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Send a request to the Gremlin Server.
|
|
65
|
+
* @param {string} message The script to send
|
|
66
|
+
* @param {Object|null} [bindings] The script bindings, if any.
|
|
67
|
+
* @param {RequestOptions} [requestOptions] Configuration specific to the current request.
|
|
68
|
+
* @returns {Promise}
|
|
69
|
+
*/ //TODO:: tighten return type to Promise<ResultSet>
|
|
70
|
+
submit(message, bindings, requestOptions) {
|
|
71
|
+
const requestBuilder = RequestMessage.build(message)
|
|
72
|
+
.addG(this.options.traversalSource || 'g');
|
|
73
|
+
if (requestOptions?.language) {
|
|
74
|
+
requestBuilder.addLanguage(requestOptions.language);
|
|
75
|
+
}
|
|
76
|
+
if (requestOptions?.bindings) {
|
|
77
|
+
requestBuilder.addBindings(requestOptions.bindings);
|
|
78
|
+
}
|
|
79
|
+
if (bindings) {
|
|
80
|
+
requestBuilder.addBindings(bindings);
|
|
81
|
+
}
|
|
82
|
+
if (requestOptions?.materializeProperties) {
|
|
83
|
+
requestBuilder.addMaterializeProperties(requestOptions.materializeProperties);
|
|
84
|
+
}
|
|
85
|
+
if (requestOptions?.evaluationTimeout) {
|
|
86
|
+
requestBuilder.addTimeoutMillis(requestOptions.evaluationTimeout);
|
|
87
|
+
}
|
|
88
|
+
if (requestOptions?.bulkResults) {
|
|
89
|
+
requestBuilder.addBulkResults(requestOptions.bulkResults);
|
|
90
|
+
}
|
|
91
|
+
return this._connection.submit(requestBuilder.create());
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Send a request to the Gremlin Server and receive a stream for the results.
|
|
95
|
+
* @param {string} message The script to send
|
|
96
|
+
* @param {Object} [bindings] The script bindings, if any.
|
|
97
|
+
* @param {RequestOptions} [requestOptions] Configuration specific to the current request.
|
|
98
|
+
* @returns {ReadableStream}
|
|
99
|
+
*/
|
|
100
|
+
//TODO:: Update stream() to mirror submit()
|
|
101
|
+
stream(message, bindings, requestOptions) {
|
|
102
|
+
throw new Error("Stream not yet implemented");
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Closes the underlying connection
|
|
106
|
+
* send session close request before connection close if session mode
|
|
107
|
+
* @returns {Promise}
|
|
108
|
+
*/
|
|
109
|
+
close() {
|
|
110
|
+
return this._connection.close();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Adds an event listener to the connection
|
|
114
|
+
* @param {String} event The event name that you want to listen to.
|
|
115
|
+
* @param {Function} handler The callback to be called when the event occurs.
|
|
116
|
+
*/
|
|
117
|
+
addListener(event, handler) {
|
|
118
|
+
this._connection.on(event, handler);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Removes a previowsly added event listener to the connection
|
|
122
|
+
* @param {String} event The event name that you want to listen to.
|
|
123
|
+
* @param {Function} handler The event handler to be removed.
|
|
124
|
+
*/
|
|
125
|
+
removeListener(event, handler) {
|
|
126
|
+
this._connection.removeListener(event, handler);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -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.js';
|
|
8
|
+
import { RequestMessage } from "./request-message.js";
|
|
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
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
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
|
+
* @author Jorge Bay Gondra
|
|
21
|
+
*/
|
|
22
|
+
import { Buffer } from 'buffer';
|
|
23
|
+
import { EventEmitter } from 'eventemitter3';
|
|
24
|
+
import ioc from '../structure/io/binary/GraphBinary.js';
|
|
25
|
+
import * as utils from '../utils.js';
|
|
26
|
+
import ResultSet from './result-set.js';
|
|
27
|
+
import ResponseError from './response-error.js';
|
|
28
|
+
import { Traverser } from '../process/traversal.js';
|
|
29
|
+
const { DeferredPromise } = utils;
|
|
30
|
+
const { graphBinaryReader, graphBinaryWriter } = ioc;
|
|
31
|
+
const responseStatusCode = {
|
|
32
|
+
success: 200,
|
|
33
|
+
noContent: 204,
|
|
34
|
+
partialContent: 206,
|
|
35
|
+
authenticationChallenge: 407,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Represents a single connection to a Gremlin Server.
|
|
39
|
+
*/
|
|
40
|
+
export default class Connection extends EventEmitter {
|
|
41
|
+
url;
|
|
42
|
+
options;
|
|
43
|
+
_reader;
|
|
44
|
+
_writer;
|
|
45
|
+
isOpen = true;
|
|
46
|
+
traversalSource;
|
|
47
|
+
_enableUserAgentOnConnect;
|
|
48
|
+
_interceptors;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new instance of {@link Connection}.
|
|
51
|
+
* @param {String} url The resource uri.
|
|
52
|
+
* @param {ConnectionOptions} [options] The connection options.
|
|
53
|
+
*/
|
|
54
|
+
constructor(url, options = {}) {
|
|
55
|
+
super();
|
|
56
|
+
this.url = url;
|
|
57
|
+
this.options = options;
|
|
58
|
+
this._reader = options.reader || graphBinaryReader;
|
|
59
|
+
this._writer = 'writer' in options ? options.writer : graphBinaryWriter;
|
|
60
|
+
this.traversalSource = options.traversalSource || 'g';
|
|
61
|
+
this._enableUserAgentOnConnect = options.enableUserAgentOnConnect !== false;
|
|
62
|
+
const interceptors = options.interceptors;
|
|
63
|
+
if (typeof interceptors === 'function') {
|
|
64
|
+
this._interceptors = [interceptors];
|
|
65
|
+
}
|
|
66
|
+
else if (Array.isArray(interceptors)) {
|
|
67
|
+
this._interceptors = interceptors;
|
|
68
|
+
}
|
|
69
|
+
else if (interceptors === undefined || interceptors === null) {
|
|
70
|
+
this._interceptors = [];
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw new TypeError('interceptors must be a function, array, or undefined');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Opens the connection, if its not already opened.
|
|
78
|
+
* @returns {Promise}
|
|
79
|
+
*/
|
|
80
|
+
async open() {
|
|
81
|
+
// No-op for HTTP connections
|
|
82
|
+
return Promise.resolve();
|
|
83
|
+
}
|
|
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
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/** @override */
|
|
94
|
+
stream(request) {
|
|
95
|
+
throw new Error('stream() is not yet implemented');
|
|
96
|
+
}
|
|
97
|
+
#getReaderForContentType(contentType) {
|
|
98
|
+
if (!contentType) {
|
|
99
|
+
return this._reader;
|
|
100
|
+
}
|
|
101
|
+
if (contentType === this._reader.mimeType) {
|
|
102
|
+
return this._reader;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
async #makeHttpRequest(body) {
|
|
107
|
+
const headers = {
|
|
108
|
+
'Accept': this._reader.mimeType
|
|
109
|
+
};
|
|
110
|
+
if (this._writer) {
|
|
111
|
+
headers['Content-Type'] = this._writer.mimeType;
|
|
112
|
+
}
|
|
113
|
+
if (this._enableUserAgentOnConnect) {
|
|
114
|
+
const userAgent = await utils.getUserAgent();
|
|
115
|
+
if (userAgent !== undefined) {
|
|
116
|
+
headers[utils.getUserAgentHeader()] = userAgent;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (this.options.headers) {
|
|
120
|
+
Object.entries(this.options.headers).forEach(([key, value]) => {
|
|
121
|
+
headers[key] = Array.isArray(value) ? value.join(', ') : value;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
let httpRequest = {
|
|
125
|
+
url: this.url,
|
|
126
|
+
method: 'POST',
|
|
127
|
+
headers,
|
|
128
|
+
body,
|
|
129
|
+
};
|
|
130
|
+
for (let i = 0; i < this._interceptors.length; i++) {
|
|
131
|
+
try {
|
|
132
|
+
httpRequest = await this._interceptors[i](httpRequest);
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
throw new Error(`Request interceptor at index ${i} failed: ${e.message}`, { cause: e });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return fetch(httpRequest.url, {
|
|
139
|
+
method: httpRequest.method,
|
|
140
|
+
headers: httpRequest.headers,
|
|
141
|
+
body: httpRequest.body,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
async #handleResponse(response) {
|
|
145
|
+
const contentType = response.headers.get("Content-Type");
|
|
146
|
+
const buffer = Buffer.from(await response.arrayBuffer());
|
|
147
|
+
const reader = this.#getReaderForContentType(contentType);
|
|
148
|
+
if (!response.ok) {
|
|
149
|
+
const errorMessage = `Server returned HTTP ${response.status}: ${response.statusText}`;
|
|
150
|
+
try {
|
|
151
|
+
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
|
+
}
|
|
158
|
+
throw new ResponseError(errorMessage, {
|
|
159
|
+
code: deserialized.status.code,
|
|
160
|
+
message: deserialized.status.message || response.statusText,
|
|
161
|
+
attributes: attributes,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
else if (contentType === 'application/json') {
|
|
165
|
+
const errorBody = JSON.parse(buffer.toString());
|
|
166
|
+
throw new ResponseError(errorMessage, {
|
|
167
|
+
code: response.status,
|
|
168
|
+
message: errorBody.message || errorBody.error || response.statusText,
|
|
169
|
+
attributes: new Map(),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
if (err instanceof ResponseError) {
|
|
175
|
+
throw err;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
throw new ResponseError(errorMessage, {
|
|
179
|
+
code: response.status,
|
|
180
|
+
message: response.statusText,
|
|
181
|
+
attributes: new Map(),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
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
|
+
}
|
|
194
|
+
throw new ResponseError(`Server error: ${deserialized.status.message || 'Unknown error'} (${deserialized.status.code})`, {
|
|
195
|
+
code: deserialized.status.code,
|
|
196
|
+
message: deserialized.status.message || '',
|
|
197
|
+
attributes: attributes,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return new ResultSet(deserialized.result.bulked
|
|
201
|
+
? deserialized.result.data.map((item) => new Traverser(item.v, item.bulk))
|
|
202
|
+
: deserialized.result.data, new Map());
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Closes the Connection.
|
|
206
|
+
* @return {Promise}
|
|
207
|
+
*/
|
|
208
|
+
close() {
|
|
209
|
+
return Promise.resolve();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author Jorge Bay Gondra
|
|
3
|
+
*/
|
|
4
|
+
import * as rcModule from './remote-connection.js';
|
|
5
|
+
declare const RemoteConnection: typeof rcModule.RemoteConnection;
|
|
6
|
+
import GremlinLang from '../process/gremlin-lang.js';
|
|
7
|
+
import { ConnectionOptions } from './connection.js';
|
|
8
|
+
/**
|
|
9
|
+
* Represents the default `RemoteConnection` implementation.
|
|
10
|
+
*/
|
|
11
|
+
export default class DriverRemoteConnection extends RemoteConnection {
|
|
12
|
+
private readonly _client;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new instance of {@link DriverRemoteConnection}.
|
|
15
|
+
* @param {String} url The resource uri.
|
|
16
|
+
* @param {ConnectionOptions} [options] The connection options.
|
|
17
|
+
*/
|
|
18
|
+
constructor(url: string, options?: ConnectionOptions);
|
|
19
|
+
/** @override */
|
|
20
|
+
open(): Promise<void>;
|
|
21
|
+
/** @override */
|
|
22
|
+
get isOpen(): boolean;
|
|
23
|
+
/** @override */
|
|
24
|
+
submit(gremlinLang: GremlinLang): Promise<rcModule.RemoteTraversal>;
|
|
25
|
+
commit(): Promise<any>;
|
|
26
|
+
rollback(): Promise<any>;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
/** @override */
|
|
29
|
+
addListener(event: string, handler: (...args: any[]) => unknown): void;
|
|
30
|
+
/** @override */
|
|
31
|
+
removeListener(event: string, handler: (...args: any[]) => unknown): void;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
* @author Jorge Bay Gondra
|
|
21
|
+
*/
|
|
22
|
+
import * as rcModule from './remote-connection.js';
|
|
23
|
+
const RemoteConnection = rcModule.RemoteConnection;
|
|
24
|
+
const RemoteTraversal = rcModule.RemoteTraversal;
|
|
25
|
+
import Client from './client.js';
|
|
26
|
+
/**
|
|
27
|
+
* Represents the default `RemoteConnection` implementation.
|
|
28
|
+
*/
|
|
29
|
+
export default class DriverRemoteConnection extends RemoteConnection {
|
|
30
|
+
_client;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new instance of {@link DriverRemoteConnection}.
|
|
33
|
+
* @param {String} url The resource uri.
|
|
34
|
+
* @param {ConnectionOptions} [options] The connection options.
|
|
35
|
+
*/
|
|
36
|
+
constructor(url, options = {}) {
|
|
37
|
+
super(url, options);
|
|
38
|
+
this._client = new Client(url, options);
|
|
39
|
+
}
|
|
40
|
+
/** @override */
|
|
41
|
+
open() {
|
|
42
|
+
return this._client.open();
|
|
43
|
+
}
|
|
44
|
+
/** @override */
|
|
45
|
+
get isOpen() {
|
|
46
|
+
return this._client.isOpen;
|
|
47
|
+
}
|
|
48
|
+
/** @override */
|
|
49
|
+
submit(gremlinLang) {
|
|
50
|
+
gremlinLang.addG(this.options.traversalSource || 'g');
|
|
51
|
+
let requestOptions = undefined;
|
|
52
|
+
const strategies = gremlinLang.getOptionsStrategies();
|
|
53
|
+
if (strategies.length > 0) {
|
|
54
|
+
requestOptions = {};
|
|
55
|
+
const allowedKeys = [
|
|
56
|
+
'evaluationTimeout',
|
|
57
|
+
'scriptEvaluationTimeout',
|
|
58
|
+
'batchSize',
|
|
59
|
+
'requestId',
|
|
60
|
+
'userAgent',
|
|
61
|
+
'materializeProperties',
|
|
62
|
+
'bulkResults',
|
|
63
|
+
];
|
|
64
|
+
for (const strategy of strategies) {
|
|
65
|
+
for (const key in strategy.configuration) {
|
|
66
|
+
if (allowedKeys.indexOf(key) > -1) {
|
|
67
|
+
requestOptions[key] = strategy.configuration[key];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!requestOptions) {
|
|
73
|
+
requestOptions = {};
|
|
74
|
+
}
|
|
75
|
+
if (!('bulkResults' in requestOptions)) {
|
|
76
|
+
requestOptions.bulkResults = true;
|
|
77
|
+
}
|
|
78
|
+
const params = gremlinLang.getParameters();
|
|
79
|
+
if (params.size > 0) {
|
|
80
|
+
requestOptions.params = Object.fromEntries(params);
|
|
81
|
+
}
|
|
82
|
+
return this._client.submit(gremlinLang.getGremlin(), null, requestOptions)
|
|
83
|
+
.then((result) => new RemoteTraversal(result.toArray()));
|
|
84
|
+
}
|
|
85
|
+
commit() {
|
|
86
|
+
return this._client.submit('g.tx().commit()', null);
|
|
87
|
+
}
|
|
88
|
+
rollback() {
|
|
89
|
+
return this._client.submit('g.tx().rollback()', null);
|
|
90
|
+
}
|
|
91
|
+
close() {
|
|
92
|
+
return this._client.close();
|
|
93
|
+
}
|
|
94
|
+
/** @override */
|
|
95
|
+
addListener(event, handler) {
|
|
96
|
+
return this._client.addListener(event, handler);
|
|
97
|
+
}
|
|
98
|
+
/** @override */
|
|
99
|
+
removeListener(event, handler) {
|
|
100
|
+
return this._client.removeListener(event, handler);
|
|
101
|
+
}
|
|
102
|
+
}
|