oak-domain 2.6.2 → 2.6.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/base-app-domain/Modi/Storage.js +2 -4
- package/lib/base-app-domain/User/Storage.js +2 -4
- package/lib/compiler/schemalBuilder.js +74 -77
- package/lib/store/CascadeStore.js +39 -33
- package/lib/store/checker.d.ts +2 -2
- package/lib/store/checker.js +387 -151
- package/lib/store/filter.js +7 -15
- package/lib/types/Auth.d.ts +10 -10
- package/lib/types/Exception.d.ts +6 -0
- package/lib/types/Exception.js +25 -1
- package/lib/types/Polyfill.d.ts +1 -0
- package/lib/types/Storage.d.ts +1 -0
- package/lib/utils/validator.d.ts +3 -2
- package/package.json +1 -1
package/lib/store/filter.js
CHANGED
|
@@ -13,7 +13,7 @@ function addFilterSegment() {
|
|
|
13
13
|
}
|
|
14
14
|
var filter = {};
|
|
15
15
|
filters.forEach(function (ele) {
|
|
16
|
-
var _a, _b, _c
|
|
16
|
+
var _a, _b, _c;
|
|
17
17
|
if (ele) {
|
|
18
18
|
for (var k in ele) {
|
|
19
19
|
if (k === '$and') {
|
|
@@ -24,25 +24,17 @@ function addFilterSegment() {
|
|
|
24
24
|
filter.$and = ele[k];
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
else if (k === '$or') {
|
|
28
|
-
if (filter.$or) {
|
|
29
|
-
(_b = filter.$or).push.apply(_b, tslib_1.__spreadArray([], tslib_1.__read(ele[k]), false));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
filter.$or = ele[k];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
27
|
else if (filter.hasOwnProperty(k)) {
|
|
36
28
|
if (filter.$and) {
|
|
37
|
-
filter.$and.push((
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
filter.$and.push((_b = {},
|
|
30
|
+
_b[k] = ele[k],
|
|
31
|
+
_b));
|
|
40
32
|
}
|
|
41
33
|
else {
|
|
42
34
|
filter.$and = [
|
|
43
|
-
(
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
(_c = {},
|
|
36
|
+
_c[k] = ele[k],
|
|
37
|
+
_c)
|
|
46
38
|
];
|
|
47
39
|
}
|
|
48
40
|
}
|
package/lib/types/Auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CascadeActionAuth, CascadeRelationAuth, ActionOnRemove } from ".";
|
|
1
|
+
import { CascadeActionAuth, CascadeRelationAuth, ActionOnRemove, SyncOrAsync } from ".";
|
|
2
2
|
import { AsyncContext } from "../store/AsyncRowStore";
|
|
3
3
|
import { SyncContext } from "../store/SyncRowStore";
|
|
4
4
|
import { EntityDict, OperateOption, SelectOption } from "../types/Entity";
|
|
@@ -12,21 +12,21 @@ export declare type DataChecker<ED extends EntityDict, T extends keyof ED, Cxt e
|
|
|
12
12
|
type: 'data';
|
|
13
13
|
entity: T;
|
|
14
14
|
action: Omit<ED[T]['Action'], 'remove'> | Array<Omit<ED[T]['Action'], 'remove'>>;
|
|
15
|
-
checker: (data: ED[T]['Create']['data'] | ED[T]['Update']['data'], context: Cxt) =>
|
|
16
|
-
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) =>
|
|
15
|
+
checker: (data: ED[T]['Create']['data'] | ED[T]['Update']['data'], context: Cxt) => SyncOrAsync<any>;
|
|
16
|
+
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => SyncOrAsync<ED[T]['Selection']['filter']>);
|
|
17
17
|
};
|
|
18
18
|
export declare type RowChecker<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = {
|
|
19
19
|
priority?: number;
|
|
20
20
|
type: 'row';
|
|
21
21
|
entity: T;
|
|
22
22
|
action: Omit<ED[T]['Action'], 'create'> | Array<Omit<ED[T]['Action'], 'create'>>;
|
|
23
|
-
filter: ED[T]['Selection']['filter'] | ((operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) =>
|
|
23
|
+
filter: ED[T]['Selection']['filter'] | ((operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) => SyncOrAsync<ED[T]['Selection']['filter']>);
|
|
24
24
|
errMsg?: string;
|
|
25
25
|
inconsistentRows?: {
|
|
26
26
|
entity: keyof ED;
|
|
27
27
|
selection: (filter?: ED[T]['Selection']['filter']) => ED[keyof ED]['Selection'];
|
|
28
28
|
};
|
|
29
|
-
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) =>
|
|
29
|
+
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => SyncOrAsync<ED[T]['Update']['filter']>);
|
|
30
30
|
};
|
|
31
31
|
export declare type RelationChecker<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = {
|
|
32
32
|
priority?: number;
|
|
@@ -34,9 +34,9 @@ export declare type RelationChecker<ED extends EntityDict, T extends keyof ED, C
|
|
|
34
34
|
entity: T;
|
|
35
35
|
when?: 'after';
|
|
36
36
|
action: ED[T]['Action'] | Array<ED[T]['Action']>;
|
|
37
|
-
relationFilter: (operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) =>
|
|
37
|
+
relationFilter: (operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) => SyncOrAsync<ED[T]['Selection']['filter']>;
|
|
38
38
|
errMsg: string;
|
|
39
|
-
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) =>
|
|
39
|
+
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => SyncOrAsync<ED[T]['Selection']['filter']>);
|
|
40
40
|
};
|
|
41
41
|
export declare type LogicalChecker<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = {
|
|
42
42
|
priority?: number;
|
|
@@ -44,8 +44,8 @@ export declare type LogicalChecker<ED extends EntityDict, T extends keyof ED, Cx
|
|
|
44
44
|
when?: 'after';
|
|
45
45
|
entity: T;
|
|
46
46
|
action: ED[T]['Action'] | Array<ED[T]['Action']>;
|
|
47
|
-
checker: (operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) =>
|
|
48
|
-
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => ED[T]['Update']['filter']);
|
|
47
|
+
checker: (operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) => SyncOrAsync<any>;
|
|
48
|
+
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => SyncOrAsync<ED[T]['Update']['filter']>);
|
|
49
49
|
};
|
|
50
50
|
export declare type LogicalRelationChecker<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = {
|
|
51
51
|
priority?: number;
|
|
@@ -54,7 +54,7 @@ export declare type LogicalRelationChecker<ED extends EntityDict, T extends keyo
|
|
|
54
54
|
entity: T;
|
|
55
55
|
action: ED[T]['Action'] | Array<ED[T]['Action']>;
|
|
56
56
|
checker: (operation: ED[T]['Operation'] | ED[T]['Selection'], context: Cxt, option: OperateOption | SelectOption) => any | Promise<any>;
|
|
57
|
-
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => ED[T]['Update']['filter']);
|
|
57
|
+
conditionalFilter?: ED[T]['Update']['filter'] | ((operation: ED[T]['Operation'], context: Cxt, option: OperateOption) => SyncOrAsync<ED[T]['Update']['filter']>);
|
|
58
58
|
};
|
|
59
59
|
export declare type Checker<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED> | SyncContext<ED>> = DataChecker<ED, T, Cxt> | RowChecker<ED, T, Cxt> | RelationChecker<ED, T, Cxt> | LogicalChecker<ED, T, Cxt> | LogicalRelationChecker<ED, T, Cxt>;
|
|
60
60
|
export declare type AuthDef<ED extends EntityDict, T extends keyof ED> = {
|
package/lib/types/Exception.d.ts
CHANGED
|
@@ -92,6 +92,12 @@ export declare class OakCongruentRowExists<ED extends EntityDict, T extends keyo
|
|
|
92
92
|
export declare class OakDeadlock<ED extends EntityDict> extends OakUserException<ED> {
|
|
93
93
|
constructor(message?: string | undefined);
|
|
94
94
|
}
|
|
95
|
+
export declare class OakPreConditionUnsetException<ED extends EntityDict> extends OakUserException<ED> {
|
|
96
|
+
entity?: keyof ED;
|
|
97
|
+
code?: string;
|
|
98
|
+
constructor(message?: string | undefined, entity?: keyof ED | undefined, code?: string | undefined);
|
|
99
|
+
toString(): string;
|
|
100
|
+
}
|
|
95
101
|
export declare function makeException<ED extends EntityDict>(data: {
|
|
96
102
|
name: string;
|
|
97
103
|
message?: string;
|
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.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserUnpermittedException = 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.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakRowUnexistedException = exports.OakOperExistedException = 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) {
|
|
@@ -252,6 +252,25 @@ var OakDeadlock = /** @class */ (function (_super) {
|
|
|
252
252
|
}(OakUserException));
|
|
253
253
|
exports.OakDeadlock = OakDeadlock;
|
|
254
254
|
;
|
|
255
|
+
var OakPreConditionUnsetException = /** @class */ (function (_super) {
|
|
256
|
+
tslib_1.__extends(OakPreConditionUnsetException, _super);
|
|
257
|
+
function OakPreConditionUnsetException(message, entity, code) {
|
|
258
|
+
var _this = _super.call(this, message || '前置条件不满足') || this;
|
|
259
|
+
_this.entity = entity,
|
|
260
|
+
_this.code = code;
|
|
261
|
+
return _this;
|
|
262
|
+
}
|
|
263
|
+
OakPreConditionUnsetException.prototype.toString = function () {
|
|
264
|
+
return JSON.stringify({
|
|
265
|
+
name: this.constructor.name,
|
|
266
|
+
message: this.message,
|
|
267
|
+
code: this.code,
|
|
268
|
+
entity: this.entity,
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
return OakPreConditionUnsetException;
|
|
272
|
+
}(OakUserException));
|
|
273
|
+
exports.OakPreConditionUnsetException = OakPreConditionUnsetException;
|
|
255
274
|
function makeException(data) {
|
|
256
275
|
var name = data.name;
|
|
257
276
|
switch (name) {
|
|
@@ -320,6 +339,11 @@ function makeException(data) {
|
|
|
320
339
|
e.setOpRecords(data.opRecords);
|
|
321
340
|
return e;
|
|
322
341
|
}
|
|
342
|
+
case 'OakPreConditionUnsetException': {
|
|
343
|
+
var e = new OakPreConditionUnsetException(data.message, data.entity, data.code);
|
|
344
|
+
e.setOpRecords(data.opRecords);
|
|
345
|
+
return e;
|
|
346
|
+
}
|
|
323
347
|
default:
|
|
324
348
|
return;
|
|
325
349
|
}
|
package/lib/types/Polyfill.d.ts
CHANGED
package/lib/types/Storage.d.ts
CHANGED
package/lib/utils/validator.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EntityDict } from "../types";
|
|
1
2
|
declare type ValidatorFunction = (text: string, size?: number) => string | boolean;
|
|
2
3
|
declare type ValidatorMoneyFunction = (text: string, zero?: boolean) => string | boolean;
|
|
3
4
|
export declare const isMobile: ValidatorFunction;
|
|
@@ -18,6 +19,6 @@ export declare const isPhone: ValidatorFunction;
|
|
|
18
19
|
export declare const isNumber: ValidatorFunction;
|
|
19
20
|
export declare const isMoney: ValidatorMoneyFunction;
|
|
20
21
|
export declare const isVehicleNumber: ValidatorFunction;
|
|
21
|
-
export declare function checkAttributesNotNull<
|
|
22
|
-
export declare function checkAttributesScope<
|
|
22
|
+
export declare function checkAttributesNotNull<ED extends EntityDict, T extends keyof EntityDict>(entity: T, data: Partial<ED[T]['CreateSingle']['data']>, attributes: Array<keyof ED[T]['CreateSingle']['data']>, allowEmpty?: true): void;
|
|
23
|
+
export declare function checkAttributesScope<ED extends EntityDict, T extends keyof EntityDict>(entity: T, data: Partial<ED[T]['CreateSingle']['data']>, attributes: Array<keyof ED[T]['CreateSingle']['data']>): void;
|
|
23
24
|
export {};
|