oak-domain 2.4.4 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/lib/base-app-domain/ActionDefDict.d.ts +4 -1
  2. package/lib/base-app-domain/ActionDefDict.js +3 -1
  3. package/lib/base-app-domain/EntityDict.d.ts +2 -0
  4. package/lib/base-app-domain/Modi/Action.d.ts +4 -4
  5. package/lib/base-app-domain/ModiEntity/Schema.d.ts +31 -4
  6. package/lib/base-app-domain/ModiEntity/Storage.js +1 -1
  7. package/lib/base-app-domain/OperEntity/Schema.d.ts +31 -4
  8. package/lib/base-app-domain/OperEntity/Storage.js +1 -1
  9. package/lib/base-app-domain/Storage.js +3 -1
  10. package/lib/base-app-domain/User/Action.d.ts +10 -0
  11. package/lib/base-app-domain/User/Action.js +12 -0
  12. package/lib/base-app-domain/User/Schema.d.ts +60 -8
  13. package/lib/base-app-domain/User/Storage.js +12 -1
  14. package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +121 -0
  15. package/lib/base-app-domain/UserEntityGrant/Schema.js +2 -0
  16. package/lib/base-app-domain/UserEntityGrant/Storage.d.ts +3 -0
  17. package/lib/base-app-domain/UserEntityGrant/Storage.js +28 -0
  18. package/lib/base-app-domain/_SubQuery.d.ts +8 -0
  19. package/lib/checkers/index.js +1 -1
  20. package/lib/compiler/schemalBuilder.js +50 -6
  21. package/lib/entities/User.d.ts +1 -0
  22. package/lib/entities/User.js +16 -0
  23. package/lib/entities/UserEntityGrant.d.ts +7 -0
  24. package/lib/entities/UserEntityGrant.js +12 -0
  25. package/lib/store/checker.js +3 -3
  26. package/lib/store/modi.js +33 -15
  27. package/lib/types/Trigger.d.ts +1 -0
  28. package/lib/types/Trigger.js +2 -1
  29. package/package.json +1 -1
  30. package/src/entities/User.ts +26 -1
  31. package/src/entities/UserEntityGrant.ts +24 -0
@@ -1,5 +1,8 @@
1
1
  export declare const ActionDefDict: {
2
2
  modi: {
3
- iState: import("../types").ActionDef<import("./Modi/Action").IAction, import("./Modi/Action").IState>;
3
+ iState: import("../types").ActionDef<string, string>;
4
+ };
5
+ user: {
6
+ userState: import("../types").ActionDef<string, string>;
4
7
  };
5
8
  };
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActionDefDict = void 0;
4
4
  var Action_1 = require("./Modi/Action");
5
+ var Action_2 = require("./User/Action");
5
6
  exports.ActionDefDict = {
6
- modi: Action_1.ActionDefDict
7
+ modi: Action_1.ActionDefDict,
8
+ user: Action_2.ActionDefDict
7
9
  };
@@ -3,10 +3,12 @@ import { EntityDef as ModiEntity } from "./ModiEntity/Schema";
3
3
  import { EntityDef as Oper } from "./Oper/Schema";
4
4
  import { EntityDef as OperEntity } from "./OperEntity/Schema";
5
5
  import { EntityDef as User } from "./User/Schema";
6
+ import { EntityDef as UserEntityGrant } from "./UserEntityGrant/Schema";
6
7
  export declare type EntityDict = {
7
8
  modi: Modi;
8
9
  modiEntity: ModiEntity;
9
10
  oper: Oper;
10
11
  operEntity: OperEntity;
11
12
  user: User;
13
+ userEntityGrant: UserEntityGrant;
12
14
  };
@@ -1,10 +1,10 @@
1
1
  import { ActionDef } from "../../types/Action";
2
2
  import { GenericAction } from "../../actions/action";
3
- export declare type IState = 'active' | 'applied' | 'abandoned';
4
- export declare type IAction = 'apply' | 'abandon';
3
+ export declare type IState = 'active' | 'applied' | 'abandoned' | string;
4
+ export declare type IAction = 'apply' | 'abandon' | string;
5
5
  export declare type ParticularAction = IAction;
6
- export declare type Action = GenericAction | ParticularAction;
6
+ export declare type Action = GenericAction | ParticularAction | string;
7
7
  export declare const actions: string[];
8
8
  export declare const ActionDefDict: {
9
- iState: ActionDef<IAction, IState>;
9
+ iState: ActionDef<string, string>;
10
10
  };
@@ -6,18 +6,20 @@ import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOper
6
6
  import { AppendOnlyAction } from "../../actions/action";
7
7
  import * as Modi from "../Modi/Schema";
8
8
  import * as User from "../User/Schema";
9
+ import * as UserEntityGrant from "../UserEntityGrant/Schema";
9
10
  export declare type OpSchema = EntityShape & {
10
11
  modiId: ForeignKey<"modi">;
11
- entity: "user" | string;
12
+ entity: "user" | "userEntityGrant" | string;
12
13
  entityId: String<64>;
13
14
  };
14
15
  export declare type OpAttr = keyof OpSchema;
15
16
  export declare type Schema = EntityShape & {
16
17
  modiId: ForeignKey<"modi">;
17
- entity: "user" | string;
18
+ entity: "user" | "userEntityGrant" | string;
18
19
  entityId: String<64>;
19
20
  modi: Modi.Schema;
20
21
  user?: User.Schema;
22
+ userEntityGrant?: UserEntityGrant.Schema;
21
23
  } & {
22
24
  [A in ExpressionKey]?: any;
23
25
  };
@@ -31,8 +33,9 @@ declare type AttrFilter<E> = {
31
33
  entity: E;
32
34
  entityId: Q_StringValue;
33
35
  user: User.Filter;
36
+ userEntityGrant: UserEntityGrant.Filter;
34
37
  };
35
- export declare type Filter<E = Q_EnumValue<"user" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
38
+ export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
36
39
  export declare type Projection = {
37
40
  "#id"?: NodeId;
38
41
  [k: string]: any;
@@ -45,6 +48,7 @@ export declare type Projection = {
45
48
  entity?: number;
46
49
  entityId?: number;
47
50
  user?: User.Projection;
51
+ userEntityGrant?: UserEntityGrant.Projection;
48
52
  } & Partial<ExprOp<OpAttr | string>>;
49
53
  declare type ModiEntityIdProjection = OneOf<{
50
54
  id: number;
@@ -55,6 +59,9 @@ declare type ModiIdProjection = OneOf<{
55
59
  declare type UserIdProjection = OneOf<{
56
60
  entityId: number;
57
61
  }>;
62
+ declare type UserEntityGrantIdProjection = OneOf<{
63
+ entityId: number;
64
+ }>;
58
65
  export declare type SortAttr = {
59
66
  id: number;
60
67
  } | {
@@ -73,6 +80,8 @@ export declare type SortAttr = {
73
80
  entityId: number;
74
81
  } | {
75
82
  user: User.SortAttr;
83
+ } | {
84
+ userEntityGrant: UserEntityGrant.SortAttr;
76
85
  } | {
77
86
  [k: string]: any;
78
87
  } | OneOf<ExprOp<OpAttr | string>>;
@@ -103,6 +112,17 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
103
112
  } | {
104
113
  entity: "user";
105
114
  entityId: String<64>;
115
+ } | {
116
+ entity?: never;
117
+ entityId?: never;
118
+ userEntityGrant: UserEntityGrant.CreateSingleOperation;
119
+ } | {
120
+ entity: "userEntityGrant";
121
+ entityId: String<64>;
122
+ userEntityGrant: UserEntityGrant.UpdateOperation;
123
+ } | {
124
+ entity: "userEntityGrant";
125
+ entityId: String<64>;
106
126
  } | {
107
127
  entity?: string;
108
128
  entityId?: string;
@@ -128,7 +148,11 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity"
128
148
  entityId?: never;
129
149
  entity?: never;
130
150
  } | {
131
- entity?: ("user" | string) | null;
151
+ userEntityGrant?: UserEntityGrant.CreateSingleOperation | UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
152
+ entityId?: never;
153
+ entity?: never;
154
+ } | {
155
+ entity?: ("user" | "userEntityGrant" | string) | null;
132
156
  entityId?: String<64> | null;
133
157
  }) & {
134
158
  [k: string]: any;
@@ -138,6 +162,8 @@ export declare type RemoveOperationData = {} & (({
138
162
  modi?: Modi.UpdateOperation | Modi.RemoveOperation;
139
163
  })) & ({
140
164
  user?: User.UpdateOperation | User.RemoveOperation;
165
+ } | {
166
+ userEntityGrant?: UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
141
167
  } | {
142
168
  [k: string]: any;
143
169
  });
@@ -145,6 +171,7 @@ export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData
145
171
  export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
146
172
  export declare type ModiIdSubQuery = Selection<ModiIdProjection>;
147
173
  export declare type UserIdSubQuery = Selection<UserIdProjection>;
174
+ export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
148
175
  export declare type ModiEntityIdSubQuery = Selection<ModiEntityIdProjection>;
149
176
  export declare type EntityDef = {
150
177
  Schema: Schema;
@@ -13,7 +13,7 @@ exports.desc = {
13
13
  params: {
14
14
  length: 32
15
15
  },
16
- ref: ["user"]
16
+ ref: ["user", "userEntityGrant"]
17
17
  },
18
18
  entityId: {
19
19
  type: "varchar",
@@ -7,19 +7,21 @@ import { AppendOnlyAction } from "../../actions/action";
7
7
  import * as Oper from "../Oper/Schema";
8
8
  import * as Modi from "../Modi/Schema";
9
9
  import * as User from "../User/Schema";
10
+ import * as UserEntityGrant from "../UserEntityGrant/Schema";
10
11
  export declare type OpSchema = EntityShape & {
11
12
  operId: ForeignKey<"oper">;
12
- entity: "modi" | "user" | string;
13
+ entity: "modi" | "user" | "userEntityGrant" | string;
13
14
  entityId: String<64>;
14
15
  };
15
16
  export declare type OpAttr = keyof OpSchema;
16
17
  export declare type Schema = EntityShape & {
17
18
  operId: ForeignKey<"oper">;
18
- entity: "modi" | "user" | string;
19
+ entity: "modi" | "user" | "userEntityGrant" | string;
19
20
  entityId: String<64>;
20
21
  oper: Oper.Schema;
21
22
  modi?: Modi.Schema;
22
23
  user?: User.Schema;
24
+ userEntityGrant?: UserEntityGrant.Schema;
23
25
  } & {
24
26
  [A in ExpressionKey]?: any;
25
27
  };
@@ -34,8 +36,9 @@ declare type AttrFilter<E> = {
34
36
  entityId: Q_StringValue;
35
37
  modi: Modi.Filter;
36
38
  user: User.Filter;
39
+ userEntityGrant: UserEntityGrant.Filter;
37
40
  };
38
- export declare type Filter<E = Q_EnumValue<"modi" | "user" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
41
+ export declare type Filter<E = Q_EnumValue<"modi" | "user" | "userEntityGrant" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
39
42
  export declare type Projection = {
40
43
  "#id"?: NodeId;
41
44
  [k: string]: any;
@@ -49,6 +52,7 @@ export declare type Projection = {
49
52
  entityId?: number;
50
53
  modi?: Modi.Projection;
51
54
  user?: User.Projection;
55
+ userEntityGrant?: UserEntityGrant.Projection;
52
56
  } & Partial<ExprOp<OpAttr | string>>;
53
57
  declare type OperEntityIdProjection = OneOf<{
54
58
  id: number;
@@ -62,6 +66,9 @@ declare type ModiIdProjection = OneOf<{
62
66
  declare type UserIdProjection = OneOf<{
63
67
  entityId: number;
64
68
  }>;
69
+ declare type UserEntityGrantIdProjection = OneOf<{
70
+ entityId: number;
71
+ }>;
65
72
  export declare type SortAttr = {
66
73
  id: number;
67
74
  } | {
@@ -82,6 +89,8 @@ export declare type SortAttr = {
82
89
  modi: Modi.SortAttr;
83
90
  } | {
84
91
  user: User.SortAttr;
92
+ } | {
93
+ userEntityGrant: UserEntityGrant.SortAttr;
85
94
  } | {
86
95
  [k: string]: any;
87
96
  } | OneOf<ExprOp<OpAttr | string>>;
@@ -120,6 +129,17 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
120
129
  } | {
121
130
  entity: "user";
122
131
  entityId: String<64>;
132
+ } | {
133
+ entity?: never;
134
+ entityId?: never;
135
+ userEntityGrant: UserEntityGrant.CreateSingleOperation;
136
+ } | {
137
+ entity: "userEntityGrant";
138
+ entityId: String<64>;
139
+ userEntityGrant: UserEntityGrant.UpdateOperation;
140
+ } | {
141
+ entity: "userEntityGrant";
142
+ entityId: String<64>;
123
143
  } | {
124
144
  entity?: string;
125
145
  entityId?: string;
@@ -143,7 +163,11 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity"
143
163
  entityId?: never;
144
164
  entity?: never;
145
165
  } | {
146
- entity?: ("modi" | "user" | string) | null;
166
+ userEntityGrant?: UserEntityGrant.CreateSingleOperation | UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
167
+ entityId?: never;
168
+ entity?: never;
169
+ } | {
170
+ entity?: ("modi" | "user" | "userEntityGrant" | string) | null;
147
171
  entityId?: String<64> | null;
148
172
  }) & {
149
173
  [k: string]: any;
@@ -153,6 +177,8 @@ export declare type RemoveOperationData = {} & ({
153
177
  modi?: Modi.UpdateOperation | Modi.RemoveOperation;
154
178
  } | {
155
179
  user?: User.UpdateOperation | User.RemoveOperation;
180
+ } | {
181
+ userEntityGrant?: UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
156
182
  } | {
157
183
  [k: string]: any;
158
184
  });
@@ -161,6 +187,7 @@ export declare type Operation = CreateOperation | UpdateOperation | RemoveOperat
161
187
  export declare type OperIdSubQuery = Selection<OperIdProjection>;
162
188
  export declare type ModiIdSubQuery = Selection<ModiIdProjection>;
163
189
  export declare type UserIdSubQuery = Selection<UserIdProjection>;
190
+ export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
164
191
  export declare type OperEntityIdSubQuery = Selection<OperEntityIdProjection>;
165
192
  export declare type EntityDef = {
166
193
  Schema: Schema;
@@ -13,7 +13,7 @@ exports.desc = {
13
13
  params: {
14
14
  length: 32
15
15
  },
16
- ref: ["modi", "user"]
16
+ ref: ["modi", "user", "userEntityGrant"]
17
17
  },
18
18
  entityId: {
19
19
  type: "varchar",
@@ -6,10 +6,12 @@ var Storage_2 = require("./ModiEntity/Storage");
6
6
  var Storage_3 = require("./Oper/Storage");
7
7
  var Storage_4 = require("./OperEntity/Storage");
8
8
  var Storage_5 = require("./User/Storage");
9
+ var Storage_6 = require("./UserEntityGrant/Storage");
9
10
  exports.storageSchema = {
10
11
  modi: Storage_1.desc,
11
12
  modiEntity: Storage_2.desc,
12
13
  oper: Storage_3.desc,
13
14
  operEntity: Storage_4.desc,
14
- user: Storage_5.desc
15
+ user: Storage_5.desc,
16
+ userEntityGrant: Storage_6.desc
15
17
  };
@@ -0,0 +1,10 @@
1
+ import { ActionDef } from "../../types/Action";
2
+ import { GenericAction, RelationAction } from "../../actions/action";
3
+ export declare type UserAction = 'mergeTo' | string;
4
+ export declare type UserState = 'normal' | 'merged' | string;
5
+ export declare type ParticularAction = UserAction;
6
+ export declare type Action = GenericAction | ParticularAction | RelationAction | string;
7
+ export declare const actions: string[];
8
+ export declare const ActionDefDict: {
9
+ userState: ActionDef<string, string>;
10
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionDefDict = exports.actions = void 0;
4
+ exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "grant", "revoke", "mergeTo"];
5
+ var UserActionDef = {
6
+ stm: {
7
+ mergeTo: ['normal', 'merged']
8
+ }
9
+ };
10
+ exports.ActionDefDict = {
11
+ userState: UserActionDef
12
+ };
@@ -1,9 +1,10 @@
1
- import { String, Text } from "../../types/DataType";
2
- import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
1
+ import { String, Text, ForeignKey } from "../../types/DataType";
2
+ import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
3
3
  import { OneOf } from "../../types/Polyfill";
4
4
  import * as SubQuery from "../_SubQuery";
5
5
  import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity";
6
- import { GenericAction, RelationAction } from "../../actions/action";
6
+ import { Action, ParticularAction, UserState } from "./Action";
7
+ import { RelationAction } from "../../actions/action";
7
8
  import * as Oper from "../Oper/Schema";
8
9
  import * as OperEntity from "../OperEntity/Schema";
9
10
  import * as ModiEntity from "../ModiEntity/Schema";
@@ -11,14 +12,21 @@ export declare type OpSchema = EntityShape & {
11
12
  name?: String<16> | null;
12
13
  nickname?: String<64> | null;
13
14
  password?: Text | null;
15
+ refId?: ForeignKey<"user"> | null;
16
+ userState?: UserState | null;
14
17
  };
15
18
  export declare type OpAttr = keyof OpSchema;
16
19
  export declare type Schema = EntityShape & {
17
20
  name?: String<16> | null;
18
21
  nickname?: String<64> | null;
19
22
  password?: Text | null;
23
+ refId?: ForeignKey<"user"> | null;
24
+ userState?: UserState | null;
25
+ ref?: Schema | null;
20
26
  oper$operator?: Array<Oper.Schema>;
21
27
  oper$operator$$aggr?: AggregationResult<Oper.Schema>;
28
+ user$ref?: Array<Schema>;
29
+ user$ref$$aggr?: AggregationResult<Schema>;
22
30
  operEntity$entity?: Array<OperEntity.Schema>;
23
31
  operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
24
32
  modiEntity$entity?: Array<ModiEntity.Schema>;
@@ -34,6 +42,9 @@ declare type AttrFilter = {
34
42
  name: Q_StringValue;
35
43
  nickname: Q_StringValue;
36
44
  password: Q_StringValue;
45
+ refId: Q_StringValue | SubQuery.UserIdSubQuery;
46
+ ref: Filter;
47
+ userState: Q_EnumValue<UserState>;
37
48
  };
38
49
  export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
39
50
  export declare type Projection = {
@@ -46,12 +57,21 @@ export declare type Projection = {
46
57
  name?: number;
47
58
  nickname?: number;
48
59
  password?: number;
60
+ refId?: number;
61
+ ref?: Projection;
62
+ userState?: number;
49
63
  oper$operator?: Oper.Selection & {
50
64
  $entity: "oper";
51
65
  };
52
66
  oper$operator$$aggr?: Oper.Aggregation & {
53
67
  $entity: "oper";
54
68
  };
69
+ user$ref?: Selection & {
70
+ $entity: "user";
71
+ };
72
+ user$ref$$aggr?: Aggregation & {
73
+ $entity: "user";
74
+ };
55
75
  operEntity$entity?: OperEntity.Selection & {
56
76
  $entity: "operEntity";
57
77
  };
@@ -67,6 +87,7 @@ export declare type Projection = {
67
87
  } & Partial<ExprOp<OpAttr | string>>;
68
88
  declare type UserIdProjection = OneOf<{
69
89
  id: number;
90
+ refId: number;
70
91
  }>;
71
92
  export declare type SortAttr = {
72
93
  id: number;
@@ -82,6 +103,12 @@ export declare type SortAttr = {
82
103
  nickname: number;
83
104
  } | {
84
105
  password: number;
106
+ } | {
107
+ refId: number;
108
+ } | {
109
+ ref: SortAttr;
110
+ } | {
111
+ userState: number;
85
112
  } | {
86
113
  [k: string]: any;
87
114
  } | OneOf<ExprOp<OpAttr | string>>;
@@ -93,29 +120,53 @@ export declare type Sorter = SortNode[];
93
120
  export declare type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
94
121
  export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
95
122
  export declare type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
96
- export declare type CreateOperationData = FormCreateData<OpSchema> & {
123
+ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "refId">> & (({
124
+ refId?: never;
125
+ ref?: CreateSingleOperation;
126
+ } | {
127
+ refId: String<64>;
128
+ ref?: UpdateOperation;
129
+ } | {
130
+ refId?: String<64>;
131
+ })) & {
97
132
  oper$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>;
133
+ user$ref?: OakOperation<UpdateOperation["action"], Omit<UpdateOperationData, "ref" | "refId">, Filter> | OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">[]> | Array<OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">> | OakOperation<UpdateOperation["action"], Omit<UpdateOperationData, "ref" | "refId">, Filter>>;
98
134
  operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
99
135
  modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
100
136
  };
101
137
  export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
102
138
  export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
103
139
  export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
104
- export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
140
+ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "refId">> & (({
141
+ ref: CreateSingleOperation;
142
+ refId?: never;
143
+ } | {
144
+ ref: UpdateOperation;
145
+ refId?: never;
146
+ } | {
147
+ ref: RemoveOperation;
148
+ refId?: never;
149
+ } | {
150
+ ref?: never;
151
+ refId?: String<64> | null;
152
+ })) & {
105
153
  [k: string]: any;
106
154
  oper$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>;
155
+ user$ref?: UpdateOperation | RemoveOperation | OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">[]> | Array<OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">> | UpdateOperation | RemoveOperation>;
107
156
  operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
108
157
  modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
109
158
  };
110
- export declare type UpdateOperation = OakOperation<"update" | RelationAction | string, UpdateOperationData, Filter, Sorter>;
111
- export declare type RemoveOperationData = {};
159
+ export declare type UpdateOperation = OakOperation<"update" | ParticularAction | RelationAction | string, UpdateOperationData, Filter, Sorter>;
160
+ export declare type RemoveOperationData = {} & (({
161
+ ref?: UpdateOperation | RemoveOperation;
162
+ }));
112
163
  export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
113
164
  export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
114
165
  export declare type UserIdSubQuery = Selection<UserIdProjection>;
115
166
  export declare type EntityDef = {
116
167
  Schema: Schema;
117
168
  OpSchema: OpSchema;
118
- Action: OakMakeAction<GenericAction | RelationAction> | string;
169
+ Action: OakMakeAction<Action | RelationAction> | string;
119
170
  Selection: Selection;
120
171
  Aggregation: Aggregation;
121
172
  Operation: Operation;
@@ -124,5 +175,6 @@ export declare type EntityDef = {
124
175
  Remove: RemoveOperation;
125
176
  CreateSingle: CreateSingleOperation;
126
177
  CreateMulti: CreateMultipleOperation;
178
+ ParticularAction: ParticularAction;
127
179
  };
128
180
  export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.desc = void 0;
4
+ var Action_1 = require("./Action");
4
5
  var action_1 = require("../../actions/action");
5
6
  exports.desc = {
6
7
  attributes: {
@@ -18,8 +19,18 @@ exports.desc = {
18
19
  },
19
20
  password: {
20
21
  type: "text"
22
+ },
23
+ refId: {
24
+ type: "ref",
25
+ ref: "user"
26
+ },
27
+ userState: {
28
+ type: "varchar",
29
+ params: {
30
+ length: 24
31
+ }
21
32
  }
22
33
  },
23
34
  actionType: "crud",
24
- actions: action_1.genericActions.concat(action_1.relationActions)
35
+ actions: Action_1.actions.concat(action_1.relationActions)
25
36
  };
@@ -0,0 +1,121 @@
1
+ import { String } from "../../types/DataType";
2
+ import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
3
+ import { OneOf } from "../../types/Polyfill";
4
+ import * as SubQuery from "../_SubQuery";
5
+ import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity";
6
+ import { GenericAction } from "../../actions/action";
7
+ import * as OperEntity from "../OperEntity/Schema";
8
+ import * as ModiEntity from "../ModiEntity/Schema";
9
+ export declare type OpSchema = EntityShape & {
10
+ entity: String<32>;
11
+ entityId: String<64>;
12
+ relation: String<32>;
13
+ };
14
+ export declare type OpAttr = keyof OpSchema;
15
+ export declare type Schema = EntityShape & {
16
+ entity: String<32>;
17
+ entityId: String<64>;
18
+ relation: String<32>;
19
+ operEntity$entity?: Array<OperEntity.Schema>;
20
+ operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
21
+ modiEntity$entity?: Array<ModiEntity.Schema>;
22
+ modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>;
23
+ } & {
24
+ [A in ExpressionKey]?: any;
25
+ };
26
+ declare type AttrFilter = {
27
+ id: Q_StringValue | SubQuery.UserEntityGrantIdSubQuery;
28
+ $$createAt$$: Q_DateValue;
29
+ $$seq$$: Q_StringValue;
30
+ $$updateAt$$: Q_DateValue;
31
+ entity: Q_StringValue;
32
+ entityId: Q_StringValue;
33
+ relation: Q_StringValue;
34
+ };
35
+ export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
36
+ export declare type Projection = {
37
+ "#id"?: NodeId;
38
+ [k: string]: any;
39
+ id?: number;
40
+ $$createAt$$?: number;
41
+ $$updateAt$$?: number;
42
+ $$seq$$?: number;
43
+ entity?: number;
44
+ entityId?: number;
45
+ relation?: number;
46
+ operEntity$entity?: OperEntity.Selection & {
47
+ $entity: "operEntity";
48
+ };
49
+ operEntity$entity$$aggr?: OperEntity.Aggregation & {
50
+ $entity: "operEntity";
51
+ };
52
+ modiEntity$entity?: ModiEntity.Selection & {
53
+ $entity: "modiEntity";
54
+ };
55
+ modiEntity$entity$$aggr?: ModiEntity.Aggregation & {
56
+ $entity: "modiEntity";
57
+ };
58
+ } & Partial<ExprOp<OpAttr | string>>;
59
+ declare type UserEntityGrantIdProjection = OneOf<{
60
+ id: number;
61
+ }>;
62
+ export declare type SortAttr = {
63
+ id: number;
64
+ } | {
65
+ $$createAt$$: number;
66
+ } | {
67
+ $$seq$$: number;
68
+ } | {
69
+ $$updateAt$$: number;
70
+ } | {
71
+ entity: number;
72
+ } | {
73
+ entityId: number;
74
+ } | {
75
+ relation: number;
76
+ } | {
77
+ [k: string]: any;
78
+ } | OneOf<ExprOp<OpAttr | string>>;
79
+ export declare type SortNode = {
80
+ $attr: SortAttr;
81
+ $direction?: "asc" | "desc";
82
+ };
83
+ export declare type Sorter = SortNode[];
84
+ export declare type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
85
+ export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
86
+ export declare type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
87
+ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId">> & ({
88
+ entity?: string;
89
+ entityId?: string;
90
+ [K: string]: any;
91
+ }) & {
92
+ operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
93
+ modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
94
+ };
95
+ export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
96
+ export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
97
+ export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
98
+ export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
99
+ [k: string]: any;
100
+ operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
101
+ modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
102
+ };
103
+ export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
104
+ export declare type RemoveOperationData = {};
105
+ export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
106
+ export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
107
+ export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
108
+ export declare type EntityDef = {
109
+ Schema: Schema;
110
+ OpSchema: OpSchema;
111
+ Action: OakMakeAction<GenericAction> | string;
112
+ Selection: Selection;
113
+ Aggregation: Aggregation;
114
+ Operation: Operation;
115
+ Create: CreateOperation;
116
+ Update: UpdateOperation;
117
+ Remove: RemoveOperation;
118
+ CreateSingle: CreateSingleOperation;
119
+ CreateMulti: CreateMultipleOperation;
120
+ };
121
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { StorageDesc } from "../../types/Storage";
2
+ import { OpSchema } from "./Schema";
3
+ export declare const desc: StorageDesc<OpSchema>;
@@ -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
  };
@@ -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
- // checkers.push(...createRemoveCheckers<ED, Cxt>(schema));
10
+ checkers.push.apply(checkers, tslib_1.__spreadArray([], tslib_1.__read((0, checker_1.createRemoveCheckers)(schema)), 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
- if (!path.includes('oak-general-business')) {
321
- console.log("\u51FA\u73B0\u4E86\u540C\u540D\u7684Entity\u5B9A\u4E49\u300C".concat(moduleName, "\u300D\uFF0C\u5C06\u4F7F\u7528\u60A8\u6240\u5B9A\u4E49\u7684\u5BF9\u8C61\u7ED3\u6784\u53D6\u4EE3\u6389\u9ED8\u8BA4\u5BF9\u8C61\uFF0C\u8BF7\u786E\u8BA4"));
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].push(moduleName);
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
- pushStatementIntoActionAst(moduleName, factory.updateTypeAliasDeclaration(node, node.decorators, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], node.name, node.typeParameters, node.type), sourceFile);
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) {
@@ -4,4 +4,5 @@ export interface Schema extends EntityShape {
4
4
  name?: String<16>;
5
5
  nickname?: String<64>;
6
6
  password?: Text;
7
+ ref?: Schema;
7
8
  }
@@ -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
  };
@@ -0,0 +1,7 @@
1
+ import { String } from '../types/DataType';
2
+ import { EntityShape } from '../types/Entity';
3
+ export interface Schema extends EntityShape {
4
+ entity: String<32>;
5
+ entityId: String<64>;
6
+ relation: String<32>;
7
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ var locale = {
5
+ zh_CN: {
6
+ attr: {
7
+ relation: '关系',
8
+ entity: '关联对象',
9
+ entityId: '关联对象id',
10
+ },
11
+ },
12
+ };
@@ -546,8 +546,8 @@ function createRemoveCheckers(schema) {
546
546
  }
547
547
  };
548
548
  for (var entity in schema) {
549
- if (['operEntity'].includes(entity)) {
550
- continue; // OperEntity会指向每一个对象,不必处理
549
+ if (['operEntity', 'modiEntity', 'userEntityGrant'].includes(entity)) {
550
+ continue; // 系统功能性数据,不用处理
551
551
  }
552
552
  var attributes = schema[entity].attributes;
553
553
  for (var attr in attributes) {
@@ -565,7 +565,7 @@ function createRemoveCheckers(schema) {
565
565
  }
566
566
  }
567
567
  // 当删除一时,要确认多上面没有指向一的数据
568
- var entities = (0, lodash_1.intersection)(Object.keys(OneToManyMatrix), Object.keys(OneToManyOnEntityMatrix));
568
+ var entities = (0, lodash_1.union)(Object.keys(OneToManyMatrix), Object.keys(OneToManyOnEntityMatrix));
569
569
  var _loop_3 = function (entity) {
570
570
  checkers.push({
571
571
  entity: entity,
package/lib/store/modi.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createModiRelatedTriggers = exports.createModiRelatedCheckers = exports.abandonModis = exports.applyModis = exports.createOperationsFromModies = void 0;
4
4
  var tslib_1 = require("tslib");
5
+ var types_1 = require("../types");
5
6
  var action_1 = require("../actions/action");
6
7
  var lodash_1 = require("../utils/lodash");
7
8
  var uuid_1 = require("../utils/uuid");
@@ -154,35 +155,52 @@ function createModiRelatedTriggers(schema) {
154
155
  if (inModi) {
155
156
  // 当关联modi的对象被删除时,对应的modi也删除
156
157
  triggers.push({
157
- name: "\u5F53\u5220\u9664".concat(entity, "\u5BF9\u8C61\u65F6\uFF0C\u5220\u9664\u76F8\u5173\u8054\u8FD8\u6D3B\u8DC3\u7684modi"),
158
+ name: "\u5F53\u5220\u9664".concat(entity, "\u5BF9\u8C61\u65F6\uFF0C\u5220\u9664\u76F8\u5173\u8054\u7684modi\u7684modiEntity"),
158
159
  action: 'remove',
159
160
  entity: entity,
160
161
  when: 'after',
162
+ priority: types_1.REMOVE_CASCADE_PRIORITY,
161
163
  fn: function (_a, context, option) {
162
164
  var operation = _a.operation;
163
165
  return tslib_1.__awaiter(_this, void 0, void 0, function () {
164
- var data, id, _b, _c, _d;
165
- var _e;
166
- return tslib_1.__generator(this, function (_f) {
167
- switch (_f.label) {
166
+ var data, id, _b, _c, _d, _e, _f, _g;
167
+ var _h, _j;
168
+ return tslib_1.__generator(this, function (_k) {
169
+ switch (_k.label) {
168
170
  case 0:
169
171
  data = operation.data;
170
172
  id = data.id;
171
173
  _c = (_b = context).operate;
172
- _d = ['modi'];
173
- _e = {};
174
+ _d = ['modiEntity'];
175
+ _h = {};
174
176
  return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
175
- case 1: return [4 /*yield*/, _c.apply(_b, _d.concat([(_e.id = _f.sent(),
176
- _e.action = 'remove',
177
- _e.data = {},
178
- _e.filter = {
177
+ case 1: return [4 /*yield*/, _c.apply(_b, _d.concat([(_h.id = _k.sent(),
178
+ _h.action = 'remove',
179
+ _h.data = {},
180
+ _h.filter = {
181
+ modi: {
182
+ entity: entity,
183
+ entityId: id,
184
+ },
185
+ },
186
+ _h), { dontCollect: true }]))];
187
+ case 2:
188
+ _k.sent();
189
+ _f = (_e = context).operate;
190
+ _g = ['modi'];
191
+ _j = {};
192
+ return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
193
+ case 3: return [4 /*yield*/, _f.apply(_e, _g.concat([(_j.id = _k.sent(),
194
+ _j.action = 'remove',
195
+ _j.data = {},
196
+ _j.filter = {
179
197
  entity: entity,
180
198
  entityId: id,
181
199
  },
182
- _e), option]))];
183
- case 2:
184
- _f.sent();
185
- return [2 /*return*/, 1];
200
+ _j), { dontCollect: true }]))];
201
+ case 4:
202
+ _k.sent();
203
+ return [2 /*return*/, 0];
186
204
  }
187
205
  });
188
206
  });
@@ -12,6 +12,7 @@ export declare const TRIGGER_MIN_PRIORITY = 1;
12
12
  export declare const TRIGGER_MAX_PRIORITY = 99;
13
13
  export declare const DATA_CHECKER_DEFAULT_PRIORITY = 60;
14
14
  export declare const CHECKER_DEFAULT_PRIORITY = 99;
15
+ export declare const REMOVE_CASCADE_PRIORITY = 70;
15
16
  interface TriggerBase<ED extends EntityDict, T extends keyof ED> {
16
17
  checkerType?: CheckerType;
17
18
  entity: T;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHECKER_DEFAULT_PRIORITY = exports.DATA_CHECKER_DEFAULT_PRIORITY = exports.TRIGGER_MAX_PRIORITY = exports.TRIGGER_MIN_PRIORITY = exports.TRIGGER_DEFAULT_PRIORITY = void 0;
3
+ exports.REMOVE_CASCADE_PRIORITY = exports.CHECKER_DEFAULT_PRIORITY = exports.DATA_CHECKER_DEFAULT_PRIORITY = exports.TRIGGER_MAX_PRIORITY = exports.TRIGGER_MIN_PRIORITY = exports.TRIGGER_DEFAULT_PRIORITY = void 0;
4
4
  /**
5
5
  * 优先级越小,越早执行。定义在1~99之间
6
6
  */
@@ -9,6 +9,7 @@ exports.TRIGGER_MIN_PRIORITY = 1;
9
9
  exports.TRIGGER_MAX_PRIORITY = 99;
10
10
  exports.DATA_CHECKER_DEFAULT_PRIORITY = 60;
11
11
  exports.CHECKER_DEFAULT_PRIORITY = 99;
12
+ exports.REMOVE_CASCADE_PRIORITY = 70;
12
13
  ;
13
14
  ;
14
15
  ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-domain",
3
- "version": "2.4.4",
3
+ "version": "2.5.1",
4
4
  "author": {
5
5
  "name": "XuChang"
6
6
  },
@@ -1,20 +1,45 @@
1
1
  import { String, Int, Text, Image, Datetime } from '../types/DataType';
2
2
  import { LocaleDef } from '../types/Locale';
3
3
  import { EntityShape } from '../types/Entity';
4
+ import { ActionDef } from '../types/Action';
4
5
 
5
6
  export interface Schema extends EntityShape {
6
7
  name?: String<16>;
7
8
  nickname?: String<64>;
8
9
  password?: Text;
10
+ ref?: Schema;
9
11
  };
10
12
 
13
+ type UserAction = 'mergeTo';
14
+ type UserState = 'normal' | 'merged';
11
15
 
12
- const locale: LocaleDef<Schema, '', '', {}> = {
16
+ type Action = UserAction;
17
+
18
+ const UserActionDef: ActionDef<UserAction, UserState> = {
19
+ stm: {
20
+ mergeTo: ['normal', 'merged'],
21
+ },
22
+ };
23
+
24
+ const locale: LocaleDef<Schema, Action, '', {
25
+ userState: UserState;
26
+ }> = {
13
27
  zh_CN: {
14
28
  attr: {
15
29
  name: '姓名',
16
30
  nickname: '昵称',
17
31
  password: '密码',
32
+ ref: '指向用户',
33
+ userState: '状态',
34
+ },
35
+ action: {
36
+ mergeTo: '合并',
18
37
  },
38
+ v: {
39
+ userState: {
40
+ normal: '正常',
41
+ merged: '已被合并',
42
+ },
43
+ }
19
44
  },
20
45
  };
@@ -0,0 +1,24 @@
1
+ import { String } from '../types/DataType';
2
+ import { LocaleDef } from '../types/Locale';
3
+ import { EntityShape } from '../types/Entity';
4
+
5
+ export interface Schema extends EntityShape {
6
+ entity: String<32>;
7
+ entityId: String<64>;
8
+ relation: String<32>;
9
+ };
10
+
11
+ const locale: LocaleDef<
12
+ Schema,
13
+ '',
14
+ '',
15
+ {}
16
+ > = {
17
+ zh_CN: {
18
+ attr: {
19
+ relation: '关系',
20
+ entity: '关联对象',
21
+ entityId: '关联对象id',
22
+ },
23
+ },
24
+ };