oak-domain 2.3.2 → 2.4.0

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 (38) hide show
  1. package/lib/actions/relation.d.ts +4 -0
  2. package/lib/actions/relation.js +36 -0
  3. package/lib/base-app-domain/Modi/Schema.d.ts +2 -4
  4. package/lib/base-app-domain/ModiEntity/Schema.d.ts +2 -4
  5. package/lib/base-app-domain/Oper/Schema.d.ts +2 -4
  6. package/lib/base-app-domain/OperEntity/Schema.d.ts +2 -4
  7. package/lib/base-app-domain/User/Schema.d.ts +2 -4
  8. package/lib/checkers/index.d.ts +2 -2
  9. package/lib/checkers/index.js +4 -2
  10. package/lib/compiler/schemalBuilder.js +87 -31
  11. package/lib/store/CascadeStore.d.ts +4 -4
  12. package/lib/store/TriggerExecutor.js +45 -26
  13. package/lib/store/checker.d.ts +10 -4
  14. package/lib/store/checker.js +342 -235
  15. package/lib/store/filter.d.ts +11 -2
  16. package/lib/store/filter.js +40 -25
  17. package/lib/store/modi.js +0 -8
  18. package/lib/store/relation.d.ts +1 -1
  19. package/lib/store/relation.js +1 -1
  20. package/lib/types/Action.d.ts +5 -1
  21. package/lib/types/Auth.d.ts +26 -26
  22. package/lib/types/Endpoint.d.ts +10 -0
  23. package/lib/types/Endpoint.js +3 -0
  24. package/lib/types/Entity.d.ts +55 -69
  25. package/lib/types/Entity.js +0 -1
  26. package/lib/types/Exception.d.ts +5 -0
  27. package/lib/types/Exception.js +16 -1
  28. package/lib/types/Expression.d.ts +24 -2
  29. package/lib/types/Expression.js +27 -2
  30. package/lib/types/Port.d.ts +17 -0
  31. package/lib/types/Port.js +2 -0
  32. package/lib/types/Storage.d.ts +4 -4
  33. package/lib/types/Trigger.d.ts +2 -2
  34. package/lib/types/index.d.ts +2 -0
  35. package/lib/types/index.js +2 -0
  36. package/lib/utils/date.d.ts +1 -0
  37. package/lib/utils/date.js +18 -0
  38. package/package.json +2 -2
@@ -0,0 +1,17 @@
1
+ import { AsyncContext } from "../store/AsyncRowStore";
2
+ import { EntityDict } from "./Entity";
3
+ export declare type Exportation<ED extends EntityDict, T extends keyof ED, K extends string> = {
4
+ name: string;
5
+ id: string;
6
+ entity: T;
7
+ projection: ED[T]['Selection']['data'];
8
+ headers: K[];
9
+ fn: (data: ED[T]['Schema']) => Partial<Record<K, string | number | boolean | null>>;
10
+ };
11
+ export declare type Importation<ED extends EntityDict, T extends keyof ED, K extends string> = {
12
+ name: string;
13
+ id: string;
14
+ entity: T;
15
+ headers: K[];
16
+ fn: (data: Partial<Record<K, string | number | boolean>>[], context: AsyncContext<ED>, option?: Record<string, any>) => Promise<ED[T]['CreateMulti']['data']>;
17
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
1
  import { ActionType } from '.';
2
- import { EntityDict, EntityShape, InstinctiveAttributes, RelationHierarchy } from './Entity';
2
+ import { EntityDict, EntityShape, InstinctiveAttributes } from './Entity';
3
3
  import { DataType, DataTypeParams } from './schema/DataTypes';
4
4
  export declare type Ref = 'ref';
5
5
  export interface Column<SH extends EntityShape> {
@@ -36,7 +36,7 @@ export declare type UniqConstraint<SH extends EntityShape> = {
36
36
  attributes: Array<keyof SH>;
37
37
  type?: string;
38
38
  };
39
- export interface StorageDesc<SH extends EntityShape, Relation extends string = ''> {
39
+ export interface StorageDesc<SH extends EntityShape> {
40
40
  storageName?: string;
41
41
  comment?: string;
42
42
  attributes: Attributes<SH>;
@@ -48,9 +48,9 @@ export interface StorageDesc<SH extends EntityShape, Relation extends string = '
48
48
  static?: true;
49
49
  actions: string[];
50
50
  actionType: ActionType;
51
- relationHierarchy?: RelationHierarchy<Relation>;
51
+ relation?: string[];
52
52
  view?: true;
53
53
  }
54
54
  export declare type StorageSchema<ED extends EntityDict> = {
55
- [K in keyof ED]: StorageDesc<ED[K]['OpSchema'], any>;
55
+ [K in keyof ED]: StorageDesc<ED[K]['OpSchema']>;
56
56
  };
@@ -37,7 +37,7 @@ export interface UpdateTriggerBase<ED extends EntityDict, T extends keyof ED, Cx
37
37
  fn: (event: {
38
38
  operation: ED[T]['Update'];
39
39
  }, context: Cxt, option: OperateOption) => Promise<number> | number;
40
- filter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Update'], context: Cxt, option: OperateOption) => ED[T]['Update']['filter']);
40
+ filter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Update'], context: Cxt, option: OperateOption) => ED[T]['Update']['filter'] | Promise<ED[T]['Update']['filter']>);
41
41
  }
42
42
  export interface UpdateTriggerInTxn<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends UpdateTriggerBase<ED, T, Cxt> {
43
43
  when: 'before' | 'after';
@@ -58,7 +58,7 @@ export interface RemoveTriggerBase<ED extends EntityDict, T extends keyof ED, Cx
58
58
  fn: (event: {
59
59
  operation: ED[T]['Remove'];
60
60
  }, context: Cxt, option: OperateOption) => Promise<number> | number;
61
- filter?: ED[T]['Remove']['filter'] | ((operation: ED[T]['Remove'], context: Cxt, option: OperateOption) => ED[T]['Remove']['filter']);
61
+ filter?: ED[T]['Remove']['filter'] | ((operation: ED[T]['Remove'], context: Cxt, option: OperateOption) => ED[T]['Remove']['filter'] | Promise<ED[T]['Remove']['filter']>);
62
62
  }
63
63
  export interface RemoveTriggerInTxn<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> extends RemoveTriggerBase<ED, T, Cxt> {
64
64
  when: 'before' | 'after';
@@ -17,3 +17,5 @@ export * from './Watcher';
17
17
  export * from './AppLoader';
18
18
  export * from './Connector';
19
19
  export * from './Timer';
20
+ export * from './Port';
21
+ export * from './Endpoint';
@@ -20,3 +20,5 @@ tslib_1.__exportStar(require("./Watcher"), exports);
20
20
  tslib_1.__exportStar(require("./AppLoader"), exports);
21
21
  tslib_1.__exportStar(require("./Connector"), exports);
22
22
  tslib_1.__exportStar(require("./Timer"), exports);
23
+ tslib_1.__exportStar(require("./Port"), exports);
24
+ tslib_1.__exportStar(require("./Endpoint"), exports);
@@ -0,0 +1 @@
1
+ export declare function excelStringToDate(str: string | number): number | undefined;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.excelStringToDate = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
6
+ function excelStringToDate(str) {
7
+ if (!str) {
8
+ return undefined;
9
+ }
10
+ if (typeof str === 'number') {
11
+ if (str < 100000) {
12
+ return (0, dayjs_1.default)((((str - 25569) * 24 - 8) * 3600) * 1000).valueOf(); // excel日期可能为1900-1-1至今的天数
13
+ }
14
+ return (0, dayjs_1.default)(str).valueOf();
15
+ }
16
+ return Date.parse(str);
17
+ }
18
+ exports.excelStringToDate = excelStringToDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-domain",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "author": {
5
5
  "name": "XuChang"
6
6
  },
@@ -37,7 +37,7 @@
37
37
  "mocha": "^8.2.1",
38
38
  "ts-node": "~10.9.1",
39
39
  "tslib": "^2.4.0",
40
- "typescript": "~4.7.4"
40
+ "typescript": "^4.9.4"
41
41
  },
42
42
  "dependencies": {
43
43
  "@datasert/cronjs-matcher": "^1.2.0",