oak-domain 2.1.0 → 2.2.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/compiler/schemalBuilder.js +22 -28
- package/lib/store/AsyncRowStore.d.ts +1 -0
- package/lib/store/SyncRowStore.d.ts +1 -0
- package/lib/store/selection.js +7 -0
- package/lib/types/Auth.d.ts +1 -1
- package/lib/types/Context.d.ts +1 -0
- package/lib/types/Timer.d.ts +14 -0
- package/lib/types/Timer.js +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +2 -1
|
@@ -367,7 +367,7 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
367
367
|
var hasEntityAttr_1 = false;
|
|
368
368
|
var hasEntityIdAttr_1 = false;
|
|
369
369
|
var members = node.members, heritageClauses = node.heritageClauses;
|
|
370
|
-
(0, assert_1.default)(['EntityShape'
|
|
370
|
+
(0, assert_1.default)(['EntityShape'].includes(heritageClauses[0].types[0].expression.text), moduleName);
|
|
371
371
|
members.forEach(function (attrNode) {
|
|
372
372
|
var _a, _b;
|
|
373
373
|
var _c = attrNode, type = _c.type, name = _c.name, questionToken = _c.questionToken;
|
|
@@ -439,39 +439,33 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
if (attrName === 'entity'
|
|
443
|
-
|
|
444
|
-
&& ts.isIdentifier(type.typeName)) {
|
|
442
|
+
if (attrName === 'entity') {
|
|
443
|
+
(0, assert_1.default)(ts.isTypeReferenceNode(type) && ts.isIdentifier(type.typeName), "\u300C".concat(moduleName, "\u300D\u4E2Dentity\u5C5E\u6027\u7684\u5B9A\u4E49\u4E0D\u662FString<32>\u7C7B\u578B\uFF0Centity\u662F\u7CFB\u7EDF\u7528\u4E8E\u8868\u793A\u53CD\u6307\u6307\u9488\u7684\u4FDD\u7559\u5C5E\u6027\uFF0C\u8BF7\u52FF\u4ED6\u7528"));
|
|
445
444
|
var typeArguments = type.typeArguments;
|
|
446
|
-
|
|
445
|
+
(0, assert_1.default)(type.typeName.text === 'String'
|
|
447
446
|
&& typeArguments
|
|
448
|
-
&& typeArguments.length === 1)
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
447
|
+
&& typeArguments.length === 1, "\u300C".concat(moduleName, "\u300D\u4E2Dentity\u5C5E\u6027\u7684\u5B9A\u4E49\u4E0D\u662FString<32>\u7C7B\u578B\uFF0Centity\u662F\u7CFB\u7EDF\u7528\u4E8E\u8868\u793A\u53CD\u6307\u6307\u9488\u7684\u4FDD\u7559\u5C5E\u6027\uFF0C\u8BF7\u52FF\u4ED6\u7528"));
|
|
448
|
+
var _d = tslib_1.__read(typeArguments, 1), node_1 = _d[0];
|
|
449
|
+
if (ts.isLiteralTypeNode(node_1) && ts.isNumericLiteral(node_1.literal)) {
|
|
450
|
+
if (parseInt(node_1.literal.text) > 32) {
|
|
451
|
+
(0, assert_1.default)(false, "\u300C".concat(moduleName, "\u300D\u4E2Dentity\u5C5E\u6027\u7684\u5B9A\u4E49\u4E0D\u662FString<32>\u7C7B\u578B\uFF0Centity\u662F\u7CFB\u7EDF\u7528\u4E8E\u8868\u793A\u53CD\u6307\u6307\u9488\u7684\u4FDD\u7559\u5C5E\u6027\uFF0C\u8BF7\u52FF\u4ED6\u7528"));
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
hasEntityAttr_1 = true;
|
|
457
455
|
}
|
|
458
456
|
}
|
|
459
457
|
}
|
|
460
|
-
if (attrName === 'entityId'
|
|
461
|
-
|
|
462
|
-
&& ts.isIdentifier(type.typeName)) {
|
|
458
|
+
if (attrName === 'entityId') {
|
|
459
|
+
(0, assert_1.default)(ts.isTypeReferenceNode(type) && ts.isIdentifier(type.typeName), "\u300C".concat(moduleName, "\u300D\u4E2DentityId\u5C5E\u6027\u7684\u5B9A\u4E49\u4E0D\u662FString<64>\u7C7B\u578B\uFF0CentityId\u662F\u7CFB\u7EDF\u7528\u4E8E\u8868\u793A\u53CD\u6307\u6307\u9488\u7684\u4FDD\u7559\u5C5E\u6027\uFF0C\u8BF7\u52FF\u4ED6\u7528"));
|
|
463
460
|
var typeArguments = type.typeArguments;
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
else {
|
|
473
|
-
hasEntityIdAttr_1 = true;
|
|
474
|
-
}
|
|
461
|
+
(0, assert_1.default)(type.typeName.text === 'String' && typeArguments && typeArguments.length === 1, "\u300C".concat(moduleName, "\u300D\u4E2DentityId\u5C5E\u6027\u7684\u5B9A\u4E49\u4E0D\u662FString<64>\u7C7B\u578B\uFF0CentityId\u662F\u7CFB\u7EDF\u7528\u4E8E\u8868\u793A\u53CD\u6307\u6307\u9488\u7684\u4FDD\u7559\u5C5E\u6027\uFF0C\u8BF7\u52FF\u4ED6\u7528"));
|
|
462
|
+
var _e = tslib_1.__read(typeArguments, 1), node_2 = _e[0];
|
|
463
|
+
if (ts.isLiteralTypeNode(node_2) && ts.isNumericLiteral(node_2.literal)) {
|
|
464
|
+
if (parseInt(node_2.literal.text) !== 64) {
|
|
465
|
+
(0, assert_1.default)(false, "\u300C".concat(moduleName, "\u300D\u4E2DentityId\u5C5E\u6027\u7684\u5B9A\u4E49\u4E0D\u662FString<64>\u7C7B\u578B\uFF0CentityId\u662F\u7CFB\u7EDF\u7528\u4E8E\u8868\u793A\u53CD\u6307\u6307\u9488\u7684\u4FDD\u7559\u5C5E\u6027\uFF0C\u8BF7\u52FF\u4ED6\u7528"));
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
hasEntityIdAttr_1 = true;
|
|
475
469
|
}
|
|
476
470
|
}
|
|
477
471
|
}
|
|
@@ -34,6 +34,7 @@ export declare abstract class AsyncContext<ED extends EntityDict> implements Con
|
|
|
34
34
|
abstract isRoot(): boolean;
|
|
35
35
|
abstract getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
|
|
36
36
|
abstract toString(): string;
|
|
37
|
+
abstract allowUserUpdate(): boolean;
|
|
37
38
|
}
|
|
38
39
|
export interface AsyncRowStore<ED extends EntityDict, Cxt extends Context> extends RowStore<ED> {
|
|
39
40
|
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
|
|
@@ -15,6 +15,7 @@ export declare abstract class SyncContext<ED extends EntityDict> implements Cont
|
|
|
15
15
|
select<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], option: OP): Partial<ED[T]["Schema"]>[];
|
|
16
16
|
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, option: OP): number;
|
|
17
17
|
mergeMultipleResults(toBeMerged: OperationResult<ED>[]): OperationResult<ED>;
|
|
18
|
+
abstract allowUserUpdate(): boolean;
|
|
18
19
|
}
|
|
19
20
|
export interface SyncRowStore<ED extends EntityDict, Cxt extends Context> extends RowStore<ED> {
|
|
20
21
|
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): OperationResult<ED>;
|
package/lib/store/selection.js
CHANGED
|
@@ -59,6 +59,13 @@ function reinforceSelection(schema, entity, selection) {
|
|
|
59
59
|
else if (attr === '$not') {
|
|
60
60
|
checkFilterNode_1(entity2, filterNode[attr], projectionNode);
|
|
61
61
|
}
|
|
62
|
+
else if (attr === '$text') {
|
|
63
|
+
// 全文检索首先要有fulltext索引,其次要把fulltext的相关属性加到projection里
|
|
64
|
+
var indexes = schema[entity2].indexes;
|
|
65
|
+
var fulltextIndex = indexes.find(function (ele) { return ele.config && ele.config.type === 'fulltext'; });
|
|
66
|
+
var attributes = fulltextIndex.attributes;
|
|
67
|
+
necessaryAttrs.push.apply(necessaryAttrs, tslib_1.__spreadArray([], tslib_1.__read((attributes.map(function (ele) { return ele.name; }))), false));
|
|
68
|
+
}
|
|
62
69
|
else {
|
|
63
70
|
if (attr.toLowerCase().startsWith(Demand_1.EXPRESSION_PREFIX)) {
|
|
64
71
|
var exprResult = (0, types_1.getAttrRefInExpression)(filterNode[attr]);
|
package/lib/types/Auth.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare type DataChecker<ED extends EntityDict, T extends keyof ED, Cxt e
|
|
|
7
7
|
priority?: number;
|
|
8
8
|
type: 'data';
|
|
9
9
|
entity: T;
|
|
10
|
-
action: Omit<ED[T]['Action'], 'remove'
|
|
10
|
+
action: Omit<ED[T]['Action'], 'remove'> | Array<Omit<ED[T]['Action'], 'remove'>>;
|
|
11
11
|
checker: (data: ED[T]['Create']['data'] | ED[T]['Update']['data'], context: Cxt) => void;
|
|
12
12
|
};
|
|
13
13
|
export declare type RowChecker<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = {
|
package/lib/types/Context.d.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RecurrenceRule, RecurrenceSpecDateRange, RecurrenceSpecObjLit } from 'node-schedule';
|
|
2
|
+
import { EntityDict } from './Entity';
|
|
3
|
+
import { AsyncContext } from "../store/AsyncRowStore";
|
|
4
|
+
declare type RoutineFn<ED extends EntityDict, Cxt extends AsyncContext<ED>> = (context: Cxt) => Promise<string>;
|
|
5
|
+
export declare type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
|
6
|
+
name: string;
|
|
7
|
+
fn: RoutineFn<ED, Cxt>;
|
|
8
|
+
};
|
|
9
|
+
export declare type Timer<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
|
10
|
+
name: string;
|
|
11
|
+
cron: RecurrenceRule | RecurrenceSpecDateRange | RecurrenceSpecObjLit | Date | string | number;
|
|
12
|
+
fn: RoutineFn<ED, Cxt>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -19,3 +19,4 @@ tslib_1.__exportStar(require("./Exception"), exports);
|
|
|
19
19
|
tslib_1.__exportStar(require("./Watcher"), exports);
|
|
20
20
|
tslib_1.__exportStar(require("./AppLoader"), exports);
|
|
21
21
|
tslib_1.__exportStar(require("./Connector"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./Timer"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-domain",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "XuChang"
|
|
6
6
|
},
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@types/luxon": "^2.0.9",
|
|
28
28
|
"@types/mocha": "^8.2.0",
|
|
29
29
|
"@types/node": "^14.14.25",
|
|
30
|
+
"@types/node-schedule": "^2.1.0",
|
|
30
31
|
"@types/react": "^17.0.2",
|
|
31
32
|
"@types/uuid": "^8.3.0",
|
|
32
33
|
"@types/wechat-miniprogram": "^3.4.1",
|