oak-domain 4.1.0 → 4.2.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 (73) hide show
  1. package/lib/base-app-domain/ActionAuth/Schema.d.ts +185 -185
  2. package/lib/base-app-domain/ActionDefDict.d.ts +2 -2
  3. package/lib/base-app-domain/I18n/Schema.d.ts +128 -128
  4. package/lib/base-app-domain/Modi/Schema.d.ts +135 -135
  5. package/lib/base-app-domain/ModiEntity/Schema.d.ts +383 -383
  6. package/lib/base-app-domain/Oper/Schema.d.ts +158 -152
  7. package/lib/base-app-domain/Oper/Storage.js +19 -1
  8. package/lib/base-app-domain/OperEntity/Schema.d.ts +372 -372
  9. package/lib/base-app-domain/Path/Schema.d.ts +148 -148
  10. package/lib/base-app-domain/Relation/Schema.d.ts +187 -187
  11. package/lib/base-app-domain/RelationAuth/Schema.d.ts +213 -213
  12. package/lib/base-app-domain/User/Action.d.ts +1 -0
  13. package/lib/base-app-domain/User/Action.js +3 -3
  14. package/lib/base-app-domain/User/Schema.d.ts +209 -209
  15. package/lib/base-app-domain/UserEntityClaim/Schema.d.ts +263 -263
  16. package/lib/base-app-domain/UserEntityGrant/Action.d.ts +5 -5
  17. package/lib/base-app-domain/UserEntityGrant/Action.js +5 -5
  18. package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +130 -130
  19. package/lib/base-app-domain/UserRelation/Schema.d.ts +207 -207
  20. package/lib/compiler/localeBuilder.d.ts +27 -27
  21. package/lib/compiler/localeBuilder.js +215 -215
  22. package/lib/compiler/routerBuilder.js +263 -263
  23. package/lib/compiler/schemalBuilder.js +4167 -4160
  24. package/lib/entities/Oper.d.ts +2 -1
  25. package/lib/entities/Oper.js +16 -1
  26. package/lib/entities/User.d.ts +10 -0
  27. package/lib/entities/User.js +3 -2
  28. package/lib/index.d.ts +0 -22
  29. package/lib/index.js +1 -35
  30. package/lib/store/AsyncRowStore.d.ts +66 -65
  31. package/lib/store/AsyncRowStore.js +180 -180
  32. package/lib/store/CascadeStore.js +7 -31
  33. package/lib/store/RelationAuth.d.ts +103 -103
  34. package/lib/store/RelationAuth.js +1209 -1343
  35. package/lib/store/SyncRowStore.d.ts +29 -29
  36. package/lib/store/TriggerExecutor.js +468 -468
  37. package/lib/store/actionDef.js +278 -278
  38. package/lib/store/checker.js +487 -487
  39. package/lib/triggers/index.d.ts +2 -2
  40. package/lib/triggers/index.js +21 -1
  41. package/lib/types/Aspect.d.ts +13 -13
  42. package/lib/types/Configuration.d.ts +42 -0
  43. package/lib/types/Configuration.js +3 -0
  44. package/lib/types/Connector.d.ts +38 -38
  45. package/lib/types/Context.d.ts +7 -7
  46. package/lib/types/Entity.d.ts +4 -4
  47. package/lib/types/Environment.d.ts +93 -93
  48. package/lib/types/Exception.d.ts +155 -155
  49. package/lib/types/Exception.js +436 -436
  50. package/lib/types/Sync.d.ts +48 -0
  51. package/lib/types/Sync.js +8 -0
  52. package/lib/types/index.d.ts +1 -0
  53. package/lib/types/index.js +1 -0
  54. package/lib/utils/SimpleConnector.d.ts +64 -64
  55. package/lib/utils/SimpleConnector.js +206 -206
  56. package/lib/utils/assert.d.ts +5 -5
  57. package/lib/utils/projection.d.ts +1 -1
  58. package/lib/utils/relationPath.d.ts +31 -0
  59. package/lib/utils/relationPath.js +202 -0
  60. package/package.json +51 -51
  61. package/src/entities/ActionAuth.ts +41 -41
  62. package/src/entities/I18n.ts +45 -45
  63. package/src/entities/Modi.ts +69 -69
  64. package/src/entities/ModiEntity.ts +26 -26
  65. package/src/entities/Oper.ts +48 -32
  66. package/src/entities/OperEntity.ts +27 -27
  67. package/src/entities/Path.ts +43 -43
  68. package/src/entities/Relation.ts +43 -43
  69. package/src/entities/RelationAuth.ts +44 -44
  70. package/src/entities/User.ts +48 -48
  71. package/src/entities/UserEntityClaim.ts +29 -29
  72. package/src/entities/UserEntityGrant.ts +24 -24
  73. package/src/entities/UserRelation.ts +50 -50
@@ -1,5 +1,5 @@
1
1
  import { EntityDict as BaseEntityDict } from '../base-app-domain';
2
- import { StorageSchema, EntityDict } from '../types';
2
+ import { StorageSchema, EntityDict, Trigger } from '../types';
3
3
  import { AsyncContext } from '../store/AsyncRowStore';
4
4
  import { SyncContext } from '../store/SyncRowStore';
5
- export declare function createDynamicTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): import("../types").Trigger<ED, keyof ED, Cxt>[];
5
+ export declare function createDynamicTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): Trigger<ED, keyof ED, Cxt>[];
@@ -1,8 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createDynamicTriggers = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const assert_1 = tslib_1.__importDefault(require("assert"));
4
6
  const modi_1 = require("../store/modi");
7
+ function createOperTriggers() {
8
+ return [
9
+ {
10
+ name: 'assign initial bornAt for local oper',
11
+ entity: 'oper',
12
+ action: 'create',
13
+ when: 'before',
14
+ fn({ operation }) {
15
+ const { data } = operation;
16
+ (0, assert_1.default)(!(data instanceof Array));
17
+ if (!data.bornAt) {
18
+ data.bornAt = Date.now();
19
+ }
20
+ return 1;
21
+ }
22
+ }
23
+ ];
24
+ }
5
25
  function createDynamicTriggers(schema) {
6
- return (0, modi_1.createModiRelatedTriggers)(schema);
26
+ return (0, modi_1.createModiRelatedTriggers)(schema).concat(createOperTriggers());
7
27
  }
8
28
  exports.createDynamicTriggers = createDynamicTriggers;
@@ -1,13 +1,13 @@
1
- import { EntityDict } from "./Entity";
2
- import { OpRecord } from "./Entity";
3
- import { AsyncContext } from "../store/AsyncRowStore";
4
- export interface Aspect<ED extends EntityDict, Cxt extends AsyncContext<ED>> {
5
- (params: any, context: Cxt): Promise<any>;
6
- }
7
- export interface AspectWrapper<ED extends EntityDict, Cxt extends AsyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>> {
8
- exec: <T extends keyof AD>(name: T, params: Parameters<AD[T]>[0], ignoreContext?: true) => Promise<{
9
- result: Awaited<ReturnType<AD[T]>>;
10
- opRecords?: OpRecord<ED>[];
11
- message?: string | null;
12
- }>;
13
- }
1
+ import { EntityDict } from "./Entity";
2
+ import { OpRecord } from "./Entity";
3
+ import { AsyncContext } from "../store/AsyncRowStore";
4
+ export interface Aspect<ED extends EntityDict, Cxt extends AsyncContext<ED>> {
5
+ (params: any, context: Cxt): Promise<any>;
6
+ }
7
+ export interface AspectWrapper<ED extends EntityDict, Cxt extends AsyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>> {
8
+ exec: <T extends keyof AD>(name: T, params: Parameters<AD[T]>[0], ignoreContext?: true) => Promise<{
9
+ result: Awaited<ReturnType<AD[T]>>;
10
+ opRecords?: OpRecord<ED>[];
11
+ message?: string | null;
12
+ }>;
13
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * 后台环境配置
3
+ */
4
+ export type ServerConfiguration = {
5
+ database: {
6
+ type: 'mysql';
7
+ host: string;
8
+ database: string;
9
+ port: number;
10
+ user: string;
11
+ password?: string;
12
+ connectionLimit: number;
13
+ charset: "utf8mb4_general_ci";
14
+ };
15
+ http: {
16
+ port: number;
17
+ };
18
+ };
19
+ /**
20
+ * 前后台共用的配置
21
+ */
22
+ export type ProjectConfiguration = {
23
+ routerPrefixes?: {
24
+ aspect?: string;
25
+ endpoint?: string;
26
+ subscribe?: string;
27
+ getSubscribePoint?: string;
28
+ bridge?: string;
29
+ };
30
+ };
31
+ /**
32
+ * 编译环境配置
33
+ */
34
+ export type CompilerConfiguration = {
35
+ webpack?: {
36
+ resolve?: {
37
+ alias?: Record<string, string>;
38
+ fallback?: Record<string, string | false>;
39
+ };
40
+ extraOakModules?: (string | RegExp)[];
41
+ };
42
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // 将项目的所有配置规范化到一起(未完成)by Xc 20240207
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,38 +1,38 @@
1
- /// <reference types="node" />
2
- import { IncomingHttpHeaders } from "http";
3
- import { SyncContext } from "../store/SyncRowStore";
4
- import { EntityDict, OpRecord } from "./Entity";
5
- import { OakException } from "./Exception";
6
- export interface Connector<ED extends EntityDict, FrontCxt extends SyncContext<ED>> {
7
- callAspect: (name: string, params: any, context?: FrontCxt) => Promise<{
8
- result: any;
9
- opRecords?: OpRecord<ED>[];
10
- message?: string | null;
11
- }>;
12
- getRouter: () => string;
13
- parseRequestHeaders: (headers: IncomingHttpHeaders) => {
14
- contextString?: string;
15
- aspectName: string;
16
- };
17
- serializeResult: (result: any, opRecords: OpRecord<ED>[], headers: IncomingHttpHeaders, body: any, message?: string) => Promise<{
18
- body: any;
19
- headers?: Record<string, any>;
20
- }>;
21
- serializeException: (exception: OakException<ED>, headers: IncomingHttpHeaders, body: any) => {
22
- body: any;
23
- headers?: Record<string, any>;
24
- };
25
- getSubscribeRouter: () => string;
26
- getSubscribePointRouter: () => string;
27
- getSubscribePoint: () => Promise<{
28
- url: string;
29
- path: string;
30
- }>;
31
- getBridgeRouter: () => string;
32
- makeBridgeUrl: (url: string, headers?: Record<string, string>) => string;
33
- getEndpointRouter: () => string;
34
- parseBridgeRequestQuery: (urlParams: string) => {
35
- url: string;
36
- headers?: Record<string, string>;
37
- };
38
- }
1
+ /// <reference types="node" />
2
+ import { IncomingHttpHeaders } from "http";
3
+ import { SyncContext } from "../store/SyncRowStore";
4
+ import { EntityDict, OpRecord } from "./Entity";
5
+ import { OakException } from "./Exception";
6
+ export interface Connector<ED extends EntityDict, FrontCxt extends SyncContext<ED>> {
7
+ callAspect: (name: string, params: any, context?: FrontCxt) => Promise<{
8
+ result: any;
9
+ opRecords?: OpRecord<ED>[];
10
+ message?: string | null;
11
+ }>;
12
+ getRouter: () => string;
13
+ parseRequestHeaders: (headers: IncomingHttpHeaders) => {
14
+ contextString?: string;
15
+ aspectName: string;
16
+ };
17
+ serializeResult: (result: any, opRecords: OpRecord<ED>[], headers: IncomingHttpHeaders, body: any, message?: string) => Promise<{
18
+ body: any;
19
+ headers?: Record<string, any>;
20
+ }>;
21
+ serializeException: (exception: OakException<ED>, headers: IncomingHttpHeaders, body: any) => {
22
+ body: any;
23
+ headers?: Record<string, any>;
24
+ };
25
+ getSubscribeRouter: () => string;
26
+ getSubscribePointRouter: () => string;
27
+ getSubscribePoint: () => Promise<{
28
+ url: string;
29
+ path: string;
30
+ }>;
31
+ getBridgeRouter: () => string;
32
+ makeBridgeUrl: (url: string, headers?: Record<string, string>) => string;
33
+ getEndpointRouter: () => string;
34
+ parseBridgeRequestQuery: (urlParams: string) => {
35
+ url: string;
36
+ headers?: Record<string, string>;
37
+ };
38
+ }
@@ -1,7 +1,7 @@
1
- export interface Context {
2
- getCurrentTxnId(): string | undefined;
3
- getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
4
- isRoot(): boolean;
5
- allowUserUpdate(): boolean;
6
- toString(): Promise<string>;
7
- }
1
+ export interface Context {
2
+ getCurrentTxnId(): string | undefined;
3
+ getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
4
+ isRoot(): boolean;
5
+ allowUserUpdate(): boolean;
6
+ toString(): Promise<string>;
7
+ }
@@ -35,7 +35,6 @@ export type OperateOption = {
35
35
  blockTrigger?: true;
36
36
  dontCollect?: boolean;
37
37
  dontCreateOper?: boolean;
38
- dontCreateModi?: boolean;
39
38
  includedDeleted?: true;
40
39
  allowExists?: boolean;
41
40
  modiParentId?: string;
@@ -55,6 +54,7 @@ export type Operation<A extends string, D extends Projection, F extends Filter |
55
54
  action: A;
56
55
  data: D;
57
56
  sorter?: S;
57
+ bornAt?: number;
58
58
  } & FilterPart<A, F>;
59
59
  export type Selection<A extends ReadOnlyAction, D extends Projection, F extends Filter | undefined = undefined, S extends Sorter | undefined = undefined> = {
60
60
  id?: string;
@@ -146,20 +146,20 @@ type RemoveOperationData = {
146
146
  export type RemoveOperation = Operation<'remove', RemoveOperationData, Filter, Sorter>;
147
147
  export type CUDOperation = CreateOperation | UpdateOperation | RemoveOperation;
148
148
  export type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
149
- id?: string;
149
+ id: string;
150
150
  a: 'c';
151
151
  e: T;
152
152
  d: ED[T]['OpSchema'] | ED[T]['OpSchema'][];
153
153
  };
154
154
  export type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
155
- id?: string;
155
+ id: string;
156
156
  a: 'u';
157
157
  e: T;
158
158
  d: UpdateOperationData;
159
159
  f?: Filter;
160
160
  };
161
161
  export type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
162
- id?: string;
162
+ id: string;
163
163
  a: 'r';
164
164
  e: T;
165
165
  f?: Filter;
@@ -1,93 +1,93 @@
1
- export type WechatMpEnv = {
2
- type: 'wechatMp';
3
- brand: string;
4
- model: string;
5
- pixelRatio: number;
6
- screenWidth: number;
7
- screenHeight: number;
8
- windowWidth: number;
9
- windowHeight: number;
10
- statusBarHeight: number;
11
- language: string;
12
- version: string;
13
- system: string;
14
- platform: string;
15
- fontSizeSetting: number;
16
- SDKVersion: string;
17
- benchmarkLevel: number;
18
- albumAuthorized?: boolean;
19
- cameraAuthorized: boolean;
20
- locationAuthorized: boolean;
21
- microphoneAuthorized: boolean;
22
- notificationAuthorized: boolean;
23
- notificationAlertAuthorized?: boolean;
24
- notificationBadgeAuthorized?: boolean;
25
- notificationSoundAuthorized?: boolean;
26
- phoneCalendarAuthorized: boolean;
27
- bluetoothEnabled: boolean;
28
- locationEnabled: boolean;
29
- wifiEnabled: boolean;
30
- locationReducedAccuracy?: boolean;
31
- theme?: 'light' | 'dark';
32
- enableDebug: boolean;
33
- deviceOrientation: 'portrait' | 'landscape';
34
- host: {
35
- appId: string;
36
- };
37
- localStorageEnabled: true;
38
- };
39
- export type WebEnv = {
40
- type: 'web';
41
- visitorId: string;
42
- platform: {
43
- value: string;
44
- };
45
- timezone: {
46
- value: string;
47
- };
48
- vendor: {
49
- value: string;
50
- };
51
- vendorFlavors: {
52
- value: string[];
53
- };
54
- language: string;
55
- localStorageEnabled: boolean;
56
- };
57
- export type ServerEnv = {
58
- type: 'server';
59
- };
60
- export type NativeEnv = {
61
- constants: {
62
- isTesting: boolean;
63
- reactNativeVersion: object;
64
- Version?: number;
65
- Release?: string;
66
- Serial?: string;
67
- Fingerprint?: string;
68
- Model?: string;
69
- Brand?: string;
70
- Manufacture?: string;
71
- ServerHost?: string;
72
- uiMode?: 'car' | 'desk' | 'normal' | 'tv' | 'watch' | 'unknown';
73
- forceTouchAvailable?: boolean;
74
- interfaceIdiom?: string;
75
- osVersion?: string;
76
- systemName?: string;
77
- };
78
- isPad: boolean;
79
- isTesting: boolean;
80
- OS: 'android' | 'ios';
81
- Version: number | string;
82
- language: string;
83
- visitorId: string;
84
- type: 'native';
85
- };
86
- export type Environment = WechatMpEnv | WebEnv | ServerEnv | NativeEnv;
87
- export type BriefEnv = {
88
- system: string;
89
- brand?: string;
90
- model?: string;
91
- wechat?: string;
92
- explorer?: string;
93
- };
1
+ export type WechatMpEnv = {
2
+ type: 'wechatMp';
3
+ brand: string;
4
+ model: string;
5
+ pixelRatio: number;
6
+ screenWidth: number;
7
+ screenHeight: number;
8
+ windowWidth: number;
9
+ windowHeight: number;
10
+ statusBarHeight: number;
11
+ language: string;
12
+ version: string;
13
+ system: string;
14
+ platform: string;
15
+ fontSizeSetting: number;
16
+ SDKVersion: string;
17
+ benchmarkLevel: number;
18
+ albumAuthorized?: boolean;
19
+ cameraAuthorized: boolean;
20
+ locationAuthorized: boolean;
21
+ microphoneAuthorized: boolean;
22
+ notificationAuthorized: boolean;
23
+ notificationAlertAuthorized?: boolean;
24
+ notificationBadgeAuthorized?: boolean;
25
+ notificationSoundAuthorized?: boolean;
26
+ phoneCalendarAuthorized: boolean;
27
+ bluetoothEnabled: boolean;
28
+ locationEnabled: boolean;
29
+ wifiEnabled: boolean;
30
+ locationReducedAccuracy?: boolean;
31
+ theme?: 'light' | 'dark';
32
+ enableDebug: boolean;
33
+ deviceOrientation: 'portrait' | 'landscape';
34
+ host: {
35
+ appId: string;
36
+ };
37
+ localStorageEnabled: true;
38
+ };
39
+ export type WebEnv = {
40
+ type: 'web';
41
+ visitorId: string;
42
+ platform: {
43
+ value: string;
44
+ };
45
+ timezone: {
46
+ value: string;
47
+ };
48
+ vendor: {
49
+ value: string;
50
+ };
51
+ vendorFlavors: {
52
+ value: string[];
53
+ };
54
+ language: string;
55
+ localStorageEnabled: boolean;
56
+ };
57
+ export type ServerEnv = {
58
+ type: 'server';
59
+ };
60
+ export type NativeEnv = {
61
+ constants: {
62
+ isTesting: boolean;
63
+ reactNativeVersion: object;
64
+ Version?: number;
65
+ Release?: string;
66
+ Serial?: string;
67
+ Fingerprint?: string;
68
+ Model?: string;
69
+ Brand?: string;
70
+ Manufacture?: string;
71
+ ServerHost?: string;
72
+ uiMode?: 'car' | 'desk' | 'normal' | 'tv' | 'watch' | 'unknown';
73
+ forceTouchAvailable?: boolean;
74
+ interfaceIdiom?: string;
75
+ osVersion?: string;
76
+ systemName?: string;
77
+ };
78
+ isPad: boolean;
79
+ isTesting: boolean;
80
+ OS: 'android' | 'ios';
81
+ Version: number | string;
82
+ language: string;
83
+ visitorId: string;
84
+ type: 'native';
85
+ };
86
+ export type Environment = WechatMpEnv | WebEnv | ServerEnv | NativeEnv;
87
+ export type BriefEnv = {
88
+ system: string;
89
+ brand?: string;
90
+ model?: string;
91
+ wechat?: string;
92
+ explorer?: string;
93
+ };