oak-domain 2.6.8 → 2.6.9
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/ActionAuth/Schema.d.ts +156 -0
- package/lib/base-app-domain/ActionAuth/Schema.js +2 -0
- package/lib/base-app-domain/ActionAuth/Storage.d.ts +3 -0
- package/lib/base-app-domain/ActionAuth/Storage.js +49 -0
- package/lib/base-app-domain/EntityDict.d.ts +8 -0
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +112 -4
- package/lib/base-app-domain/ModiEntity/Storage.js +1 -1
- package/lib/base-app-domain/OperEntity/Schema.d.ts +112 -4
- package/lib/base-app-domain/OperEntity/Storage.js +1 -1
- package/lib/base-app-domain/Relation/Schema.d.ts +160 -0
- package/lib/base-app-domain/Relation/Schema.js +2 -0
- package/lib/base-app-domain/Relation/Storage.d.ts +3 -0
- package/lib/base-app-domain/Relation/Storage.js +57 -0
- package/lib/base-app-domain/RelationAuth/Schema.d.ts +156 -0
- package/lib/base-app-domain/RelationAuth/Schema.js +2 -0
- package/lib/base-app-domain/RelationAuth/Storage.d.ts +3 -0
- package/lib/base-app-domain/RelationAuth/Storage.js +49 -0
- package/lib/base-app-domain/Storage.js +20 -12
- package/lib/base-app-domain/User/Schema.d.ts +11 -0
- package/lib/base-app-domain/UserRelation/Schema.d.ts +175 -0
- package/lib/base-app-domain/UserRelation/Schema.js +2 -0
- package/lib/base-app-domain/UserRelation/Storage.d.ts +3 -0
- package/lib/base-app-domain/UserRelation/Storage.js +36 -0
- package/lib/base-app-domain/_SubQuery.d.ts +32 -0
- package/lib/entities/ActionAuth.d.ts +11 -0
- package/lib/entities/ActionAuth.js +30 -0
- package/lib/entities/Relation.d.ts +8 -0
- package/lib/entities/Relation.js +33 -0
- package/lib/entities/RelationAuth.d.ts +11 -0
- package/lib/entities/RelationAuth.js +30 -0
- package/lib/entities/UserRelation.d.ts +7 -0
- package/lib/entities/UserRelation.js +28 -0
- package/lib/store/CascadeStore.js +5 -4
- package/lib/store/checker.js +47 -19
- package/lib/types/Auth.d.ts +1 -1
- package/lib/types/Connector.d.ts +6 -0
- package/lib/types/Entity.d.ts +1 -0
- package/lib/utils/SimpleConnector.d.ts +15 -2
- package/lib/utils/SimpleConnector.js +39 -4
- package/lib/utils/money.d.ts +2 -1
- package/lib/utils/money.js +17 -1
- package/lib/utils/version.d.ts +7 -0
- package/lib/utils/version.js +21 -0
- package/package.json +1 -1
- package/src/entities/ActionAuth.ts +49 -0
- package/src/entities/Relation.ts +49 -0
- package/src/entities/RelationAuth.ts +49 -0
- package/src/entities/UserRelation.ts +44 -0
- package/lib/checkers/SyncCheckExecutor.d.ts +0 -9
- package/lib/checkers/SyncCheckExecutor.js +0 -103
package/lib/types/Entity.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ import { AsyncContext, AsyncRowStore } from '../store/AsyncRowStore';
|
|
|
4
4
|
import { SyncContext } from '../store/SyncRowStore';
|
|
5
5
|
import { Connector, EntityDict, OakException } from "../types";
|
|
6
6
|
export declare class SimpleConnector<ED extends EntityDict, BackCxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>> extends Connector<ED, BackCxt, FrontCxt> {
|
|
7
|
-
static
|
|
8
|
-
|
|
7
|
+
static ASPECT_ROUTER: string;
|
|
8
|
+
static BRIDGE_ROUTER: string;
|
|
9
|
+
private serverAspectUrl;
|
|
10
|
+
private serverBridgeUrl;
|
|
9
11
|
private makeException;
|
|
10
12
|
private contextBuilder;
|
|
11
13
|
constructor(serverUrl: string, makeException: (exceptionData: any) => OakException<ED>, contextBuilder: (str: string | undefined) => (store: AsyncRowStore<ED, BackCxt>) => Promise<BackCxt>);
|
|
@@ -32,4 +34,15 @@ export declare class SimpleConnector<ED extends EntityDict, BackCxt extends Asyn
|
|
|
32
34
|
body: any;
|
|
33
35
|
headers?: Record<string, any> | undefined;
|
|
34
36
|
};
|
|
37
|
+
getBridgeRouter(): string;
|
|
38
|
+
/**
|
|
39
|
+
* 通过本地服务器桥接访问外部资源的url
|
|
40
|
+
* @param url
|
|
41
|
+
* @param headers
|
|
42
|
+
*/
|
|
43
|
+
makeBridgeUrl(url: string, headers?: Record<string, string>): string;
|
|
44
|
+
parseBridgeRequestQuery(urlParams: string): {
|
|
45
|
+
url: string;
|
|
46
|
+
headers?: Record<string, string> | undefined;
|
|
47
|
+
};
|
|
35
48
|
}
|
|
@@ -4,6 +4,7 @@ exports.SimpleConnector = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
6
|
var stream_1 = require("stream");
|
|
7
|
+
var url_1 = tslib_1.__importDefault(require("url"));
|
|
7
8
|
var types_1 = require("../types");
|
|
8
9
|
function makeContentTypeAndBody(data) {
|
|
9
10
|
//
|
|
@@ -24,7 +25,8 @@ var SimpleConnector = /** @class */ (function (_super) {
|
|
|
24
25
|
tslib_1.__extends(SimpleConnector, _super);
|
|
25
26
|
function SimpleConnector(serverUrl, makeException, contextBuilder) {
|
|
26
27
|
var _this = _super.call(this) || this;
|
|
27
|
-
_this.
|
|
28
|
+
_this.serverAspectUrl = "".concat(serverUrl).concat(SimpleConnector.ASPECT_ROUTER);
|
|
29
|
+
_this.serverBridgeUrl = "".concat(serverUrl).concat(SimpleConnector.BRIDGE_ROUTER);
|
|
28
30
|
_this.makeException = makeException;
|
|
29
31
|
_this.contextBuilder = contextBuilder;
|
|
30
32
|
return _this;
|
|
@@ -37,7 +39,7 @@ var SimpleConnector = /** @class */ (function (_super) {
|
|
|
37
39
|
case 0:
|
|
38
40
|
cxtStr = context.toString();
|
|
39
41
|
_a = makeContentTypeAndBody(params), contentType = _a.contentType, body = _a.body;
|
|
40
|
-
return [4 /*yield*/, global.fetch(this.
|
|
42
|
+
return [4 /*yield*/, global.fetch(this.serverAspectUrl, {
|
|
41
43
|
method: 'POST',
|
|
42
44
|
headers: Object.assign({
|
|
43
45
|
'oak-cxt': cxtStr,
|
|
@@ -82,7 +84,7 @@ var SimpleConnector = /** @class */ (function (_super) {
|
|
|
82
84
|
});
|
|
83
85
|
};
|
|
84
86
|
SimpleConnector.prototype.getRouter = function () {
|
|
85
|
-
return SimpleConnector.
|
|
87
|
+
return SimpleConnector.ASPECT_ROUTER;
|
|
86
88
|
};
|
|
87
89
|
SimpleConnector.prototype.parseRequest = function (headers, body, store) {
|
|
88
90
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -139,7 +141,40 @@ var SimpleConnector = /** @class */ (function (_super) {
|
|
|
139
141
|
},
|
|
140
142
|
};
|
|
141
143
|
};
|
|
142
|
-
SimpleConnector.
|
|
144
|
+
SimpleConnector.prototype.getBridgeRouter = function () {
|
|
145
|
+
return SimpleConnector.BRIDGE_ROUTER;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* 通过本地服务器桥接访问外部资源的url
|
|
149
|
+
* @param url
|
|
150
|
+
* @param headers
|
|
151
|
+
*/
|
|
152
|
+
SimpleConnector.prototype.makeBridgeUrl = function (url, headers) {
|
|
153
|
+
// if (process.env.PROD !== 'true') {
|
|
154
|
+
// console.warn('在development下无法通过bridge访问资源,将直接访问,可能失败', url);
|
|
155
|
+
// return url;
|
|
156
|
+
// }
|
|
157
|
+
var encodeUrl = encodeURIComponent(url);
|
|
158
|
+
// const urlParse = URL.parse(url, true);
|
|
159
|
+
// const { search } = urlParse as {
|
|
160
|
+
// search: string;
|
|
161
|
+
// };
|
|
162
|
+
// if (headers) {
|
|
163
|
+
// search.append('headers', JSON.stringify(headers));
|
|
164
|
+
// }
|
|
165
|
+
return "".concat(this.serverBridgeUrl, "?url=").concat(encodeUrl);
|
|
166
|
+
};
|
|
167
|
+
SimpleConnector.prototype.parseBridgeRequestQuery = function (urlParams) {
|
|
168
|
+
var search = new url_1.default.URLSearchParams(urlParams);
|
|
169
|
+
var url = search.get('url');
|
|
170
|
+
var headers = search.get('headers');
|
|
171
|
+
return {
|
|
172
|
+
url: url,
|
|
173
|
+
headers: headers && JSON.parse(headers),
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
SimpleConnector.ASPECT_ROUTER = '/aspect';
|
|
177
|
+
SimpleConnector.BRIDGE_ROUTER = '/bridge';
|
|
143
178
|
return SimpleConnector;
|
|
144
179
|
}(types_1.Connector));
|
|
145
180
|
exports.SimpleConnector = SimpleConnector;
|
package/lib/utils/money.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ declare const ToCent: (float: number) => number;
|
|
|
2
2
|
declare const ToYuan: (int: number) => number;
|
|
3
3
|
declare const StringToCent: (value: string, allowNegative?: true) => number | undefined;
|
|
4
4
|
declare const CentToString: (value: number) => string | undefined;
|
|
5
|
-
|
|
5
|
+
declare const ThousandCont: (value: number) => string | undefined;
|
|
6
|
+
export { ToCent, ToYuan, StringToCent, CentToString, ThousandCont };
|
package/lib/utils/money.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CentToString = exports.StringToCent = exports.ToYuan = exports.ToCent = void 0;
|
|
3
|
+
exports.ThousandCont = exports.CentToString = exports.StringToCent = exports.ToYuan = exports.ToCent = void 0;
|
|
4
4
|
var ToCent = function (float) {
|
|
5
5
|
return Math.round(float * 100);
|
|
6
6
|
};
|
|
@@ -22,3 +22,19 @@ var CentToString = function (value) {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
exports.CentToString = CentToString;
|
|
25
|
+
var ThousandCont = function (value) {
|
|
26
|
+
var value1 = "".concat(value);
|
|
27
|
+
var numArr = value1.split('.');
|
|
28
|
+
value1 = numArr[0];
|
|
29
|
+
var result = '';
|
|
30
|
+
while (value1.length > 3) {
|
|
31
|
+
result = ',' + value1.slice(-3) + result;
|
|
32
|
+
value1 = value1.slice(0, value1.length - 3);
|
|
33
|
+
}
|
|
34
|
+
if (value1) {
|
|
35
|
+
result = value1 + result;
|
|
36
|
+
}
|
|
37
|
+
result = result + '.' + numArr[1];
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
exports.ThousandCont = ThousandCont;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareVersion = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 版本比较
|
|
6
|
+
* @param curVersion 当前版本
|
|
7
|
+
* @param reqVersion 比较版本
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
var compareVersion = function (curVersion, reqVersion) {
|
|
11
|
+
var v1 = curVersion.split('.');
|
|
12
|
+
var v2 = reqVersion.split('.');
|
|
13
|
+
for (var i = 0; i < Math.max(v1.length, v2.length); i++) {
|
|
14
|
+
var num1 = i < v1.length ? parseInt(v1[i], 10) : 0;
|
|
15
|
+
var num2 = i < v2.length ? parseInt(v2[i], 10) : 0;
|
|
16
|
+
if (num1 !== num2)
|
|
17
|
+
return num1 - num2;
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
};
|
|
21
|
+
exports.compareVersion = compareVersion;
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { LocaleDef } from '../types/Locale';
|
|
3
|
+
import { EntityShape } from '../types/Entity';
|
|
4
|
+
import { Index } from '../types/Storage';
|
|
5
|
+
import { Schema as Relation } from './Relation';
|
|
6
|
+
|
|
7
|
+
type Actions = string[];
|
|
8
|
+
|
|
9
|
+
export interface Schema extends EntityShape {
|
|
10
|
+
relation: Relation;
|
|
11
|
+
path: String<256>;
|
|
12
|
+
destEntity: String<32>;
|
|
13
|
+
deActions: Actions;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const indexes: Index<Schema>[] = [
|
|
18
|
+
{
|
|
19
|
+
name: 'index_relation_path',
|
|
20
|
+
attributes: [
|
|
21
|
+
{
|
|
22
|
+
name: 'relation',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'path',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
config: {
|
|
29
|
+
unique: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const locale: LocaleDef<
|
|
35
|
+
Schema,
|
|
36
|
+
'',
|
|
37
|
+
'',
|
|
38
|
+
{}
|
|
39
|
+
> = {
|
|
40
|
+
zh_CN: {
|
|
41
|
+
name: '用户授权',
|
|
42
|
+
attr: {
|
|
43
|
+
relation: '关系',
|
|
44
|
+
path: '路径',
|
|
45
|
+
destEntity: '目标对象',
|
|
46
|
+
deActions: '目标对象动作',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { LocaleDef } from '../types/Locale';
|
|
3
|
+
import { EntityShape } from '../types/Entity';
|
|
4
|
+
import { Index } from '../types/Storage';
|
|
5
|
+
|
|
6
|
+
export interface Schema extends EntityShape {
|
|
7
|
+
entity: String<32>;
|
|
8
|
+
entityId: String<64>; // 可以为空
|
|
9
|
+
name: String<32>;
|
|
10
|
+
display: String<32>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const indexes: Index<Schema>[] = [
|
|
15
|
+
{
|
|
16
|
+
name: 'index_entity_entityId_name',
|
|
17
|
+
attributes: [
|
|
18
|
+
{
|
|
19
|
+
name: 'entity',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'entityId',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'name',
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
config: {
|
|
29
|
+
unique: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const locale: LocaleDef<
|
|
35
|
+
Schema,
|
|
36
|
+
'',
|
|
37
|
+
'',
|
|
38
|
+
{}
|
|
39
|
+
> = {
|
|
40
|
+
zh_CN: {
|
|
41
|
+
name: '用户授权',
|
|
42
|
+
attr: {
|
|
43
|
+
name: '关系',
|
|
44
|
+
entity: '目标对象',
|
|
45
|
+
entityId: '目标对象id',
|
|
46
|
+
display: '显示值',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { LocaleDef } from '../types/Locale';
|
|
3
|
+
import { EntityShape } from '../types/Entity';
|
|
4
|
+
import { Index } from '../types/Storage';
|
|
5
|
+
import { Schema as Relation } from './Relation';
|
|
6
|
+
|
|
7
|
+
type Relations = string[];
|
|
8
|
+
|
|
9
|
+
export interface Schema extends EntityShape {
|
|
10
|
+
relation: Relation;
|
|
11
|
+
path: String<256>;
|
|
12
|
+
destEntity: String<32>;
|
|
13
|
+
deRelations: Relations;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const indexes: Index<Schema>[] = [
|
|
18
|
+
{
|
|
19
|
+
name: 'index_relation_path',
|
|
20
|
+
attributes: [
|
|
21
|
+
{
|
|
22
|
+
name: 'relation',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'path',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
config: {
|
|
29
|
+
unique: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const locale: LocaleDef<
|
|
35
|
+
Schema,
|
|
36
|
+
'',
|
|
37
|
+
'',
|
|
38
|
+
{}
|
|
39
|
+
> = {
|
|
40
|
+
zh_CN: {
|
|
41
|
+
name: '用户授权',
|
|
42
|
+
attr: {
|
|
43
|
+
relation: '关系',
|
|
44
|
+
path: '路径',
|
|
45
|
+
destEntity: '目标对象',
|
|
46
|
+
deRelations: '目标对象关系',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { LocaleDef } from '../types/Locale';
|
|
3
|
+
import { EntityShape } from '../types/Entity';
|
|
4
|
+
import { Index } from '../types/Storage';
|
|
5
|
+
import { Schema as User } from './User';
|
|
6
|
+
import { Schema as Relation } from './Relation';
|
|
7
|
+
|
|
8
|
+
export interface Schema extends EntityShape {
|
|
9
|
+
user: User;
|
|
10
|
+
relation: Relation;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const indexes: Index<Schema>[] = [
|
|
15
|
+
{
|
|
16
|
+
name: 'index_user_relation',
|
|
17
|
+
attributes: [
|
|
18
|
+
{
|
|
19
|
+
name: 'user',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'relation',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
config: {
|
|
26
|
+
unique: true,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const locale: LocaleDef<
|
|
32
|
+
Schema,
|
|
33
|
+
'',
|
|
34
|
+
'',
|
|
35
|
+
{}
|
|
36
|
+
> = {
|
|
37
|
+
zh_CN: {
|
|
38
|
+
name: '用户对象关系',
|
|
39
|
+
attr: {
|
|
40
|
+
user: '关系',
|
|
41
|
+
relation: '目标关系',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { EntityDict } from '../types/Entity';
|
|
2
|
-
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
3
|
-
import { Checker, CheckerType } from '../types';
|
|
4
|
-
import { SyncContext } from '../store/SyncRowStore';
|
|
5
|
-
export default class SyncCheckerExecutor<ED extends EntityDict & BaseEntityDict, Cxt extends SyncContext<ED>> {
|
|
6
|
-
private checkerMap;
|
|
7
|
-
registerChecker<T extends keyof ED>(checker: Checker<ED, T, Cxt>): void;
|
|
8
|
-
check<T extends keyof ED>(entity: T, operation: Omit<ED[T]['Operation'], 'id'>, context: Cxt, when?: 'before' | 'after', checkerTypes?: CheckerType[]): void;
|
|
9
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
// 简化版的对checker的同步检查
|
|
5
|
-
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
-
var types_1 = require("../types");
|
|
7
|
-
var checker_1 = require("../store/checker");
|
|
8
|
-
var filter_1 = require("../store/filter");
|
|
9
|
-
var SyncCheckerExecutor = /** @class */ (function () {
|
|
10
|
-
function SyncCheckerExecutor() {
|
|
11
|
-
this.checkerMap = {};
|
|
12
|
-
}
|
|
13
|
-
SyncCheckerExecutor.prototype.registerChecker = function (checker) {
|
|
14
|
-
var _this = this;
|
|
15
|
-
var entity = checker.entity, action = checker.action, priority = checker.priority, type = checker.type, conditionalFilter = checker.conditionalFilter;
|
|
16
|
-
var _a = (0, checker_1.translateCheckerInSyncContext)(checker), fn = _a.fn, when = _a.when;
|
|
17
|
-
if (priority === undefined) {
|
|
18
|
-
priority = type === 'data' ? types_1.DATA_CHECKER_DEFAULT_PRIORITY : types_1.CHECKER_DEFAULT_PRIORITY;
|
|
19
|
-
}
|
|
20
|
-
var addCheckerMap = function (action2) {
|
|
21
|
-
var _a, _b, _c;
|
|
22
|
-
if (_this.checkerMap[entity] && _this.checkerMap[entity][action2]) {
|
|
23
|
-
var iter = 0;
|
|
24
|
-
var checkers = _this.checkerMap[entity][action2];
|
|
25
|
-
for (; iter < checkers.length; iter++) {
|
|
26
|
-
if (priority <= checkers[iter].priority) {
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
checkers.splice(iter, 0, {
|
|
31
|
-
type: type,
|
|
32
|
-
priority: priority,
|
|
33
|
-
fn: fn,
|
|
34
|
-
when: when,
|
|
35
|
-
filter: conditionalFilter,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
else if (_this.checkerMap[entity]) {
|
|
39
|
-
Object.assign(_this.checkerMap[entity], (_a = {},
|
|
40
|
-
_a[action2] = [{
|
|
41
|
-
type: type,
|
|
42
|
-
priority: priority,
|
|
43
|
-
fn: fn,
|
|
44
|
-
when: when,
|
|
45
|
-
filter: conditionalFilter,
|
|
46
|
-
}],
|
|
47
|
-
_a));
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
Object.assign(_this.checkerMap, (_b = {},
|
|
51
|
-
_b[entity] = (_c = {},
|
|
52
|
-
_c[action2] = [{
|
|
53
|
-
type: type,
|
|
54
|
-
priority: priority,
|
|
55
|
-
fn: fn,
|
|
56
|
-
when: when,
|
|
57
|
-
filter: conditionalFilter,
|
|
58
|
-
}],
|
|
59
|
-
_c),
|
|
60
|
-
_b));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
if (action instanceof Array) {
|
|
64
|
-
action.forEach(function (a) { return addCheckerMap(a); });
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
addCheckerMap(action);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
SyncCheckerExecutor.prototype.check = function (entity, operation, context, when, checkerTypes) {
|
|
71
|
-
var e_1, _a;
|
|
72
|
-
var action = operation.action;
|
|
73
|
-
var checkers = this.checkerMap[entity] && this.checkerMap[entity][action];
|
|
74
|
-
if (checkers) {
|
|
75
|
-
var checkers2 = checkers.filter(function (ele) { return (!checkerTypes || checkerTypes.includes(ele.type)) && (!when || ele.when === when); });
|
|
76
|
-
try {
|
|
77
|
-
for (var checkers2_1 = tslib_1.__values(checkers2), checkers2_1_1 = checkers2_1.next(); !checkers2_1_1.done; checkers2_1_1 = checkers2_1.next()) {
|
|
78
|
-
var checker = checkers2_1_1.value;
|
|
79
|
-
var filter = checker.filter;
|
|
80
|
-
if (filter) {
|
|
81
|
-
var filterr = typeof filter === 'function' ? filter(operation, context, {}) : filter;
|
|
82
|
-
(0, assert_1.default)(!(filter instanceof Promise), "\u5BF9".concat(entity, "\u7684\u52A8\u4F5C").concat(action, "\u4E0A\u5B9A\u4E49\u7684checker\uFF0C\u5176filter\u8FD4\u56DE\u4E86Promise\uFF0C\u8BF7\u6CE8\u610F\u5C06\u540C\u6B65\u548C\u5F02\u6B65\u7684\u8FD4\u56DE\u533A\u5206\u5BF9\u5F85"));
|
|
83
|
-
var isRepel = (0, filter_1.checkFilterRepel)(entity, context, filterr, operation.filter, true);
|
|
84
|
-
(0, assert_1.default)(typeof isRepel === 'boolean');
|
|
85
|
-
if (isRepel) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
checker.fn(operation, context, {});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
93
|
-
finally {
|
|
94
|
-
try {
|
|
95
|
-
if (checkers2_1_1 && !checkers2_1_1.done && (_a = checkers2_1.return)) _a.call(checkers2_1);
|
|
96
|
-
}
|
|
97
|
-
finally { if (e_1) throw e_1.error; }
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
return SyncCheckerExecutor;
|
|
102
|
-
}());
|
|
103
|
-
exports.default = SyncCheckerExecutor;
|