@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,990 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FormatResponse = exports.FormatType = exports.mergeQueryResponse = void 0;
|
|
7
|
+
const ultipa_pb_1 = require("../proto/ultipa_pb");
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const index_1 = require("../utils/index");
|
|
11
|
+
/**
|
|
12
|
+
let a = "123"
|
|
13
|
+
let aBuffer = new DataView(new ArrayBuffer(4))
|
|
14
|
+
aBuffer.setInt32(0, parseInt(a))
|
|
15
|
+
let aValue = new DataView(aBuffer.buffer).getInt32(aBuffer.byteOffset)
|
|
16
|
+
|
|
17
|
+
console.log(
|
|
18
|
+
a, aBuffer, aValue
|
|
19
|
+
)
|
|
20
|
+
console.log(new ArrayBuffer(4))
|
|
21
|
+
|
|
22
|
+
let b = "!@3鼎折覆餗"
|
|
23
|
+
let bBuffer = Buffer.from(b, 'utf8');
|
|
24
|
+
let bString = new TextDecoder("utf-8").decode(bBuffer);
|
|
25
|
+
console.log({
|
|
26
|
+
b, bBuffer, bString
|
|
27
|
+
})
|
|
28
|
+
*/
|
|
29
|
+
let ULITPA_PRIVATE_KEYS = {
|
|
30
|
+
id: "_id",
|
|
31
|
+
from: "_from",
|
|
32
|
+
to: "_to",
|
|
33
|
+
uuid: "_uuid",
|
|
34
|
+
from_uuid: "_from_uuid",
|
|
35
|
+
to_uuid: "_to_uuid",
|
|
36
|
+
};
|
|
37
|
+
const _mapValues = (values, types, timeZone) => {
|
|
38
|
+
let result = new Map;
|
|
39
|
+
values.forEach((v, index) => {
|
|
40
|
+
let pty = types[index];
|
|
41
|
+
result.set(pty.getPropertyName(), index_1.DESERIALIZE.deserialize(v, pty.getPropertyType(), pty.getSubTypesList(), timeZone));
|
|
42
|
+
// [pty.getPropertyName()] = DESERIALIZE.deserialize(v, pty.getPropertyType(), pty.getSubTypesList(), timeZone);
|
|
43
|
+
});
|
|
44
|
+
// console.log(result)
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
const DataMerge = {
|
|
48
|
+
arrayDiff: (arr1, arr2) => {
|
|
49
|
+
let diff = [];
|
|
50
|
+
arr2.forEach((s) => {
|
|
51
|
+
if (!arr1.includes(s)) {
|
|
52
|
+
diff.push(s);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return diff;
|
|
56
|
+
},
|
|
57
|
+
merge: (o1, o2, ignoreKeys) => {
|
|
58
|
+
if (!o2) {
|
|
59
|
+
return o1;
|
|
60
|
+
}
|
|
61
|
+
function customizer(objValue, srcValue, key) {
|
|
62
|
+
if (ignoreKeys && ignoreKeys.includes(key)) {
|
|
63
|
+
return srcValue;
|
|
64
|
+
}
|
|
65
|
+
if (lodash_1.default.isArray(srcValue)) {
|
|
66
|
+
return srcValue.concat(objValue);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return lodash_1.default.mergeWith(o2, o1, customizer);
|
|
70
|
+
},
|
|
71
|
+
concat: (arr1, arr2, byKey, ignoreKeys) => {
|
|
72
|
+
if (!(arr2 === null || arr2 === void 0 ? void 0 : arr2.length)) {
|
|
73
|
+
return arr1;
|
|
74
|
+
}
|
|
75
|
+
if (byKey) {
|
|
76
|
+
let newArray = [...arr1];
|
|
77
|
+
let diff = DataMerge.arrayDiff(arr1.map((o) => o[byKey]), arr2.map((o) => o[byKey]));
|
|
78
|
+
diff.forEach((k) => newArray.push({
|
|
79
|
+
[byKey]: k,
|
|
80
|
+
}));
|
|
81
|
+
let results = [];
|
|
82
|
+
newArray.forEach((o) => {
|
|
83
|
+
let newObj = o;
|
|
84
|
+
let finds = arr2.filter((o2) => {
|
|
85
|
+
return o2[byKey] == o[byKey];
|
|
86
|
+
});
|
|
87
|
+
finds.forEach((f) => {
|
|
88
|
+
newObj = DataMerge.merge(newObj, f, ignoreKeys);
|
|
89
|
+
});
|
|
90
|
+
results.push(newObj);
|
|
91
|
+
});
|
|
92
|
+
return results;
|
|
93
|
+
}
|
|
94
|
+
return [...arr1, ...arr2];
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
const mergeQueryResponse = (res1, res2) => {
|
|
98
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
99
|
+
res1.status = res2.status;
|
|
100
|
+
if (!(res2 === null || res2 === void 0 ? void 0 : res2.data)) {
|
|
101
|
+
return res1;
|
|
102
|
+
}
|
|
103
|
+
// res1.data.results = DataMerge.concat(res1.data?.results, res2.data?.results);
|
|
104
|
+
res1.data.paths = DataMerge.concat((_a = res1.data) === null || _a === void 0 ? void 0 : _a.paths, (_b = res2.data) === null || _b === void 0 ? void 0 : _b.paths, "alias");
|
|
105
|
+
res1.data.nodes = DataMerge.concat((_c = res1.data) === null || _c === void 0 ? void 0 : _c.nodes, (_d = res2.data) === null || _d === void 0 ? void 0 : _d.nodes, "alias");
|
|
106
|
+
res1.data.edges = DataMerge.concat((_e = res1.data) === null || _e === void 0 ? void 0 : _e.edges, (_f = res2.data) === null || _f === void 0 ? void 0 : _f.edges, "alias");
|
|
107
|
+
res1.data.attrs = DataMerge.concat((_g = res1.data) === null || _g === void 0 ? void 0 : _g.attrs, (_h = res2.data) === null || _h === void 0 ? void 0 : _h.attrs, "alias");
|
|
108
|
+
res1.data.tables = DataMerge.concat((_j = res1.data) === null || _j === void 0 ? void 0 : _j.tables, (_k = res2.data) === null || _k === void 0 ? void 0 : _k.tables, "name", ["headers"]);
|
|
109
|
+
if (res2 === null || res2 === void 0 ? void 0 : res2.statistics) {
|
|
110
|
+
res1.statistics = res2.statistics;
|
|
111
|
+
res1.data.statistics = res2.statistics;
|
|
112
|
+
res1.data.total_time_cost = res2.statistics.totalCost;
|
|
113
|
+
res1.data.engine_time_cost = res2.statistics.engineCost;
|
|
114
|
+
}
|
|
115
|
+
return res1;
|
|
116
|
+
};
|
|
117
|
+
exports.mergeQueryResponse = mergeQueryResponse;
|
|
118
|
+
exports.FormatType = {
|
|
119
|
+
queryResponse: (res, timeZone) => {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
// console.log(JSON.stringify(res.toObject()))
|
|
122
|
+
let response = new types_1.ULTIPA.QueryBaseResponse();
|
|
123
|
+
response.status = exports.FormatType.status(res.getStatus());
|
|
124
|
+
let statistics = (_b = (_a = exports.FormatType.table(res.getStatistics(), timeZone)) === null || _a === void 0 ? void 0 : _a.toKV()) === null || _b === void 0 ? void 0 : _b[0];
|
|
125
|
+
if (statistics) {
|
|
126
|
+
statistics = {
|
|
127
|
+
totalCost: +statistics.total_time_cost || 0,
|
|
128
|
+
engineCost: +statistics.engine_time_cost || 0,
|
|
129
|
+
nodeAffected: +statistics.node_affected || 0,
|
|
130
|
+
edgeAffected: +statistics.edge_affected || 0,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
let attrs = exports.FormatType.attrAliases(res.getAttrsList(), timeZone);
|
|
134
|
+
let attrs_map = {};
|
|
135
|
+
let attrs_format = [];
|
|
136
|
+
let addAttrMap = (alias, type, values, p) => {
|
|
137
|
+
if (!attrs_map[alias]) {
|
|
138
|
+
if (p.has_attr_data) {
|
|
139
|
+
type = types_1.ULTIPA.ResultType.RESULT_TYPE_ATTR;
|
|
140
|
+
}
|
|
141
|
+
let v = {
|
|
142
|
+
alias,
|
|
143
|
+
type: type,
|
|
144
|
+
type_desc: types_1.ULTIPA.ResultType[type],
|
|
145
|
+
values: [],
|
|
146
|
+
};
|
|
147
|
+
attrs_map[alias] = v;
|
|
148
|
+
attrs_format.push(v);
|
|
149
|
+
}
|
|
150
|
+
if (type === types_1.ULTIPA.ResultType.RESULT_TYPE_ATTR && p.only_attr_list) {
|
|
151
|
+
attrs_map[alias].values = values;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
attrs_map[alias].values.push(values);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
attrs === null || attrs === void 0 ? void 0 : attrs.forEach(attrAlias => {
|
|
158
|
+
var _a;
|
|
159
|
+
let alias = attrAlias.alias;
|
|
160
|
+
let { has_attr_data, has_ultipa_data, } = attrAlias.attr;
|
|
161
|
+
let only_attr_list = has_attr_data && !has_ultipa_data;
|
|
162
|
+
let p = {
|
|
163
|
+
only_attr_list,
|
|
164
|
+
has_attr_data,
|
|
165
|
+
has_ultipa_data,
|
|
166
|
+
};
|
|
167
|
+
if (attrAlias.attr.type == types_1.ULTIPA.PropertyType.PROPERTY_LIST) {
|
|
168
|
+
if (only_attr_list) {
|
|
169
|
+
addAttrMap(alias, types_1.ULTIPA.ResultType.RESULT_TYPE_ATTR, attrAlias.attr.values, p);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
(_a = attrAlias.attr.values) === null || _a === void 0 ? void 0 : _a.forEach(o => {
|
|
173
|
+
if (!o || !o.type) {
|
|
174
|
+
addAttrMap(alias, types_1.ULTIPA.ResultType.RESULT_TYPE_ATTR, o, p);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
switch (o.type) {
|
|
178
|
+
case types_1.ULTIPA.ResultType.RESULT_TYPE_EDGE:
|
|
179
|
+
{
|
|
180
|
+
addAttrMap(alias, o.type, o.edges, p);
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
case types_1.ULTIPA.ResultType.RESULT_TYPE_NODE:
|
|
184
|
+
{
|
|
185
|
+
addAttrMap(alias, o.type, o.nodes, p);
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
case types_1.ULTIPA.ResultType.RESULT_TYPE_PATH:
|
|
189
|
+
{
|
|
190
|
+
addAttrMap(alias, o.type, o.paths, p);
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
addAttrMap(alias, types_1.ULTIPA.ResultType.RESULT_TYPE_ATTR, attrAlias.attr.values, p);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
response.data = {
|
|
201
|
+
total_time_cost: res.getTotalTimeCost(),
|
|
202
|
+
engine_time_cost: res.getEngineTimeCost(),
|
|
203
|
+
results: exports.FormatType.resultAliases(res.getAliasList()),
|
|
204
|
+
paths: exports.FormatType.pathAliases(res.getPathsList()),
|
|
205
|
+
nodes: exports.FormatType.nodeAliases(res.getNodesList(), timeZone),
|
|
206
|
+
edges: exports.FormatType.edgeAliases(res.getEdgesList(), timeZone),
|
|
207
|
+
graph: exports.FormatType.graphAliases(res.getPathsList(), timeZone),
|
|
208
|
+
attrs: attrs_format,
|
|
209
|
+
tables: exports.FormatType.tables(res.getTablesList(), timeZone),
|
|
210
|
+
statistics,
|
|
211
|
+
explainPlans: exports.FormatType.explainPlan(res.getExplainPlan()),
|
|
212
|
+
};
|
|
213
|
+
response.statistics = response.data.statistics;
|
|
214
|
+
response.explainPlans = response.data.explainPlans;
|
|
215
|
+
return response;
|
|
216
|
+
},
|
|
217
|
+
status: (statusData, p) => {
|
|
218
|
+
let status = {
|
|
219
|
+
code: types_1.ULTIPA.Code.SUCCESS,
|
|
220
|
+
message: "",
|
|
221
|
+
};
|
|
222
|
+
if (statusData) {
|
|
223
|
+
status.code = statusData.getErrorCode();
|
|
224
|
+
status.message = statusData.getMsg();
|
|
225
|
+
}
|
|
226
|
+
status.code_desc = types_1.ULTIPA.Code[status.code];
|
|
227
|
+
return status;
|
|
228
|
+
},
|
|
229
|
+
keyValue: (keyValuesData) => {
|
|
230
|
+
if (!keyValuesData || keyValuesData.length == 0) {
|
|
231
|
+
return {};
|
|
232
|
+
}
|
|
233
|
+
let keyValue = {};
|
|
234
|
+
keyValuesData.forEach((kv) => {
|
|
235
|
+
keyValue[kv.getKey()] = kv.getValue();
|
|
236
|
+
});
|
|
237
|
+
return keyValue;
|
|
238
|
+
},
|
|
239
|
+
paths: (paths) => {
|
|
240
|
+
let newPaths = [];
|
|
241
|
+
paths.forEach(o => {
|
|
242
|
+
let p = new types_1.ULTIPA.Path();
|
|
243
|
+
p.nodeUUIDs = exports.FormatType.uuids(o.getNodeTable());
|
|
244
|
+
p.edgeUUIDs = exports.FormatType.uuids(o.getEdgeTable());
|
|
245
|
+
// p.length = p.edges.length
|
|
246
|
+
newPaths.push(p);
|
|
247
|
+
});
|
|
248
|
+
return newPaths;
|
|
249
|
+
},
|
|
250
|
+
pathAliases: (pathsData) => {
|
|
251
|
+
if (!pathsData || pathsData.length == 0) {
|
|
252
|
+
return [];
|
|
253
|
+
}
|
|
254
|
+
let pathAliases = [];
|
|
255
|
+
pathsData.forEach((pathData) => {
|
|
256
|
+
let pathAlias = {
|
|
257
|
+
alias: pathData.getAlias(),
|
|
258
|
+
paths: exports.FormatType.paths(pathData.getPathsList())
|
|
259
|
+
};
|
|
260
|
+
pathAliases.push(pathAlias);
|
|
261
|
+
});
|
|
262
|
+
return pathAliases;
|
|
263
|
+
},
|
|
264
|
+
graph: (paths, timeZone) => {
|
|
265
|
+
var _a, _b;
|
|
266
|
+
let graph = new types_1.ULTIPA.Graph();
|
|
267
|
+
graph.paths = exports.FormatType.paths(paths);
|
|
268
|
+
(_a = graph.nodes) !== null && _a !== void 0 ? _a : (graph.nodes = new Map());
|
|
269
|
+
(_b = graph.edges) !== null && _b !== void 0 ? _b : (graph.edges = new Map());
|
|
270
|
+
paths.forEach(o => {
|
|
271
|
+
let nodes = exports.FormatType.nodeTable(o.getNodeTable(), timeZone);
|
|
272
|
+
nodes.forEach(n => {
|
|
273
|
+
graph.nodes.set(n._uuid, n);
|
|
274
|
+
});
|
|
275
|
+
let edges = exports.FormatType.edgeTable(o.getEdgeTable(), timeZone);
|
|
276
|
+
edges.forEach(e => {
|
|
277
|
+
graph.edges.set(e._uuid, e);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
return graph;
|
|
281
|
+
},
|
|
282
|
+
graphAliases: (pathsData, timezone) => {
|
|
283
|
+
if (!pathsData || pathsData.length == 0) {
|
|
284
|
+
return [];
|
|
285
|
+
}
|
|
286
|
+
let graphAliases = [];
|
|
287
|
+
pathsData.forEach((pathdata => {
|
|
288
|
+
let graphAlias = {
|
|
289
|
+
alias: pathdata.getAlias(),
|
|
290
|
+
graph: exports.FormatType.graph(pathdata.getPathsList(), timezone)
|
|
291
|
+
};
|
|
292
|
+
graphAliases.push(graphAlias);
|
|
293
|
+
}));
|
|
294
|
+
return graphAliases;
|
|
295
|
+
},
|
|
296
|
+
explainPlan: (data) => {
|
|
297
|
+
if (!data) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
let explainPlan = {
|
|
301
|
+
plan_nodes: []
|
|
302
|
+
};
|
|
303
|
+
let planNodes = [];
|
|
304
|
+
data.getPlanNodesList().forEach(plan => {
|
|
305
|
+
let one = {
|
|
306
|
+
alias: plan.getAlias(),
|
|
307
|
+
children_num: plan.getChildrenNum(),
|
|
308
|
+
infos: plan.getInfos(),
|
|
309
|
+
query_text: plan.getQueryText(),
|
|
310
|
+
};
|
|
311
|
+
planNodes.push(one);
|
|
312
|
+
});
|
|
313
|
+
explainPlan.plan_nodes = planNodes;
|
|
314
|
+
return explainPlan;
|
|
315
|
+
},
|
|
316
|
+
table: (tableData, timeZone) => {
|
|
317
|
+
if (!tableData) {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
let tableRows = [];
|
|
321
|
+
let tableHeaders = [];
|
|
322
|
+
tableData.getHeadersList().forEach(h => {
|
|
323
|
+
tableHeaders.push({
|
|
324
|
+
name: h.getPropertyName(),
|
|
325
|
+
type: h.getPropertyType(),
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
tableData.getTableRowsList().forEach((tableRowData) => {
|
|
329
|
+
let values = [];
|
|
330
|
+
tableRowData.getValuesList_asU8().forEach((v, i) => {
|
|
331
|
+
let header = tableHeaders[i];
|
|
332
|
+
values.push(index_1.DESERIALIZE.deserialize(v, header.type, header.subTypes, timeZone));
|
|
333
|
+
});
|
|
334
|
+
tableRows.push(values);
|
|
335
|
+
});
|
|
336
|
+
let t = new types_1.ULTIPA.Table();
|
|
337
|
+
t.name = tableData.getTableName();
|
|
338
|
+
t.alias = t.name;
|
|
339
|
+
t.headers = tableHeaders.map(o => o.name);
|
|
340
|
+
t.rows = tableRows;
|
|
341
|
+
return t;
|
|
342
|
+
},
|
|
343
|
+
tables: (tablesData, timeZone) => {
|
|
344
|
+
if (!tablesData || tablesData.length == 0) {
|
|
345
|
+
return [];
|
|
346
|
+
}
|
|
347
|
+
let tables = [];
|
|
348
|
+
tablesData.forEach((tableData) => {
|
|
349
|
+
tables.push(exports.FormatType.table(tableData, timeZone));
|
|
350
|
+
});
|
|
351
|
+
return tables;
|
|
352
|
+
},
|
|
353
|
+
resultAliases: (resultAliases) => {
|
|
354
|
+
if (!resultAliases || resultAliases.length == 0) {
|
|
355
|
+
return [];
|
|
356
|
+
}
|
|
357
|
+
let rs = [];
|
|
358
|
+
resultAliases.forEach(one => {
|
|
359
|
+
rs.push({
|
|
360
|
+
alias: one.getAlias(),
|
|
361
|
+
result_type: one.getResultType()
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
return rs;
|
|
365
|
+
},
|
|
366
|
+
// arrayAliases: (arrayAliases: ArrayAlias[], timeZone: ULTIPA.TimeZone) => {
|
|
367
|
+
// if (!arrayAliases || arrayAliases.length == 0) {
|
|
368
|
+
// return [];
|
|
369
|
+
// }
|
|
370
|
+
// let rs :ULTIPA.ArrayAliases = []
|
|
371
|
+
// arrayAliases.forEach(one => {
|
|
372
|
+
// let eles = []
|
|
373
|
+
// let type = one.getPropertyType()
|
|
374
|
+
// one.getElementsList().map(o => {
|
|
375
|
+
// let rs = []
|
|
376
|
+
// o.getValuesList_asU8().map(o1 => {
|
|
377
|
+
// rs.push(DESERIALIZE.base(o1, type, timeZone))
|
|
378
|
+
// })
|
|
379
|
+
// eles.push(rs)
|
|
380
|
+
// })
|
|
381
|
+
// rs.push({
|
|
382
|
+
// alias: one.getAlias(),
|
|
383
|
+
// elements: eles,
|
|
384
|
+
// })
|
|
385
|
+
// })
|
|
386
|
+
// return rs
|
|
387
|
+
// },
|
|
388
|
+
nodeAliases: (nodesListData, timeZone) => {
|
|
389
|
+
if (!nodesListData || nodesListData.length == 0) {
|
|
390
|
+
return [];
|
|
391
|
+
}
|
|
392
|
+
let nodeAliases = [];
|
|
393
|
+
nodesListData.forEach((nodeData) => {
|
|
394
|
+
nodeAliases.push({
|
|
395
|
+
alias: nodeData.getAlias(),
|
|
396
|
+
nodes: exports.FormatType.nodeTable(nodeData.getNodeTable(), timeZone),
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
return nodeAliases;
|
|
400
|
+
},
|
|
401
|
+
edgeAliases: (edgesListData, timeZone) => {
|
|
402
|
+
if (!edgesListData || edgesListData.length == 0) {
|
|
403
|
+
return [];
|
|
404
|
+
}
|
|
405
|
+
let nodeAliases = [];
|
|
406
|
+
edgesListData.forEach((nodeData) => {
|
|
407
|
+
nodeAliases.push({
|
|
408
|
+
alias: nodeData.getAlias(),
|
|
409
|
+
edges: exports.FormatType.edgeTable(nodeData.getEdgeTable(), timeZone),
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
return nodeAliases;
|
|
413
|
+
},
|
|
414
|
+
toEdgeTable: (propertyTypeObject, schemaName, headers, rows, timeZone) => {
|
|
415
|
+
let edgeTable = new ultipa_pb_1.EntityTable();
|
|
416
|
+
let handles = [ULITPA_PRIVATE_KEYS.uuid, ULITPA_PRIVATE_KEYS.from, ULITPA_PRIVATE_KEYS.to, ULITPA_PRIVATE_KEYS.from_uuid, ULITPA_PRIVATE_KEYS.to_uuid];
|
|
417
|
+
let schemaHeaders = [];
|
|
418
|
+
let schemaHeader = new ultipa_pb_1.Schema();
|
|
419
|
+
schemaHeader.setSchemaName(schemaName);
|
|
420
|
+
let headerList = [];
|
|
421
|
+
headers.forEach((h) => {
|
|
422
|
+
if (handles.includes(h)) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
let header = new ultipa_pb_1.Property();
|
|
426
|
+
header.setPropertyName(h);
|
|
427
|
+
let typeCfg = index_1.PropertyUtils.GetPropertyType(propertyTypeObject[h]);
|
|
428
|
+
header.setPropertyType(typeCfg.type);
|
|
429
|
+
if (typeCfg.subTypes) {
|
|
430
|
+
header.setSubTypesList(typeCfg.subTypes);
|
|
431
|
+
}
|
|
432
|
+
headerList.push(header);
|
|
433
|
+
});
|
|
434
|
+
schemaHeader.setPropertiesList(headerList);
|
|
435
|
+
schemaHeaders.push(schemaHeader);
|
|
436
|
+
edgeTable.setSchemasList(schemaHeaders);
|
|
437
|
+
let edgeRowsList = [];
|
|
438
|
+
rows.forEach(rowsObj => {
|
|
439
|
+
let edgeRow = new ultipa_pb_1.EntityRow();
|
|
440
|
+
if (!rowsObj) {
|
|
441
|
+
edgeRow.setIsNull(true);
|
|
442
|
+
edgeRowsList.push(edgeRow);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
edgeRow.setSchemaName(schemaName);
|
|
446
|
+
let rowValues = rowsObj;
|
|
447
|
+
let values = [];
|
|
448
|
+
headers.forEach((h, index) => {
|
|
449
|
+
if (h === ULITPA_PRIVATE_KEYS.from) {
|
|
450
|
+
edgeRow.setFromId(rowValues[index]);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (h === ULITPA_PRIVATE_KEYS.to) {
|
|
454
|
+
edgeRow.setToId(rowValues[index]);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (h === ULITPA_PRIVATE_KEYS.uuid) {
|
|
458
|
+
let uuid = rowValues[index];
|
|
459
|
+
if (uuid) {
|
|
460
|
+
uuid += "";
|
|
461
|
+
}
|
|
462
|
+
edgeRow.setUuid(uuid);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (h === ULITPA_PRIVATE_KEYS.from_uuid) {
|
|
466
|
+
edgeRow.setFromUuid(rowValues[index]);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (h === ULITPA_PRIVATE_KEYS.to_uuid) {
|
|
470
|
+
edgeRow.setToUuid(rowValues[index]);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
let typeCfg = index_1.PropertyUtils.GetPropertyType(propertyTypeObject[h]);
|
|
474
|
+
values.push(index_1.SERIALIZE.serialize(rowValues[index], typeCfg.type, typeCfg.subTypes, timeZone));
|
|
475
|
+
});
|
|
476
|
+
edgeRow.setValuesList(values);
|
|
477
|
+
edgeRowsList.push(edgeRow);
|
|
478
|
+
});
|
|
479
|
+
edgeTable.setEntityRowsList(edgeRowsList);
|
|
480
|
+
return edgeTable;
|
|
481
|
+
},
|
|
482
|
+
toPropertyTypeObject: (properties) => {
|
|
483
|
+
let object = {};
|
|
484
|
+
properties.forEach(p => {
|
|
485
|
+
object[p.name] = p.type;
|
|
486
|
+
});
|
|
487
|
+
return object;
|
|
488
|
+
},
|
|
489
|
+
toNodeTable: (propertyTypeObject, schemaName, headers, rows, timeZone) => {
|
|
490
|
+
let nodeTable = new ultipa_pb_1.EntityTable();
|
|
491
|
+
let handles = [ULITPA_PRIVATE_KEYS.id, ULITPA_PRIVATE_KEYS.uuid];
|
|
492
|
+
let schemaHeaders = [];
|
|
493
|
+
let schemaHeader = new ultipa_pb_1.Schema();
|
|
494
|
+
schemaHeader.setSchemaName(schemaName);
|
|
495
|
+
let headerList = [];
|
|
496
|
+
headers.forEach((h) => {
|
|
497
|
+
if (handles.includes(h)) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
let header = new ultipa_pb_1.Property();
|
|
501
|
+
header.setPropertyName(h);
|
|
502
|
+
let typeCfg = index_1.PropertyUtils.GetPropertyType(propertyTypeObject[h]);
|
|
503
|
+
header.setPropertyType(typeCfg.type);
|
|
504
|
+
if (typeCfg.subTypes) {
|
|
505
|
+
header.setSubTypesList(typeCfg.subTypes);
|
|
506
|
+
}
|
|
507
|
+
headerList.push(header);
|
|
508
|
+
});
|
|
509
|
+
schemaHeader.setPropertiesList(headerList);
|
|
510
|
+
schemaHeaders.push(schemaHeader);
|
|
511
|
+
nodeTable.setSchemasList(schemaHeaders);
|
|
512
|
+
let nodeRowsList = [];
|
|
513
|
+
rows.forEach(rowObj => {
|
|
514
|
+
let nodeRow = new ultipa_pb_1.EntityRow();
|
|
515
|
+
if (!rowObj) {
|
|
516
|
+
nodeRow.setIsNull(true);
|
|
517
|
+
nodeRowsList.push(nodeRow);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
nodeRow.setSchemaName(schemaName);
|
|
521
|
+
let values = [];
|
|
522
|
+
let rowValues = rowObj;
|
|
523
|
+
headers.forEach((h, index) => {
|
|
524
|
+
if (h === ULITPA_PRIVATE_KEYS.id) {
|
|
525
|
+
nodeRow.setId(rowValues[index]);
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
if (h === ULITPA_PRIVATE_KEYS.uuid) {
|
|
529
|
+
let uuid = rowValues[index];
|
|
530
|
+
if (uuid) {
|
|
531
|
+
uuid += "";
|
|
532
|
+
}
|
|
533
|
+
nodeRow.setUuid(uuid);
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
let typeCfg = index_1.PropertyUtils.GetPropertyType(propertyTypeObject[h]);
|
|
537
|
+
values.push(index_1.SERIALIZE.serialize(rowValues[index], typeCfg.type, typeCfg.subTypes, timeZone));
|
|
538
|
+
});
|
|
539
|
+
nodeRow.setValuesList(values);
|
|
540
|
+
nodeRowsList.push(nodeRow);
|
|
541
|
+
});
|
|
542
|
+
nodeTable.setEntityRowsList(nodeRowsList);
|
|
543
|
+
return nodeTable;
|
|
544
|
+
},
|
|
545
|
+
toEdgeTableWithSchema: (schema, rows, timeZone) => {
|
|
546
|
+
let table = new ultipa_pb_1.EntityTable();
|
|
547
|
+
let handles = [ULITPA_PRIVATE_KEYS.uuid, ULITPA_PRIVATE_KEYS.from, ULITPA_PRIVATE_KEYS.to, ULITPA_PRIVATE_KEYS.from_uuid, ULITPA_PRIVATE_KEYS.to_uuid];
|
|
548
|
+
let schemaHeaders = [];
|
|
549
|
+
let schemaHeader = new ultipa_pb_1.Schema();
|
|
550
|
+
schemaHeader.setSchemaName(schema.name);
|
|
551
|
+
let headerList = [];
|
|
552
|
+
schema.properties.forEach((o) => {
|
|
553
|
+
let { name, type, subTypes } = o;
|
|
554
|
+
if (handles.includes(name)) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
let header = new ultipa_pb_1.Property();
|
|
558
|
+
header.setPropertyName(name);
|
|
559
|
+
header.setPropertyType(type);
|
|
560
|
+
if (subTypes) {
|
|
561
|
+
header.setSubTypesList(subTypes);
|
|
562
|
+
}
|
|
563
|
+
headerList.push(header);
|
|
564
|
+
});
|
|
565
|
+
schemaHeader.setPropertiesList(headerList);
|
|
566
|
+
schemaHeaders.push(schemaHeader);
|
|
567
|
+
table.setSchemasList(schemaHeaders);
|
|
568
|
+
let rowList = [];
|
|
569
|
+
rows.forEach(rowObj => {
|
|
570
|
+
let row = new ultipa_pb_1.EntityRow();
|
|
571
|
+
if (!rowObj) {
|
|
572
|
+
row.setIsNull(true);
|
|
573
|
+
rowList.push(row);
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
row.setSchemaName(schema.name);
|
|
577
|
+
if (!!rowObj._uuid) {
|
|
578
|
+
row.setUuid(rowObj._uuid);
|
|
579
|
+
}
|
|
580
|
+
if (!!rowObj._from) {
|
|
581
|
+
row.setFromId(rowObj._from);
|
|
582
|
+
}
|
|
583
|
+
if (!!rowObj._to) {
|
|
584
|
+
row.setToId(rowObj._to);
|
|
585
|
+
}
|
|
586
|
+
let values = [];
|
|
587
|
+
let rowValues = rowObj.values || new Map();
|
|
588
|
+
headerList.forEach((o, index) => {
|
|
589
|
+
let name = o.getPropertyName();
|
|
590
|
+
let type = o.getPropertyType();
|
|
591
|
+
let subTypes = o.getSubTypesList();
|
|
592
|
+
values.push(index_1.SERIALIZE.serialize(rowValues.get(name), type, subTypes, timeZone));
|
|
593
|
+
});
|
|
594
|
+
row.setValuesList(values);
|
|
595
|
+
rowList.push(row);
|
|
596
|
+
});
|
|
597
|
+
table.setEntityRowsList(rowList);
|
|
598
|
+
return table;
|
|
599
|
+
},
|
|
600
|
+
toNodeTableWithSchema: (schema, rows, timeZone) => {
|
|
601
|
+
let nodeTable = new ultipa_pb_1.EntityTable();
|
|
602
|
+
let handles = [ULITPA_PRIVATE_KEYS.id, ULITPA_PRIVATE_KEYS.uuid];
|
|
603
|
+
let schemaHeaders = [];
|
|
604
|
+
let schemaHeader = new ultipa_pb_1.Schema();
|
|
605
|
+
schemaHeader.setSchemaName(schema.name);
|
|
606
|
+
let headerList = [];
|
|
607
|
+
schema.properties.forEach((o) => {
|
|
608
|
+
let { name, type, subTypes } = o;
|
|
609
|
+
if (handles.includes(name)) {
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
let header = new ultipa_pb_1.Property();
|
|
613
|
+
header.setPropertyName(name);
|
|
614
|
+
header.setPropertyType(type);
|
|
615
|
+
if (subTypes) {
|
|
616
|
+
header.setSubTypesList(subTypes);
|
|
617
|
+
}
|
|
618
|
+
headerList.push(header);
|
|
619
|
+
});
|
|
620
|
+
schemaHeader.setPropertiesList(headerList);
|
|
621
|
+
schemaHeaders.push(schemaHeader);
|
|
622
|
+
nodeTable.setSchemasList(schemaHeaders);
|
|
623
|
+
let nodeRowsList = [];
|
|
624
|
+
rows.forEach(rowObj => {
|
|
625
|
+
let nodeRow = new ultipa_pb_1.EntityRow();
|
|
626
|
+
if (!rowObj) {
|
|
627
|
+
nodeRow.setIsNull(true);
|
|
628
|
+
nodeRowsList.push(nodeRow);
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
if (!!rowObj._id) {
|
|
632
|
+
nodeRow.setId(rowObj._id);
|
|
633
|
+
}
|
|
634
|
+
if (!!rowObj._uuid) {
|
|
635
|
+
nodeRow.setUuid(rowObj._uuid);
|
|
636
|
+
}
|
|
637
|
+
nodeRow.setSchemaName(schema.name);
|
|
638
|
+
let values = [];
|
|
639
|
+
let rowValues = rowObj.values || new Map();
|
|
640
|
+
headerList.forEach((o, index) => {
|
|
641
|
+
let name = o.getPropertyName();
|
|
642
|
+
let type = o.getPropertyType();
|
|
643
|
+
let subTypes = o.getSubTypesList();
|
|
644
|
+
values.push(index_1.SERIALIZE.serialize(rowValues.get(name), type, subTypes, timeZone));
|
|
645
|
+
});
|
|
646
|
+
nodeRow.setValuesList(values);
|
|
647
|
+
nodeRowsList.push(nodeRow);
|
|
648
|
+
});
|
|
649
|
+
nodeTable.setEntityRowsList(nodeRowsList);
|
|
650
|
+
return nodeTable;
|
|
651
|
+
},
|
|
652
|
+
uuids: (tableData) => {
|
|
653
|
+
if (!tableData) {
|
|
654
|
+
return [];
|
|
655
|
+
}
|
|
656
|
+
let rowsData = tableData.getEntityRowsList();
|
|
657
|
+
let uuids = [];
|
|
658
|
+
rowsData.forEach((data) => {
|
|
659
|
+
uuids.push(data.getUuid());
|
|
660
|
+
});
|
|
661
|
+
return uuids;
|
|
662
|
+
},
|
|
663
|
+
nodeTable: (nodeTableData, timeZone) => {
|
|
664
|
+
let tables = [];
|
|
665
|
+
if (!nodeTableData) {
|
|
666
|
+
return tables;
|
|
667
|
+
}
|
|
668
|
+
let headerMap = {};
|
|
669
|
+
nodeTableData.getSchemasList().forEach((sh) => {
|
|
670
|
+
let schema = sh.getSchemaName();
|
|
671
|
+
headerMap[schema] = sh.getPropertiesList();
|
|
672
|
+
});
|
|
673
|
+
let nodeRowsData = nodeTableData.getEntityRowsList();
|
|
674
|
+
nodeRowsData.forEach((nodeRowData) => {
|
|
675
|
+
if (nodeRowData.getIsNull()) {
|
|
676
|
+
tables.push(null);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
let schema = nodeRowData.getSchemaName();
|
|
680
|
+
let ptys = headerMap[schema];
|
|
681
|
+
let values = nodeRowData.getValuesList_asU8();
|
|
682
|
+
let _v = _mapValues(values, ptys, timeZone);
|
|
683
|
+
let nodeRow = new types_1.ULTIPA.Node();
|
|
684
|
+
nodeRow._id = nodeRowData.getId(),
|
|
685
|
+
nodeRow._uuid = nodeRowData.getUuid(),
|
|
686
|
+
nodeRow.schema = schema,
|
|
687
|
+
nodeRow.values = _v,
|
|
688
|
+
tables.push(nodeRow);
|
|
689
|
+
});
|
|
690
|
+
return tables;
|
|
691
|
+
},
|
|
692
|
+
edgeTable: (edgeTableData, timeZone) => {
|
|
693
|
+
let tables = [];
|
|
694
|
+
if (!edgeTableData) {
|
|
695
|
+
return tables;
|
|
696
|
+
}
|
|
697
|
+
let headerMap = {};
|
|
698
|
+
edgeTableData.getSchemasList().forEach((sh) => {
|
|
699
|
+
let schema = sh.getSchemaName();
|
|
700
|
+
headerMap[schema] = sh.getPropertiesList();
|
|
701
|
+
});
|
|
702
|
+
edgeTableData.getSchemasList().forEach((sh) => {
|
|
703
|
+
let schema = sh.getSchemaName();
|
|
704
|
+
headerMap[schema] = sh.getPropertiesList();
|
|
705
|
+
});
|
|
706
|
+
let edgeRowsData = edgeTableData.getEntityRowsList();
|
|
707
|
+
edgeRowsData.forEach((rowData) => {
|
|
708
|
+
if (rowData.getIsNull()) {
|
|
709
|
+
tables.push(null);
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
let schema = rowData.getSchemaName();
|
|
713
|
+
let ptys = headerMap[schema];
|
|
714
|
+
let values = rowData.getValuesList_asU8();
|
|
715
|
+
let _v = _mapValues(values, ptys, timeZone);
|
|
716
|
+
let edgeRow = new types_1.ULTIPA.Edge();
|
|
717
|
+
// id: rowData.getId(),
|
|
718
|
+
edgeRow._from = rowData.getFromId();
|
|
719
|
+
edgeRow._to = rowData.getToId();
|
|
720
|
+
edgeRow._uuid = rowData.getUuid();
|
|
721
|
+
edgeRow.schema = schema;
|
|
722
|
+
edgeRow.values = _v;
|
|
723
|
+
tables.push(edgeRow);
|
|
724
|
+
});
|
|
725
|
+
return tables;
|
|
726
|
+
},
|
|
727
|
+
attr(attr, timeZone) {
|
|
728
|
+
let type = attr.getValueType();
|
|
729
|
+
let result = {
|
|
730
|
+
type,
|
|
731
|
+
type_desc: index_1.PropertyUtils.propertyGet(type),
|
|
732
|
+
values: null,
|
|
733
|
+
has_attr_data: false,
|
|
734
|
+
has_ultipa_data: false,
|
|
735
|
+
};
|
|
736
|
+
result.values = [];
|
|
737
|
+
attr.getValuesList_asU8().forEach((v) => {
|
|
738
|
+
if (type == types_1.ULTIPA.PropertyType.PROPERTY_NULL) {
|
|
739
|
+
result.has_attr_data = true;
|
|
740
|
+
return result.values.push(null);
|
|
741
|
+
}
|
|
742
|
+
if (type == types_1.ULTIPA.PropertyType.PROPERTY_LIST) {
|
|
743
|
+
let attrListData = ultipa_pb_1.AttrListData.deserializeBinary(v);
|
|
744
|
+
if (attrListData.getIsNull()) {
|
|
745
|
+
return result.values.push(null);
|
|
746
|
+
}
|
|
747
|
+
let result_type = attrListData.getType();
|
|
748
|
+
switch (result_type) {
|
|
749
|
+
case ultipa_pb_1.ResultType.RESULT_TYPE_NODE:
|
|
750
|
+
{
|
|
751
|
+
let v = {
|
|
752
|
+
type: result_type,
|
|
753
|
+
type_desc: types_1.ULTIPA.ResultType[result_type],
|
|
754
|
+
nodes: exports.FormatType.nodeTable(attrListData.getNodes(), timeZone)
|
|
755
|
+
};
|
|
756
|
+
result.has_ultipa_data = true;
|
|
757
|
+
result.values.push(v);
|
|
758
|
+
}
|
|
759
|
+
break;
|
|
760
|
+
case ultipa_pb_1.ResultType.RESULT_TYPE_EDGE:
|
|
761
|
+
{
|
|
762
|
+
let v = {
|
|
763
|
+
type: result_type,
|
|
764
|
+
type_desc: types_1.ULTIPA.ResultType[result_type],
|
|
765
|
+
edges: exports.FormatType.edgeTable(attrListData.getEdges(), timeZone)
|
|
766
|
+
};
|
|
767
|
+
result.has_ultipa_data = true;
|
|
768
|
+
result.values.push(v);
|
|
769
|
+
}
|
|
770
|
+
break;
|
|
771
|
+
case ultipa_pb_1.ResultType.RESULT_TYPE_PATH:
|
|
772
|
+
{
|
|
773
|
+
let v = {
|
|
774
|
+
type: result_type,
|
|
775
|
+
type_desc: types_1.ULTIPA.ResultType[result_type],
|
|
776
|
+
paths: exports.FormatType.paths(attrListData.getPathsList())
|
|
777
|
+
};
|
|
778
|
+
result.has_ultipa_data = true;
|
|
779
|
+
result.values.push(v);
|
|
780
|
+
}
|
|
781
|
+
break;
|
|
782
|
+
case ultipa_pb_1.ResultType.RESULT_TYPE_ATTR: {
|
|
783
|
+
{
|
|
784
|
+
let attrs = [];
|
|
785
|
+
attrListData.getAttrsList().forEach(o => {
|
|
786
|
+
let attr = exports.FormatType.attr(o, timeZone);
|
|
787
|
+
if (!attr.values) {
|
|
788
|
+
attrs.push(attr.values);
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
attrs.push(...attr.values);
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
// let v: ULTIPA.AttrListData = {
|
|
795
|
+
// type: result_type,
|
|
796
|
+
// type_desc: ULTIPA.ResultType[result_type],
|
|
797
|
+
// attrs: attrs,
|
|
798
|
+
// }
|
|
799
|
+
if (attrs.length != 0) {
|
|
800
|
+
result.has_attr_data = true;
|
|
801
|
+
}
|
|
802
|
+
result.values.push(attrs);
|
|
803
|
+
}
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
let v1 = index_1.DESERIALIZE.base(v, type, timeZone);
|
|
810
|
+
result.has_attr_data = true;
|
|
811
|
+
result.values.push(v1);
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
return result;
|
|
815
|
+
},
|
|
816
|
+
attrAliases: (attrAliasesData, timeZone) => {
|
|
817
|
+
if (!attrAliasesData || attrAliasesData.length == 0) {
|
|
818
|
+
return [];
|
|
819
|
+
}
|
|
820
|
+
let attrAliases = [];
|
|
821
|
+
attrAliasesData.forEach((attrAliasData) => {
|
|
822
|
+
let v = exports.FormatType.attr(attrAliasData.getAttr(), timeZone);
|
|
823
|
+
attrAliases.push({
|
|
824
|
+
alias: attrAliasData.getAlias(),
|
|
825
|
+
attr: v,
|
|
826
|
+
});
|
|
827
|
+
});
|
|
828
|
+
return attrAliases;
|
|
829
|
+
},
|
|
830
|
+
graphPrivileges(graphPrivileges) {
|
|
831
|
+
let new_graphPrivileges = [];
|
|
832
|
+
if (graphPrivileges) {
|
|
833
|
+
graphPrivileges.forEach((graphPrivilege) => {
|
|
834
|
+
let new_graphPrivilege = Object.assign({}, graphPrivilege);
|
|
835
|
+
Object.keys(new_graphPrivilege).forEach((key) => {
|
|
836
|
+
new_graphPrivilege["name"] = key;
|
|
837
|
+
new_graphPrivilege["values"] = new_graphPrivilege[key];
|
|
838
|
+
delete new_graphPrivilege[key];
|
|
839
|
+
});
|
|
840
|
+
new_graphPrivileges.push(new_graphPrivilege);
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
return new_graphPrivileges;
|
|
844
|
+
},
|
|
845
|
+
};
|
|
846
|
+
exports.FormatResponse = {
|
|
847
|
+
tableToArray: (table) => {
|
|
848
|
+
let res = [];
|
|
849
|
+
if (table) {
|
|
850
|
+
try {
|
|
851
|
+
table.rows.forEach((row) => {
|
|
852
|
+
let item = {};
|
|
853
|
+
row.forEach((value, index) => {
|
|
854
|
+
let header = table.headers[index];
|
|
855
|
+
item[header] = value;
|
|
856
|
+
});
|
|
857
|
+
res.push(item);
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
catch (error) {
|
|
861
|
+
console.log(error);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return res;
|
|
865
|
+
},
|
|
866
|
+
formatObjects: (objs, keysFormat) => {
|
|
867
|
+
if (!keysFormat) {
|
|
868
|
+
return objs;
|
|
869
|
+
}
|
|
870
|
+
let newObjs = [];
|
|
871
|
+
if ((objs === null || objs === void 0 ? void 0 : objs.length) > 0) {
|
|
872
|
+
objs.forEach((obj) => {
|
|
873
|
+
newObjs.push(exports.FormatResponse.formatObject(obj, keysFormat));
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
return newObjs;
|
|
877
|
+
},
|
|
878
|
+
formatObject: (_obj, keysFormat) => {
|
|
879
|
+
if (!keysFormat) {
|
|
880
|
+
return _obj;
|
|
881
|
+
}
|
|
882
|
+
let obj = Object.assign({}, _obj);
|
|
883
|
+
if (keysFormat === null || keysFormat === void 0 ? void 0 : keysFormat.jsonKeys) {
|
|
884
|
+
keysFormat.jsonKeys.forEach((k) => {
|
|
885
|
+
try {
|
|
886
|
+
if (obj[k]) {
|
|
887
|
+
obj[k] = JSON.parse(obj[k]);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
catch (error) {
|
|
891
|
+
console.log(error, k, obj);
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
if (keysFormat === null || keysFormat === void 0 ? void 0 : keysFormat.boolKeys) {
|
|
896
|
+
keysFormat.boolKeys.forEach((k) => {
|
|
897
|
+
try {
|
|
898
|
+
if (obj[k]) {
|
|
899
|
+
obj[k] = obj[k] == "true";
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
catch (error) {
|
|
903
|
+
console.log(error, k, obj);
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
if (keysFormat === null || keysFormat === void 0 ? void 0 : keysFormat.keyReplace) {
|
|
908
|
+
Object.keys(keysFormat.keyReplace).forEach((k) => {
|
|
909
|
+
if (obj[k]) {
|
|
910
|
+
obj[keysFormat.keyReplace[k]] = obj[k];
|
|
911
|
+
delete obj[k];
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
if (keysFormat === null || keysFormat === void 0 ? void 0 : keysFormat.dataFormat) {
|
|
916
|
+
obj = keysFormat.dataFormat(obj);
|
|
917
|
+
}
|
|
918
|
+
return obj;
|
|
919
|
+
},
|
|
920
|
+
// formatData: (objs :object[] | object, keysFormat?: ResponseKeyFormat) => {
|
|
921
|
+
// if (objs && keysFormat) {
|
|
922
|
+
// let array = Array.isArray(objs) ? objs : [objs]
|
|
923
|
+
// array.forEach(obj => {
|
|
924
|
+
// if (keysFormat.jsonKeys) {
|
|
925
|
+
// keysFormat.jsonKeys.forEach(k => {
|
|
926
|
+
// try {
|
|
927
|
+
// if (obj[k]) {
|
|
928
|
+
// obj[k] = JSON.parse(obj[k])
|
|
929
|
+
// }
|
|
930
|
+
// } catch (error) {
|
|
931
|
+
// console.log(error, k, obj)
|
|
932
|
+
// }
|
|
933
|
+
// })
|
|
934
|
+
// }
|
|
935
|
+
// if (keysFormat.boolKeys) {
|
|
936
|
+
// keysFormat.boolKeys.forEach(k => {
|
|
937
|
+
// try {
|
|
938
|
+
// if (obj[k]) {
|
|
939
|
+
// obj[k] = obj[k] == "true"
|
|
940
|
+
// }
|
|
941
|
+
// } catch (error) {
|
|
942
|
+
// console.log(error, k, obj)
|
|
943
|
+
// }
|
|
944
|
+
// })
|
|
945
|
+
// }
|
|
946
|
+
// if (keysFormat.keyReplace) {
|
|
947
|
+
// Object.keys(keysFormat.keyReplace).forEach(k => {
|
|
948
|
+
// if (obj[k]) {
|
|
949
|
+
// obj[keysFormat.keyReplace[k]] = obj[k]
|
|
950
|
+
// delete obj[k]
|
|
951
|
+
// }
|
|
952
|
+
// })
|
|
953
|
+
// }
|
|
954
|
+
// if (keysFormat.dataFormat) {
|
|
955
|
+
// keysFormat.dataFormat(obj)
|
|
956
|
+
// }
|
|
957
|
+
// })
|
|
958
|
+
// }
|
|
959
|
+
// },
|
|
960
|
+
successStatus: () => {
|
|
961
|
+
return {
|
|
962
|
+
code: types_1.ULTIPA.Code.SUCCESS,
|
|
963
|
+
code_desc: types_1.ULTIPA.Code[types_1.ULTIPA.Code.SUCCESS],
|
|
964
|
+
message: "ok",
|
|
965
|
+
};
|
|
966
|
+
},
|
|
967
|
+
statisticsSum: (one, sumOne) => {
|
|
968
|
+
return {
|
|
969
|
+
totalCost: ((one === null || one === void 0 ? void 0 : one.totalCost) || 0) + ((sumOne === null || sumOne === void 0 ? void 0 : sumOne.totalCost) || 0),
|
|
970
|
+
engineCost: ((one === null || one === void 0 ? void 0 : one.engineCost) || 0) + ((sumOne === null || sumOne === void 0 ? void 0 : sumOne.engineCost) || 0),
|
|
971
|
+
nodeAffected: ((one === null || one === void 0 ? void 0 : one.nodeAffected) || 0) + ((sumOne === null || sumOne === void 0 ? void 0 : sumOne.nodeAffected) || 0),
|
|
972
|
+
edgeAffected: ((one === null || one === void 0 ? void 0 : one.edgeAffected) || 0) + ((sumOne === null || sumOne === void 0 ? void 0 : sumOne.edgeAffected) || 0),
|
|
973
|
+
};
|
|
974
|
+
},
|
|
975
|
+
unknownError: (err, res) => {
|
|
976
|
+
res.status = {
|
|
977
|
+
code: types_1.ULTIPA.Code.UNKNOWN_ERROR,
|
|
978
|
+
code_desc: types_1.ULTIPA.Code[types_1.ULTIPA.Code.UNKNOWN_ERROR],
|
|
979
|
+
message: err.message || err.detail,
|
|
980
|
+
};
|
|
981
|
+
return res;
|
|
982
|
+
},
|
|
983
|
+
catchUltipaUqlError: (error) => {
|
|
984
|
+
let response = new types_1.ULTIPA.QueryBaseResponse();
|
|
985
|
+
response = exports.FormatResponse.unknownError(error, response);
|
|
986
|
+
let res = types_1.ULTIPA.formatBaseResponse(response);
|
|
987
|
+
return res;
|
|
988
|
+
},
|
|
989
|
+
};
|
|
990
|
+
//# sourceMappingURL=format.js.map
|