oak-domain 4.2.3 → 4.2.4

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 (53) hide show
  1. package/lib/base-app-domain/ActionDefDict.d.ts +8 -8
  2. package/lib/base-app-domain/Oper/Schema.d.ts +158 -158
  3. package/lib/base-app-domain/Oper/Storage.js +56 -56
  4. package/lib/base-app-domain/User/Action.d.ts +11 -11
  5. package/lib/base-app-domain/User/Action.js +12 -12
  6. package/lib/base-app-domain/UserEntityGrant/Action.d.ts +5 -5
  7. package/lib/base-app-domain/UserEntityGrant/Action.js +5 -5
  8. package/lib/compiler/schemalBuilder.js +4167 -4167
  9. package/lib/entities/Oper.d.ts +12 -12
  10. package/lib/entities/Oper.js +36 -36
  11. package/lib/entities/User.d.ts +18 -18
  12. package/lib/entities/User.js +32 -32
  13. package/lib/index.d.ts +1 -1
  14. package/lib/index.js +3 -3
  15. package/lib/store/AsyncRowStore.d.ts +66 -66
  16. package/lib/store/CascadeStore.d.ts +109 -109
  17. package/lib/store/CascadeStore.js +1728 -1728
  18. package/lib/store/RelationAuth.js +1209 -1209
  19. package/lib/store/TriggerExecutor.js +468 -468
  20. package/lib/store/actionDef.js +278 -278
  21. package/lib/store/checker.js +487 -487
  22. package/lib/store/relation.d.ts +12 -12
  23. package/lib/store/relation.js +74 -74
  24. package/lib/triggers/index.d.ts +5 -5
  25. package/lib/triggers/index.js +28 -28
  26. package/lib/types/Configuration.d.ts +42 -42
  27. package/lib/types/Configuration.js +3 -3
  28. package/lib/types/Connector.d.ts +39 -39
  29. package/lib/types/Entity.d.ts +209 -209
  30. package/lib/types/Sync.d.ts +74 -68
  31. package/lib/types/Sync.js +9 -9
  32. package/lib/types/index.d.ts +27 -27
  33. package/lib/types/index.js +30 -30
  34. package/lib/utils/SimpleConnector.d.ts +81 -81
  35. package/lib/utils/SimpleConnector.js +217 -217
  36. package/lib/utils/assert.d.ts +5 -5
  37. package/lib/utils/projection.d.ts +4 -4
  38. package/lib/utils/relationPath.d.ts +31 -31
  39. package/lib/utils/relationPath.js +202 -202
  40. package/package.json +51 -51
  41. package/src/entities/ActionAuth.ts +41 -41
  42. package/src/entities/I18n.ts +45 -45
  43. package/src/entities/Modi.ts +69 -69
  44. package/src/entities/ModiEntity.ts +26 -26
  45. package/src/entities/Oper.ts +48 -48
  46. package/src/entities/OperEntity.ts +27 -27
  47. package/src/entities/Path.ts +43 -43
  48. package/src/entities/Relation.ts +43 -43
  49. package/src/entities/RelationAuth.ts +44 -44
  50. package/src/entities/User.ts +48 -48
  51. package/src/entities/UserEntityClaim.ts +29 -29
  52. package/src/entities/UserEntityGrant.ts +24 -24
  53. package/src/entities/UserRelation.ts +50 -50
@@ -1,12 +1,12 @@
1
- import { EntityDict } from "../base-app-domain";
2
- import { EntityDict as BaseEntityDict } from "../types/Entity";
3
- import { StorageSchema } from "../types/Storage";
4
- /**
5
- * 判断对象和属性之间的关系
6
- * @param schema
7
- * @param entity
8
- * @param attr
9
- * @param row
10
- * @returns
11
- */
12
- export declare function judgeRelation<ED extends EntityDict & BaseEntityDict>(schema: StorageSchema<ED>, entity: keyof ED, attr: string, allowUnrecoganized?: boolean): string | 1 | 2 | string[] | 0 | -1;
1
+ import { EntityDict } from "../base-app-domain";
2
+ import { EntityDict as BaseEntityDict } from "../types/Entity";
3
+ import { StorageSchema } from "../types/Storage";
4
+ /**
5
+ * 判断对象和属性之间的关系
6
+ * @param schema
7
+ * @param entity
8
+ * @param attr
9
+ * @param row
10
+ * @returns
11
+ */
12
+ export declare function judgeRelation<ED extends EntityDict & BaseEntityDict>(schema: StorageSchema<ED>, entity: keyof ED, attr: string, allowUnrecoganized?: boolean): string | 1 | 2 | string[] | 0 | -1;
@@ -1,74 +1,74 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.judgeRelation = void 0;
4
- const tslib_1 = require("tslib");
5
- const assert_1 = tslib_1.__importDefault(require("assert"));
6
- const Demand_1 = require("../types/Demand");
7
- const Entity_1 = require("../types/Entity");
8
- /**
9
- * 判断对象和属性之间的关系
10
- * @param schema
11
- * @param entity
12
- * @param attr
13
- * @param row
14
- * @returns
15
- */
16
- function judgeRelation(schema, entity, attr, allowUnrecoganized) {
17
- const { [entity]: { attributes } } = schema;
18
- if (attr.startsWith(Demand_1.EXPRESSION_PREFIX) || attr.startsWith('#')) {
19
- // 表达式属性或者metadata
20
- return 0;
21
- }
22
- if (attributes.hasOwnProperty(attr) || Entity_1.initinctiveAttributes.includes(attr)) {
23
- // 原生属性
24
- return 1;
25
- }
26
- if (attr.includes('$')) {
27
- const firstDelimiter = attr.indexOf('$');
28
- const entity2 = attr.slice(0, firstDelimiter);
29
- (0, assert_1.default)(schema.hasOwnProperty(entity2));
30
- const secondDelemiter = attr.indexOf('$', firstDelimiter + 1);
31
- const foreignKey = attr.slice(firstDelimiter + 1, secondDelemiter > 0 ? secondDelemiter : attr.length);
32
- const { [entity2]: { attributes: attributes2 } } = schema;
33
- if (foreignKey === 'entity') {
34
- // 基于反指对象的反向关联
35
- return [entity2];
36
- }
37
- else if (attributes2.hasOwnProperty(`${foreignKey}Id`)
38
- && attributes2[`${foreignKey}Id`].type === 'ref'
39
- && attributes2[`${foreignKey}Id`].ref === entity) {
40
- // 基于外键的反向关联
41
- return [entity2, `${foreignKey}Id`];
42
- }
43
- else {
44
- // 这种情况应该不会跑到
45
- (0, assert_1.default)(false);
46
- }
47
- }
48
- else if ((attributes.hasOwnProperty(`${attr}Id`))) {
49
- const { type, ref } = attributes[`${attr}Id`];
50
- if (type === 'ref') {
51
- return ref;
52
- }
53
- return 1;
54
- }
55
- else if (attributes.hasOwnProperty('entity')
56
- && attributes.hasOwnProperty('entityId')
57
- && schema.hasOwnProperty(attr)) {
58
- (0, assert_1.default)(attributes.entity.ref.includes(attr), '不应当出现的case');
59
- // 反向指针的外键
60
- return 2;
61
- }
62
- else {
63
- if (Entity_1.initinctiveAttributes.includes(attr)) {
64
- return 1;
65
- }
66
- else if (allowUnrecoganized) {
67
- return -1;
68
- }
69
- else {
70
- throw new Error(`${entity}对象中的${attr}属性找不到`);
71
- }
72
- }
73
- }
74
- exports.judgeRelation = judgeRelation;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.judgeRelation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const assert_1 = tslib_1.__importDefault(require("assert"));
6
+ const Demand_1 = require("../types/Demand");
7
+ const Entity_1 = require("../types/Entity");
8
+ /**
9
+ * 判断对象和属性之间的关系
10
+ * @param schema
11
+ * @param entity
12
+ * @param attr
13
+ * @param row
14
+ * @returns
15
+ */
16
+ function judgeRelation(schema, entity, attr, allowUnrecoganized) {
17
+ const { [entity]: { attributes } } = schema;
18
+ if (attr.startsWith(Demand_1.EXPRESSION_PREFIX) || attr.startsWith('#')) {
19
+ // 表达式属性或者metadata
20
+ return 0;
21
+ }
22
+ if (attributes.hasOwnProperty(attr) || Entity_1.initinctiveAttributes.includes(attr)) {
23
+ // 原生属性
24
+ return 1;
25
+ }
26
+ if (attr.includes('$')) {
27
+ const firstDelimiter = attr.indexOf('$');
28
+ const entity2 = attr.slice(0, firstDelimiter);
29
+ (0, assert_1.default)(schema.hasOwnProperty(entity2));
30
+ const secondDelemiter = attr.indexOf('$', firstDelimiter + 1);
31
+ const foreignKey = attr.slice(firstDelimiter + 1, secondDelemiter > 0 ? secondDelemiter : attr.length);
32
+ const { [entity2]: { attributes: attributes2 } } = schema;
33
+ if (foreignKey === 'entity') {
34
+ // 基于反指对象的反向关联
35
+ return [entity2];
36
+ }
37
+ else if (attributes2.hasOwnProperty(`${foreignKey}Id`)
38
+ && attributes2[`${foreignKey}Id`].type === 'ref'
39
+ && attributes2[`${foreignKey}Id`].ref === entity) {
40
+ // 基于外键的反向关联
41
+ return [entity2, `${foreignKey}Id`];
42
+ }
43
+ else {
44
+ // 这种情况应该不会跑到
45
+ (0, assert_1.default)(false);
46
+ }
47
+ }
48
+ else if ((attributes.hasOwnProperty(`${attr}Id`))) {
49
+ const { type, ref } = attributes[`${attr}Id`];
50
+ if (type === 'ref') {
51
+ return ref;
52
+ }
53
+ return 1;
54
+ }
55
+ else if (attributes.hasOwnProperty('entity')
56
+ && attributes.hasOwnProperty('entityId')
57
+ && schema.hasOwnProperty(attr)) {
58
+ (0, assert_1.default)(attributes.entity.ref.includes(attr), '不应当出现的case');
59
+ // 反向指针的外键
60
+ return 2;
61
+ }
62
+ else {
63
+ if (Entity_1.initinctiveAttributes.includes(attr)) {
64
+ return 1;
65
+ }
66
+ else if (allowUnrecoganized) {
67
+ return -1;
68
+ }
69
+ else {
70
+ throw new Error(`${entity}对象中的${attr}属性找不到`);
71
+ }
72
+ }
73
+ }
74
+ exports.judgeRelation = judgeRelation;
@@ -1,5 +1,5 @@
1
- import { EntityDict as BaseEntityDict } from '../base-app-domain';
2
- import { StorageSchema, EntityDict, Trigger } from '../types';
3
- import { AsyncContext } from '../store/AsyncRowStore';
4
- import { SyncContext } from '../store/SyncRowStore';
5
- export declare function createDynamicTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): Trigger<ED, keyof ED, Cxt>[];
1
+ import { EntityDict as BaseEntityDict } from '../base-app-domain';
2
+ import { StorageSchema, EntityDict, Trigger } from '../types';
3
+ import { AsyncContext } from '../store/AsyncRowStore';
4
+ import { SyncContext } from '../store/SyncRowStore';
5
+ export declare function createDynamicTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): Trigger<ED, keyof ED, Cxt>[];
@@ -1,28 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDynamicTriggers = void 0;
4
- const tslib_1 = require("tslib");
5
- const assert_1 = tslib_1.__importDefault(require("assert"));
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
- }
25
- function createDynamicTriggers(schema) {
26
- return (0, modi_1.createModiRelatedTriggers)(schema).concat(createOperTriggers());
27
- }
28
- exports.createDynamicTriggers = createDynamicTriggers;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDynamicTriggers = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const assert_1 = tslib_1.__importDefault(require("assert"));
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
+ }
25
+ function createDynamicTriggers(schema) {
26
+ return (0, modi_1.createModiRelatedTriggers)(schema).concat(createOperTriggers());
27
+ }
28
+ exports.createDynamicTriggers = createDynamicTriggers;
@@ -1,42 +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
- };
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
+ };
@@ -1,3 +1,3 @@
1
- "use strict";
2
- // 将项目的所有配置规范化到一起(未完成)by Xc 20240207
3
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ // 将项目的所有配置规范化到一起(未完成)by Xc 20240207
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,39 +1,39 @@
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
- parseRequest: (headers: IncomingHttpHeaders, body?: any, files?: any) => {
14
- contextString?: string;
15
- aspectName: string;
16
- data?: any;
17
- };
18
- serializeResult: (result: any, opRecords: OpRecord<ED>[], headers: IncomingHttpHeaders, body: any, message?: string) => Promise<{
19
- body: any;
20
- headers?: Record<string, any>;
21
- }>;
22
- serializeException: (exception: OakException<ED>, headers: IncomingHttpHeaders, body: any) => {
23
- body: any;
24
- headers?: Record<string, any>;
25
- };
26
- getSubscribeRouter: () => string;
27
- getSubscribePointRouter: () => string;
28
- getSubscribePoint: () => Promise<{
29
- url: string;
30
- path: string;
31
- }>;
32
- getBridgeRouter: () => string;
33
- makeBridgeUrl: (url: string, headers?: Record<string, string>) => string;
34
- getEndpointRouter: () => string;
35
- parseBridgeRequestQuery: (urlParams: string) => {
36
- url: string;
37
- headers?: Record<string, string>;
38
- };
39
- }
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
+ parseRequest: (headers: IncomingHttpHeaders, body?: any, files?: any) => {
14
+ contextString?: string;
15
+ aspectName: string;
16
+ data?: any;
17
+ };
18
+ serializeResult: (result: any, opRecords: OpRecord<ED>[], headers: IncomingHttpHeaders, body: any, message?: string) => Promise<{
19
+ body: any;
20
+ headers?: Record<string, any>;
21
+ }>;
22
+ serializeException: (exception: OakException<ED>, headers: IncomingHttpHeaders, body: any) => {
23
+ body: any;
24
+ headers?: Record<string, any>;
25
+ };
26
+ getSubscribeRouter: () => string;
27
+ getSubscribePointRouter: () => string;
28
+ getSubscribePoint: () => Promise<{
29
+ url: string;
30
+ path: string;
31
+ }>;
32
+ getBridgeRouter: () => string;
33
+ makeBridgeUrl: (url: string, headers?: Record<string, string>) => string;
34
+ getEndpointRouter: () => string;
35
+ parseBridgeRequestQuery: (urlParams: string) => {
36
+ url: string;
37
+ headers?: Record<string, string>;
38
+ };
39
+ }