oak-domain 2.6.6 → 2.6.7
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/lib/base-app-domain/Modi/Schema.d.ts +0 -11
- package/lib/base-app-domain/Oper/Schema.d.ts +6 -0
- package/lib/base-app-domain/Oper/Storage.js +6 -0
- package/lib/base-app-domain/OperEntity/Schema.d.ts +4 -31
- package/lib/base-app-domain/OperEntity/Storage.js +1 -1
- package/lib/base-app-domain/User/Schema.d.ts +11 -11
- package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +11 -11
- package/lib/compiler/env.d.ts +1 -0
- package/lib/compiler/env.js +2 -1
- package/lib/compiler/schemalBuilder.js +29 -15
- package/lib/entities/Oper.d.ts +1 -0
- package/lib/entities/Oper.js +1 -0
- package/lib/store/AsyncRowStore.d.ts +5 -1
- package/lib/store/CascadeStore.d.ts +7 -1
- package/lib/store/CascadeStore.js +387 -131
- package/lib/store/SyncRowStore.d.ts +1 -1
- package/lib/store/TriggerExecutor.js +1 -1
- package/lib/store/checker.d.ts +1 -1
- package/lib/store/checker.js +4 -4
- package/lib/timers/oper.d.ts +18 -0
- package/lib/timers/oper.js +60 -0
- package/lib/timers/vaccum.d.ts +20 -0
- package/lib/timers/vaccum.js +176 -0
- package/lib/types/Connector.d.ts +2 -2
- package/lib/types/Entity.d.ts +1 -0
- package/lib/types/RowStore.d.ts +4 -0
- package/lib/utils/SimpleConnector.d.ts +2 -2
- package/lib/utils/SimpleConnector.js +24 -14
- package/package.json +1 -1
- package/src/entities/Oper.ts +2 -0
- package/lib/store/selection.d.ts +0 -19
- package/lib/store/selection.js +0 -265
|
@@ -11,13 +11,251 @@ var types_1 = require("../types");
|
|
|
11
11
|
var lodash_1 = require("../utils/lodash");
|
|
12
12
|
var filter_2 = require("./filter");
|
|
13
13
|
var uuid_1 = require("../utils/uuid");
|
|
14
|
-
var selection_1 = require("./selection");
|
|
15
14
|
/**这个用来处理级联的select和update,对不同能力的 */
|
|
16
15
|
var CascadeStore = /** @class */ (function (_super) {
|
|
17
16
|
tslib_1.__extends(CascadeStore, _super);
|
|
18
17
|
function CascadeStore(storageSchema) {
|
|
19
|
-
|
|
18
|
+
var _this = _super.call(this, storageSchema) || this;
|
|
19
|
+
_this.selectionRewriters = [];
|
|
20
|
+
_this.operationRewriters = [];
|
|
21
|
+
return _this;
|
|
20
22
|
}
|
|
23
|
+
CascadeStore.prototype.reinforceSelection = function (entity, selection) {
|
|
24
|
+
var _this = this;
|
|
25
|
+
var filter = selection.filter, data = selection.data, sorter = selection.sorter;
|
|
26
|
+
var checkNode = function (projectionNode, attrs) {
|
|
27
|
+
attrs.forEach(function (attr) {
|
|
28
|
+
var _a;
|
|
29
|
+
if (!projectionNode.hasOwnProperty(attr)) {
|
|
30
|
+
Object.assign(projectionNode, (_a = {},
|
|
31
|
+
_a[attr] = 1,
|
|
32
|
+
_a));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
var relevantIds = [];
|
|
37
|
+
if (filter) {
|
|
38
|
+
var toBeAssignNode_1 = {}; // 用来记录在表达式中涉及到的结点
|
|
39
|
+
// filter当中所关联到的属性必须在projection中
|
|
40
|
+
var filterNodeDict_1 = {};
|
|
41
|
+
var checkFilterNode_1 = function (entity2, filterNode, projectionNode) {
|
|
42
|
+
var _a, e_1, _b, _c, _d, _e, _f;
|
|
43
|
+
var necessaryAttrs = ['id'];
|
|
44
|
+
for (var attr in filterNode) {
|
|
45
|
+
if (attr === '#id') {
|
|
46
|
+
(0, assert_1.default)(!filterNodeDict_1[filterNode[attr]], "projection\u4E2D\u7ED3\u70B9\u7684id\u6709\u91CD\u590D, ".concat(filterNode[attr]));
|
|
47
|
+
Object.assign(filterNodeDict_1, (_a = {},
|
|
48
|
+
_a[filterNode[attr]] = projectionNode,
|
|
49
|
+
_a));
|
|
50
|
+
if (toBeAssignNode_1[filterNode[attr]]) {
|
|
51
|
+
checkNode(projectionNode, toBeAssignNode_1[filterNode[attr]]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (['$and', '$or'].includes(attr)) {
|
|
55
|
+
try {
|
|
56
|
+
for (var _g = (e_1 = void 0, tslib_1.__values(filterNode[attr])), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
57
|
+
var node = _h.value;
|
|
58
|
+
checkFilterNode_1(entity2, node, projectionNode);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
62
|
+
finally {
|
|
63
|
+
try {
|
|
64
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
65
|
+
}
|
|
66
|
+
finally { if (e_1) throw e_1.error; }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (attr === '$not') {
|
|
70
|
+
checkFilterNode_1(entity2, filterNode[attr], projectionNode);
|
|
71
|
+
}
|
|
72
|
+
else if (attr === '$text') {
|
|
73
|
+
// 全文检索首先要有fulltext索引,其次要把fulltext的相关属性加到projection里
|
|
74
|
+
var indexes = _this.getSchema()[entity2].indexes;
|
|
75
|
+
var fulltextIndex = indexes.find(function (ele) { return ele.config && ele.config.type === 'fulltext'; });
|
|
76
|
+
var attributes = fulltextIndex.attributes;
|
|
77
|
+
necessaryAttrs.push.apply(necessaryAttrs, tslib_1.__spreadArray([], tslib_1.__read((attributes.map(function (ele) { return ele.name; }))), false));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
if (attr.toLowerCase().startsWith(types_1.EXPRESSION_PREFIX)) {
|
|
81
|
+
var exprResult = (0, types_1.getAttrRefInExpression)(filterNode[attr]);
|
|
82
|
+
for (var nodeName in exprResult) {
|
|
83
|
+
if (nodeName === '#current') {
|
|
84
|
+
checkNode(projectionNode, exprResult[nodeName]);
|
|
85
|
+
}
|
|
86
|
+
else if (filterNodeDict_1[nodeName]) {
|
|
87
|
+
checkNode(filterNodeDict_1[nodeName], exprResult[nodeName]);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
if (toBeAssignNode_1[nodeName]) {
|
|
91
|
+
(_c = toBeAssignNode_1[nodeName]).push.apply(_c, tslib_1.__spreadArray([], tslib_1.__read(exprResult[nodeName]), false));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
Object.assign(toBeAssignNode_1, (_d = {},
|
|
95
|
+
_d[nodeName] = exprResult[nodeName],
|
|
96
|
+
_d));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
var rel = _this.judgeRelation(entity2, attr);
|
|
103
|
+
if (rel === 1) {
|
|
104
|
+
necessaryAttrs.push(attr);
|
|
105
|
+
}
|
|
106
|
+
else if (rel === 2) {
|
|
107
|
+
// entity/entityId反指
|
|
108
|
+
necessaryAttrs.push('entity', 'entityId');
|
|
109
|
+
if (!projectionNode[attr]) {
|
|
110
|
+
Object.assign(projectionNode, (_e = {},
|
|
111
|
+
_e[attr] = {
|
|
112
|
+
id: 1,
|
|
113
|
+
},
|
|
114
|
+
_e));
|
|
115
|
+
}
|
|
116
|
+
checkFilterNode_1(attr, filterNode[attr], projectionNode[attr]);
|
|
117
|
+
}
|
|
118
|
+
else if (typeof rel === 'string') {
|
|
119
|
+
necessaryAttrs.push("".concat(attr, "Id"));
|
|
120
|
+
if (!projectionNode[attr]) {
|
|
121
|
+
Object.assign(projectionNode, (_f = {},
|
|
122
|
+
_f[attr] = {
|
|
123
|
+
id: 1,
|
|
124
|
+
},
|
|
125
|
+
_f));
|
|
126
|
+
}
|
|
127
|
+
checkFilterNode_1(rel, filterNode[attr], projectionNode[attr]);
|
|
128
|
+
}
|
|
129
|
+
else if (rel instanceof Array) {
|
|
130
|
+
// 现在filter中还不支持一对多的语义,先放着吧
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
checkNode(projectionNode, necessaryAttrs);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
checkFilterNode_1(entity, filter, data);
|
|
138
|
+
relevantIds = (0, filter_2.getRelevantIds)(filter);
|
|
139
|
+
}
|
|
140
|
+
// sorter感觉现在取不取影响不大,前端的list直接获取返回的ids了,先不管之
|
|
141
|
+
if (sorter) {
|
|
142
|
+
}
|
|
143
|
+
var toBeAssignNode2 = {}; // 用来记录在表达式中涉及到的结点
|
|
144
|
+
var projectionNodeDict = {};
|
|
145
|
+
var checkProjectionNode = function (entity2, projectionNode) {
|
|
146
|
+
var _a, _b, _c;
|
|
147
|
+
var necessaryAttrs = ['id', '$$createAt$$']; // 有的页面依赖于其它页面取数据,有时两个页面的filter的差异会导致有一个加createAt,有一个不加,此时可能产生前台取数据不完整的异常。先统一加上
|
|
148
|
+
for (var attr in projectionNode) {
|
|
149
|
+
if (attr === '#id') {
|
|
150
|
+
(0, assert_1.default)(!projectionNodeDict[projectionNode[attr]], "projection\u4E2D\u7ED3\u70B9\u7684id\u6709\u91CD\u590D, ".concat(projectionNode[attr]));
|
|
151
|
+
Object.assign(projectionNodeDict, (_a = {},
|
|
152
|
+
_a[projectionNode[attr]] = projectionNode,
|
|
153
|
+
_a));
|
|
154
|
+
if (toBeAssignNode2[projectionNode[attr]]) {
|
|
155
|
+
checkNode(projectionNode, toBeAssignNode2[projectionNode[attr]]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
if (attr.toLowerCase().startsWith(types_1.EXPRESSION_PREFIX)) {
|
|
160
|
+
var exprResult = (0, types_1.getAttrRefInExpression)(projectionNode[attr]);
|
|
161
|
+
for (var nodeName in exprResult) {
|
|
162
|
+
if (nodeName === '#current') {
|
|
163
|
+
checkNode(projectionNode, exprResult[nodeName]);
|
|
164
|
+
}
|
|
165
|
+
else if (projectionNodeDict[nodeName]) {
|
|
166
|
+
checkNode(projectionNodeDict[nodeName], exprResult[nodeName]);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
if (toBeAssignNode2[nodeName]) {
|
|
170
|
+
(_b = toBeAssignNode2[nodeName]).push.apply(_b, tslib_1.__spreadArray([], tslib_1.__read(exprResult[nodeName]), false));
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
Object.assign(toBeAssignNode2, (_c = {},
|
|
174
|
+
_c[nodeName] = exprResult[nodeName],
|
|
175
|
+
_c));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
var rel = (0, relation_1.judgeRelation)(_this.getSchema(), entity2, attr);
|
|
182
|
+
if (rel === 1) {
|
|
183
|
+
necessaryAttrs.push(attr);
|
|
184
|
+
}
|
|
185
|
+
else if (rel === 2) {
|
|
186
|
+
// entity/entityId反指
|
|
187
|
+
necessaryAttrs.push('entity', 'entityId');
|
|
188
|
+
checkProjectionNode(attr, projectionNode[attr]);
|
|
189
|
+
}
|
|
190
|
+
else if (typeof rel === 'string') {
|
|
191
|
+
necessaryAttrs.push("".concat(attr, "Id"));
|
|
192
|
+
checkProjectionNode(rel, projectionNode[attr]);
|
|
193
|
+
}
|
|
194
|
+
else if (rel instanceof Array && !attr.endsWith('$$aggr')) {
|
|
195
|
+
var data_1 = projectionNode[attr].data;
|
|
196
|
+
if (rel[1]) {
|
|
197
|
+
checkNode(data_1, [rel[1]]);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
checkNode(data_1, ['entity', 'entityId']);
|
|
201
|
+
}
|
|
202
|
+
_this.reinforceSelection(rel[0], projectionNode[attr]);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
checkNode(projectionNode, necessaryAttrs);
|
|
207
|
+
}
|
|
208
|
+
// 如果对象中指向一对多的Modi,此时加上指向Modi的projection
|
|
209
|
+
if (_this.getSchema()[entity2].toModi) {
|
|
210
|
+
Object.assign(projectionNode, {
|
|
211
|
+
modi$entity: {
|
|
212
|
+
$entity: 'modi',
|
|
213
|
+
data: {
|
|
214
|
+
id: 1,
|
|
215
|
+
targetEntity: 1,
|
|
216
|
+
entity: 1,
|
|
217
|
+
entityId: 1,
|
|
218
|
+
action: 1,
|
|
219
|
+
iState: 1,
|
|
220
|
+
data: 1,
|
|
221
|
+
filter: 1,
|
|
222
|
+
},
|
|
223
|
+
filter: {
|
|
224
|
+
iState: 'active',
|
|
225
|
+
},
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
checkProjectionNode(entity, data);
|
|
231
|
+
if (!sorter && relevantIds.length === 0) {
|
|
232
|
+
// 如果没有sorter,就给予一个按createAt逆序的sorter
|
|
233
|
+
Object.assign(selection, {
|
|
234
|
+
sorter: [
|
|
235
|
+
{
|
|
236
|
+
$attr: {
|
|
237
|
+
$$createAt$$: 1,
|
|
238
|
+
},
|
|
239
|
+
$direction: 'desc',
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
});
|
|
243
|
+
Object.assign(data, {
|
|
244
|
+
$$createAt$$: 1,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
this.selectionRewriters.forEach(function (ele) { return ele(_this.getSchema(), entity, selection); });
|
|
248
|
+
};
|
|
249
|
+
CascadeStore.prototype.reinforceOperation = function (entity, operation) {
|
|
250
|
+
var _this = this;
|
|
251
|
+
this.operationRewriters.forEach(function (ele) { return ele(_this.getSchema(), entity, operation); });
|
|
252
|
+
};
|
|
253
|
+
CascadeStore.prototype.registerOperationRewriter = function (rewriter) {
|
|
254
|
+
this.operationRewriters.push(rewriter);
|
|
255
|
+
};
|
|
256
|
+
CascadeStore.prototype.registerSelectionRewriter = function (rewriter) {
|
|
257
|
+
this.selectionRewriters.push(rewriter);
|
|
258
|
+
};
|
|
21
259
|
CascadeStore.prototype.destructCascadeSelect = function (entity, projection2, context, cascadeSelectFn, aggregateFn, option) {
|
|
22
260
|
var _this = this;
|
|
23
261
|
var projection = {};
|
|
@@ -69,6 +307,10 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
69
307
|
}
|
|
70
308
|
else {
|
|
71
309
|
cascadeSelectionFns.push(function (result) {
|
|
310
|
+
var entityIds = (0, lodash_1.uniq)(result.filter(function (ele) { return ele.entity === attr; }).map(function (ele) {
|
|
311
|
+
(0, assert_1.default)(ele.entityId !== null);
|
|
312
|
+
return ele.entityId;
|
|
313
|
+
}));
|
|
72
314
|
var dealWithSubRows = function (subRows) {
|
|
73
315
|
(0, assert_1.default)(subRows.length <= entityIds.length);
|
|
74
316
|
if (subRows.length < entityIds.length && !toModi) {
|
|
@@ -101,10 +343,6 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
101
343
|
}
|
|
102
344
|
});
|
|
103
345
|
};
|
|
104
|
-
var entityIds = (0, lodash_1.uniq)(result.filter(function (ele) { return ele.entity === attr; }).map(function (ele) {
|
|
105
|
-
(0, assert_1.default)(ele.entityId !== null);
|
|
106
|
-
return ele.entityId;
|
|
107
|
-
}));
|
|
108
346
|
if (entityIds.length > 0) {
|
|
109
347
|
var subRows = cascadeSelectFn.call(_this, attr, {
|
|
110
348
|
data: projection2[attr],
|
|
@@ -121,8 +359,6 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
121
359
|
dealWithSubRows(subRows);
|
|
122
360
|
}
|
|
123
361
|
}
|
|
124
|
-
else {
|
|
125
|
-
}
|
|
126
362
|
});
|
|
127
363
|
}
|
|
128
364
|
}
|
|
@@ -161,6 +397,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
161
397
|
}
|
|
162
398
|
else {
|
|
163
399
|
cascadeSelectionFns.push(function (result) {
|
|
400
|
+
var ids = (0, lodash_1.uniq)(result.filter(function (ele) { return !!(ele["".concat(attr, "Id")]); }).map(function (ele) { return ele["".concat(attr, "Id")]; }));
|
|
164
401
|
var dealWithSubRows = function (subRows) {
|
|
165
402
|
(0, assert_1.default)(subRows.length <= ids.length);
|
|
166
403
|
if (subRows.length < ids.length && !toModi) {
|
|
@@ -198,7 +435,6 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
198
435
|
}
|
|
199
436
|
});
|
|
200
437
|
};
|
|
201
|
-
var ids = (0, lodash_1.uniq)(result.filter(function (ele) { return !!(ele["".concat(attr, "Id")]); }).map(function (ele) { return ele["".concat(attr, "Id")]; }));
|
|
202
438
|
if (ids.length > 0) {
|
|
203
439
|
var subRows = cascadeSelectFn.call(_this, relation, {
|
|
204
440
|
data: projection2[attr],
|
|
@@ -262,14 +498,24 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
262
498
|
var _a;
|
|
263
499
|
var ids = result.map(function (ele) { return ele.id; });
|
|
264
500
|
var dealWithSubRows = function (subRows) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
Object.assign(
|
|
270
|
-
_a[attr] =
|
|
501
|
+
var _a;
|
|
502
|
+
// 这里如果result只有一行,则把返回结果直接置上,不对比外键值
|
|
503
|
+
// 这样做的原因是有的对象的filter会被改写掉(userId),只能临时这样处理
|
|
504
|
+
if (result.length == 1) {
|
|
505
|
+
Object.assign(result[0], (_a = {},
|
|
506
|
+
_a[attr] = subRows,
|
|
271
507
|
_a));
|
|
272
|
-
}
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
result.forEach(function (ele) {
|
|
511
|
+
var _a;
|
|
512
|
+
var subRowss = subRows.filter(function (ele2) { return ele2[foreignKey_1] === ele.id; });
|
|
513
|
+
(0, assert_1.default)(subRowss);
|
|
514
|
+
Object.assign(ele, (_a = {},
|
|
515
|
+
_a[attr] = subRowss,
|
|
516
|
+
_a));
|
|
517
|
+
});
|
|
518
|
+
}
|
|
273
519
|
};
|
|
274
520
|
if (ids.length > 0) {
|
|
275
521
|
var subRows = cascadeSelectFn.call(_this, entity2_1, {
|
|
@@ -332,14 +578,24 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
332
578
|
cascadeSelectionFns.push(function (result) {
|
|
333
579
|
var ids = result.map(function (ele) { return ele.id; });
|
|
334
580
|
var dealWithSubRows = function (subRows) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
Object.assign(
|
|
340
|
-
_a[attr] =
|
|
581
|
+
var _a;
|
|
582
|
+
// 这里如果result只有一行,则把返回结果直接置上,不对比外键值
|
|
583
|
+
// 这样做的原因是有的对象的filter会被改写掉(userId),只能临时这样处理
|
|
584
|
+
if (result.length === 1) {
|
|
585
|
+
Object.assign(result[0], (_a = {},
|
|
586
|
+
_a[attr] = subRows,
|
|
341
587
|
_a));
|
|
342
|
-
}
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
result.forEach(function (ele) {
|
|
591
|
+
var _a;
|
|
592
|
+
var subRowss = subRows.filter(function (ele2) { return ele2.entityId === ele.id; });
|
|
593
|
+
(0, assert_1.default)(subRowss);
|
|
594
|
+
Object.assign(ele, (_a = {},
|
|
595
|
+
_a[attr] = subRowss,
|
|
596
|
+
_a));
|
|
597
|
+
});
|
|
598
|
+
}
|
|
343
599
|
};
|
|
344
600
|
if (ids.length > 0) {
|
|
345
601
|
var subRows = cascadeSelectFn.call(_this, entity2_1, {
|
|
@@ -426,7 +682,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
426
682
|
option2.modiParentEntity = entity;
|
|
427
683
|
}
|
|
428
684
|
var _loop_2 = function (attr) {
|
|
429
|
-
var _a, _b, _c,
|
|
685
|
+
var _a, _b, _c, e_2, _d;
|
|
430
686
|
var relation = (0, relation_1.judgeRelation)(this_2.storageSchema, entity, attr);
|
|
431
687
|
if (relation === 1) {
|
|
432
688
|
Object.assign(opData, (_a = {},
|
|
@@ -683,17 +939,17 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
683
939
|
};
|
|
684
940
|
if (otmOperations instanceof Array) {
|
|
685
941
|
try {
|
|
686
|
-
for (var otmOperations_1 = (
|
|
942
|
+
for (var otmOperations_1 = (e_2 = void 0, tslib_1.__values(otmOperations)), otmOperations_1_1 = otmOperations_1.next(); !otmOperations_1_1.done; otmOperations_1_1 = otmOperations_1.next()) {
|
|
687
943
|
var oper = otmOperations_1_1.value;
|
|
688
944
|
dealWithOneToMany(oper);
|
|
689
945
|
}
|
|
690
946
|
}
|
|
691
|
-
catch (
|
|
947
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
692
948
|
finally {
|
|
693
949
|
try {
|
|
694
950
|
if (otmOperations_1_1 && !otmOperations_1_1.done && (_d = otmOperations_1.return)) _d.call(otmOperations_1);
|
|
695
951
|
}
|
|
696
|
-
finally { if (
|
|
952
|
+
finally { if (e_2) throw e_2.error; }
|
|
697
953
|
}
|
|
698
954
|
}
|
|
699
955
|
else {
|
|
@@ -754,8 +1010,8 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
754
1010
|
*/
|
|
755
1011
|
CascadeStore.prototype.doUpdateSingleRowAsync = function (entity, operation, context, option) {
|
|
756
1012
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
757
|
-
var data, action, operId, filter, now, _a, modiCreate, result_1, createInner, multipleCreate,
|
|
758
|
-
var
|
|
1013
|
+
var data, action, operId, filter, now, _a, modiCreate, result_1, createInner, multipleCreate, data_2, data_2_1, d, createSingleOper, e_3_1, operatorId, createOper, _b, ids_1, selection, rows, modiUpsert, upsertModis, _c, originData, originId, _d, createOper, updateAttrCount, result;
|
|
1014
|
+
var e_3, _e, _f, _g, _h, _j, _k, _l;
|
|
759
1015
|
var _this = this;
|
|
760
1016
|
return tslib_1.__generator(this, function (_m) {
|
|
761
1017
|
switch (_m.label) {
|
|
@@ -766,7 +1022,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
766
1022
|
switch (_a) {
|
|
767
1023
|
case 'create': return [3 /*break*/, 1];
|
|
768
1024
|
}
|
|
769
|
-
return [3 /*break*/,
|
|
1025
|
+
return [3 /*break*/, 22];
|
|
770
1026
|
case 1:
|
|
771
1027
|
this.preProcessDataCreated(entity, data);
|
|
772
1028
|
if (!(option.modiParentEntity && !['modi', 'modiEntity', 'oper', 'operEntity'].includes(entity))) return [3 /*break*/, 3];
|
|
@@ -797,7 +1053,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
797
1053
|
case 3:
|
|
798
1054
|
result_1 = 0;
|
|
799
1055
|
createInner = function (operation2) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
800
|
-
var _a,
|
|
1056
|
+
var _a, e_4;
|
|
801
1057
|
return tslib_1.__generator(this, function (_b) {
|
|
802
1058
|
switch (_b.label) {
|
|
803
1059
|
case 0:
|
|
@@ -808,7 +1064,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
808
1064
|
result_1 = _a + _b.sent();
|
|
809
1065
|
return [3 /*break*/, 3];
|
|
810
1066
|
case 2:
|
|
811
|
-
|
|
1067
|
+
e_4 = _b.sent();
|
|
812
1068
|
/* 这段代码是处理插入时有重复的行,现在看有问题,等实际需求出现再写
|
|
813
1069
|
if (e instanceof OakCongruentRowExists) {
|
|
814
1070
|
if (option.allowExists) {
|
|
@@ -872,7 +1128,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
872
1128
|
}
|
|
873
1129
|
}
|
|
874
1130
|
} */
|
|
875
|
-
throw
|
|
1131
|
+
throw e_4;
|
|
876
1132
|
case 3: return [2 /*return*/];
|
|
877
1133
|
}
|
|
878
1134
|
});
|
|
@@ -886,11 +1142,11 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
886
1142
|
return [3 /*break*/, 12];
|
|
887
1143
|
case 5:
|
|
888
1144
|
_m.trys.push([5, 10, 11, 12]);
|
|
889
|
-
|
|
1145
|
+
data_2 = tslib_1.__values(data), data_2_1 = data_2.next();
|
|
890
1146
|
_m.label = 6;
|
|
891
1147
|
case 6:
|
|
892
|
-
if (!!
|
|
893
|
-
d =
|
|
1148
|
+
if (!!data_2_1.done) return [3 /*break*/, 9];
|
|
1149
|
+
d = data_2_1.value;
|
|
894
1150
|
createSingleOper = {
|
|
895
1151
|
id: 'any',
|
|
896
1152
|
action: 'create',
|
|
@@ -901,18 +1157,18 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
901
1157
|
_m.sent();
|
|
902
1158
|
_m.label = 8;
|
|
903
1159
|
case 8:
|
|
904
|
-
|
|
1160
|
+
data_2_1 = data_2.next();
|
|
905
1161
|
return [3 /*break*/, 6];
|
|
906
1162
|
case 9: return [3 /*break*/, 12];
|
|
907
1163
|
case 10:
|
|
908
|
-
|
|
909
|
-
|
|
1164
|
+
e_3_1 = _m.sent();
|
|
1165
|
+
e_3 = { error: e_3_1 };
|
|
910
1166
|
return [3 /*break*/, 12];
|
|
911
1167
|
case 11:
|
|
912
1168
|
try {
|
|
913
|
-
if (
|
|
1169
|
+
if (data_2_1 && !data_2_1.done && (_e = data_2.return)) _e.call(data_2);
|
|
914
1170
|
}
|
|
915
|
-
finally { if (
|
|
1171
|
+
finally { if (e_3) throw e_3.error; }
|
|
916
1172
|
return [7 /*endfinally*/];
|
|
917
1173
|
case 12: return [3 /*break*/, 15];
|
|
918
1174
|
case 13: return [4 /*yield*/, createInner(operation)];
|
|
@@ -927,13 +1183,11 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
927
1183
|
d: data,
|
|
928
1184
|
});
|
|
929
1185
|
}
|
|
930
|
-
if (!(!option.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity))) return [3 /*break*/,
|
|
1186
|
+
if (!(!option.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity))) return [3 /*break*/, 21];
|
|
931
1187
|
// 按照框架要求生成Oper和OperEntity这两个内置的对象
|
|
932
1188
|
(0, assert_1.default)(operId);
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
operatorId = _m.sent();
|
|
936
|
-
if (!operatorId) return [3 /*break*/, 22];
|
|
1189
|
+
operatorId = context.getCurrentUserId(true);
|
|
1190
|
+
if (!operatorId) return [3 /*break*/, 21];
|
|
937
1191
|
_f = {
|
|
938
1192
|
id: 'dummy',
|
|
939
1193
|
action: 'create'
|
|
@@ -942,9 +1196,10 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
942
1196
|
id: operId,
|
|
943
1197
|
action: action,
|
|
944
1198
|
data: data,
|
|
945
|
-
operatorId: operatorId
|
|
1199
|
+
operatorId: operatorId,
|
|
1200
|
+
targetEntity: entity
|
|
946
1201
|
};
|
|
947
|
-
if (!(data instanceof Array)) return [3 /*break*/,
|
|
1202
|
+
if (!(data instanceof Array)) return [3 /*break*/, 17];
|
|
948
1203
|
_h = {
|
|
949
1204
|
id: 'dummy',
|
|
950
1205
|
action: 'create'
|
|
@@ -957,31 +1212,31 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
957
1212
|
_a = {};
|
|
958
1213
|
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
|
959
1214
|
case 1: return [2 /*return*/, (_a.id = _b.sent(),
|
|
960
|
-
_a.entity = entity,
|
|
961
1215
|
_a.entityId = ele.id,
|
|
1216
|
+
_a.entity = entity,
|
|
962
1217
|
_a)];
|
|
963
1218
|
}
|
|
964
1219
|
});
|
|
965
1220
|
}); }))];
|
|
966
|
-
case
|
|
1221
|
+
case 16:
|
|
967
1222
|
_b = (_h.data = _m.sent(),
|
|
968
1223
|
_h);
|
|
969
|
-
return [3 /*break*/,
|
|
970
|
-
case
|
|
1224
|
+
return [3 /*break*/, 19];
|
|
1225
|
+
case 17:
|
|
971
1226
|
_j = {
|
|
972
1227
|
id: 'dummy',
|
|
973
1228
|
action: 'create'
|
|
974
1229
|
};
|
|
975
1230
|
_k = {};
|
|
976
1231
|
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
|
977
|
-
case
|
|
1232
|
+
case 18:
|
|
978
1233
|
_b = [(_j.data = (_k.id = _m.sent(),
|
|
979
|
-
_k.entity = entity,
|
|
980
1234
|
_k.entityId = data.id,
|
|
1235
|
+
_k.entity = entity,
|
|
981
1236
|
_k),
|
|
982
1237
|
_j)];
|
|
983
|
-
_m.label =
|
|
984
|
-
case
|
|
1238
|
+
_m.label = 19;
|
|
1239
|
+
case 19:
|
|
985
1240
|
createOper = (_f.data = (_g.operEntity$oper = _b,
|
|
986
1241
|
_g),
|
|
987
1242
|
_f);
|
|
@@ -989,13 +1244,13 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
989
1244
|
dontCollect: true,
|
|
990
1245
|
dontCreateOper: true,
|
|
991
1246
|
})];
|
|
992
|
-
case
|
|
1247
|
+
case 20:
|
|
993
1248
|
_m.sent();
|
|
994
|
-
_m.label =
|
|
995
|
-
case
|
|
996
|
-
case
|
|
1249
|
+
_m.label = 21;
|
|
1250
|
+
case 21: return [2 /*return*/, result_1];
|
|
1251
|
+
case 22:
|
|
997
1252
|
ids_1 = (0, filter_2.getRelevantIds)(filter);
|
|
998
|
-
if (!(ids_1.length === 0)) return [3 /*break*/,
|
|
1253
|
+
if (!(ids_1.length === 0)) return [3 /*break*/, 24];
|
|
999
1254
|
selection = {
|
|
1000
1255
|
data: {
|
|
1001
1256
|
id: 1,
|
|
@@ -1007,17 +1262,17 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1007
1262
|
return [4 /*yield*/, this.selectAbjointRowAsync(entity, selection, context, {
|
|
1008
1263
|
dontCollect: true,
|
|
1009
1264
|
})];
|
|
1010
|
-
case
|
|
1265
|
+
case 23:
|
|
1011
1266
|
rows = _m.sent();
|
|
1012
1267
|
ids_1.push.apply(ids_1, tslib_1.__spreadArray([], tslib_1.__read((rows.map(function (ele) { return ele.id; }))), false));
|
|
1013
|
-
_m.label =
|
|
1014
|
-
case
|
|
1268
|
+
_m.label = 24;
|
|
1269
|
+
case 24:
|
|
1015
1270
|
if (data) {
|
|
1016
1271
|
this.preProcessDataUpdated(data);
|
|
1017
1272
|
}
|
|
1018
|
-
if (!(option.modiParentEntity && !['modi', 'modiEntity'].includes(entity))) return [3 /*break*/,
|
|
1273
|
+
if (!(option.modiParentEntity && !['modi', 'modiEntity'].includes(entity))) return [3 /*break*/, 30];
|
|
1019
1274
|
modiUpsert = void 0;
|
|
1020
|
-
if (!(action !== 'remove')) return [3 /*break*/,
|
|
1275
|
+
if (!(action !== 'remove')) return [3 /*break*/, 26];
|
|
1021
1276
|
return [4 /*yield*/, this.selectAbjointRowAsync('modi', {
|
|
1022
1277
|
data: {
|
|
1023
1278
|
id: 1,
|
|
@@ -1048,7 +1303,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1048
1303
|
indexFrom: 0,
|
|
1049
1304
|
count: 1,
|
|
1050
1305
|
}, context, option)];
|
|
1051
|
-
case
|
|
1306
|
+
case 25:
|
|
1052
1307
|
upsertModis = _m.sent();
|
|
1053
1308
|
if (upsertModis.length > 0) {
|
|
1054
1309
|
_c = upsertModis[0], originData = _c.data, originId = _c.id;
|
|
@@ -1063,9 +1318,9 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1063
1318
|
}
|
|
1064
1319
|
};
|
|
1065
1320
|
}
|
|
1066
|
-
_m.label =
|
|
1067
|
-
case
|
|
1068
|
-
if (!!modiUpsert) return [3 /*break*/,
|
|
1321
|
+
_m.label = 26;
|
|
1322
|
+
case 26:
|
|
1323
|
+
if (!!modiUpsert) return [3 /*break*/, 28];
|
|
1069
1324
|
modiUpsert = {
|
|
1070
1325
|
id: 'dummy',
|
|
1071
1326
|
action: 'create',
|
|
@@ -1080,7 +1335,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1080
1335
|
filter: filter,
|
|
1081
1336
|
},
|
|
1082
1337
|
};
|
|
1083
|
-
if (!(ids_1.length > 0)) return [3 /*break*/,
|
|
1338
|
+
if (!(ids_1.length > 0)) return [3 /*break*/, 28];
|
|
1084
1339
|
_d = modiUpsert.data;
|
|
1085
1340
|
_l = {
|
|
1086
1341
|
id: 'dummy',
|
|
@@ -1100,15 +1355,15 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1100
1355
|
}
|
|
1101
1356
|
});
|
|
1102
1357
|
}); }))];
|
|
1103
|
-
case
|
|
1358
|
+
case 27:
|
|
1104
1359
|
_d.modiEntity$modi = (_l.data = _m.sent(),
|
|
1105
1360
|
_l);
|
|
1106
|
-
_m.label =
|
|
1107
|
-
case
|
|
1108
|
-
case
|
|
1361
|
+
_m.label = 28;
|
|
1362
|
+
case 28: return [4 /*yield*/, this.cascadeUpdateAsync('modi', modiUpsert, context, option)];
|
|
1363
|
+
case 29:
|
|
1109
1364
|
_m.sent();
|
|
1110
1365
|
return [2 /*return*/, 1];
|
|
1111
|
-
case
|
|
1366
|
+
case 30:
|
|
1112
1367
|
createOper = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
1113
1368
|
var createOper_1;
|
|
1114
1369
|
var _a, _b, _c;
|
|
@@ -1126,7 +1381,8 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1126
1381
|
_b = {
|
|
1127
1382
|
id: operId,
|
|
1128
1383
|
action: action,
|
|
1129
|
-
data: data
|
|
1384
|
+
data: data,
|
|
1385
|
+
targetEntity: entity
|
|
1130
1386
|
};
|
|
1131
1387
|
_c = {
|
|
1132
1388
|
id: 'dummy',
|
|
@@ -1140,8 +1396,8 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1140
1396
|
_a = {};
|
|
1141
1397
|
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
|
1142
1398
|
case 1: return [2 /*return*/, (_a.id = _b.sent(),
|
|
1143
|
-
_a.entity = entity,
|
|
1144
1399
|
_a.entityId = ele,
|
|
1400
|
+
_a.entity = entity,
|
|
1145
1401
|
_a)];
|
|
1146
1402
|
}
|
|
1147
1403
|
});
|
|
@@ -1162,7 +1418,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1162
1418
|
}
|
|
1163
1419
|
});
|
|
1164
1420
|
}); };
|
|
1165
|
-
if (!(action === 'remove')) return [3 /*break*/,
|
|
1421
|
+
if (!(action === 'remove')) return [3 /*break*/, 31];
|
|
1166
1422
|
if (!option.dontCollect) {
|
|
1167
1423
|
context.opRecords.push({
|
|
1168
1424
|
a: 'r',
|
|
@@ -1174,10 +1430,10 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1174
1430
|
},
|
|
1175
1431
|
});
|
|
1176
1432
|
}
|
|
1177
|
-
return [3 /*break*/,
|
|
1178
|
-
case
|
|
1433
|
+
return [3 /*break*/, 35];
|
|
1434
|
+
case 31:
|
|
1179
1435
|
updateAttrCount = Object.keys(data).length;
|
|
1180
|
-
if (!(updateAttrCount > 0)) return [3 /*break*/,
|
|
1436
|
+
if (!(updateAttrCount > 0)) return [3 /*break*/, 32];
|
|
1181
1437
|
// 优化一下,如果不更新任何属性,则不实际执行
|
|
1182
1438
|
Object.assign(data, {
|
|
1183
1439
|
$$updateAt$$: now,
|
|
@@ -1194,21 +1450,21 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1194
1450
|
},
|
|
1195
1451
|
});
|
|
1196
1452
|
}
|
|
1197
|
-
return [3 /*break*/,
|
|
1198
|
-
case
|
|
1199
|
-
if (!(action !== 'update')) return [3 /*break*/,
|
|
1453
|
+
return [3 /*break*/, 35];
|
|
1454
|
+
case 32:
|
|
1455
|
+
if (!(action !== 'update')) return [3 /*break*/, 34];
|
|
1200
1456
|
// 如果不是update动作而是用户自定义的动作,这里还是要记录oper
|
|
1201
1457
|
return [4 /*yield*/, createOper()];
|
|
1202
|
-
case
|
|
1458
|
+
case 33:
|
|
1203
1459
|
// 如果不是update动作而是用户自定义的动作,这里还是要记录oper
|
|
1204
1460
|
_m.sent();
|
|
1205
1461
|
return [2 /*return*/, 0];
|
|
1206
|
-
case
|
|
1207
|
-
case
|
|
1208
|
-
case
|
|
1462
|
+
case 34: return [2 /*return*/, 0];
|
|
1463
|
+
case 35: return [4 /*yield*/, this.updateAbjointRowAsync(entity, operation, context, option)];
|
|
1464
|
+
case 36:
|
|
1209
1465
|
result = _m.sent();
|
|
1210
1466
|
return [4 /*yield*/, createOper()];
|
|
1211
|
-
case
|
|
1467
|
+
case 37:
|
|
1212
1468
|
_m.sent();
|
|
1213
1469
|
return [2 /*return*/, result];
|
|
1214
1470
|
}
|
|
@@ -1216,7 +1472,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1216
1472
|
});
|
|
1217
1473
|
};
|
|
1218
1474
|
CascadeStore.prototype.doUpdateSingleRow = function (entity, operation, context, option) {
|
|
1219
|
-
var
|
|
1475
|
+
var e_5, _a;
|
|
1220
1476
|
var _this = this;
|
|
1221
1477
|
var data = operation.data, action = operation.action, operId = operation.id, filter = operation.filter;
|
|
1222
1478
|
var now = Date.now();
|
|
@@ -1239,8 +1495,8 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1239
1495
|
}
|
|
1240
1496
|
else {
|
|
1241
1497
|
try {
|
|
1242
|
-
for (var
|
|
1243
|
-
var d =
|
|
1498
|
+
for (var data_3 = tslib_1.__values(data), data_3_1 = data_3.next(); !data_3_1.done; data_3_1 = data_3.next()) {
|
|
1499
|
+
var d = data_3_1.value;
|
|
1244
1500
|
var createSingleOper = {
|
|
1245
1501
|
id: 'any',
|
|
1246
1502
|
action: 'create',
|
|
@@ -1249,12 +1505,12 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1249
1505
|
createInner(createSingleOper);
|
|
1250
1506
|
}
|
|
1251
1507
|
}
|
|
1252
|
-
catch (
|
|
1508
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1253
1509
|
finally {
|
|
1254
1510
|
try {
|
|
1255
|
-
if (
|
|
1511
|
+
if (data_3_1 && !data_3_1.done && (_a = data_3.return)) _a.call(data_3);
|
|
1256
1512
|
}
|
|
1257
|
-
finally { if (
|
|
1513
|
+
finally { if (e_5) throw e_5.error; }
|
|
1258
1514
|
}
|
|
1259
1515
|
}
|
|
1260
1516
|
}
|
|
@@ -1284,8 +1540,8 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1284
1540
|
}
|
|
1285
1541
|
};
|
|
1286
1542
|
CascadeStore.prototype.cascadeUpdate = function (entity, operation, context, option) {
|
|
1287
|
-
var
|
|
1288
|
-
|
|
1543
|
+
var e_6, _a, e_7, _b, e_8, _c;
|
|
1544
|
+
this.reinforceOperation(entity, operation);
|
|
1289
1545
|
var action = operation.action, data = operation.data, filter = operation.filter, id = operation.id;
|
|
1290
1546
|
var opData;
|
|
1291
1547
|
var wholeBeforeFns = [];
|
|
@@ -1294,20 +1550,20 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1294
1550
|
if (['create', 'create-l'].includes(action) && data instanceof Array) {
|
|
1295
1551
|
opData = [];
|
|
1296
1552
|
try {
|
|
1297
|
-
for (var
|
|
1298
|
-
var d =
|
|
1553
|
+
for (var data_4 = tslib_1.__values(data), data_4_1 = data_4.next(); !data_4_1.done; data_4_1 = data_4.next()) {
|
|
1554
|
+
var d = data_4_1.value;
|
|
1299
1555
|
var _d = this.destructCascadeUpdate(entity, action, d, context, option, this.cascadeUpdate), od = _d.data, beforeFns = _d.beforeFns, afterFns = _d.afterFns;
|
|
1300
1556
|
opData.push(od);
|
|
1301
1557
|
wholeBeforeFns.push.apply(wholeBeforeFns, tslib_1.__spreadArray([], tslib_1.__read(beforeFns), false));
|
|
1302
1558
|
wholeAfterFns.push.apply(wholeAfterFns, tslib_1.__spreadArray([], tslib_1.__read(afterFns), false));
|
|
1303
1559
|
}
|
|
1304
1560
|
}
|
|
1305
|
-
catch (
|
|
1561
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1306
1562
|
finally {
|
|
1307
1563
|
try {
|
|
1308
|
-
if (
|
|
1564
|
+
if (data_4_1 && !data_4_1.done && (_a = data_4.return)) _a.call(data_4);
|
|
1309
1565
|
}
|
|
1310
|
-
finally { if (
|
|
1566
|
+
finally { if (e_6) throw e_6.error; }
|
|
1311
1567
|
}
|
|
1312
1568
|
}
|
|
1313
1569
|
else {
|
|
@@ -1325,12 +1581,12 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1325
1581
|
before_1();
|
|
1326
1582
|
}
|
|
1327
1583
|
}
|
|
1328
|
-
catch (
|
|
1584
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
1329
1585
|
finally {
|
|
1330
1586
|
try {
|
|
1331
1587
|
if (wholeBeforeFns_1_1 && !wholeBeforeFns_1_1.done && (_b = wholeBeforeFns_1.return)) _b.call(wholeBeforeFns_1);
|
|
1332
1588
|
}
|
|
1333
|
-
finally { if (
|
|
1589
|
+
finally { if (e_7) throw e_7.error; }
|
|
1334
1590
|
}
|
|
1335
1591
|
var count = this.doUpdateSingleRow(entity, operation2, context, option);
|
|
1336
1592
|
try {
|
|
@@ -1339,12 +1595,12 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1339
1595
|
after_1();
|
|
1340
1596
|
}
|
|
1341
1597
|
}
|
|
1342
|
-
catch (
|
|
1598
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
1343
1599
|
finally {
|
|
1344
1600
|
try {
|
|
1345
1601
|
if (wholeAfterFns_1_1 && !wholeAfterFns_1_1.done && (_c = wholeAfterFns_1.return)) _c.call(wholeAfterFns_1);
|
|
1346
1602
|
}
|
|
1347
|
-
finally { if (
|
|
1603
|
+
finally { if (e_8) throw e_8.error; }
|
|
1348
1604
|
}
|
|
1349
1605
|
return result;
|
|
1350
1606
|
};
|
|
@@ -1357,12 +1613,12 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1357
1613
|
*/
|
|
1358
1614
|
CascadeStore.prototype.cascadeUpdateAsync = function (entity, operation, context, option) {
|
|
1359
1615
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1360
|
-
var action, data, filter, id, opData, wholeBeforeFns, wholeAfterFns, result,
|
|
1361
|
-
var
|
|
1616
|
+
var action, data, filter, id, opData, wholeBeforeFns, wholeAfterFns, result, data_5, data_5_1, d, _a, od, beforeFns, afterFns, _b, od, beforeFns, afterFns, operation2, wholeBeforeFns_2, wholeBeforeFns_2_1, before_2, e_9_1, count, wholeAfterFns_2, wholeAfterFns_2_1, after_2, e_10_1;
|
|
1617
|
+
var e_11, _c, e_9, _d, _e, _f, e_10, _g;
|
|
1362
1618
|
return tslib_1.__generator(this, function (_h) {
|
|
1363
1619
|
switch (_h.label) {
|
|
1364
1620
|
case 0:
|
|
1365
|
-
|
|
1621
|
+
this.reinforceOperation(entity, operation);
|
|
1366
1622
|
action = operation.action, data = operation.data, filter = operation.filter, id = operation.id;
|
|
1367
1623
|
wholeBeforeFns = [];
|
|
1368
1624
|
wholeAfterFns = [];
|
|
@@ -1370,20 +1626,20 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1370
1626
|
if (['create', 'create-l'].includes(action) && data instanceof Array) {
|
|
1371
1627
|
opData = [];
|
|
1372
1628
|
try {
|
|
1373
|
-
for (
|
|
1374
|
-
d =
|
|
1629
|
+
for (data_5 = tslib_1.__values(data), data_5_1 = data_5.next(); !data_5_1.done; data_5_1 = data_5.next()) {
|
|
1630
|
+
d = data_5_1.value;
|
|
1375
1631
|
_a = this.destructCascadeUpdate(entity, action, d, context, option, this.cascadeUpdateAsync), od = _a.data, beforeFns = _a.beforeFns, afterFns = _a.afterFns;
|
|
1376
1632
|
opData.push(od);
|
|
1377
1633
|
wholeBeforeFns.push.apply(wholeBeforeFns, tslib_1.__spreadArray([], tslib_1.__read(beforeFns), false));
|
|
1378
1634
|
wholeAfterFns.push.apply(wholeAfterFns, tslib_1.__spreadArray([], tslib_1.__read(afterFns), false));
|
|
1379
1635
|
}
|
|
1380
1636
|
}
|
|
1381
|
-
catch (
|
|
1637
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1382
1638
|
finally {
|
|
1383
1639
|
try {
|
|
1384
|
-
if (
|
|
1640
|
+
if (data_5_1 && !data_5_1.done && (_c = data_5.return)) _c.call(data_5);
|
|
1385
1641
|
}
|
|
1386
|
-
finally { if (
|
|
1642
|
+
finally { if (e_11) throw e_11.error; }
|
|
1387
1643
|
}
|
|
1388
1644
|
}
|
|
1389
1645
|
else {
|
|
@@ -1412,14 +1668,14 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1412
1668
|
return [3 /*break*/, 2];
|
|
1413
1669
|
case 5: return [3 /*break*/, 8];
|
|
1414
1670
|
case 6:
|
|
1415
|
-
|
|
1416
|
-
|
|
1671
|
+
e_9_1 = _h.sent();
|
|
1672
|
+
e_9 = { error: e_9_1 };
|
|
1417
1673
|
return [3 /*break*/, 8];
|
|
1418
1674
|
case 7:
|
|
1419
1675
|
try {
|
|
1420
1676
|
if (wholeBeforeFns_2_1 && !wholeBeforeFns_2_1.done && (_d = wholeBeforeFns_2.return)) _d.call(wholeBeforeFns_2);
|
|
1421
1677
|
}
|
|
1422
|
-
finally { if (
|
|
1678
|
+
finally { if (e_9) throw e_9.error; }
|
|
1423
1679
|
return [7 /*endfinally*/];
|
|
1424
1680
|
case 8: return [4 /*yield*/, this.doUpdateSingleRowAsync(entity, operation2, context, option)];
|
|
1425
1681
|
case 9:
|
|
@@ -1446,14 +1702,14 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1446
1702
|
return [3 /*break*/, 11];
|
|
1447
1703
|
case 14: return [3 /*break*/, 17];
|
|
1448
1704
|
case 15:
|
|
1449
|
-
|
|
1450
|
-
|
|
1705
|
+
e_10_1 = _h.sent();
|
|
1706
|
+
e_10 = { error: e_10_1 };
|
|
1451
1707
|
return [3 /*break*/, 17];
|
|
1452
1708
|
case 16:
|
|
1453
1709
|
try {
|
|
1454
1710
|
if (wholeAfterFns_2_1 && !wholeAfterFns_2_1.done && (_g = wholeAfterFns_2.return)) _g.call(wholeAfterFns_2);
|
|
1455
1711
|
}
|
|
1456
|
-
finally { if (
|
|
1712
|
+
finally { if (e_10) throw e_10.error; }
|
|
1457
1713
|
return [7 /*endfinally*/];
|
|
1458
1714
|
case 17: return [2 /*return*/, result];
|
|
1459
1715
|
}
|
|
@@ -1461,7 +1717,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1461
1717
|
});
|
|
1462
1718
|
};
|
|
1463
1719
|
CascadeStore.prototype.cascadeSelect = function (entity, selection, context, option) {
|
|
1464
|
-
|
|
1720
|
+
this.reinforceSelection(entity, selection);
|
|
1465
1721
|
var data = selection.data, filter = selection.filter, indexFrom = selection.indexFrom, count = selection.count, sorter = selection.sorter;
|
|
1466
1722
|
var _a = this.destructCascadeSelect(entity, data, context, this.cascadeSelect, this.aggregateSync, option), projection = _a.projection, cascadeSelectionFns = _a.cascadeSelectionFns;
|
|
1467
1723
|
var rows = this.selectAbjointRow(entity, {
|
|
@@ -1544,11 +1800,11 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1544
1800
|
var id = row.id;
|
|
1545
1801
|
if (!entityBranch_1[id]) {
|
|
1546
1802
|
Object.assign(entityBranch_1, (_a = {},
|
|
1547
|
-
_a[id] = row,
|
|
1803
|
+
_a[id] = (0, lodash_1.cloneDeep)(row),
|
|
1548
1804
|
_a));
|
|
1549
1805
|
}
|
|
1550
1806
|
else {
|
|
1551
|
-
Object.assign(entityBranch_1[id], row);
|
|
1807
|
+
Object.assign(entityBranch_1[id], (0, lodash_1.cloneDeep)(row));
|
|
1552
1808
|
}
|
|
1553
1809
|
}
|
|
1554
1810
|
});
|
|
@@ -1568,7 +1824,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1568
1824
|
if (row) {
|
|
1569
1825
|
var id = row.id;
|
|
1570
1826
|
Object.assign(entityBranch, (_a = {},
|
|
1571
|
-
_a[id] = row,
|
|
1827
|
+
_a[id] = (0, lodash_1.cloneDeep)(row),
|
|
1572
1828
|
_a));
|
|
1573
1829
|
}
|
|
1574
1830
|
});
|
|
@@ -1583,7 +1839,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1583
1839
|
return tslib_1.__generator(this, function (_b) {
|
|
1584
1840
|
switch (_b.label) {
|
|
1585
1841
|
case 0:
|
|
1586
|
-
|
|
1842
|
+
this.reinforceSelection(entity, selection);
|
|
1587
1843
|
data = selection.data, filter = selection.filter, indexFrom = selection.indexFrom, count = selection.count, sorter = selection.sorter;
|
|
1588
1844
|
_a = this.destructCascadeSelect(entity, data, context, this.cascadeSelectAsync, this.aggregateAsync, option), projection = _a.projection, cascadeSelectionFns = _a.cascadeSelectionFns;
|
|
1589
1845
|
return [4 /*yield*/, this.selectAbjointRowAsync(entity, {
|
|
@@ -1601,7 +1857,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1601
1857
|
if (!(cascadeSelectionFns.length > 0)) return [3 /*break*/, 3];
|
|
1602
1858
|
ruException_2 = [];
|
|
1603
1859
|
return [4 /*yield*/, Promise.all(cascadeSelectionFns.map(function (ele) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
1604
|
-
var
|
|
1860
|
+
var e_12, rows_2;
|
|
1605
1861
|
return tslib_1.__generator(this, function (_a) {
|
|
1606
1862
|
switch (_a.label) {
|
|
1607
1863
|
case 0:
|
|
@@ -1611,13 +1867,13 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1611
1867
|
_a.sent();
|
|
1612
1868
|
return [3 /*break*/, 3];
|
|
1613
1869
|
case 2:
|
|
1614
|
-
|
|
1615
|
-
if (
|
|
1616
|
-
rows_2 =
|
|
1870
|
+
e_12 = _a.sent();
|
|
1871
|
+
if (e_12 instanceof types_1.OakRowUnexistedException) {
|
|
1872
|
+
rows_2 = e_12.getRows();
|
|
1617
1873
|
ruException_2.push.apply(ruException_2, tslib_1.__spreadArray([], tslib_1.__read(rows_2), false));
|
|
1618
1874
|
}
|
|
1619
1875
|
else {
|
|
1620
|
-
throw
|
|
1876
|
+
throw e_12;
|
|
1621
1877
|
}
|
|
1622
1878
|
return [3 /*break*/, 3];
|
|
1623
1879
|
case 3: return [2 /*return*/];
|