oak-domain 2.4.1 → 2.4.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.
Files changed (40) hide show
  1. package/lib/actions/action.d.ts +8 -8
  2. package/lib/actions/action.js +1 -1
  3. package/lib/actions/relation.d.ts +1 -1
  4. package/lib/base-app-domain/EntityDict.d.ts +1 -1
  5. package/lib/base-app-domain/Modi/Action.d.ts +4 -4
  6. package/lib/base-app-domain/Modi/Action.js +1 -1
  7. package/lib/base-app-domain/Modi/Schema.d.ts +27 -27
  8. package/lib/base-app-domain/ModiEntity/Schema.d.ts +29 -29
  9. package/lib/base-app-domain/Oper/Schema.d.ts +28 -28
  10. package/lib/base-app-domain/OperEntity/Schema.d.ts +31 -31
  11. package/lib/base-app-domain/User/Schema.d.ts +28 -28
  12. package/lib/base-app-domain/_SubQuery.d.ts +5 -5
  13. package/lib/compiler/schemalBuilder.js +29 -27
  14. package/lib/store/CascadeStore.js +20 -24
  15. package/lib/store/TriggerExecutor.d.ts +1 -1
  16. package/lib/store/actionDef.js +223 -25
  17. package/lib/types/Action.d.ts +5 -5
  18. package/lib/types/Auth.d.ts +9 -9
  19. package/lib/types/DataType.d.ts +14 -14
  20. package/lib/types/Demand.d.ts +23 -23
  21. package/lib/types/Endpoint.d.ts +1 -1
  22. package/lib/types/Entity.d.ts +54 -47
  23. package/lib/types/Exception.d.ts +10 -0
  24. package/lib/types/Exception.js +17 -1
  25. package/lib/types/Expression.d.ts +14 -14
  26. package/lib/types/Geo.d.ts +6 -6
  27. package/lib/types/Locale.d.ts +5 -5
  28. package/lib/types/Polyfill.d.ts +8 -8
  29. package/lib/types/Port.d.ts +2 -2
  30. package/lib/types/RowStore.d.ts +1 -1
  31. package/lib/types/Storage.d.ts +4 -4
  32. package/lib/types/Timer.d.ts +3 -3
  33. package/lib/types/Trigger.d.ts +5 -5
  34. package/lib/types/Watcher.d.ts +2 -2
  35. package/lib/types/schema/DataTypes.d.ts +7 -7
  36. package/lib/utils/concurrent.d.ts +1 -1
  37. package/lib/utils/uuid.d.ts +1 -1
  38. package/lib/utils/uuid.js +1 -1
  39. package/lib/utils/validator.d.ts +2 -2
  40. package/package.json +1 -1
@@ -2,18 +2,18 @@ import { String, Text } from "../../types/DataType";
2
2
  import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
3
3
  import { OneOf } from "../../types/Polyfill";
4
4
  import * as SubQuery from "../_SubQuery";
5
- import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity";
5
+ import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity";
6
6
  import { GenericAction, RelationAction } from "../../actions/action";
7
7
  import * as Oper from "../Oper/Schema";
8
8
  import * as OperEntity from "../OperEntity/Schema";
9
9
  import * as ModiEntity from "../ModiEntity/Schema";
10
- export type OpSchema = EntityShape & {
10
+ export declare type OpSchema = EntityShape & {
11
11
  name?: String<16> | null;
12
12
  nickname?: String<64> | null;
13
13
  password?: Text | null;
14
14
  };
15
- export type OpAttr = keyof OpSchema;
16
- export type Schema = EntityShape & {
15
+ export declare type OpAttr = keyof OpSchema;
16
+ export declare type Schema = EntityShape & {
17
17
  name?: String<16> | null;
18
18
  nickname?: String<64> | null;
19
19
  password?: Text | null;
@@ -26,7 +26,7 @@ export type Schema = EntityShape & {
26
26
  } & {
27
27
  [A in ExpressionKey]?: any;
28
28
  };
29
- type AttrFilter = {
29
+ declare type AttrFilter = {
30
30
  id: Q_StringValue | SubQuery.UserIdSubQuery;
31
31
  $$createAt$$: Q_DateValue;
32
32
  $$seq$$: Q_StringValue;
@@ -35,8 +35,8 @@ type AttrFilter = {
35
35
  nickname: Q_StringValue;
36
36
  password: Q_StringValue;
37
37
  };
38
- export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
39
- export type Projection = {
38
+ export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
39
+ export declare type Projection = {
40
40
  "#id"?: NodeId;
41
41
  [k: string]: any;
42
42
  id?: number;
@@ -65,10 +65,10 @@ export type Projection = {
65
65
  $entity: "modiEntity";
66
66
  };
67
67
  } & Partial<ExprOp<OpAttr | string>>;
68
- type UserIdProjection = OneOf<{
68
+ declare type UserIdProjection = OneOf<{
69
69
  id: number;
70
70
  }>;
71
- export type SortAttr = {
71
+ export declare type SortAttr = {
72
72
  id: number;
73
73
  } | {
74
74
  $$createAt$$: number;
@@ -85,34 +85,34 @@ export type SortAttr = {
85
85
  } | {
86
86
  [k: string]: any;
87
87
  } | OneOf<ExprOp<OpAttr | string>>;
88
- export type SortNode = {
88
+ export declare type SortNode = {
89
89
  $attr: SortAttr;
90
90
  $direction?: "asc" | "desc";
91
91
  };
92
- export type Sorter = SortNode[];
93
- export type SelectOperation<P extends Object = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
94
- export type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
95
- export type Aggregation = Omit<DeduceAggregation<Projection, Filter, Sorter>, "id">;
96
- export type CreateOperationData = FormCreateData<OpSchema> & {
92
+ export declare type Sorter = SortNode[];
93
+ export declare type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
94
+ export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
95
+ export declare type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
96
+ export declare type CreateOperationData = FormCreateData<OpSchema> & {
97
97
  oper$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>;
98
98
  operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
99
99
  modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
100
100
  };
101
- export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
102
- export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
103
- export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
104
- export type UpdateOperationData = FormUpdateData<OpSchema> & {
101
+ export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
102
+ export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
103
+ export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
104
+ export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
105
105
  [k: string]: any;
106
- opers$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>;
107
- operEntitys$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
108
- modiEntitys$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
106
+ oper$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>;
107
+ operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
108
+ modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
109
109
  };
110
- export type UpdateOperation = OakOperation<"update" | RelationAction | string, UpdateOperationData, Filter, Sorter>;
111
- export type RemoveOperationData = {};
112
- export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
113
- export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
114
- export type UserIdSubQuery = Selection<UserIdProjection>;
115
- export type EntityDef = {
110
+ export declare type UpdateOperation = OakOperation<"update" | RelationAction | string, UpdateOperationData, Filter, Sorter>;
111
+ export declare type RemoveOperationData = {};
112
+ export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
113
+ export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
114
+ export declare type UserIdSubQuery = Selection<UserIdProjection>;
115
+ export declare type EntityDef = {
116
116
  Schema: Schema;
117
117
  OpSchema: OpSchema;
118
118
  Action: OakMakeAction<GenericAction | RelationAction> | string;
@@ -3,31 +3,31 @@ 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
- export type ModiIdSubQuery = {
6
+ export declare type ModiIdSubQuery = {
7
7
  [K in "$in" | "$nin"]?: (ModiEntity.ModiIdSubQuery & {
8
8
  entity: "modiEntity";
9
9
  }) | (Modi.ModiIdSubQuery & {
10
10
  entity: "modi";
11
11
  }) | any;
12
12
  };
13
- export type ModiEntityIdSubQuery = {
13
+ export declare type ModiEntityIdSubQuery = {
14
14
  [K in "$in" | "$nin"]?: (ModiEntity.ModiEntityIdSubQuery & {
15
15
  entity: "modiEntity";
16
16
  }) | any;
17
17
  };
18
- export type OperIdSubQuery = {
18
+ export declare type OperIdSubQuery = {
19
19
  [K in "$in" | "$nin"]?: (OperEntity.OperIdSubQuery & {
20
20
  entity: "operEntity";
21
21
  }) | (Oper.OperIdSubQuery & {
22
22
  entity: "oper";
23
23
  }) | any;
24
24
  };
25
- export type OperEntityIdSubQuery = {
25
+ export declare type OperEntityIdSubQuery = {
26
26
  [K in "$in" | "$nin"]?: (OperEntity.OperEntityIdSubQuery & {
27
27
  entity: "operEntity";
28
28
  }) | any;
29
29
  };
30
- export type UserIdSubQuery = {
30
+ export declare type UserIdSubQuery = {
31
31
  [K in "$in" | "$nin"]?: (Oper.UserIdSubQuery & {
32
32
  entity: "oper";
33
33
  }) | (User.UserIdSubQuery & {
@@ -652,12 +652,12 @@ function analyzeEntity(filename, path, program, relativePath) {
652
652
  return ele2.name.getText() === 'name';
653
653
  });
654
654
  (0, assert_1.default)(ts.isStringLiteral(nameProperty.initializer));
655
- var indexName = nameProperty.initializer.text;
656
- if (indexNameDict_1[indexName]) {
657
- throw new Error("\u300C".concat(filename, "\u300D\u7D22\u5F15\u5B9A\u4E49\u91CD\u540D\u300C").concat(indexName, "\u300D"));
655
+ var nameText = nameProperty.initializer.text;
656
+ if (indexNameDict_1[nameText]) {
657
+ throw new Error("\u300C".concat(filename, "\u300D\u7D22\u5F15\u5B9A\u4E49\u91CD\u540D\u300C").concat(nameText, "\u300D"));
658
658
  }
659
659
  (0, lodash_1.assign)(indexNameDict_1, (_a = {},
660
- _a[indexName] = true,
660
+ _a[nameText] = true,
661
661
  _a));
662
662
  var configProperty = properties.find(function (ele2) {
663
663
  (0, assert_1.default)(ts.isPropertyAssignment(ele2));
@@ -695,10 +695,10 @@ function analyzeEntity(filename, path, program, relativePath) {
695
695
  return ele3.name.text === indexAttrName;
696
696
  });
697
697
  if (!schemaNode) {
698
- throw new Error("\u300C".concat(filename, "\u300D\u4E2D\u7D22\u5F15\u300C").concat(indexName, "\u300D\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u5B9A\u4E49\u975E\u6CD5"));
698
+ throw new Error("\u300C".concat(filename, "\u300D\u4E2D\u7D22\u5F15\u300C").concat(nameText, "\u300D\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u5B9A\u4E49\u975E\u6CD5"));
699
699
  }
700
700
  var type = schemaNode.type, name_1 = schemaNode.name;
701
- var entity = (0, string_1.firstLetterLowerCase)(moduleName);
701
+ var entity = moduleName;
702
702
  var _a = ManyToOne, _b = entity, manyToOneSet = _a[_b];
703
703
  if (ts.isTypeReferenceNode(type)) {
704
704
  var typeName = type.typeName;
@@ -712,14 +712,19 @@ function analyzeEntity(filename, path, program, relativePath) {
712
712
  if (!manyToOneItem) {
713
713
  // 如果不是外键,则不能是Text, File
714
714
  if (isFulltextIndex) {
715
- (0, assert_1.default)(['Text', 'String'].includes(text2_1), "\u300C".concat(filename, "\u300D\u4E2D\u5168\u6587\u7D22\u5F15\u300C").concat(indexName, "\u300D\u5B9A\u4E49\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u7C7B\u578B\u975E\u6CD5\uFF0C\u53EA\u80FD\u662FText/String"));
715
+ (0, assert_1.default)(['Text', 'String'].includes(text2_1), "\u300C".concat(filename, "\u300D\u4E2D\u5168\u6587\u7D22\u5F15\u300C").concat(nameText, "\u300D\u5B9A\u4E49\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u7C7B\u578B\u975E\u6CD5\uFF0C\u53EA\u80FD\u662FText/String"));
716
716
  }
717
717
  else {
718
- (0, assert_1.default)(!DataType_1.unIndexedTypes.includes(text2_1), "\u300C".concat(filename, "\u300D\u4E2D\u7D22\u5F15\u300C").concat(indexName, "\u300D\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u7684\u7C7B\u578B\u4E3A\u300C").concat(text2_1, "\u300D\uFF0C\u4E0D\u53EF\u7D22\u5F15"));
718
+ (0, assert_1.default)(!DataType_1.unIndexedTypes.includes(text2_1), "\u300C".concat(filename, "\u300D\u4E2D\u7D22\u5F15\u300C").concat(nameText, "\u300D\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u7684\u7C7B\u578B\u4E3A\u300C").concat(text2_1, "\u300D\uFF0C\u4E0D\u53EF\u7D22\u5F15"));
719
719
  }
720
720
  }
721
721
  else {
722
- (0, assert_1.default)(!isFulltextIndex, "\u300C".concat(filename, "\u300D\u4E2D\u5168\u6587\u7D22\u5F15\u300C").concat(indexName, "\u300D\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u7C7B\u578B\u975E\u6CD5\uFF0C\u53EA\u80FD\u4E3AText/String"));
722
+ (0, assert_1.default)(!isFulltextIndex, "\u300C".concat(filename, "\u300D\u4E2D\u5168\u6587\u7D22\u5F15\u300C").concat(nameText, "\u300D\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u7C7B\u578B\u975E\u6CD5\uFF0C\u53EA\u80FD\u4E3AText/String"));
723
+ // 在这里把外键加上Id,这样storageSchema才能正常通过
724
+ // 这里的写法不太好,未来TS版本高了可能会有问题。by Xc 20230131
725
+ Object.assign(nameProperty, {
726
+ initializer: factory.createStringLiteral("".concat(indexAttrName, "Id")),
727
+ });
723
728
  }
724
729
  }
725
730
  else {
@@ -727,8 +732,8 @@ function analyzeEntity(filename, path, program, relativePath) {
727
732
  }
728
733
  }
729
734
  else {
730
- (0, assert_1.default)(!isFulltextIndex, "\u300C".concat(filename, "\u300D\u4E2D\u5168\u6587\u7D22\u5F15\u300C").concat(indexName, "\u300D\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u7C7B\u578B\u53EA\u80FD\u4E3AText/String"));
731
- (0, assert_1.default)(ts.isUnionTypeNode(type) || ts.isLiteralTypeNode(type), "".concat(entity, "\u4E2D\u7D22\u5F15\u300C").concat(indexName, "\u300D\u7684\u5C5E\u6027").concat(name_1.text, "\u6709\u5B9A\u4E49\u975E\u6CD5"));
735
+ (0, assert_1.default)(!isFulltextIndex, "\u300C".concat(filename, "\u300D\u4E2D\u5168\u6587\u7D22\u5F15\u300C").concat(nameText, "\u300D\u7684\u5C5E\u6027\u300C").concat(indexAttrName, "\u300D\u7C7B\u578B\u53EA\u80FD\u4E3AText/String"));
736
+ (0, assert_1.default)(ts.isUnionTypeNode(type) || ts.isLiteralTypeNode(type), "".concat(entity, "\u4E2D\u7D22\u5F15\u300C").concat(nameText, "\u300D\u7684\u5C5E\u6027").concat(name_1.text, "\u6709\u5B9A\u4E49\u975E\u6CD5"));
732
737
  }
733
738
  }
734
739
  });
@@ -1077,6 +1082,7 @@ function constructFilter(statements, entity) {
1077
1082
  break;
1078
1083
  }
1079
1084
  case 'Int':
1085
+ case 'Uint':
1080
1086
  case 'Float':
1081
1087
  case 'Double': {
1082
1088
  type2 = factory.createTypeReferenceNode(factory.createIdentifier('Q_NumberValue'));
@@ -1784,14 +1790,11 @@ function constructActions(statements, entity) {
1784
1790
  // Selection
1785
1791
  statements.push(factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("SelectOperation"), [
1786
1792
  factory.createTypeParameterDeclaration(undefined, factory.createIdentifier("P"), factory.createTypeReferenceNode(factory.createIdentifier("Object"), undefined), factory.createTypeReferenceNode(factory.createIdentifier("Projection"), undefined))
1787
- ], factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [
1788
- factory.createTypeReferenceNode(factory.createIdentifier("OakOperation"), [
1789
- factory.createLiteralTypeNode(factory.createStringLiteral("select")),
1790
- factory.createTypeReferenceNode(factory.createIdentifier("P"), undefined),
1791
- factory.createTypeReferenceNode(factory.createIdentifier("Filter"), undefined),
1792
- factory.createTypeReferenceNode(factory.createIdentifier("Sorter"), undefined)
1793
- ]),
1794
- factory.createLiteralTypeNode(factory.createStringLiteral("id"))
1793
+ ], factory.createTypeReferenceNode(factory.createIdentifier("OakSelection"), [
1794
+ factory.createLiteralTypeNode(factory.createStringLiteral("select")),
1795
+ factory.createTypeReferenceNode(factory.createIdentifier("P"), undefined),
1796
+ factory.createTypeReferenceNode(factory.createIdentifier("Filter"), undefined),
1797
+ factory.createTypeReferenceNode(factory.createIdentifier("Sorter"), undefined)
1795
1798
  ])), factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("Selection"), [
1796
1799
  factory.createTypeParameterDeclaration(undefined, factory.createIdentifier("P"), factory.createTypeReferenceNode(factory.createIdentifier("Object"), undefined), factory.createTypeReferenceNode(factory.createIdentifier("Projection"), undefined))
1797
1800
  ], factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [
@@ -1799,13 +1802,10 @@ function constructActions(statements, entity) {
1799
1802
  factory.createTypeReferenceNode(factory.createIdentifier("P"), undefined)
1800
1803
  ]),
1801
1804
  factory.createLiteralTypeNode(factory.createStringLiteral("action"))
1802
- ])), factory.createTypeAliasDeclaration(undefined, [factory.createToken(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("Aggregation"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [
1803
- factory.createTypeReferenceNode(factory.createIdentifier("DeduceAggregation"), [
1804
- factory.createTypeReferenceNode(factory.createIdentifier("Projection"), undefined),
1805
- factory.createTypeReferenceNode(factory.createIdentifier("Filter"), undefined),
1806
- factory.createTypeReferenceNode(factory.createIdentifier("Sorter"), undefined)
1807
- ]),
1808
- factory.createLiteralTypeNode(factory.createStringLiteral("id"))
1805
+ ])), factory.createTypeAliasDeclaration(undefined, [factory.createToken(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("Aggregation"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("DeduceAggregation"), [
1806
+ factory.createTypeReferenceNode(factory.createIdentifier("Projection"), undefined),
1807
+ factory.createTypeReferenceNode(factory.createIdentifier("Filter"), undefined),
1808
+ factory.createTypeReferenceNode(factory.createIdentifier("Sorter"), undefined)
1809
1809
  ])));
1810
1810
  // Exportation
1811
1811
  // 已经废弃,by Xc 2023.01.08
@@ -2297,7 +2297,7 @@ function constructActions(statements, entity) {
2297
2297
  var _loop_9 = function (entityName) {
2298
2298
  var entityNameLc = (0, string_1.firstLetterLowerCase)(entityName);
2299
2299
  foreignKeySet[entityName].forEach(function (foreignKey) {
2300
- var identifier = "".concat(entityNameLc, "s$").concat(foreignKey);
2300
+ var identifier = "".concat(entityNameLc, "$").concat(foreignKey);
2301
2301
  var otmCreateOperationDataNode = factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [
2302
2302
  factory.createTypeReferenceNode(createForeignRef(entity, entityName, 'CreateOperationData'), undefined),
2303
2303
  factory.createUnionTypeNode(foreignKey === 'entity' ? [
@@ -2612,6 +2612,7 @@ var initialStatements = function () { return [
2612
2612
  factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
2613
2613
  factory.createImportSpecifier(false, undefined, factory.createIdentifier('String')),
2614
2614
  factory.createImportSpecifier(false, undefined, factory.createIdentifier('Int')),
2615
+ factory.createImportSpecifier(false, undefined, factory.createIdentifier('Uint')),
2615
2616
  factory.createImportSpecifier(false, undefined, factory.createIdentifier('Float')),
2616
2617
  factory.createImportSpecifier(false, undefined, factory.createIdentifier('Double')),
2617
2618
  factory.createImportSpecifier(false, undefined, factory.createIdentifier('Boolean')),
@@ -2653,6 +2654,7 @@ var initialStatements = function () { return [
2653
2654
  factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormUpdateData")),
2654
2655
  factory.createImportSpecifier(false, undefined, factory.createIdentifier("DeduceAggregation")),
2655
2656
  factory.createImportSpecifier(false, factory.createIdentifier("Operation"), factory.createIdentifier("OakOperation")),
2657
+ factory.createImportSpecifier(false, factory.createIdentifier("Selection"), factory.createIdentifier("OakSelection")),
2656
2658
  factory.createImportSpecifier(false, factory.createIdentifier("MakeAction"), factory.createIdentifier("OakMakeAction")),
2657
2659
  factory.createImportSpecifier(false, undefined, factory.createIdentifier("EntityShape")),
2658
2660
  factory.createImportSpecifier(false, undefined, factory.createIdentifier("AggregationResult")),
@@ -529,7 +529,7 @@ var CascadeStore = /** @class */ (function (_super) {
529
529
  var _g = tslib_1.__read(relation, 2), entityOtm_1 = _g[0], foreignKey_2 = _g[1];
530
530
  var otmOperations = data[attr];
531
531
  var dealWithOneToMany = function (otm) {
532
- var _a, _b, _c, _d;
532
+ var _a, _b, _c, _d, _e;
533
533
  var actionOtm = otm.action, dataOtm = otm.data, filterOtm = otm.filter;
534
534
  if (!foreignKey_2) {
535
535
  // 基于entity/entityId的one-to-many
@@ -550,7 +550,7 @@ var CascadeStore = /** @class */ (function (_super) {
550
550
  }
551
551
  else if (actionOtm === 'create') {
552
552
  // 这里先假设A(必是update)的filter上一定有id,否则用户界面上应该设计不出来这样的操作
553
- // todo 这个假设成立吗?等遇到create/create一对多的case再完善
553
+ // todo 这个假设对watcher等后台行为可能不成立,等遇到create/create一对多的case再完善
554
554
  var id_2 = filter.id;
555
555
  (0, assert_1.default)(typeof id_2 === 'string');
556
556
  if (dataOtm instanceof Array) {
@@ -569,12 +569,10 @@ var CascadeStore = /** @class */ (function (_super) {
569
569
  else {
570
570
  // 这里先假设A(必是update)的filter上一定有id,否则用户界面上应该设计不出来这样的操作
571
571
  // 这个倒是好像不可能出现create/update的一对多,如果遇到了再完善
572
- var id = filter.id;
573
572
  Object.assign(otm, {
574
- filter: (0, filter_1.addFilterSegment)({
575
- entity: entity,
576
- entityId: id,
577
- }, filterOtm),
573
+ filter: (0, filter_1.addFilterSegment)((_a = {},
574
+ _a[entity] = filter,
575
+ _a), filterOtm),
578
576
  });
579
577
  if (action === 'remove' && actionOtm === 'update') {
580
578
  Object.assign(dataOtm, {
@@ -597,14 +595,14 @@ var CascadeStore = /** @class */ (function (_super) {
597
595
  });
598
596
  }
599
597
  else {
600
- Object.assign(dataOtm, (_a = {},
601
- _a[foreignKey_2] = id_3,
602
- _a));
598
+ Object.assign(dataOtm, (_b = {},
599
+ _b[foreignKey_2] = id_3,
600
+ _b));
603
601
  }
604
602
  }
605
603
  else if (actionOtm === 'create') {
606
604
  // 这里先假设A(必是update)的filter上一定有id,否则用户界面上应该设计不出来这样的操作
607
- // todo 这个假设成立吗?等遇到create/create一对多的case再完善
605
+ // todo 这个假设在后台可能不成立,等遇到了再说
608
606
  var id_4 = filter.id;
609
607
  (0, assert_1.default)(typeof id_4 === 'string');
610
608
  if (dataOtm instanceof Array) {
@@ -616,28 +614,26 @@ var CascadeStore = /** @class */ (function (_super) {
616
614
  });
617
615
  }
618
616
  else {
619
- Object.assign(dataOtm, (_b = {},
620
- _b[foreignKey_2] = id_4,
621
- _b));
617
+ Object.assign(dataOtm, (_c = {},
618
+ _c[foreignKey_2] = id_4,
619
+ _c));
622
620
  }
623
621
  }
624
622
  else {
625
- // 这里先假设A(必是update)的filter上一定有id,否则用户界面上应该设计不出来这样的操作
626
- // 这个倒是好像不可能出现create/update的一对多,如果遇到了再完善
627
- var id = filter.id;
623
+ // update可能出现上层filter不是根据id的(userEntityGrant的过期触发的wechatQrCode的过期,见general中的userEntityGrant的trigger)
628
624
  Object.assign(otm, {
629
- filter: (0, filter_1.addFilterSegment)((_c = {},
630
- _c[foreignKey_2] = id,
631
- _c), filterOtm),
625
+ filter: (0, filter_1.addFilterSegment)((_d = {},
626
+ _d[foreignKey_2.slice(0, foreignKey_2.length - 2)] = filter,
627
+ _d), filterOtm),
632
628
  });
633
629
  if (action === 'remove' && actionOtm === 'update') {
634
- Object.assign(dataOtm, (_d = {},
635
- _d[foreignKey_2] = null,
636
- _d));
630
+ Object.assign(dataOtm, (_e = {},
631
+ _e[foreignKey_2] = null,
632
+ _e));
637
633
  }
638
634
  }
639
635
  }
640
- afterFns.push(function () { return cascadeUpdate.call(_this, entityOtm_1, otm, context, option2); });
636
+ beforeFns.push(function () { return cascadeUpdate.call(_this, entityOtm_1, otm, context, option2); });
641
637
  };
642
638
  if (otmOperations instanceof Array) {
643
639
  try {
@@ -16,7 +16,7 @@ export declare class TriggerExecutor<ED extends EntityDict & BaseEntityDict> {
16
16
  private contextBuilder;
17
17
  constructor(contextBuilder: (cxtString: string) => Promise<AsyncContext<ED>>, logger?: Logger);
18
18
  registerChecker<T extends keyof ED, Cxt extends AsyncContext<ED>>(checker: Checker<ED, T, Cxt>): void;
19
- getCheckers<T extends keyof ED>(entity: T, action: ED[T]['Action'], checkerTypes?: CheckerType[]): Trigger<ED, T, AsyncContext<ED>>[];
19
+ getCheckers<T extends keyof ED>(entity: T, action: ED[T]['Action'], checkerTypes?: CheckerType[]): Trigger<ED, T, AsyncContext<ED>>[] | undefined;
20
20
  registerTrigger<T extends keyof ED, Cxt extends AsyncContext<ED>>(trigger: Trigger<ED, T, Cxt>): void;
21
21
  unregisterTrigger<T extends keyof ED, Cxt extends AsyncContext<ED>>(trigger: Trigger<ED, T, Cxt>): void;
22
22
  private preCommitTrigger;