oak-domain 5.1.26 → 5.1.28
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/ActionAuth/Storage.js +0 -1
- package/lib/base-app-domain/EntityDict.d.ts +18 -2
- package/lib/base-app-domain/I18n/Storage.js +0 -1
- package/lib/base-app-domain/Path/Storage.js +0 -2
- package/lib/base-app-domain/Path/_baseSchema.d.ts +1 -1
- package/lib/base-app-domain/RelationAuth/Storage.js +0 -1
- package/lib/compiler/dependencyBuilder.js +12 -7
- package/lib/entities/ActionAuth.js +0 -3
- package/lib/entities/I18n.js +0 -3
- package/lib/entities/Path.d.ts +1 -1
- package/lib/entities/Path.js +0 -3
- package/lib/entities/RelationAuth.js +0 -3
- package/lib/store/AsyncRowStore.d.ts +1 -0
- package/lib/store/IntrinsicLogics.js +1 -1
- package/lib/store/TriggerExecutor.js +22 -4
- package/lib/store/filter.js +2 -1
- package/lib/store/triggers.d.ts +1 -1
- package/lib/store/triggers.js +23 -2
- package/lib/types/AppLoader.d.ts +1 -1
- package/package.json +1 -1
- package/src/entities/ActionAuth.ts +0 -3
- package/src/entities/I18n.ts +0 -3
- package/src/entities/Path.ts +1 -4
- package/src/entities/RelationAuth.ts +0 -3
|
@@ -43,12 +43,14 @@ export type ActionAuth = {
|
|
|
43
43
|
Aggregation: DeduceAggregation<ActionAuth["Projection"], ActionAuth["Filter"], ActionAuth["Sorter"]>;
|
|
44
44
|
CreateOperationData: FormCreateData<BaseActionAuth.OpSchema & {
|
|
45
45
|
relation?: OakOperation<"create", Relation["CreateOperationData"]> | OakOperation<BaseRelation.OpUpdateAction, Relation["UpdateOperationData"], Relation["Filter"]>;
|
|
46
|
+
path?: OakOperation<"create", Path["CreateOperationData"]> | OakOperation<BasePath.OpUpdateAction, Path["UpdateOperationData"], Path["Filter"]>;
|
|
46
47
|
}>;
|
|
47
48
|
CreateSingle: OakOperation<"create", ActionAuth["CreateOperationData"]>;
|
|
48
49
|
CreateMulti: OakOperation<"create", Array<ActionAuth["CreateOperationData"]>>;
|
|
49
50
|
Create: ActionAuth["CreateSingle"] | ActionAuth["CreateMulti"];
|
|
50
51
|
UpdateOperationData: FormUpdateData<BaseActionAuth.OpSchema & {
|
|
51
52
|
relation?: OakOperation<"create", Relation["CreateOperationData"]> | OakOperation<BaseRelation.OpUpdateAction, Relation["UpdateOperationData"], Relation["Filter"]> | OakOperation<"remove", Relation["RemoveOperationData"], Relation["Filter"]>;
|
|
53
|
+
path?: OakOperation<"create", Path["CreateOperationData"]> | OakOperation<BasePath.OpUpdateAction, Path["UpdateOperationData"], Path["Filter"]> | OakOperation<"remove", Path["RemoveOperationData"], Path["Filter"]>;
|
|
52
54
|
}>;
|
|
53
55
|
Update: OakOperation<BaseActionAuth.OpUpdateAction, ActionAuth["UpdateOperationData"], ActionAuth["Filter"], ActionAuth["Sorter"]>;
|
|
54
56
|
RemoveOperationData: {};
|
|
@@ -326,11 +328,17 @@ export type Path = {
|
|
|
326
328
|
Sorter: Path["SortNode"][];
|
|
327
329
|
Selection: OakSelection<"select", Path["Projection"], Path["Filter"], Path["Sorter"]>;
|
|
328
330
|
Aggregation: DeduceAggregation<Path["Projection"], Path["Filter"], Path["Sorter"]>;
|
|
329
|
-
CreateOperationData: FormCreateData<BasePath.OpSchema
|
|
331
|
+
CreateOperationData: FormCreateData<BasePath.OpSchema & {
|
|
332
|
+
actionAuth$path?: (OakOperation<"create", Omit<ActionAuth["CreateOperationData"], "path"> | Omit<ActionAuth["CreateOperationData"], "path">[]> | OakOperation<BaseActionAuth.OpUpdateAction, Omit<ActionAuth["UpdateOperationData"], "path">, ActionAuth["Filter"]>)[];
|
|
333
|
+
relationAuth$path?: (OakOperation<"create", Omit<RelationAuth["CreateOperationData"], "path"> | Omit<RelationAuth["CreateOperationData"], "path">[]> | OakOperation<BaseRelationAuth.OpUpdateAction, Omit<RelationAuth["UpdateOperationData"], "path">, RelationAuth["Filter"]>)[];
|
|
334
|
+
}>;
|
|
330
335
|
CreateSingle: OakOperation<"create", Path["CreateOperationData"]>;
|
|
331
336
|
CreateMulti: OakOperation<"create", Array<Path["CreateOperationData"]>>;
|
|
332
337
|
Create: Path["CreateSingle"] | Path["CreateMulti"];
|
|
333
|
-
UpdateOperationData: FormUpdateData<BasePath.OpSchema
|
|
338
|
+
UpdateOperationData: FormUpdateData<BasePath.OpSchema & {
|
|
339
|
+
actionAuth$path?: (OakOperation<"create", Omit<ActionAuth["CreateOperationData"], "path"> | Omit<ActionAuth["CreateOperationData"], "path">[]> | OakOperation<BaseActionAuth.OpUpdateAction, Omit<ActionAuth["UpdateOperationData"], "path">, ActionAuth["Filter"]> | OakOperation<"remove", ActionAuth["RemoveOperationData"], ActionAuth["Filter"]>)[];
|
|
340
|
+
relationAuth$path?: (OakOperation<"create", Omit<RelationAuth["CreateOperationData"], "path"> | Omit<RelationAuth["CreateOperationData"], "path">[]> | OakOperation<BaseRelationAuth.OpUpdateAction, Omit<RelationAuth["UpdateOperationData"], "path">, RelationAuth["Filter"]> | OakOperation<"remove", RelationAuth["RemoveOperationData"], RelationAuth["Filter"]>)[];
|
|
341
|
+
}>;
|
|
334
342
|
Update: OakOperation<BasePath.OpUpdateAction, Path["UpdateOperationData"], Path["Filter"], Path["Sorter"]>;
|
|
335
343
|
RemoveOperationData: {};
|
|
336
344
|
Remove: OakOperation<"remove", Path["RemoveOperationData"], Path["Filter"], Path["Sorter"]>;
|
|
@@ -400,6 +408,9 @@ export type Relation = {
|
|
|
400
408
|
Selection: OakSelection<"select", Relation["Projection"], Relation["Filter"], Relation["Sorter"]>;
|
|
401
409
|
Aggregation: DeduceAggregation<Relation["Projection"], Relation["Filter"], Relation["Sorter"]>;
|
|
402
410
|
CreateOperationData: FormCreateData<BaseRelation.OpSchema & {
|
|
411
|
+
actionAuth$relation?: (OakOperation<"create", Omit<ActionAuth["CreateOperationData"], "relation"> | Omit<ActionAuth["CreateOperationData"], "relation">[]> | OakOperation<BaseActionAuth.OpUpdateAction, Omit<ActionAuth["UpdateOperationData"], "relation">, ActionAuth["Filter"]>)[];
|
|
412
|
+
relationAuth$sourceRelation?: (OakOperation<"create", Omit<RelationAuth["CreateOperationData"], "sourceRelation"> | Omit<RelationAuth["CreateOperationData"], "sourceRelation">[]> | OakOperation<BaseRelationAuth.OpUpdateAction, Omit<RelationAuth["UpdateOperationData"], "sourceRelation">, RelationAuth["Filter"]>)[];
|
|
413
|
+
relationAuth$destRelation?: (OakOperation<"create", Omit<RelationAuth["CreateOperationData"], "destRelation"> | Omit<RelationAuth["CreateOperationData"], "destRelation">[]> | OakOperation<BaseRelationAuth.OpUpdateAction, Omit<RelationAuth["UpdateOperationData"], "destRelation">, RelationAuth["Filter"]>)[];
|
|
403
414
|
userEntityClaim$relation?: (OakOperation<"create", Omit<UserEntityClaim["CreateOperationData"], "relation"> | Omit<UserEntityClaim["CreateOperationData"], "relation">[]> | OakOperation<BaseUserEntityClaim.OpUpdateAction, Omit<UserEntityClaim["UpdateOperationData"], "relation">, UserEntityClaim["Filter"]>)[];
|
|
404
415
|
userRelation$relation?: (OakOperation<"create", Omit<UserRelation["CreateOperationData"], "relation"> | Omit<UserRelation["CreateOperationData"], "relation">[]> | OakOperation<BaseUserRelation.OpUpdateAction, Omit<UserRelation["UpdateOperationData"], "relation">, UserRelation["Filter"]>)[];
|
|
405
416
|
}>;
|
|
@@ -407,6 +418,9 @@ export type Relation = {
|
|
|
407
418
|
CreateMulti: OakOperation<"create", Array<Relation["CreateOperationData"]>>;
|
|
408
419
|
Create: Relation["CreateSingle"] | Relation["CreateMulti"];
|
|
409
420
|
UpdateOperationData: FormUpdateData<BaseRelation.OpSchema & {
|
|
421
|
+
actionAuth$relation?: (OakOperation<"create", Omit<ActionAuth["CreateOperationData"], "relation"> | Omit<ActionAuth["CreateOperationData"], "relation">[]> | OakOperation<BaseActionAuth.OpUpdateAction, Omit<ActionAuth["UpdateOperationData"], "relation">, ActionAuth["Filter"]> | OakOperation<"remove", ActionAuth["RemoveOperationData"], ActionAuth["Filter"]>)[];
|
|
422
|
+
relationAuth$sourceRelation?: (OakOperation<"create", Omit<RelationAuth["CreateOperationData"], "sourceRelation"> | Omit<RelationAuth["CreateOperationData"], "sourceRelation">[]> | OakOperation<BaseRelationAuth.OpUpdateAction, Omit<RelationAuth["UpdateOperationData"], "sourceRelation">, RelationAuth["Filter"]> | OakOperation<"remove", RelationAuth["RemoveOperationData"], RelationAuth["Filter"]>)[];
|
|
423
|
+
relationAuth$destRelation?: (OakOperation<"create", Omit<RelationAuth["CreateOperationData"], "destRelation"> | Omit<RelationAuth["CreateOperationData"], "destRelation">[]> | OakOperation<BaseRelationAuth.OpUpdateAction, Omit<RelationAuth["UpdateOperationData"], "destRelation">, RelationAuth["Filter"]> | OakOperation<"remove", RelationAuth["RemoveOperationData"], RelationAuth["Filter"]>)[];
|
|
410
424
|
userEntityClaim$relation?: (OakOperation<"create", Omit<UserEntityClaim["CreateOperationData"], "relation"> | Omit<UserEntityClaim["CreateOperationData"], "relation">[]> | OakOperation<BaseUserEntityClaim.OpUpdateAction, Omit<UserEntityClaim["UpdateOperationData"], "relation">, UserEntityClaim["Filter"]> | OakOperation<"remove", UserEntityClaim["RemoveOperationData"], UserEntityClaim["Filter"]>)[];
|
|
411
425
|
userRelation$relation?: (OakOperation<"create", Omit<UserRelation["CreateOperationData"], "relation"> | Omit<UserRelation["CreateOperationData"], "relation">[]> | OakOperation<BaseUserRelation.OpUpdateAction, Omit<UserRelation["UpdateOperationData"], "relation">, UserRelation["Filter"]> | OakOperation<"remove", UserRelation["RemoveOperationData"], UserRelation["Filter"]>)[];
|
|
412
426
|
}>;
|
|
@@ -448,6 +462,7 @@ export type RelationAuth = {
|
|
|
448
462
|
Aggregation: DeduceAggregation<RelationAuth["Projection"], RelationAuth["Filter"], RelationAuth["Sorter"]>;
|
|
449
463
|
CreateOperationData: FormCreateData<BaseRelationAuth.OpSchema & {
|
|
450
464
|
sourceRelation?: OakOperation<"create", Relation["CreateOperationData"]> | OakOperation<BaseRelation.OpUpdateAction, Relation["UpdateOperationData"], Relation["Filter"]>;
|
|
465
|
+
path?: OakOperation<"create", Path["CreateOperationData"]> | OakOperation<BasePath.OpUpdateAction, Path["UpdateOperationData"], Path["Filter"]>;
|
|
451
466
|
destRelation?: OakOperation<"create", Relation["CreateOperationData"]> | OakOperation<BaseRelation.OpUpdateAction, Relation["UpdateOperationData"], Relation["Filter"]>;
|
|
452
467
|
}>;
|
|
453
468
|
CreateSingle: OakOperation<"create", RelationAuth["CreateOperationData"]>;
|
|
@@ -455,6 +470,7 @@ export type RelationAuth = {
|
|
|
455
470
|
Create: RelationAuth["CreateSingle"] | RelationAuth["CreateMulti"];
|
|
456
471
|
UpdateOperationData: FormUpdateData<BaseRelationAuth.OpSchema & {
|
|
457
472
|
sourceRelation?: OakOperation<"create", Relation["CreateOperationData"]> | OakOperation<BaseRelation.OpUpdateAction, Relation["UpdateOperationData"], Relation["Filter"]> | OakOperation<"remove", Relation["RemoveOperationData"], Relation["Filter"]>;
|
|
473
|
+
path?: OakOperation<"create", Path["CreateOperationData"]> | OakOperation<BasePath.OpUpdateAction, Path["UpdateOperationData"], Path["Filter"]> | OakOperation<"remove", Path["RemoveOperationData"], Path["Filter"]>;
|
|
458
474
|
destRelation?: OakOperation<"create", Relation["CreateOperationData"]> | OakOperation<BaseRelation.OpUpdateAction, Relation["UpdateOperationData"], Relation["Filter"]> | OakOperation<"remove", Relation["RemoveOperationData"], Relation["Filter"]>;
|
|
459
475
|
}>;
|
|
460
476
|
Update: OakOperation<BaseRelationAuth.OpUpdateAction, RelationAuth["UpdateOperationData"], RelationAuth["Filter"], RelationAuth["Sorter"]>;
|
|
@@ -19,7 +19,6 @@ exports.desc = {
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
recursive: {
|
|
22
|
-
notNull: true,
|
|
23
22
|
type: "boolean"
|
|
24
23
|
},
|
|
25
24
|
sourceEntity: {
|
|
@@ -36,7 +35,6 @@ exports.desc = {
|
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
},
|
|
39
|
-
static: true,
|
|
40
38
|
actionType: "crud",
|
|
41
39
|
actions: action_1.genericActions,
|
|
42
40
|
indexes: [
|
|
@@ -749,7 +749,7 @@ function injectDataIndexFile(dataIndexFile, briefNames, printer) {
|
|
|
749
749
|
* @param fromDir 依赖项目的目录
|
|
750
750
|
* @param toDir 当前项目的目录
|
|
751
751
|
*/
|
|
752
|
-
function tryCopyFilesRecursively(fromDir, toDir) {
|
|
752
|
+
function tryCopyFilesRecursively(fromDir, toDir, rebuild) {
|
|
753
753
|
const files = (0, fs_1.readdirSync)(fromDir);
|
|
754
754
|
files.forEach((file) => {
|
|
755
755
|
const fromFile = join(fromDir, file);
|
|
@@ -757,7 +757,12 @@ function tryCopyFilesRecursively(fromDir, toDir) {
|
|
|
757
757
|
const stat = (0, fs_1.statSync)(fromFile);
|
|
758
758
|
if (stat.isFile()) {
|
|
759
759
|
if ((0, fs_1.existsSync)(join(toDir, file))) {
|
|
760
|
-
|
|
760
|
+
if (rebuild) {
|
|
761
|
+
console.log(`覆盖文件${toFile}`);
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
console.log(`忽略文件${toFile}`);
|
|
765
|
+
}
|
|
761
766
|
}
|
|
762
767
|
else {
|
|
763
768
|
console.log(`拷贝文件${toFile}`);
|
|
@@ -771,7 +776,7 @@ function tryCopyFilesRecursively(fromDir, toDir) {
|
|
|
771
776
|
console.log(`创建文件夹${toFile}`);
|
|
772
777
|
(0, fs_extra_1.mkdirSync)(toFile);
|
|
773
778
|
}
|
|
774
|
-
tryCopyFilesRecursively(fromFile, toFile);
|
|
779
|
+
tryCopyFilesRecursively(fromFile, toFile, rebuild);
|
|
775
780
|
}
|
|
776
781
|
});
|
|
777
782
|
}
|
|
@@ -781,7 +786,7 @@ function tryCopyFilesRecursively(fromDir, toDir) {
|
|
|
781
786
|
* @param dependencies
|
|
782
787
|
* @param briefNames
|
|
783
788
|
*/
|
|
784
|
-
function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer) {
|
|
789
|
+
function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer, rebuild) {
|
|
785
790
|
const injectDataIndexFileDependencies = [];
|
|
786
791
|
const injectDataIndexFileBriefNames = [];
|
|
787
792
|
dependencies.forEach((dep, idx) => {
|
|
@@ -792,7 +797,7 @@ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer) {
|
|
|
792
797
|
const dataFile = join(moduleTemplateDir, 'data.ts');
|
|
793
798
|
if ((0, fs_1.existsSync)(dataFile)) {
|
|
794
799
|
const prjDataFile = join(cwd, 'src', 'data', `${briefNames[idx]}Data.ts`);
|
|
795
|
-
if (!(0, fs_1.existsSync)(prjDataFile)) {
|
|
800
|
+
if (!(0, fs_1.existsSync)(prjDataFile) || rebuild) {
|
|
796
801
|
console.log(`拷贝${dataFile}到${prjDataFile}中`);
|
|
797
802
|
(0, fs_extra_1.copySync)(dataFile, prjDataFile);
|
|
798
803
|
injectDataIndexFileDependencies.push(dep);
|
|
@@ -802,7 +807,7 @@ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer) {
|
|
|
802
807
|
// src下面的文件是可以拷贝到项目中的
|
|
803
808
|
const srcDir = join(moduleTemplateDir, 'src');
|
|
804
809
|
if ((0, fs_1.existsSync)(srcDir)) {
|
|
805
|
-
tryCopyFilesRecursively(srcDir, join(cwd, 'src'));
|
|
810
|
+
tryCopyFilesRecursively(srcDir, join(cwd, 'src'), rebuild);
|
|
806
811
|
}
|
|
807
812
|
}
|
|
808
813
|
});
|
|
@@ -1020,7 +1025,7 @@ function buildDependency(rebuild) {
|
|
|
1020
1025
|
}
|
|
1021
1026
|
// 把各个依赖项目的一些初始化的文件拷贝过去
|
|
1022
1027
|
if (!isModule) {
|
|
1023
|
-
tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer);
|
|
1028
|
+
tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer, rebuild);
|
|
1024
1029
|
}
|
|
1025
1030
|
}
|
|
1026
1031
|
exports.default = buildDependency;
|
package/lib/entities/I18n.js
CHANGED
package/lib/entities/Path.d.ts
CHANGED
package/lib/entities/Path.js
CHANGED
|
@@ -72,4 +72,5 @@ export interface AsyncRowStore<ED extends EntityDict & BaseEntityDict, Cxt exten
|
|
|
72
72
|
commit(txnId: string): Promise<void>;
|
|
73
73
|
rollback(txnId: string): Promise<void>;
|
|
74
74
|
exec(script: string, txnId?: string): Promise<void>;
|
|
75
|
+
checkRelationAsync<T extends keyof ED, Cxt extends AsyncContext<ED>>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>, context: Cxt): Promise<void>;
|
|
75
76
|
}
|
|
@@ -34,7 +34,7 @@ function createExpiredWatchers(schema) {
|
|
|
34
34
|
function makeIntrinsicLogics(schema, actionDefDict, attrUpdateMatrix) {
|
|
35
35
|
const checkers = (0, IntrinsicCheckers_1.makeIntrinsicCheckers)(schema, actionDefDict, attrUpdateMatrix);
|
|
36
36
|
const triggers = (0, modi_1.createModiRelatedTriggers)(schema);
|
|
37
|
-
triggers.push(...triggers_1.actionAuthTriggers, ...triggers_1.
|
|
37
|
+
triggers.push(...triggers_1.actionAuthTriggers, ...triggers_1.triggers);
|
|
38
38
|
const watchers = createExpiredWatchers(schema);
|
|
39
39
|
return {
|
|
40
40
|
triggers,
|
|
@@ -276,12 +276,17 @@ class TriggerExecutor {
|
|
|
276
276
|
// 加上modi的过滤条件
|
|
277
277
|
&& this.judgeModiTurn(option, trigger));
|
|
278
278
|
if (triggers) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const commitTriggers = triggers.filter(ele => ele.when === 'commit'
|
|
282
|
-
(!ele.check || ele.check(operation)));
|
|
279
|
+
// 这里的check和attribute的检查要到trigger实际执行的时候再做,前面的trigger可能对后面的有影响
|
|
280
|
+
const preTriggers = triggers.filter(ele => ele.when === 'before');
|
|
281
|
+
const commitTriggers = triggers.filter(ele => ele.when === 'commit');
|
|
283
282
|
if (context instanceof SyncRowStore_1.SyncContext) {
|
|
284
283
|
for (const trigger of preTriggers) {
|
|
284
|
+
if (trigger.check && !trigger.check(operation)) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
if (trigger.attributes && (0, lodash_1.difference)(trigger.attributes, Object.keys(operation.data)).length === 0) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
285
290
|
if (trigger.filter) {
|
|
286
291
|
// trigger只对满足条件的前项进行判断,如果确定不满足可以pass
|
|
287
292
|
(0, assert_1.default)(operation.action !== 'create');
|
|
@@ -307,6 +312,12 @@ class TriggerExecutor {
|
|
|
307
312
|
return;
|
|
308
313
|
}
|
|
309
314
|
const trigger = preTriggers[idx];
|
|
315
|
+
if (trigger.check && !trigger.check(operation)) {
|
|
316
|
+
return execPreTrigger(idx + 1);
|
|
317
|
+
}
|
|
318
|
+
if (trigger.attributes && (0, lodash_1.difference)(trigger.attributes, Object.keys(operation.data)).length === 0) {
|
|
319
|
+
return execPreTrigger(idx + 1);
|
|
320
|
+
}
|
|
310
321
|
if (trigger.filter) {
|
|
311
322
|
(0, assert_1.default)(operation.action !== 'create');
|
|
312
323
|
const { filter } = trigger;
|
|
@@ -336,6 +347,12 @@ class TriggerExecutor {
|
|
|
336
347
|
}
|
|
337
348
|
(0, assert_1.default)(!action_1.readOnlyActions.includes(operation.action), '当前应该不支持select的跨事务trigger');
|
|
338
349
|
const trigger = commitTriggers[idx];
|
|
350
|
+
if (trigger.check && !trigger.check(operation)) {
|
|
351
|
+
return execCommitTrigger(idx + 1);
|
|
352
|
+
}
|
|
353
|
+
if (trigger.attributes && (0, lodash_1.difference)(trigger.attributes, Object.keys(operation.data)).length === 0) {
|
|
354
|
+
return execCommitTrigger(idx + 1);
|
|
355
|
+
}
|
|
339
356
|
if (trigger.filter) {
|
|
340
357
|
(0, assert_1.default)(operation.action !== 'create');
|
|
341
358
|
const { filter } = trigger;
|
|
@@ -426,6 +443,7 @@ class TriggerExecutor {
|
|
|
426
443
|
}
|
|
427
444
|
postOperation(entity, operation, context, option, result) {
|
|
428
445
|
const { action } = operation;
|
|
446
|
+
// 后trigger不会再改operation中的Data了,在这里检查好像没太大问题。by Xc 20251010
|
|
429
447
|
const triggers = this.triggerMap[entity] && this.triggerMap[entity][action]?.filter(trigger => (typeof trigger.action === 'string' && trigger.action === operation.action
|
|
430
448
|
|| trigger.action instanceof Array && trigger.action.includes(operation.action))
|
|
431
449
|
// 加上modi的过滤条件
|
package/lib/store/filter.js
CHANGED
|
@@ -21,7 +21,8 @@ function translateCreateDataToFilter(schema, entity, data, allowUnrecoganized) {
|
|
|
21
21
|
'sequence',
|
|
22
22
|
'array',
|
|
23
23
|
'object'
|
|
24
|
-
].includes(schema[entity].attributes[attr]?.type)) {
|
|
24
|
+
].includes(schema[entity].attributes[attr]?.type) || entity === 'userEntityGrant') {
|
|
25
|
+
// 这里要过滤掉userEntityGrant这一特殊对象,因为其relationIds和relationEntityFilter这两个属性后面要用
|
|
25
26
|
if (data[attr] === null) {
|
|
26
27
|
data2[attr] = {
|
|
27
28
|
$exists: false,
|
package/lib/store/triggers.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { EntityDict } from '../types/Entity';
|
|
|
3
3
|
import { Trigger } from '../types';
|
|
4
4
|
import { AsyncContext } from './AsyncRowStore';
|
|
5
5
|
export declare const actionAuthTriggers: Trigger<EntityDict & BaseEntityDict, 'actionAuth', AsyncContext<EntityDict & BaseEntityDict>>[];
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const triggers: Trigger<EntityDict & BaseEntityDict, keyof (EntityDict & BaseEntityDict), AsyncContext<EntityDict & BaseEntityDict>>[];
|
package/lib/store/triggers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.triggers = exports.actionAuthTriggers = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const uuid_1 = require("../utils/uuid");
|
|
@@ -176,7 +176,7 @@ async function redoLog(log, context) {
|
|
|
176
176
|
dontCreateOper: true,
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
exports.
|
|
179
|
+
exports.triggers = [
|
|
180
180
|
{
|
|
181
181
|
name: '当log被undo时,同一entity上所有在其之后的log全部回滚',
|
|
182
182
|
entity: 'log',
|
|
@@ -383,4 +383,25 @@ exports.logTriggers = [
|
|
|
383
383
|
return result.oper?.remove || 0;
|
|
384
384
|
}
|
|
385
385
|
},
|
|
386
|
+
// 当删除userRelation时,一并删除掉关联的userEntityClaim,这个设计似乎不是太好
|
|
387
|
+
{
|
|
388
|
+
name: '当删除userRelation时,一并删除掉关联的userEntityClaim',
|
|
389
|
+
action: 'remove',
|
|
390
|
+
entity: 'userRelation',
|
|
391
|
+
when: 'before',
|
|
392
|
+
fn: async ({ operation }, context, option) => {
|
|
393
|
+
const { filter } = operation;
|
|
394
|
+
const close = context.openRootMode();
|
|
395
|
+
const result = await context.operate('userEntityClaim', {
|
|
396
|
+
id: await (0, uuid_1.generateNewIdAsync)(),
|
|
397
|
+
action: 'remove',
|
|
398
|
+
data: {},
|
|
399
|
+
filter: {
|
|
400
|
+
userRelation: filter,
|
|
401
|
+
},
|
|
402
|
+
}, option);
|
|
403
|
+
close();
|
|
404
|
+
return result.userEntityClaim?.remove || 0;
|
|
405
|
+
}
|
|
406
|
+
},
|
|
386
407
|
];
|
package/lib/types/AppLoader.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare abstract class AppLoader<ED extends EntityDict & BaseEntityDict,
|
|
|
11
11
|
message?: string;
|
|
12
12
|
result: any;
|
|
13
13
|
}>;
|
|
14
|
-
abstract initialize(
|
|
14
|
+
abstract initialize(ifExists?: 'drop' | 'omit' | 'dropIfNotStatic'): Promise<void>;
|
|
15
15
|
abstract mount(): Promise<void>;
|
|
16
16
|
abstract unmount(): Promise<void>;
|
|
17
17
|
abstract getStore(): AsyncRowStore<ED, Cxt>;
|
package/package.json
CHANGED
package/src/entities/I18n.ts
CHANGED
package/src/entities/Path.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { EntityDesc } from '../types/EntityDesc';
|
|
|
5
5
|
export interface Schema extends EntityShape {
|
|
6
6
|
destEntity: String<32>;
|
|
7
7
|
value: String<256>;
|
|
8
|
-
recursive
|
|
8
|
+
recursive?: Boolean;
|
|
9
9
|
sourceEntity: String<32>;
|
|
10
10
|
desc?: String<256>;
|
|
11
11
|
};
|
|
@@ -42,7 +42,4 @@ const entityDesc: EntityDesc<Schema> = {
|
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
|
-
configuration: {
|
|
46
|
-
static: true,
|
|
47
|
-
}
|
|
48
45
|
};
|