@ultipa-graph/ultipa-driver 5.1.5-s5.2 → 6.0.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.
Files changed (260) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -0
  3. package/dist/client.d.ts +194 -0
  4. package/dist/client.js +390 -0
  5. package/dist/config.d.ts +65 -0
  6. package/dist/config.js +135 -0
  7. package/dist/connection.d.ts +30 -0
  8. package/dist/connection.js +190 -0
  9. package/dist/errors.d.ts +99 -0
  10. package/dist/errors.js +237 -0
  11. package/dist/index.d.ts +14 -5
  12. package/dist/index.js +88 -39
  13. package/dist/printers.d.ts +33 -0
  14. package/dist/printers.js +312 -0
  15. package/dist/proto/gqldb.proto +632 -0
  16. package/dist/response.d.ts +256 -0
  17. package/dist/response.js +723 -0
  18. package/dist/services/admin-service.d.ts +40 -0
  19. package/dist/services/admin-service.js +115 -0
  20. package/dist/services/bulk-import-service.d.ts +35 -0
  21. package/dist/services/bulk-import-service.js +108 -0
  22. package/dist/services/converters.d.ts +57 -0
  23. package/dist/services/converters.js +254 -0
  24. package/dist/services/data-service.d.ts +44 -0
  25. package/dist/services/data-service.js +206 -0
  26. package/dist/services/graph-service.d.ts +32 -0
  27. package/dist/services/graph-service.js +127 -0
  28. package/dist/services/health-service.d.ts +50 -0
  29. package/dist/services/health-service.js +78 -0
  30. package/dist/services/index.d.ts +13 -0
  31. package/dist/services/index.js +30 -0
  32. package/dist/services/query-service.d.ts +39 -0
  33. package/dist/services/query-service.js +112 -0
  34. package/dist/services/service-context.d.ts +39 -0
  35. package/dist/services/service-context.js +73 -0
  36. package/dist/services/session-service.d.ts +24 -0
  37. package/dist/services/session-service.js +66 -0
  38. package/dist/services/transaction-service.d.ts +33 -0
  39. package/dist/services/transaction-service.js +100 -0
  40. package/dist/services.d.ts +28 -0
  41. package/dist/services.js +122 -0
  42. package/dist/session.d.ts +45 -0
  43. package/dist/session.js +75 -0
  44. package/dist/transaction.d.ts +42 -0
  45. package/dist/transaction.js +89 -0
  46. package/dist/types/bulk_import.d.ts +53 -0
  47. package/dist/types/bulk_import.js +6 -0
  48. package/dist/types/data_types.d.ts +116 -0
  49. package/dist/types/data_types.js +122 -0
  50. package/dist/types/enums.d.ts +59 -0
  51. package/dist/types/enums.js +67 -0
  52. package/dist/types/graph_models.d.ts +54 -0
  53. package/dist/types/graph_models.js +6 -0
  54. package/dist/types/index.d.ts +11 -5
  55. package/dist/types/index.js +36 -37
  56. package/dist/types/metadata.d.ts +60 -0
  57. package/dist/types/metadata.js +6 -0
  58. package/dist/types/schema.d.ts +31 -0
  59. package/dist/types/schema.js +6 -0
  60. package/dist/types/typed_value.d.ts +25 -0
  61. package/dist/types/typed_value.js +1176 -0
  62. package/dist/types/wrappers.d.ts +23 -0
  63. package/dist/types/wrappers.js +39 -0
  64. package/dist/types.d.ts +7 -0
  65. package/dist/types.js +24 -0
  66. package/package.json +49 -62
  67. package/dist/connection/connection.final.d.ts +0 -14
  68. package/dist/connection/connection.final.js +0 -94
  69. package/dist/connection/connection.final.js.map +0 -1
  70. package/dist/connection/connection.pool.d.ts +0 -21
  71. package/dist/connection/connection.pool.js +0 -103
  72. package/dist/connection/connection.pool.js.map +0 -1
  73. package/dist/connection/extra/algos/algo.extra.d.ts +0 -34
  74. package/dist/connection/extra/algos/algo.extra.js +0 -69
  75. package/dist/connection/extra/algos/algo.extra.js.map +0 -1
  76. package/dist/connection/extra/algos/algo.utils.d.ts +0 -3
  77. package/dist/connection/extra/algos/algo.utils.js +0 -54
  78. package/dist/connection/extra/algos/algo.utils.js.map +0 -1
  79. package/dist/connection/extra/algos/community.d.ts +0 -27
  80. package/dist/connection/extra/algos/community.js +0 -76
  81. package/dist/connection/extra/algos/community.js.map +0 -1
  82. package/dist/connection/extra/algos/degrees.d.ts +0 -10
  83. package/dist/connection/extra/algos/degrees.js +0 -24
  84. package/dist/connection/extra/algos/degrees.js.map +0 -1
  85. package/dist/connection/extra/algos/embedding.d.ts +0 -13
  86. package/dist/connection/extra/algos/embedding.js +0 -33
  87. package/dist/connection/extra/algos/embedding.js.map +0 -1
  88. package/dist/connection/extra/algos/index.d.ts +0 -5
  89. package/dist/connection/extra/algos/index.js +0 -14
  90. package/dist/connection/extra/algos/index.js.map +0 -1
  91. package/dist/connection/extra/base.extra.d.ts +0 -18
  92. package/dist/connection/extra/base.extra.js +0 -111
  93. package/dist/connection/extra/base.extra.js.map +0 -1
  94. package/dist/connection/extra/batch.insert.extra.d.ts +0 -58
  95. package/dist/connection/extra/batch.insert.extra.js +0 -354
  96. package/dist/connection/extra/batch.insert.extra.js.map +0 -1
  97. package/dist/connection/extra/connection.base.d.ts +0 -112
  98. package/dist/connection/extra/connection.base.js +0 -530
  99. package/dist/connection/extra/connection.base.js.map +0 -1
  100. package/dist/connection/extra/connection.d.ts +0 -17
  101. package/dist/connection/extra/connection.js +0 -44
  102. package/dist/connection/extra/connection.js.map +0 -1
  103. package/dist/connection/extra/graph.extra.d.ts +0 -54
  104. package/dist/connection/extra/graph.extra.js +0 -151
  105. package/dist/connection/extra/graph.extra.js.map +0 -1
  106. package/dist/connection/extra/hdc.extra.d.ts +0 -89
  107. package/dist/connection/extra/hdc.extra.js +0 -322
  108. package/dist/connection/extra/hdc.extra.js.map +0 -1
  109. package/dist/connection/extra/index.extra.d.ts +0 -102
  110. package/dist/connection/extra/index.extra.js +0 -210
  111. package/dist/connection/extra/index.extra.js.map +0 -1
  112. package/dist/connection/extra/job.extra.d.ts +0 -32
  113. package/dist/connection/extra/job.extra.js +0 -122
  114. package/dist/connection/extra/job.extra.js.map +0 -1
  115. package/dist/connection/extra/meta.extra.d.ts +0 -36
  116. package/dist/connection/extra/meta.extra.js +0 -123
  117. package/dist/connection/extra/meta.extra.js.map +0 -1
  118. package/dist/connection/extra/policy.extra.d.ts +0 -32
  119. package/dist/connection/extra/policy.extra.js +0 -114
  120. package/dist/connection/extra/policy.extra.js.map +0 -1
  121. package/dist/connection/extra/privilege.extra.d.ts +0 -8
  122. package/dist/connection/extra/privilege.extra.js +0 -20
  123. package/dist/connection/extra/privilege.extra.js.map +0 -1
  124. package/dist/connection/extra/property.extra.d.ts +0 -66
  125. package/dist/connection/extra/property.extra.js +0 -190
  126. package/dist/connection/extra/property.extra.js.map +0 -1
  127. package/dist/connection/extra/schema.extra.d.ts +0 -108
  128. package/dist/connection/extra/schema.extra.js +0 -253
  129. package/dist/connection/extra/schema.extra.js.map +0 -1
  130. package/dist/connection/extra/search.extra.d.ts +0 -12
  131. package/dist/connection/extra/search.extra.js +0 -117
  132. package/dist/connection/extra/search.extra.js.map +0 -1
  133. package/dist/connection/extra/task.extra.d.ts +0 -24
  134. package/dist/connection/extra/task.extra.js +0 -107
  135. package/dist/connection/extra/task.extra.js.map +0 -1
  136. package/dist/connection/extra/user.extra.d.ts +0 -28
  137. package/dist/connection/extra/user.extra.js +0 -91
  138. package/dist/connection/extra/user.extra.js.map +0 -1
  139. package/dist/connection/extra/user.privilege.extra.d.ts +0 -64
  140. package/dist/connection/extra/user.privilege.extra.js +0 -273
  141. package/dist/connection/extra/user.privilege.extra.js.map +0 -1
  142. package/dist/connection/index.d.ts +0 -5
  143. package/dist/connection/index.js +0 -13
  144. package/dist/connection/index.js.map +0 -1
  145. package/dist/connection/network.manager.d.ts +0 -28
  146. package/dist/connection/network.manager.js +0 -179
  147. package/dist/connection/network.manager.js.map +0 -1
  148. package/dist/index.js.map +0 -1
  149. package/dist/printers/alias.d.ts +0 -2
  150. package/dist/printers/alias.js +0 -39
  151. package/dist/printers/alias.js.map +0 -1
  152. package/dist/printers/any.d.ts +0 -2
  153. package/dist/printers/any.js +0 -63
  154. package/dist/printers/any.js.map +0 -1
  155. package/dist/printers/array.aio.d.ts +0 -3
  156. package/dist/printers/array.aio.js +0 -259
  157. package/dist/printers/array.aio.js.map +0 -1
  158. package/dist/printers/common.d.ts +0 -0
  159. package/dist/printers/common.js +0 -1
  160. package/dist/printers/common.js.map +0 -1
  161. package/dist/printers/edge.d.ts +0 -5
  162. package/dist/printers/edge.js +0 -78
  163. package/dist/printers/edge.js.map +0 -1
  164. package/dist/printers/explain.plan.d.ts +0 -2
  165. package/dist/printers/explain.plan.js +0 -46
  166. package/dist/printers/explain.plan.js.map +0 -1
  167. package/dist/printers/index.d.ts +0 -24
  168. package/dist/printers/index.js +0 -43
  169. package/dist/printers/index.js.map +0 -1
  170. package/dist/printers/node.d.ts +0 -5
  171. package/dist/printers/node.js +0 -77
  172. package/dist/printers/node.js.map +0 -1
  173. package/dist/printers/path.d.ts +0 -3
  174. package/dist/printers/path.js +0 -62
  175. package/dist/printers/path.js.map +0 -1
  176. package/dist/printers/status.d.ts +0 -3
  177. package/dist/printers/status.js +0 -68
  178. package/dist/printers/status.js.map +0 -1
  179. package/dist/printers/table.d.ts +0 -2
  180. package/dist/printers/table.js +0 -56
  181. package/dist/printers/table.js.map +0 -1
  182. package/dist/proto/tmp.js +0 -366
  183. package/dist/proto/ultipa_grpc_pb.d.ts +0 -258
  184. package/dist/proto/ultipa_grpc_pb.js +0 -366
  185. package/dist/proto/ultipa_grpc_pb.js.map +0 -1
  186. package/dist/proto/ultipa_pb.d.ts +0 -1
  187. package/dist/proto/ultipa_pb.js +0 -12119
  188. package/dist/proto/ultipa_pb.js.map +0 -1
  189. package/dist/types/index.js.map +0 -1
  190. package/dist/types/types.algos.params.d.ts +0 -545
  191. package/dist/types/types.algos.params.js +0 -16
  192. package/dist/types/types.algos.params.js.map +0 -1
  193. package/dist/types/types.d.ts +0 -1214
  194. package/dist/types/types.extra.d.ts +0 -146
  195. package/dist/types/types.extra.js +0 -27
  196. package/dist/types/types.extra.js.map +0 -1
  197. package/dist/types/types.js +0 -1606
  198. package/dist/types/types.js.map +0 -1
  199. package/dist/types/util.d.ts +0 -15
  200. package/dist/types/util.js +0 -136
  201. package/dist/types/util.js.map +0 -1
  202. package/dist/utils/common.d.ts +0 -3
  203. package/dist/utils/common.js +0 -22
  204. package/dist/utils/common.js.map +0 -1
  205. package/dist/utils/config.d.ts +0 -3
  206. package/dist/utils/config.js +0 -7
  207. package/dist/utils/config.js.map +0 -1
  208. package/dist/utils/format.d.ts +0 -45
  209. package/dist/utils/format.js +0 -879
  210. package/dist/utils/format.js.map +0 -1
  211. package/dist/utils/index.d.ts +0 -10
  212. package/dist/utils/index.js +0 -30
  213. package/dist/utils/index.js.map +0 -1
  214. package/dist/utils/params.validate.d.ts +0 -4
  215. package/dist/utils/params.validate.js +0 -14
  216. package/dist/utils/params.validate.js.map +0 -1
  217. package/dist/utils/property.d.ts +0 -24
  218. package/dist/utils/property.js +0 -203
  219. package/dist/utils/property.js.map +0 -1
  220. package/dist/utils/raft.retry.d.ts +0 -0
  221. package/dist/utils/raft.retry.js +0 -1
  222. package/dist/utils/raft.retry.js.map +0 -1
  223. package/dist/utils/serialize/commont.d.ts +0 -12
  224. package/dist/utils/serialize/commont.js +0 -46
  225. package/dist/utils/serialize/commont.js.map +0 -1
  226. package/dist/utils/serialize/deserialize.d.ts +0 -10
  227. package/dist/utils/serialize/deserialize.js +0 -288
  228. package/dist/utils/serialize/deserialize.js.map +0 -1
  229. package/dist/utils/serialize/null.d.ts +0 -32
  230. package/dist/utils/serialize/null.js +0 -178
  231. package/dist/utils/serialize/null.js.map +0 -1
  232. package/dist/utils/serialize/serialize.d.ts +0 -10
  233. package/dist/utils/serialize/serialize.js +0 -146
  234. package/dist/utils/serialize/serialize.js.map +0 -1
  235. package/dist/utils/stream.helper.d.ts +0 -10
  236. package/dist/utils/stream.helper.js +0 -71
  237. package/dist/utils/stream.helper.js.map +0 -1
  238. package/dist/utils/time.record.d.ts +0 -15
  239. package/dist/utils/time.record.js +0 -52
  240. package/dist/utils/time.record.js.map +0 -1
  241. package/dist/utils/timezone.d.ts +0 -7
  242. package/dist/utils/timezone.js +0 -21
  243. package/dist/utils/timezone.js.map +0 -1
  244. package/dist/utils/ultipa.datetime.d.ts +0 -14
  245. package/dist/utils/ultipa.datetime.js +0 -160
  246. package/dist/utils/ultipa.datetime.js.map +0 -1
  247. package/dist/utils/uql-maker.d.ts +0 -165
  248. package/dist/utils/uql-maker.js +0 -402
  249. package/dist/utils/uql-maker.js.map +0 -1
  250. package/dist/utils/uql.parse.d.ts +0 -27
  251. package/dist/utils/uql.parse.js +0 -205
  252. package/dist/utils/uql.parse.js.map +0 -1
  253. package/readme.md +0 -65
  254. package/src/proto/build.sh +0 -41
  255. package/src/proto/build_windows.sh +0 -40
  256. package/src/proto/ultipa.proto +0 -531
  257. package/src/proto/ultipa_grpc_pb.d.ts +0 -92
  258. package/src/proto/ultipa_grpc_pb.js +0 -414
  259. package/src/proto/ultipa_pb.d.ts +0 -1983
  260. package/src/proto/ultipa_pb.js +0 -14852
@@ -1,879 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.FormatResponse = exports.FormatType = exports.mergeQueryResponse = void 0;
30
- const ultipa_pb_1 = require("../proto/ultipa_pb");
31
- const ULTIPA = __importStar(require("../types/types"));
32
- const lodash_1 = __importDefault(require("lodash"));
33
- const index_1 = require("../utils/index");
34
- const types_1 = require("../types/types");
35
- let ULITPA_PRIVATE_KEYS = {
36
- id: "_id",
37
- from: "_from",
38
- to: "_to",
39
- uuid: "_uuid",
40
- from_uuid: "_from_uuid",
41
- to_uuid: "_to_uuid",
42
- };
43
- const _mapValues = (values, types, timezone) => {
44
- let result = {};
45
- values.forEach((v, index) => {
46
- let pty = types[index];
47
- result[pty.getPropertyName()] = index_1.DESERIALIZE.deserialize(v, pty.getPropertyType(), pty.getSubTypesList(), timezone);
48
- });
49
- return result;
50
- };
51
- const DataMerge = {
52
- arrayDiff: (arr1, arr2) => {
53
- let diff = [];
54
- arr2.forEach((s) => {
55
- if (!arr1.includes(s)) {
56
- diff.push(s);
57
- }
58
- });
59
- return diff;
60
- },
61
- merge: (o1, o2, ignoreKeys) => {
62
- if (!o2) {
63
- return o1;
64
- }
65
- function customizer(objValue, srcValue, key) {
66
- if (ignoreKeys && ignoreKeys.includes(key)) {
67
- return srcValue;
68
- }
69
- if (lodash_1.default.isArray(srcValue)) {
70
- return srcValue.concat(objValue);
71
- }
72
- }
73
- return lodash_1.default.mergeWith(o2, o1, customizer);
74
- },
75
- concat: (arr1, arr2, byKey, ignoreKeys) => {
76
- if (!arr2?.length) {
77
- return arr1;
78
- }
79
- if (byKey) {
80
- let newArray = [...arr1];
81
- let diff = DataMerge.arrayDiff(arr1.map((o) => o[byKey]), arr2.map((o) => o[byKey]));
82
- diff.forEach((k) => newArray.push({
83
- [byKey]: k,
84
- }));
85
- let results = [];
86
- newArray.forEach((o) => {
87
- let newObj = o;
88
- let finds = arr2.filter((o2) => {
89
- return o2[byKey] == o[byKey];
90
- });
91
- finds.forEach((f) => {
92
- newObj = DataMerge.merge(newObj, f, ignoreKeys);
93
- });
94
- results.push(newObj);
95
- });
96
- return results;
97
- }
98
- return [...arr1, ...arr2];
99
- },
100
- };
101
- const mergeQueryResponse = (res1, res2) => {
102
- if (!res1.explainPlan) {
103
- res1.explainPlan = new ULTIPA.ExplainPlan();
104
- }
105
- res1.status = res2.status;
106
- if (!res2?.items) {
107
- return res1;
108
- }
109
- res1.aliases = res1.aliases || [];
110
- const aliasMap = new Map();
111
- [...res1.aliases, ...(res2.aliases || [])].forEach(alias => {
112
- if (alias.type === 0) {
113
- return;
114
- }
115
- const existingAlias = aliasMap.get(alias.name);
116
- if (existingAlias) {
117
- if (existingAlias.type === 0 && alias.type !== 0) {
118
- aliasMap.set(alias.name, alias);
119
- }
120
- }
121
- else {
122
- aliasMap.set(alias.name, alias);
123
- }
124
- });
125
- res1.aliases = Array.from(aliasMap.values());
126
- res1.explainPlan.planNodes = res1.explainPlan?.planNodes || [];
127
- res1.explainPlan.planNodes = [...new Set([...res1.explainPlan.planNodes, ...(res2.explainPlan?.planNodes || [])].map(item => JSON.stringify(item)))].map(item => JSON.parse(item));
128
- res1.items = res1.items || {};
129
- for (const [key, value] of Object.entries(res2.items)) {
130
- if (key in res1.items) {
131
- const existingItem = res1.items[key];
132
- switch (existingItem.type) {
133
- case ULTIPA.ResultType.RESULT_TYPE_TABLE:
134
- existingItem.entities.rows = [...existingItem.entities.rows, ...value.entities.rows];
135
- break;
136
- case ULTIPA.ResultType.RESULT_TYPE_PATH:
137
- if (!existingItem.entities) {
138
- existingItem.entities = [];
139
- }
140
- existingItem.entities.paths = [...existingItem.entities.paths, ...value.entities.paths];
141
- const nodeKeys = value.entities.nodes.keys();
142
- for (const uuid of nodeKeys) {
143
- existingItem.entities.nodes.set(uuid, value.entities.nodes.get(uuid));
144
- }
145
- const edgeKeys = value.entities.edges.keys();
146
- for (const uuid of edgeKeys) {
147
- existingItem.entities.edges.set(uuid, value.entities.edges.get(uuid));
148
- }
149
- break;
150
- case ULTIPA.ResultType.RESULT_TYPE_NODE:
151
- case ULTIPA.ResultType.RESULT_TYPE_EDGE:
152
- if (!existingItem.entities) {
153
- existingItem.entities = [];
154
- }
155
- if (!value.entities) {
156
- value.entities = [];
157
- }
158
- existingItem.entities = [...existingItem.entities, ...value.entities];
159
- break;
160
- case ULTIPA.ResultType.RESULT_TYPE_ATTR:
161
- if (!existingItem.entities) {
162
- existingItem.entities = new ULTIPA.Attr();
163
- }
164
- if (!value.entities) {
165
- value.entities = new ULTIPA.Attr();
166
- }
167
- existingItem.entities.values = [
168
- ...(existingItem.entities.values || []),
169
- ...(value.entities.values || [])
170
- ];
171
- break;
172
- default:
173
- if (!existingItem.entities) {
174
- existingItem.entities = [];
175
- }
176
- if (!value.entities) {
177
- value.entities = [];
178
- }
179
- existingItem.entities = [...existingItem.entities, ...value.entities];
180
- }
181
- res1.items[key] = existingItem;
182
- }
183
- else {
184
- res1.items[key] = value;
185
- }
186
- }
187
- if (res2?.statistics) {
188
- res1.statistics = res1.statistics || { totalCost: 0, engineCost: 0 };
189
- res1.statistics.totalCost += res2.statistics.totalCost;
190
- res1.statistics.engineCost += res2.statistics.engineCost;
191
- }
192
- return res1;
193
- };
194
- exports.mergeQueryResponse = mergeQueryResponse;
195
- exports.FormatType = {
196
- queryResponse: (res, timezone) => {
197
- let response = new ULTIPA.Response();
198
- if (res.hasStatus()) {
199
- response.status = exports.FormatType.status(res.getStatus());
200
- }
201
- else {
202
- response.status = exports.FormatResponse.successStatus();
203
- }
204
- let statistics = exports.FormatType.table(res.getStatistics(), timezone)?.toKV()?.[0];
205
- if (statistics) {
206
- statistics = {
207
- totalCost: +statistics.total_time_cost || 0,
208
- engineCost: +statistics.engine_time_cost || 0,
209
- nodeAffected: +statistics.node_affected || 0,
210
- edgeAffected: +statistics.edge_affected || 0,
211
- };
212
- }
213
- response.statistics = statistics;
214
- response.aliases = res.getAliasList().map(i => ({ name: i.getAlias(), type: i.getResultType() }));
215
- response.explainPlan = exports.FormatType.explainPlan(res.getExplainPlan());
216
- let items = {};
217
- res.getNodesList()?.forEach((nodeTableData) => {
218
- let dataItem = new types_1.DataItem(nodeTableData.getAlias(), ULTIPA.ResultType.RESULT_TYPE_NODE, exports.FormatType.nodeTable(nodeTableData.getNodeTable(), timezone));
219
- items[dataItem.alias] = dataItem;
220
- });
221
- res.getEdgesList()?.forEach((edgeTableData) => {
222
- let dataItem = new types_1.DataItem(edgeTableData.getAlias(), ULTIPA.ResultType.RESULT_TYPE_EDGE, exports.FormatType.edgeTable(edgeTableData.getEdgeTable(), timezone));
223
- items[dataItem.alias] = dataItem;
224
- });
225
- res.getPathsList()?.forEach((pathTableData) => {
226
- let dataItem = new types_1.DataItem(pathTableData.getAlias(), ULTIPA.ResultType.RESULT_TYPE_PATH, exports.FormatType.graph(pathTableData.getPathsList(), timezone));
227
- items[dataItem.alias] = dataItem;
228
- });
229
- res.getAttrsList()?.forEach((attrTableData) => {
230
- let attr = exports.FormatType.attr(attrTableData.getAttr(), timezone);
231
- attr.name = attrTableData.getAlias();
232
- attr.resultType = ULTIPA.ResultType.RESULT_TYPE_ATTR;
233
- let dataItem = new types_1.DataItem(attrTableData.getAlias(), ULTIPA.ResultType.RESULT_TYPE_ATTR, attr);
234
- const existingAliasIndex = response.aliases.findIndex(a => a.name === attrTableData.getAlias());
235
- if (existingAliasIndex !== -1) {
236
- response.aliases[existingAliasIndex].type = ULTIPA.ResultType.RESULT_TYPE_ATTR;
237
- }
238
- else {
239
- response.aliases.push({ name: attrTableData.getAlias(), type: ULTIPA.ResultType.RESULT_TYPE_ATTR });
240
- }
241
- items[dataItem.alias] = dataItem;
242
- });
243
- res.getTablesList()?.forEach((tableData) => {
244
- let dataItem = new types_1.DataItem(tableData.getTableName(), ULTIPA.ResultType.RESULT_TYPE_TABLE, exports.FormatType.table(tableData, timezone));
245
- items[dataItem.alias] = dataItem;
246
- });
247
- response.items = items;
248
- return response;
249
- },
250
- status: (statusData, p) => {
251
- let status = {
252
- code: ULTIPA.ErrorCode.SUCCESS,
253
- message: ULTIPA.ErrorCode[ultipa_pb_1.ErrorCode.SUCCESS],
254
- };
255
- if (statusData !== undefined) {
256
- status.code = statusData.getErrorCode();
257
- status.message = statusData.getMsg();
258
- }
259
- if (statusData?.getErrorCode() === ULTIPA.ErrorCode.SUCCESS) {
260
- status.message = ULTIPA.ErrorCode[ultipa_pb_1.ErrorCode.SUCCESS];
261
- }
262
- return status;
263
- },
264
- alias: (resultAlias) => {
265
- return resultAlias.map(alias => ({ name: alias.getAlias(), type: alias.getResultType() }));
266
- },
267
- keyValue: (keyValuesData) => {
268
- if (!keyValuesData || keyValuesData.length == 0) {
269
- return {};
270
- }
271
- let keyValue = {};
272
- keyValuesData.forEach((kv) => {
273
- keyValue[kv.getKey()] = kv.getValue();
274
- });
275
- return keyValue;
276
- },
277
- paths: (paths) => {
278
- let newPaths = [];
279
- paths.forEach(o => {
280
- let p = new ULTIPA.Path();
281
- p.nodeUuids = exports.FormatType.uuids(o.getNodeTable());
282
- p.edgeUuids = exports.FormatType.uuids(o.getEdgeTable());
283
- // p.length = p.edges.keys.length
284
- newPaths.push(p);
285
- });
286
- return newPaths;
287
- },
288
- graph: (paths, timezone) => {
289
- let graph = new ULTIPA.Graph();
290
- graph.paths = exports.FormatType.paths(paths);
291
- graph.nodes ??= new Map();
292
- graph.edges ??= new Map();
293
- paths.forEach(o => {
294
- let nodes = exports.FormatType.nodeTable(o.getNodeTable(), timezone);
295
- nodes.forEach(n => {
296
- graph.nodes.set(n.uuid, n);
297
- });
298
- let edges = exports.FormatType.edgeTable(o.getEdgeTable(), timezone);
299
- edges.forEach(e => {
300
- graph.edges.set(e.uuid, e);
301
- });
302
- });
303
- return graph;
304
- },
305
- explainPlan: (data) => {
306
- if (!data) {
307
- return null;
308
- }
309
- let explainPlan = {
310
- planNodes: []
311
- };
312
- let planNodes = [];
313
- data.getPlanNodesList().forEach(plan => {
314
- let one = {
315
- alias: plan.getAlias(),
316
- childrenNum: plan.getChildrenNum(),
317
- infos: plan.getInfos(),
318
- uql: plan.getQueryText(),
319
- };
320
- planNodes.push(one);
321
- });
322
- explainPlan.planNodes = planNodes;
323
- return explainPlan;
324
- },
325
- table: (tableData, timezone) => {
326
- if (!tableData) {
327
- return null;
328
- }
329
- let tableRows = [];
330
- let tableHeaders = [];
331
- tableData.getHeadersList().forEach(h => {
332
- let header = new types_1.Header();
333
- header.propertyName = h.getPropertyName();
334
- header.propertyType = h.getPropertyType();
335
- tableHeaders.push(header);
336
- });
337
- tableData.getTableRowsList().forEach((tableRowData) => {
338
- let values = [];
339
- tableRowData.getValuesList_asU8().forEach((v, i) => {
340
- let header = tableHeaders[i];
341
- values.push(index_1.DESERIALIZE.deserialize(v, header.propertyType, undefined, timezone));
342
- });
343
- tableRows.push(values);
344
- });
345
- let t = new ULTIPA.Table();
346
- t.name = tableData.getTableName();
347
- t.headers = tableHeaders;
348
- t.rows = tableRows;
349
- return t;
350
- },
351
- tables: (tablesData, timezone) => {
352
- if (!tablesData || tablesData.length == 0) {
353
- return [];
354
- }
355
- let tables = [];
356
- tablesData.forEach((tableData) => {
357
- tables.push(exports.FormatType.table(tableData, timezone));
358
- });
359
- return tables;
360
- },
361
- toEdgeTable: (propertyTypeObject, schemaName, headers, rows, timezone) => {
362
- let edgeTable = new ultipa_pb_1.EntityTable();
363
- let handles = [ULITPA_PRIVATE_KEYS.uuid, ULITPA_PRIVATE_KEYS.from, ULITPA_PRIVATE_KEYS.to, ULITPA_PRIVATE_KEYS.from_uuid, ULITPA_PRIVATE_KEYS.to_uuid];
364
- let schemaHeaders = [];
365
- let schemaHeader = new ultipa_pb_1.Schema();
366
- schemaHeader.setSchemaName(schemaName);
367
- let headerList = [];
368
- headers.forEach((h) => {
369
- if (handles.includes(h)) {
370
- return;
371
- }
372
- let header = new ultipa_pb_1.Property();
373
- header.setPropertyName(h);
374
- let typeCfg = index_1.PropertyUtils.GetPropertyType(propertyTypeObject[h]);
375
- header.setPropertyType(typeCfg.type);
376
- if (typeCfg.subTypes) {
377
- header.setSubTypesList(typeCfg.subTypes);
378
- }
379
- headerList.push(header);
380
- });
381
- schemaHeader.setPropertiesList(headerList);
382
- schemaHeaders.push(schemaHeader);
383
- edgeTable.setSchemasList(schemaHeaders);
384
- let edgeRowsList = [];
385
- rows.forEach(rowsObj => {
386
- let edgeRow = new ultipa_pb_1.EntityRow();
387
- if (!rowsObj) {
388
- edgeRow.setIsNull(true);
389
- edgeRowsList.push(edgeRow);
390
- return;
391
- }
392
- edgeRow.setSchemaName(schemaName);
393
- let rowValues = rowsObj;
394
- let values = [];
395
- headers.forEach((h, index) => {
396
- if (h === ULITPA_PRIVATE_KEYS.from) {
397
- edgeRow.setFromId(rowValues[index]);
398
- return;
399
- }
400
- if (h === ULITPA_PRIVATE_KEYS.to) {
401
- edgeRow.setToId(rowValues[index]);
402
- return;
403
- }
404
- if (h === ULITPA_PRIVATE_KEYS.uuid) {
405
- let uuid = rowValues[index];
406
- if (uuid) {
407
- uuid += "";
408
- }
409
- edgeRow.setUuid(uuid);
410
- return;
411
- }
412
- if (h === ULITPA_PRIVATE_KEYS.from_uuid) {
413
- edgeRow.setFromUuid(rowValues[index]);
414
- return;
415
- }
416
- if (h === ULITPA_PRIVATE_KEYS.to_uuid) {
417
- edgeRow.setToUuid(rowValues[index]);
418
- return;
419
- }
420
- let typeCfg = index_1.PropertyUtils.GetPropertyType(propertyTypeObject[h]);
421
- values.push(index_1.SERIALIZE.serialize(rowValues[index], typeCfg.type, typeCfg.subTypes, timezone));
422
- });
423
- edgeRow.setValuesList(values);
424
- edgeRowsList.push(edgeRow);
425
- });
426
- edgeTable.setEntityRowsList(edgeRowsList);
427
- return edgeTable;
428
- },
429
- toPropertyTypeObject: (properties) => {
430
- let object = {};
431
- properties.forEach(p => {
432
- object[p.name] = p.type;
433
- });
434
- return object;
435
- },
436
- toNodeTable: (propertyTypeObject, schemaName, headers, rows, timezone) => {
437
- let nodeTable = new ultipa_pb_1.EntityTable();
438
- let handles = [ULITPA_PRIVATE_KEYS.id, ULITPA_PRIVATE_KEYS.uuid];
439
- let schemaHeaders = [];
440
- let schemaHeader = new ultipa_pb_1.Schema();
441
- schemaHeader.setSchemaName(schemaName);
442
- let headerList = [];
443
- headers.forEach((h) => {
444
- if (handles.includes(h)) {
445
- return;
446
- }
447
- let header = new ultipa_pb_1.Property();
448
- header.setPropertyName(h);
449
- let typeCfg = index_1.PropertyUtils.GetPropertyType(propertyTypeObject[h]);
450
- header.setPropertyType(typeCfg.type);
451
- if (typeCfg.subTypes) {
452
- header.setSubTypesList(typeCfg.subTypes);
453
- }
454
- headerList.push(header);
455
- });
456
- schemaHeader.setPropertiesList(headerList);
457
- schemaHeaders.push(schemaHeader);
458
- nodeTable.setSchemasList(schemaHeaders);
459
- let nodeRowsList = [];
460
- rows.forEach(rowObj => {
461
- let nodeRow = new ultipa_pb_1.EntityRow();
462
- if (!rowObj) {
463
- nodeRow.setIsNull(true);
464
- nodeRowsList.push(nodeRow);
465
- return;
466
- }
467
- nodeRow.setSchemaName(schemaName);
468
- let values = [];
469
- let rowValues = rowObj;
470
- headers.forEach((h, index) => {
471
- if (h === ULITPA_PRIVATE_KEYS.id) {
472
- nodeRow.setId(rowValues[index]);
473
- return;
474
- }
475
- if (h === ULITPA_PRIVATE_KEYS.uuid) {
476
- let uuid = rowValues[index];
477
- if (uuid) {
478
- uuid += "";
479
- }
480
- nodeRow.setUuid(uuid);
481
- return;
482
- }
483
- let typeCfg = index_1.PropertyUtils.GetPropertyType(propertyTypeObject[h]);
484
- values.push(index_1.SERIALIZE.serialize(rowValues[index], typeCfg.type, typeCfg.subTypes, timezone));
485
- });
486
- nodeRow.setValuesList(values);
487
- nodeRowsList.push(nodeRow);
488
- });
489
- nodeTable.setEntityRowsList(nodeRowsList);
490
- return nodeTable;
491
- },
492
- toEdgeTableWithSchema: (schema, rows, timezone) => {
493
- let table = new ultipa_pb_1.EntityTable();
494
- let handles = [ULITPA_PRIVATE_KEYS.uuid, ULITPA_PRIVATE_KEYS.from, ULITPA_PRIVATE_KEYS.to, ULITPA_PRIVATE_KEYS.from_uuid, ULITPA_PRIVATE_KEYS.to_uuid];
495
- let schemaHeaders = [];
496
- let schemaHeader = new ultipa_pb_1.Schema();
497
- schemaHeader.setSchemaName(schema.name);
498
- let headerList = [];
499
- schema.properties.forEach((o) => {
500
- let { name, type, subType } = o;
501
- if (handles.includes(name)) {
502
- return;
503
- }
504
- let header = new ultipa_pb_1.Property();
505
- header.setPropertyName(name);
506
- header.setPropertyType(type);
507
- if (subType) {
508
- header.setSubTypesList(subType);
509
- }
510
- headerList.push(header);
511
- });
512
- schemaHeader.setPropertiesList(headerList);
513
- schemaHeaders.push(schemaHeader);
514
- table.setSchemasList(schemaHeaders);
515
- let rowList = [];
516
- rows.forEach(rowObj => {
517
- let row = new ultipa_pb_1.EntityRow();
518
- if (!rowObj) {
519
- row.setIsNull(true);
520
- rowList.push(row);
521
- return;
522
- }
523
- row.setSchemaName(schema.name);
524
- if (!!rowObj.uuid) {
525
- row.setUuid(rowObj.uuid);
526
- }
527
- if (!!rowObj.from) {
528
- row.setFromId(rowObj.from);
529
- }
530
- if (!!rowObj.to) {
531
- row.setToId(rowObj.to);
532
- }
533
- if (!!rowObj.fromUuid) {
534
- row.setFromUuid(rowObj.fromUuid);
535
- }
536
- if (!!rowObj.toUuid) {
537
- row.setToUuid(rowObj.toUuid);
538
- }
539
- let values = [];
540
- let rowValues = rowObj.values || {};
541
- headerList.forEach((o, index) => {
542
- let name = o.getPropertyName();
543
- let type = o.getPropertyType();
544
- let subTypes = o.getSubTypesList();
545
- values.push(index_1.SERIALIZE.serialize(rowValues[name], type, subTypes, timezone));
546
- });
547
- row.setValuesList(values);
548
- rowList.push(row);
549
- });
550
- table.setEntityRowsList(rowList);
551
- return table;
552
- },
553
- toNodeTableWithSchema: (schema, rows, timezone) => {
554
- let nodeTable = new ultipa_pb_1.EntityTable();
555
- let handles = [ULITPA_PRIVATE_KEYS.id, ULITPA_PRIVATE_KEYS.uuid];
556
- let schemaHeaders = [];
557
- let schemaHeader = new ultipa_pb_1.Schema();
558
- schemaHeader.setSchemaName(schema.name);
559
- let headerList = [];
560
- schema.properties.forEach((o) => {
561
- let { name, type, subType } = o;
562
- if (handles.includes(name)) {
563
- return;
564
- }
565
- let header = new ultipa_pb_1.Property();
566
- header.setPropertyName(name);
567
- header.setPropertyType(type);
568
- if (subType) {
569
- header.setSubTypesList(subType);
570
- }
571
- headerList.push(header);
572
- });
573
- schemaHeader.setPropertiesList(headerList);
574
- schemaHeaders.push(schemaHeader);
575
- nodeTable.setSchemasList(schemaHeaders);
576
- let nodeRowsList = [];
577
- rows.forEach(rowObj => {
578
- let nodeRow = new ultipa_pb_1.EntityRow();
579
- if (!rowObj) {
580
- nodeRow.setIsNull(true);
581
- nodeRowsList.push(nodeRow);
582
- return;
583
- }
584
- if (!!rowObj.id) {
585
- nodeRow.setId(rowObj.id);
586
- }
587
- if (!!rowObj.uuid) {
588
- nodeRow.setUuid(rowObj.uuid);
589
- }
590
- nodeRow.setSchemaName(schema.name);
591
- let values = [];
592
- let rowValues = rowObj.values || {};
593
- headerList.forEach((o, index) => {
594
- let name = o.getPropertyName();
595
- let type = o.getPropertyType();
596
- let subTypes = o.getSubTypesList();
597
- values.push(index_1.SERIALIZE.serialize(rowValues[name], type, subTypes, timezone));
598
- });
599
- nodeRow.setValuesList(values);
600
- nodeRowsList.push(nodeRow);
601
- });
602
- nodeTable.setEntityRowsList(nodeRowsList);
603
- return nodeTable;
604
- },
605
- uuids: (tableData) => {
606
- if (!tableData) {
607
- return [];
608
- }
609
- let rowsData = tableData.getEntityRowsList();
610
- let uuids = [];
611
- rowsData.forEach((data) => {
612
- uuids.push(data.getUuid());
613
- });
614
- return uuids;
615
- },
616
- nodeTable: (nodeTableData, timezone) => {
617
- let tables = [];
618
- if (!nodeTableData) {
619
- return tables;
620
- }
621
- let headerMap = {};
622
- nodeTableData.getSchemasList().forEach((sh) => {
623
- let schema = sh.getSchemaName();
624
- headerMap[schema] = sh.getPropertiesList();
625
- });
626
- let nodeRowsData = nodeTableData.getEntityRowsList();
627
- nodeRowsData.forEach((nodeRowData) => {
628
- if (nodeRowData.getIsNull()) {
629
- tables.push(null);
630
- return;
631
- }
632
- let schema = nodeRowData.getSchemaName();
633
- let ptys = headerMap[schema];
634
- let values = nodeRowData.getValuesList_asU8();
635
- let _v = _mapValues(values, ptys, timezone);
636
- let nodeRow = new ULTIPA.Node();
637
- nodeRow.id = nodeRowData.getId(),
638
- nodeRow.uuid = nodeRowData.getUuid(),
639
- nodeRow.schema = schema,
640
- nodeRow.values = _v,
641
- tables.push(nodeRow);
642
- });
643
- return tables;
644
- },
645
- edgeTable: (edgeTableData, timezone) => {
646
- let tables = [];
647
- if (!edgeTableData) {
648
- return tables;
649
- }
650
- let headerMap = {};
651
- edgeTableData.getSchemasList().forEach((sh) => {
652
- let schema = sh.getSchemaName();
653
- headerMap[schema] = sh.getPropertiesList();
654
- });
655
- edgeTableData.getSchemasList().forEach((sh) => {
656
- let schema = sh.getSchemaName();
657
- headerMap[schema] = sh.getPropertiesList();
658
- });
659
- let edgeRowsData = edgeTableData.getEntityRowsList();
660
- edgeRowsData.forEach((rowData) => {
661
- if (rowData.getIsNull()) {
662
- tables.push(null);
663
- return;
664
- }
665
- let schema = rowData.getSchemaName();
666
- let ptys = headerMap[schema];
667
- let values = rowData.getValuesList_asU8();
668
- let _v = _mapValues(values, ptys, timezone);
669
- let edgeRow = new ULTIPA.Edge();
670
- // id: rowData.getId(),
671
- edgeRow.from = rowData.getFromId();
672
- edgeRow.to = rowData.getToId();
673
- edgeRow.uuid = rowData.getUuid();
674
- edgeRow.fromUuid = rowData.getFromUuid();
675
- edgeRow.toUuid = rowData.getToUuid();
676
- edgeRow.schema = schema;
677
- edgeRow.values = _v;
678
- tables.push(edgeRow);
679
- });
680
- return tables;
681
- },
682
- attr(attr, timezone) {
683
- let type = attr.getValueType();
684
- let result = new ULTIPA.Attr();
685
- result.values = [];
686
- result.resultType = ultipa_pb_1.ResultType.RESULT_TYPE_ATTR;
687
- result.propertyType = type;
688
- attr.getValuesList_asU8().forEach((v) => {
689
- if (type == ULTIPA.UltipaPropertyType.NULL) {
690
- return result.values.push(null);
691
- }
692
- if (type == ULTIPA.UltipaPropertyType.LIST) {
693
- let attrListData = ultipa_pb_1.AttrListData.deserializeBinary(v);
694
- if (attrListData.getIsNull()) {
695
- return result.values.push(null);
696
- }
697
- let result_type = attrListData.getType();
698
- switch (result_type) {
699
- case ultipa_pb_1.ResultType.RESULT_TYPE_NODE:
700
- {
701
- let v = {
702
- type: result_type,
703
- type_desc: ULTIPA.ResultType[result_type],
704
- nodes: exports.FormatType.nodeTable(attrListData.getNodes(), timezone)
705
- };
706
- result.values.push(v);
707
- }
708
- break;
709
- case ultipa_pb_1.ResultType.RESULT_TYPE_EDGE:
710
- {
711
- let v = {
712
- type: result_type,
713
- type_desc: ULTIPA.ResultType[result_type],
714
- edges: exports.FormatType.edgeTable(attrListData.getEdges(), timezone)
715
- };
716
- result.values.push(v);
717
- }
718
- break;
719
- case ultipa_pb_1.ResultType.RESULT_TYPE_PATH:
720
- {
721
- let v = {
722
- type: result_type,
723
- type_desc: ULTIPA.ResultType[result_type],
724
- paths: exports.FormatType.paths(attrListData.getPathsList())
725
- };
726
- result.values.push(v);
727
- }
728
- break;
729
- case ultipa_pb_1.ResultType.RESULT_TYPE_ATTR: {
730
- {
731
- let attrs = [];
732
- attrListData.getAttrsList().forEach(o => {
733
- let attr = exports.FormatType.attr(o, timezone);
734
- if (!attr.values) {
735
- attrs.push(attr.values);
736
- }
737
- else {
738
- attrs.push(...attr.values);
739
- }
740
- });
741
- // let v: ULTIPA.AttrListData = {
742
- // type: result_type,
743
- // type_desc: ULTIPA.ResultType[result_type],
744
- // attrs: attrs,
745
- // }
746
- if (attrs.length != 0) {
747
- }
748
- result.values.push(attrs);
749
- }
750
- break;
751
- }
752
- }
753
- }
754
- else {
755
- let v1 = index_1.DESERIALIZE.base(v, type, timezone);
756
- result.values.push(v1);
757
- }
758
- });
759
- return result;
760
- },
761
- graphPrivileges(graphPrivileges) {
762
- let new_graphPrivileges = [];
763
- if (graphPrivileges) {
764
- graphPrivileges.forEach((graphPrivilege) => {
765
- let new_graphPrivilege = { ...graphPrivilege };
766
- Object.keys(new_graphPrivilege).forEach((key) => {
767
- new_graphPrivilege["name"] = key;
768
- new_graphPrivilege["values"] = new_graphPrivilege[key];
769
- delete new_graphPrivilege[key];
770
- });
771
- new_graphPrivileges.push(new_graphPrivilege);
772
- });
773
- }
774
- return new_graphPrivileges;
775
- },
776
- };
777
- exports.FormatResponse = {
778
- tableToArray: (table) => {
779
- let res = [];
780
- if (table) {
781
- try {
782
- table.rows.forEach((row) => {
783
- let item = {};
784
- row.forEach((value, index) => {
785
- let header = table.headers[index];
786
- item[header.propertyName] = value;
787
- });
788
- res.push(item);
789
- });
790
- }
791
- catch (error) {
792
- console.log(error);
793
- }
794
- }
795
- return res;
796
- },
797
- formatObjects: (objs, keysFormat) => {
798
- if (!keysFormat) {
799
- return objs;
800
- }
801
- let newObjs = [];
802
- if (objs?.length > 0) {
803
- objs.forEach((obj) => {
804
- newObjs.push(exports.FormatResponse.formatObject(obj, keysFormat));
805
- });
806
- }
807
- return newObjs;
808
- },
809
- formatObject: (_obj, keysFormat) => {
810
- if (!keysFormat) {
811
- return _obj;
812
- }
813
- let obj = { ..._obj };
814
- if (keysFormat?.jsonKeys) {
815
- keysFormat.jsonKeys.forEach((k) => {
816
- try {
817
- if (obj[k]) {
818
- obj[k] = JSON.parse(obj[k]);
819
- }
820
- }
821
- catch (error) {
822
- console.log(error, k, obj);
823
- }
824
- });
825
- }
826
- if (keysFormat?.boolKeys) {
827
- keysFormat.boolKeys.forEach((k) => {
828
- try {
829
- if (obj[k]) {
830
- obj[k] = obj[k] == "true";
831
- }
832
- }
833
- catch (error) {
834
- console.log(error, k, obj);
835
- }
836
- });
837
- }
838
- if (keysFormat?.keyReplace) {
839
- Object.keys(keysFormat.keyReplace).forEach((k) => {
840
- if (obj[k]) {
841
- obj[keysFormat.keyReplace[k]] = obj[k];
842
- delete obj[k];
843
- }
844
- });
845
- }
846
- if (keysFormat?.dataFormat) {
847
- obj = keysFormat.dataFormat(obj);
848
- }
849
- return obj;
850
- },
851
- successStatus: () => {
852
- return {
853
- code: ULTIPA.ErrorCode.SUCCESS,
854
- message: ULTIPA.ErrorCode[ULTIPA.ErrorCode.SUCCESS]
855
- // message: "ok",
856
- };
857
- },
858
- statisticsSum: (one, sumOne) => {
859
- return {
860
- totalCost: (one?.totalCost || 0) + (sumOne?.totalCost || 0),
861
- engineCost: (one?.engineCost || 0) + (sumOne?.engineCost || 0),
862
- nodeAffected: (one?.nodeAffected || 0) + (sumOne?.nodeAffected || 0),
863
- edgeAffected: (one?.edgeAffected || 0) + (sumOne?.edgeAffected || 0),
864
- };
865
- },
866
- unknownError: (err, res) => {
867
- res.status = {
868
- code: ULTIPA.ErrorCode.UNKNOWN_ERROR,
869
- message: err.message || err.detail,
870
- };
871
- return res;
872
- },
873
- catchUltipaUqlError: (error) => {
874
- let response = new ULTIPA.Response();
875
- response = exports.FormatResponse.unknownError(error, response);
876
- return response;
877
- },
878
- };
879
- //# sourceMappingURL=format.js.map