oak-domain 5.1.20 → 5.1.21
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/_baseSchema.d.ts +2 -0
- package/lib/base-app-domain/ModiEntity/_baseSchema.d.ts +1 -0
- package/lib/base-app-domain/Oper/_baseSchema.d.ts +2 -0
- package/lib/base-app-domain/OperEntity/_baseSchema.d.ts +1 -0
- package/lib/base-app-domain/RelationAuth/_baseSchema.d.ts +3 -0
- package/lib/base-app-domain/User/_baseSchema.d.ts +1 -0
- package/lib/base-app-domain/UserEntityClaim/_baseSchema.d.ts +4 -0
- package/lib/base-app-domain/UserRelation/_baseSchema.d.ts +2 -0
- package/lib/compiler/schemalBuilder.js +1 -1
- package/lib/store/TriggerExecutor.js +12 -6
- package/lib/types/Trigger.d.ts +6 -6
- package/package.json +1 -1
|
@@ -58,8 +58,10 @@ export type OpSortAttr = Partial<{
|
|
|
58
58
|
$$seq$$: number;
|
|
59
59
|
$$updateAt$$: number;
|
|
60
60
|
action: number;
|
|
61
|
+
operatorId: number;
|
|
61
62
|
targetEntity: number;
|
|
62
63
|
bornAt: number;
|
|
64
|
+
logId: number;
|
|
63
65
|
iState: number;
|
|
64
66
|
[k: string]: any;
|
|
65
67
|
} | ExprOp<OpAttr | string>>;
|
|
@@ -35,6 +35,9 @@ export type OpSortAttr = Partial<{
|
|
|
35
35
|
$$createAt$$: number;
|
|
36
36
|
$$seq$$: number;
|
|
37
37
|
$$updateAt$$: number;
|
|
38
|
+
sourceRelationId: number;
|
|
39
|
+
pathId: number;
|
|
40
|
+
destRelationId: number;
|
|
38
41
|
[k: string]: any;
|
|
39
42
|
} | ExprOp<OpAttr | string>>;
|
|
40
43
|
export type OpAction = OakMakeAction<GenericAction | string>;
|
|
@@ -42,7 +42,11 @@ export type OpSortAttr = Partial<{
|
|
|
42
42
|
$$createAt$$: number;
|
|
43
43
|
$$seq$$: number;
|
|
44
44
|
$$updateAt$$: number;
|
|
45
|
+
uegId: number;
|
|
46
|
+
userId: number;
|
|
47
|
+
relationId: number;
|
|
45
48
|
claimEntityId: number;
|
|
49
|
+
userRelationId: number;
|
|
46
50
|
[k: string]: any;
|
|
47
51
|
} | ExprOp<OpAttr | string>>;
|
|
48
52
|
export type OpAction = OakMakeAction<GenericAction | string>;
|
|
@@ -2532,7 +2532,7 @@ function _constructOpSortAttr(statements, entity) {
|
|
|
2532
2532
|
const text2 = text === 'Schema' ? entity : text;
|
|
2533
2533
|
const manyToOneItem = manyToOneSet && manyToOneSet.find(([refEntity]) => refEntity === text2);
|
|
2534
2534
|
if (manyToOneItem) {
|
|
2535
|
-
factory.createPropertySignature(undefined, factory.createIdentifier(`${name.text}Id`), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword));
|
|
2535
|
+
members.push(factory.createPropertySignature(undefined, factory.createIdentifier(`${name.text}Id`), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword)));
|
|
2536
2536
|
}
|
|
2537
2537
|
else if (!['Object'].includes(text)) {
|
|
2538
2538
|
// todo 对State的专门处理
|
|
@@ -276,7 +276,8 @@ class TriggerExecutor {
|
|
|
276
276
|
// 加上modi的过滤条件
|
|
277
277
|
&& this.judgeModiTurn(option, trigger));
|
|
278
278
|
if (triggers) {
|
|
279
|
-
const preTriggers = triggers.filter(ele => ele.when === 'before' && (!ele.check || ele.check(operation))
|
|
279
|
+
const preTriggers = triggers.filter(ele => ele.when === 'before' && (!ele.check || ele.check(operation))
|
|
280
|
+
&& (!ele.attributes || (0, lodash_1.difference)(ele.attributes, Object.keys(operation.data)).length === 0));
|
|
280
281
|
const commitTriggers = triggers.filter(ele => ele.when === 'commit' &&
|
|
281
282
|
(!ele.check || ele.check(operation)));
|
|
282
283
|
if (context instanceof SyncRowStore_1.SyncContext) {
|
|
@@ -363,14 +364,18 @@ class TriggerExecutor {
|
|
|
363
364
|
if (trigger.strict === 'makeSure' && ids.length && !cleanTriggerDataBySelf) {
|
|
364
365
|
// 这里开root模式,否则还可能有权限问题
|
|
365
366
|
const closeRoot2 = context.openRootMode();
|
|
367
|
+
const data = {
|
|
368
|
+
[Entity_1.TriggerDataAttribute]: null,
|
|
369
|
+
[Entity_1.TriggerUuidAttribute]: null,
|
|
370
|
+
};
|
|
371
|
+
if (typeof callback === 'object') {
|
|
372
|
+
Object.assign(data, callback);
|
|
373
|
+
}
|
|
366
374
|
try {
|
|
367
375
|
await context.operate(entity, {
|
|
368
376
|
id: await (0, uuid_1.generateNewIdAsync)(),
|
|
369
377
|
action: 'update',
|
|
370
|
-
data
|
|
371
|
-
[Entity_1.TriggerDataAttribute]: null,
|
|
372
|
-
[Entity_1.TriggerUuidAttribute]: null,
|
|
373
|
-
},
|
|
378
|
+
data,
|
|
374
379
|
filter: {
|
|
375
380
|
id: {
|
|
376
381
|
$in: ids,
|
|
@@ -426,7 +431,8 @@ class TriggerExecutor {
|
|
|
426
431
|
// 加上modi的过滤条件
|
|
427
432
|
&& this.judgeModiTurn(option, trigger));
|
|
428
433
|
if (triggers) {
|
|
429
|
-
const postTriggers = triggers.filter(ele => ele.when === 'after' && (!ele.check || ele.check(operation))
|
|
434
|
+
const postTriggers = triggers.filter(ele => ele.when === 'after' && (!ele.check || ele.check(operation))
|
|
435
|
+
&& (!ele.attributes || (0, lodash_1.difference)(ele.attributes, Object.keys(operation.data)).length === 0));
|
|
430
436
|
const commitTriggers = triggers.filter(ele => ele.when === 'commit' &&
|
|
431
437
|
(!ele.check || ele.check(operation)));
|
|
432
438
|
if (context instanceof SyncRowStore_1.SyncContext) {
|
package/lib/types/Trigger.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface CreateTriggerInTxn<ED extends EntityDict & BaseEntityDict, T ex
|
|
|
36
36
|
operation: ED[T]['Create'];
|
|
37
37
|
}, context: Cxt, option: OperateOption) => Promise<number> | number;
|
|
38
38
|
}
|
|
39
|
-
interface TriggerCrossTxn<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>> {
|
|
39
|
+
interface TriggerCrossTxn<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> {
|
|
40
40
|
when: 'commit';
|
|
41
41
|
strict?: 'takeEasy' | 'makeSure';
|
|
42
42
|
cs?: true;
|
|
@@ -45,9 +45,9 @@ interface TriggerCrossTxn<ED extends EntityDict & BaseEntityDict, Cxt extends As
|
|
|
45
45
|
grouped?: true;
|
|
46
46
|
fn: (event: {
|
|
47
47
|
ids: string[];
|
|
48
|
-
}, context: Cxt, option: OperateOption) => Promise<((context: Cxt, option: OperateOption) => Promise<any>) | void>;
|
|
48
|
+
}, context: Cxt, option: OperateOption) => Promise<((context: Cxt, option: OperateOption) => Promise<any>) | void | ED[T]['Update']['data']>;
|
|
49
49
|
}
|
|
50
|
-
export interface CreateTriggerCrossTxn<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends CreateTriggerBase<ED, T, Cxt>, TriggerCrossTxn<ED, Cxt> {
|
|
50
|
+
export interface CreateTriggerCrossTxn<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends CreateTriggerBase<ED, T, Cxt>, TriggerCrossTxn<ED, T, Cxt> {
|
|
51
51
|
}
|
|
52
52
|
export type CreateTrigger<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = CreateTriggerInTxn<ED, T, Cxt> | CreateTriggerCrossTxn<ED, T, Cxt>;
|
|
53
53
|
/**
|
|
@@ -57,7 +57,7 @@ export type CreateTrigger<ED extends EntityDict & BaseEntityDict, T extends keyo
|
|
|
57
57
|
*/
|
|
58
58
|
export interface UpdateTriggerBase<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends TriggerBase<ED, T> {
|
|
59
59
|
action: Exclude<ED[T]['Action'], ExcludeUpdateAction> | Array<Exclude<ED[T]['Action'], ExcludeUpdateAction>>;
|
|
60
|
-
attributes?:
|
|
60
|
+
attributes?: Array<keyof ED[T]['OpSchema']>;
|
|
61
61
|
mt?: ModiTurn;
|
|
62
62
|
check?: (operation: ED[T]['Update']) => boolean;
|
|
63
63
|
filter?: ED[T]['Filter'] | ((operation: ED[T]['Update'], context: Cxt, option: OperateOption) => ED[T]['Filter'] | Promise<ED[T]['Filter']>);
|
|
@@ -68,7 +68,7 @@ export interface UpdateTriggerInTxn<ED extends EntityDict & BaseEntityDict, T ex
|
|
|
68
68
|
operation: ED[T]['Update'];
|
|
69
69
|
}, context: Cxt, option: OperateOption) => Promise<number> | number;
|
|
70
70
|
}
|
|
71
|
-
export interface UpdateTriggerCrossTxn<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends UpdateTriggerBase<ED, T, Cxt>, TriggerCrossTxn<ED, Cxt> {
|
|
71
|
+
export interface UpdateTriggerCrossTxn<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends UpdateTriggerBase<ED, T, Cxt>, TriggerCrossTxn<ED, T, Cxt> {
|
|
72
72
|
}
|
|
73
73
|
export type UpdateTrigger<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = UpdateTriggerInTxn<ED, T, Cxt> | UpdateTriggerCrossTxn<ED, T, Cxt>;
|
|
74
74
|
/**
|
|
@@ -88,7 +88,7 @@ export interface RemoveTriggerInTxn<ED extends EntityDict & BaseEntityDict, T ex
|
|
|
88
88
|
operation: ED[T]['Remove'];
|
|
89
89
|
}, context: Cxt, option: OperateOption) => Promise<number> | number;
|
|
90
90
|
}
|
|
91
|
-
export interface RemoveTriggerCrossTxn<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends RemoveTriggerBase<ED, T, Cxt>, TriggerCrossTxn<ED, Cxt> {
|
|
91
|
+
export interface RemoveTriggerCrossTxn<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends RemoveTriggerBase<ED, T, Cxt>, TriggerCrossTxn<ED, T, Cxt> {
|
|
92
92
|
}
|
|
93
93
|
export type RemoveTrigger<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = RemoveTriggerInTxn<ED, T, Cxt> | RemoveTriggerCrossTxn<ED, T, Cxt>;
|
|
94
94
|
export interface SelectTriggerBase<ED extends EntityDict & BaseEntityDict, T extends keyof ED> extends TriggerBase<ED, T> {
|