gremlin 4.0.0-beta.2 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/driver/auth.cjs +11 -4
- package/build/cjs/driver/auth.d.cts +1 -1
- package/build/cjs/driver/client.cjs +82 -38
- package/build/cjs/driver/client.d.cts +30 -27
- package/build/cjs/driver/connection.cjs +173 -60
- package/build/cjs/driver/connection.d.cts +69 -26
- 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 +27 -15
- package/build/cjs/driver/driver-remote-connection.d.cts +10 -4
- 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 +5 -8
- package/build/cjs/driver/remote-connection.d.cts +6 -21
- package/build/cjs/driver/request-message.cjs +110 -21
- package/build/cjs/driver/request-message.d.cts +38 -8
- package/build/cjs/driver/response-error.cjs +3 -3
- package/build/cjs/driver/response-error.d.cts +2 -2
- package/build/cjs/index.cjs +21 -0
- package/build/cjs/index.d.cts +47 -0
- package/build/cjs/language/grammar/GremlinLexer.cjs +1669 -1615
- package/build/cjs/language/grammar/GremlinLexer.d.cts +325 -316
- package/build/cjs/language/grammar/GremlinListener.cjs +322 -8
- package/build/cjs/language/grammar/GremlinListener.d.cts +351 -10
- package/build/cjs/language/grammar/GremlinParser.cjs +8700 -5798
- package/build/cjs/language/grammar/GremlinParser.d.cts +998 -619
- package/build/cjs/language/translator/AnonymizedTranslateVisitor.cjs +9 -0
- package/build/cjs/language/translator/AnonymizedTranslateVisitor.d.cts +3 -0
- package/build/cjs/language/translator/DotNetTranslateVisitor.cjs +113 -4
- package/build/cjs/language/translator/DotNetTranslateVisitor.d.cts +13 -2
- package/build/cjs/language/translator/GoTranslateVisitor.cjs +82 -0
- package/build/cjs/language/translator/GoTranslateVisitor.d.cts +9 -0
- package/build/cjs/language/translator/GroovyTranslateVisitor.cjs +23 -0
- package/build/cjs/language/translator/GroovyTranslateVisitor.d.cts +3 -0
- package/build/cjs/language/translator/JavaTranslateVisitor.cjs +23 -0
- package/build/cjs/language/translator/JavaTranslateVisitor.d.cts +3 -0
- package/build/cjs/language/translator/JavascriptTranslateVisitor.cjs +11 -0
- package/build/cjs/language/translator/JavascriptTranslateVisitor.d.cts +3 -0
- package/build/cjs/language/translator/PythonTranslateVisitor.cjs +39 -3
- package/build/cjs/language/translator/PythonTranslateVisitor.d.cts +3 -0
- package/build/cjs/language/translator/TranslateVisitor.cjs +9 -0
- package/build/cjs/language/translator/TranslateVisitor.d.cts +3 -0
- package/build/cjs/process/anonymous-traversal.cjs +5 -1
- package/build/cjs/process/graph-traversal.cjs +139 -8
- package/build/cjs/process/graph-traversal.d.cts +84 -3
- package/build/cjs/process/gremlin-lang.cjs +119 -7
- package/build/cjs/process/gremlin-lang.d.cts +6 -1
- package/build/cjs/process/gvalue.cjs +42 -0
- package/build/cjs/process/gvalue.d.cts +7 -0
- package/build/cjs/process/transaction.cjs +125 -23
- package/build/cjs/process/transaction.d.cts +50 -14
- package/build/cjs/process/traversal.cjs +105 -48
- package/build/cjs/process/traversal.d.cts +36 -10
- package/build/cjs/structure/PDTRegistry.cjs +116 -0
- package/build/cjs/structure/PDTRegistry.d.cts +34 -0
- package/build/cjs/structure/graph.cjs +351 -8
- package/build/cjs/structure/graph.d.cts +122 -3
- package/build/cjs/structure/io/binary/GraphBinary.cjs +68 -39
- package/build/cjs/structure/io/binary/GraphBinary.d.cts +15 -1
- package/build/cjs/structure/io/binary/internals/AnySerializer.cjs +34 -17
- package/build/cjs/structure/io/binary/internals/AnySerializer.d.cts +12 -2
- package/build/cjs/structure/io/binary/internals/ArraySerializer.cjs +41 -72
- package/build/cjs/structure/io/binary/internals/ArraySerializer.d.cts +14 -7
- package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.cjs +34 -54
- package/build/cjs/structure/io/binary/internals/BigIntegerSerializer.d.cts +12 -7
- package/build/cjs/structure/io/binary/internals/BinarySerializer.cjs +31 -51
- package/build/cjs/structure/io/binary/internals/BinarySerializer.d.cts +12 -4
- package/build/cjs/structure/io/binary/internals/BooleanSerializer.cjs +28 -42
- package/build/cjs/structure/io/binary/internals/BooleanSerializer.d.cts +12 -4
- package/build/cjs/structure/io/binary/internals/ByteSerializer.cjs +24 -38
- package/build/cjs/structure/io/binary/internals/ByteSerializer.d.cts +12 -4
- 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/DateTimeSerializer.cjs +52 -69
- package/build/cjs/structure/io/binary/internals/DateTimeSerializer.d.cts +12 -7
- package/build/cjs/structure/io/binary/internals/DoubleSerializer.cjs +24 -38
- package/build/cjs/structure/io/binary/internals/DoubleSerializer.d.cts +12 -4
- package/build/cjs/structure/io/binary/internals/EdgeSerializer.cjs +69 -124
- package/build/cjs/structure/io/binary/internals/EdgeSerializer.d.cts +14 -12
- package/build/cjs/structure/io/binary/internals/EnumSerializer.cjs +47 -59
- package/build/cjs/structure/io/binary/internals/EnumSerializer.d.cts +19 -4
- package/build/cjs/structure/io/binary/internals/FloatSerializer.cjs +24 -38
- package/build/cjs/structure/io/binary/internals/FloatSerializer.d.cts +12 -4
- package/build/cjs/structure/io/binary/internals/GraphBinaryReader.cjs +111 -37
- package/build/cjs/structure/io/binary/internals/GraphBinaryReader.d.cts +26 -2
- package/build/cjs/structure/io/binary/internals/GraphBinaryWriter.cjs +6 -6
- 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 +33 -38
- package/build/cjs/structure/io/binary/internals/IntSerializer.d.cts +19 -4
- package/build/cjs/structure/io/binary/internals/LongSerializer.cjs +29 -42
- package/build/cjs/structure/io/binary/internals/LongSerializer.d.cts +13 -4
- package/build/cjs/structure/io/binary/internals/MapSerializer.cjs +36 -70
- package/build/cjs/structure/io/binary/internals/MapSerializer.d.cts +14 -7
- package/build/cjs/structure/io/binary/internals/MarkerSerializer.cjs +30 -33
- package/build/cjs/structure/io/binary/internals/MarkerSerializer.d.cts +13 -4
- package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.cjs +28 -2
- package/build/cjs/structure/io/binary/internals/NumberSerializationStrategy.d.cts +0 -3
- package/build/cjs/structure/io/binary/internals/PathSerializer.cjs +30 -55
- package/build/cjs/structure/io/binary/internals/PathSerializer.d.cts +14 -7
- 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 +32 -69
- package/build/cjs/structure/io/binary/internals/PropertySerializer.d.cts +14 -7
- package/build/cjs/structure/io/binary/internals/SetSerializer.cjs +39 -73
- package/build/cjs/structure/io/binary/internals/SetSerializer.d.cts +14 -7
- package/build/cjs/structure/io/binary/internals/ShortSerializer.cjs +24 -38
- package/build/cjs/structure/io/binary/internals/ShortSerializer.d.cts +12 -4
- 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 +34 -53
- package/build/cjs/structure/io/binary/internals/StringSerializer.d.cts +14 -4
- package/build/cjs/structure/io/binary/internals/StubSerializer.cjs +2 -1
- package/build/cjs/structure/io/binary/internals/StubSerializer.d.cts +1 -1
- 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 +8 -31
- package/build/cjs/structure/io/binary/internals/UnspecifiedNullSerializer.d.cts +6 -4
- package/build/cjs/structure/io/binary/internals/UuidSerializer.cjs +33 -49
- package/build/cjs/structure/io/binary/internals/UuidSerializer.d.cts +12 -7
- package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.cjs +37 -95
- package/build/cjs/structure/io/binary/internals/VertexPropertySerializer.d.cts +14 -7
- package/build/cjs/structure/io/binary/internals/VertexSerializer.cjs +41 -68
- package/build/cjs/structure/io/binary/internals/VertexSerializer.d.cts +14 -9
- package/build/cjs/utils.cjs +157 -40
- package/build/cjs/utils.d.cts +62 -4
- package/build/esm/driver/auth.d.ts +1 -1
- package/build/esm/driver/auth.js +11 -4
- package/build/esm/driver/client.d.ts +30 -27
- package/build/esm/driver/client.js +82 -38
- package/build/esm/driver/connection.d.ts +69 -26
- package/build/esm/driver/connection.js +172 -60
- 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 +10 -4
- package/build/esm/driver/driver-remote-connection.js +27 -15
- 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 +6 -21
- package/build/esm/driver/remote-connection.js +5 -8
- package/build/esm/driver/request-message.d.ts +38 -8
- package/build/esm/driver/request-message.js +107 -21
- package/build/esm/driver/response-error.d.ts +2 -2
- package/build/esm/driver/response-error.js +3 -3
- package/build/esm/index.d.ts +47 -0
- package/build/esm/index.js +21 -0
- package/build/esm/language/grammar/GremlinLexer.d.ts +325 -316
- package/build/esm/language/grammar/GremlinLexer.js +1669 -1615
- package/build/esm/language/grammar/GremlinListener.d.ts +351 -10
- package/build/esm/language/grammar/GremlinListener.js +322 -8
- package/build/esm/language/grammar/GremlinParser.d.ts +998 -619
- package/build/esm/language/grammar/GremlinParser.js +8646 -5778
- package/build/esm/language/translator/AnonymizedTranslateVisitor.d.ts +3 -0
- package/build/esm/language/translator/AnonymizedTranslateVisitor.js +9 -0
- package/build/esm/language/translator/DotNetTranslateVisitor.d.ts +13 -2
- package/build/esm/language/translator/DotNetTranslateVisitor.js +113 -4
- package/build/esm/language/translator/GoTranslateVisitor.d.ts +9 -0
- package/build/esm/language/translator/GoTranslateVisitor.js +82 -0
- package/build/esm/language/translator/GroovyTranslateVisitor.d.ts +3 -0
- package/build/esm/language/translator/GroovyTranslateVisitor.js +23 -0
- package/build/esm/language/translator/JavaTranslateVisitor.d.ts +3 -0
- package/build/esm/language/translator/JavaTranslateVisitor.js +23 -0
- package/build/esm/language/translator/JavascriptTranslateVisitor.d.ts +3 -0
- package/build/esm/language/translator/JavascriptTranslateVisitor.js +11 -0
- package/build/esm/language/translator/PythonTranslateVisitor.d.ts +3 -0
- package/build/esm/language/translator/PythonTranslateVisitor.js +39 -3
- package/build/esm/language/translator/TranslateVisitor.d.ts +3 -0
- package/build/esm/language/translator/TranslateVisitor.js +9 -0
- package/build/esm/process/anonymous-traversal.js +5 -1
- package/build/esm/process/graph-traversal.d.ts +84 -3
- package/build/esm/process/graph-traversal.js +139 -8
- package/build/esm/process/gremlin-lang.d.ts +6 -1
- package/build/esm/process/gremlin-lang.js +121 -9
- package/build/esm/process/gvalue.d.ts +7 -0
- package/build/esm/process/gvalue.js +38 -0
- package/build/esm/process/transaction.d.ts +50 -14
- package/build/esm/process/transaction.js +122 -23
- package/build/esm/process/traversal.d.ts +36 -10
- package/build/esm/process/traversal.js +104 -47
- package/build/esm/structure/PDTRegistry.d.ts +34 -0
- package/build/esm/structure/PDTRegistry.js +112 -0
- package/build/esm/structure/graph.d.ts +122 -3
- package/build/esm/structure/graph.js +347 -7
- package/build/esm/structure/io/binary/GraphBinary.d.ts +15 -1
- package/build/esm/structure/io/binary/GraphBinary.js +66 -38
- package/build/esm/structure/io/binary/internals/AnySerializer.d.ts +12 -2
- package/build/esm/structure/io/binary/internals/AnySerializer.js +34 -17
- package/build/esm/structure/io/binary/internals/ArraySerializer.d.ts +14 -7
- package/build/esm/structure/io/binary/internals/ArraySerializer.js +41 -72
- package/build/esm/structure/io/binary/internals/BigIntegerSerializer.d.ts +12 -7
- package/build/esm/structure/io/binary/internals/BigIntegerSerializer.js +34 -54
- package/build/esm/structure/io/binary/internals/BinarySerializer.d.ts +12 -4
- package/build/esm/structure/io/binary/internals/BinarySerializer.js +31 -51
- package/build/esm/structure/io/binary/internals/BooleanSerializer.d.ts +12 -4
- package/build/esm/structure/io/binary/internals/BooleanSerializer.js +28 -42
- package/build/esm/structure/io/binary/internals/ByteSerializer.d.ts +12 -4
- package/build/esm/structure/io/binary/internals/ByteSerializer.js +24 -38
- 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/DateTimeSerializer.d.ts +12 -7
- package/build/esm/structure/io/binary/internals/DateTimeSerializer.js +52 -69
- package/build/esm/structure/io/binary/internals/DoubleSerializer.d.ts +12 -4
- package/build/esm/structure/io/binary/internals/DoubleSerializer.js +24 -38
- package/build/esm/structure/io/binary/internals/EdgeSerializer.d.ts +14 -12
- package/build/esm/structure/io/binary/internals/EdgeSerializer.js +69 -124
- package/build/esm/structure/io/binary/internals/EnumSerializer.d.ts +19 -4
- package/build/esm/structure/io/binary/internals/EnumSerializer.js +47 -59
- package/build/esm/structure/io/binary/internals/FloatSerializer.d.ts +12 -4
- package/build/esm/structure/io/binary/internals/FloatSerializer.js +24 -38
- package/build/esm/structure/io/binary/internals/GraphBinaryReader.d.ts +26 -2
- package/build/esm/structure/io/binary/internals/GraphBinaryReader.js +108 -37
- package/build/esm/structure/io/binary/internals/GraphBinaryWriter.js +6 -6
- 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 +19 -4
- package/build/esm/structure/io/binary/internals/IntSerializer.js +33 -38
- package/build/esm/structure/io/binary/internals/LongSerializer.d.ts +13 -4
- package/build/esm/structure/io/binary/internals/LongSerializer.js +29 -42
- package/build/esm/structure/io/binary/internals/MapSerializer.d.ts +14 -7
- package/build/esm/structure/io/binary/internals/MapSerializer.js +36 -70
- package/build/esm/structure/io/binary/internals/MarkerSerializer.d.ts +13 -4
- package/build/esm/structure/io/binary/internals/MarkerSerializer.js +29 -33
- package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.d.ts +0 -3
- package/build/esm/structure/io/binary/internals/NumberSerializationStrategy.js +28 -2
- package/build/esm/structure/io/binary/internals/PathSerializer.d.ts +14 -7
- package/build/esm/structure/io/binary/internals/PathSerializer.js +30 -55
- 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 +14 -7
- package/build/esm/structure/io/binary/internals/PropertySerializer.js +32 -69
- package/build/esm/structure/io/binary/internals/SetSerializer.d.ts +14 -7
- package/build/esm/structure/io/binary/internals/SetSerializer.js +39 -73
- package/build/esm/structure/io/binary/internals/ShortSerializer.d.ts +12 -4
- package/build/esm/structure/io/binary/internals/ShortSerializer.js +24 -38
- 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 +14 -4
- package/build/esm/structure/io/binary/internals/StringSerializer.js +34 -53
- package/build/esm/structure/io/binary/internals/StubSerializer.d.ts +1 -1
- package/build/esm/structure/io/binary/internals/StubSerializer.js +2 -1
- 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 +6 -4
- package/build/esm/structure/io/binary/internals/UnspecifiedNullSerializer.js +8 -31
- package/build/esm/structure/io/binary/internals/UuidSerializer.d.ts +12 -7
- package/build/esm/structure/io/binary/internals/UuidSerializer.js +33 -49
- package/build/esm/structure/io/binary/internals/VertexPropertySerializer.d.ts +14 -7
- package/build/esm/structure/io/binary/internals/VertexPropertySerializer.js +37 -95
- package/build/esm/structure/io/binary/internals/VertexSerializer.d.ts +14 -9
- package/build/esm/structure/io/binary/internals/VertexSerializer.js +41 -68
- package/build/esm/utils.d.ts +62 -4
- package/build/esm/utils.js +145 -6
- package/package.json +27 -18
|
@@ -1,34 +1,70 @@
|
|
|
1
|
+
import Client from '../driver/client.js';
|
|
1
2
|
import { GraphTraversalSource } from './graph-traversal.js';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
7
19
|
*/
|
|
8
20
|
export declare class Transaction {
|
|
9
|
-
private
|
|
10
|
-
private
|
|
11
|
-
|
|
21
|
+
#private;
|
|
22
|
+
private _transactionId?;
|
|
23
|
+
private _isOpen;
|
|
24
|
+
private _failed;
|
|
25
|
+
private readonly _client;
|
|
12
26
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
27
|
+
* Creates a Transaction. Accepts a Client which provides the connection
|
|
28
|
+
* and traversal source for all transaction requests.
|
|
15
29
|
*/
|
|
16
|
-
|
|
30
|
+
constructor(client: Client);
|
|
17
31
|
/**
|
|
18
|
-
*
|
|
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>}
|
|
19
44
|
*/
|
|
20
45
|
commit(): Promise<void>;
|
|
21
46
|
/**
|
|
22
|
-
*
|
|
47
|
+
* Rolls back the transaction.
|
|
48
|
+
* @returns {Promise<void>}
|
|
23
49
|
*/
|
|
24
50
|
rollback(): Promise<void>;
|
|
25
51
|
/**
|
|
26
52
|
* Returns true if transaction is open.
|
|
27
|
-
* @returns {Boolean}
|
|
28
53
|
*/
|
|
29
54
|
get isOpen(): boolean;
|
|
30
55
|
/**
|
|
31
|
-
*
|
|
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>}
|
|
32
63
|
*/
|
|
33
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>;
|
|
34
70
|
}
|
|
@@ -16,50 +16,149 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
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';
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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.
|
|
24
40
|
*/
|
|
25
41
|
export class Transaction {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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;
|
|
30
55
|
}
|
|
31
56
|
/**
|
|
32
|
-
* Spawns a
|
|
33
|
-
*
|
|
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>}
|
|
34
64
|
*/
|
|
35
|
-
begin() {
|
|
36
|
-
|
|
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;
|
|
37
102
|
}
|
|
38
103
|
/**
|
|
39
|
-
*
|
|
104
|
+
* Commits the transaction.
|
|
105
|
+
* @returns {Promise<void>}
|
|
40
106
|
*/
|
|
41
|
-
commit() {
|
|
42
|
-
|
|
107
|
+
async commit() {
|
|
108
|
+
await this.#closeTransaction('g.tx().commit()');
|
|
43
109
|
}
|
|
44
110
|
/**
|
|
45
|
-
*
|
|
111
|
+
* Rolls back the transaction.
|
|
112
|
+
* @returns {Promise<void>}
|
|
46
113
|
*/
|
|
47
|
-
rollback() {
|
|
48
|
-
|
|
114
|
+
async rollback() {
|
|
115
|
+
await this.#closeTransaction('g.tx().rollback()');
|
|
49
116
|
}
|
|
50
117
|
/**
|
|
51
118
|
* Returns true if transaction is open.
|
|
52
|
-
* @returns {Boolean}
|
|
53
119
|
*/
|
|
54
120
|
get isOpen() {
|
|
55
|
-
return this.
|
|
121
|
+
return this._isOpen;
|
|
56
122
|
}
|
|
57
123
|
/**
|
|
58
|
-
*
|
|
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>}
|
|
59
133
|
*/
|
|
60
134
|
async close() {
|
|
61
|
-
if (this.
|
|
62
|
-
this.
|
|
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');
|
|
63
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);
|
|
64
163
|
}
|
|
65
164
|
}
|
|
@@ -13,13 +13,29 @@ export declare class Traversal {
|
|
|
13
13
|
graph: Graph | null;
|
|
14
14
|
traversalStrategies: TraversalStrategies | null;
|
|
15
15
|
gremlinLang: GremlinLang;
|
|
16
|
-
results
|
|
16
|
+
/** @internal Async results stream set by RemoteStrategy */
|
|
17
|
+
_resultsStream: AsyncGenerator<any> | null;
|
|
18
|
+
/** @internal Buffered traverser for bulk expansion and hasNext peek */
|
|
19
|
+
private _currentTraverser;
|
|
20
|
+
/** Trailing response status from the server, populated after iteration completes. */
|
|
21
|
+
private _status;
|
|
17
22
|
sideEffects?: any;
|
|
18
23
|
private _traversalStrategiesPromise;
|
|
19
|
-
private
|
|
24
|
+
private _done;
|
|
20
25
|
constructor(graph: Graph | null, traversalStrategies: TraversalStrategies | null, gremlinLang?: GremlinLang);
|
|
21
26
|
/** @returns {GremlinLang} */
|
|
22
27
|
getGremlinLang(): GremlinLang;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the trailing response status from the server.
|
|
30
|
+
* Available after the traversal has been fully iterated (via toList(), iterate(), or manual iteration).
|
|
31
|
+
* Returns null if the traversal has not completed.
|
|
32
|
+
* @returns {{ code: number, message: string | null, exception: string | null } | null}
|
|
33
|
+
*/
|
|
34
|
+
getStatus(): {
|
|
35
|
+
code: number;
|
|
36
|
+
message: string | null;
|
|
37
|
+
exception: string | null;
|
|
38
|
+
} | null;
|
|
23
39
|
/**
|
|
24
40
|
* Returns an Array containing the traverser objects.
|
|
25
41
|
* @returns {Promise.<Array>}
|
|
@@ -36,16 +52,27 @@ export declare class Traversal {
|
|
|
36
52
|
*/
|
|
37
53
|
iterate(): Promise<void>;
|
|
38
54
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
55
|
+
* Returns the next result from the traversal.
|
|
56
|
+
*
|
|
57
|
+
* When called without an argument, returns a Promise that resolves to an iterator
|
|
58
|
+
* item ({value, done}), following the async iterator protocol.
|
|
59
|
+
*
|
|
60
|
+
* When called with an amount, returns a Promise that resolves to an Array containing
|
|
61
|
+
* up to {@code amount} result values. The Array form is always used when an amount is
|
|
62
|
+
* supplied, including {@code next(1)}, which resolves to an Array of one value rather
|
|
63
|
+
* than a bare value, matching the behavior of next(n) in the other Gremlin language
|
|
64
|
+
* variants. If fewer results remain, the Array contains only those that remain, and an
|
|
65
|
+
* amount of zero or less yields an empty Array.
|
|
66
|
+
* @param {Number} [amount] The number of results to retrieve.
|
|
67
|
+
* @returns {Promise.<{value, done}>|Promise.<Array>}
|
|
42
68
|
*/
|
|
43
69
|
next<T>(): Promise<IteratorResult<T, null>>;
|
|
70
|
+
next<T>(amount: number): Promise<T[]>;
|
|
44
71
|
/**
|
|
45
|
-
*
|
|
72
|
+
* Pull the next value, handling Traverser bulk expansion.
|
|
46
73
|
* @private
|
|
47
74
|
*/
|
|
48
|
-
_getNext<T>(): IteratorResult<T, null
|
|
75
|
+
_getNext<T>(): Promise<IteratorResult<T, null>>;
|
|
49
76
|
_applyStrategies(): Promise<void>;
|
|
50
77
|
/**
|
|
51
78
|
* Returns step instructions during JSON serialization
|
|
@@ -81,8 +108,8 @@ export declare class P<T1 = any, T2 = any> {
|
|
|
81
108
|
toString(): string;
|
|
82
109
|
and(arg?: any): P<this, any>;
|
|
83
110
|
or(arg?: any): P<this, any>;
|
|
84
|
-
static within(...args: any[]): P<any
|
|
85
|
-
static without(...args: any[]): P<any
|
|
111
|
+
static within(...args: any[]): P<any, null>;
|
|
112
|
+
static without(...args: any[]): P<any, null>;
|
|
86
113
|
/** @param {...Object} args */
|
|
87
114
|
static between(...args: any[]): any;
|
|
88
115
|
/** @param {...Object} args */
|
|
@@ -173,7 +200,6 @@ export declare const dt: Record<string, EnumValue>;
|
|
|
173
200
|
export declare const gType: {
|
|
174
201
|
[key: string]: any;
|
|
175
202
|
};
|
|
176
|
-
export declare const graphSONVersion: Record<string, EnumValue>;
|
|
177
203
|
export declare const gryoVersion: Record<string, EnumValue>;
|
|
178
204
|
export declare const merge: Record<string, EnumValue>;
|
|
179
205
|
export declare const operator: Record<string, EnumValue>;
|
|
@@ -23,10 +23,15 @@ export class Traversal {
|
|
|
23
23
|
graph;
|
|
24
24
|
traversalStrategies;
|
|
25
25
|
gremlinLang;
|
|
26
|
-
results
|
|
26
|
+
/** @internal Async results stream set by RemoteStrategy */
|
|
27
|
+
_resultsStream = null;
|
|
28
|
+
/** @internal Buffered traverser for bulk expansion and hasNext peek */
|
|
29
|
+
_currentTraverser = null;
|
|
30
|
+
/** Trailing response status from the server, populated after iteration completes. */
|
|
31
|
+
_status = null;
|
|
27
32
|
sideEffects = null;
|
|
28
33
|
_traversalStrategiesPromise = null;
|
|
29
|
-
|
|
34
|
+
_done = false;
|
|
30
35
|
constructor(graph, traversalStrategies, gremlinLang = new GremlinLang()) {
|
|
31
36
|
this.graph = graph;
|
|
32
37
|
this.traversalStrategies = traversalStrategies;
|
|
@@ -42,75 +47,122 @@ export class Traversal {
|
|
|
42
47
|
getGremlinLang() {
|
|
43
48
|
return this.gremlinLang;
|
|
44
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets the trailing response status from the server.
|
|
52
|
+
* Available after the traversal has been fully iterated (via toList(), iterate(), or manual iteration).
|
|
53
|
+
* Returns null if the traversal has not completed.
|
|
54
|
+
* @returns {{ code: number, message: string | null, exception: string | null } | null}
|
|
55
|
+
*/
|
|
56
|
+
getStatus() {
|
|
57
|
+
return this._status;
|
|
58
|
+
}
|
|
45
59
|
/**
|
|
46
60
|
* Returns an Array containing the traverser objects.
|
|
47
61
|
* @returns {Promise.<Array>}
|
|
48
62
|
*/
|
|
49
|
-
toList() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
63
|
+
async toList() {
|
|
64
|
+
await this._applyStrategies();
|
|
65
|
+
const result = [];
|
|
66
|
+
while (true) {
|
|
67
|
+
const it = await this._getNext();
|
|
68
|
+
if (it.done)
|
|
69
|
+
break;
|
|
70
|
+
result.push(it.value);
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
58
73
|
}
|
|
59
74
|
/**
|
|
60
75
|
* Determines if there are any more items to iterate from the traversal.
|
|
61
76
|
* @returns {Promise.<boolean>}
|
|
62
77
|
*/
|
|
63
|
-
hasNext() {
|
|
64
|
-
|
|
65
|
-
|
|
78
|
+
async hasNext() {
|
|
79
|
+
await this._applyStrategies();
|
|
80
|
+
// If we have a current traverser with remaining bulk, there's more
|
|
81
|
+
if (this._currentTraverser && this._currentTraverser.bulk > 0) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
if (this._done)
|
|
85
|
+
return false;
|
|
86
|
+
// Try to pull the next item from the source to check
|
|
87
|
+
if (this._resultsStream) {
|
|
88
|
+
const { value, done } = await this._resultsStream.next();
|
|
89
|
+
if (done) {
|
|
90
|
+
this._done = true;
|
|
66
91
|
return false;
|
|
67
92
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
});
|
|
93
|
+
// Buffer it as a traverser for the next _getNext() call
|
|
94
|
+
this._currentTraverser = value instanceof Traverser ? value : new Traverser(value, 1);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
75
98
|
}
|
|
76
99
|
/**
|
|
77
100
|
* Iterates all Traverser instances in the traversal.
|
|
78
101
|
* @returns {Promise}
|
|
79
102
|
*/
|
|
80
|
-
iterate() {
|
|
103
|
+
async iterate() {
|
|
81
104
|
this.gremlinLang.addStep('discard');
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
105
|
+
await this._applyStrategies();
|
|
106
|
+
while (true) {
|
|
107
|
+
const it = await this._getNext();
|
|
108
|
+
if (it.done)
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
88
111
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
112
|
+
async next(amount) {
|
|
113
|
+
await this._applyStrategies();
|
|
114
|
+
if (amount === undefined || amount === null) {
|
|
115
|
+
return this._getNext();
|
|
116
|
+
}
|
|
117
|
+
const result = [];
|
|
118
|
+
for (let i = 0; i < amount; i++) {
|
|
119
|
+
const it = await this._getNext();
|
|
120
|
+
if (it.done) {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
result.push(it.value);
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
96
126
|
}
|
|
97
127
|
/**
|
|
98
|
-
*
|
|
128
|
+
* Pull the next value, handling Traverser bulk expansion.
|
|
99
129
|
* @private
|
|
100
130
|
*/
|
|
101
|
-
_getNext() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
131
|
+
async _getNext() {
|
|
132
|
+
// Drain current traverser's bulk first
|
|
133
|
+
if (this._currentTraverser) {
|
|
134
|
+
if (this._currentTraverser.bulk > 0) {
|
|
135
|
+
this._currentTraverser.bulk--;
|
|
136
|
+
const value = this._currentTraverser.object;
|
|
137
|
+
if (this._currentTraverser.bulk <= 0) {
|
|
138
|
+
this._currentTraverser = null;
|
|
108
139
|
}
|
|
140
|
+
return { value, done: false };
|
|
109
141
|
}
|
|
110
|
-
this.
|
|
111
|
-
|
|
112
|
-
|
|
142
|
+
this._currentTraverser = null;
|
|
143
|
+
}
|
|
144
|
+
// Streaming source path
|
|
145
|
+
if (this._resultsStream) {
|
|
146
|
+
if (this._done)
|
|
147
|
+
return itemDone;
|
|
148
|
+
const { value, done } = await this._resultsStream.next();
|
|
149
|
+
if (done) {
|
|
150
|
+
this._done = true;
|
|
151
|
+
this._status = value ?? null;
|
|
152
|
+
return itemDone;
|
|
113
153
|
}
|
|
154
|
+
if (value instanceof Traverser) {
|
|
155
|
+
if (value.bulk > 0) {
|
|
156
|
+
value.bulk--;
|
|
157
|
+
const result = value.object;
|
|
158
|
+
if (value.bulk > 0) {
|
|
159
|
+
this._currentTraverser = value;
|
|
160
|
+
}
|
|
161
|
+
return { value: result, done: false };
|
|
162
|
+
}
|
|
163
|
+
return itemDone;
|
|
164
|
+
}
|
|
165
|
+
return { value, done: false };
|
|
114
166
|
}
|
|
115
167
|
return itemDone;
|
|
116
168
|
}
|
|
@@ -255,12 +307,18 @@ export class P {
|
|
|
255
307
|
if (args.length === 1 && Array.isArray(args[0])) {
|
|
256
308
|
return new P('within', args[0], null);
|
|
257
309
|
}
|
|
310
|
+
if (args.length === 1 && args[0] != null && typeof args[0].getGremlinLang === 'function') {
|
|
311
|
+
return new P('within', args[0], null);
|
|
312
|
+
}
|
|
258
313
|
return new P('within', args, null);
|
|
259
314
|
}
|
|
260
315
|
static without(...args) {
|
|
261
316
|
if (args.length === 1 && Array.isArray(args[0])) {
|
|
262
317
|
return new P('without', args[0], null);
|
|
263
318
|
}
|
|
319
|
+
if (args.length === 1 && args[0] != null && typeof args[0].getGremlinLang === 'function') {
|
|
320
|
+
return new P('without', args[0], null);
|
|
321
|
+
}
|
|
264
322
|
return new P('without', args, null);
|
|
265
323
|
}
|
|
266
324
|
/** @param {...Object} args */
|
|
@@ -457,7 +515,6 @@ export const column = toEnum('Column', 'keys values');
|
|
|
457
515
|
export const direction = toDirectionEnum('Direction', 'BOTH IN OUT from_ to');
|
|
458
516
|
export const dt = toEnum('DT', 'second minute hour day');
|
|
459
517
|
export const gType = toGTypeEnum('GType', 'bigDecimal bigInt binary boolean byte char datetime double duration edge float graph int list long map null number path property set short string tree uuid vertex vproperty');
|
|
460
|
-
export const graphSONVersion = toEnum('GraphSONVersion', 'V1_0 V2_0 V3_0');
|
|
461
518
|
export const gryoVersion = toEnum('GryoVersion', 'V1_0 V3_0');
|
|
462
519
|
export const merge = toEnum('Merge', 'onCreate onMatch outV inV');
|
|
463
520
|
export const operator = toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong');
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface PdtAdapter {
|
|
2
|
+
serialize: (obj: any) => Record<string, any>;
|
|
3
|
+
deserialize: (fields: Record<string, any>) => any;
|
|
4
|
+
}
|
|
5
|
+
export interface PrimitivePdtAdapter {
|
|
6
|
+
toValue: (obj: any) => string;
|
|
7
|
+
fromValue: (value: string) => any;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A standalone registry that allows users to register adapters for hydrating
|
|
11
|
+
* raw {@link CompositePDT} and {@link PrimitivePDT} instances
|
|
12
|
+
* into domain-specific objects.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PDTRegistry {
|
|
15
|
+
private readonly _adapters;
|
|
16
|
+
private readonly _adaptersByClass;
|
|
17
|
+
private readonly _primitiveAdapters;
|
|
18
|
+
private readonly _primitiveAdaptersByClass;
|
|
19
|
+
register(typeName: string, adapter: PdtAdapter, targetClass?: Function): void;
|
|
20
|
+
registerPrimitive(typeName: string, adapter: PrimitivePdtAdapter, targetClass?: Function): void;
|
|
21
|
+
hydrate(pdt: any): any;
|
|
22
|
+
hydratePrimitive(pdt: any): any;
|
|
23
|
+
hasAdapter(typeName: string): boolean;
|
|
24
|
+
hasPrimitiveAdapter(typeName: string): boolean;
|
|
25
|
+
getSerializer(typeName: string): ((obj: any) => Record<string, any>) | null;
|
|
26
|
+
getAdapterByClass(cls: Function): {
|
|
27
|
+
typeName: string;
|
|
28
|
+
serialize: (obj: any) => Record<string, any>;
|
|
29
|
+
} | null;
|
|
30
|
+
getPrimitiveAdapterByClass(cls: Function): {
|
|
31
|
+
typeName: string;
|
|
32
|
+
toValue: (obj: any) => string;
|
|
33
|
+
} | null;
|
|
34
|
+
}
|