gremlin 3.8.1 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -4
- package/build/cjs/driver/auth.cjs +76 -0
- package/build/cjs/driver/auth.d.cts +9 -0
- package/build/cjs/driver/client.cjs +178 -0
- package/build/cjs/driver/client.d.cts +88 -0
- package/build/cjs/driver/connection.cjs +363 -0
- package/build/cjs/driver/connection.d.cts +106 -0
- package/build/cjs/driver/dispatcher.browser.cjs +57 -0
- package/build/cjs/driver/dispatcher.browser.d.cts +35 -0
- package/build/cjs/driver/dispatcher.cjs +101 -0
- package/build/cjs/driver/dispatcher.d.cts +48 -0
- package/build/cjs/driver/driver-remote-connection.cjs +153 -0
- package/build/cjs/driver/driver-remote-connection.d.cts +39 -0
- package/build/cjs/driver/http-request.cjs +64 -0
- package/build/cjs/driver/http-request.d.cts +28 -0
- package/build/cjs/driver/logger.cjs +45 -0
- package/build/cjs/driver/logger.d.cts +29 -0
- package/build/cjs/driver/remote-connection.cjs +72 -0
- package/build/cjs/driver/remote-connection.d.cts +57 -0
- package/build/cjs/driver/request-message.cjs +246 -0
- package/build/cjs/driver/request-message.d.cts +79 -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 +146 -0
- package/build/cjs/index.d.cts +440 -0
- package/build/cjs/language/grammar/GremlinLexer.cjs +1905 -0
- package/build/cjs/language/grammar/GremlinLexer.d.cts +349 -0
- package/build/cjs/language/grammar/GremlinListener.cjs +4804 -0
- package/build/cjs/language/grammar/GremlinListener.d.cts +5239 -0
- package/build/cjs/language/grammar/GremlinParser.cjs +38146 -0
- package/build/cjs/language/grammar/GremlinParser.d.cts +6260 -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 +166 -0
- package/build/cjs/language/translator/AnonymizedTranslateVisitor.d.cts +39 -0
- package/build/cjs/language/translator/DotNetTranslateVisitor.cjs +935 -0
- package/build/cjs/language/translator/DotNetTranslateVisitor.d.cts +166 -0
- package/build/cjs/language/translator/GoTranslateVisitor.cjs +421 -0
- package/build/cjs/language/translator/GoTranslateVisitor.d.cts +40 -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 +310 -0
- package/build/cjs/language/translator/GroovyTranslateVisitor.d.cts +37 -0
- package/build/cjs/language/translator/JavaTranslateVisitor.cjs +270 -0
- package/build/cjs/language/translator/JavaTranslateVisitor.d.cts +26 -0
- package/build/cjs/language/translator/JavascriptTranslateVisitor.cjs +231 -0
- package/build/cjs/language/translator/JavascriptTranslateVisitor.d.cts +28 -0
- package/build/cjs/language/translator/PythonTranslateVisitor.cjs +340 -0
- package/build/cjs/language/translator/PythonTranslateVisitor.d.cts +31 -0
- package/build/cjs/language/translator/TranslateVisitor.cjs +398 -0
- package/build/cjs/language/translator/TranslateVisitor.d.cts +94 -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 +82 -0
- package/build/cjs/process/anonymous-traversal.d.cts +40 -0
- package/build/cjs/process/graph-traversal.cjs +1833 -0
- package/build/cjs/process/graph-traversal.d.cts +1215 -0
- package/build/cjs/process/gremlin-lang.cjs +308 -0
- package/build/cjs/process/gremlin-lang.d.cts +20 -0
- package/{lib/driver/response-error.js → build/cjs/process/gvalue.cjs} +23 -28
- package/build/cjs/process/gvalue.d.cts +7 -0
- package/build/cjs/process/transaction.cjs +171 -0
- package/build/cjs/process/transaction.d.cts +70 -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 +539 -0
- package/build/cjs/process/traversal.d.cts +212 -0
- package/build/cjs/structure/PDTRegistry.cjs +116 -0
- package/build/cjs/structure/PDTRegistry.d.cts +34 -0
- package/build/cjs/structure/graph.cjs +500 -0
- package/build/cjs/structure/graph.d.cts +176 -0
- package/build/cjs/structure/io/binary/GraphBinary.cjs +177 -0
- package/build/cjs/structure/io/binary/GraphBinary.d.cts +105 -0
- package/build/cjs/structure/io/binary/internals/AnySerializer.cjs +97 -0
- package/build/cjs/structure/io/binary/internals/AnySerializer.d.cts +18 -0
- package/build/cjs/structure/io/binary/internals/ArraySerializer.cjs +108 -0
- package/build/cjs/structure/io/binary/internals/ArraySerializer.d.cts +22 -0
- package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.cjs +116 -0
- package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.d.cts +19 -0
- package/build/cjs/structure/io/binary/internals/BinarySerializer.cjs +92 -0
- package/build/cjs/structure/io/binary/internals/BinarySerializer.d.cts +19 -0
- package/build/cjs/structure/io/binary/internals/BooleanSerializer.cjs +79 -0
- package/build/cjs/structure/io/binary/internals/BooleanSerializer.d.cts +19 -0
- package/build/cjs/structure/io/binary/internals/ByteSerializer.cjs +74 -0
- package/build/cjs/structure/io/binary/internals/ByteSerializer.d.cts +18 -0
- package/build/cjs/structure/io/binary/internals/CompositePDTSerializer.cjs +81 -0
- package/build/cjs/structure/io/binary/internals/CompositePDTSerializer.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 +122 -0
- package/build/cjs/structure/io/binary/internals/DateTimeSerializer.d.cts +20 -0
- package/build/cjs/structure/io/binary/internals/DoubleSerializer.cjs +77 -0
- package/build/cjs/structure/io/binary/internals/DoubleSerializer.d.cts +19 -0
- package/build/cjs/structure/io/binary/internals/EdgeSerializer.cjs +146 -0
- package/build/cjs/structure/io/binary/internals/EdgeSerializer.d.cts +22 -0
- package/build/cjs/structure/io/binary/internals/EnumSerializer.cjs +115 -0
- package/build/cjs/structure/io/binary/internals/EnumSerializer.d.cts +39 -0
- package/build/cjs/structure/io/binary/internals/FloatSerializer.cjs +77 -0
- package/build/cjs/structure/io/binary/internals/FloatSerializer.d.cts +19 -0
- package/build/cjs/structure/io/binary/internals/GraphBinaryReader.cjs +171 -0
- package/build/cjs/structure/io/binary/internals/GraphBinaryReader.d.cts +43 -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/GraphSerializer.cjs +184 -0
- package/build/cjs/structure/io/binary/internals/GraphSerializer.d.cts +22 -0
- package/build/cjs/structure/io/binary/internals/IntSerializer.cjs +98 -0
- package/build/cjs/structure/io/binary/internals/IntSerializer.d.cts +28 -0
- package/build/cjs/structure/io/binary/internals/LongSerializer.cjs +82 -0
- package/build/cjs/structure/io/binary/internals/LongSerializer.d.cts +20 -0
- package/build/cjs/structure/io/binary/internals/MapSerializer.cjs +110 -0
- package/build/cjs/structure/io/binary/internals/MapSerializer.d.cts +20 -0
- package/build/cjs/structure/io/binary/internals/MarkerSerializer.cjs +60 -0
- package/build/cjs/structure/io/binary/internals/MarkerSerializer.d.cts +17 -0
- package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.cjs +92 -0
- package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.d.cts +6 -0
- package/build/cjs/structure/io/binary/internals/PathSerializer.cjs +88 -0
- package/build/cjs/structure/io/binary/internals/PathSerializer.d.cts +22 -0
- package/build/cjs/structure/io/binary/internals/PrimitivePDTSerializer.cjs +80 -0
- package/build/cjs/structure/io/binary/internals/PrimitivePDTSerializer.d.cts +10 -0
- package/build/cjs/structure/io/binary/internals/PropertySerializer.cjs +93 -0
- package/build/cjs/structure/io/binary/internals/PropertySerializer.d.cts +22 -0
- package/build/cjs/structure/io/binary/internals/SetSerializer.cjs +104 -0
- package/build/cjs/structure/io/binary/internals/SetSerializer.d.cts +22 -0
- package/build/cjs/structure/io/binary/internals/ShortSerializer.cjs +77 -0
- package/build/cjs/structure/io/binary/internals/ShortSerializer.d.cts +19 -0
- package/build/cjs/structure/io/binary/internals/StreamReader.cjs +184 -0
- package/build/cjs/structure/io/binary/internals/StreamReader.d.cts +69 -0
- package/build/cjs/structure/io/binary/internals/StringSerializer.cjs +88 -0
- package/build/cjs/structure/io/binary/internals/StringSerializer.d.cts +21 -0
- package/build/cjs/structure/io/binary/internals/StubSerializer.cjs +33 -0
- package/build/cjs/structure/io/binary/internals/StubSerializer.d.cts +7 -0
- package/build/cjs/structure/io/binary/internals/TreeSerializer.cjs +139 -0
- package/build/cjs/structure/io/binary/internals/TreeSerializer.d.cts +54 -0
- package/build/cjs/structure/io/binary/internals/UnspecifiedNullSerializer.cjs +47 -0
- package/build/cjs/structure/io/binary/internals/UnspecifiedNullSerializer.d.cts +13 -0
- package/build/cjs/structure/io/binary/internals/UuidSerializer.cjs +93 -0
- package/build/cjs/structure/io/binary/internals/UuidSerializer.d.cts +19 -0
- package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.cjs +105 -0
- package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.d.cts +22 -0
- package/build/cjs/structure/io/binary/internals/VertexSerializer.cjs +101 -0
- package/build/cjs/structure/io/binary/internals/VertexSerializer.d.cts +22 -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 +259 -0
- package/build/cjs/utils.d.cts +78 -0
- package/build/esm/driver/auth.d.ts +9 -0
- package/build/esm/driver/auth.js +72 -0
- package/build/esm/driver/client.d.ts +88 -0
- package/build/esm/driver/client.js +172 -0
- package/build/esm/driver/connection.d.ts +106 -0
- package/build/esm/driver/connection.js +323 -0
- package/build/esm/driver/dispatcher.browser.d.ts +35 -0
- package/build/esm/driver/dispatcher.browser.js +53 -0
- package/build/esm/driver/dispatcher.d.ts +48 -0
- package/build/esm/driver/dispatcher.js +94 -0
- package/build/esm/driver/driver-remote-connection.d.ts +39 -0
- package/build/esm/driver/driver-remote-connection.js +114 -0
- package/build/esm/driver/http-request.d.ts +28 -0
- package/build/esm/driver/http-request.js +60 -0
- package/build/esm/driver/logger.d.ts +29 -0
- package/build/esm/driver/logger.js +42 -0
- package/build/esm/driver/remote-connection.d.ts +57 -0
- package/build/esm/driver/remote-connection.js +66 -0
- package/build/esm/driver/request-message.d.ts +79 -0
- package/build/esm/driver/request-message.js +238 -0
- package/build/esm/driver/response-error.d.ts +13 -0
- package/{lib/driver/auth/mechanisms/sasl-mechanism-base.js → build/esm/driver/response-error.js} +24 -34
- 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 +440 -0
- package/{index.js → build/esm/index.js} +44 -33
- package/build/esm/language/grammar/GremlinLexer.d.ts +349 -0
- package/build/esm/language/grammar/GremlinLexer.js +1868 -0
- package/build/esm/language/grammar/GremlinListener.d.ts +5239 -0
- package/build/esm/language/grammar/GremlinListener.js +4800 -0
- package/build/esm/language/grammar/GremlinParser.d.ts +6260 -0
- package/build/esm/language/grammar/GremlinParser.js +37579 -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 +39 -0
- package/build/esm/language/translator/AnonymizedTranslateVisitor.js +160 -0
- package/build/esm/language/translator/DotNetTranslateVisitor.d.ts +166 -0
- package/build/esm/language/translator/DotNetTranslateVisitor.js +929 -0
- package/build/esm/language/translator/GoTranslateVisitor.d.ts +40 -0
- package/build/esm/language/translator/GoTranslateVisitor.js +415 -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 +37 -0
- package/build/esm/language/translator/GroovyTranslateVisitor.js +304 -0
- package/build/esm/language/translator/JavaTranslateVisitor.d.ts +26 -0
- package/build/esm/language/translator/JavaTranslateVisitor.js +264 -0
- package/build/esm/language/translator/JavascriptTranslateVisitor.d.ts +28 -0
- package/build/esm/language/translator/JavascriptTranslateVisitor.js +225 -0
- package/build/esm/language/translator/PythonTranslateVisitor.d.ts +31 -0
- package/build/esm/language/translator/PythonTranslateVisitor.js +334 -0
- package/build/esm/language/translator/TranslateVisitor.d.ts +94 -0
- package/build/esm/language/translator/TranslateVisitor.js +395 -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 +76 -0
- package/build/esm/process/graph-traversal.d.ts +1215 -0
- package/build/esm/process/graph-traversal.js +1824 -0
- package/build/esm/process/gremlin-lang.d.ts +20 -0
- package/build/esm/process/gremlin-lang.js +305 -0
- package/build/esm/process/gvalue.d.ts +7 -0
- package/{lib/driver/auth/authenticator.js → build/esm/process/gvalue.js} +19 -19
- package/build/esm/process/transaction.d.ts +70 -0
- package/build/esm/process/transaction.js +164 -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 +212 -0
- package/build/esm/process/traversal.js +526 -0
- package/build/esm/structure/PDTRegistry.d.ts +34 -0
- package/build/esm/structure/PDTRegistry.js +112 -0
- package/build/esm/structure/graph.d.ts +176 -0
- package/build/esm/structure/graph.js +488 -0
- package/build/esm/structure/io/binary/GraphBinary.d.ts +105 -0
- package/build/esm/structure/io/binary/GraphBinary.js +136 -0
- package/build/esm/structure/io/binary/internals/AnySerializer.d.ts +18 -0
- package/build/esm/structure/io/binary/internals/AnySerializer.js +94 -0
- package/build/esm/structure/io/binary/internals/ArraySerializer.d.ts +22 -0
- package/build/esm/structure/io/binary/internals/ArraySerializer.js +105 -0
- package/build/esm/structure/io/binary/internals/BigIntegerSerializer.d.ts +19 -0
- package/build/esm/structure/io/binary/internals/BigIntegerSerializer.js +113 -0
- package/build/esm/structure/io/binary/internals/BinarySerializer.d.ts +19 -0
- package/build/esm/structure/io/binary/internals/BinarySerializer.js +89 -0
- package/build/esm/structure/io/binary/internals/BooleanSerializer.d.ts +19 -0
- package/build/esm/structure/io/binary/internals/BooleanSerializer.js +76 -0
- package/build/esm/structure/io/binary/internals/ByteSerializer.d.ts +18 -0
- package/build/esm/structure/io/binary/internals/ByteSerializer.js +71 -0
- package/build/esm/structure/io/binary/internals/CompositePDTSerializer.d.ts +10 -0
- package/build/esm/structure/io/binary/internals/CompositePDTSerializer.js +78 -0
- package/build/esm/structure/io/binary/internals/DataType.d.ts +35 -0
- package/build/esm/structure/io/binary/internals/DataType.js +61 -0
- package/build/esm/structure/io/binary/internals/DateTimeSerializer.d.ts +20 -0
- package/build/esm/structure/io/binary/internals/DateTimeSerializer.js +119 -0
- package/build/esm/structure/io/binary/internals/DoubleSerializer.d.ts +19 -0
- package/build/esm/structure/io/binary/internals/DoubleSerializer.js +74 -0
- package/build/esm/structure/io/binary/internals/EdgeSerializer.d.ts +22 -0
- package/build/esm/structure/io/binary/internals/EdgeSerializer.js +143 -0
- package/build/esm/structure/io/binary/internals/EnumSerializer.d.ts +39 -0
- package/build/esm/structure/io/binary/internals/EnumSerializer.js +112 -0
- package/build/esm/structure/io/binary/internals/FloatSerializer.d.ts +19 -0
- package/build/esm/structure/io/binary/internals/FloatSerializer.js +74 -0
- package/build/esm/structure/io/binary/internals/GraphBinaryReader.d.ts +43 -0
- package/build/esm/structure/io/binary/internals/GraphBinaryReader.js +165 -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/GraphSerializer.d.ts +22 -0
- package/build/esm/structure/io/binary/internals/GraphSerializer.js +181 -0
- package/build/esm/structure/io/binary/internals/IntSerializer.d.ts +28 -0
- package/build/esm/structure/io/binary/internals/IntSerializer.js +95 -0
- package/build/esm/structure/io/binary/internals/LongSerializer.d.ts +20 -0
- package/build/esm/structure/io/binary/internals/LongSerializer.js +79 -0
- package/build/esm/structure/io/binary/internals/MapSerializer.d.ts +20 -0
- package/build/esm/structure/io/binary/internals/MapSerializer.js +107 -0
- package/build/esm/structure/io/binary/internals/MarkerSerializer.d.ts +17 -0
- package/build/esm/structure/io/binary/internals/MarkerSerializer.js +56 -0
- package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.d.ts +6 -0
- package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.js +89 -0
- package/build/esm/structure/io/binary/internals/PathSerializer.d.ts +22 -0
- package/build/esm/structure/io/binary/internals/PathSerializer.js +85 -0
- package/build/esm/structure/io/binary/internals/PrimitivePDTSerializer.d.ts +10 -0
- package/build/esm/structure/io/binary/internals/PrimitivePDTSerializer.js +77 -0
- package/build/esm/structure/io/binary/internals/PropertySerializer.d.ts +22 -0
- package/build/esm/structure/io/binary/internals/PropertySerializer.js +90 -0
- package/build/esm/structure/io/binary/internals/SetSerializer.d.ts +22 -0
- package/build/esm/structure/io/binary/internals/SetSerializer.js +101 -0
- package/build/esm/structure/io/binary/internals/ShortSerializer.d.ts +19 -0
- package/build/esm/structure/io/binary/internals/ShortSerializer.js +74 -0
- package/build/esm/structure/io/binary/internals/StreamReader.d.ts +69 -0
- package/build/esm/structure/io/binary/internals/StreamReader.js +181 -0
- package/build/esm/structure/io/binary/internals/StringSerializer.d.ts +21 -0
- package/build/esm/structure/io/binary/internals/StringSerializer.js +85 -0
- package/build/esm/structure/io/binary/internals/StubSerializer.d.ts +7 -0
- package/{.prettierrc.js → build/esm/structure/io/binary/internals/StubSerializer.js} +12 -11
- package/build/esm/structure/io/binary/internals/TreeSerializer.d.ts +54 -0
- package/build/esm/structure/io/binary/internals/TreeSerializer.js +136 -0
- package/build/esm/structure/io/binary/internals/UnspecifiedNullSerializer.d.ts +13 -0
- package/build/esm/structure/io/binary/internals/UnspecifiedNullSerializer.js +44 -0
- package/build/esm/structure/io/binary/internals/UuidSerializer.d.ts +19 -0
- package/build/esm/structure/io/binary/internals/UuidSerializer.js +90 -0
- package/build/esm/structure/io/binary/internals/VertexPropertySerializer.d.ts +22 -0
- package/build/esm/structure/io/binary/internals/VertexPropertySerializer.js +102 -0
- package/build/esm/structure/io/binary/internals/VertexSerializer.d.ts +22 -0
- package/build/esm/structure/io/binary/internals/VertexSerializer.js +98 -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 +78 -0
- package/build/esm/utils.js +237 -0
- package/package.json +71 -26
- 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,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
* or more contributor license agreements. See the NOTICE file
|
|
5
|
+
* distributed with this work for additional information
|
|
6
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
* to you under the Apache License, Version 2.0 (the
|
|
8
|
+
* "License"); you may not use this file except in compliance
|
|
9
|
+
* with the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing,
|
|
14
|
+
* software distributed under the License is distributed on an
|
|
15
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
* KIND, either express or implied. See the License for the
|
|
17
|
+
* specific language governing permissions and limitations
|
|
18
|
+
* under the License.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const traversal_js_1 = require("./traversal.cjs");
|
|
22
|
+
const traversal_strategy_js_1 = require("./traversal-strategy.cjs");
|
|
23
|
+
const utils_js_1 = require("../utils.cjs");
|
|
24
|
+
const graph_js_1 = require("../structure/graph.cjs");
|
|
25
|
+
const gvalue_js_1 = require("./gvalue.cjs");
|
|
26
|
+
const node_util_1 = require("node:util");
|
|
27
|
+
const buffer_1 = require("node:buffer");
|
|
28
|
+
const PARAM_NAME_PATTERN = /^[\p{L}_$][\p{L}\p{Nd}_$]*$/u;
|
|
29
|
+
class GremlinLang {
|
|
30
|
+
gremlin = '';
|
|
31
|
+
optionsStrategies = [];
|
|
32
|
+
parameters = new Map();
|
|
33
|
+
pdtRegistry = null;
|
|
34
|
+
constructor(toClone) {
|
|
35
|
+
if (toClone) {
|
|
36
|
+
this.gremlin = toClone.gremlin;
|
|
37
|
+
this.optionsStrategies = [...toClone.optionsStrategies];
|
|
38
|
+
this.parameters = new Map(toClone.parameters);
|
|
39
|
+
this.pdtRegistry = toClone.pdtRegistry;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
getOptionsStrategies() {
|
|
43
|
+
return this.optionsStrategies;
|
|
44
|
+
}
|
|
45
|
+
appendGremlin(text) {
|
|
46
|
+
this.gremlin += text;
|
|
47
|
+
}
|
|
48
|
+
getParameters() {
|
|
49
|
+
return this.parameters;
|
|
50
|
+
}
|
|
51
|
+
_predicateAsString(p) {
|
|
52
|
+
if (p.operator === 'and' || p.operator === 'or') {
|
|
53
|
+
return `${this._predicateAsString(p.value)}.${p.operator}(${this._predicateAsString(p.other)})`;
|
|
54
|
+
}
|
|
55
|
+
let result = p.operator + '(';
|
|
56
|
+
if (Array.isArray(p.value)) {
|
|
57
|
+
// If all elements are traversals, serialize as comma-separated args (no brackets)
|
|
58
|
+
// This matches the server grammar: within(trav1, trav2) via genericArgumentVarargs
|
|
59
|
+
const allTraversals = p.value.length > 0 && p.value.every((v) => v != null && typeof v.getGremlinLang === 'function');
|
|
60
|
+
if (allTraversals) {
|
|
61
|
+
result += p.value.map((v) => this._argAsString(v)).join(',');
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
result += '[' + p.value.map((v) => this._argAsString(v)).join(',') + ']';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
result += this._argAsString(p.value);
|
|
69
|
+
if (p.other !== undefined && p.other !== null) {
|
|
70
|
+
result += ',' + this._argAsString(p.other);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
result += ')';
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
_argAsString(arg) {
|
|
77
|
+
if (arg === null || arg === undefined)
|
|
78
|
+
return 'null';
|
|
79
|
+
if (typeof arg === 'boolean')
|
|
80
|
+
return arg ? 'true' : 'false';
|
|
81
|
+
if (arg instanceof utils_js_1.Long) {
|
|
82
|
+
return String(arg.value) + 'L';
|
|
83
|
+
}
|
|
84
|
+
if (arg instanceof utils_js_1.Float) {
|
|
85
|
+
return GremlinLang._fpAsString(arg.value, 'F');
|
|
86
|
+
}
|
|
87
|
+
if (arg instanceof utils_js_1.Double) {
|
|
88
|
+
return GremlinLang._fpAsString(arg.value, 'D');
|
|
89
|
+
}
|
|
90
|
+
if (arg instanceof utils_js_1.Short) {
|
|
91
|
+
return String(arg.value) + 'S';
|
|
92
|
+
}
|
|
93
|
+
if (arg instanceof utils_js_1.Byte) {
|
|
94
|
+
return String(arg.value) + 'B';
|
|
95
|
+
}
|
|
96
|
+
if (arg instanceof utils_js_1.Int) {
|
|
97
|
+
return String(arg.value);
|
|
98
|
+
}
|
|
99
|
+
if (typeof arg === 'bigint') {
|
|
100
|
+
return String(arg) + 'N';
|
|
101
|
+
}
|
|
102
|
+
if (typeof arg === 'number') {
|
|
103
|
+
if (Number.isNaN(arg))
|
|
104
|
+
return 'NaN';
|
|
105
|
+
if (arg === Infinity)
|
|
106
|
+
return '+Infinity';
|
|
107
|
+
if (arg === -Infinity)
|
|
108
|
+
return '-Infinity';
|
|
109
|
+
if (!Number.isInteger(arg))
|
|
110
|
+
return String(arg) + 'D';
|
|
111
|
+
if (arg >= utils_js_1.INT32_MIN && arg <= utils_js_1.INT32_MAX)
|
|
112
|
+
return String(arg);
|
|
113
|
+
// Outside safe integer range, values have lost precision and may exceed Java Long - emit as Double.
|
|
114
|
+
if (arg > Number.MAX_SAFE_INTEGER || arg < -Number.MAX_SAFE_INTEGER)
|
|
115
|
+
return String(arg) + 'D';
|
|
116
|
+
return String(arg) + 'L';
|
|
117
|
+
}
|
|
118
|
+
if (arg instanceof Date) {
|
|
119
|
+
const iso = arg.toISOString();
|
|
120
|
+
return `datetime("${iso}")`;
|
|
121
|
+
}
|
|
122
|
+
if (typeof arg === 'string') {
|
|
123
|
+
// JSON.stringify handles all special character escaping in one call.
|
|
124
|
+
// Strip the outer double quotes and re-wrap in single quotes for Gremlin.
|
|
125
|
+
const escaped = JSON.stringify(arg).slice(1, -1).replace(/'/g, "\\'");
|
|
126
|
+
return `'${escaped}'`;
|
|
127
|
+
}
|
|
128
|
+
if (arg instanceof gvalue_js_1.GValue) {
|
|
129
|
+
const key = arg.name;
|
|
130
|
+
if (!PARAM_NAME_PATTERN.test(key)) {
|
|
131
|
+
throw new Error(`Invalid parameter name [${key}].`);
|
|
132
|
+
}
|
|
133
|
+
if (this.parameters.has(key)) {
|
|
134
|
+
if (!(0, node_util_1.isDeepStrictEqual)(this.parameters.get(key), arg.value)) {
|
|
135
|
+
throw new Error(`Parameter with name ${key} already exists.`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.parameters.set(key, arg.value);
|
|
140
|
+
}
|
|
141
|
+
return key;
|
|
142
|
+
}
|
|
143
|
+
if (arg instanceof traversal_js_1.P || arg instanceof traversal_js_1.TextP) {
|
|
144
|
+
return this._predicateAsString(arg);
|
|
145
|
+
}
|
|
146
|
+
if (arg instanceof traversal_js_1.EnumValue) {
|
|
147
|
+
return arg.toString();
|
|
148
|
+
}
|
|
149
|
+
if (arg instanceof traversal_strategy_js_1.TraversalStrategy && !(arg instanceof traversal_strategy_js_1.OptionsStrategy)) {
|
|
150
|
+
const simpleName = arg.strategyName;
|
|
151
|
+
const configEntries = Object.entries(arg.configuration);
|
|
152
|
+
if (configEntries.length === 0) {
|
|
153
|
+
return simpleName;
|
|
154
|
+
}
|
|
155
|
+
const configStr = configEntries.map(([k, v]) => `${k}:${this._argAsString(v)}`).join(',');
|
|
156
|
+
return `new ${simpleName}(${configStr})`;
|
|
157
|
+
}
|
|
158
|
+
if (typeof arg === 'function' && arg.prototype instanceof traversal_strategy_js_1.TraversalStrategy) {
|
|
159
|
+
return arg.name;
|
|
160
|
+
}
|
|
161
|
+
if (arg instanceof graph_js_1.PrimitivePDT) {
|
|
162
|
+
// PDT literals use double-quoted strings (consistent with the composite PDT form below);
|
|
163
|
+
// JSON.stringify handles special-character escaping, then the outer quotes are stripped.
|
|
164
|
+
const escapedName = JSON.stringify(arg.name).slice(1, -1);
|
|
165
|
+
const escapedValue = JSON.stringify(arg.value).slice(1, -1);
|
|
166
|
+
return `PDT("${escapedName}","${escapedValue}")`;
|
|
167
|
+
}
|
|
168
|
+
if (arg instanceof graph_js_1.CompositePDT) {
|
|
169
|
+
const fields = arg.fields;
|
|
170
|
+
const keys = Object.keys(fields);
|
|
171
|
+
const escapedName = JSON.stringify(arg.name).slice(1, -1);
|
|
172
|
+
if (keys.length === 0)
|
|
173
|
+
return `PDT("${escapedName}",[:])`;
|
|
174
|
+
const entries = keys.map(k => `${this._argAsString(k)}:${this._argAsString(fields[k])}`);
|
|
175
|
+
return `PDT("${escapedName}",[${entries.join(',')}])`;
|
|
176
|
+
}
|
|
177
|
+
if (arg instanceof graph_js_1.Vertex) {
|
|
178
|
+
return this._argAsString(arg.id);
|
|
179
|
+
}
|
|
180
|
+
if (arg instanceof GremlinLang) {
|
|
181
|
+
// Merge the child's parameters so GValue bindings nested inside a child
|
|
182
|
+
// traversal are still sent to the server alongside the rendered query.
|
|
183
|
+
arg.parameters.forEach((v, k) => this.parameters.set(k, v));
|
|
184
|
+
return arg.getGremlin('__');
|
|
185
|
+
}
|
|
186
|
+
if (typeof arg.getGremlinLang === 'function') {
|
|
187
|
+
// This is a Traversal - render as anonymous traversal
|
|
188
|
+
if (arg.graph != null) {
|
|
189
|
+
throw new Error('Child traversal must be anonymous - use __ not g');
|
|
190
|
+
}
|
|
191
|
+
const childLang = arg.getGremlinLang();
|
|
192
|
+
// Merge the child's parameters so GValue bindings nested inside a child
|
|
193
|
+
// traversal are still sent to the server alongside the rendered query.
|
|
194
|
+
childLang.parameters.forEach((v, k) => this.parameters.set(k, v));
|
|
195
|
+
return childLang.getGremlin('__');
|
|
196
|
+
}
|
|
197
|
+
if (arg instanceof Uint8Array) {
|
|
198
|
+
return `Binary("${buffer_1.Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength).toString('base64')}")`;
|
|
199
|
+
}
|
|
200
|
+
if (arg instanceof Set) {
|
|
201
|
+
const items = [...arg];
|
|
202
|
+
if (items.length === 0)
|
|
203
|
+
return '{}';
|
|
204
|
+
return '{' + items.map(a => this._argAsString(a)).join(',') + '}';
|
|
205
|
+
}
|
|
206
|
+
if (arg instanceof Map) {
|
|
207
|
+
if (arg.size === 0)
|
|
208
|
+
return '[:]';
|
|
209
|
+
const entries = [];
|
|
210
|
+
arg.forEach((v, k) => {
|
|
211
|
+
const ks = this._argAsString(k);
|
|
212
|
+
const vs = this._argAsString(v);
|
|
213
|
+
entries.push(typeof k === 'string' ? `${ks}:${vs}` : `(${ks}):${vs}`);
|
|
214
|
+
});
|
|
215
|
+
return '[' + entries.join(',') + ']';
|
|
216
|
+
}
|
|
217
|
+
if (Array.isArray(arg)) {
|
|
218
|
+
return '[' + arg.map(a => this._argAsString(a)).join(',') + ']';
|
|
219
|
+
}
|
|
220
|
+
if (typeof arg === 'object' && arg.constructor === Object) {
|
|
221
|
+
const entries = Object.entries(arg);
|
|
222
|
+
if (entries.length === 0)
|
|
223
|
+
return '[:]';
|
|
224
|
+
return '[' + entries.map(([k, v]) => `${this._argAsString(k)}:${this._argAsString(v)}`).join(',') + ']';
|
|
225
|
+
}
|
|
226
|
+
// Registry-based dehydration
|
|
227
|
+
if (this.pdtRegistry && typeof arg === 'object' && arg.constructor) {
|
|
228
|
+
const primitiveEntry = this.pdtRegistry.getPrimitiveAdapterByClass(arg.constructor);
|
|
229
|
+
if (primitiveEntry) {
|
|
230
|
+
const value = primitiveEntry.toValue(arg);
|
|
231
|
+
return this._argAsString(new graph_js_1.PrimitivePDT(primitiveEntry.typeName, value));
|
|
232
|
+
}
|
|
233
|
+
const entry = this.pdtRegistry.getAdapterByClass(arg.constructor);
|
|
234
|
+
if (entry) {
|
|
235
|
+
const fields = entry.serialize(arg);
|
|
236
|
+
return this._argAsString(new graph_js_1.CompositePDT(entry.typeName, fields));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
throw new TypeError(`GremlinLang contains at least one type [${arg?.constructor?.name ?? typeof arg}] that cannot be represented as text.`);
|
|
240
|
+
}
|
|
241
|
+
addStep(name, args) {
|
|
242
|
+
const argsStr = args?.length ? args.map(a => this._argAsString(a)).join(',') : '';
|
|
243
|
+
this.gremlin += `.${name}(${argsStr})`;
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
addSource(name, args) {
|
|
247
|
+
if (name === 'CardinalityValueTraversal' && args) {
|
|
248
|
+
const card = args[0];
|
|
249
|
+
this.gremlin += `Cardinality.${card.elementName}(${this._argAsString(args[1])})`;
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
if (name === 'withStrategies' && args) {
|
|
253
|
+
const nonOptionsStrategies = [];
|
|
254
|
+
for (const strategy of args) {
|
|
255
|
+
if (strategy instanceof traversal_strategy_js_1.OptionsStrategy) {
|
|
256
|
+
this.optionsStrategies.push(strategy);
|
|
257
|
+
// Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
|
|
258
|
+
if (strategy.configuration['multilabel'] !== undefined) {
|
|
259
|
+
this.gremlin += '.with("multilabel")';
|
|
260
|
+
}
|
|
261
|
+
if (strategy.configuration['singlelabel'] !== undefined) {
|
|
262
|
+
this.gremlin += '.with("singlelabel")';
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
nonOptionsStrategies.push(strategy);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (nonOptionsStrategies.length > 0) {
|
|
270
|
+
const argsStr = nonOptionsStrategies.map(a => this._argAsString(a)).join(',');
|
|
271
|
+
this.gremlin += `.withStrategies(${argsStr})`;
|
|
272
|
+
}
|
|
273
|
+
return this;
|
|
274
|
+
}
|
|
275
|
+
const argsStr = args?.length ? args.map(a => this._argAsString(a)).join(',') : '';
|
|
276
|
+
this.gremlin += `.${name}(${argsStr})`;
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
279
|
+
static _fpAsString(v, suffix) {
|
|
280
|
+
if (v === Infinity)
|
|
281
|
+
return '+Infinity';
|
|
282
|
+
if (v === -Infinity)
|
|
283
|
+
return '-Infinity';
|
|
284
|
+
if (Number.isNaN(v))
|
|
285
|
+
return 'NaN';
|
|
286
|
+
return Number.isInteger(v) ? `${v}.0${suffix}` : `${v}${suffix}`;
|
|
287
|
+
}
|
|
288
|
+
getGremlin(prefix = 'g') {
|
|
289
|
+
if (this.gremlin.length > 0 && this.gremlin[0] !== '.') {
|
|
290
|
+
return this.gremlin;
|
|
291
|
+
}
|
|
292
|
+
return prefix + this.gremlin;
|
|
293
|
+
}
|
|
294
|
+
getParametersAsString() {
|
|
295
|
+
return GremlinLang.convertParametersToString(this.parameters);
|
|
296
|
+
}
|
|
297
|
+
static convertParametersToString(params) {
|
|
298
|
+
if (params == null || params.size === 0)
|
|
299
|
+
return '[:]';
|
|
300
|
+
const helper = new GremlinLang();
|
|
301
|
+
const parts = [];
|
|
302
|
+
params.forEach((v, k) => {
|
|
303
|
+
parts.push(`${helper._argAsString(k)}:${helper._argAsString(v)}`);
|
|
304
|
+
});
|
|
305
|
+
return '[' + parts.join(',') + ']';
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
exports.default = GremlinLang;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OptionsStrategy } from './traversal-strategy.cjs';
|
|
2
|
+
import { PDTRegistry } from '../structure/PDTRegistry.cjs';
|
|
3
|
+
export default class GremlinLang {
|
|
4
|
+
private gremlin;
|
|
5
|
+
private optionsStrategies;
|
|
6
|
+
private parameters;
|
|
7
|
+
pdtRegistry: PDTRegistry | null;
|
|
8
|
+
constructor(toClone?: GremlinLang);
|
|
9
|
+
getOptionsStrategies(): OptionsStrategy[];
|
|
10
|
+
appendGremlin(text: string): void;
|
|
11
|
+
getParameters(): Map<string, any>;
|
|
12
|
+
private _predicateAsString;
|
|
13
|
+
private _argAsString;
|
|
14
|
+
addStep(name: string, args?: any[]): GremlinLang;
|
|
15
|
+
addSource(name: string, args?: any[]): GremlinLang;
|
|
16
|
+
private static _fpAsString;
|
|
17
|
+
getGremlin(prefix?: string): string;
|
|
18
|
+
getParametersAsString(): string;
|
|
19
|
+
static convertParametersToString(params: Map<string, any> | null): string;
|
|
20
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
4
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -16,32 +17,26 @@
|
|
|
16
17
|
* specific language governing permissions and limitations
|
|
17
18
|
* under the License.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Gets the server status attributes as a Map (may contain provider specific status information).
|
|
42
|
-
*/
|
|
43
|
-
this.statusAttributes = responseStatus.attributes || {};
|
|
44
|
-
}
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.GValue = void 0;
|
|
22
|
+
class GValue {
|
|
23
|
+
name;
|
|
24
|
+
value;
|
|
25
|
+
constructor(name, value) {
|
|
26
|
+
if (value instanceof GValue) {
|
|
27
|
+
throw new Error('GValues cannot be nested');
|
|
28
|
+
}
|
|
29
|
+
if (name == null) {
|
|
30
|
+
throw new Error('GValue name cannot be null.');
|
|
31
|
+
}
|
|
32
|
+
this.name = name;
|
|
33
|
+
this.value = value;
|
|
34
|
+
}
|
|
35
|
+
isNull() {
|
|
36
|
+
return this.value == null;
|
|
37
|
+
}
|
|
38
|
+
toString() {
|
|
39
|
+
return `${this.name}=${this.value}`;
|
|
40
|
+
}
|
|
45
41
|
}
|
|
46
|
-
|
|
47
|
-
module.exports = ResponseError;
|
|
42
|
+
exports.GValue = GValue;
|
|
@@ -0,0 +1,171 @@
|
|
|
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
|
+
exports.Transaction = void 0;
|
|
25
|
+
const remote_connection_js_1 = require("../driver/remote-connection.cjs");
|
|
26
|
+
const driver_remote_connection_js_1 = __importDefault(require("../driver/driver-remote-connection.cjs"));
|
|
27
|
+
const gremlin_lang_js_1 = __importDefault(require("./gremlin-lang.cjs"));
|
|
28
|
+
const graph_traversal_js_1 = require("./graph-traversal.cjs");
|
|
29
|
+
const traversal_strategy_js_1 = require("./traversal-strategy.cjs");
|
|
30
|
+
/**
|
|
31
|
+
* Controls an explicit remote transaction. A thin wrapper around a Client that
|
|
32
|
+
* adds transaction lifecycle (begin/commit/rollback/close) and attaches a
|
|
33
|
+
* transactionId to every request.
|
|
34
|
+
*
|
|
35
|
+
* Created via Client.transact() or g.tx(). The traversal source (g alias) is
|
|
36
|
+
* inherited from the Client and cannot be changed.
|
|
37
|
+
*
|
|
38
|
+
* Transactions are short-lived and single-use. After commit or rollback, the
|
|
39
|
+
* transaction ID is invalid and the object cannot be reused.
|
|
40
|
+
*
|
|
41
|
+
* Each traversal on the transaction-bound source must be awaited before
|
|
42
|
+
* submitting the next, to ensure the server receives requests in order.
|
|
43
|
+
*
|
|
44
|
+
* This class is NOT thread-safe. Do not share a Transaction across concurrent
|
|
45
|
+
* async contexts without external synchronization.
|
|
46
|
+
*/
|
|
47
|
+
class Transaction {
|
|
48
|
+
_transactionId;
|
|
49
|
+
_isOpen = false;
|
|
50
|
+
_failed = false;
|
|
51
|
+
_client;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a Transaction. Accepts a Client which provides the connection
|
|
54
|
+
* and traversal source for all transaction requests.
|
|
55
|
+
*/
|
|
56
|
+
constructor(client) {
|
|
57
|
+
if (!client) {
|
|
58
|
+
throw new Error('Client is required for transactions');
|
|
59
|
+
}
|
|
60
|
+
this._client = client;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Spawns a GraphTraversalSource that is bound to a remote transaction.
|
|
64
|
+
*
|
|
65
|
+
* begin() is idempotent: calling it while a transaction is already open does not send a
|
|
66
|
+
* second begin to the server and does not throw - it reuses the existing transaction ID and
|
|
67
|
+
* returns a source bound to the same transaction. A transaction is single-use, so calling
|
|
68
|
+
* begin() after it has been closed (commit/rollback/failed begin) throws.
|
|
69
|
+
* @returns {Promise<GraphTraversalSource>}
|
|
70
|
+
*/
|
|
71
|
+
async begin() {
|
|
72
|
+
if (this._failed) {
|
|
73
|
+
throw new Error('Transaction is closed and cannot be reused; begin a new transaction');
|
|
74
|
+
}
|
|
75
|
+
// idempotent: if a transaction is already open, reuse the existing transactionId without
|
|
76
|
+
// sending a second begin to the server, and return a source bound to the same transaction
|
|
77
|
+
if (!this._isOpen) {
|
|
78
|
+
let result;
|
|
79
|
+
try {
|
|
80
|
+
result = await this._client.submit('g.tx().begin()', null);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
this._failed = true;
|
|
84
|
+
throw e;
|
|
85
|
+
}
|
|
86
|
+
const resultArray = result.toArray();
|
|
87
|
+
if (!resultArray || resultArray.length === 0) {
|
|
88
|
+
this._failed = true;
|
|
89
|
+
throw new Error('Server did not return transaction ID');
|
|
90
|
+
}
|
|
91
|
+
const resultMap = resultArray[0];
|
|
92
|
+
if (!resultMap || !(resultMap instanceof Map) || !resultMap.get('transactionId')) {
|
|
93
|
+
this._failed = true;
|
|
94
|
+
throw new Error('Server did not return transaction ID in expected format');
|
|
95
|
+
}
|
|
96
|
+
this._transactionId = resultMap.get('transactionId');
|
|
97
|
+
this._isOpen = true;
|
|
98
|
+
this._client.trackTransaction(this);
|
|
99
|
+
}
|
|
100
|
+
// Create a DriverRemoteConnection bound to this transaction. The DRC
|
|
101
|
+
// will automatically attach the transactionId to all requests.
|
|
102
|
+
const txConnection = new driver_remote_connection_js_1.default(this._client.url, this._client.options, this._transactionId);
|
|
103
|
+
const strategies = new traversal_strategy_js_1.TraversalStrategies();
|
|
104
|
+
strategies.addStrategy(new remote_connection_js_1.RemoteStrategy(txConnection));
|
|
105
|
+
const gtx = new graph_traversal_js_1.GraphTraversalSource(null, strategies, new gremlin_lang_js_1.default());
|
|
106
|
+
gtx._boundTransaction = this;
|
|
107
|
+
return gtx;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Commits the transaction.
|
|
111
|
+
* @returns {Promise<void>}
|
|
112
|
+
*/
|
|
113
|
+
async commit() {
|
|
114
|
+
await this.#closeTransaction('g.tx().commit()');
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Rolls back the transaction.
|
|
118
|
+
* @returns {Promise<void>}
|
|
119
|
+
*/
|
|
120
|
+
async rollback() {
|
|
121
|
+
await this.#closeTransaction('g.tx().rollback()');
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Returns true if transaction is open.
|
|
125
|
+
*/
|
|
126
|
+
get isOpen() {
|
|
127
|
+
return this._isOpen;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns the server-generated transaction ID, or undefined if not yet begun.
|
|
131
|
+
*/
|
|
132
|
+
get transactionId() {
|
|
133
|
+
return this._transactionId;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Closes the transaction. Default behavior is rollback: partial work is
|
|
137
|
+
* discarded rather than accidentally persisted.
|
|
138
|
+
* @returns {Promise<void>}
|
|
139
|
+
*/
|
|
140
|
+
async close() {
|
|
141
|
+
if (this._isOpen) {
|
|
142
|
+
await this.rollback();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Submits a gremlin-lang string within this transaction. The transactionId
|
|
147
|
+
* is automatically attached. Has the same signature as Client.submit().
|
|
148
|
+
*/
|
|
149
|
+
async submit(gremlin, parameters, requestOptions) {
|
|
150
|
+
if (!this._isOpen) {
|
|
151
|
+
throw new Error('Transaction is not open');
|
|
152
|
+
}
|
|
153
|
+
const opts = {
|
|
154
|
+
...requestOptions,
|
|
155
|
+
transactionId: this._transactionId,
|
|
156
|
+
};
|
|
157
|
+
return this._client.submit(gremlin, parameters || null, opts);
|
|
158
|
+
}
|
|
159
|
+
async #closeTransaction(script) {
|
|
160
|
+
if (!this._isOpen) {
|
|
161
|
+
throw new Error('Transaction is not open');
|
|
162
|
+
}
|
|
163
|
+
await this._client.submit(script, null, {
|
|
164
|
+
transactionId: this._transactionId
|
|
165
|
+
});
|
|
166
|
+
this._isOpen = false;
|
|
167
|
+
this._failed = true; // Terminal state: transaction cannot be reused
|
|
168
|
+
this._client.untrackTransaction(this);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.Transaction = Transaction;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import Client from '../driver/client.cjs';
|
|
2
|
+
import { GraphTraversalSource } from './graph-traversal.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* Controls an explicit remote transaction. A thin wrapper around a Client that
|
|
5
|
+
* adds transaction lifecycle (begin/commit/rollback/close) and attaches a
|
|
6
|
+
* transactionId to every request.
|
|
7
|
+
*
|
|
8
|
+
* Created via Client.transact() or g.tx(). The traversal source (g alias) is
|
|
9
|
+
* inherited from the Client and cannot be changed.
|
|
10
|
+
*
|
|
11
|
+
* Transactions are short-lived and single-use. After commit or rollback, the
|
|
12
|
+
* transaction ID is invalid and the object cannot be reused.
|
|
13
|
+
*
|
|
14
|
+
* Each traversal on the transaction-bound source must be awaited before
|
|
15
|
+
* submitting the next, to ensure the server receives requests in order.
|
|
16
|
+
*
|
|
17
|
+
* This class is NOT thread-safe. Do not share a Transaction across concurrent
|
|
18
|
+
* async contexts without external synchronization.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Transaction {
|
|
21
|
+
#private;
|
|
22
|
+
private _transactionId?;
|
|
23
|
+
private _isOpen;
|
|
24
|
+
private _failed;
|
|
25
|
+
private readonly _client;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a Transaction. Accepts a Client which provides the connection
|
|
28
|
+
* and traversal source for all transaction requests.
|
|
29
|
+
*/
|
|
30
|
+
constructor(client: Client);
|
|
31
|
+
/**
|
|
32
|
+
* Spawns a GraphTraversalSource that is bound to a remote transaction.
|
|
33
|
+
*
|
|
34
|
+
* begin() is idempotent: calling it while a transaction is already open does not send a
|
|
35
|
+
* second begin to the server and does not throw - it reuses the existing transaction ID and
|
|
36
|
+
* returns a source bound to the same transaction. A transaction is single-use, so calling
|
|
37
|
+
* begin() after it has been closed (commit/rollback/failed begin) throws.
|
|
38
|
+
* @returns {Promise<GraphTraversalSource>}
|
|
39
|
+
*/
|
|
40
|
+
begin(): Promise<GraphTraversalSource>;
|
|
41
|
+
/**
|
|
42
|
+
* Commits the transaction.
|
|
43
|
+
* @returns {Promise<void>}
|
|
44
|
+
*/
|
|
45
|
+
commit(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Rolls back the transaction.
|
|
48
|
+
* @returns {Promise<void>}
|
|
49
|
+
*/
|
|
50
|
+
rollback(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns true if transaction is open.
|
|
53
|
+
*/
|
|
54
|
+
get isOpen(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the server-generated transaction ID, or undefined if not yet begun.
|
|
57
|
+
*/
|
|
58
|
+
get transactionId(): string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Closes the transaction. Default behavior is rollback: partial work is
|
|
61
|
+
* discarded rather than accidentally persisted.
|
|
62
|
+
* @returns {Promise<void>}
|
|
63
|
+
*/
|
|
64
|
+
close(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Submits a gremlin-lang string within this transaction. The transactionId
|
|
67
|
+
* is automatically attached. Has the same signature as Client.submit().
|
|
68
|
+
*/
|
|
69
|
+
submit(gremlin: string, parameters?: any, requestOptions?: any): Promise<any>;
|
|
70
|
+
}
|