@ultipa-graph/ultipa-driver 5.0.0-s5.0
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/dist/.DS_Store +0 -0
- package/dist/connection/connection.final.d.ts +45 -0
- package/dist/connection/connection.final.js +600 -0
- package/dist/connection/connection.final.js.map +1 -0
- package/dist/connection/connection.pool.d.ts +26 -0
- package/dist/connection/connection.pool.js +121 -0
- package/dist/connection/connection.pool.js.map +1 -0
- package/dist/connection/extra/algos/algo.extra.d.ts +34 -0
- package/dist/connection/extra/algos/algo.extra.js +81 -0
- package/dist/connection/extra/algos/algo.extra.js.map +1 -0
- package/dist/connection/extra/algos/algo.utils.d.ts +3 -0
- package/dist/connection/extra/algos/algo.utils.js +71 -0
- package/dist/connection/extra/algos/algo.utils.js.map +1 -0
- package/dist/connection/extra/algos/community.d.ts +27 -0
- package/dist/connection/extra/algos/community.js +129 -0
- package/dist/connection/extra/algos/community.js.map +1 -0
- package/dist/connection/extra/algos/degrees.d.ts +10 -0
- package/dist/connection/extra/algos/degrees.js +43 -0
- package/dist/connection/extra/algos/degrees.js.map +1 -0
- package/dist/connection/extra/algos/embedding.d.ts +13 -0
- package/dist/connection/extra/algos/embedding.js +58 -0
- package/dist/connection/extra/algos/embedding.js.map +1 -0
- package/dist/connection/extra/algos/index.d.ts +5 -0
- package/dist/connection/extra/algos/index.js +14 -0
- package/dist/connection/extra/algos/index.js.map +1 -0
- package/dist/connection/extra/base.extra.d.ts +71 -0
- package/dist/connection/extra/base.extra.js +183 -0
- package/dist/connection/extra/base.extra.js.map +1 -0
- package/dist/connection/extra/connection.base.d.ts +82 -0
- package/dist/connection/extra/connection.base.js +623 -0
- package/dist/connection/extra/connection.base.js.map +1 -0
- package/dist/connection/extra/connection.d.ts +16 -0
- package/dist/connection/extra/connection.js +46 -0
- package/dist/connection/extra/connection.js.map +1 -0
- package/dist/connection/extra/graph.extra.d.ts +85 -0
- package/dist/connection/extra/graph.extra.js +241 -0
- package/dist/connection/extra/graph.extra.js.map +1 -0
- package/dist/connection/extra/index.extra.d.ts +70 -0
- package/dist/connection/extra/index.extra.js +201 -0
- package/dist/connection/extra/index.extra.js.map +1 -0
- package/dist/connection/extra/job.extra.d.ts +32 -0
- package/dist/connection/extra/job.extra.js +145 -0
- package/dist/connection/extra/job.extra.js.map +1 -0
- package/dist/connection/extra/meta.extra.d.ts +91 -0
- package/dist/connection/extra/meta.extra.js +441 -0
- package/dist/connection/extra/meta.extra.js.map +1 -0
- package/dist/connection/extra/property.extra.d.ts +81 -0
- package/dist/connection/extra/property.extra.js +268 -0
- package/dist/connection/extra/property.extra.js.map +1 -0
- package/dist/connection/extra/schema.extra.d.ts +50 -0
- package/dist/connection/extra/schema.extra.js +248 -0
- package/dist/connection/extra/schema.extra.js.map +1 -0
- package/dist/connection/extra/search.extra.d.ts +12 -0
- package/dist/connection/extra/search.extra.js +126 -0
- package/dist/connection/extra/search.extra.js.map +1 -0
- package/dist/connection/extra/task.extra.d.ts +24 -0
- package/dist/connection/extra/task.extra.js +126 -0
- package/dist/connection/extra/task.extra.js.map +1 -0
- package/dist/connection/extra/user.privilege.extra.d.ts +64 -0
- package/dist/connection/extra/user.privilege.extra.js +348 -0
- package/dist/connection/extra/user.privilege.extra.js.map +1 -0
- package/dist/connection/index.d.ts +4 -0
- package/dist/connection/index.js +10 -0
- package/dist/connection/index.js.map +1 -0
- package/dist/connection/network.manager.d.ts +27 -0
- package/dist/connection/network.manager.js +178 -0
- package/dist/connection/network.manager.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/printers/alias.d.ts +2 -0
- package/dist/printers/alias.js +15 -0
- package/dist/printers/alias.js.map +1 -0
- package/dist/printers/any.d.ts +2 -0
- package/dist/printers/any.js +40 -0
- package/dist/printers/any.js.map +1 -0
- package/dist/printers/array.aio.d.ts +44 -0
- package/dist/printers/array.aio.js +240 -0
- package/dist/printers/array.aio.js.map +1 -0
- package/dist/printers/common.d.ts +0 -0
- package/dist/printers/common.js +1 -0
- package/dist/printers/common.js.map +1 -0
- package/dist/printers/edge.d.ts +5 -0
- package/dist/printers/edge.js +49 -0
- package/dist/printers/edge.js.map +1 -0
- package/dist/printers/explain.plan.d.ts +2 -0
- package/dist/printers/explain.plan.js +24 -0
- package/dist/printers/explain.plan.js.map +1 -0
- package/dist/printers/graph.d.ts +2 -0
- package/dist/printers/graph.js +34 -0
- package/dist/printers/graph.js.map +1 -0
- package/dist/printers/index.d.ts +25 -0
- package/dist/printers/index.js +44 -0
- package/dist/printers/index.js.map +1 -0
- package/dist/printers/node.d.ts +5 -0
- package/dist/printers/node.js +49 -0
- package/dist/printers/node.js.map +1 -0
- package/dist/printers/path.d.ts +3 -0
- package/dist/printers/path.js +42 -0
- package/dist/printers/path.js.map +1 -0
- package/dist/printers/status.d.ts +3 -0
- package/dist/printers/status.js +45 -0
- package/dist/printers/status.js.map +1 -0
- package/dist/printers/table.d.ts +2 -0
- package/dist/printers/table.js +31 -0
- package/dist/printers/table.js.map +1 -0
- package/dist/proto/tmp.js +366 -0
- package/dist/proto/ultipa_grpc_pb.d.ts +257 -0
- package/dist/proto/ultipa_grpc_pb.js +366 -0
- package/dist/proto/ultipa_grpc_pb.js.map +1 -0
- package/dist/proto/ultipa_pb.d.ts +1 -0
- package/dist/proto/ultipa_pb.js +11002 -0
- package/dist/proto/ultipa_pb.js.map +1 -0
- package/dist/transaction/UltipaSession.d.ts +28 -0
- package/dist/transaction/UltipaSession.js +148 -0
- package/dist/transaction/UltipaSession.js.map +1 -0
- package/dist/transaction/UltipaTransaction.Recorder.d.ts +20 -0
- package/dist/transaction/UltipaTransaction.Recorder.js +23 -0
- package/dist/transaction/UltipaTransaction.Recorder.js.map +1 -0
- package/dist/transaction/UltipaTransaction.d.ts +35 -0
- package/dist/transaction/UltipaTransaction.js +203 -0
- package/dist/transaction/UltipaTransaction.js.map +1 -0
- package/dist/transaction/UltipaTransactionSession.d.ts +15 -0
- package/dist/transaction/UltipaTransactionSession.js +46 -0
- package/dist/transaction/UltipaTransactionSession.js.map +1 -0
- package/dist/transaction/operations/Transaction.Deletes.d.ts +4 -0
- package/dist/transaction/operations/Transaction.Deletes.js +52 -0
- package/dist/transaction/operations/Transaction.Deletes.js.map +1 -0
- package/dist/transaction/operations/Transaction.Inserts.d.ts +4 -0
- package/dist/transaction/operations/Transaction.Inserts.js +78 -0
- package/dist/transaction/operations/Transaction.Inserts.js.map +1 -0
- package/dist/transaction/operations/Transaction.Update.d.ts +4 -0
- package/dist/transaction/operations/Transaction.Update.js +43 -0
- package/dist/transaction/operations/Transaction.Update.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +13 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/types.algos.params.d.ts +545 -0
- package/dist/types/types.algos.params.js +16 -0
- package/dist/types/types.algos.params.js.map +1 -0
- package/dist/types/types.d.ts +496 -0
- package/dist/types/types.extra.d.ts +788 -0
- package/dist/types/types.extra.js +49 -0
- package/dist/types/types.extra.js.map +1 -0
- package/dist/types/types.js +706 -0
- package/dist/types/types.js.map +1 -0
- package/dist/types/util.d.ts +15 -0
- package/dist/types/util.js +163 -0
- package/dist/types/util.js.map +1 -0
- package/dist/utils/common.d.ts +3 -0
- package/dist/utils/common.js +31 -0
- package/dist/utils/common.js.map +1 -0
- package/dist/utils/config.d.ts +3 -0
- package/dist/utils/config.js +7 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/format.d.ts +49 -0
- package/dist/utils/format.js +990 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +34 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/params.validate.d.ts +4 -0
- package/dist/utils/params.validate.js +14 -0
- package/dist/utils/params.validate.js.map +1 -0
- package/dist/utils/property.d.ts +15 -0
- package/dist/utils/property.js +117 -0
- package/dist/utils/property.js.map +1 -0
- package/dist/utils/raft.retry.d.ts +0 -0
- package/dist/utils/raft.retry.js +1 -0
- package/dist/utils/raft.retry.js.map +1 -0
- package/dist/utils/serialize/commont.d.ts +12 -0
- package/dist/utils/serialize/commont.js +46 -0
- package/dist/utils/serialize/commont.js.map +1 -0
- package/dist/utils/serialize/deserialize.d.ts +9 -0
- package/dist/utils/serialize/deserialize.js +164 -0
- package/dist/utils/serialize/deserialize.js.map +1 -0
- package/dist/utils/serialize/null.d.ts +24 -0
- package/dist/utils/serialize/null.js +133 -0
- package/dist/utils/serialize/null.js.map +1 -0
- package/dist/utils/serialize/serialize.d.ts +10 -0
- package/dist/utils/serialize/serialize.js +135 -0
- package/dist/utils/serialize/serialize.js.map +1 -0
- package/dist/utils/stream.helper.d.ts +9 -0
- package/dist/utils/stream.helper.js +97 -0
- package/dist/utils/stream.helper.js.map +1 -0
- package/dist/utils/time.record.d.ts +15 -0
- package/dist/utils/time.record.js +50 -0
- package/dist/utils/time.record.js.map +1 -0
- package/dist/utils/timezone.d.ts +7 -0
- package/dist/utils/timezone.js +21 -0
- package/dist/utils/timezone.js.map +1 -0
- package/dist/utils/ultipa.datetime.d.ts +8 -0
- package/dist/utils/ultipa.datetime.js +120 -0
- package/dist/utils/ultipa.datetime.js.map +1 -0
- package/dist/utils/uql-maker.d.ts +164 -0
- package/dist/utils/uql-maker.js +400 -0
- package/dist/utils/uql-maker.js.map +1 -0
- package/dist/utils/uql.parse.d.ts +27 -0
- package/dist/utils/uql.parse.js +206 -0
- package/dist/utils/uql.parse.js.map +1 -0
- package/package.json +62 -0
- package/readme.md +63 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { UltipaTransactionRecorder } from "./UltipaTransaction.Recorder";
|
|
2
|
+
import { ConnectionFinal } from "../connection/connection.final";
|
|
3
|
+
import { UltipaTransaction } from "./UltipaTransaction";
|
|
4
|
+
import { RequestType, ULTIPA } from "../types";
|
|
5
|
+
import RequestConfig = RequestType.RequestConfig;
|
|
6
|
+
export declare class UltipaSession {
|
|
7
|
+
recorder: UltipaTransactionRecorder;
|
|
8
|
+
txn: UltipaTransaction;
|
|
9
|
+
id: string;
|
|
10
|
+
conn: ConnectionFinal;
|
|
11
|
+
onError?: (Msg: string) => void;
|
|
12
|
+
constructor(conn: ConnectionFinal, txn: UltipaTransaction);
|
|
13
|
+
uql(uql: string, requestConfig?: RequestConfig): Promise<ULTIPA.UQLResponse>;
|
|
14
|
+
insertNodes(nodes: ULTIPA.Node[]): Promise<ULTIPA.Response<import("../types").ResponseType.InsertNodes>>;
|
|
15
|
+
insertEdges(edges: ULTIPA.Edge[]): Promise<ULTIPA.Response<import("../types").ResponseType.InsertEdges>>;
|
|
16
|
+
deleteNodes(filter: string): Promise<ULTIPA.UQLResponse>;
|
|
17
|
+
deleteEdges(filter: string): Promise<ULTIPA.UQLResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* @param filter "age > 10"
|
|
20
|
+
* @param value "{time: "1999-01-01 12:12:00", age: 10}"
|
|
21
|
+
*/
|
|
22
|
+
updateNodes(filter: string, value: string): Promise<ULTIPA.UQLResponse>;
|
|
23
|
+
updateEdges(filter: string, value: string): Promise<ULTIPA.UQLResponse>;
|
|
24
|
+
rollback(msg?: string): Promise<void>;
|
|
25
|
+
commit(): Promise<void>;
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
throwError(msg: string, rollback?: boolean): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UltipaSession = void 0;
|
|
13
|
+
const UltipaTransaction_Recorder_1 = require("./UltipaTransaction.Recorder");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
const types_1 = require("../types");
|
|
16
|
+
const Transaction_Inserts_1 = require("./operations/Transaction.Inserts");
|
|
17
|
+
const Transaction_Deletes_1 = require("./operations/Transaction.Deletes");
|
|
18
|
+
const Transaction_Update_1 = require("./operations/Transaction.Update");
|
|
19
|
+
var InsertType = types_1.ULTIPA.InsertType;
|
|
20
|
+
const { v4: uuidv4 } = require("uuid");
|
|
21
|
+
class UltipaSession {
|
|
22
|
+
constructor(conn, txn) {
|
|
23
|
+
this.recorder = new UltipaTransaction_Recorder_1.UltipaTransactionRecorder();
|
|
24
|
+
this.conn = conn;
|
|
25
|
+
this.id = uuidv4();
|
|
26
|
+
this.txn = txn;
|
|
27
|
+
console.log(`Transaction ID ${this.id} Created`);
|
|
28
|
+
}
|
|
29
|
+
uql(uql, requestConfig) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
var u = new utils_1.EasyUqlParse(uql);
|
|
32
|
+
if (u.hasWrite()) {
|
|
33
|
+
yield this.throwError("The uql contains some writing clauses, please using transaction api to update, insert or delete data.");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (u.isGlobal()) {
|
|
37
|
+
yield this.throwError("Database level operation can not executed in a transaction, such as privileges/user/graph/task operations");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var res = yield this.conn.uql(uql, requestConfig);
|
|
41
|
+
if (res.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
42
|
+
yield this.throwError(res.status.message);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
return res;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
insertNodes(nodes) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return yield (0, Transaction_Inserts_1.InsertNodes)(this, nodes);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
insertEdges(edges) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return yield (0, Transaction_Inserts_1.InsertEdges)(this, edges);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
deleteNodes(filter) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return yield (0, Transaction_Deletes_1.deleteNodes)(this, filter);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
deleteEdges(filter) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
return yield (0, Transaction_Deletes_1.deleteEdges)(this, filter);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @param filter "age > 10"
|
|
70
|
+
* @param value "{time: "1999-01-01 12:12:00", age: 10}"
|
|
71
|
+
*/
|
|
72
|
+
updateNodes(filter, value) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
return yield (0, Transaction_Update_1.UpdateNodes)(this, filter, value);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
updateEdges(filter, value) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
return yield (0, Transaction_Update_1.UpdateEdges)(this, filter, value);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
rollback(msg) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
console.log(`transaction ID: ${this.id} rollback`);
|
|
85
|
+
msg && console.log("Caused by " + msg);
|
|
86
|
+
for (let op of this.recorder.logs.reverse()) {
|
|
87
|
+
switch (op.Op) {
|
|
88
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.New_Nodes:
|
|
89
|
+
let newNodeRes = yield this.conn.uql(`delete().nodes({_uuid in [${op.node_uuids.join(",")}]})`);
|
|
90
|
+
if (newNodeRes.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
91
|
+
yield this.throwError(newNodeRes.status.message, false);
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.New_Edges:
|
|
95
|
+
let resNewEdges = yield this.conn.uql(`delete().edges({_uuid in [${op.edge_uuids.join(",")}]})`);
|
|
96
|
+
if (resNewEdges.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
97
|
+
yield this.throwError(resNewEdges.status.message, false);
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Delete_Nodes:
|
|
101
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Update_Nodes:
|
|
102
|
+
let resDeleteUpdateNodes = yield this.conn.insertNodesBatchAuto(op.nodes, {
|
|
103
|
+
insertType: InsertType.INSERT_TYPE_OVERWRITE,
|
|
104
|
+
silent: true
|
|
105
|
+
});
|
|
106
|
+
if (resDeleteUpdateNodes.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
107
|
+
yield this.throwError(resDeleteUpdateNodes.status.message, false);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Update_Edges:
|
|
111
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Delete_Edges:
|
|
112
|
+
let resDeleteEdges = yield this.conn.insertEdgesBatchAuto(op.edges, {
|
|
113
|
+
insertType: InsertType.INSERT_TYPE_OVERWRITE,
|
|
114
|
+
silent: true
|
|
115
|
+
});
|
|
116
|
+
if (resDeleteEdges.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
117
|
+
yield this.throwError(resDeleteEdges.status.message, false);
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
yield this.throwError("Not Supported Operation found! " + JSON.stringify(op), false);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
commit() {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
console.log(`transaction ID: ${this.id} committed`);
|
|
129
|
+
yield this.close();
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
close() {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
this.recorder.close();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
throwError(msg, rollback = true) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
this.onError && this.onError(msg);
|
|
140
|
+
if (rollback)
|
|
141
|
+
yield this.rollback(msg);
|
|
142
|
+
throw new Error(msg);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
;
|
|
146
|
+
}
|
|
147
|
+
exports.UltipaSession = UltipaSession;
|
|
148
|
+
//# sourceMappingURL=UltipaSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UltipaSession.js","sourceRoot":"","sources":["../../src/transaction/UltipaSession.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6EAAoG;AAEpG,oCAAsC;AAEtC,oCAA6C;AAC7C,0EAA0E;AAC1E,0EAA0E;AAC1E,wEAAyE;AAEzE,IAAO,UAAU,GAAG,cAAM,CAAC,UAAU,CAAC;AAEtC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAGvC,MAAa,aAAa;IAStB,YAAY,IAAqB,EAAE,GAAsB;QARzD,aAAQ,GAA8B,IAAI,sDAAyB,EAAE,CAAC;QASlE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC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D,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QACtB,CAAC;KAAA;IACK,KAAK;;YACP,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;QACzB,CAAC;KAAA;IAEK,UAAU,CAAC,GAAU,EAAE,WAAoB,IAAI;;YACjD,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAClC,IAAG,QAAQ;gBAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;KAAA;IAAA,CAAC;CAEL;AAjHD,sCAiHC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ULTIPA } from "../types";
|
|
2
|
+
export declare enum UltipaTransactionRecorderOp {
|
|
3
|
+
New_Nodes = 0,
|
|
4
|
+
New_Edges = 1,
|
|
5
|
+
Delete_Nodes = 2,
|
|
6
|
+
Delete_Edges = 3,
|
|
7
|
+
Update_Nodes = 4,
|
|
8
|
+
Update_Edges = 5
|
|
9
|
+
}
|
|
10
|
+
export declare class UltipaTransactionRecorder {
|
|
11
|
+
logs: {
|
|
12
|
+
node_uuids?: number[];
|
|
13
|
+
edge_uuids?: number[];
|
|
14
|
+
nodes?: ULTIPA.Node[];
|
|
15
|
+
edges?: ULTIPA.Edge[];
|
|
16
|
+
Op: UltipaTransactionRecorderOp;
|
|
17
|
+
}[];
|
|
18
|
+
constructor();
|
|
19
|
+
close(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UltipaTransactionRecorder = exports.UltipaTransactionRecorderOp = void 0;
|
|
4
|
+
var UltipaTransactionRecorderOp;
|
|
5
|
+
(function (UltipaTransactionRecorderOp) {
|
|
6
|
+
UltipaTransactionRecorderOp[UltipaTransactionRecorderOp["New_Nodes"] = 0] = "New_Nodes";
|
|
7
|
+
UltipaTransactionRecorderOp[UltipaTransactionRecorderOp["New_Edges"] = 1] = "New_Edges";
|
|
8
|
+
UltipaTransactionRecorderOp[UltipaTransactionRecorderOp["Delete_Nodes"] = 2] = "Delete_Nodes";
|
|
9
|
+
UltipaTransactionRecorderOp[UltipaTransactionRecorderOp["Delete_Edges"] = 3] = "Delete_Edges";
|
|
10
|
+
UltipaTransactionRecorderOp[UltipaTransactionRecorderOp["Update_Nodes"] = 4] = "Update_Nodes";
|
|
11
|
+
UltipaTransactionRecorderOp[UltipaTransactionRecorderOp["Update_Edges"] = 5] = "Update_Edges";
|
|
12
|
+
})(UltipaTransactionRecorderOp = exports.UltipaTransactionRecorderOp || (exports.UltipaTransactionRecorderOp = {}));
|
|
13
|
+
class UltipaTransactionRecorder {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
constructor() {
|
|
16
|
+
this.logs = [];
|
|
17
|
+
}
|
|
18
|
+
close() {
|
|
19
|
+
delete this.logs;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.UltipaTransactionRecorder = UltipaTransactionRecorder;
|
|
23
|
+
//# sourceMappingURL=UltipaTransaction.Recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UltipaTransaction.Recorder.js","sourceRoot":"","sources":["../../src/transaction/UltipaTransaction.Recorder.ts"],"names":[],"mappings":";;;AAKA,IAAa,2BAOZ;AAPD,WAAa,2BAA2B;IACpC,uFAAS,CAAA;IACT,uFAAS,CAAA;IACT,6FAAY,CAAA;IACZ,6FAAY,CAAA;IACZ,6FAAY,CAAA;IACZ,6FAAY,CAAA;AAChB,CAAC,EAPY,2BAA2B,GAA3B,mCAA2B,KAA3B,mCAA2B,QAOvC;AAED,MAAa,yBAAyB;IAQlC,aAAa;IACb;QACI,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;IAClB,CAAC;IAED,KAAK;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;CAEJ;AAjBD,8DAiBC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { UltipaTransactionRecorder } from "./UltipaTransaction.Recorder";
|
|
2
|
+
import { ConnectionFinal } from "../connection/connection.final";
|
|
3
|
+
import { UltipaTransactionSession } from "./UltipaTransactionSession";
|
|
4
|
+
import { RequestType, ULTIPA } from "../types";
|
|
5
|
+
import RequestConfig = RequestType.RequestConfig;
|
|
6
|
+
export declare enum TransactionStatus {
|
|
7
|
+
Open = 0,
|
|
8
|
+
Closed = 1,
|
|
9
|
+
Committed = 2
|
|
10
|
+
}
|
|
11
|
+
export declare class UltipaTransaction {
|
|
12
|
+
recorder: UltipaTransactionRecorder;
|
|
13
|
+
session: UltipaTransactionSession;
|
|
14
|
+
status: TransactionStatus;
|
|
15
|
+
id: string;
|
|
16
|
+
conn: ConnectionFinal;
|
|
17
|
+
onError?: (Msg: string) => void;
|
|
18
|
+
constructor(conn: ConnectionFinal, session: UltipaTransactionSession);
|
|
19
|
+
uql(uql: string, requestConfig?: RequestConfig): Promise<ULTIPA.UQLResponse>;
|
|
20
|
+
insertNodes(nodes: ULTIPA.Node[]): Promise<ULTIPA.Response<import("../types").ResponseType.InsertNodes>>;
|
|
21
|
+
insertEdges(edges: ULTIPA.Edge[]): Promise<ULTIPA.Response<import("../types").ResponseType.InsertEdges>>;
|
|
22
|
+
deleteNodes(filter: string): Promise<ULTIPA.UQLResponse>;
|
|
23
|
+
deleteEdges(filter: string): Promise<ULTIPA.UQLResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* @param filter "age > 10"
|
|
26
|
+
* @param value "{time: "1999-01-01 12:12:00", age: 10}"
|
|
27
|
+
*/
|
|
28
|
+
updateNodes(filter: string, value: string): Promise<ULTIPA.UQLResponse>;
|
|
29
|
+
updateEdges(filter: string, value: string): Promise<ULTIPA.UQLResponse>;
|
|
30
|
+
rollback(msg?: string): Promise<void>;
|
|
31
|
+
commit(): Promise<void>;
|
|
32
|
+
close(): Promise<void>;
|
|
33
|
+
throwError(msg: string, rollback?: boolean): Promise<void>;
|
|
34
|
+
checkCommitOrClosed(silent?: boolean): Promise<boolean>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UltipaTransaction = exports.TransactionStatus = void 0;
|
|
13
|
+
const UltipaTransaction_Recorder_1 = require("./UltipaTransaction.Recorder");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
const types_1 = require("../types");
|
|
16
|
+
const Transaction_Inserts_1 = require("./operations/Transaction.Inserts");
|
|
17
|
+
const Transaction_Deletes_1 = require("./operations/Transaction.Deletes");
|
|
18
|
+
const Transaction_Update_1 = require("./operations/Transaction.Update");
|
|
19
|
+
var InsertType = types_1.ULTIPA.InsertType;
|
|
20
|
+
const { v4: uuidv4 } = require("uuid");
|
|
21
|
+
var TransactionStatus;
|
|
22
|
+
(function (TransactionStatus) {
|
|
23
|
+
TransactionStatus[TransactionStatus["Open"] = 0] = "Open";
|
|
24
|
+
TransactionStatus[TransactionStatus["Closed"] = 1] = "Closed";
|
|
25
|
+
TransactionStatus[TransactionStatus["Committed"] = 2] = "Committed";
|
|
26
|
+
})(TransactionStatus = exports.TransactionStatus || (exports.TransactionStatus = {}));
|
|
27
|
+
class UltipaTransaction {
|
|
28
|
+
constructor(conn, session) {
|
|
29
|
+
this.recorder = new UltipaTransaction_Recorder_1.UltipaTransactionRecorder();
|
|
30
|
+
// store the items in this session, insert/delete/or uqls.
|
|
31
|
+
// txnItems : txnItem[];
|
|
32
|
+
this.status = TransactionStatus.Open;
|
|
33
|
+
this.conn = conn;
|
|
34
|
+
this.id = uuidv4();
|
|
35
|
+
this.session = session;
|
|
36
|
+
console.log(`Transaction ID ${this.id} Created`);
|
|
37
|
+
}
|
|
38
|
+
uql(uql, requestConfig) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (yield this.checkCommitOrClosed())
|
|
41
|
+
return;
|
|
42
|
+
var u = new utils_1.EasyUqlParse(uql);
|
|
43
|
+
if (u.hasWrite()) {
|
|
44
|
+
yield this.throwError("The uql contains some writing clauses, please using transaction api to update, insert or delete data.");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (u.isGlobal()) {
|
|
48
|
+
yield this.throwError("Database level operation can not executed in a transaction, such as privileges/user/graph/task operations");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
var res = yield this.conn.uql(uql, requestConfig);
|
|
52
|
+
if (res.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
53
|
+
yield this.throwError(res.status.message);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
return res;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
insertNodes(nodes) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
if (yield this.checkCommitOrClosed())
|
|
62
|
+
return;
|
|
63
|
+
return yield (0, Transaction_Inserts_1.InsertNodes)(this, nodes);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
insertEdges(edges) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
if (yield this.checkCommitOrClosed())
|
|
69
|
+
return;
|
|
70
|
+
return yield (0, Transaction_Inserts_1.InsertEdges)(this, edges);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
deleteNodes(filter) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
if (yield this.checkCommitOrClosed())
|
|
76
|
+
return;
|
|
77
|
+
return yield (0, Transaction_Deletes_1.deleteNodes)(this, filter);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
deleteEdges(filter) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
if (yield this.checkCommitOrClosed())
|
|
83
|
+
return;
|
|
84
|
+
return yield (0, Transaction_Deletes_1.deleteEdges)(this, filter);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @param filter "age > 10"
|
|
89
|
+
* @param value "{time: "1999-01-01 12:12:00", age: 10}"
|
|
90
|
+
*/
|
|
91
|
+
updateNodes(filter, value) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
if (yield this.checkCommitOrClosed())
|
|
94
|
+
return;
|
|
95
|
+
return yield (0, Transaction_Update_1.UpdateNodes)(this, filter, value);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
updateEdges(filter, value) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
if (yield this.checkCommitOrClosed())
|
|
101
|
+
return;
|
|
102
|
+
return yield (0, Transaction_Update_1.UpdateEdges)(this, filter, value);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
rollback(msg) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
console.log(`transaction ID: ${this.id} rollback`);
|
|
108
|
+
msg && console.log("Caused by " + msg);
|
|
109
|
+
if (yield this.checkCommitOrClosed())
|
|
110
|
+
return;
|
|
111
|
+
for (let op of this.recorder.logs.reverse()) {
|
|
112
|
+
switch (op.Op) {
|
|
113
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.New_Nodes:
|
|
114
|
+
let newNodeRes = yield this.conn.uql(`delete().nodes({_uuid in [${op.node_uuids.join(",")}]})`);
|
|
115
|
+
if (newNodeRes.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
116
|
+
yield this.throwError(newNodeRes.status.message, false);
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.New_Edges:
|
|
120
|
+
let resNewEdges = yield this.conn.uql(`delete().edges({_uuid in [${op.edge_uuids.join(",")}]})`);
|
|
121
|
+
if (resNewEdges.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
122
|
+
yield this.throwError(resNewEdges.status.message, false);
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Delete_Nodes:
|
|
126
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Update_Nodes:
|
|
127
|
+
let resDeleteUpdateNodes = yield this.conn.insertNodesBatchAuto(op.nodes, {
|
|
128
|
+
insertType: InsertType.INSERT_TYPE_OVERWRITE,
|
|
129
|
+
silent: true
|
|
130
|
+
});
|
|
131
|
+
if (resDeleteUpdateNodes.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
132
|
+
yield this.throwError(resDeleteUpdateNodes.status.message, false);
|
|
133
|
+
}
|
|
134
|
+
if (!!op.edges && op.edges.length > 0) {
|
|
135
|
+
let resDeleteNodesRecoverEdges = yield this.conn.insertEdgesBatchAuto(op.edges, {
|
|
136
|
+
insertType: InsertType.INSERT_TYPE_OVERWRITE,
|
|
137
|
+
silent: true
|
|
138
|
+
});
|
|
139
|
+
if (resDeleteNodesRecoverEdges.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
140
|
+
yield this.throwError(resDeleteNodesRecoverEdges.status.message, false);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Update_Edges:
|
|
145
|
+
case UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Delete_Edges:
|
|
146
|
+
let resDeleteEdges = yield this.conn.insertEdgesBatchAuto(op.edges, {
|
|
147
|
+
insertType: InsertType.INSERT_TYPE_OVERWRITE,
|
|
148
|
+
silent: true
|
|
149
|
+
});
|
|
150
|
+
if (resDeleteEdges.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
151
|
+
yield this.throwError(resDeleteEdges.status.message, false);
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
yield this.throwError("Not Supported Operation found! " + JSON.stringify(op), false);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
this.recorder = new UltipaTransaction_Recorder_1.UltipaTransactionRecorder();
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
commit() {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
if (yield this.checkCommitOrClosed(true))
|
|
164
|
+
return;
|
|
165
|
+
console.log(`transaction ID: ${this.id} committed`);
|
|
166
|
+
this.status = TransactionStatus.Committed;
|
|
167
|
+
yield this.close();
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
close() {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
this.recorder.close();
|
|
173
|
+
if (yield this.checkCommitOrClosed(true))
|
|
174
|
+
return;
|
|
175
|
+
this.status = TransactionStatus.Closed;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
throwError(msg, rollback = true) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
this.onError && this.onError(msg);
|
|
181
|
+
if (rollback) {
|
|
182
|
+
yield this.rollback(msg);
|
|
183
|
+
}
|
|
184
|
+
throw new Error(msg);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
;
|
|
188
|
+
checkCommitOrClosed(silent = false) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
if (this.status == TransactionStatus.Committed) {
|
|
191
|
+
!silent && (yield this.throwError(`Transaction ID ${this.id} has been committed. other operation is not allowed`, false));
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
if (this.status == TransactionStatus.Closed) {
|
|
195
|
+
!silent && (yield this.throwError(`Transaction ID ${this.id} has been closed. other operation is not allowed`, false));
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.UltipaTransaction = UltipaTransaction;
|
|
203
|
+
//# sourceMappingURL=UltipaTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UltipaTransaction.js","sourceRoot":"","sources":["../../src/transaction/UltipaTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6EAAoG;AAEpG,oCAAsC;AAEtC,oCAA6C;AAC7C,0EAA0E;AAC1E,0EAA0E;AAC1E,wEAAyE;AAEzE,IAAO,UAAU,GAAG,cAAM,CAAC,UAAU,CAAC;AAEtC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAEvC,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,yDAAI,CAAA;IACJ,6DAAM,CAAA;IACN,mEAAS,CAAA;AACb,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AACD,MAAa,iBAAiB;IAU1B,YAAY,IAAqB,EAAE,OAAiC;QATpE,aAAQ,GAA8B,IAAI,sDAAyB,EAAE,CAAC;QAEtE,0DAA0D;QAC1D,wBAAwB;QACxB,WAAM,GAAsB,iBAAiB,CAAC,IAAI,CAAC;QAM/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;QACnB,IAAI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E,CAAA;YACrB,IAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;gBAAE,OAAM;YAC/C,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;QAC3C,CAAC;KAAA;IAEK,UAAU,CAAC,GAAU,EAAE,WAAoB,IAAI;;YACjD,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,QAAQ,EAAE;gBACV,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;aAC3B;YAED,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;KAAA;IAAA,CAAC;IAEI,mBAAmB,CAAC,MAAM,GAAG,KAAK;;YAGpC,IAAI,IAAI,CAAC,MAAM,IAAI,iBAAiB,CAAC,SAAS,EAAE;gBAC5C,CAAC,MAAM,KAAI,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,IAAI,CAAC,EAAE,qDAAqD,EAAE,KAAK,CAAC,CAAA,CAAA;gBACvH,OAAO,IAAI,CAAC;aACf;YAED,IAAI,IAAI,CAAC,MAAM,IAAI,iBAAiB,CAAC,MAAM,EAAE;gBACzC,CAAC,MAAM,KAAI,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,IAAI,CAAC,EAAE,kDAAkD,EAAE,KAAK,CAAC,CAAA,CAAA;gBACpH,OAAO,IAAI,CAAC;aACf;YAED,OAAO,KAAK,CAAA;QAChB,CAAC;KAAA;CAGJ;AApKD,8CAoKC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UltipaTransaction } from "./UltipaTransaction";
|
|
2
|
+
import type { queueAsPromised } from "fastq";
|
|
3
|
+
import { ConnectionFinal } from "../connection/connection.final";
|
|
4
|
+
type Task = {
|
|
5
|
+
id: number;
|
|
6
|
+
cb: () => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export declare class UltipaTransactionSession {
|
|
9
|
+
queue: queueAsPromised<Task>;
|
|
10
|
+
conn: ConnectionFinal;
|
|
11
|
+
taskIndex: number;
|
|
12
|
+
constructor(conn: ConnectionFinal);
|
|
13
|
+
exec(cb: (txn: UltipaTransaction) => Promise<void>): Promise<any>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UltipaTransactionSession = void 0;
|
|
16
|
+
const UltipaTransaction_1 = require("./UltipaTransaction");
|
|
17
|
+
const fastq_1 = __importDefault(require("fastq"));
|
|
18
|
+
function worker(arg) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
yield arg.cb();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
class UltipaTransactionSession {
|
|
24
|
+
constructor(conn) {
|
|
25
|
+
this.taskIndex = 0;
|
|
26
|
+
this.conn = conn;
|
|
27
|
+
this.queue = fastq_1.default.promise(worker, 1);
|
|
28
|
+
}
|
|
29
|
+
exec(cb) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
return this.queue.push({
|
|
32
|
+
id: this.taskIndex++,
|
|
33
|
+
cb: () => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
let txn = new UltipaTransaction_1.UltipaTransaction(this.conn, this);
|
|
35
|
+
yield cb(txn);
|
|
36
|
+
if (txn.status != UltipaTransaction_1.TransactionStatus.Committed) {
|
|
37
|
+
yield txn.rollback("rollback without commit and close int the end");
|
|
38
|
+
}
|
|
39
|
+
yield txn.close();
|
|
40
|
+
}),
|
|
41
|
+
}).catch((err) => console.error(err));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.UltipaTransactionSession = UltipaTransactionSession;
|
|
46
|
+
//# sourceMappingURL=UltipaTransactionSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UltipaTransactionSession.js","sourceRoot":"","sources":["../../src/transaction/UltipaTransactionSession.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAAyE;AAEzE,kDAA0B;AAQ1B,SAAe,MAAM,CAAE,GAAS;;QAC5B,MAAM,GAAG,CAAC,EAAE,EAAE,CAAA;IAClB,CAAC;CAAA;AAED,MAAa,wBAAwB;IAIjC,YAAY,IAAqB;QADjC,cAAS,GAAY,CAAC,CAAC;QAEnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,eAAK,CAAC,OAAO,CAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAEK,IAAI,CAAC,EAA8C;;YACrD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBACnB,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE;gBACpB,EAAE,EAAE,GAAS,EAAE;oBACX,IAAI,GAAG,GAAE,IAAI,qCAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;oBAC/C,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;oBACd,IAAI,GAAG,CAAC,MAAM,IAAI,qCAAiB,CAAC,SAAS,EAAE;wBAC3C,MAAM,GAAG,CAAC,QAAQ,CAAC,+CAA+C,CAAC,CAAC;qBACvE;oBACD,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;gBACtB,CAAC,CAAA;aACJ,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;KAAA;CAEJ;AAvBD,4DAuBC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { UltipaTransaction } from "../UltipaTransaction";
|
|
2
|
+
import { ULTIPA } from "../../types";
|
|
3
|
+
export declare function deleteNodes(session: UltipaTransaction, filter: string): Promise<ULTIPA.UQLResponse>;
|
|
4
|
+
export declare function deleteEdges(session: UltipaTransaction, filter: string): Promise<ULTIPA.UQLResponse>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.deleteEdges = exports.deleteNodes = void 0;
|
|
13
|
+
const types_1 = require("../../types");
|
|
14
|
+
const UltipaTransaction_Recorder_1 = require("../UltipaTransaction.Recorder");
|
|
15
|
+
// filter should be { <filter> }
|
|
16
|
+
function deleteNodes(session, filter) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
// find out all the existed nodes
|
|
19
|
+
let res = yield session.conn.uql(`find().nodes({${filter}}) return nodes{*}`);
|
|
20
|
+
if (res.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
21
|
+
yield session.throwError(res.status.message);
|
|
22
|
+
}
|
|
23
|
+
// find out all the existed edges related to the nodes
|
|
24
|
+
let resEdges = yield session.conn.uql(`n({${filter}}).e(as edges).n() with distinct edges return edges{*}`);
|
|
25
|
+
if (resEdges.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
26
|
+
yield session.throwError(resEdges.status.message);
|
|
27
|
+
}
|
|
28
|
+
session.recorder.logs.push({
|
|
29
|
+
Op: UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Delete_Nodes,
|
|
30
|
+
nodes: res.data.alias("nodes").asNodes(),
|
|
31
|
+
edges: resEdges.data.alias("edges").asEdges()
|
|
32
|
+
});
|
|
33
|
+
return yield session.conn.uql(`delete().nodes({${filter}})`);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.deleteNodes = deleteNodes;
|
|
37
|
+
function deleteEdges(session, filter) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
// find out all the existed nodes
|
|
40
|
+
let res = yield session.conn.uql(`find().edges({${filter}}) return edges{*}`);
|
|
41
|
+
if (res.status.code != types_1.ULTIPA.Code.SUCCESS) {
|
|
42
|
+
yield session.throwError(res.status.message);
|
|
43
|
+
}
|
|
44
|
+
session.recorder.logs.push({
|
|
45
|
+
Op: UltipaTransaction_Recorder_1.UltipaTransactionRecorderOp.Delete_Edges,
|
|
46
|
+
edges: res.data.alias("edges").asEdges()
|
|
47
|
+
});
|
|
48
|
+
return yield session.conn.uql(`delete().edges({${filter}})`);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.deleteEdges = deleteEdges;
|
|
52
|
+
//# sourceMappingURL=Transaction.Delet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OAA0B,EAAE,MAAc;;QACxE,iCAAiC;QAEjC,IAAI,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,MAAM,oBAAoB,CAAC,CAAC;QAC9E,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,cAAM,CAAC,IAAI,CAAC,OAAO,EAAE;YACxC,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SAChD;QAED,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,EAAE,EAAE,wDAA2B,CAAC,YAAY;YAC5C,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE;SAC3C,CAAC,CAAC;QAEH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,MAAM,IAAI,CAAC,CAAA;IAChE,CAAC;CAAA;AAdD,kCAcC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { UltipaTransaction } from "../UltipaTransaction";
|
|
2
|
+
import { ResponseType, ULTIPA } from "../../types";
|
|
3
|
+
export declare function InsertNodes(session: UltipaTransaction, nodes: ULTIPA.Node[]): Promise<ULTIPA.Response<ResponseType.InsertNodes>>;
|
|
4
|
+
export declare function InsertEdges(session: UltipaTransaction, edges: ULTIPA.Edge[]): Promise<ULTIPA.Response<ResponseType.InsertEdges>>;
|