oak-domain 2.0.2 → 2.0.3
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.
- package/lib/actions/action.d.ts +16 -16
- package/lib/actions/action.js +17 -17
- package/lib/actions/relation.d.ts +1 -1
- package/lib/actions/relation.js +2 -2
- package/lib/base-app-domain/ActionDefDict.d.ts +5 -5
- package/lib/base-app-domain/ActionDefDict.js +7 -7
- package/lib/base-app-domain/EntityDict.d.ts +12 -12
- package/lib/base-app-domain/EntityDict.js +2 -2
- package/lib/base-app-domain/Modi/Action.d.ts +10 -10
- package/lib/base-app-domain/Modi/Action.js +14 -14
- package/lib/base-app-domain/Modi/Schema.d.ts +161 -161
- package/lib/base-app-domain/Modi/Schema.js +2 -2
- package/lib/base-app-domain/Modi/Storage.d.ts +3 -3
- package/lib/base-app-domain/Modi/Storage.js +60 -60
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +176 -176
- package/lib/base-app-domain/ModiEntity/Schema.js +2 -2
- package/lib/base-app-domain/ModiEntity/Storage.d.ts +3 -3
- package/lib/base-app-domain/ModiEntity/Storage.js +26 -26
- package/lib/base-app-domain/Oper/Schema.d.ts +158 -158
- package/lib/base-app-domain/Oper/Schema.js +2 -2
- package/lib/base-app-domain/Oper/Storage.d.ts +3 -3
- package/lib/base-app-domain/Oper/Storage.js +29 -29
- package/lib/base-app-domain/OperEntity/Schema.d.ts +193 -193
- package/lib/base-app-domain/OperEntity/Schema.js +2 -2
- package/lib/base-app-domain/OperEntity/Storage.d.ts +3 -3
- package/lib/base-app-domain/OperEntity/Storage.js +26 -26
- package/lib/base-app-domain/Storage.d.ts +3 -3
- package/lib/base-app-domain/Storage.js +15 -15
- package/lib/base-app-domain/User/Schema.d.ts +137 -137
- package/lib/base-app-domain/User/Schema.js +2 -2
- package/lib/base-app-domain/User/Storage.d.ts +3 -3
- package/lib/base-app-domain/User/Storage.js +25 -25
- package/lib/base-app-domain/_SubQuery.d.ts +36 -36
- package/lib/base-app-domain/_SubQuery.js +2 -2
- package/lib/base-app-domain/index.d.ts +3 -3
- package/lib/base-app-domain/index.js +6 -6
- package/lib/checkers/index.d.ts +5 -5
- package/lib/checkers/index.js +8 -8
- package/lib/compiler/env.d.ts +11 -11
- package/lib/compiler/env.js +39 -39
- package/lib/compiler/schemalBuilder.d.ts +2 -2
- package/lib/compiler/schemalBuilder.js +3137 -3137
- package/lib/compiler/uiBuilder.d.ts +1 -1
- package/lib/compiler/uiBuilder.js +3 -3
- package/lib/entities/Modi.d.ts +11 -11
- package/lib/entities/Modi.js +46 -46
- package/lib/entities/ModiEntity.d.ts +8 -8
- package/lib/entities/ModiEntity.js +15 -15
- package/lib/entities/Oper.d.ts +10 -10
- package/lib/entities/Oper.js +17 -17
- package/lib/entities/OperEntity.d.ts +8 -8
- package/lib/entities/OperEntity.js +15 -15
- package/lib/entities/User.d.ts +7 -7
- package/lib/entities/User.js +12 -12
- package/lib/store/AsyncRowStore.d.ts +45 -45
- package/lib/store/AsyncRowStore.js +180 -180
- package/lib/store/CascadeStore.d.ts +89 -89
- package/lib/store/CascadeStore.js +1515 -1511
- package/lib/store/SyncRowStore.d.ts +26 -26
- package/lib/store/SyncRowStore.js +45 -45
- package/lib/store/TriggerExecutor.d.ts +32 -32
- package/lib/store/TriggerExecutor.js +470 -470
- package/lib/store/actionDef.d.ts +9 -9
- package/lib/store/actionDef.js +135 -135
- package/lib/store/checker.d.ts +6 -6
- package/lib/store/checker.js +218 -165
- package/lib/store/filter.d.ts +99 -99
- package/lib/store/filter.js +855 -855
- package/lib/store/modi.d.ts +13 -13
- package/lib/store/modi.js +172 -172
- package/lib/store/relation.d.ts +13 -13
- package/lib/store/relation.js +64 -64
- package/lib/store/selection.d.ts +7 -7
- package/lib/store/selection.js +228 -228
- package/lib/triggers/index.d.ts +6 -6
- package/lib/triggers/index.js +11 -11
- package/lib/triggers/modi.d.ts +5 -5
- package/lib/triggers/modi.js +72 -72
- package/lib/types/Action.d.ts +14 -14
- package/lib/types/Action.js +2 -2
- package/lib/types/AppLoader.d.ts +11 -11
- package/lib/types/AppLoader.js +10 -10
- package/lib/types/Aspect.d.ts +12 -12
- package/lib/types/Aspect.js +4 -4
- package/lib/types/Auth.d.ts +57 -31
- package/lib/types/Auth.js +2 -2
- package/lib/types/Connector.d.ts +26 -26
- package/lib/types/Connector.js +9 -9
- package/lib/types/Context.d.ts +6 -6
- package/lib/types/Context.js +3 -3
- package/lib/types/DataType.d.ts +18 -18
- package/lib/types/DataType.js +5 -5
- package/lib/types/Demand.d.ts +77 -77
- package/lib/types/Demand.js +9 -9
- package/lib/types/Entity.d.ts +159 -159
- package/lib/types/Entity.js +15 -15
- package/lib/types/Exception.d.ts +83 -83
- package/lib/types/Exception.js +252 -252
- package/lib/types/Expression.d.ts +141 -141
- package/lib/types/Expression.js +387 -387
- package/lib/types/Geo.d.ts +18 -18
- package/lib/types/Geo.js +2 -2
- package/lib/types/Locale.d.ts +24 -24
- package/lib/types/Locale.js +2 -2
- package/lib/types/Logger.d.ts +5 -5
- package/lib/types/Logger.js +3 -3
- package/lib/types/Polyfill.d.ts +23 -23
- package/lib/types/Polyfill.js +2 -2
- package/lib/types/RowStore.d.ts +12 -12
- package/lib/types/RowStore.js +34 -34
- package/lib/types/Storage.d.ts +55 -55
- package/lib/types/Storage.js +2 -2
- package/lib/types/Trigger.d.ts +88 -89
- package/lib/types/Trigger.js +39 -39
- package/lib/types/Txn.d.ts +2 -2
- package/lib/types/Txn.js +3 -3
- package/lib/types/Watcher.d.ts +19 -19
- package/lib/types/Watcher.js +4 -4
- package/lib/types/index.d.ts +18 -18
- package/lib/types/index.js +21 -21
- package/lib/types/schema/DataTypes.d.ts +32 -32
- package/lib/types/schema/DataTypes.js +3 -3
- package/lib/utils/SimpleConnector.d.ts +30 -30
- package/lib/utils/SimpleConnector.js +102 -102
- package/lib/utils/assert.d.ts +5 -5
- package/lib/utils/assert.js +9 -9
- package/lib/utils/concurrent.d.ts +15 -15
- package/lib/utils/concurrent.js +89 -89
- package/lib/utils/geo.d.ts +4 -4
- package/lib/utils/geo.js +24 -24
- package/lib/utils/lodash.d.ts +5 -5
- package/lib/utils/lodash.js +38 -38
- package/lib/utils/random/random.d.ts +1 -1
- package/lib/utils/random/random.js +24 -24
- package/lib/utils/random/random.mp.d.ts +1 -1
- package/lib/utils/random/random.mp.js +25 -25
- package/lib/utils/random/random.web.d.ts +1 -1
- package/lib/utils/random/random.web.js +17 -17
- package/lib/utils/string.d.ts +22 -22
- package/lib/utils/string.js +70 -70
- package/lib/utils/uuid.d.ts +12 -12
- package/lib/utils/uuid.js +182 -182
- package/lib/utils/validator.d.ts +23 -23
- package/lib/utils/validator.js +123 -123
- package/package.json +47 -47
- package/src/entities/Modi.ts +68 -68
- package/src/entities/ModiEntity.ts +24 -24
- package/src/entities/Oper.ts +28 -28
- package/src/entities/OperEntity.ts +24 -24
- package/src/entities/User.ts +19 -19
package/lib/store/selection.js
CHANGED
|
@@ -1,228 +1,228 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reinforceSelection = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
-
var types_1 = require("../types");
|
|
7
|
-
var Demand_1 = require("../types/Demand");
|
|
8
|
-
var filter_1 = require("./filter");
|
|
9
|
-
var relation_1 = require("./relation");
|
|
10
|
-
/**
|
|
11
|
-
* 对selection进行一些完善,避免编程人员的疏漏
|
|
12
|
-
* @param selection
|
|
13
|
-
*/
|
|
14
|
-
function reinforceSelection(schema, entity, selection) {
|
|
15
|
-
var filter = selection.filter, data = selection.data, sorter = selection.sorter;
|
|
16
|
-
var checkNode = function (projectionNode, attrs) {
|
|
17
|
-
attrs.forEach(function (attr) {
|
|
18
|
-
var _a;
|
|
19
|
-
if (!projectionNode.hasOwnProperty(attr)) {
|
|
20
|
-
Object.assign(projectionNode, (_a = {},
|
|
21
|
-
_a[attr] = 1,
|
|
22
|
-
_a));
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var relevantIds = [];
|
|
27
|
-
if (filter) {
|
|
28
|
-
var toBeAssignNode_1 = {}; // 用来记录在表达式中涉及到的结点
|
|
29
|
-
// filter当中所关联到的属性必须在projection中
|
|
30
|
-
var filterNodeDict_1 = {};
|
|
31
|
-
var checkFilterNode_1 = function (entity2, filterNode, projectionNode) {
|
|
32
|
-
var _a, e_1, _b, _c, _d, _e, _f;
|
|
33
|
-
var necessaryAttrs = ['id'];
|
|
34
|
-
for (var attr in filterNode) {
|
|
35
|
-
if (attr === '#id') {
|
|
36
|
-
(0, assert_1.default)(!filterNodeDict_1[filterNode[attr]], "projection\u4E2D\u7ED3\u70B9\u7684id\u6709\u91CD\u590D, ".concat(filterNode[attr]));
|
|
37
|
-
Object.assign(filterNodeDict_1, (_a = {},
|
|
38
|
-
_a[filterNode[attr]] = projectionNode,
|
|
39
|
-
_a));
|
|
40
|
-
if (toBeAssignNode_1[filterNode[attr]]) {
|
|
41
|
-
checkNode(projectionNode, toBeAssignNode_1[filterNode[attr]]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else if (['$and', '$or'].includes(attr)) {
|
|
45
|
-
try {
|
|
46
|
-
for (var _g = (e_1 = void 0, tslib_1.__values(filterNode[attr])), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
47
|
-
var node = _h.value;
|
|
48
|
-
checkFilterNode_1(entity2, node, projectionNode);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
52
|
-
finally {
|
|
53
|
-
try {
|
|
54
|
-
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
55
|
-
}
|
|
56
|
-
finally { if (e_1) throw e_1.error; }
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else if (attr === '$not') {
|
|
60
|
-
checkFilterNode_1(entity2, filterNode[attr], projectionNode);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
if (attr.toLowerCase().startsWith(Demand_1.EXPRESSION_PREFIX)) {
|
|
64
|
-
var exprResult = (0, types_1.getAttrRefInExpression)(filterNode[attr]);
|
|
65
|
-
for (var nodeName in exprResult) {
|
|
66
|
-
if (nodeName === '#current') {
|
|
67
|
-
checkNode(projectionNode, exprResult[nodeName]);
|
|
68
|
-
}
|
|
69
|
-
else if (filterNodeDict_1[nodeName]) {
|
|
70
|
-
checkNode(filterNodeDict_1[nodeName], exprResult[nodeName]);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
if (toBeAssignNode_1[nodeName]) {
|
|
74
|
-
(_c = toBeAssignNode_1[nodeName]).push.apply(_c, tslib_1.__spreadArray([], tslib_1.__read(exprResult[nodeName]), false));
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
Object.assign(toBeAssignNode_1, (_d = {},
|
|
78
|
-
_d[nodeName] = exprResult[nodeName],
|
|
79
|
-
_d));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
var rel = (0, relation_1.judgeRelation)(schema, entity2, attr);
|
|
86
|
-
if (rel === 1) {
|
|
87
|
-
necessaryAttrs.push(attr);
|
|
88
|
-
}
|
|
89
|
-
else if (rel === 2) {
|
|
90
|
-
// entity/entityId反指
|
|
91
|
-
necessaryAttrs.push('entity', 'entityId');
|
|
92
|
-
if (!projectionNode[attr]) {
|
|
93
|
-
Object.assign(projectionNode, (_e = {},
|
|
94
|
-
_e[attr] = {
|
|
95
|
-
id: 1,
|
|
96
|
-
},
|
|
97
|
-
_e));
|
|
98
|
-
}
|
|
99
|
-
checkFilterNode_1(attr, filterNode[attr], projectionNode[attr]);
|
|
100
|
-
}
|
|
101
|
-
else if (typeof rel === 'string') {
|
|
102
|
-
necessaryAttrs.push("".concat(attr, "Id"));
|
|
103
|
-
if (!projectionNode[attr]) {
|
|
104
|
-
Object.assign(projectionNode, (_f = {},
|
|
105
|
-
_f[attr] = {
|
|
106
|
-
id: 1,
|
|
107
|
-
},
|
|
108
|
-
_f));
|
|
109
|
-
}
|
|
110
|
-
checkFilterNode_1(rel, filterNode[attr], projectionNode[attr]);
|
|
111
|
-
}
|
|
112
|
-
else if (rel instanceof Array) {
|
|
113
|
-
// 现在filter中还不支持一对多的语义,先放着吧
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
checkNode(projectionNode, necessaryAttrs);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
checkFilterNode_1(entity, filter, data);
|
|
121
|
-
relevantIds = (0, filter_1.getRelevantIds)(filter);
|
|
122
|
-
}
|
|
123
|
-
// sorter感觉现在取不取影响不大,前端的list直接获取返回的ids了,先不管之
|
|
124
|
-
if (sorter) {
|
|
125
|
-
}
|
|
126
|
-
var toBeAssignNode2 = {}; // 用来记录在表达式中涉及到的结点
|
|
127
|
-
var projectionNodeDict = {};
|
|
128
|
-
var checkProjectionNode = function (entity2, projectionNode) {
|
|
129
|
-
var _a, _b, _c;
|
|
130
|
-
var necessaryAttrs = ['id'];
|
|
131
|
-
for (var attr in projectionNode) {
|
|
132
|
-
if (attr === '#id') {
|
|
133
|
-
(0, assert_1.default)(!projectionNodeDict[projectionNode[attr]], "projection\u4E2D\u7ED3\u70B9\u7684id\u6709\u91CD\u590D, ".concat(projectionNode[attr]));
|
|
134
|
-
Object.assign(projectionNodeDict, (_a = {},
|
|
135
|
-
_a[projectionNode[attr]] = projectionNode,
|
|
136
|
-
_a));
|
|
137
|
-
if (toBeAssignNode2[projectionNode[attr]]) {
|
|
138
|
-
checkNode(projectionNode, toBeAssignNode2[projectionNode[attr]]);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
if (attr.toLowerCase().startsWith(Demand_1.EXPRESSION_PREFIX)) {
|
|
143
|
-
var exprResult = (0, types_1.getAttrRefInExpression)(projectionNode[attr]);
|
|
144
|
-
for (var nodeName in exprResult) {
|
|
145
|
-
if (nodeName === '#current') {
|
|
146
|
-
checkNode(projectionNode, exprResult[nodeName]);
|
|
147
|
-
}
|
|
148
|
-
else if (projectionNodeDict[nodeName]) {
|
|
149
|
-
checkNode(projectionNodeDict[nodeName], exprResult[nodeName]);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
if (toBeAssignNode2[nodeName]) {
|
|
153
|
-
(_b = toBeAssignNode2[nodeName]).push.apply(_b, tslib_1.__spreadArray([], tslib_1.__read(exprResult[nodeName]), false));
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
Object.assign(toBeAssignNode2, (_c = {},
|
|
157
|
-
_c[nodeName] = exprResult[nodeName],
|
|
158
|
-
_c));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
var rel = (0, relation_1.judgeRelation)(schema, entity2, attr);
|
|
165
|
-
if (rel === 1) {
|
|
166
|
-
necessaryAttrs.push(attr);
|
|
167
|
-
}
|
|
168
|
-
else if (rel === 2) {
|
|
169
|
-
// entity/entityId反指
|
|
170
|
-
necessaryAttrs.push('entity', 'entityId');
|
|
171
|
-
checkProjectionNode(attr, projectionNode[attr]);
|
|
172
|
-
}
|
|
173
|
-
else if (typeof rel === 'string') {
|
|
174
|
-
necessaryAttrs.push("".concat(attr, "Id"));
|
|
175
|
-
checkProjectionNode(rel, projectionNode[attr]);
|
|
176
|
-
}
|
|
177
|
-
else if (rel instanceof Array) {
|
|
178
|
-
var data_1 = projectionNode[attr].data;
|
|
179
|
-
if (rel[1]) {
|
|
180
|
-
checkNode(data_1, [rel[1]]);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
checkNode(data_1, ['entity', 'entityId']);
|
|
184
|
-
}
|
|
185
|
-
checkProjectionNode(rel[0], data_1);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
checkNode(projectionNode, necessaryAttrs);
|
|
190
|
-
}
|
|
191
|
-
// 如果对象中指向一对多的Modi,此时加上指向Modi的projection
|
|
192
|
-
if (schema[entity2].toModi) {
|
|
193
|
-
Object.assign(projectionNode, {
|
|
194
|
-
modi$entity: {
|
|
195
|
-
$entity: 'modi',
|
|
196
|
-
data: {
|
|
197
|
-
id: 1,
|
|
198
|
-
targetEntity: 1,
|
|
199
|
-
entity: 1,
|
|
200
|
-
entityId: 1,
|
|
201
|
-
action: 1,
|
|
202
|
-
iState: 1,
|
|
203
|
-
data: 1,
|
|
204
|
-
filter: 1,
|
|
205
|
-
},
|
|
206
|
-
filter: {
|
|
207
|
-
iState: 'active',
|
|
208
|
-
},
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
checkProjectionNode(entity, data);
|
|
214
|
-
if (!sorter && relevantIds.length === 0) {
|
|
215
|
-
// 如果没有sorter,就给予一个按createAt逆序的sorter
|
|
216
|
-
Object.assign(selection, {
|
|
217
|
-
sorter: [
|
|
218
|
-
{
|
|
219
|
-
$attr: {
|
|
220
|
-
$$createAt$$: 1,
|
|
221
|
-
},
|
|
222
|
-
$direction: 'desc',
|
|
223
|
-
}
|
|
224
|
-
]
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
exports.reinforceSelection = reinforceSelection;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reinforceSelection = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
var types_1 = require("../types");
|
|
7
|
+
var Demand_1 = require("../types/Demand");
|
|
8
|
+
var filter_1 = require("./filter");
|
|
9
|
+
var relation_1 = require("./relation");
|
|
10
|
+
/**
|
|
11
|
+
* 对selection进行一些完善,避免编程人员的疏漏
|
|
12
|
+
* @param selection
|
|
13
|
+
*/
|
|
14
|
+
function reinforceSelection(schema, entity, selection) {
|
|
15
|
+
var filter = selection.filter, data = selection.data, sorter = selection.sorter;
|
|
16
|
+
var checkNode = function (projectionNode, attrs) {
|
|
17
|
+
attrs.forEach(function (attr) {
|
|
18
|
+
var _a;
|
|
19
|
+
if (!projectionNode.hasOwnProperty(attr)) {
|
|
20
|
+
Object.assign(projectionNode, (_a = {},
|
|
21
|
+
_a[attr] = 1,
|
|
22
|
+
_a));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var relevantIds = [];
|
|
27
|
+
if (filter) {
|
|
28
|
+
var toBeAssignNode_1 = {}; // 用来记录在表达式中涉及到的结点
|
|
29
|
+
// filter当中所关联到的属性必须在projection中
|
|
30
|
+
var filterNodeDict_1 = {};
|
|
31
|
+
var checkFilterNode_1 = function (entity2, filterNode, projectionNode) {
|
|
32
|
+
var _a, e_1, _b, _c, _d, _e, _f;
|
|
33
|
+
var necessaryAttrs = ['id'];
|
|
34
|
+
for (var attr in filterNode) {
|
|
35
|
+
if (attr === '#id') {
|
|
36
|
+
(0, assert_1.default)(!filterNodeDict_1[filterNode[attr]], "projection\u4E2D\u7ED3\u70B9\u7684id\u6709\u91CD\u590D, ".concat(filterNode[attr]));
|
|
37
|
+
Object.assign(filterNodeDict_1, (_a = {},
|
|
38
|
+
_a[filterNode[attr]] = projectionNode,
|
|
39
|
+
_a));
|
|
40
|
+
if (toBeAssignNode_1[filterNode[attr]]) {
|
|
41
|
+
checkNode(projectionNode, toBeAssignNode_1[filterNode[attr]]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (['$and', '$or'].includes(attr)) {
|
|
45
|
+
try {
|
|
46
|
+
for (var _g = (e_1 = void 0, tslib_1.__values(filterNode[attr])), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
47
|
+
var node = _h.value;
|
|
48
|
+
checkFilterNode_1(entity2, node, projectionNode);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
52
|
+
finally {
|
|
53
|
+
try {
|
|
54
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
55
|
+
}
|
|
56
|
+
finally { if (e_1) throw e_1.error; }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (attr === '$not') {
|
|
60
|
+
checkFilterNode_1(entity2, filterNode[attr], projectionNode);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if (attr.toLowerCase().startsWith(Demand_1.EXPRESSION_PREFIX)) {
|
|
64
|
+
var exprResult = (0, types_1.getAttrRefInExpression)(filterNode[attr]);
|
|
65
|
+
for (var nodeName in exprResult) {
|
|
66
|
+
if (nodeName === '#current') {
|
|
67
|
+
checkNode(projectionNode, exprResult[nodeName]);
|
|
68
|
+
}
|
|
69
|
+
else if (filterNodeDict_1[nodeName]) {
|
|
70
|
+
checkNode(filterNodeDict_1[nodeName], exprResult[nodeName]);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if (toBeAssignNode_1[nodeName]) {
|
|
74
|
+
(_c = toBeAssignNode_1[nodeName]).push.apply(_c, tslib_1.__spreadArray([], tslib_1.__read(exprResult[nodeName]), false));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
Object.assign(toBeAssignNode_1, (_d = {},
|
|
78
|
+
_d[nodeName] = exprResult[nodeName],
|
|
79
|
+
_d));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
var rel = (0, relation_1.judgeRelation)(schema, entity2, attr);
|
|
86
|
+
if (rel === 1) {
|
|
87
|
+
necessaryAttrs.push(attr);
|
|
88
|
+
}
|
|
89
|
+
else if (rel === 2) {
|
|
90
|
+
// entity/entityId反指
|
|
91
|
+
necessaryAttrs.push('entity', 'entityId');
|
|
92
|
+
if (!projectionNode[attr]) {
|
|
93
|
+
Object.assign(projectionNode, (_e = {},
|
|
94
|
+
_e[attr] = {
|
|
95
|
+
id: 1,
|
|
96
|
+
},
|
|
97
|
+
_e));
|
|
98
|
+
}
|
|
99
|
+
checkFilterNode_1(attr, filterNode[attr], projectionNode[attr]);
|
|
100
|
+
}
|
|
101
|
+
else if (typeof rel === 'string') {
|
|
102
|
+
necessaryAttrs.push("".concat(attr, "Id"));
|
|
103
|
+
if (!projectionNode[attr]) {
|
|
104
|
+
Object.assign(projectionNode, (_f = {},
|
|
105
|
+
_f[attr] = {
|
|
106
|
+
id: 1,
|
|
107
|
+
},
|
|
108
|
+
_f));
|
|
109
|
+
}
|
|
110
|
+
checkFilterNode_1(rel, filterNode[attr], projectionNode[attr]);
|
|
111
|
+
}
|
|
112
|
+
else if (rel instanceof Array) {
|
|
113
|
+
// 现在filter中还不支持一对多的语义,先放着吧
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
checkNode(projectionNode, necessaryAttrs);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
checkFilterNode_1(entity, filter, data);
|
|
121
|
+
relevantIds = (0, filter_1.getRelevantIds)(filter);
|
|
122
|
+
}
|
|
123
|
+
// sorter感觉现在取不取影响不大,前端的list直接获取返回的ids了,先不管之
|
|
124
|
+
if (sorter) {
|
|
125
|
+
}
|
|
126
|
+
var toBeAssignNode2 = {}; // 用来记录在表达式中涉及到的结点
|
|
127
|
+
var projectionNodeDict = {};
|
|
128
|
+
var checkProjectionNode = function (entity2, projectionNode) {
|
|
129
|
+
var _a, _b, _c;
|
|
130
|
+
var necessaryAttrs = ['id'];
|
|
131
|
+
for (var attr in projectionNode) {
|
|
132
|
+
if (attr === '#id') {
|
|
133
|
+
(0, assert_1.default)(!projectionNodeDict[projectionNode[attr]], "projection\u4E2D\u7ED3\u70B9\u7684id\u6709\u91CD\u590D, ".concat(projectionNode[attr]));
|
|
134
|
+
Object.assign(projectionNodeDict, (_a = {},
|
|
135
|
+
_a[projectionNode[attr]] = projectionNode,
|
|
136
|
+
_a));
|
|
137
|
+
if (toBeAssignNode2[projectionNode[attr]]) {
|
|
138
|
+
checkNode(projectionNode, toBeAssignNode2[projectionNode[attr]]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
if (attr.toLowerCase().startsWith(Demand_1.EXPRESSION_PREFIX)) {
|
|
143
|
+
var exprResult = (0, types_1.getAttrRefInExpression)(projectionNode[attr]);
|
|
144
|
+
for (var nodeName in exprResult) {
|
|
145
|
+
if (nodeName === '#current') {
|
|
146
|
+
checkNode(projectionNode, exprResult[nodeName]);
|
|
147
|
+
}
|
|
148
|
+
else if (projectionNodeDict[nodeName]) {
|
|
149
|
+
checkNode(projectionNodeDict[nodeName], exprResult[nodeName]);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
if (toBeAssignNode2[nodeName]) {
|
|
153
|
+
(_b = toBeAssignNode2[nodeName]).push.apply(_b, tslib_1.__spreadArray([], tslib_1.__read(exprResult[nodeName]), false));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
Object.assign(toBeAssignNode2, (_c = {},
|
|
157
|
+
_c[nodeName] = exprResult[nodeName],
|
|
158
|
+
_c));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
var rel = (0, relation_1.judgeRelation)(schema, entity2, attr);
|
|
165
|
+
if (rel === 1) {
|
|
166
|
+
necessaryAttrs.push(attr);
|
|
167
|
+
}
|
|
168
|
+
else if (rel === 2) {
|
|
169
|
+
// entity/entityId反指
|
|
170
|
+
necessaryAttrs.push('entity', 'entityId');
|
|
171
|
+
checkProjectionNode(attr, projectionNode[attr]);
|
|
172
|
+
}
|
|
173
|
+
else if (typeof rel === 'string') {
|
|
174
|
+
necessaryAttrs.push("".concat(attr, "Id"));
|
|
175
|
+
checkProjectionNode(rel, projectionNode[attr]);
|
|
176
|
+
}
|
|
177
|
+
else if (rel instanceof Array) {
|
|
178
|
+
var data_1 = projectionNode[attr].data;
|
|
179
|
+
if (rel[1]) {
|
|
180
|
+
checkNode(data_1, [rel[1]]);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
checkNode(data_1, ['entity', 'entityId']);
|
|
184
|
+
}
|
|
185
|
+
checkProjectionNode(rel[0], data_1);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
checkNode(projectionNode, necessaryAttrs);
|
|
190
|
+
}
|
|
191
|
+
// 如果对象中指向一对多的Modi,此时加上指向Modi的projection
|
|
192
|
+
if (schema[entity2].toModi) {
|
|
193
|
+
Object.assign(projectionNode, {
|
|
194
|
+
modi$entity: {
|
|
195
|
+
$entity: 'modi',
|
|
196
|
+
data: {
|
|
197
|
+
id: 1,
|
|
198
|
+
targetEntity: 1,
|
|
199
|
+
entity: 1,
|
|
200
|
+
entityId: 1,
|
|
201
|
+
action: 1,
|
|
202
|
+
iState: 1,
|
|
203
|
+
data: 1,
|
|
204
|
+
filter: 1,
|
|
205
|
+
},
|
|
206
|
+
filter: {
|
|
207
|
+
iState: 'active',
|
|
208
|
+
},
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
checkProjectionNode(entity, data);
|
|
214
|
+
if (!sorter && relevantIds.length === 0) {
|
|
215
|
+
// 如果没有sorter,就给予一个按createAt逆序的sorter
|
|
216
|
+
Object.assign(selection, {
|
|
217
|
+
sorter: [
|
|
218
|
+
{
|
|
219
|
+
$attr: {
|
|
220
|
+
$$createAt$$: 1,
|
|
221
|
+
},
|
|
222
|
+
$direction: 'desc',
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
exports.reinforceSelection = reinforceSelection;
|
package/lib/triggers/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
2
|
-
import { StorageSchema, EntityDict } from '../types';
|
|
3
|
-
import { AsyncContext } from '../store/AsyncRowStore';
|
|
4
|
-
declare const _default: import("../types").Trigger<BaseEntityDict, "modi", AsyncContext<BaseEntityDict>>[];
|
|
5
|
-
export default _default;
|
|
6
|
-
export declare function createDynamicTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(schema: StorageSchema<ED>): import("../types").Trigger<ED, keyof ED, Cxt>[];
|
|
1
|
+
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
2
|
+
import { StorageSchema, EntityDict } from '../types';
|
|
3
|
+
import { AsyncContext } from '../store/AsyncRowStore';
|
|
4
|
+
declare const _default: import("../types").Trigger<BaseEntityDict, "modi", AsyncContext<BaseEntityDict>>[];
|
|
5
|
+
export default _default;
|
|
6
|
+
export declare function createDynamicTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(schema: StorageSchema<ED>): import("../types").Trigger<ED, keyof ED, Cxt>[];
|
package/lib/triggers/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDynamicTriggers = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var modi_1 = tslib_1.__importDefault(require("./modi"));
|
|
6
|
-
var modi_2 = require("../store/modi");
|
|
7
|
-
exports.default = tslib_1.__spreadArray([], tslib_1.__read(modi_1.default), false);
|
|
8
|
-
function createDynamicTriggers(schema) {
|
|
9
|
-
return (0, modi_2.createModiRelatedTriggers)(schema);
|
|
10
|
-
}
|
|
11
|
-
exports.createDynamicTriggers = createDynamicTriggers;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDynamicTriggers = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var modi_1 = tslib_1.__importDefault(require("./modi"));
|
|
6
|
+
var modi_2 = require("../store/modi");
|
|
7
|
+
exports.default = tslib_1.__spreadArray([], tslib_1.__read(modi_1.default), false);
|
|
8
|
+
function createDynamicTriggers(schema) {
|
|
9
|
+
return (0, modi_2.createModiRelatedTriggers)(schema);
|
|
10
|
+
}
|
|
11
|
+
exports.createDynamicTriggers = createDynamicTriggers;
|
package/lib/triggers/modi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
+
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;
|
package/lib/triggers/modi.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
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;
|
|
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;
|