oak-domain 2.6.10 → 3.0.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 (122) hide show
  1. package/lib/actions/action.d.ts +1 -1
  2. package/lib/actions/action.js +2 -2
  3. package/lib/base-app-domain/ActionAuth/Schema.d.ts +25 -21
  4. package/lib/base-app-domain/ActionAuth/Storage.js +6 -13
  5. package/lib/base-app-domain/ActionDefDict.d.ts +1 -0
  6. package/lib/base-app-domain/ActionDefDict.js +3 -1
  7. package/lib/base-app-domain/EntityDict.d.ts +2 -0
  8. package/lib/base-app-domain/I18n/Schema.d.ts +129 -0
  9. package/lib/base-app-domain/I18n/Schema.js +2 -0
  10. package/lib/base-app-domain/I18n/Storage.d.ts +3 -0
  11. package/lib/base-app-domain/I18n/Storage.js +59 -0
  12. package/lib/base-app-domain/Modi/Action.d.ts +1 -1
  13. package/lib/base-app-domain/Modi/Schema.d.ts +10 -9
  14. package/lib/base-app-domain/ModiEntity/Schema.d.ts +42 -28
  15. package/lib/base-app-domain/ModiEntity/Storage.js +1 -1
  16. package/lib/base-app-domain/Oper/Schema.d.ts +15 -13
  17. package/lib/base-app-domain/OperEntity/Schema.d.ts +41 -27
  18. package/lib/base-app-domain/OperEntity/Storage.js +1 -1
  19. package/lib/base-app-domain/Relation/Schema.d.ts +50 -22
  20. package/lib/base-app-domain/Relation/Storage.js +1 -4
  21. package/lib/base-app-domain/Relation.d.ts +10 -0
  22. package/lib/base-app-domain/Relation.js +10 -0
  23. package/lib/base-app-domain/RelationAuth/Schema.d.ts +67 -43
  24. package/lib/base-app-domain/RelationAuth/Storage.js +9 -12
  25. package/lib/base-app-domain/Storage.js +20 -18
  26. package/lib/base-app-domain/User/Action.d.ts +1 -1
  27. package/lib/base-app-domain/User/Schema.d.ts +20 -14
  28. package/lib/base-app-domain/User/Storage.js +1 -2
  29. package/lib/base-app-domain/UserEntityGrant/Action.d.ts +5 -0
  30. package/lib/base-app-domain/UserEntityGrant/Action.js +5 -0
  31. package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +53 -17
  32. package/lib/base-app-domain/UserEntityGrant/Storage.js +5 -7
  33. package/lib/base-app-domain/UserRelation/Schema.d.ts +35 -16
  34. package/lib/base-app-domain/UserRelation/Storage.js +21 -1
  35. package/lib/base-app-domain/_SubQuery.d.ts +40 -4
  36. package/lib/base-app-domain/index.d.ts +1 -0
  37. package/lib/base-app-domain/index.js +1 -0
  38. package/lib/checkers/index.d.ts +2 -2
  39. package/lib/checkers/index.js +2 -5
  40. package/lib/compiler/env.d.ts +3 -1
  41. package/lib/compiler/env.js +12 -2
  42. package/lib/compiler/localeBuilder.d.ts +22 -0
  43. package/lib/compiler/localeBuilder.js +169 -0
  44. package/lib/compiler/schemalBuilder.d.ts +9 -0
  45. package/lib/compiler/schemalBuilder.js +774 -362
  46. package/lib/entities/ActionAuth.d.ts +3 -2
  47. package/lib/entities/ActionAuth.js +21 -22
  48. package/lib/entities/I18n.d.ts +9 -0
  49. package/lib/entities/I18n.js +37 -0
  50. package/lib/entities/Modi.js +35 -33
  51. package/lib/entities/ModiEntity.js +12 -10
  52. package/lib/entities/Oper.js +15 -13
  53. package/lib/entities/OperEntity.js +12 -10
  54. package/lib/entities/Relation.d.ts +3 -3
  55. package/lib/entities/Relation.js +27 -25
  56. package/lib/entities/RelationAuth.d.ts +2 -5
  57. package/lib/entities/RelationAuth.js +27 -23
  58. package/lib/entities/User.js +20 -18
  59. package/lib/entities/UserEntityGrant.d.ts +2 -1
  60. package/lib/entities/UserEntityGrant.js +12 -7
  61. package/lib/entities/UserRelation.d.ts +3 -0
  62. package/lib/entities/UserRelation.js +30 -20
  63. package/lib/store/AsyncRowStore.d.ts +3 -0
  64. package/lib/store/AsyncRowStore.js +3 -0
  65. package/lib/store/CascadeStore.d.ts +9 -3
  66. package/lib/store/CascadeStore.js +247 -113
  67. package/lib/store/RelationAuth.d.ts +96 -0
  68. package/lib/store/RelationAuth.js +1307 -0
  69. package/lib/store/TriggerExecutor.d.ts +1 -2
  70. package/lib/store/TriggerExecutor.js +22 -22
  71. package/lib/store/actionAuth.d.ts +4 -0
  72. package/lib/store/actionAuth.js +40 -0
  73. package/lib/store/actionDef.d.ts +4 -3
  74. package/lib/store/actionDef.js +14 -10
  75. package/lib/store/checker.d.ts +2 -9
  76. package/lib/store/checker.js +39 -815
  77. package/lib/store/filter.d.ts +31 -18
  78. package/lib/store/filter.js +1256 -422
  79. package/lib/store/modi.d.ts +1 -1
  80. package/lib/store/modi.js +108 -9
  81. package/lib/store/relation.d.ts +3 -4
  82. package/lib/timers/oper.js +1 -1
  83. package/lib/timers/vaccum.js +2 -2
  84. package/lib/triggers/index.d.ts +2 -3
  85. package/lib/triggers/index.js +2 -5
  86. package/lib/types/Auth.d.ts +5 -0
  87. package/lib/types/DataType.d.ts +3 -0
  88. package/lib/types/Demand.d.ts +11 -0
  89. package/lib/types/Demand.js +2 -1
  90. package/lib/types/Entity.d.ts +10 -3
  91. package/lib/types/EntityDesc.d.ts +8 -0
  92. package/lib/types/EntityDesc.js +2 -0
  93. package/lib/types/Environment.d.ts +57 -0
  94. package/lib/types/Environment.js +2 -0
  95. package/lib/types/Exception.d.ts +6 -0
  96. package/lib/types/Exception.js +25 -1
  97. package/lib/types/Logger.d.ts +1 -0
  98. package/lib/types/RowStore.d.ts +6 -4
  99. package/lib/types/Style.d.ts +1 -1
  100. package/lib/types/Trigger.d.ts +4 -5
  101. package/lib/types/Trigger.js +11 -6
  102. package/lib/types/index.d.ts +2 -0
  103. package/lib/types/index.js +2 -0
  104. package/lib/utils/SimpleConnector.js +1 -1
  105. package/lib/utils/string.d.ts +6 -0
  106. package/lib/utils/string.js +13 -1
  107. package/lib/utils/uuid.d.ts +5 -0
  108. package/lib/utils/uuid.js +64 -1
  109. package/package.json +3 -3
  110. package/src/entities/ActionAuth.ts +25 -33
  111. package/src/entities/I18n.ts +46 -0
  112. package/src/entities/Modi.ts +36 -36
  113. package/src/entities/ModiEntity.ts +14 -13
  114. package/src/entities/Oper.ts +17 -16
  115. package/src/entities/OperEntity.ts +13 -11
  116. package/src/entities/Relation.ts +31 -37
  117. package/src/entities/RelationAuth.ts +31 -37
  118. package/src/entities/User.ts +24 -21
  119. package/src/entities/UserEntityGrant.ts +16 -14
  120. package/src/entities/UserRelation.ts +33 -27
  121. package/lib/triggers/modi.d.ts +0 -5
  122. package/lib/triggers/modi.js +0 -72
@@ -1,25 +1,27 @@
1
1
  import { String } from '../types/DataType';
2
- import { LocaleDef } from '../types/Locale';
3
2
  import { EntityShape } from '../types/Entity';
3
+ import { Schema as Relation } from './Relation';
4
+ import { EntityDesc } from '../types/EntityDesc';
4
5
 
5
6
  export interface Schema extends EntityShape {
6
7
  entity: String<32>;
7
8
  entityId: String<64>;
8
- relation: String<32>;
9
+ relation: Relation;
9
10
  };
11
+ type Action = 'confirm';
10
12
 
11
- const locale: LocaleDef<
12
- Schema,
13
- '',
14
- '',
15
- {}
16
- > = {
17
- zh_CN: {
18
- name: '用户授权',
19
- attr: {
20
- relation: '关系',
21
- entity: '关联对象',
22
- entityId: '关联对象id',
13
+ const entityDesc: EntityDesc<Schema, Action> = {
14
+ locales: {
15
+ zh_CN: {
16
+ name: '用户授权',
17
+ attr: {
18
+ relation: '关系',
19
+ entity: '关联对象',
20
+ entityId: '关联对象id',
21
+ },
22
+ action: {
23
+ confirm: '领取',
24
+ },
23
25
  },
24
26
  },
25
27
  };
@@ -4,41 +4,47 @@ import { EntityShape } from '../types/Entity';
4
4
  import { Index } from '../types/Storage';
5
5
  import { Schema as User } from './User';
6
6
  import { Schema as Relation } from './Relation';
7
+ import { EntityDesc } from '../types/EntityDesc';
7
8
 
8
9
  export interface Schema extends EntityShape {
9
10
  user: User;
10
11
  relation: Relation;
12
+ entity: String<32>;
13
+ entityId: String<64>;
11
14
  };
12
15
 
13
-
14
- const indexes: Index<Schema>[] = [
15
- {
16
- name: 'index_user_relation',
17
- attributes: [
18
- {
19
- name: 'user',
20
- },
21
- {
22
- name: 'relation',
16
+ const entityDesc: EntityDesc<Schema> = {
17
+ locales: {
18
+ zh_CN: {
19
+ name: '用户对象关系',
20
+ attr: {
21
+ user: '关系',
22
+ relation: '目标关系',
23
+ entity: '目标对象',
24
+ entityId: '目标对象ID',
23
25
  },
24
- ],
25
- config: {
26
- unique: true,
27
26
  },
28
27
  },
29
- ];
30
-
31
- const locale: LocaleDef<
32
- Schema,
33
- '',
34
- '',
35
- {}
36
- > = {
37
- zh_CN: {
38
- name: '用户对象关系',
39
- attr: {
40
- user: '关系',
41
- relation: '目标关系',
28
+ indexes: [
29
+ {
30
+ name: 'index_user_entity_entityId_relation',
31
+ attributes: [
32
+ {
33
+ name: 'user',
34
+ },
35
+ {
36
+ name: 'entity',
37
+ },
38
+ {
39
+ name: 'entityId',
40
+ },
41
+ {
42
+ name: 'relation',
43
+ },
44
+ ],
45
+ config: {
46
+ unique: true,
47
+ },
42
48
  },
43
- },
49
+ ]
44
50
  };
@@ -1,5 +0,0 @@
1
- import { EntityDict } from "../base-app-domain";
2
- import { AsyncContext } from "../store/AsyncRowStore";
3
- import { Trigger } from "../types";
4
- declare const triggers: Trigger<EntityDict, 'modi', AsyncContext<EntityDict>>[];
5
- export default triggers;
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var triggers = [
5
- {
6
- name: '当modi被应用时,将相应的operate完成',
7
- entity: 'modi',
8
- action: 'apply',
9
- when: 'after',
10
- fn: function (_a, context, option) {
11
- var operation = _a.operation;
12
- return tslib_1.__awaiter(void 0, void 0, void 0, function () {
13
- var filter, modies, modies_1, modies_1_1, modi, targetEntity, id, action, data, filter_1, e_1_1;
14
- var e_1, _b;
15
- return tslib_1.__generator(this, function (_c) {
16
- switch (_c.label) {
17
- case 0:
18
- filter = operation.filter;
19
- return [4 /*yield*/, context.select('modi', {
20
- data: {
21
- id: 1,
22
- action: 1,
23
- data: 1,
24
- filter: 1,
25
- targetEntity: 1,
26
- },
27
- filter: filter,
28
- }, option)];
29
- case 1:
30
- modies = _c.sent();
31
- _c.label = 2;
32
- case 2:
33
- _c.trys.push([2, 7, 8, 9]);
34
- modies_1 = tslib_1.__values(modies), modies_1_1 = modies_1.next();
35
- _c.label = 3;
36
- case 3:
37
- if (!!modies_1_1.done) return [3 /*break*/, 6];
38
- modi = modies_1_1.value;
39
- targetEntity = modi.targetEntity, id = modi.id, action = modi.action, data = modi.data, filter_1 = modi.filter;
40
- return [4 /*yield*/, context.operate(targetEntity, {
41
- id: id,
42
- action: action,
43
- data: data,
44
- filter: filter_1,
45
- }, Object.assign({}, option, {
46
- blockTrigger: true,
47
- }))];
48
- case 4:
49
- _c.sent();
50
- _c.label = 5;
51
- case 5:
52
- modies_1_1 = modies_1.next();
53
- return [3 /*break*/, 3];
54
- case 6: return [3 /*break*/, 9];
55
- case 7:
56
- e_1_1 = _c.sent();
57
- e_1 = { error: e_1_1 };
58
- return [3 /*break*/, 9];
59
- case 8:
60
- try {
61
- if (modies_1_1 && !modies_1_1.done && (_b = modies_1.return)) _b.call(modies_1);
62
- }
63
- finally { if (e_1) throw e_1.error; }
64
- return [7 /*endfinally*/];
65
- case 9: return [2 /*return*/, modies.length];
66
- }
67
- });
68
- });
69
- }
70
- }
71
- ];
72
- exports.default = triggers;