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.
- package/lib/actions/action.d.ts +1 -1
- package/lib/actions/action.js +2 -2
- package/lib/base-app-domain/ActionAuth/Schema.d.ts +25 -21
- package/lib/base-app-domain/ActionAuth/Storage.js +6 -13
- package/lib/base-app-domain/ActionDefDict.d.ts +1 -0
- package/lib/base-app-domain/ActionDefDict.js +3 -1
- package/lib/base-app-domain/EntityDict.d.ts +2 -0
- package/lib/base-app-domain/I18n/Schema.d.ts +129 -0
- package/lib/base-app-domain/I18n/Schema.js +2 -0
- package/lib/base-app-domain/I18n/Storage.d.ts +3 -0
- package/lib/base-app-domain/I18n/Storage.js +59 -0
- package/lib/base-app-domain/Modi/Action.d.ts +1 -1
- package/lib/base-app-domain/Modi/Schema.d.ts +10 -9
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +42 -28
- package/lib/base-app-domain/ModiEntity/Storage.js +1 -1
- package/lib/base-app-domain/Oper/Schema.d.ts +15 -13
- package/lib/base-app-domain/OperEntity/Schema.d.ts +41 -27
- package/lib/base-app-domain/OperEntity/Storage.js +1 -1
- package/lib/base-app-domain/Relation/Schema.d.ts +50 -22
- package/lib/base-app-domain/Relation/Storage.js +1 -4
- package/lib/base-app-domain/Relation.d.ts +10 -0
- package/lib/base-app-domain/Relation.js +10 -0
- package/lib/base-app-domain/RelationAuth/Schema.d.ts +67 -43
- package/lib/base-app-domain/RelationAuth/Storage.js +9 -12
- package/lib/base-app-domain/Storage.js +20 -18
- package/lib/base-app-domain/User/Action.d.ts +1 -1
- package/lib/base-app-domain/User/Schema.d.ts +20 -14
- package/lib/base-app-domain/User/Storage.js +1 -2
- package/lib/base-app-domain/UserEntityGrant/Action.d.ts +5 -0
- package/lib/base-app-domain/UserEntityGrant/Action.js +5 -0
- package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +53 -17
- package/lib/base-app-domain/UserEntityGrant/Storage.js +5 -7
- package/lib/base-app-domain/UserRelation/Schema.d.ts +35 -16
- package/lib/base-app-domain/UserRelation/Storage.js +21 -1
- package/lib/base-app-domain/_SubQuery.d.ts +40 -4
- package/lib/base-app-domain/index.d.ts +1 -0
- package/lib/base-app-domain/index.js +1 -0
- package/lib/checkers/index.d.ts +2 -2
- package/lib/checkers/index.js +2 -5
- package/lib/compiler/env.d.ts +3 -1
- package/lib/compiler/env.js +12 -2
- package/lib/compiler/localeBuilder.d.ts +22 -0
- package/lib/compiler/localeBuilder.js +169 -0
- package/lib/compiler/schemalBuilder.d.ts +9 -0
- package/lib/compiler/schemalBuilder.js +774 -362
- package/lib/entities/ActionAuth.d.ts +3 -2
- package/lib/entities/ActionAuth.js +21 -22
- package/lib/entities/I18n.d.ts +9 -0
- package/lib/entities/I18n.js +37 -0
- package/lib/entities/Modi.js +35 -33
- package/lib/entities/ModiEntity.js +12 -10
- package/lib/entities/Oper.js +15 -13
- package/lib/entities/OperEntity.js +12 -10
- package/lib/entities/Relation.d.ts +3 -3
- package/lib/entities/Relation.js +27 -25
- package/lib/entities/RelationAuth.d.ts +2 -5
- package/lib/entities/RelationAuth.js +27 -23
- package/lib/entities/User.js +20 -18
- package/lib/entities/UserEntityGrant.d.ts +2 -1
- package/lib/entities/UserEntityGrant.js +12 -7
- package/lib/entities/UserRelation.d.ts +3 -0
- package/lib/entities/UserRelation.js +30 -20
- package/lib/store/AsyncRowStore.d.ts +3 -0
- package/lib/store/AsyncRowStore.js +3 -0
- package/lib/store/CascadeStore.d.ts +9 -3
- package/lib/store/CascadeStore.js +247 -113
- package/lib/store/RelationAuth.d.ts +96 -0
- package/lib/store/RelationAuth.js +1307 -0
- package/lib/store/TriggerExecutor.d.ts +1 -2
- package/lib/store/TriggerExecutor.js +22 -22
- package/lib/store/actionAuth.d.ts +4 -0
- package/lib/store/actionAuth.js +40 -0
- package/lib/store/actionDef.d.ts +4 -3
- package/lib/store/actionDef.js +14 -10
- package/lib/store/checker.d.ts +2 -9
- package/lib/store/checker.js +39 -815
- package/lib/store/filter.d.ts +31 -18
- package/lib/store/filter.js +1256 -422
- package/lib/store/modi.d.ts +1 -1
- package/lib/store/modi.js +108 -9
- package/lib/store/relation.d.ts +3 -4
- package/lib/timers/oper.js +1 -1
- package/lib/timers/vaccum.js +2 -2
- package/lib/triggers/index.d.ts +2 -3
- package/lib/triggers/index.js +2 -5
- package/lib/types/Auth.d.ts +5 -0
- package/lib/types/DataType.d.ts +3 -0
- package/lib/types/Demand.d.ts +11 -0
- package/lib/types/Demand.js +2 -1
- package/lib/types/Entity.d.ts +10 -3
- package/lib/types/EntityDesc.d.ts +8 -0
- package/lib/types/EntityDesc.js +2 -0
- package/lib/types/Environment.d.ts +57 -0
- package/lib/types/Environment.js +2 -0
- package/lib/types/Exception.d.ts +6 -0
- package/lib/types/Exception.js +25 -1
- package/lib/types/Logger.d.ts +1 -0
- package/lib/types/RowStore.d.ts +6 -4
- package/lib/types/Style.d.ts +1 -1
- package/lib/types/Trigger.d.ts +4 -5
- package/lib/types/Trigger.js +11 -6
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/lib/utils/SimpleConnector.js +1 -1
- package/lib/utils/string.d.ts +6 -0
- package/lib/utils/string.js +13 -1
- package/lib/utils/uuid.d.ts +5 -0
- package/lib/utils/uuid.js +64 -1
- package/package.json +3 -3
- package/src/entities/ActionAuth.ts +25 -33
- package/src/entities/I18n.ts +46 -0
- package/src/entities/Modi.ts +36 -36
- package/src/entities/ModiEntity.ts +14 -13
- package/src/entities/Oper.ts +17 -16
- package/src/entities/OperEntity.ts +13 -11
- package/src/entities/Relation.ts +31 -37
- package/src/entities/RelationAuth.ts +31 -37
- package/src/entities/User.ts +24 -21
- package/src/entities/UserEntityGrant.ts +16 -14
- package/src/entities/UserRelation.ts +33 -27
- package/lib/triggers/modi.d.ts +0 -5
- package/lib/triggers/modi.js +0 -72
package/lib/store/modi.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export declare function createOperationsFromModies(modies: Modi[]): Array<{
|
|
|
10
10
|
export declare function applyModis<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, Op extends OperateOption>(filter: ED['modi']['Selection']['filter'], context: Cxt, option: Op): Promise<import("../types").OperationResult<ED>>;
|
|
11
11
|
export declare function abandonModis<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, Op extends OperateOption>(filter: ED['modi']['Selection']['filter'], context: Cxt, option: Op): Promise<import("../types").OperationResult<ED>>;
|
|
12
12
|
export declare function createModiRelatedCheckers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): RowChecker<ED, keyof ED, Cxt>[];
|
|
13
|
-
export declare function createModiRelatedTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(schema: StorageSchema<ED>): Trigger<ED, keyof ED, Cxt>[];
|
|
13
|
+
export declare function createModiRelatedTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): Trigger<ED, keyof ED, Cxt>[];
|
package/lib/store/modi.js
CHANGED
|
@@ -93,14 +93,33 @@ function createModiRelatedCheckers(schema) {
|
|
|
93
93
|
(0, assert_1.default)(modiParentEntity);
|
|
94
94
|
(0, assert_1.default)(modiParentId);
|
|
95
95
|
return {
|
|
96
|
-
|
|
96
|
+
modiEntity$entity: {
|
|
97
|
+
'#sqp': 'not in',
|
|
98
|
+
entity: entity,
|
|
99
|
+
modi: {
|
|
100
|
+
iState: 'active',
|
|
101
|
+
$or: [
|
|
102
|
+
{
|
|
103
|
+
entity: {
|
|
104
|
+
$ne: modiParentEntity,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
entityId: {
|
|
109
|
+
$ne: modiParentId,
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
/* id: {
|
|
97
116
|
$nin: {
|
|
98
117
|
entity: 'modiEntity',
|
|
99
118
|
data: {
|
|
100
119
|
entityId: 1,
|
|
101
120
|
},
|
|
102
121
|
filter: {
|
|
103
|
-
entity
|
|
122
|
+
entity,
|
|
104
123
|
modi: {
|
|
105
124
|
iState: 'active',
|
|
106
125
|
$or: [
|
|
@@ -118,24 +137,31 @@ function createModiRelatedCheckers(schema) {
|
|
|
118
137
|
},
|
|
119
138
|
},
|
|
120
139
|
},
|
|
121
|
-
}
|
|
140
|
+
} */
|
|
122
141
|
};
|
|
123
142
|
}
|
|
124
143
|
return {
|
|
125
|
-
|
|
144
|
+
modiEntity$entity: {
|
|
145
|
+
'#sqp': 'not in',
|
|
146
|
+
entity: entity,
|
|
147
|
+
modi: {
|
|
148
|
+
iState: 'active',
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
/* id: {
|
|
126
152
|
$nin: {
|
|
127
153
|
entity: 'modiEntity',
|
|
128
154
|
data: {
|
|
129
155
|
entityId: 1,
|
|
130
156
|
},
|
|
131
157
|
filter: {
|
|
132
|
-
entity
|
|
158
|
+
entity,
|
|
133
159
|
modi: {
|
|
134
160
|
iState: 'active',
|
|
135
161
|
}
|
|
136
162
|
},
|
|
137
163
|
},
|
|
138
|
-
}
|
|
164
|
+
} */
|
|
139
165
|
};
|
|
140
166
|
},
|
|
141
167
|
errMsg: '您请求的更新对象上还有正在申请的更新,请等该更新结束后再试',
|
|
@@ -159,8 +185,8 @@ function createModiRelatedTriggers(schema) {
|
|
|
159
185
|
name: "\u5F53\u5220\u9664".concat(entity, "\u5BF9\u8C61\u65F6\uFF0C\u5220\u9664\u76F8\u5173\u8054\u7684modi\u7684modiEntity"),
|
|
160
186
|
action: 'remove',
|
|
161
187
|
entity: entity,
|
|
162
|
-
when: '
|
|
163
|
-
priority: types_1.
|
|
188
|
+
when: 'before',
|
|
189
|
+
priority: types_1.TRIGGER_DEFAULT_PRIORITY,
|
|
164
190
|
fn: function (_a, context, option) {
|
|
165
191
|
var operation = _a.operation;
|
|
166
192
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -211,6 +237,79 @@ function createModiRelatedTriggers(schema) {
|
|
|
211
237
|
for (var entity in schema) {
|
|
212
238
|
_loop_2(entity);
|
|
213
239
|
}
|
|
214
|
-
|
|
240
|
+
// modi被应用时的效用,搬到这里了
|
|
241
|
+
var applyTrigger = {
|
|
242
|
+
name: '当modi被应用时,将相应的operate完成',
|
|
243
|
+
entity: 'modi',
|
|
244
|
+
action: 'apply',
|
|
245
|
+
when: 'after',
|
|
246
|
+
fn: function (_a, context, option) {
|
|
247
|
+
var operation = _a.operation;
|
|
248
|
+
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
249
|
+
var filter, modies, modies_1, modies_1_1, modi, targetEntity, id, action, data, filter_1, e_1_1;
|
|
250
|
+
var e_1, _b;
|
|
251
|
+
return tslib_1.__generator(this, function (_c) {
|
|
252
|
+
switch (_c.label) {
|
|
253
|
+
case 0:
|
|
254
|
+
filter = operation.filter;
|
|
255
|
+
return [4 /*yield*/, context.select('modi', {
|
|
256
|
+
data: {
|
|
257
|
+
id: 1,
|
|
258
|
+
action: 1,
|
|
259
|
+
data: 1,
|
|
260
|
+
filter: 1,
|
|
261
|
+
targetEntity: 1,
|
|
262
|
+
},
|
|
263
|
+
filter: filter,
|
|
264
|
+
sorter: [
|
|
265
|
+
{
|
|
266
|
+
$attr: {
|
|
267
|
+
$$createAt$$: 1,
|
|
268
|
+
},
|
|
269
|
+
$direction: 'asc',
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
}, option)];
|
|
273
|
+
case 1:
|
|
274
|
+
modies = _c.sent();
|
|
275
|
+
_c.label = 2;
|
|
276
|
+
case 2:
|
|
277
|
+
_c.trys.push([2, 7, 8, 9]);
|
|
278
|
+
modies_1 = tslib_1.__values(modies), modies_1_1 = modies_1.next();
|
|
279
|
+
_c.label = 3;
|
|
280
|
+
case 3:
|
|
281
|
+
if (!!modies_1_1.done) return [3 /*break*/, 6];
|
|
282
|
+
modi = modies_1_1.value;
|
|
283
|
+
targetEntity = modi.targetEntity, id = modi.id, action = modi.action, data = modi.data, filter_1 = modi.filter;
|
|
284
|
+
return [4 /*yield*/, context.operate(targetEntity, {
|
|
285
|
+
id: id,
|
|
286
|
+
action: action,
|
|
287
|
+
data: data,
|
|
288
|
+
filter: filter_1,
|
|
289
|
+
}, option)];
|
|
290
|
+
case 4:
|
|
291
|
+
_c.sent();
|
|
292
|
+
_c.label = 5;
|
|
293
|
+
case 5:
|
|
294
|
+
modies_1_1 = modies_1.next();
|
|
295
|
+
return [3 /*break*/, 3];
|
|
296
|
+
case 6: return [3 /*break*/, 9];
|
|
297
|
+
case 7:
|
|
298
|
+
e_1_1 = _c.sent();
|
|
299
|
+
e_1 = { error: e_1_1 };
|
|
300
|
+
return [3 /*break*/, 9];
|
|
301
|
+
case 8:
|
|
302
|
+
try {
|
|
303
|
+
if (modies_1_1 && !modies_1_1.done && (_b = modies_1.return)) _b.call(modies_1);
|
|
304
|
+
}
|
|
305
|
+
finally { if (e_1) throw e_1.error; }
|
|
306
|
+
return [7 /*endfinally*/];
|
|
307
|
+
case 9: return [2 /*return*/, modies.length];
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
return triggers.concat([applyTrigger]);
|
|
215
314
|
}
|
|
216
315
|
exports.createModiRelatedTriggers = createModiRelatedTriggers;
|
package/lib/store/relation.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EntityDict } from "../base-app-domain";
|
|
2
|
+
import { EntityDict as BaseEntityDict } from "../types/Entity";
|
|
2
3
|
import { StorageSchema } from "../types/Storage";
|
|
3
4
|
/**
|
|
4
5
|
* 判断对象和属性之间的关系
|
|
@@ -8,6 +9,4 @@ import { StorageSchema } from "../types/Storage";
|
|
|
8
9
|
* @param row
|
|
9
10
|
* @returns
|
|
10
11
|
*/
|
|
11
|
-
export declare function judgeRelation<ED extends
|
|
12
|
-
[E: string]: EntityDef;
|
|
13
|
-
}>(schema: StorageSchema<ED>, entity: keyof ED, attr: string): string | 1 | 2 | string[] | 0;
|
|
12
|
+
export declare function judgeRelation<ED extends EntityDict & BaseEntityDict>(schema: StorageSchema<ED>, entity: keyof ED, attr: string): string | 1 | 2 | string[] | 0;
|
package/lib/timers/oper.js
CHANGED
|
@@ -43,7 +43,7 @@ function vaccumOper(option, context) {
|
|
|
43
43
|
entity: 'operEntity',
|
|
44
44
|
aliveLine: aliveLine + 10000,
|
|
45
45
|
filter: {
|
|
46
|
-
oper: (0, filter_1.combineFilters)([operFilter, {
|
|
46
|
+
oper: (0, filter_1.combineFilters)('operEntity', context.getSchema(), [operFilter, {
|
|
47
47
|
$$createAt$$: {
|
|
48
48
|
$lt: aliveLine,
|
|
49
49
|
}
|
package/lib/timers/vaccum.js
CHANGED
|
@@ -34,7 +34,7 @@ function vaccumEntities(option, context) {
|
|
|
34
34
|
},
|
|
35
35
|
};
|
|
36
36
|
if (filter) {
|
|
37
|
-
filter2 = (0, filter_1.combineFilters)([filter2, filter]);
|
|
37
|
+
filter2 = (0, filter_1.combineFilters)(entity, context.getSchema(), [filter2, filter]);
|
|
38
38
|
}
|
|
39
39
|
if (!(backupDir && process.env.OAK_PLATFORM === 'server')) return [3 /*break*/, 4];
|
|
40
40
|
zip = option.zip;
|
|
@@ -65,7 +65,7 @@ function vaccumEntities(option, context) {
|
|
|
65
65
|
return tslib_1.__generator(this, function (_a) {
|
|
66
66
|
switch (_a.label) {
|
|
67
67
|
case 0:
|
|
68
|
-
filter3 = (0, filter_1.combineFilters)([filter2, {
|
|
68
|
+
filter3 = (0, filter_1.combineFilters)(entity, context.getSchema(), [filter2, {
|
|
69
69
|
$$createAt$$: {
|
|
70
70
|
$gt: minCreateAt,
|
|
71
71
|
},
|
package/lib/triggers/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
2
2
|
import { StorageSchema, EntityDict } from '../types';
|
|
3
3
|
import { AsyncContext } from '../store/AsyncRowStore';
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export declare function createDynamicTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(schema: StorageSchema<ED>): import("../types").Trigger<ED, keyof ED, Cxt>[];
|
|
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>[];
|
package/lib/triggers/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDynamicTriggers = void 0;
|
|
4
|
-
var
|
|
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);
|
|
4
|
+
var modi_1 = require("../store/modi");
|
|
8
5
|
function createDynamicTriggers(schema) {
|
|
9
|
-
return (0,
|
|
6
|
+
return (0, modi_1.createModiRelatedTriggers)(schema);
|
|
10
7
|
}
|
|
11
8
|
exports.createDynamicTriggers = createDynamicTriggers;
|
package/lib/types/Auth.d.ts
CHANGED
|
@@ -64,6 +64,11 @@ export declare type AuthDef<ED extends EntityDict, T extends keyof ED> = {
|
|
|
64
64
|
[E in (keyof ED | keyof ED[T]['Schema'] | '@entity')]?: ActionOnRemove;
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
+
export declare type CascadeRemoveDefDict<ED extends EntityDict> = {
|
|
68
|
+
[T in keyof ED]?: {
|
|
69
|
+
[E in (keyof ED | keyof ED[T]['Schema'] | '@entity')]?: ActionOnRemove;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
67
72
|
export declare type AuthDefDict<ED extends EntityDict> = {
|
|
68
73
|
[K in keyof ED]?: AuthDef<ED, K>;
|
|
69
74
|
};
|
package/lib/types/DataType.d.ts
CHANGED
|
@@ -19,3 +19,6 @@ export { Geo, SingleGeo } from './Geo';
|
|
|
19
19
|
export declare type DataTypes = number | string | Datetime | Day | Time | Geo | Object | SingleGeo;
|
|
20
20
|
export declare const types: string[];
|
|
21
21
|
export declare const unIndexedTypes: string[];
|
|
22
|
+
export declare type JsonProjection<O extends object> = {
|
|
23
|
+
[k in keyof O]?: NonNullable<O[k]> extends object ? JsonProjection<NonNullable<O[k]>> | number : number;
|
|
24
|
+
};
|
package/lib/types/Demand.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare type Q_DateComparisonValue = Q_NumberComparisonValue;
|
|
|
35
35
|
export declare type Q_EnumComparisonValue<E> = E | OneOf<{
|
|
36
36
|
$in: E[];
|
|
37
37
|
$nin: E[];
|
|
38
|
+
$ne: E;
|
|
38
39
|
}>;
|
|
39
40
|
export declare type Q_ExistsValue = {
|
|
40
41
|
$exists: boolean;
|
|
@@ -74,4 +75,14 @@ export declare type RefAttr<A> = {
|
|
|
74
75
|
'#refAttr': string;
|
|
75
76
|
};
|
|
76
77
|
export declare function isRefAttrNode<A>(node: any): node is RefAttr<A>;
|
|
78
|
+
export declare type JsonFilter<O extends any> = O extends Array<infer P> ? (JsonFilter<P> | undefined)[] | {
|
|
79
|
+
$contains?: P | P[];
|
|
80
|
+
$overlaps?: P | P[];
|
|
81
|
+
} : O extends number ? Q_NumberValue : O extends string ? Q_StringValue : O extends boolean ? Q_BooleanValue : O extends Record<string, any> ? {
|
|
82
|
+
[A in keyof O]?: JsonFilter<O[A]>;
|
|
83
|
+
} : never;
|
|
84
|
+
export declare type SubQueryPredicateMetadata = {
|
|
85
|
+
'#sqp'?: 'in' | 'not in' | 'all' | 'not all';
|
|
86
|
+
};
|
|
87
|
+
export declare const SUB_QUERY_PREDICATE_KEYWORD = "#sqp";
|
|
77
88
|
export {};
|
package/lib/types/Demand.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRefAttrNode = exports.EXPRESSION_PREFIX = void 0;
|
|
3
|
+
exports.SUB_QUERY_PREDICATE_KEYWORD = exports.isRefAttrNode = exports.EXPRESSION_PREFIX = void 0;
|
|
4
4
|
exports.EXPRESSION_PREFIX = '$expr';
|
|
5
5
|
function isRefAttrNode(node) {
|
|
6
6
|
return node.hasOwnProperty('#attr') || (node.hasOwnProperty('#refId') && node.hasOwnProperty('#refAttr'));
|
|
7
7
|
}
|
|
8
8
|
exports.isRefAttrNode = isRefAttrNode;
|
|
9
9
|
;
|
|
10
|
+
exports.SUB_QUERY_PREDICATE_KEYWORD = '#sqp';
|
package/lib/types/Entity.d.ts
CHANGED
|
@@ -54,10 +54,12 @@ export declare type Operation<A extends string, D extends Projection, F extends
|
|
|
54
54
|
} & FilterPart<A, F>;
|
|
55
55
|
export declare type Selection<A extends ReadOnlyAction, D extends Projection, F extends Filter | undefined = undefined, S extends Sorter | undefined = undefined> = {
|
|
56
56
|
id?: string;
|
|
57
|
-
action
|
|
57
|
+
action?: A;
|
|
58
58
|
data: D;
|
|
59
59
|
sorter?: S;
|
|
60
|
-
} & FilterPart<A, F
|
|
60
|
+
} & FilterPart<A, F> & {
|
|
61
|
+
randomRange?: number;
|
|
62
|
+
};
|
|
61
63
|
export interface EntityShape {
|
|
62
64
|
id: PrimaryKey;
|
|
63
65
|
$$seq$$: Sequence;
|
|
@@ -74,7 +76,7 @@ export interface EntityDef {
|
|
|
74
76
|
OpSchema: GeneralEntityShape;
|
|
75
77
|
Action: string;
|
|
76
78
|
ParticularAction?: string;
|
|
77
|
-
Selection:
|
|
79
|
+
Selection: Selection<'select', Projection, Filter, Sorter>;
|
|
78
80
|
Aggregation: DeduceAggregation<Projection, Filter, Sorter>;
|
|
79
81
|
Operation: CUDOperation;
|
|
80
82
|
Create: CreateOperation;
|
|
@@ -181,5 +183,10 @@ export declare type Configuration = {
|
|
|
181
183
|
actionType?: ActionType;
|
|
182
184
|
static?: boolean;
|
|
183
185
|
};
|
|
186
|
+
export declare type AuthCascadePath<ED extends EntityDict> = [keyof ED, string, keyof ED, boolean];
|
|
187
|
+
export declare type AuthDeduceRelationMap<ED extends EntityDict> = {
|
|
188
|
+
[T in keyof ED]?: keyof ED[T]['OpSchema'];
|
|
189
|
+
};
|
|
190
|
+
export declare type SelectFreeEntities<ED extends EntityDict> = (keyof ED)[];
|
|
184
191
|
export declare type OtmKey<K extends string> = K | `${K}$${number}`;
|
|
185
192
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LocaleDef } from './Locale';
|
|
2
|
+
import { Index } from './Storage';
|
|
3
|
+
import { EntityShape, Configuration } from './Entity';
|
|
4
|
+
export declare type EntityDesc<Schema extends EntityShape, Action extends string = '', Relation extends string = '', V extends Record<string, string> = {}> = {
|
|
5
|
+
locales: LocaleDef<Schema, Action, Relation, V>;
|
|
6
|
+
indexes?: Index<Schema>[];
|
|
7
|
+
configuration?: Configuration;
|
|
8
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare 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
|
+
localStorageEnabled: true;
|
|
35
|
+
};
|
|
36
|
+
export declare type WebEnv = {
|
|
37
|
+
type: 'web';
|
|
38
|
+
visitorId: string;
|
|
39
|
+
platform: {
|
|
40
|
+
value: string;
|
|
41
|
+
};
|
|
42
|
+
timezone: {
|
|
43
|
+
value: string;
|
|
44
|
+
};
|
|
45
|
+
vendor: {
|
|
46
|
+
value: string;
|
|
47
|
+
};
|
|
48
|
+
vendorFlavors: {
|
|
49
|
+
value: string[];
|
|
50
|
+
};
|
|
51
|
+
language: string;
|
|
52
|
+
localStorageEnabled: boolean;
|
|
53
|
+
};
|
|
54
|
+
export declare type ServerEnv = {
|
|
55
|
+
type: 'server';
|
|
56
|
+
};
|
|
57
|
+
export declare type Environment = WechatMpEnv | WebEnv | ServerEnv;
|
package/lib/types/Exception.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export declare class OakImportDataParseException<ED extends EntityDict> extends
|
|
|
23
23
|
header?: string;
|
|
24
24
|
constructor(message: string, line: number, header?: string);
|
|
25
25
|
}
|
|
26
|
+
export declare class OakNoRelationDefException<ED extends EntityDict, T extends keyof ED> extends OakDataException<ED> {
|
|
27
|
+
entity: T;
|
|
28
|
+
actions: ED[T]['Action'][];
|
|
29
|
+
constructor(entity: T, actions: ED[T]['Action'][], msg?: string);
|
|
30
|
+
toString(): string;
|
|
31
|
+
}
|
|
26
32
|
export declare class OakOperExistedException<ED extends EntityDict> extends OakDataException<ED> {
|
|
27
33
|
}
|
|
28
34
|
export declare class OakRowUnexistedException<ED extends EntityDict> extends OakDataException<ED> {
|
package/lib/types/Exception.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserUnpermittedException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakDataException = exports.OakException = void 0;
|
|
3
|
+
exports.makeException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserUnpermittedException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakDataException = exports.OakException = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
6
|
var OakException = /** @class */ (function (_super) {
|
|
@@ -83,6 +83,25 @@ var OakImportDataParseException = /** @class */ (function (_super) {
|
|
|
83
83
|
return OakImportDataParseException;
|
|
84
84
|
}(OakException));
|
|
85
85
|
exports.OakImportDataParseException = OakImportDataParseException;
|
|
86
|
+
var OakNoRelationDefException = /** @class */ (function (_super) {
|
|
87
|
+
tslib_1.__extends(OakNoRelationDefException, _super);
|
|
88
|
+
function OakNoRelationDefException(entity, actions, msg) {
|
|
89
|
+
var _this = _super.call(this, msg || "\u5BF9\u8C61".concat(entity, "\u7684\u64CD\u4F5C").concat(actions.join(','), "\u627E\u4E0D\u5230\u6709\u6548\u7684relation\u5B9A\u4E49")) || this;
|
|
90
|
+
_this.entity = entity;
|
|
91
|
+
_this.actions = actions;
|
|
92
|
+
return _this;
|
|
93
|
+
}
|
|
94
|
+
OakNoRelationDefException.prototype.toString = function () {
|
|
95
|
+
return JSON.stringify({
|
|
96
|
+
name: this.constructor.name,
|
|
97
|
+
message: this.message,
|
|
98
|
+
entity: this.entity,
|
|
99
|
+
action: this.actions,
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
return OakNoRelationDefException;
|
|
103
|
+
}(OakDataException));
|
|
104
|
+
exports.OakNoRelationDefException = OakNoRelationDefException;
|
|
86
105
|
var OakOperExistedException = /** @class */ (function (_super) {
|
|
87
106
|
tslib_1.__extends(OakOperExistedException, _super);
|
|
88
107
|
function OakOperExistedException() {
|
|
@@ -338,6 +357,11 @@ function makeException(data) {
|
|
|
338
357
|
e.setOpRecords(data.opRecords);
|
|
339
358
|
return e;
|
|
340
359
|
}
|
|
360
|
+
case 'OakNoRelationDefException': {
|
|
361
|
+
var e = new OakNoRelationDefException(data.entity, data.action, data.message);
|
|
362
|
+
e.setOpRecords(data.opRecords);
|
|
363
|
+
return e;
|
|
364
|
+
}
|
|
341
365
|
case 'OakUniqueViolationException': {
|
|
342
366
|
var e = new OakUniqueViolationException(data.rows, data.message);
|
|
343
367
|
e.setOpRecords(data.opRecords);
|
package/lib/types/Logger.d.ts
CHANGED
package/lib/types/RowStore.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { OperationResult, EntityDict } from './Entity';
|
|
2
2
|
import { StorageSchema } from './Storage';
|
|
3
|
+
import { AsyncContext } from '../store/AsyncRowStore';
|
|
4
|
+
import { SyncContext } from '../store/SyncRowStore';
|
|
3
5
|
export declare type TxnOption = {
|
|
4
6
|
isolationLevel: 'repeatable read' | 'serializable';
|
|
5
7
|
};
|
|
6
|
-
export declare type SelectionRewriter<ED extends EntityDict> = (schema: StorageSchema<ED>, entity: keyof ED, selection: ED[keyof ED]['Selection']) => void
|
|
7
|
-
export declare type OperationRewriter<ED extends EntityDict> = (schema: StorageSchema<ED>, entity: keyof ED, operate: ED[keyof ED]['Operation']) => void
|
|
8
|
+
export declare type SelectionRewriter<ED extends EntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>> = (schema: StorageSchema<ED>, entity: keyof ED, selection: ED[keyof ED]['Selection'], context: Cxt) => void | Promise<void>;
|
|
9
|
+
export declare type OperationRewriter<ED extends EntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>> = (schema: StorageSchema<ED>, entity: keyof ED, operate: ED[keyof ED]['Operation'], context: Cxt) => void | Promise<void>;
|
|
8
10
|
export declare abstract class RowStore<ED extends EntityDict> {
|
|
9
11
|
protected storageSchema: StorageSchema<ED>;
|
|
10
12
|
constructor(storageSchema: StorageSchema<ED>);
|
|
11
|
-
abstract registerOperationRewriter(rewriter: OperationRewriter<ED>): void;
|
|
12
|
-
abstract registerSelectionRewriter(rewriter: SelectionRewriter<ED>): void;
|
|
13
|
+
abstract registerOperationRewriter(rewriter: OperationRewriter<ED, AsyncContext<ED> | SyncContext<ED>>): void;
|
|
14
|
+
abstract registerSelectionRewriter(rewriter: SelectionRewriter<ED, AsyncContext<ED> | SyncContext<ED>>): void;
|
|
13
15
|
getSchema(): StorageSchema<ED>;
|
|
14
16
|
mergeOperationResult(result: OperationResult<ED>, toBeMerged: OperationResult<ED>): void;
|
|
15
17
|
mergeMultipleResults(toBeMerged: OperationResult<ED>[]): OperationResult<ED>;
|
package/lib/types/Style.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntityDict } from './Entity';
|
|
2
2
|
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
3
|
-
declare type ThemeColor = 'default' | 'success' | 'warning' | 'error';
|
|
3
|
+
declare type ThemeColor = 'default' | 'success' | 'warning' | 'error' | 'primary' | 'danger';
|
|
4
4
|
export declare type ColorDict<ED extends BaseEntityDict & EntityDict> = {
|
|
5
5
|
[T in keyof ED]?: {
|
|
6
6
|
[A in keyof ED[T]['OpSchema']]?: {
|
package/lib/types/Trigger.d.ts
CHANGED
|
@@ -7,12 +7,11 @@ import { EntityShape } from "../types/Entity";
|
|
|
7
7
|
/**
|
|
8
8
|
* 优先级越小,越早执行。定义在1~99之间
|
|
9
9
|
*/
|
|
10
|
-
export declare const TRIGGER_DEFAULT_PRIORITY = 50;
|
|
11
10
|
export declare const TRIGGER_MIN_PRIORITY = 1;
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
11
|
+
export declare const TRIGGER_DEFAULT_PRIORITY = 25;
|
|
12
|
+
export declare const TRIGGER_MAX_PRIORITY = 50;
|
|
13
|
+
export declare const CHECKER_MAX_PRIORITY = 99;
|
|
14
|
+
export declare const CHECKER_PRIORITY_MAP: Record<CheckerType, number>;
|
|
16
15
|
interface TriggerBase<ED extends EntityDict, T extends keyof ED> {
|
|
17
16
|
checkerType?: CheckerType;
|
|
18
17
|
entity: T;
|
package/lib/types/Trigger.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CHECKER_PRIORITY_MAP = exports.CHECKER_MAX_PRIORITY = exports.TRIGGER_MAX_PRIORITY = exports.TRIGGER_DEFAULT_PRIORITY = exports.TRIGGER_MIN_PRIORITY = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 优先级越小,越早执行。定义在1~99之间
|
|
6
6
|
*/
|
|
7
|
-
exports.TRIGGER_DEFAULT_PRIORITY = 50;
|
|
8
7
|
exports.TRIGGER_MIN_PRIORITY = 1;
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
8
|
+
exports.TRIGGER_DEFAULT_PRIORITY = 25;
|
|
9
|
+
exports.TRIGGER_MAX_PRIORITY = 50;
|
|
10
|
+
exports.CHECKER_MAX_PRIORITY = 99;
|
|
11
|
+
exports.CHECKER_PRIORITY_MAP = {
|
|
12
|
+
row: 51,
|
|
13
|
+
data: 61,
|
|
14
|
+
relation: 71,
|
|
15
|
+
logicalRelation: 72,
|
|
16
|
+
logical: 73,
|
|
17
|
+
};
|
|
13
18
|
;
|
|
14
19
|
;
|
|
15
20
|
;
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -23,3 +23,5 @@ tslib_1.__exportStar(require("./Timer"), exports);
|
|
|
23
23
|
tslib_1.__exportStar(require("./Port"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./Endpoint"), exports);
|
|
25
25
|
tslib_1.__exportStar(require("./Style"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./EntityDesc"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./Environment"), exports);
|
|
@@ -56,7 +56,7 @@ var SimpleConnector = /** @class */ (function (_super) {
|
|
|
56
56
|
throw err;
|
|
57
57
|
}
|
|
58
58
|
message = response.headers.get('oak-message');
|
|
59
|
-
responseType = response.headers.get('Content-Type');
|
|
59
|
+
responseType = response.headers.get('Content-Type') || response.headers.get('content-type');
|
|
60
60
|
if (!(responseType === null || responseType === void 0 ? void 0 : responseType.toLocaleLowerCase().match(/application\/json/i))) return [3 /*break*/, 3];
|
|
61
61
|
return [4 /*yield*/, response.json()];
|
|
62
62
|
case 2:
|
package/lib/utils/string.d.ts
CHANGED
|
@@ -20,3 +20,9 @@ export declare const random: (randomLength?: number) => string;
|
|
|
20
20
|
* @returns
|
|
21
21
|
*/
|
|
22
22
|
export declare const randomName: (prefix?: string, randomLength?: number) => string;
|
|
23
|
+
/**
|
|
24
|
+
* 将字符串中的u16编码转换回汉字
|
|
25
|
+
* @param str
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare function unescapeUnicode(str: string): string;
|
package/lib/utils/string.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomName = exports.random = exports.template = exports.firstLetterUpperCase = exports.firstLetterLowerCase = void 0;
|
|
3
|
+
exports.unescapeUnicode = exports.randomName = exports.random = exports.template = exports.firstLetterUpperCase = exports.firstLetterLowerCase = void 0;
|
|
4
4
|
function firstLetterLowerCase(s) {
|
|
5
5
|
return s.slice(0, 1).toLowerCase().concat(s.slice(1));
|
|
6
6
|
}
|
|
@@ -68,3 +68,15 @@ var randomName = function (prefix, randomLength) {
|
|
|
68
68
|
return name;
|
|
69
69
|
};
|
|
70
70
|
exports.randomName = randomName;
|
|
71
|
+
/**
|
|
72
|
+
* 将字符串中的u16编码转换回汉字
|
|
73
|
+
* @param str
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
function unescapeUnicode(str) {
|
|
77
|
+
return str.replace(/\\u[\dA-F]{4}/gi, function (match) {
|
|
78
|
+
return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
exports.unescapeUnicode = unescapeUnicode;
|
|
82
|
+
;
|
package/lib/utils/uuid.d.ts
CHANGED
|
@@ -10,3 +10,8 @@ export declare function generateNewIdAsync(option?: GenerateIdOption): Promise<s
|
|
|
10
10
|
export declare function produceIds(): Promise<void>;
|
|
11
11
|
export declare function setGenerateIdOption(option: GenerateIdOption): Promise<void>;
|
|
12
12
|
export declare function generateNewId(): string;
|
|
13
|
+
/**
|
|
14
|
+
* 在一些特殊场景下根据数据生成指定的uuid,长度不能超过36byte
|
|
15
|
+
* @param: input: 输入的数据数组,应保证唯一性
|
|
16
|
+
*/
|
|
17
|
+
export declare function formUuid(...input: string[]): string;
|