oak-domain 2.4.4 → 2.5.2
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/actions/relation.d.ts +3 -3
- package/lib/actions/relation.js +1 -1
- package/lib/base-app-domain/ActionDefDict.d.ts +4 -1
- package/lib/base-app-domain/ActionDefDict.js +3 -1
- package/lib/base-app-domain/EntityDict.d.ts +2 -0
- package/lib/base-app-domain/Modi/Action.d.ts +4 -4
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +31 -4
- package/lib/base-app-domain/ModiEntity/Storage.js +1 -1
- package/lib/base-app-domain/OperEntity/Schema.d.ts +31 -4
- package/lib/base-app-domain/OperEntity/Storage.js +1 -1
- package/lib/base-app-domain/Storage.js +3 -1
- package/lib/base-app-domain/User/Action.d.ts +10 -0
- package/lib/base-app-domain/User/Action.js +12 -0
- package/lib/base-app-domain/User/Schema.d.ts +60 -8
- package/lib/base-app-domain/User/Storage.js +12 -1
- package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +121 -0
- package/lib/base-app-domain/UserEntityGrant/Schema.js +2 -0
- package/lib/base-app-domain/UserEntityGrant/Storage.d.ts +3 -0
- package/lib/base-app-domain/UserEntityGrant/Storage.js +28 -0
- package/lib/base-app-domain/_SubQuery.d.ts +8 -0
- package/lib/checkers/index.js +1 -1
- package/lib/compiler/schemalBuilder.js +50 -6
- package/lib/entities/User.d.ts +1 -0
- package/lib/entities/User.js +16 -0
- package/lib/entities/UserEntityGrant.d.ts +7 -0
- package/lib/entities/UserEntityGrant.js +12 -0
- package/lib/store/CascadeStore.js +121 -108
- package/lib/store/checker.d.ts +1 -1
- package/lib/store/checker.js +151 -9
- package/lib/store/modi.js +33 -15
- package/lib/types/Action.d.ts +3 -1
- package/lib/types/Auth.d.ts +4 -1
- package/lib/types/Trigger.d.ts +1 -0
- package/lib/types/Trigger.js +2 -1
- package/package.json +1 -1
- package/src/entities/User.ts +26 -1
- package/src/entities/UserEntityGrant.ts +24 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.desc = void 0;
|
|
4
|
+
var action_1 = require("../../actions/action");
|
|
5
|
+
exports.desc = {
|
|
6
|
+
attributes: {
|
|
7
|
+
entity: {
|
|
8
|
+
type: "varchar",
|
|
9
|
+
params: {
|
|
10
|
+
length: 32
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
entityId: {
|
|
14
|
+
type: "varchar",
|
|
15
|
+
params: {
|
|
16
|
+
length: 64
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
relation: {
|
|
20
|
+
type: "varchar",
|
|
21
|
+
params: {
|
|
22
|
+
length: 32
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
actionType: "crud",
|
|
27
|
+
actions: action_1.genericActions
|
|
28
|
+
};
|
|
@@ -3,6 +3,7 @@ import * as ModiEntity from "./ModiEntity/Schema";
|
|
|
3
3
|
import * as Oper from "./Oper/Schema";
|
|
4
4
|
import * as OperEntity from "./OperEntity/Schema";
|
|
5
5
|
import * as User from "./User/Schema";
|
|
6
|
+
import * as UserEntityGrant from "./UserEntityGrant/Schema";
|
|
6
7
|
export declare type ModiIdSubQuery = {
|
|
7
8
|
[K in "$in" | "$nin"]?: (ModiEntity.ModiIdSubQuery & {
|
|
8
9
|
entity: "modiEntity";
|
|
@@ -32,5 +33,12 @@ export declare type UserIdSubQuery = {
|
|
|
32
33
|
entity: "oper";
|
|
33
34
|
}) | (User.UserIdSubQuery & {
|
|
34
35
|
entity: "user";
|
|
36
|
+
}) | (User.UserIdSubQuery & {
|
|
37
|
+
entity: "user";
|
|
38
|
+
}) | any;
|
|
39
|
+
};
|
|
40
|
+
export declare type UserEntityGrantIdSubQuery = {
|
|
41
|
+
[K in "$in" | "$nin"]?: (UserEntityGrant.UserEntityGrantIdSubQuery & {
|
|
42
|
+
entity: "userEntityGrant";
|
|
35
43
|
}) | any;
|
|
36
44
|
};
|
package/lib/checkers/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var modi_1 = require("../store/modi");
|
|
|
7
7
|
function createDynamicCheckers(schema, authDict) {
|
|
8
8
|
var checkers = [];
|
|
9
9
|
checkers.push.apply(checkers, tslib_1.__spreadArray([], tslib_1.__read((0, modi_1.createModiRelatedCheckers)(schema)), false));
|
|
10
|
-
|
|
10
|
+
checkers.push.apply(checkers, tslib_1.__spreadArray([], tslib_1.__read((0, checker_1.createRemoveCheckers)(schema, authDict)), false));
|
|
11
11
|
if (authDict) {
|
|
12
12
|
checkers.push.apply(checkers, tslib_1.__spreadArray([], tslib_1.__read((0, checker_1.createAuthCheckers)(schema, authDict)), false));
|
|
13
13
|
}
|
|
@@ -51,6 +51,20 @@ function addRelationship(many, one, key, notNull) {
|
|
|
51
51
|
_b));
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* 对relationship去重。一旦发生对象重定义这里就有可能重复
|
|
56
|
+
*/
|
|
57
|
+
function uniqRelationships() {
|
|
58
|
+
for (var entity in ManyToOne) {
|
|
59
|
+
ManyToOne[entity] = (0, lodash_1.uniqBy)(ManyToOne[entity], function (ele) { return "".concat(ele[0], "-").concat(ele[1]); });
|
|
60
|
+
}
|
|
61
|
+
for (var entity in OneToMany) {
|
|
62
|
+
OneToMany[entity] = (0, lodash_1.uniqBy)(OneToMany[entity], function (ele) { return "".concat(ele[0], "-").concat(ele[1]); });
|
|
63
|
+
}
|
|
64
|
+
for (var entity in ReversePointerRelations) {
|
|
65
|
+
OneToMany[entity] = (0, lodash_1.uniq)(OneToMany[entity]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
54
68
|
function createForeignRef(entity, foreignKey, ref) {
|
|
55
69
|
if (entity === foreignKey) {
|
|
56
70
|
return factory.createIdentifier(ref);
|
|
@@ -317,9 +331,10 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
317
331
|
var sourceFile = program.getSourceFile(fullPath);
|
|
318
332
|
var moduleName = filename.split('.')[0];
|
|
319
333
|
if (Schema.hasOwnProperty(moduleName)) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
334
|
+
delete ActionAsts[moduleName];
|
|
335
|
+
delete SchemaAsts[moduleName];
|
|
336
|
+
// removeFromRelationShip(moduleName);
|
|
337
|
+
console.warn("\u51FA\u73B0\u4E86\u540C\u540D\u7684Entity\u5B9A\u4E49\u300C".concat(moduleName, "\u300D\uFF0C\u5C06\u4F7F\u7528").concat(fullPath, "\u53D6\u4EE3\u6389\u9ED8\u8BA4\u5BF9\u8C61\uFF0C\u8BF7\u68C0\u67E5\u65B0\u7684\u5BF9\u8C61\u7ED3\u6784\u53CA\u76F8\u5173\u5E38\u91CF\u5B9A\u4E49\u4E0E\u539F\u6709\u7684\u517C\u5BB9\uFF0C\u5426\u5219\u539F\u6709\u5BF9\u8C61\u7684\u76F8\u5173\u903B\u8F91\u4F1A\u51FA\u73B0\u4E0D\u53EF\u77E5\u5F02\u5E38"));
|
|
323
338
|
}
|
|
324
339
|
var referencedSchemas = [];
|
|
325
340
|
var schemaAttrs = [];
|
|
@@ -340,7 +355,7 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
340
355
|
// let relationHierarchy: ts.ObjectLiteralExpression | undefined = undefined;
|
|
341
356
|
// let reverseCascadeRelationHierarchy: ts.ObjectLiteralExpression | undefined = undefined;
|
|
342
357
|
ts.forEachChild(sourceFile, function (node) {
|
|
343
|
-
var _a, _b, _c, _d;
|
|
358
|
+
var _a, _b, _c, _d, _e;
|
|
344
359
|
if (ts.isImportDeclaration(node)) {
|
|
345
360
|
var entityImported = getEntityImported(node);
|
|
346
361
|
if (entityImported) {
|
|
@@ -389,7 +404,9 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
389
404
|
&& referencedSchemas.includes(typeArguments[0].typeName.text), "\u300C".concat(filename, "\u300D\u975E\u6CD5\u7684\u5C5E\u6027\u5B9A\u4E49\u300C").concat(attrName, "\u300D"));
|
|
390
405
|
var reverseEntity = typeArguments[0].typeName.text;
|
|
391
406
|
if (ReversePointerRelations[reverseEntity]) {
|
|
392
|
-
ReversePointerRelations[reverseEntity].
|
|
407
|
+
if (!ReversePointerRelations[reverseEntity].includes(moduleName)) {
|
|
408
|
+
ReversePointerRelations[reverseEntity].push(moduleName);
|
|
409
|
+
}
|
|
393
410
|
}
|
|
394
411
|
else {
|
|
395
412
|
(0, lodash_1.assign)(ReversePointerRelations, (_a = {},
|
|
@@ -520,6 +537,9 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
520
537
|
if (hasRelationDef || moduleName === 'User') {
|
|
521
538
|
actionDefNodes.push(factory.createTypeReferenceNode('RelationAction', undefined));
|
|
522
539
|
}
|
|
540
|
+
if (process.env.COMPLING_AS_LIB) {
|
|
541
|
+
actionDefNodes.push(factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));
|
|
542
|
+
}
|
|
523
543
|
pushStatementIntoActionAst(moduleName, factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("Action"), undefined, factory.createUnionTypeNode(actionDefNodes)), sourceFile);
|
|
524
544
|
dealWithActions(moduleName, filename, node.type, program, sourceFile, !!hasRelationDef || moduleName === 'User');
|
|
525
545
|
}
|
|
@@ -558,12 +578,35 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
558
578
|
_d));
|
|
559
579
|
addRelationship(relationEntityName, 'User', 'user', true);
|
|
560
580
|
addRelationship(relationEntityName, moduleName, entityLc, true);
|
|
581
|
+
// 对UserEntityGrant对象,建立相应的反指关系
|
|
582
|
+
if (ReversePointerRelations['UserEntityGrant']) {
|
|
583
|
+
if (!ReversePointerRelations['UserEntityGrant'].includes(moduleName)) {
|
|
584
|
+
ReversePointerRelations['UserEntityGrant'].push(moduleName);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
(0, lodash_1.assign)(ReversePointerRelations, (_e = {},
|
|
589
|
+
_e['UserEntityGrant'] = [moduleName],
|
|
590
|
+
_e));
|
|
591
|
+
}
|
|
561
592
|
hasRelationDef = node;
|
|
562
593
|
}
|
|
563
594
|
else if (node.name.text.endsWith('Action') || node.name.text.endsWith('State')) {
|
|
564
595
|
(0, assert_1.default)(!localeDef, "\u3010".concat(filename, "\u3011locale\u5B9A\u4E49\u987B\u5728Action/State\u4E4B\u540E"));
|
|
565
596
|
hasActionOrStateDef = true;
|
|
566
|
-
|
|
597
|
+
var type = node.type;
|
|
598
|
+
if (ts.isUnionTypeNode(type)) {
|
|
599
|
+
pushStatementIntoActionAst(moduleName, factory.updateTypeAliasDeclaration(node, node.decorators, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], node.name, node.typeParameters, process.env.COMPLING_AS_LIB ? factory.createUnionTypeNode(tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(type.types), false), [
|
|
600
|
+
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
|
|
601
|
+
], false)) : type), sourceFile);
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
(0, assert_1.default)(ts.isLiteralTypeNode(type) || ts.isTypeReferenceNode(type), "".concat(moduleName, " - ").concat(node.name));
|
|
605
|
+
pushStatementIntoActionAst(moduleName, factory.updateTypeAliasDeclaration(node, node.decorators, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], node.name, node.typeParameters, process.env.COMPLING_AS_LIB ? factory.createUnionTypeNode([
|
|
606
|
+
type,
|
|
607
|
+
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
|
|
608
|
+
]) : type), sourceFile);
|
|
609
|
+
}
|
|
567
610
|
}
|
|
568
611
|
else if (beforeSchema) {
|
|
569
612
|
// 本地规定的一些形状定义,直接使用
|
|
@@ -3291,6 +3334,7 @@ function analyzeEntities(inputDir, relativePath) {
|
|
|
3291
3334
|
analyzeEntity(filename, inputDir, program, relativePath);
|
|
3292
3335
|
});
|
|
3293
3336
|
analyzeInModi();
|
|
3337
|
+
uniqRelationships();
|
|
3294
3338
|
}
|
|
3295
3339
|
exports.analyzeEntities = analyzeEntities;
|
|
3296
3340
|
function buildSchema(outputDir) {
|
package/lib/entities/User.d.ts
CHANGED
package/lib/entities/User.js
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
;
|
|
4
|
+
var UserActionDef = {
|
|
5
|
+
stm: {
|
|
6
|
+
mergeTo: ['normal', 'merged'],
|
|
7
|
+
},
|
|
8
|
+
};
|
|
4
9
|
var locale = {
|
|
5
10
|
zh_CN: {
|
|
6
11
|
attr: {
|
|
7
12
|
name: '姓名',
|
|
8
13
|
nickname: '昵称',
|
|
9
14
|
password: '密码',
|
|
15
|
+
ref: '指向用户',
|
|
16
|
+
userState: '状态',
|
|
17
|
+
},
|
|
18
|
+
action: {
|
|
19
|
+
mergeTo: '合并',
|
|
10
20
|
},
|
|
21
|
+
v: {
|
|
22
|
+
userState: {
|
|
23
|
+
normal: '正常',
|
|
24
|
+
merged: '已被合并',
|
|
25
|
+
},
|
|
26
|
+
}
|
|
11
27
|
},
|
|
12
28
|
};
|
|
@@ -100,20 +100,27 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
|
-
var entityIds = (0, lodash_1.uniq)(result.filter(function (ele) { return ele.entity === attr; }).map(function (ele) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
var entityIds = (0, lodash_1.uniq)(result.filter(function (ele) { return ele.entity === attr; }).map(function (ele) {
|
|
104
|
+
(0, assert_1.default)(ele.entityId !== null);
|
|
105
|
+
return ele.entityId;
|
|
106
|
+
}));
|
|
107
|
+
if (entityIds.length > 0) {
|
|
108
|
+
var subRows = cascadeSelectFn.call(_this, attr, {
|
|
109
|
+
data: projection2[attr],
|
|
110
|
+
filter: {
|
|
111
|
+
id: {
|
|
112
|
+
$in: entityIds
|
|
113
|
+
},
|
|
109
114
|
},
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
}, context, option);
|
|
116
|
+
if (subRows instanceof Promise) {
|
|
117
|
+
return subRows.then(function (subRowss) { return dealWithSubRows(subRowss); });
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
dealWithSubRows(subRows);
|
|
121
|
+
}
|
|
114
122
|
}
|
|
115
123
|
else {
|
|
116
|
-
dealWithSubRows(subRows);
|
|
117
124
|
}
|
|
118
125
|
});
|
|
119
126
|
}
|
|
@@ -191,18 +198,20 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
191
198
|
});
|
|
192
199
|
};
|
|
193
200
|
var ids = (0, lodash_1.uniq)(result.filter(function (ele) { return !!(ele["".concat(attr, "Id")]); }).map(function (ele) { return ele["".concat(attr, "Id")]; }));
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
if (ids.length > 0) {
|
|
202
|
+
var subRows = cascadeSelectFn.call(_this, relation, {
|
|
203
|
+
data: projection2[attr],
|
|
204
|
+
filter: {
|
|
205
|
+
id: {
|
|
206
|
+
$in: ids
|
|
207
|
+
},
|
|
199
208
|
},
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
209
|
+
}, context, option);
|
|
210
|
+
if (subRows instanceof Promise) {
|
|
211
|
+
return subRows.then(function (subRowss) { return dealWithSubRows(subRowss); });
|
|
212
|
+
}
|
|
213
|
+
dealWithSubRows(subRows);
|
|
204
214
|
}
|
|
205
|
-
dealWithSubRows(subRows);
|
|
206
215
|
});
|
|
207
216
|
}
|
|
208
217
|
}
|
|
@@ -261,21 +270,23 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
261
270
|
_a));
|
|
262
271
|
});
|
|
263
272
|
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
273
|
+
if (ids.length > 0) {
|
|
274
|
+
var subRows = cascadeSelectFn.call(_this, entity2_1, {
|
|
275
|
+
data: subProjection_1,
|
|
276
|
+
filter: (0, filter_1.combineFilters)([(_a = {},
|
|
277
|
+
_a[foreignKey_1] = {
|
|
278
|
+
$in: ids,
|
|
279
|
+
},
|
|
280
|
+
_a), subFilter_1]),
|
|
281
|
+
sorter: subSorter_1,
|
|
282
|
+
indexFrom: indexFrom_1,
|
|
283
|
+
count: count_1
|
|
284
|
+
}, context, option);
|
|
285
|
+
if (subRows instanceof Promise) {
|
|
286
|
+
return subRows.then(function (subRowss) { return dealWithSubRows(subRowss); });
|
|
287
|
+
}
|
|
288
|
+
dealWithSubRows(subRows);
|
|
277
289
|
}
|
|
278
|
-
dealWithSubRows(subRows);
|
|
279
290
|
});
|
|
280
291
|
}
|
|
281
292
|
}
|
|
@@ -329,22 +340,24 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
329
340
|
_a));
|
|
330
341
|
});
|
|
331
342
|
};
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
343
|
+
if (ids.length > 0) {
|
|
344
|
+
var subRows = cascadeSelectFn.call(_this, entity2_1, {
|
|
345
|
+
data: subProjection_1,
|
|
346
|
+
filter: (0, filter_1.combineFilters)([{
|
|
347
|
+
entity: entity,
|
|
348
|
+
entityId: {
|
|
349
|
+
$in: ids,
|
|
350
|
+
}
|
|
351
|
+
}, subFilter_1]),
|
|
352
|
+
sorter: subSorter_1,
|
|
353
|
+
indexFrom: indexFrom_1,
|
|
354
|
+
count: count_1
|
|
355
|
+
}, context, option);
|
|
356
|
+
if (subRows instanceof Promise) {
|
|
357
|
+
return subRows.then(function (subRowss) { return dealWithSubRows(subRowss); });
|
|
358
|
+
}
|
|
359
|
+
dealWithSubRows(subRows);
|
|
346
360
|
}
|
|
347
|
-
dealWithSubRows(subRows);
|
|
348
361
|
});
|
|
349
362
|
}
|
|
350
363
|
}
|
|
@@ -708,11 +721,11 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
708
721
|
*/
|
|
709
722
|
CascadeStore.prototype.doUpdateSingleRowAsync = function (entity, operation, context, option) {
|
|
710
723
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
711
|
-
var data, action, operId, filter, now, _a, modiCreate, result_1, createInner, multipleCreate, data_1, data_1_1, d, createSingleOper, e_2_1, operatorId, createOper, _b, ids_1, selection, rows, modiUpsert, upsertModis, _c, originData, originId, createOper, updateAttrCount, result;
|
|
712
|
-
var e_2,
|
|
724
|
+
var data, action, operId, filter, now, _a, modiCreate, result_1, createInner, multipleCreate, data_1, data_1_1, d, createSingleOper, e_2_1, operatorId, createOper, _b, ids_1, selection, rows, modiUpsert, upsertModis, _c, originData, originId, _d, createOper, updateAttrCount, result;
|
|
725
|
+
var e_2, _e, _f, _g, _h, _j, _k, _l;
|
|
713
726
|
var _this = this;
|
|
714
|
-
return tslib_1.__generator(this, function (
|
|
715
|
-
switch (
|
|
727
|
+
return tslib_1.__generator(this, function (_m) {
|
|
728
|
+
switch (_m.label) {
|
|
716
729
|
case 0:
|
|
717
730
|
data = operation.data, action = operation.action, operId = operation.id, filter = operation.filter;
|
|
718
731
|
now = Date.now();
|
|
@@ -746,7 +759,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
746
759
|
};
|
|
747
760
|
return [4 /*yield*/, this.cascadeUpdateAsync('modi', modiCreate, context, option)];
|
|
748
761
|
case 2:
|
|
749
|
-
|
|
762
|
+
_m.sent();
|
|
750
763
|
return [2 /*return*/, 1];
|
|
751
764
|
case 3:
|
|
752
765
|
result_1 = 0;
|
|
@@ -836,12 +849,12 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
836
849
|
if (!multipleCreate) return [3 /*break*/, 5];
|
|
837
850
|
return [4 /*yield*/, createInner(operation)];
|
|
838
851
|
case 4:
|
|
839
|
-
|
|
852
|
+
_m.sent();
|
|
840
853
|
return [3 /*break*/, 12];
|
|
841
854
|
case 5:
|
|
842
|
-
|
|
855
|
+
_m.trys.push([5, 10, 11, 12]);
|
|
843
856
|
data_1 = tslib_1.__values(data), data_1_1 = data_1.next();
|
|
844
|
-
|
|
857
|
+
_m.label = 6;
|
|
845
858
|
case 6:
|
|
846
859
|
if (!!data_1_1.done) return [3 /*break*/, 9];
|
|
847
860
|
d = data_1_1.value;
|
|
@@ -852,27 +865,27 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
852
865
|
};
|
|
853
866
|
return [4 /*yield*/, createInner(createSingleOper)];
|
|
854
867
|
case 7:
|
|
855
|
-
|
|
856
|
-
|
|
868
|
+
_m.sent();
|
|
869
|
+
_m.label = 8;
|
|
857
870
|
case 8:
|
|
858
871
|
data_1_1 = data_1.next();
|
|
859
872
|
return [3 /*break*/, 6];
|
|
860
873
|
case 9: return [3 /*break*/, 12];
|
|
861
874
|
case 10:
|
|
862
|
-
e_2_1 =
|
|
875
|
+
e_2_1 = _m.sent();
|
|
863
876
|
e_2 = { error: e_2_1 };
|
|
864
877
|
return [3 /*break*/, 12];
|
|
865
878
|
case 11:
|
|
866
879
|
try {
|
|
867
|
-
if (data_1_1 && !data_1_1.done && (
|
|
880
|
+
if (data_1_1 && !data_1_1.done && (_e = data_1.return)) _e.call(data_1);
|
|
868
881
|
}
|
|
869
882
|
finally { if (e_2) throw e_2.error; }
|
|
870
883
|
return [7 /*endfinally*/];
|
|
871
884
|
case 12: return [3 /*break*/, 15];
|
|
872
885
|
case 13: return [4 /*yield*/, createInner(operation)];
|
|
873
886
|
case 14:
|
|
874
|
-
|
|
875
|
-
|
|
887
|
+
_m.sent();
|
|
888
|
+
_m.label = 15;
|
|
876
889
|
case 15:
|
|
877
890
|
if (!option.dontCollect) {
|
|
878
891
|
context.opRecords.push({
|
|
@@ -886,20 +899,20 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
886
899
|
(0, assert_1.default)(operId);
|
|
887
900
|
return [4 /*yield*/, context.getCurrentUserId(true)];
|
|
888
901
|
case 16:
|
|
889
|
-
operatorId =
|
|
902
|
+
operatorId = _m.sent();
|
|
890
903
|
if (!operatorId) return [3 /*break*/, 22];
|
|
891
|
-
|
|
904
|
+
_f = {
|
|
892
905
|
id: 'dummy',
|
|
893
906
|
action: 'create'
|
|
894
907
|
};
|
|
895
|
-
|
|
908
|
+
_g = {
|
|
896
909
|
id: operId,
|
|
897
910
|
action: action,
|
|
898
911
|
data: data,
|
|
899
912
|
operatorId: operatorId
|
|
900
913
|
};
|
|
901
914
|
if (!(data instanceof Array)) return [3 /*break*/, 18];
|
|
902
|
-
|
|
915
|
+
_h = {
|
|
903
916
|
id: 'dummy',
|
|
904
917
|
action: 'create'
|
|
905
918
|
};
|
|
@@ -918,34 +931,34 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
918
931
|
});
|
|
919
932
|
}); }))];
|
|
920
933
|
case 17:
|
|
921
|
-
_b = (
|
|
922
|
-
|
|
934
|
+
_b = (_h.data = _m.sent(),
|
|
935
|
+
_h);
|
|
923
936
|
return [3 /*break*/, 20];
|
|
924
937
|
case 18:
|
|
925
|
-
|
|
938
|
+
_j = {
|
|
926
939
|
id: 'dummy',
|
|
927
940
|
action: 'create'
|
|
928
941
|
};
|
|
929
|
-
|
|
942
|
+
_k = {};
|
|
930
943
|
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
|
931
944
|
case 19:
|
|
932
|
-
_b = [(
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
945
|
+
_b = [(_j.data = (_k.id = _m.sent(),
|
|
946
|
+
_k.entity = entity,
|
|
947
|
+
_k.entityId = data.id,
|
|
948
|
+
_k),
|
|
949
|
+
_j)];
|
|
950
|
+
_m.label = 20;
|
|
938
951
|
case 20:
|
|
939
|
-
createOper = (
|
|
940
|
-
|
|
941
|
-
|
|
952
|
+
createOper = (_f.data = (_g.operEntity$oper = _b,
|
|
953
|
+
_g),
|
|
954
|
+
_f);
|
|
942
955
|
return [4 /*yield*/, this.cascadeUpdateAsync('oper', createOper, context, {
|
|
943
956
|
dontCollect: true,
|
|
944
957
|
dontCreateOper: true,
|
|
945
958
|
})];
|
|
946
959
|
case 21:
|
|
947
|
-
|
|
948
|
-
|
|
960
|
+
_m.sent();
|
|
961
|
+
_m.label = 22;
|
|
949
962
|
case 22: return [2 /*return*/, result_1];
|
|
950
963
|
case 23:
|
|
951
964
|
ids_1 = (0, filter_2.getRelevantIds)(filter);
|
|
@@ -962,9 +975,9 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
962
975
|
dontCollect: true,
|
|
963
976
|
})];
|
|
964
977
|
case 24:
|
|
965
|
-
rows =
|
|
978
|
+
rows = _m.sent();
|
|
966
979
|
ids_1.push.apply(ids_1, tslib_1.__spreadArray([], tslib_1.__read((rows.map(function (ele) { return ele.id; }))), false));
|
|
967
|
-
|
|
980
|
+
_m.label = 25;
|
|
968
981
|
case 25:
|
|
969
982
|
if (data) {
|
|
970
983
|
this.preProcessDataUpdated(data);
|
|
@@ -1003,7 +1016,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1003
1016
|
count: 1,
|
|
1004
1017
|
}, context, option)];
|
|
1005
1018
|
case 26:
|
|
1006
|
-
upsertModis =
|
|
1019
|
+
upsertModis = _m.sent();
|
|
1007
1020
|
if (upsertModis.length > 0) {
|
|
1008
1021
|
_c = upsertModis[0], originData = _c.data, originId = _c.id;
|
|
1009
1022
|
modiUpsert = {
|
|
@@ -1017,24 +1030,26 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1017
1030
|
}
|
|
1018
1031
|
};
|
|
1019
1032
|
}
|
|
1020
|
-
|
|
1033
|
+
_m.label = 27;
|
|
1021
1034
|
case 27:
|
|
1022
1035
|
if (!!modiUpsert) return [3 /*break*/, 29];
|
|
1023
|
-
|
|
1036
|
+
modiUpsert = {
|
|
1024
1037
|
id: 'dummy',
|
|
1025
|
-
action: 'create'
|
|
1038
|
+
action: 'create',
|
|
1039
|
+
data: {
|
|
1040
|
+
id: operId,
|
|
1041
|
+
targetEntity: entity,
|
|
1042
|
+
entity: option.modiParentEntity,
|
|
1043
|
+
entityId: option.modiParentId,
|
|
1044
|
+
action: action,
|
|
1045
|
+
data: data,
|
|
1046
|
+
iState: 'active',
|
|
1047
|
+
filter: filter,
|
|
1048
|
+
},
|
|
1026
1049
|
};
|
|
1050
|
+
if (!(ids_1.length > 0)) return [3 /*break*/, 29];
|
|
1051
|
+
_d = modiUpsert.data;
|
|
1027
1052
|
_l = {
|
|
1028
|
-
id: operId,
|
|
1029
|
-
targetEntity: entity,
|
|
1030
|
-
entity: option.modiParentEntity,
|
|
1031
|
-
entityId: option.modiParentId,
|
|
1032
|
-
action: action,
|
|
1033
|
-
data: data,
|
|
1034
|
-
iState: 'active',
|
|
1035
|
-
filter: filter
|
|
1036
|
-
};
|
|
1037
|
-
_m = {
|
|
1038
1053
|
id: 'dummy',
|
|
1039
1054
|
action: 'create'
|
|
1040
1055
|
};
|
|
@@ -1053,14 +1068,12 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1053
1068
|
});
|
|
1054
1069
|
}); }))];
|
|
1055
1070
|
case 28:
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
_k);
|
|
1060
|
-
_o.label = 29;
|
|
1071
|
+
_d.modiEntity$modi = (_l.data = _m.sent(),
|
|
1072
|
+
_l);
|
|
1073
|
+
_m.label = 29;
|
|
1061
1074
|
case 29: return [4 /*yield*/, this.cascadeUpdateAsync('modi', modiUpsert, context, option)];
|
|
1062
1075
|
case 30:
|
|
1063
|
-
|
|
1076
|
+
_m.sent();
|
|
1064
1077
|
return [2 /*return*/, 1];
|
|
1065
1078
|
case 31:
|
|
1066
1079
|
createOper = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -1155,15 +1168,15 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1155
1168
|
return [4 /*yield*/, createOper()];
|
|
1156
1169
|
case 34:
|
|
1157
1170
|
// 如果不是update动作而是用户自定义的动作,这里还是要记录oper
|
|
1158
|
-
|
|
1171
|
+
_m.sent();
|
|
1159
1172
|
return [2 /*return*/, 0];
|
|
1160
1173
|
case 35: return [2 /*return*/, 0];
|
|
1161
1174
|
case 36: return [4 /*yield*/, this.updateAbjointRowAsync(entity, operation, context, option)];
|
|
1162
1175
|
case 37:
|
|
1163
|
-
result =
|
|
1176
|
+
result = _m.sent();
|
|
1164
1177
|
return [4 /*yield*/, createOper()];
|
|
1165
1178
|
case 38:
|
|
1166
|
-
|
|
1179
|
+
_m.sent();
|
|
1167
1180
|
return [2 /*return*/, result];
|
|
1168
1181
|
}
|
|
1169
1182
|
});
|
package/lib/store/checker.d.ts
CHANGED
|
@@ -23,4 +23,4 @@ export declare function createAuthCheckers<ED extends EntityDict & BaseEntityDic
|
|
|
23
23
|
* @returns
|
|
24
24
|
* 如果有的对象允许删除,需要使用trigger来处理其相关联的外键对象,这些trigger写作before,则会在checker之前执行,仍然可以删除成功
|
|
25
25
|
*/
|
|
26
|
-
export declare function createRemoveCheckers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): Checker<ED, keyof ED, Cxt>[];
|
|
26
|
+
export declare function createRemoveCheckers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>, authDict?: AuthDefDict<ED>): Checker<ED, keyof ED, Cxt>[];
|