oak-domain 2.6.2 → 2.6.4
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 +92 -89
- package/lib/entities/Modi.js +1 -0
- package/lib/entities/ModiEntity.js +1 -0
- package/lib/entities/Oper.js +1 -0
- package/lib/entities/OperEntity.js +1 -0
- package/lib/entities/User.js +1 -0
- package/lib/entities/UserEntityGrant.js +1 -0
- package/lib/store/AsyncRowStore.js +40 -42
- package/lib/store/CascadeStore.js +39 -33
- package/lib/store/checker.d.ts +2 -2
- package/lib/store/checker.js +516 -136
- package/lib/store/filter.js +7 -15
- package/lib/types/Auth.d.ts +10 -10
- package/lib/types/DataType.d.ts +4 -1
- package/lib/types/DataType.js +2 -1
- package/lib/types/Exception.d.ts +6 -0
- package/lib/types/Exception.js +25 -1
- package/lib/types/Locale.d.ts +1 -0
- package/lib/types/Polyfill.d.ts +1 -0
- package/lib/types/Storage.d.ts +1 -0
- package/lib/types/Style.d.ts +11 -0
- package/lib/types/Style.js +2 -0
- package/lib/types/Timer.d.ts +3 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/schema/DataTypes.d.ts +2 -0
- package/lib/utils/SimpleConnector.js +6 -5
- package/lib/utils/mask.d.ts +5 -0
- package/lib/utils/mask.js +35 -0
- package/lib/utils/money.d.ts +5 -0
- package/lib/utils/money.js +24 -0
- package/lib/utils/validator.d.ts +4 -2
- package/lib/utils/validator.js +8 -3
- package/package.json +3 -2
- package/src/entities/Modi.ts +1 -0
- package/src/entities/ModiEntity.ts +1 -0
- package/src/entities/Oper.ts +1 -0
- package/src/entities/OperEntity.ts +1 -0
- package/src/entities/User.ts +1 -0
- package/src/entities/UserEntityGrant.ts +1 -0
- package/lib/utils/cron.d.ts +0 -1
- package/lib/utils/cron.js +0 -18
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/DataType.d.ts
CHANGED
|
@@ -8,11 +8,14 @@ export declare type Text = string;
|
|
|
8
8
|
export declare type Image = string;
|
|
9
9
|
export declare type File = string;
|
|
10
10
|
export declare type Datetime = number | Date;
|
|
11
|
+
export declare type Day = number | Date;
|
|
12
|
+
export declare type Time = number | Date;
|
|
11
13
|
export declare type Boolean = boolean;
|
|
14
|
+
export declare type Price = number;
|
|
12
15
|
export declare type PrimaryKey = string;
|
|
13
16
|
export declare type ForeignKey<E extends string> = string;
|
|
14
17
|
export declare type Sequence = string;
|
|
15
18
|
export { Geo, SingleGeo } from './Geo';
|
|
16
|
-
export declare type DataTypes = number | string | Datetime | Geo | Object | SingleGeo;
|
|
19
|
+
export declare type DataTypes = number | string | Datetime | Day | Time | Geo | Object | SingleGeo;
|
|
17
20
|
export declare const types: string[];
|
|
18
21
|
export declare const unIndexedTypes: string[];
|
package/lib/types/DataType.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unIndexedTypes = exports.types = void 0;
|
|
4
|
-
exports.types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', '
|
|
4
|
+
exports.types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', 'Day', 'Time',
|
|
5
|
+
'Boolean', 'Image', 'File', 'Geo', 'SingleGeo', 'Price'];
|
|
5
6
|
exports.unIndexedTypes = ['Text', 'Image', 'File', 'Object'];
|
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/Locale.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ declare type LocaleOfValue<V extends Record<string, string>> = {
|
|
|
13
13
|
};
|
|
14
14
|
export declare type LocaleDef<Sc extends Record<string, any>, Ac extends string, R extends string, V extends Record<string, string>> = {
|
|
15
15
|
[L in Language]?: {
|
|
16
|
+
name: string;
|
|
16
17
|
attr: LocaleOfSchema<Sc> & {
|
|
17
18
|
[A in keyof V]: string;
|
|
18
19
|
};
|
package/lib/types/Polyfill.d.ts
CHANGED
package/lib/types/Storage.d.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EntityDict } from './Entity';
|
|
2
|
+
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
3
|
+
declare type ThemeColor = 'default' | 'success' | 'warning' | 'error';
|
|
4
|
+
export declare type ColorDict<ED extends BaseEntityDict & EntityDict> = {
|
|
5
|
+
[T in keyof ED]?: {
|
|
6
|
+
[A in keyof ED[T]['OpSchema']]?: {
|
|
7
|
+
[E in ED[T]['OpSchema'][A]]?: ThemeColor | `#${string}`;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export {};
|
package/lib/types/Timer.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { RecurrenceRule, RecurrenceSpecDateRange, RecurrenceSpecObjLit } from 'node-schedule';
|
|
1
2
|
import { EntityDict } from './Entity';
|
|
2
|
-
import { AsyncContext } from
|
|
3
|
+
import { AsyncContext } from '../store/AsyncRowStore';
|
|
3
4
|
declare type RoutineFn<ED extends EntityDict, Cxt extends AsyncContext<ED>> = (context: Cxt) => Promise<string>;
|
|
4
5
|
export declare type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
|
5
6
|
name: string;
|
|
@@ -7,7 +8,7 @@ export declare type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>>
|
|
|
7
8
|
};
|
|
8
9
|
export declare type Timer<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
|
9
10
|
name: string;
|
|
10
|
-
cron: string;
|
|
11
|
+
cron: RecurrenceRule | RecurrenceSpecDateRange | RecurrenceSpecObjLit | Date | string | number;
|
|
11
12
|
fn: RoutineFn<ED, Cxt>;
|
|
12
13
|
};
|
|
13
14
|
export {};
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -22,3 +22,4 @@ tslib_1.__exportStar(require("./Connector"), exports);
|
|
|
22
22
|
tslib_1.__exportStar(require("./Timer"), exports);
|
|
23
23
|
tslib_1.__exportStar(require("./Port"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./Endpoint"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./Style"), exports);
|
|
@@ -10,7 +10,7 @@ function makeContentTypeAndBody(data) {
|
|
|
10
10
|
if (process.env.OAK_PLATFORM !== 'wechatMp') {
|
|
11
11
|
if (data instanceof FormData) {
|
|
12
12
|
return {
|
|
13
|
-
contentType: 'multipart/form-data',
|
|
13
|
+
// contentType: 'multipart/form-data',
|
|
14
14
|
body: data,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
@@ -39,11 +39,12 @@ var SimpleConnector = /** @class */ (function (_super) {
|
|
|
39
39
|
_a = makeContentTypeAndBody(params), contentType = _a.contentType, body = _a.body;
|
|
40
40
|
return [4 /*yield*/, global.fetch(this.serverUrl, {
|
|
41
41
|
method: 'POST',
|
|
42
|
-
headers: {
|
|
43
|
-
'Content-Type': contentType,
|
|
42
|
+
headers: Object.assign({
|
|
44
43
|
'oak-cxt': cxtStr,
|
|
45
44
|
'oak-aspect': name,
|
|
46
|
-
},
|
|
45
|
+
}, contentType && {
|
|
46
|
+
'Content-Type': contentType,
|
|
47
|
+
}),
|
|
47
48
|
body: body,
|
|
48
49
|
})];
|
|
49
50
|
case 1:
|
|
@@ -106,7 +107,7 @@ var SimpleConnector = /** @class */ (function (_super) {
|
|
|
106
107
|
});
|
|
107
108
|
};
|
|
108
109
|
SimpleConnector.prototype.serializeResult = function (result, context, headers, body) {
|
|
109
|
-
if (result instanceof stream_1.Stream) {
|
|
110
|
+
if (result instanceof stream_1.Stream || result instanceof Buffer) {
|
|
110
111
|
return {
|
|
111
112
|
body: result,
|
|
112
113
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const maskIdCard: (idCardNumber: string) => string;
|
|
2
|
+
declare const maskMobile: (mobile: string) => string;
|
|
3
|
+
declare const maskName: (name: string) => string;
|
|
4
|
+
declare const maskStar: (str: string, front: number, end: number, star: string) => string;
|
|
5
|
+
export { maskIdCard, maskMobile, maskName, maskStar, };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maskStar = exports.maskName = exports.maskMobile = exports.maskIdCard = void 0;
|
|
4
|
+
var maskIdCard = function (idCardNumber) {
|
|
5
|
+
if (!idCardNumber instanceof String) {
|
|
6
|
+
throw new Error("身份证号码必须是String类型");
|
|
7
|
+
}
|
|
8
|
+
var begin = idCardNumber.slice(0, 4);
|
|
9
|
+
var end = idCardNumber.slice(idCardNumber.length - 4, 4);
|
|
10
|
+
for (var i = 0; i < idCardNumber.length - 8; i++) {
|
|
11
|
+
begin = begin.concat("*");
|
|
12
|
+
}
|
|
13
|
+
return begin.concat(end);
|
|
14
|
+
};
|
|
15
|
+
exports.maskIdCard = maskIdCard;
|
|
16
|
+
var maskMobile = function (mobile) {
|
|
17
|
+
var begin = mobile.slice(0, 3);
|
|
18
|
+
var end = mobile.slice(7, 11);
|
|
19
|
+
return begin.concat("****").concat(end);
|
|
20
|
+
};
|
|
21
|
+
exports.maskMobile = maskMobile;
|
|
22
|
+
var maskName = function (name) {
|
|
23
|
+
return name.slice(0, name.length - 1).concat("*");
|
|
24
|
+
};
|
|
25
|
+
exports.maskName = maskName;
|
|
26
|
+
var maskStar = function (str, frontLen, endLen, star) {
|
|
27
|
+
if (star === void 0) { star = '*'; }
|
|
28
|
+
var len = str.length - frontLen - endLen;
|
|
29
|
+
var xing = '';
|
|
30
|
+
for (var i = 0; i < len; i++) {
|
|
31
|
+
xing += star;
|
|
32
|
+
}
|
|
33
|
+
return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
|
|
34
|
+
};
|
|
35
|
+
exports.maskStar = maskStar;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const ToCent: (float: number) => number;
|
|
2
|
+
declare const ToYuan: (int: number) => number;
|
|
3
|
+
declare const StringToCent: (value: string, allowNegative?: true) => number | undefined;
|
|
4
|
+
declare const CentToString: (value: number) => string | undefined;
|
|
5
|
+
export { ToCent, ToYuan, StringToCent, CentToString, };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CentToString = exports.StringToCent = exports.ToYuan = exports.ToCent = void 0;
|
|
4
|
+
var ToCent = function (float) {
|
|
5
|
+
return Math.round(float * 100);
|
|
6
|
+
};
|
|
7
|
+
exports.ToCent = ToCent;
|
|
8
|
+
var ToYuan = function (int) {
|
|
9
|
+
return Math.round(int) / 100;
|
|
10
|
+
};
|
|
11
|
+
exports.ToYuan = ToYuan;
|
|
12
|
+
var StringToCent = function (value, allowNegative) {
|
|
13
|
+
var numValue = parseInt(value, 10);
|
|
14
|
+
if (typeof numValue === 'number' && (numValue >= 0 || allowNegative)) {
|
|
15
|
+
return ToCent(numValue);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.StringToCent = StringToCent;
|
|
19
|
+
var CentToString = function (value) {
|
|
20
|
+
if (typeof value === 'number') {
|
|
21
|
+
return "".concat(ToYuan(value));
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.CentToString = CentToString;
|
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;
|
|
@@ -15,9 +16,10 @@ export declare const isNickname: ValidatorFunction;
|
|
|
15
16
|
export declare const isSizedCaptcha: ValidatorFunction;
|
|
16
17
|
export declare const isDigital: ValidatorFunction;
|
|
17
18
|
export declare const isPhone: ValidatorFunction;
|
|
19
|
+
export declare const isTel: ValidatorFunction;
|
|
18
20
|
export declare const isNumber: ValidatorFunction;
|
|
19
21
|
export declare const isMoney: ValidatorMoneyFunction;
|
|
20
22
|
export declare const isVehicleNumber: ValidatorFunction;
|
|
21
|
-
export declare function checkAttributesNotNull<
|
|
22
|
-
export declare function checkAttributesScope<
|
|
23
|
+
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;
|
|
24
|
+
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
25
|
export {};
|
package/lib/utils/validator.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.checkAttributesScope = exports.checkAttributesNotNull = exports.isVehicleNumber = exports.isMoney = exports.isNumber = exports.isPhone = exports.isDigital = exports.isSizedCaptcha = exports.isNickname = exports.isUrl = exports.isSoldierNumber = exports.isBirthNumber = exports.isTwCardNumber = exports.isAmCardNumber = exports.isHkCardNumber = exports.isPassportNumber = exports.isIdCardNumber = exports.isCaptcha = exports.isPassword = exports.isMobile = void 0;
|
|
6
|
+
exports.checkAttributesScope = exports.checkAttributesNotNull = exports.isVehicleNumber = exports.isMoney = exports.isNumber = exports.isTel = exports.isPhone = exports.isDigital = exports.isSizedCaptcha = exports.isNickname = exports.isUrl = exports.isSoldierNumber = exports.isBirthNumber = exports.isTwCardNumber = exports.isAmCardNumber = exports.isHkCardNumber = exports.isPassportNumber = exports.isIdCardNumber = exports.isCaptcha = exports.isPassword = exports.isMobile = void 0;
|
|
7
7
|
var types_1 = require("../types");
|
|
8
8
|
var isMobile = function (text) {
|
|
9
9
|
return ((text) && (typeof text === "string") && ((/^1[3|4|5|6|7|8|9]\d{9}$/.test(text))));
|
|
@@ -79,14 +79,19 @@ var isPhone = function (phone) {
|
|
|
79
79
|
return /^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/.test(phone);
|
|
80
80
|
};
|
|
81
81
|
exports.isPhone = isPhone;
|
|
82
|
+
var isTel = function (text) {
|
|
83
|
+
// 1、133xxxx4545 2、0571-630xx239 3、400-123-1400
|
|
84
|
+
var reg = /^(((\d{3,4}-)?[0-9]{7,8})|(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}|((400)-(\d{3})-(\d{4})(.)(\d{1,4})|(400)-(\d{3})-(\d{4}$)|(400)(\d{3})(\d{4}$)|(400)-(\d{4})-(\d{3}$)))$/.test(text);
|
|
85
|
+
return reg;
|
|
86
|
+
};
|
|
87
|
+
exports.isTel = isTel;
|
|
82
88
|
var isNumber = function (str) {
|
|
83
89
|
return /^[0-9]*$/.test(str);
|
|
84
90
|
};
|
|
85
91
|
exports.isNumber = isNumber;
|
|
86
92
|
var isMoney = function (str, zero) {
|
|
87
|
-
// zero为true包含零
|
|
93
|
+
// 金额,最多可以有两位小数 zero为true包含零
|
|
88
94
|
if (zero) {
|
|
89
|
-
// 金额,最多可以有两位小数
|
|
90
95
|
return /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(str);
|
|
91
96
|
}
|
|
92
97
|
return /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/.test(str);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-domain",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.4",
|
|
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",
|
|
@@ -40,9 +41,9 @@
|
|
|
40
41
|
"typescript": "^4.7.4"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@datasert/cronjs-matcher": "^1.2.0",
|
|
44
44
|
"dayjs": "^1.11.5",
|
|
45
45
|
"lodash": "^4.17.21",
|
|
46
|
+
"node-schedule": "^2.1.1",
|
|
46
47
|
"uuid": "^9.0.0"
|
|
47
48
|
}
|
|
48
49
|
}
|
package/src/entities/Modi.ts
CHANGED
package/src/entities/Oper.ts
CHANGED
package/src/entities/User.ts
CHANGED
package/lib/utils/cron.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function schedule(cron: string, fn: (date: Date) => any): void;
|
package/lib/utils/cron.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.schedule = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var cronjs_matcher_1 = require("@datasert/cronjs-matcher");
|
|
6
|
-
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
7
|
-
function schedule(cron, fn) {
|
|
8
|
-
var futureMatches = (0, cronjs_matcher_1.getFutureMatches)(cron, {
|
|
9
|
-
matchCount: 1,
|
|
10
|
-
});
|
|
11
|
-
var date = (0, dayjs_1.default)(futureMatches[0]);
|
|
12
|
-
var interval = date.diff((0, dayjs_1.default)(), 'ms');
|
|
13
|
-
setTimeout(function () {
|
|
14
|
-
fn(new Date());
|
|
15
|
-
schedule(cron, fn);
|
|
16
|
-
}, interval);
|
|
17
|
-
}
|
|
18
|
-
exports.schedule = schedule;
|