oak-domain 2.5.2 → 2.6.2
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 +5 -5
- package/lib/actions/relation.js +38 -38
- package/lib/base-app-domain/ActionDefDict.d.ts +8 -8
- package/lib/base-app-domain/ActionDefDict.js +9 -9
- package/lib/base-app-domain/EntityDict.d.ts +14 -14
- 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 +146 -146
- 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 +189 -189
- 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 +27 -27
- package/lib/base-app-domain/Oper/Schema.d.ts +144 -144
- 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 +205 -205
- 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 +27 -27
- package/lib/base-app-domain/Storage.d.ts +3 -3
- package/lib/base-app-domain/Storage.js +17 -17
- package/lib/base-app-domain/User/Action.d.ts +10 -10
- package/lib/base-app-domain/User/Action.js +12 -12
- package/lib/base-app-domain/User/Schema.d.ts +180 -180
- 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 +36 -36
- package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +121 -121
- package/lib/base-app-domain/UserEntityGrant/Schema.js +2 -2
- package/lib/base-app-domain/UserEntityGrant/Storage.d.ts +3 -3
- package/lib/base-app-domain/UserEntityGrant/Storage.js +28 -28
- package/lib/base-app-domain/_SubQuery.d.ts +44 -44
- 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 +16 -16
- 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 +3355 -3355
- 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 +8 -8
- package/lib/entities/User.js +28 -28
- package/lib/entities/UserEntityGrant.d.ts +7 -7
- package/lib/entities/UserEntityGrant.js +12 -12
- package/lib/store/AsyncRowStore.d.ts +51 -48
- package/lib/store/AsyncRowStore.js +189 -183
- package/lib/store/CascadeStore.d.ts +91 -91
- package/lib/store/CascadeStore.js +1634 -1603
- package/lib/store/SyncRowStore.d.ts +29 -29
- package/lib/store/SyncRowStore.js +48 -48
- package/lib/store/TriggerExecutor.d.ts +32 -32
- package/lib/store/TriggerExecutor.js +532 -532
- package/lib/store/actionDef.d.ts +9 -9
- package/lib/store/actionDef.js +333 -333
- package/lib/store/checker.d.ts +26 -26
- package/lib/store/checker.js +829 -867
- package/lib/store/filter.d.ts +109 -109
- package/lib/store/filter.js +893 -893
- package/lib/store/modi.d.ts +13 -13
- package/lib/store/modi.js +216 -216
- package/lib/store/relation.d.ts +13 -13
- package/lib/store/relation.js +66 -66
- package/lib/store/selection.d.ts +19 -7
- package/lib/store/selection.js +265 -238
- 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 +20 -20
- 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 +13 -12
- package/lib/types/Aspect.js +4 -4
- package/lib/types/Auth.d.ts +69 -69
- package/lib/types/Auth.js +2 -2
- package/lib/types/Connector.d.ts +27 -26
- package/lib/types/Connector.js +9 -9
- package/lib/types/Context.d.ts +7 -7
- 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/Endpoint.d.ts +11 -11
- package/lib/types/Endpoint.js +3 -3
- package/lib/types/Entity.d.ts +183 -183
- package/lib/types/Entity.js +14 -14
- package/lib/types/Exception.d.ts +100 -98
- package/lib/types/Exception.js +327 -283
- package/lib/types/Expression.d.ts +163 -163
- package/lib/types/Expression.js +427 -427
- 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/Port.d.ts +17 -17
- package/lib/types/Port.js +2 -2
- package/lib/types/RowStore.d.ts +12 -12
- package/lib/types/RowStore.js +34 -34
- package/lib/types/Storage.d.ts +56 -56
- package/lib/types/Storage.js +2 -2
- package/lib/types/Timer.d.ts +13 -13
- package/lib/types/Timer.js +2 -2
- package/lib/types/Trigger.d.ts +109 -109
- package/lib/types/Trigger.js +49 -49
- 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 +21 -21
- package/lib/types/index.js +24 -24
- package/lib/types/schema/DataTypes.d.ts +32 -32
- package/lib/types/schema/DataTypes.js +3 -3
- package/lib/utils/SimpleConnector.d.ts +35 -30
- package/lib/utils/SimpleConnector.js +134 -117
- 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/cron.d.ts +1 -1
- package/lib/utils/cron.js +18 -18
- package/lib/utils/date.d.ts +1 -1
- package/lib/utils/date.js +18 -18
- package/lib/utils/geo.d.ts +4 -4
- package/lib/utils/geo.js +24 -24
- package/lib/utils/lodash.d.ts +20 -20
- package/lib/utils/lodash.js +55 -55
- 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/url.d.ts +1 -0
- package/lib/utils/url.js +12 -0
- package/lib/utils/uuid.d.ts +12 -12
- package/lib/utils/uuid.js +194 -194
- package/lib/utils/validator.d.ts +23 -23
- package/lib/utils/validator.js +123 -123
- package/package.json +48 -48
- 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 +44 -44
- package/src/entities/UserEntityGrant.ts +24 -24
package/lib/store/selection.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import { StorageSchema } from '../types';
|
|
2
|
-
import { EntityDict } from '../types/Entity';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { StorageSchema } from '../types';
|
|
2
|
+
import { EntityDict } from '../types/Entity';
|
|
3
|
+
declare type SelectionRewriter<ED extends EntityDict> = (schema: StorageSchema<ED>, entity: keyof ED, selection: ED[keyof ED]['Selection']) => void;
|
|
4
|
+
export declare function registerSelectionRewriter<ED extends EntityDict>(rewriter: SelectionRewriter<ED>): void;
|
|
5
|
+
declare type OperationRewriter<ED extends EntityDict> = (schema: StorageSchema<ED>, entity: keyof ED, operate: ED[keyof ED]['Operation']) => void;
|
|
6
|
+
export declare function registerOperationRewriter<ED extends EntityDict>(rewriter: OperationRewriter<ED>): void;
|
|
7
|
+
/**
|
|
8
|
+
* 对selection进行一些完善,避免编程人员的疏漏
|
|
9
|
+
* @param selection
|
|
10
|
+
*/
|
|
11
|
+
export declare function reinforceSelection<ED extends EntityDict>(schema: StorageSchema<ED>, entity: keyof ED, selection: ED[keyof ED]['Selection']): void;
|
|
12
|
+
/**
|
|
13
|
+
* 对operation进行一些完善,作为operation算子的注入点
|
|
14
|
+
* @param schema
|
|
15
|
+
* @param entity
|
|
16
|
+
* @param selection
|
|
17
|
+
*/
|
|
18
|
+
export declare function reinforceOperation<ED extends EntityDict>(schema: StorageSchema<ED>, entity: keyof ED, operation: ED[keyof ED]['Operation']): void;
|
|
19
|
+
export {};
|
package/lib/store/selection.js
CHANGED
|
@@ -1,238 +1,265 @@
|
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reinforceOperation = exports.reinforceSelection = exports.registerOperationRewriter = exports.registerSelectionRewriter = 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
|
+
var SelectionRewriters = [];
|
|
11
|
+
function registerSelectionRewriter(rewriter) {
|
|
12
|
+
SelectionRewriters.push(rewriter);
|
|
13
|
+
}
|
|
14
|
+
exports.registerSelectionRewriter = registerSelectionRewriter;
|
|
15
|
+
function getSelectionRewriters() {
|
|
16
|
+
return SelectionRewriters;
|
|
17
|
+
}
|
|
18
|
+
var OperationRewriters = [];
|
|
19
|
+
function registerOperationRewriter(rewriter) {
|
|
20
|
+
OperationRewriters.push(rewriter);
|
|
21
|
+
}
|
|
22
|
+
exports.registerOperationRewriter = registerOperationRewriter;
|
|
23
|
+
function getOperationRewriters() {
|
|
24
|
+
return OperationRewriters;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 对selection进行一些完善,避免编程人员的疏漏
|
|
28
|
+
* @param selection
|
|
29
|
+
*/
|
|
30
|
+
function reinforceSelection(schema, entity, selection) {
|
|
31
|
+
var filter = selection.filter, data = selection.data, sorter = selection.sorter;
|
|
32
|
+
var checkNode = function (projectionNode, attrs) {
|
|
33
|
+
attrs.forEach(function (attr) {
|
|
34
|
+
var _a;
|
|
35
|
+
if (!projectionNode.hasOwnProperty(attr)) {
|
|
36
|
+
Object.assign(projectionNode, (_a = {},
|
|
37
|
+
_a[attr] = 1,
|
|
38
|
+
_a));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var relevantIds = [];
|
|
43
|
+
if (filter) {
|
|
44
|
+
var toBeAssignNode_1 = {}; // 用来记录在表达式中涉及到的结点
|
|
45
|
+
// filter当中所关联到的属性必须在projection中
|
|
46
|
+
var filterNodeDict_1 = {};
|
|
47
|
+
var checkFilterNode_1 = function (entity2, filterNode, projectionNode) {
|
|
48
|
+
var _a, e_1, _b, _c, _d, _e, _f;
|
|
49
|
+
var necessaryAttrs = ['id'];
|
|
50
|
+
for (var attr in filterNode) {
|
|
51
|
+
if (attr === '#id') {
|
|
52
|
+
(0, assert_1.default)(!filterNodeDict_1[filterNode[attr]], "projection\u4E2D\u7ED3\u70B9\u7684id\u6709\u91CD\u590D, ".concat(filterNode[attr]));
|
|
53
|
+
Object.assign(filterNodeDict_1, (_a = {},
|
|
54
|
+
_a[filterNode[attr]] = projectionNode,
|
|
55
|
+
_a));
|
|
56
|
+
if (toBeAssignNode_1[filterNode[attr]]) {
|
|
57
|
+
checkNode(projectionNode, toBeAssignNode_1[filterNode[attr]]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (['$and', '$or'].includes(attr)) {
|
|
61
|
+
try {
|
|
62
|
+
for (var _g = (e_1 = void 0, tslib_1.__values(filterNode[attr])), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
63
|
+
var node = _h.value;
|
|
64
|
+
checkFilterNode_1(entity2, node, projectionNode);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
68
|
+
finally {
|
|
69
|
+
try {
|
|
70
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
71
|
+
}
|
|
72
|
+
finally { if (e_1) throw e_1.error; }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (attr === '$not') {
|
|
76
|
+
checkFilterNode_1(entity2, filterNode[attr], projectionNode);
|
|
77
|
+
}
|
|
78
|
+
else if (attr === '$text') {
|
|
79
|
+
// 全文检索首先要有fulltext索引,其次要把fulltext的相关属性加到projection里
|
|
80
|
+
var indexes = schema[entity2].indexes;
|
|
81
|
+
var fulltextIndex = indexes.find(function (ele) { return ele.config && ele.config.type === 'fulltext'; });
|
|
82
|
+
var attributes = fulltextIndex.attributes;
|
|
83
|
+
necessaryAttrs.push.apply(necessaryAttrs, tslib_1.__spreadArray([], tslib_1.__read((attributes.map(function (ele) { return ele.name; }))), false));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
if (attr.toLowerCase().startsWith(Demand_1.EXPRESSION_PREFIX)) {
|
|
87
|
+
var exprResult = (0, types_1.getAttrRefInExpression)(filterNode[attr]);
|
|
88
|
+
for (var nodeName in exprResult) {
|
|
89
|
+
if (nodeName === '#current') {
|
|
90
|
+
checkNode(projectionNode, exprResult[nodeName]);
|
|
91
|
+
}
|
|
92
|
+
else if (filterNodeDict_1[nodeName]) {
|
|
93
|
+
checkNode(filterNodeDict_1[nodeName], exprResult[nodeName]);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (toBeAssignNode_1[nodeName]) {
|
|
97
|
+
(_c = toBeAssignNode_1[nodeName]).push.apply(_c, tslib_1.__spreadArray([], tslib_1.__read(exprResult[nodeName]), false));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
Object.assign(toBeAssignNode_1, (_d = {},
|
|
101
|
+
_d[nodeName] = exprResult[nodeName],
|
|
102
|
+
_d));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
var rel = (0, relation_1.judgeRelation)(schema, entity2, attr);
|
|
109
|
+
if (rel === 1) {
|
|
110
|
+
necessaryAttrs.push(attr);
|
|
111
|
+
}
|
|
112
|
+
else if (rel === 2) {
|
|
113
|
+
// entity/entityId反指
|
|
114
|
+
necessaryAttrs.push('entity', 'entityId');
|
|
115
|
+
if (!projectionNode[attr]) {
|
|
116
|
+
Object.assign(projectionNode, (_e = {},
|
|
117
|
+
_e[attr] = {
|
|
118
|
+
id: 1,
|
|
119
|
+
},
|
|
120
|
+
_e));
|
|
121
|
+
}
|
|
122
|
+
checkFilterNode_1(attr, filterNode[attr], projectionNode[attr]);
|
|
123
|
+
}
|
|
124
|
+
else if (typeof rel === 'string') {
|
|
125
|
+
necessaryAttrs.push("".concat(attr, "Id"));
|
|
126
|
+
if (!projectionNode[attr]) {
|
|
127
|
+
Object.assign(projectionNode, (_f = {},
|
|
128
|
+
_f[attr] = {
|
|
129
|
+
id: 1,
|
|
130
|
+
},
|
|
131
|
+
_f));
|
|
132
|
+
}
|
|
133
|
+
checkFilterNode_1(rel, filterNode[attr], projectionNode[attr]);
|
|
134
|
+
}
|
|
135
|
+
else if (rel instanceof Array) {
|
|
136
|
+
// 现在filter中还不支持一对多的语义,先放着吧
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
checkNode(projectionNode, necessaryAttrs);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
checkFilterNode_1(entity, filter, data);
|
|
144
|
+
relevantIds = (0, filter_1.getRelevantIds)(filter);
|
|
145
|
+
}
|
|
146
|
+
// sorter感觉现在取不取影响不大,前端的list直接获取返回的ids了,先不管之
|
|
147
|
+
if (sorter) {
|
|
148
|
+
}
|
|
149
|
+
var toBeAssignNode2 = {}; // 用来记录在表达式中涉及到的结点
|
|
150
|
+
var projectionNodeDict = {};
|
|
151
|
+
var checkProjectionNode = function (entity2, projectionNode) {
|
|
152
|
+
var _a, _b, _c;
|
|
153
|
+
var necessaryAttrs = ['id', '$$createAt$$']; // 有的页面依赖于其它页面取数据,有时两个页面的filter的差异会导致有一个加createAt,有一个不加,此时可能产生前台取数据不完整的异常。先统一加上
|
|
154
|
+
for (var attr in projectionNode) {
|
|
155
|
+
if (attr === '#id') {
|
|
156
|
+
(0, assert_1.default)(!projectionNodeDict[projectionNode[attr]], "projection\u4E2D\u7ED3\u70B9\u7684id\u6709\u91CD\u590D, ".concat(projectionNode[attr]));
|
|
157
|
+
Object.assign(projectionNodeDict, (_a = {},
|
|
158
|
+
_a[projectionNode[attr]] = projectionNode,
|
|
159
|
+
_a));
|
|
160
|
+
if (toBeAssignNode2[projectionNode[attr]]) {
|
|
161
|
+
checkNode(projectionNode, toBeAssignNode2[projectionNode[attr]]);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
if (attr.toLowerCase().startsWith(Demand_1.EXPRESSION_PREFIX)) {
|
|
166
|
+
var exprResult = (0, types_1.getAttrRefInExpression)(projectionNode[attr]);
|
|
167
|
+
for (var nodeName in exprResult) {
|
|
168
|
+
if (nodeName === '#current') {
|
|
169
|
+
checkNode(projectionNode, exprResult[nodeName]);
|
|
170
|
+
}
|
|
171
|
+
else if (projectionNodeDict[nodeName]) {
|
|
172
|
+
checkNode(projectionNodeDict[nodeName], exprResult[nodeName]);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
if (toBeAssignNode2[nodeName]) {
|
|
176
|
+
(_b = toBeAssignNode2[nodeName]).push.apply(_b, tslib_1.__spreadArray([], tslib_1.__read(exprResult[nodeName]), false));
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
Object.assign(toBeAssignNode2, (_c = {},
|
|
180
|
+
_c[nodeName] = exprResult[nodeName],
|
|
181
|
+
_c));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
var rel = (0, relation_1.judgeRelation)(schema, entity2, attr);
|
|
188
|
+
if (rel === 1) {
|
|
189
|
+
necessaryAttrs.push(attr);
|
|
190
|
+
}
|
|
191
|
+
else if (rel === 2) {
|
|
192
|
+
// entity/entityId反指
|
|
193
|
+
necessaryAttrs.push('entity', 'entityId');
|
|
194
|
+
checkProjectionNode(attr, projectionNode[attr]);
|
|
195
|
+
}
|
|
196
|
+
else if (typeof rel === 'string') {
|
|
197
|
+
necessaryAttrs.push("".concat(attr, "Id"));
|
|
198
|
+
checkProjectionNode(rel, projectionNode[attr]);
|
|
199
|
+
}
|
|
200
|
+
else if (rel instanceof Array && !attr.endsWith('$$aggr')) {
|
|
201
|
+
var data_1 = projectionNode[attr].data;
|
|
202
|
+
if (rel[1]) {
|
|
203
|
+
checkNode(data_1, [rel[1]]);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
checkNode(data_1, ['entity', 'entityId']);
|
|
207
|
+
}
|
|
208
|
+
reinforceSelection(schema, rel[0], projectionNode[attr]);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
checkNode(projectionNode, necessaryAttrs);
|
|
213
|
+
}
|
|
214
|
+
// 如果对象中指向一对多的Modi,此时加上指向Modi的projection
|
|
215
|
+
if (schema[entity2].toModi) {
|
|
216
|
+
Object.assign(projectionNode, {
|
|
217
|
+
modi$entity: {
|
|
218
|
+
$entity: 'modi',
|
|
219
|
+
data: {
|
|
220
|
+
id: 1,
|
|
221
|
+
targetEntity: 1,
|
|
222
|
+
entity: 1,
|
|
223
|
+
entityId: 1,
|
|
224
|
+
action: 1,
|
|
225
|
+
iState: 1,
|
|
226
|
+
data: 1,
|
|
227
|
+
filter: 1,
|
|
228
|
+
},
|
|
229
|
+
filter: {
|
|
230
|
+
iState: 'active',
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
checkProjectionNode(entity, data);
|
|
237
|
+
if (!sorter && relevantIds.length === 0) {
|
|
238
|
+
// 如果没有sorter,就给予一个按createAt逆序的sorter
|
|
239
|
+
Object.assign(selection, {
|
|
240
|
+
sorter: [
|
|
241
|
+
{
|
|
242
|
+
$attr: {
|
|
243
|
+
$$createAt$$: 1,
|
|
244
|
+
},
|
|
245
|
+
$direction: 'desc',
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
});
|
|
249
|
+
Object.assign(data, {
|
|
250
|
+
$$createAt$$: 1,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
SelectionRewriters.forEach(function (ele) { return ele(schema, entity, selection); });
|
|
254
|
+
}
|
|
255
|
+
exports.reinforceSelection = reinforceSelection;
|
|
256
|
+
/**
|
|
257
|
+
* 对operation进行一些完善,作为operation算子的注入点
|
|
258
|
+
* @param schema
|
|
259
|
+
* @param entity
|
|
260
|
+
* @param selection
|
|
261
|
+
*/
|
|
262
|
+
function reinforceOperation(schema, entity, operation) {
|
|
263
|
+
OperationRewriters.forEach(function (ele) { return ele(schema, entity, operation); });
|
|
264
|
+
}
|
|
265
|
+
exports.reinforceOperation = reinforceOperation;
|
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;
|