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,20 @@
|
|
|
1
|
+
import { OptionsStrategy } from './traversal-strategy.js';
|
|
2
|
+
import { PDTRegistry } from '../structure/PDTRegistry.js';
|
|
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
|
+
}
|
|
@@ -0,0 +1,305 @@
|
|
|
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 { P, TextP, EnumValue } from './traversal.js';
|
|
20
|
+
import { OptionsStrategy, TraversalStrategy } from './traversal-strategy.js';
|
|
21
|
+
import { Long, Int, Float, Double, Short, Byte, INT32_MIN, INT32_MAX } from '../utils.js';
|
|
22
|
+
import { Vertex, CompositePDT, PrimitivePDT } from '../structure/graph.js';
|
|
23
|
+
import { GValue } from './gvalue.js';
|
|
24
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
25
|
+
import { Buffer } from 'buffer';
|
|
26
|
+
const PARAM_NAME_PATTERN = /^[\p{L}_$][\p{L}\p{Nd}_$]*$/u;
|
|
27
|
+
export default class GremlinLang {
|
|
28
|
+
gremlin = '';
|
|
29
|
+
optionsStrategies = [];
|
|
30
|
+
parameters = new Map();
|
|
31
|
+
pdtRegistry = null;
|
|
32
|
+
constructor(toClone) {
|
|
33
|
+
if (toClone) {
|
|
34
|
+
this.gremlin = toClone.gremlin;
|
|
35
|
+
this.optionsStrategies = [...toClone.optionsStrategies];
|
|
36
|
+
this.parameters = new Map(toClone.parameters);
|
|
37
|
+
this.pdtRegistry = toClone.pdtRegistry;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
getOptionsStrategies() {
|
|
41
|
+
return this.optionsStrategies;
|
|
42
|
+
}
|
|
43
|
+
appendGremlin(text) {
|
|
44
|
+
this.gremlin += text;
|
|
45
|
+
}
|
|
46
|
+
getParameters() {
|
|
47
|
+
return this.parameters;
|
|
48
|
+
}
|
|
49
|
+
_predicateAsString(p) {
|
|
50
|
+
if (p.operator === 'and' || p.operator === 'or') {
|
|
51
|
+
return `${this._predicateAsString(p.value)}.${p.operator}(${this._predicateAsString(p.other)})`;
|
|
52
|
+
}
|
|
53
|
+
let result = p.operator + '(';
|
|
54
|
+
if (Array.isArray(p.value)) {
|
|
55
|
+
// If all elements are traversals, serialize as comma-separated args (no brackets)
|
|
56
|
+
// This matches the server grammar: within(trav1, trav2) via genericArgumentVarargs
|
|
57
|
+
const allTraversals = p.value.length > 0 && p.value.every((v) => v != null && typeof v.getGremlinLang === 'function');
|
|
58
|
+
if (allTraversals) {
|
|
59
|
+
result += p.value.map((v) => this._argAsString(v)).join(',');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
result += '[' + p.value.map((v) => this._argAsString(v)).join(',') + ']';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
result += this._argAsString(p.value);
|
|
67
|
+
if (p.other !== undefined && p.other !== null) {
|
|
68
|
+
result += ',' + this._argAsString(p.other);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
result += ')';
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
_argAsString(arg) {
|
|
75
|
+
if (arg === null || arg === undefined)
|
|
76
|
+
return 'null';
|
|
77
|
+
if (typeof arg === 'boolean')
|
|
78
|
+
return arg ? 'true' : 'false';
|
|
79
|
+
if (arg instanceof Long) {
|
|
80
|
+
return String(arg.value) + 'L';
|
|
81
|
+
}
|
|
82
|
+
if (arg instanceof Float) {
|
|
83
|
+
return GremlinLang._fpAsString(arg.value, 'F');
|
|
84
|
+
}
|
|
85
|
+
if (arg instanceof Double) {
|
|
86
|
+
return GremlinLang._fpAsString(arg.value, 'D');
|
|
87
|
+
}
|
|
88
|
+
if (arg instanceof Short) {
|
|
89
|
+
return String(arg.value) + 'S';
|
|
90
|
+
}
|
|
91
|
+
if (arg instanceof Byte) {
|
|
92
|
+
return String(arg.value) + 'B';
|
|
93
|
+
}
|
|
94
|
+
if (arg instanceof Int) {
|
|
95
|
+
return String(arg.value);
|
|
96
|
+
}
|
|
97
|
+
if (typeof arg === 'bigint') {
|
|
98
|
+
return String(arg) + 'N';
|
|
99
|
+
}
|
|
100
|
+
if (typeof arg === 'number') {
|
|
101
|
+
if (Number.isNaN(arg))
|
|
102
|
+
return 'NaN';
|
|
103
|
+
if (arg === Infinity)
|
|
104
|
+
return '+Infinity';
|
|
105
|
+
if (arg === -Infinity)
|
|
106
|
+
return '-Infinity';
|
|
107
|
+
if (!Number.isInteger(arg))
|
|
108
|
+
return String(arg) + 'D';
|
|
109
|
+
if (arg >= INT32_MIN && arg <= INT32_MAX)
|
|
110
|
+
return String(arg);
|
|
111
|
+
// Outside safe integer range, values have lost precision and may exceed Java Long - emit as Double.
|
|
112
|
+
if (arg > Number.MAX_SAFE_INTEGER || arg < -Number.MAX_SAFE_INTEGER)
|
|
113
|
+
return String(arg) + 'D';
|
|
114
|
+
return String(arg) + 'L';
|
|
115
|
+
}
|
|
116
|
+
if (arg instanceof Date) {
|
|
117
|
+
const iso = arg.toISOString();
|
|
118
|
+
return `datetime("${iso}")`;
|
|
119
|
+
}
|
|
120
|
+
if (typeof arg === 'string') {
|
|
121
|
+
// JSON.stringify handles all special character escaping in one call.
|
|
122
|
+
// Strip the outer double quotes and re-wrap in single quotes for Gremlin.
|
|
123
|
+
const escaped = JSON.stringify(arg).slice(1, -1).replace(/'/g, "\\'");
|
|
124
|
+
return `'${escaped}'`;
|
|
125
|
+
}
|
|
126
|
+
if (arg instanceof GValue) {
|
|
127
|
+
const key = arg.name;
|
|
128
|
+
if (!PARAM_NAME_PATTERN.test(key)) {
|
|
129
|
+
throw new Error(`Invalid parameter name [${key}].`);
|
|
130
|
+
}
|
|
131
|
+
if (this.parameters.has(key)) {
|
|
132
|
+
if (!isDeepStrictEqual(this.parameters.get(key), arg.value)) {
|
|
133
|
+
throw new Error(`Parameter with name ${key} already exists.`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
this.parameters.set(key, arg.value);
|
|
138
|
+
}
|
|
139
|
+
return key;
|
|
140
|
+
}
|
|
141
|
+
if (arg instanceof P || arg instanceof TextP) {
|
|
142
|
+
return this._predicateAsString(arg);
|
|
143
|
+
}
|
|
144
|
+
if (arg instanceof EnumValue) {
|
|
145
|
+
return arg.toString();
|
|
146
|
+
}
|
|
147
|
+
if (arg instanceof TraversalStrategy && !(arg instanceof OptionsStrategy)) {
|
|
148
|
+
const simpleName = arg.strategyName;
|
|
149
|
+
const configEntries = Object.entries(arg.configuration);
|
|
150
|
+
if (configEntries.length === 0) {
|
|
151
|
+
return simpleName;
|
|
152
|
+
}
|
|
153
|
+
const configStr = configEntries.map(([k, v]) => `${k}:${this._argAsString(v)}`).join(',');
|
|
154
|
+
return `new ${simpleName}(${configStr})`;
|
|
155
|
+
}
|
|
156
|
+
if (typeof arg === 'function' && arg.prototype instanceof TraversalStrategy) {
|
|
157
|
+
return arg.name;
|
|
158
|
+
}
|
|
159
|
+
if (arg instanceof PrimitivePDT) {
|
|
160
|
+
// PDT literals use double-quoted strings (consistent with the composite PDT form below);
|
|
161
|
+
// JSON.stringify handles special-character escaping, then the outer quotes are stripped.
|
|
162
|
+
const escapedName = JSON.stringify(arg.name).slice(1, -1);
|
|
163
|
+
const escapedValue = JSON.stringify(arg.value).slice(1, -1);
|
|
164
|
+
return `PDT("${escapedName}","${escapedValue}")`;
|
|
165
|
+
}
|
|
166
|
+
if (arg instanceof CompositePDT) {
|
|
167
|
+
const fields = arg.fields;
|
|
168
|
+
const keys = Object.keys(fields);
|
|
169
|
+
const escapedName = JSON.stringify(arg.name).slice(1, -1);
|
|
170
|
+
if (keys.length === 0)
|
|
171
|
+
return `PDT("${escapedName}",[:])`;
|
|
172
|
+
const entries = keys.map(k => `${this._argAsString(k)}:${this._argAsString(fields[k])}`);
|
|
173
|
+
return `PDT("${escapedName}",[${entries.join(',')}])`;
|
|
174
|
+
}
|
|
175
|
+
if (arg instanceof Vertex) {
|
|
176
|
+
return this._argAsString(arg.id);
|
|
177
|
+
}
|
|
178
|
+
if (arg instanceof GremlinLang) {
|
|
179
|
+
// Merge the child's parameters so GValue bindings nested inside a child
|
|
180
|
+
// traversal are still sent to the server alongside the rendered query.
|
|
181
|
+
arg.parameters.forEach((v, k) => this.parameters.set(k, v));
|
|
182
|
+
return arg.getGremlin('__');
|
|
183
|
+
}
|
|
184
|
+
if (typeof arg.getGremlinLang === 'function') {
|
|
185
|
+
// This is a Traversal - render as anonymous traversal
|
|
186
|
+
if (arg.graph != null) {
|
|
187
|
+
throw new Error('Child traversal must be anonymous - use __ not g');
|
|
188
|
+
}
|
|
189
|
+
const childLang = arg.getGremlinLang();
|
|
190
|
+
// Merge the child's parameters so GValue bindings nested inside a child
|
|
191
|
+
// traversal are still sent to the server alongside the rendered query.
|
|
192
|
+
childLang.parameters.forEach((v, k) => this.parameters.set(k, v));
|
|
193
|
+
return childLang.getGremlin('__');
|
|
194
|
+
}
|
|
195
|
+
if (arg instanceof Uint8Array) {
|
|
196
|
+
return `Binary("${Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength).toString('base64')}")`;
|
|
197
|
+
}
|
|
198
|
+
if (arg instanceof Set) {
|
|
199
|
+
const items = [...arg];
|
|
200
|
+
if (items.length === 0)
|
|
201
|
+
return '{}';
|
|
202
|
+
return '{' + items.map(a => this._argAsString(a)).join(',') + '}';
|
|
203
|
+
}
|
|
204
|
+
if (arg instanceof Map) {
|
|
205
|
+
if (arg.size === 0)
|
|
206
|
+
return '[:]';
|
|
207
|
+
const entries = [];
|
|
208
|
+
arg.forEach((v, k) => {
|
|
209
|
+
const ks = this._argAsString(k);
|
|
210
|
+
const vs = this._argAsString(v);
|
|
211
|
+
entries.push(typeof k === 'string' ? `${ks}:${vs}` : `(${ks}):${vs}`);
|
|
212
|
+
});
|
|
213
|
+
return '[' + entries.join(',') + ']';
|
|
214
|
+
}
|
|
215
|
+
if (Array.isArray(arg)) {
|
|
216
|
+
return '[' + arg.map(a => this._argAsString(a)).join(',') + ']';
|
|
217
|
+
}
|
|
218
|
+
if (typeof arg === 'object' && arg.constructor === Object) {
|
|
219
|
+
const entries = Object.entries(arg);
|
|
220
|
+
if (entries.length === 0)
|
|
221
|
+
return '[:]';
|
|
222
|
+
return '[' + entries.map(([k, v]) => `${this._argAsString(k)}:${this._argAsString(v)}`).join(',') + ']';
|
|
223
|
+
}
|
|
224
|
+
// Registry-based dehydration
|
|
225
|
+
if (this.pdtRegistry && typeof arg === 'object' && arg.constructor) {
|
|
226
|
+
const primitiveEntry = this.pdtRegistry.getPrimitiveAdapterByClass(arg.constructor);
|
|
227
|
+
if (primitiveEntry) {
|
|
228
|
+
const value = primitiveEntry.toValue(arg);
|
|
229
|
+
return this._argAsString(new PrimitivePDT(primitiveEntry.typeName, value));
|
|
230
|
+
}
|
|
231
|
+
const entry = this.pdtRegistry.getAdapterByClass(arg.constructor);
|
|
232
|
+
if (entry) {
|
|
233
|
+
const fields = entry.serialize(arg);
|
|
234
|
+
return this._argAsString(new CompositePDT(entry.typeName, fields));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
throw new TypeError(`GremlinLang contains at least one type [${arg?.constructor?.name ?? typeof arg}] that cannot be represented as text.`);
|
|
238
|
+
}
|
|
239
|
+
addStep(name, args) {
|
|
240
|
+
const argsStr = args?.length ? args.map(a => this._argAsString(a)).join(',') : '';
|
|
241
|
+
this.gremlin += `.${name}(${argsStr})`;
|
|
242
|
+
return this;
|
|
243
|
+
}
|
|
244
|
+
addSource(name, args) {
|
|
245
|
+
if (name === 'CardinalityValueTraversal' && args) {
|
|
246
|
+
const card = args[0];
|
|
247
|
+
this.gremlin += `Cardinality.${card.elementName}(${this._argAsString(args[1])})`;
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
if (name === 'withStrategies' && args) {
|
|
251
|
+
const nonOptionsStrategies = [];
|
|
252
|
+
for (const strategy of args) {
|
|
253
|
+
if (strategy instanceof OptionsStrategy) {
|
|
254
|
+
this.optionsStrategies.push(strategy);
|
|
255
|
+
// Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
|
|
256
|
+
if (strategy.configuration['multilabel'] !== undefined) {
|
|
257
|
+
this.gremlin += '.with("multilabel")';
|
|
258
|
+
}
|
|
259
|
+
if (strategy.configuration['singlelabel'] !== undefined) {
|
|
260
|
+
this.gremlin += '.with("singlelabel")';
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
nonOptionsStrategies.push(strategy);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (nonOptionsStrategies.length > 0) {
|
|
268
|
+
const argsStr = nonOptionsStrategies.map(a => this._argAsString(a)).join(',');
|
|
269
|
+
this.gremlin += `.withStrategies(${argsStr})`;
|
|
270
|
+
}
|
|
271
|
+
return this;
|
|
272
|
+
}
|
|
273
|
+
const argsStr = args?.length ? args.map(a => this._argAsString(a)).join(',') : '';
|
|
274
|
+
this.gremlin += `.${name}(${argsStr})`;
|
|
275
|
+
return this;
|
|
276
|
+
}
|
|
277
|
+
static _fpAsString(v, suffix) {
|
|
278
|
+
if (v === Infinity)
|
|
279
|
+
return '+Infinity';
|
|
280
|
+
if (v === -Infinity)
|
|
281
|
+
return '-Infinity';
|
|
282
|
+
if (Number.isNaN(v))
|
|
283
|
+
return 'NaN';
|
|
284
|
+
return Number.isInteger(v) ? `${v}.0${suffix}` : `${v}${suffix}`;
|
|
285
|
+
}
|
|
286
|
+
getGremlin(prefix = 'g') {
|
|
287
|
+
if (this.gremlin.length > 0 && this.gremlin[0] !== '.') {
|
|
288
|
+
return this.gremlin;
|
|
289
|
+
}
|
|
290
|
+
return prefix + this.gremlin;
|
|
291
|
+
}
|
|
292
|
+
getParametersAsString() {
|
|
293
|
+
return GremlinLang.convertParametersToString(this.parameters);
|
|
294
|
+
}
|
|
295
|
+
static convertParametersToString(params) {
|
|
296
|
+
if (params == null || params.size === 0)
|
|
297
|
+
return '[:]';
|
|
298
|
+
const helper = new GremlinLang();
|
|
299
|
+
const parts = [];
|
|
300
|
+
params.forEach((v, k) => {
|
|
301
|
+
parts.push(`${helper._argAsString(k)}:${helper._argAsString(v)}`);
|
|
302
|
+
});
|
|
303
|
+
return '[' + parts.join(',') + ']';
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -16,23 +16,23 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
export class GValue {
|
|
20
|
+
name;
|
|
21
|
+
value;
|
|
22
|
+
constructor(name, value) {
|
|
23
|
+
if (value instanceof GValue) {
|
|
24
|
+
throw new Error('GValues cannot be nested');
|
|
25
|
+
}
|
|
26
|
+
if (name == null) {
|
|
27
|
+
throw new Error('GValue name cannot be null.');
|
|
28
|
+
}
|
|
29
|
+
this.name = name;
|
|
30
|
+
this.value = value;
|
|
31
|
+
}
|
|
32
|
+
isNull() {
|
|
33
|
+
return this.value == null;
|
|
34
|
+
}
|
|
35
|
+
toString() {
|
|
36
|
+
return `${this.name}=${this.value}`;
|
|
37
|
+
}
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
module.exports = Authenticator;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import Client from '../driver/client.js';
|
|
2
|
+
import { GraphTraversalSource } from './graph-traversal.js';
|
|
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
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
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 { RemoteStrategy } from '../driver/remote-connection.js';
|
|
20
|
+
import DriverRemoteConnection from '../driver/driver-remote-connection.js';
|
|
21
|
+
import GremlinLang from './gremlin-lang.js';
|
|
22
|
+
import { GraphTraversalSource } from './graph-traversal.js';
|
|
23
|
+
import { TraversalStrategies } from './traversal-strategy.js';
|
|
24
|
+
/**
|
|
25
|
+
* Controls an explicit remote transaction. A thin wrapper around a Client that
|
|
26
|
+
* adds transaction lifecycle (begin/commit/rollback/close) and attaches a
|
|
27
|
+
* transactionId to every request.
|
|
28
|
+
*
|
|
29
|
+
* Created via Client.transact() or g.tx(). The traversal source (g alias) is
|
|
30
|
+
* inherited from the Client and cannot be changed.
|
|
31
|
+
*
|
|
32
|
+
* Transactions are short-lived and single-use. After commit or rollback, the
|
|
33
|
+
* transaction ID is invalid and the object cannot be reused.
|
|
34
|
+
*
|
|
35
|
+
* Each traversal on the transaction-bound source must be awaited before
|
|
36
|
+
* submitting the next, to ensure the server receives requests in order.
|
|
37
|
+
*
|
|
38
|
+
* This class is NOT thread-safe. Do not share a Transaction across concurrent
|
|
39
|
+
* async contexts without external synchronization.
|
|
40
|
+
*/
|
|
41
|
+
export class Transaction {
|
|
42
|
+
_transactionId;
|
|
43
|
+
_isOpen = false;
|
|
44
|
+
_failed = false;
|
|
45
|
+
_client;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a Transaction. Accepts a Client which provides the connection
|
|
48
|
+
* and traversal source for all transaction requests.
|
|
49
|
+
*/
|
|
50
|
+
constructor(client) {
|
|
51
|
+
if (!client) {
|
|
52
|
+
throw new Error('Client is required for transactions');
|
|
53
|
+
}
|
|
54
|
+
this._client = client;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Spawns a GraphTraversalSource that is bound to a remote transaction.
|
|
58
|
+
*
|
|
59
|
+
* begin() is idempotent: calling it while a transaction is already open does not send a
|
|
60
|
+
* second begin to the server and does not throw - it reuses the existing transaction ID and
|
|
61
|
+
* returns a source bound to the same transaction. A transaction is single-use, so calling
|
|
62
|
+
* begin() after it has been closed (commit/rollback/failed begin) throws.
|
|
63
|
+
* @returns {Promise<GraphTraversalSource>}
|
|
64
|
+
*/
|
|
65
|
+
async begin() {
|
|
66
|
+
if (this._failed) {
|
|
67
|
+
throw new Error('Transaction is closed and cannot be reused; begin a new transaction');
|
|
68
|
+
}
|
|
69
|
+
// idempotent: if a transaction is already open, reuse the existing transactionId without
|
|
70
|
+
// sending a second begin to the server, and return a source bound to the same transaction
|
|
71
|
+
if (!this._isOpen) {
|
|
72
|
+
let result;
|
|
73
|
+
try {
|
|
74
|
+
result = await this._client.submit('g.tx().begin()', null);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
this._failed = true;
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
const resultArray = result.toArray();
|
|
81
|
+
if (!resultArray || resultArray.length === 0) {
|
|
82
|
+
this._failed = true;
|
|
83
|
+
throw new Error('Server did not return transaction ID');
|
|
84
|
+
}
|
|
85
|
+
const resultMap = resultArray[0];
|
|
86
|
+
if (!resultMap || !(resultMap instanceof Map) || !resultMap.get('transactionId')) {
|
|
87
|
+
this._failed = true;
|
|
88
|
+
throw new Error('Server did not return transaction ID in expected format');
|
|
89
|
+
}
|
|
90
|
+
this._transactionId = resultMap.get('transactionId');
|
|
91
|
+
this._isOpen = true;
|
|
92
|
+
this._client.trackTransaction(this);
|
|
93
|
+
}
|
|
94
|
+
// Create a DriverRemoteConnection bound to this transaction. The DRC
|
|
95
|
+
// will automatically attach the transactionId to all requests.
|
|
96
|
+
const txConnection = new DriverRemoteConnection(this._client.url, this._client.options, this._transactionId);
|
|
97
|
+
const strategies = new TraversalStrategies();
|
|
98
|
+
strategies.addStrategy(new RemoteStrategy(txConnection));
|
|
99
|
+
const gtx = new GraphTraversalSource(null, strategies, new GremlinLang());
|
|
100
|
+
gtx._boundTransaction = this;
|
|
101
|
+
return gtx;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Commits the transaction.
|
|
105
|
+
* @returns {Promise<void>}
|
|
106
|
+
*/
|
|
107
|
+
async commit() {
|
|
108
|
+
await this.#closeTransaction('g.tx().commit()');
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Rolls back the transaction.
|
|
112
|
+
* @returns {Promise<void>}
|
|
113
|
+
*/
|
|
114
|
+
async rollback() {
|
|
115
|
+
await this.#closeTransaction('g.tx().rollback()');
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns true if transaction is open.
|
|
119
|
+
*/
|
|
120
|
+
get isOpen() {
|
|
121
|
+
return this._isOpen;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Returns the server-generated transaction ID, or undefined if not yet begun.
|
|
125
|
+
*/
|
|
126
|
+
get transactionId() {
|
|
127
|
+
return this._transactionId;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Closes the transaction. Default behavior is rollback: partial work is
|
|
131
|
+
* discarded rather than accidentally persisted.
|
|
132
|
+
* @returns {Promise<void>}
|
|
133
|
+
*/
|
|
134
|
+
async close() {
|
|
135
|
+
if (this._isOpen) {
|
|
136
|
+
await this.rollback();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Submits a gremlin-lang string within this transaction. The transactionId
|
|
141
|
+
* is automatically attached. Has the same signature as Client.submit().
|
|
142
|
+
*/
|
|
143
|
+
async submit(gremlin, parameters, requestOptions) {
|
|
144
|
+
if (!this._isOpen) {
|
|
145
|
+
throw new Error('Transaction is not open');
|
|
146
|
+
}
|
|
147
|
+
const opts = {
|
|
148
|
+
...requestOptions,
|
|
149
|
+
transactionId: this._transactionId,
|
|
150
|
+
};
|
|
151
|
+
return this._client.submit(gremlin, parameters || null, opts);
|
|
152
|
+
}
|
|
153
|
+
async #closeTransaction(script) {
|
|
154
|
+
if (!this._isOpen) {
|
|
155
|
+
throw new Error('Transaction is not open');
|
|
156
|
+
}
|
|
157
|
+
await this._client.submit(script, null, {
|
|
158
|
+
transactionId: this._transactionId
|
|
159
|
+
});
|
|
160
|
+
this._isOpen = false;
|
|
161
|
+
this._failed = true; // Terminal state: transaction cannot be reused
|
|
162
|
+
this._client.untrackTransaction(this);
|
|
163
|
+
}
|
|
164
|
+
}
|