oak-domain 5.1.16 → 5.1.18

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 (96) hide show
  1. package/lib/base-app-domain/ActionAuth/Schema.d.ts +19 -171
  2. package/lib/base-app-domain/ActionAuth/Schema.js +2 -0
  3. package/lib/base-app-domain/ActionAuth/_baseSchema.d.ts +44 -0
  4. package/lib/base-app-domain/ActionAuth/_baseSchema.js +2 -0
  5. package/lib/base-app-domain/EntityDict.d.ts +695 -14
  6. package/lib/base-app-domain/I18n/Schema.d.ts +19 -129
  7. package/lib/base-app-domain/I18n/Schema.js +2 -0
  8. package/lib/base-app-domain/I18n/_baseSchema.d.ts +51 -0
  9. package/lib/base-app-domain/I18n/_baseSchema.js +2 -0
  10. package/lib/base-app-domain/Log/Schema.d.ts +19 -141
  11. package/lib/base-app-domain/Log/Schema.js +2 -0
  12. package/lib/base-app-domain/Log/Style.d.ts +2 -2
  13. package/lib/base-app-domain/Log/_baseSchema.d.ts +44 -0
  14. package/lib/base-app-domain/Log/_baseSchema.js +2 -0
  15. package/lib/base-app-domain/Modi/Schema.d.ts +19 -130
  16. package/lib/base-app-domain/Modi/Schema.js +2 -0
  17. package/lib/base-app-domain/Modi/Style.d.ts +2 -2
  18. package/lib/base-app-domain/Modi/_baseSchema.d.ts +61 -0
  19. package/lib/base-app-domain/Modi/_baseSchema.js +2 -0
  20. package/lib/base-app-domain/ModiEntity/Schema.d.ts +19 -367
  21. package/lib/base-app-domain/ModiEntity/Schema.js +2 -0
  22. package/lib/base-app-domain/ModiEntity/Storage.js +1 -2
  23. package/lib/base-app-domain/ModiEntity/_baseSchema.d.ts +44 -0
  24. package/lib/base-app-domain/ModiEntity/_baseSchema.js +2 -0
  25. package/lib/base-app-domain/Oper/Schema.d.ts +19 -201
  26. package/lib/base-app-domain/Oper/Schema.js +2 -0
  27. package/lib/base-app-domain/Oper/Style.d.ts +2 -2
  28. package/lib/base-app-domain/Oper/_baseSchema.d.ts +67 -0
  29. package/lib/base-app-domain/Oper/_baseSchema.js +2 -0
  30. package/lib/base-app-domain/OperEntity/Schema.d.ts +19 -367
  31. package/lib/base-app-domain/OperEntity/Schema.js +2 -0
  32. package/lib/base-app-domain/OperEntity/Storage.js +1 -2
  33. package/lib/base-app-domain/OperEntity/_baseSchema.d.ts +44 -0
  34. package/lib/base-app-domain/OperEntity/_baseSchema.js +2 -0
  35. package/lib/base-app-domain/Path/Schema.d.ts +19 -157
  36. package/lib/base-app-domain/Path/Schema.js +2 -0
  37. package/lib/base-app-domain/Path/_baseSchema.d.ts +52 -0
  38. package/lib/base-app-domain/Path/_baseSchema.js +2 -0
  39. package/lib/base-app-domain/Relation/Schema.d.ts +19 -198
  40. package/lib/base-app-domain/Relation/Schema.js +2 -0
  41. package/lib/base-app-domain/Relation/_baseSchema.d.ts +48 -0
  42. package/lib/base-app-domain/Relation/_baseSchema.js +2 -0
  43. package/lib/base-app-domain/RelationAuth/Schema.d.ts +19 -199
  44. package/lib/base-app-domain/RelationAuth/Schema.js +2 -0
  45. package/lib/base-app-domain/RelationAuth/_baseSchema.d.ts +41 -0
  46. package/lib/base-app-domain/RelationAuth/_baseSchema.js +2 -0
  47. package/lib/base-app-domain/User/Schema.d.ts +19 -222
  48. package/lib/base-app-domain/User/Schema.js +2 -0
  49. package/lib/base-app-domain/User/Style.d.ts +2 -2
  50. package/lib/base-app-domain/User/_baseSchema.d.ts +53 -0
  51. package/lib/base-app-domain/User/_baseSchema.js +2 -0
  52. package/lib/base-app-domain/UserEntityClaim/Schema.d.ts +19 -264
  53. package/lib/base-app-domain/UserEntityClaim/Schema.js +2 -0
  54. package/lib/base-app-domain/UserEntityClaim/_baseSchema.d.ts +49 -0
  55. package/lib/base-app-domain/UserEntityClaim/_baseSchema.js +2 -0
  56. package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +19 -136
  57. package/lib/base-app-domain/UserEntityGrant/Schema.js +2 -0
  58. package/lib/base-app-domain/UserEntityGrant/_baseSchema.d.ts +46 -0
  59. package/lib/base-app-domain/UserEntityGrant/_baseSchema.js +2 -0
  60. package/lib/base-app-domain/UserRelation/Schema.d.ts +19 -212
  61. package/lib/base-app-domain/UserRelation/Schema.js +2 -0
  62. package/lib/base-app-domain/UserRelation/_baseSchema.d.ts +47 -0
  63. package/lib/base-app-domain/UserRelation/_baseSchema.js +2 -0
  64. package/lib/compiler/localeBuilder.d.ts +1 -0
  65. package/lib/compiler/localeBuilder.js +9 -2
  66. package/lib/compiler/schemalBuilder.d.ts +1 -0
  67. package/lib/compiler/schemalBuilder.js +1368 -186
  68. package/lib/data/i18n.d.ts +3 -0
  69. package/lib/data/i18n.js +32 -0
  70. package/lib/store/CascadeStore.d.ts +3 -3
  71. package/lib/store/CascadeStore.js +28 -27
  72. package/lib/store/RelationAuth.d.ts +1 -1
  73. package/lib/store/RelationAuth.js +6 -6
  74. package/lib/store/TriggerExecutor.js +11 -5
  75. package/lib/store/checker.js +1 -1
  76. package/lib/store/filter.d.ts +11 -11
  77. package/lib/store/filter.js +14 -8
  78. package/lib/store/modi.d.ts +2 -2
  79. package/lib/store/triggers.js +14 -14
  80. package/lib/timers/vaccum.d.ts +1 -1
  81. package/lib/types/Auth.d.ts +4 -4
  82. package/lib/types/Cluster.d.ts +1 -0
  83. package/lib/types/Configuration.d.ts +9 -0
  84. package/lib/types/Entity.d.ts +5 -1
  85. package/lib/types/EntityDesc.d.ts +1 -1
  86. package/lib/types/Exception.d.ts +26 -21
  87. package/lib/types/Exception.js +81 -71
  88. package/lib/types/Expression.d.ts +4 -1
  89. package/lib/types/Port.d.ts +1 -1
  90. package/lib/types/Trigger.d.ts +1 -1
  91. package/lib/types/Watcher.d.ts +3 -3
  92. package/lib/utils/projection.d.ts +2 -2
  93. package/lib/utils/relationPath.d.ts +4 -4
  94. package/lib/utils/relationPath.js +1 -1
  95. package/lib/utils/validator.d.ts +2 -2
  96. package/package.json +2 -2
@@ -0,0 +1,3 @@
1
+ import { CreateOperationData as I18n } from "../base-app-domain/I18n/Schema";
2
+ declare const i18ns: I18n[];
3
+ export default i18ns;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // 本文件为自动编译产生,请勿直接修改
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const i18ns = [
5
+ {
6
+ id: "78c237bf2064a36fe73d943ccbbe22d5",
7
+ namespace: "oak-domain-l-error",
8
+ language: "zh-CN",
9
+ module: "oak-domain",
10
+ position: "locales/error",
11
+ data: {
12
+ "requestTimeout": "请求超时",
13
+ "noRelationDef": "对象[%{entity}]的操作${%{action}}找不到有效的relation定义",
14
+ "rowUnexisted": "查询对象[%{entity}]时发现了空指针,请检查数据一致性",
15
+ "uniqViolation": "您更新的数据违反了唯一性约束",
16
+ "signatureFailed": "验签失败",
17
+ "attributesNull": "属性[%{attributes}]不允许为空",
18
+ "attributesCantUpdate": "属性[%{attributes}]不能更新",
19
+ "operationUnpermitted": "用户操作权限不足",
20
+ "dataInvisible": "用户查询权限不足",
21
+ "unLoggedIn": "用户未登录",
22
+ "rowLocked": "该行数据当前处于被锁定状态",
23
+ "congrentRowExists": "相同的行数据已经存在",
24
+ "deadlock": "发现死锁",
25
+ "preconditionUnset": "前置条件未满足",
26
+ "externalException": "外部接口调用异常",
27
+ "socketConnectException": "连接出现问题,请尝试刷新页面",
28
+ "importedDataParseError": "import的数据存在异常"
29
+ }
30
+ }
31
+ ];
32
+ exports.default = i18ns;
@@ -25,8 +25,8 @@ export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDic
25
25
  protected abstract updateAbjointRowAsync<T extends keyof ED, OP extends OperateOption, Cxt extends AsyncContext<ED>>(entity: T, operation: ED[T]['Create'] | ED[T]['Update'] | ED[T]['Remove'], context: Cxt, option: OP): Promise<number>;
26
26
  protected abstract aggregateAbjointRowSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): AggregationResult<ED[T]['Schema']>;
27
27
  protected abstract aggregateAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
28
- protected destructCascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED> | AsyncContext<ED>>(entity: T, projection2: ED[T]['Selection']['data'], context: Cxt, cascadeSelectFn: <T2 extends keyof ED>(entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => Partial<ED[T2]['Schema']>[] | Promise<Partial<ED[T2]['Schema']>[]>, aggregateFn: <T2 extends keyof ED>(entity2: T2, aggregation: ED[T2]['Aggregation'], context: Cxt, op: OP) => AggregationResult<ED[T2]['Schema']> | Promise<AggregationResult<ED[T2]['Schema']>>, option: OP): {
29
- projection: ED[T]["Selection"]["data"];
28
+ protected destructCascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED> | AsyncContext<ED>>(entity: T, projection2: ED[T]['Projection'], context: Cxt, cascadeSelectFn: <T2 extends keyof ED>(entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => Partial<ED[T2]['Schema']>[] | Promise<Partial<ED[T2]['Schema']>[]>, aggregateFn: <T2 extends keyof ED>(entity2: T2, aggregation: ED[T2]['Aggregation'], context: Cxt, op: OP) => AggregationResult<ED[T2]['Schema']> | Promise<AggregationResult<ED[T2]['Schema']>>, option: OP): {
29
+ projection: ED[T]["Projection"];
30
30
  cascadeSelectionFns: ((result: Partial<ED[T]['Schema']>[]) => Promise<void> | void)[];
31
31
  };
32
32
  /**
@@ -61,7 +61,7 @@ export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDic
61
61
  * @param filter
62
62
  * @returns
63
63
  */
64
- protected destructCascadeUpdate<T extends keyof ED, Cxt extends SyncContext<ED> | AsyncContext<ED>, OP extends OperateOption, R>(entity: T, action: ED[T]['Action'], data: ED[T]['CreateSingle']['data'] | ED[T]['Update']['data'] | ED[T]['Remove']['data'], context: Cxt, option: OP, cascadeUpdate: <T2 extends keyof ED>(entity: T2, operation: ED[T2]['Operation'], context: Cxt, option: OP) => R, filter?: ED[T]['Update']['filter'], bornAt?: number): {
64
+ protected destructCascadeUpdate<T extends keyof ED, Cxt extends SyncContext<ED> | AsyncContext<ED>, OP extends OperateOption, R>(entity: T, action: ED[T]['Action'], data: ED[T]['CreateOperationData'] | ED[T]['Update']['data'] | ED[T]['Remove']['data'], context: Cxt, option: OP, cascadeUpdate: <T2 extends keyof ED>(entity: T2, operation: ED[T2]['Operation'], context: Cxt, option: OP) => R, filter?: ED[T]['Filter'], bornAt?: number): {
65
65
  data: Record<string, any>;
66
66
  beforeFns: (() => R)[];
67
67
  afterFns: (() => R)[];
@@ -996,6 +996,7 @@ class CascadeStore extends RowStore_1.RowStore {
996
996
  }
997
997
  }
998
998
  else {
999
+ console.warn('一对多的cascadeUpdate即将全部升级为数组格式,请及时修正。by Xc 20250120');
999
1000
  dealWithOneToMany(otmOperations);
1000
1001
  }
1001
1002
  }
@@ -1151,15 +1152,15 @@ class CascadeStore extends RowStore_1.RowStore {
1151
1152
  } : {
1152
1153
  id: ids[0],
1153
1154
  },
1154
- modiEntity$modi: {
1155
- id: 'dummy',
1156
- action: 'create',
1157
- data: await Promise.all(ids.map(async (id) => ({
1158
- id: await (0, uuid_1.generateNewIdAsync)(),
1159
- entity: entity,
1160
- entityId: id,
1161
- }))),
1162
- }
1155
+ modiEntity$modi: [{
1156
+ id: 'dummy',
1157
+ action: 'create',
1158
+ data: await Promise.all(ids.map(async (id) => ({
1159
+ id: await (0, uuid_1.generateNewIdAsync)(),
1160
+ entity: entity,
1161
+ entityId: id,
1162
+ }))),
1163
+ }]
1163
1164
  },
1164
1165
  };
1165
1166
  }
@@ -1317,15 +1318,15 @@ class CascadeStore extends RowStore_1.RowStore {
1317
1318
  operatorId,
1318
1319
  targetEntity: entity,
1319
1320
  bornAt,
1320
- operEntity$oper: data instanceof Array ? {
1321
- id: 'dummy',
1322
- action: 'create',
1323
- data: await Promise.all(data.map(async (ele) => ({
1324
- id: await (0, uuid_1.generateNewIdAsync)(),
1325
- entityId: ele.id,
1326
- entity: entity,
1327
- }))),
1328
- } : [{
1321
+ operEntity$oper: data instanceof Array ? [{
1322
+ id: 'dummy',
1323
+ action: 'create',
1324
+ data: await Promise.all(data.map(async (ele) => ({
1325
+ id: await (0, uuid_1.generateNewIdAsync)(),
1326
+ entityId: ele.id,
1327
+ entity: entity,
1328
+ }))),
1329
+ }] : [{
1329
1330
  id: 'dummy',
1330
1331
  action: 'create',
1331
1332
  data: {
@@ -1456,15 +1457,15 @@ class CascadeStore extends RowStore_1.RowStore {
1456
1457
  targetEntity: entity,
1457
1458
  bornAt,
1458
1459
  operatorId,
1459
- operEntity$oper: {
1460
- id: 'dummy',
1461
- action: 'create',
1462
- data: await Promise.all(ids.map(async (ele) => ({
1463
- id: await (0, uuid_1.generateNewIdAsync)(),
1464
- entityId: ele,
1465
- entity: entity,
1466
- })))
1467
- },
1460
+ operEntity$oper: [{
1461
+ id: 'dummy',
1462
+ action: 'create',
1463
+ data: await Promise.all(ids.map(async (ele) => ({
1464
+ id: await (0, uuid_1.generateNewIdAsync)(),
1465
+ entityId: ele,
1466
+ entity: entity,
1467
+ })))
1468
+ }],
1468
1469
  filter: {
1469
1470
  id: { $in: ids },
1470
1471
  },
@@ -89,7 +89,7 @@ export declare class RelationAuth<ED extends EntityDict & BaseEntityDict> {
89
89
  */
90
90
  export declare function getUserRelationsByActions<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>>(params: {
91
91
  entity: T;
92
- filter: ED[T]['Selection']['filter'];
92
+ filter: ED[T]['Filter'];
93
93
  actions: ED[T]['Action'][];
94
94
  overlap?: boolean;
95
95
  }, context: Cxt): Promise<{
@@ -462,7 +462,7 @@ class RelationAuth {
462
462
  if (!hasOneToMany) {
463
463
  leafSelections.push({
464
464
  entity: entity2,
465
- filter,
465
+ filter: filter,
466
466
  });
467
467
  }
468
468
  };
@@ -513,7 +513,7 @@ class RelationAuth {
513
513
  return true;
514
514
  };
515
515
  const destructInner = (entity, operation,
516
- // extraFilter?: ED[T2]['Selection']['filter'],
516
+ // extraFilter?: ED[T2]['Filter'],
517
517
  path, child, hasParent, extraFilter) => {
518
518
  const { action, data, filter } = operation;
519
519
  const filter2 = action === 'create' ? makeCreateFilter(entity, operation) : filter ? (0, lodash_1.cloneDeep)(filter) : {};
@@ -1118,12 +1118,12 @@ class RelationAuth {
1118
1118
  if (result instanceof Promise) {
1119
1119
  return result.then((r) => {
1120
1120
  if (!r) {
1121
- throw new types_1.OakUserInvisibleException(entity, operation);
1121
+ throw new types_1.OakDataInvisibleException(entity, operation);
1122
1122
  }
1123
1123
  });
1124
1124
  }
1125
1125
  if (!result) {
1126
- throw new types_1.OakUserInvisibleException(entity, operation);
1126
+ throw new types_1.OakDataInvisibleException(entity, operation);
1127
1127
  }
1128
1128
  }
1129
1129
  else {
@@ -1131,12 +1131,12 @@ class RelationAuth {
1131
1131
  if (result instanceof Promise) {
1132
1132
  return result.then((r) => {
1133
1133
  if (!r) {
1134
- throw new types_1.OakUserUnpermittedException(entity, operation);
1134
+ throw new types_1.OakOperationUnpermittedException(entity, operation);
1135
1135
  }
1136
1136
  });
1137
1137
  }
1138
1138
  if (!result) {
1139
- throw new types_1.OakUserUnpermittedException(entity, operation);
1139
+ throw new types_1.OakOperationUnpermittedException(entity, operation);
1140
1140
  }
1141
1141
  }
1142
1142
  }
@@ -186,11 +186,15 @@ class TriggerExecutor {
186
186
  default: {
187
187
  const { filter } = operation;
188
188
  // 此时要保证更新或者删除的行上没有跨事务约束
189
- const filter2 = (0, filter_1.combineFilters)(entity, context.getSchema(), [{
189
+ const filter2 = filter ? (0, filter_1.combineFilters)(entity, context.getSchema(), [{
190
190
  [Entity_1.TriggerUuidAttribute]: {
191
191
  $exists: true,
192
192
  },
193
- }, filter]);
193
+ }, filter]) : {
194
+ [Entity_1.TriggerUuidAttribute]: {
195
+ $exists: true,
196
+ }
197
+ };
194
198
  const count = await context.count(entity, {
195
199
  filter: filter2
196
200
  }, {});
@@ -516,9 +520,11 @@ class TriggerExecutor {
516
520
  },
517
521
  };
518
522
  if (instanceCount) {
519
- filter.$$seq$$ = {
520
- $mod: [instanceCount, instanceId]
521
- };
523
+ Object.assign(filter, {
524
+ $$seq$$: {
525
+ $mod: [instanceCount, instanceId]
526
+ }
527
+ });
522
528
  }
523
529
  const context = this.contextBuilder();
524
530
  await context.begin();
@@ -52,7 +52,7 @@ function translateCheckerInAsyncContext(checker, schema) {
52
52
  return 0;
53
53
  }
54
54
  if (['select', 'count', 'stat'].includes(action)) {
55
- operation.filter = (0, filter_1.combineFilters)(entity, context.getSchema(), [operationFilter, filter2]);
55
+ operation.filter = operationFilter ? (0, filter_1.combineFilters)(entity, context.getSchema(), [operationFilter, filter2]) : filter2;
56
56
  return 0;
57
57
  }
58
58
  else {
@@ -2,11 +2,11 @@ import { EntityDict as BaseEntityDict, StorageSchema } from '../types';
2
2
  import { EntityDict } from "../base-app-domain";
3
3
  import { AsyncContext } from './AsyncRowStore';
4
4
  import { SyncContext } from './SyncRowStore';
5
- export declare function translateCreateDataToFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(schema: StorageSchema<ED>, entity: T, data: ED[T]['CreateSingle']['data'], allowUnrecoganized: boolean): ED[T]["Selection"]["filter"];
6
- export declare function combineFilters<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, schema: StorageSchema<ED>, filters: Array<ED[T]['Selection']['filter']>, union?: true): ED[T]["Selection"]["filter"] | undefined;
5
+ export declare function translateCreateDataToFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(schema: StorageSchema<ED>, entity: T, data: ED[T]['CreateOperationData'], allowUnrecoganized: boolean): ED[T]["Filter"];
6
+ export declare function combineFilters<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, schema: StorageSchema<ED>, filters: Array<ED[T]['Filter']>, union?: true): ED[T]["Filter"] | undefined;
7
7
  type DeducedFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
8
8
  entity: T;
9
- filter: ED[T]['Selection']['filter'];
9
+ filter: ED[T]['Filter'];
10
10
  };
11
11
  type DeducedFilterCombination<ED extends EntityDict & BaseEntityDict> = {
12
12
  $or?: (DeducedFilterCombination<ED> | DeducedFilter<ED, keyof ED>)[];
@@ -56,7 +56,7 @@ export declare function judgeValueRelation(value1: any, value2: any, contained:
56
56
  * totalAndDeducedFilters包含的是判定过程中推论的相容的充分条件(and关系)
57
57
  * totalOrDeducedFilters包含的是判定过程中推论的相斥的充分条件(or关系)
58
58
  */
59
- export declare function analyzeFilterRelation<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, schema: StorageSchema<ED>, filter: NonNullable<ED[T]['Selection']['filter']>, compared: NonNullable<ED[T]['Selection']['filter']>, contained: boolean): boolean | {
59
+ export declare function analyzeFilterRelation<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, schema: StorageSchema<ED>, filter: NonNullable<ED[T]['Filter']>, compared: NonNullable<ED[T]['Filter']>, contained: boolean): boolean | {
60
60
  totalAndDeducedFilters: (DeducedFilterCombination<ED> | DeducedFilter<ED, T>)[];
61
61
  totalOrDeducedFilters: (DeducedFilterCombination<ED> | DeducedFilter<ED, T>)[];
62
62
  uncertainAttributes: string[];
@@ -80,13 +80,13 @@ export declare function analyzeFilterRelation<ED extends EntityDict & BaseEntity
80
80
  * @param contained
81
81
  * @returns
82
82
  */
83
- export declare function contains<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, schema: StorageSchema<ED>, filter: ED[T]['Selection']['filter'], contained: ED[T]['Selection']['filter']): boolean | DeducedFilterCombination<ED>;
83
+ export declare function contains<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, schema: StorageSchema<ED>, filter: ED[T]['Filter'], contained: ED[T]['Filter']): boolean | DeducedFilterCombination<ED>;
84
84
  /**
85
85
  * 从filter中判断是否有确定的id对象,如果有则返回这些id,没有返回空数组
86
86
  * @param filter
87
87
  * @returns
88
88
  */
89
- export declare function getRelevantIds<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(filter: ED[T]['Selection']['filter']): string[];
89
+ export declare function getRelevantIds<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(filter?: ED[T]['Filter']): string[];
90
90
  /**
91
91
  * 判断两个过滤条件是否完全一致
92
92
  * @param entity
@@ -94,7 +94,7 @@ export declare function getRelevantIds<ED extends EntityDict & BaseEntityDict, T
94
94
  * @param filter1
95
95
  * @param filter2
96
96
  */
97
- export declare function same<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, schema: StorageSchema<ED>, filter1: ED[T]['Selection']['filter'], filter2: ED[T]['Selection']['filter']): boolean;
97
+ export declare function same<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, schema: StorageSchema<ED>, filter1: ED[T]['Filter'], filter2: ED[T]['Filter']): boolean;
98
98
  /**
99
99
  * 寻找在树形结构中满足条件的数据行的上层数据
100
100
  * 例如在area表中,如果“杭州市”满足这一条件,则希望查到更高层的“浙江省”和“中国”,即可构造出满足条件的filter
@@ -103,7 +103,7 @@ export declare function same<ED extends EntityDict & BaseEntityDict, T extends k
103
103
  * @param filter 查询当前行的条件
104
104
  * @param level
105
105
  */
106
- export declare function makeTreeAncestorFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, parentKey: string, filter: ED[T]['Selection']['filter'], level?: number, includeAll?: boolean, includeSelf?: boolean): ED[T]['Selection']['filter'];
106
+ export declare function makeTreeAncestorFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, parentKey: string, filter: ED[T]['Filter'], level?: number, includeAll?: boolean, includeSelf?: boolean): ED[T]['Filter'];
107
107
  /**
108
108
  * 寻找在树形结构中满足条件的数据行的下层数据
109
109
  * 例如在area表中,如果“杭州市”满足这一条件,则希望查到更低层的“西湖区”,即可构造出满足条件的filter
@@ -112,7 +112,7 @@ export declare function makeTreeAncestorFilter<ED extends EntityDict & BaseEntit
112
112
  * @param filter 查询当前行的条件
113
113
  * @param level
114
114
  */
115
- export declare function makeTreeDescendantFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, parentKey: string, filter: ED[T]['Selection']['filter'], level?: number, includeAll?: boolean, includeSelf?: boolean): ED[T]['Selection']['filter'];
115
+ export declare function makeTreeDescendantFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, parentKey: string, filter: ED[T]['Filter'], level?: number, includeAll?: boolean, includeSelf?: boolean): ED[T]['Filter'];
116
116
  /**
117
117
  * 检查filter是否包含contained(filter查询的数据是contained查询数据的子集)
118
118
  * @param entity
@@ -122,8 +122,8 @@ export declare function makeTreeDescendantFilter<ED extends EntityDict & BaseEnt
122
122
  * @param dataCompare
123
123
  * @returns
124
124
  */
125
- export declare function checkFilterContains<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends SyncContext<ED> | AsyncContext<ED>>(entity: T, context: Cxt, contained: ED[T]['Selection']['filter'], filter?: ED[T]['Selection']['filter'], dataCompare?: true, warningOnDataCompare?: true): boolean | Promise<boolean>;
126
- export declare function checkFilterRepel<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends SyncContext<ED> | AsyncContext<ED>>(entity: T, context: Cxt, filter1: ED[T]['Selection']['filter'], filter2: ED[T]['Selection']['filter'], dataCompare?: true, warningOnDataCompare?: true): boolean | Promise<boolean>;
125
+ export declare function checkFilterContains<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends SyncContext<ED> | AsyncContext<ED>>(entity: T, context: Cxt, contained: ED[T]['Filter'], filter?: ED[T]['Filter'], dataCompare?: true, warningOnDataCompare?: true): boolean | Promise<boolean>;
126
+ export declare function checkFilterRepel<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends SyncContext<ED> | AsyncContext<ED>>(entity: T, context: Cxt, filter1: ED[T]['Filter'], filter2: ED[T]['Filter'], dataCompare?: true, warningOnDataCompare?: true): boolean | Promise<boolean>;
127
127
  /**
128
128
  * 有的场景下将filter当成非结构化属性存储,又想支持对其查询,此时必须将查询的filter进行转换,处理其中$开头的escape
129
129
  * 只要filter是查询数据的标准子集,查询应当能返回true
@@ -51,13 +51,17 @@ function addFilterSegment(entity, schema, ...filters) {
51
51
  filter.$and.push(f);
52
52
  }
53
53
  else {
54
- filter.$and = [f];
54
+ Object.assign(filter, {
55
+ $and: [f],
56
+ });
55
57
  }
56
58
  };
57
59
  const addSingleAttr = (attr, value) => {
58
60
  (0, assert_1.default)(filter);
59
61
  if (!filter[attr]) {
60
- filter[attr] = value;
62
+ Object.assign(filter, {
63
+ [attr]: value
64
+ });
61
65
  }
62
66
  // 优化两个都等值且相等
63
67
  else if (filter[attr] === value) {
@@ -68,7 +72,9 @@ function addFilterSegment(entity, schema, ...filters) {
68
72
  }, {
69
73
  [attr]: filter[attr],
70
74
  }) === true) {
71
- filter[attr] = value;
75
+ Object.assign(filter, {
76
+ [attr]: value,
77
+ });
72
78
  }
73
79
  // 当前查询被value所定义的查询包含
74
80
  else if (contains(entity, schema, {
@@ -1677,17 +1683,17 @@ function translateFilterToObjectPredicate(filter) {
1677
1683
  }
1678
1684
  exports.translateFilterToObjectPredicate = translateFilterToObjectPredicate;
1679
1685
  /* export function getCascadeEntityFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(
1680
- filter: NonNullable<ED[T]['Selection']['filter']>,
1681
- attr: keyof NonNullable<ED[T]['Selection']['filter']>
1682
- ): ED[keyof ED]['Selection']['filter'] {
1683
- const filters: ED[keyof ED]['Selection']['filter'][] = [];
1686
+ filter: NonNullable<ED[T]['Filter']>,
1687
+ attr: keyof NonNullable<ED[T]['Filter']>
1688
+ ): ED[keyof ED]['Filter'] {
1689
+ const filters: ED[keyof ED]['Filter'][] = [];
1684
1690
  if (filter![attr]) {
1685
1691
  assert(typeof filter![attr] === 'object');
1686
1692
  filters.push(filter![attr]);
1687
1693
  }
1688
1694
  if (filter.$and) {
1689
1695
  filter.$and.forEach(
1690
- (ele: NonNullable<ED[T]['Selection']['filter']>) => {
1696
+ (ele: NonNullable<ED[T]['Filter']>) => {
1691
1697
  const f2 = getCascadeEntityFilter(ele, attr);
1692
1698
  if (f2) {
1693
1699
  filters.push(f2)
@@ -7,7 +7,7 @@ export declare function createOperationsFromModies(modies: Modi[]): Array<{
7
7
  operation: Operation<string, Object, Object>;
8
8
  entity: string;
9
9
  }>;
10
- export declare function applyModis<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, Op extends OperateOption>(filter: ED['modi']['Selection']['filter'], context: Cxt, option: Op): Promise<import("../types").OperationResult<ED>>;
11
- export declare function abandonModis<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, Op extends OperateOption>(filter: ED['modi']['Selection']['filter'], context: Cxt, option: Op): Promise<import("../types").OperationResult<ED>>;
10
+ export declare function applyModis<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, Op extends OperateOption>(filter: ED['modi']['Filter'], context: Cxt, option: Op): Promise<import("../types").OperationResult<ED>>;
11
+ export declare function abandonModis<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, Op extends OperateOption>(filter: ED['modi']['Filter'], context: Cxt, option: Op): Promise<import("../types").OperationResult<ED>>;
12
12
  export declare function createModiRelatedCheckers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): RowChecker<ED, keyof ED, Cxt>[];
13
13
  export declare function createModiRelatedTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): Trigger<ED, keyof ED, Cxt>[];
@@ -91,13 +91,13 @@ async function undoLog(log, context) {
91
91
  action: 'undo',
92
92
  data: {
93
93
  iState: 'rollbacked',
94
- oper$log: {
95
- id: 'dummy',
96
- action: 'undo',
97
- data: {
98
- iState: 'rollbacked',
99
- },
100
- },
94
+ oper$log: [{
95
+ id: 'dummy',
96
+ action: 'undo',
97
+ data: {
98
+ iState: 'rollbacked',
99
+ },
100
+ }],
101
101
  },
102
102
  filter: {
103
103
  id: log.id,
@@ -160,13 +160,13 @@ async function redoLog(log, context) {
160
160
  action: 'redo',
161
161
  data: {
162
162
  iState: 'normal',
163
- oper$log: {
164
- id: 'dummy',
165
- action: 'redo',
166
- data: {
167
- iState: 'normal',
168
- },
169
- },
163
+ oper$log: [{
164
+ id: 'dummy',
165
+ action: 'redo',
166
+ data: {
167
+ iState: 'normal',
168
+ },
169
+ }],
170
170
  },
171
171
  filter: {
172
172
  id: log.id,
@@ -3,7 +3,7 @@ import { EntityDict as BaseEntityDict } from '../base-app-domain';
3
3
  import { AsyncContext } from '../store/AsyncRowStore';
4
4
  type VaccumOptionEntity<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
5
5
  entity: T;
6
- filter?: ED[T]['Selection']['filter'];
6
+ filter?: ED[T]['Filter'];
7
7
  aliveLine: number;
8
8
  };
9
9
  type VaccumOption<ED extends EntityDict & BaseEntityDict> = {
@@ -23,14 +23,14 @@ export type RowChecker<ED extends EntityDict & BaseEntityDict, T extends keyof E
23
23
  entity: T;
24
24
  mt?: ModiTurn;
25
25
  action: ED[T]['Action'] | Array<ED[T]['Action']>;
26
- filter: ED[T]['Selection']['filter'] | ((operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) => SyncOrAsync<ED[T]['Selection']['filter']>);
26
+ filter: ED[T]['Filter'] | ((operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) => SyncOrAsync<ED[T]['Filter'] | undefined>);
27
27
  errMsg?: string;
28
28
  err?: new (msg?: string) => OakException<ED>;
29
29
  inconsistentRows?: {
30
30
  entity: keyof ED;
31
- selection: (filter?: ED[T]['Selection']['filter']) => ED[keyof ED]['Selection'];
31
+ selection: (filter?: ED[T]['Filter']) => ED[keyof ED]['Selection'];
32
32
  };
33
- conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => SyncOrAsync<ED[T]['Update']['filter']>);
33
+ conditionalFilter?: ED[T]['Filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => SyncOrAsync<ED[T]['Filter']>);
34
34
  };
35
35
  export type LogicalChecker<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = {
36
36
  priority?: number;
@@ -39,7 +39,7 @@ export type LogicalChecker<ED extends EntityDict & BaseEntityDict, T extends key
39
39
  entity: T;
40
40
  action: ED[T]['Action'] | Array<ED[T]['Action']>;
41
41
  checker: (operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) => SyncOrAsync<any>;
42
- conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => SyncOrAsync<ED[T]['Update']['filter']>);
42
+ conditionalFilter?: ED[T]['Filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => SyncOrAsync<ED[T]['Filter']>);
43
43
  };
44
44
  export type Checker<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = DataChecker<ED, T, Cxt> | RowChecker<ED, T, Cxt> | LogicalChecker<ED, T, Cxt>;
45
45
  export type AuthDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
@@ -2,4 +2,5 @@ export type ClusterInfo = {
2
2
  usingCluster: boolean;
3
3
  instanceId?: number;
4
4
  instanceCount?: number;
5
+ enableRedis?: boolean;
5
6
  };
@@ -3,6 +3,14 @@ import { EntityDict as BaseEntityDict } from "../base-app-domain";
3
3
  import { AttrUpdateMatrix } from './EntityDesc';
4
4
  import { ActionDefDict } from './Action';
5
5
  import { StyleDict } from './Style';
6
+ /**
7
+ * redis连接信息,如果是Redis集群,可以配置多个
8
+ */
9
+ export type RedisConfiguration = {
10
+ host: string;
11
+ port: number;
12
+ password?: string;
13
+ };
6
14
  /**
7
15
  * 后台配置
8
16
  */
@@ -17,6 +25,7 @@ export type ServerConfiguration = {
17
25
  connectionLimit: number;
18
26
  charset: "utf8mb4_general_ci";
19
27
  };
28
+ redis?: RedisConfiguration | RedisConfiguration[];
20
29
  workDir: {
21
30
  path: string;
22
31
  };
@@ -85,12 +85,16 @@ export interface EntityDef {
85
85
  Selection: Selection<'select', Projection, Filter, Sorter>;
86
86
  Aggregation: DeduceAggregation<Projection, Filter, Sorter>;
87
87
  Operation: CUDOperation;
88
+ CreateOperationData: CreateOperationData;
88
89
  Create: CreateOperation;
89
90
  CreateSingle: CreateSingleOperation;
90
91
  CreateMulti: CreateMultipleOperation;
91
92
  Update: UpdateOperation;
92
93
  Remove: RemoveOperation;
93
94
  Relation?: string;
95
+ Filter: Filter;
96
+ Projection: Projection;
97
+ Sorter: Sorter;
94
98
  }
95
99
  export interface EntityDict {
96
100
  [E: string]: EntityDef;
@@ -207,6 +211,6 @@ export type OtmKey<K extends string> = K | `${K}$${number}`;
207
211
  export interface SubDataDef<ED extends EntityDict, T extends keyof ED> {
208
212
  id: string;
209
213
  entity: T;
210
- filter: ED[T]['Selection']['filter'];
214
+ filter: ED[T]['Filter'];
211
215
  }
212
216
  export {};
@@ -18,7 +18,7 @@ export type AttrUpdateMatrix<ED extends EntityDict> = {
18
18
  [T in keyof ED]?: {
19
19
  [A in keyof ED[T]['Update']['data']]?: {
20
20
  actions?: ED[T]['Action'][];
21
- filter?: (NonNullable<ED[T]['Selection']['filter']>) | ((action: ED[T]['Action']) => NonNullable<ED[T]['Selection']['filter']>);
21
+ filter?: (NonNullable<ED[T]['Filter']>) | ((action: ED[T]['Action']) => NonNullable<ED[T]['Filter']>);
22
22
  };
23
23
  };
24
24
  };