oak-domain 1.1.14 → 2.0.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 (73) hide show
  1. package/lib/base-app-domain/Modi/Schema.d.ts +22 -22
  2. package/lib/base-app-domain/ModiEntity/Schema.d.ts +17 -17
  3. package/lib/base-app-domain/Oper/Schema.d.ts +17 -17
  4. package/lib/base-app-domain/OperEntity/Schema.d.ts +18 -18
  5. package/lib/base-app-domain/User/Schema.d.ts +15 -15
  6. package/lib/checkers/index.d.ts +4 -2
  7. package/lib/compiler/schemalBuilder.js +10 -10
  8. package/lib/store/AsyncRowStore.d.ts +45 -0
  9. package/lib/store/{UniversalContext.js → AsyncRowStore.js} +39 -29
  10. package/lib/store/CascadeStore.d.ts +46 -20
  11. package/lib/store/CascadeStore.js +954 -995
  12. package/lib/store/SyncRowStore.d.ts +26 -0
  13. package/lib/store/SyncRowStore.js +45 -0
  14. package/lib/store/TriggerExecutor.d.ts +14 -14
  15. package/lib/store/TriggerExecutor.js +225 -238
  16. package/lib/store/actionDef.d.ts +5 -4
  17. package/lib/store/actionDef.js +44 -134
  18. package/lib/store/checker.d.ts +6 -0
  19. package/lib/store/checker.js +165 -0
  20. package/lib/store/filter.d.ts +5 -0
  21. package/lib/store/filter.js +394 -2
  22. package/lib/store/modi.d.ts +7 -6
  23. package/lib/store/modi.js +35 -46
  24. package/lib/store/relation.d.ts +1 -1
  25. package/lib/triggers/index.d.ts +4 -3
  26. package/lib/triggers/modi.d.ts +2 -2
  27. package/lib/triggers/modi.js +5 -5
  28. package/lib/types/AppLoader.d.ts +3 -3
  29. package/lib/types/Aspect.d.ts +3 -3
  30. package/lib/types/Auth.d.ts +25 -22
  31. package/lib/types/Connector.d.ts +7 -7
  32. package/lib/types/Context.d.ts +4 -14
  33. package/lib/types/Entity.d.ts +20 -15
  34. package/lib/types/Entity.js +9 -2
  35. package/lib/types/Exception.js +11 -11
  36. package/lib/types/RowStore.d.ts +2 -13
  37. package/lib/types/RowStore.js +1 -6
  38. package/lib/types/Trigger.d.ts +32 -48
  39. package/lib/types/Trigger.js +24 -9
  40. package/lib/types/Watcher.d.ts +7 -8
  41. package/lib/utils/SimpleConnector.d.ts +9 -8
  42. package/lib/utils/SimpleConnector.js +4 -5
  43. package/lib/utils/random/random.d.ts +1 -0
  44. package/lib/utils/random/random.js +24 -0
  45. package/lib/utils/random/random.mp.d.ts +1 -0
  46. package/lib/utils/random/random.mp.js +25 -0
  47. package/lib/utils/random/random.web.d.ts +1 -0
  48. package/lib/utils/random/random.web.js +17 -0
  49. package/lib/utils/string.d.ts +20 -0
  50. package/lib/utils/string.js +60 -1
  51. package/lib/utils/uuid.d.ts +10 -0
  52. package/lib/utils/uuid.js +172 -1
  53. package/lib/utils/validator.js +1 -1
  54. package/package.json +5 -3
  55. package/lib/OakError.d.ts +0 -7
  56. package/lib/OakError.js +0 -15
  57. package/lib/compiler/utils.d.ts +0 -2
  58. package/lib/compiler/utils.js +0 -11
  59. package/lib/entities/Action.d.ts +0 -12
  60. package/lib/entities/Action.js +0 -17
  61. package/lib/entities/Ooperation.d.ts +0 -12
  62. package/lib/entities/Ooperation.js +0 -17
  63. package/lib/entities/Update.d.ts +0 -9
  64. package/lib/entities/Update.js +0 -44
  65. package/lib/entities/Uupdate.d.ts +0 -9
  66. package/lib/entities/Uupdate.js +0 -44
  67. package/lib/store/UniversalContext.d.ts +0 -32
  68. package/lib/store/action.d.ts +0 -6
  69. package/lib/store/action.js +0 -14
  70. package/lib/store/projection.d.ts +0 -7
  71. package/lib/store/projection.js +0 -211
  72. package/lib/store/watchers.d.ts +0 -2
  73. package/lib/store/watchers.js +0 -32
@@ -1,27 +1,22 @@
1
- import { Context } from '../types/Context';
2
- import { EntityDict, OperateOption, SelectOption, OperationResult, SelectRowShape } from "../types/Entity";
1
+ import { EntityDict, OperateOption, SelectOption, OperationResult, DeduceFilter } from "../types/Entity";
3
2
  import { EntityDict as BaseEntityDict } from '../base-app-domain';
4
3
  import { RowStore } from '../types/RowStore';
5
4
  import { StorageSchema } from '../types/Storage';
5
+ import { SyncContext } from "./SyncRowStore";
6
+ import { AsyncContext } from "./AsyncRowStore";
6
7
  /**这个用来处理级联的select和update,对不同能力的 */
7
- export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>> extends RowStore<ED, Cxt> {
8
+ export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> extends RowStore<ED> {
8
9
  constructor(storageSchema: StorageSchema<ED>);
9
10
  protected abstract supportManyToOneJoin(): boolean;
10
11
  protected abstract supportMultipleCreate(): boolean;
11
- protected abstract selectAbjointRow<T extends keyof ED, S extends ED[T]['Selection'], OP extends SelectOption>(entity: T, selection: S, context: Cxt, option: OP): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
12
- protected abstract updateAbjointRow<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Create'] | ED[T]['Update'] | ED[T]['Remove'], context: Cxt, option: OP): Promise<number>;
13
- /**
14
- * 将一次查询的结果集加入result
15
- * @param entity
16
- * @param rows
17
- * @param context
18
- */
19
- private addToResultSelections;
20
- private reduceDescendants;
21
- private destructCascadeSelect;
22
- protected cascadeSelect<T extends keyof ED, S extends ED[T]['Selection'], OP extends SelectOption>(entity: T, selection: S, context: Cxt, option: OP): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
23
- protected cascadeSelect2<T extends keyof ED, S extends ED[T]['Selection'], OP extends SelectOption>(entity: T, selection: S, context: Cxt, option: OP): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
24
- private destructCascadeUpdate;
12
+ protected abstract selectAbjointRow<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]['Schema']>[];
13
+ protected abstract updateAbjointRow<T extends keyof ED, OP extends OperateOption, Cxt extends SyncContext<ED>>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): number;
14
+ protected abstract selectAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
15
+ 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>;
16
+ protected destructCascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED> | AsyncContext<ED>, R>(entity: T, projection2: ED[T]['Selection']['data'], context: Cxt, cascadeSelect: <T2 extends keyof ED>(entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => R, option: OP): {
17
+ projection: ED[T]["Selection"]["data"];
18
+ cascadeSelectionFns: ((result: Partial<ED[T]['Schema']>[]) => Promise<void> | void)[];
19
+ };
25
20
  /**
26
21
  * 级联更新
27
22
  * A --> B
@@ -46,11 +41,22 @@ export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDic
46
41
  * 两者必须通过entity/entityId关联
47
42
  * 此时需要把对B的更新记录成一条新插入的Modi对象,并将A上的entity/entityId指向该对象(新生成的Modi对象的id与此operation的id保持一致)
48
43
  * @param entity
49
- * @param operation
44
+ * @param action
45
+ * @param data
50
46
  * @param context
51
47
  * @param option
48
+ * @param result
49
+ * @param filter
50
+ * @returns
52
51
  */
53
- protected cascadeUpdate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Create'] | ED[T]['Update'] | ED[T]['Remove'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
52
+ 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?: DeduceFilter<ED[T]['Schema']>): {
53
+ data: Record<string, any>;
54
+ beforeFns: (() => R)[];
55
+ afterFns: (() => R)[];
56
+ };
57
+ protected preProcessDataCreated<T extends keyof ED>(entity: T, data: ED[T]['Create']['data']): void;
58
+ protected preProcessDataUpdated<T extends keyof ED>(data: ED[T]['Update']['data']): void;
59
+ judgeRelation(entity: keyof ED, attr: string): string | 2 | 1 | string[] | 0;
54
60
  /**
55
61
  * 和具体的update过程无关的例程放在这里,包括对later动作的处理、对oper的记录以及对record的收集等
56
62
  * @param entity
@@ -58,6 +64,26 @@ export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDic
58
64
  * @param context
59
65
  * @param option
60
66
  */
67
+ private doUpdateSingleRowAsync;
61
68
  private doUpdateSingleRow;
62
- judgeRelation(entity: keyof ED, attr: string): string | string[] | 1 | 0 | 2;
69
+ protected cascadeUpdate<T extends keyof ED, Cxt extends SyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): OperationResult<ED>;
70
+ /**
71
+ *
72
+ * @param entity
73
+ * @param operation
74
+ * @param context
75
+ * @param option
76
+ */
77
+ protected cascadeUpdateAsync<T extends keyof ED, Cxt extends AsyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
78
+ protected cascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]['Schema']>[];
79
+ /**
80
+ * 将一次查询的结果集加入result
81
+ * todo 如果是supportMtoOJoin,这里还要解构(未充分测试)
82
+ * @param entity
83
+ * @param rows
84
+ * @param context
85
+ */
86
+ private addToResultSelections;
87
+ private addSingleRowToResultSelections;
88
+ protected cascadeSelectAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
63
89
  }