oak-domain 4.0.1 → 4.0.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/actions/action.d.ts +16 -16
- package/lib/actions/action.js +17 -17
- package/lib/actions/relation.d.ts +5 -5
- package/lib/actions/relation.js +25 -25
- package/lib/base-app-domain/ActionAuth/Schema.d.ts +186 -186
- package/lib/base-app-domain/ActionAuth/Storage.js +39 -39
- package/lib/base-app-domain/ActionDefDict.d.ts +8 -8
- package/lib/base-app-domain/ActionDefDict.js +9 -9
- package/lib/base-app-domain/EntityDict.d.ts +28 -28
- package/lib/base-app-domain/I18n/Schema.d.ts +129 -129
- package/lib/base-app-domain/I18n/Schema.js +2 -2
- package/lib/base-app-domain/I18n/Storage.d.ts +3 -3
- package/lib/base-app-domain/I18n/Storage.js +59 -59
- package/lib/base-app-domain/Modi/Action.d.ts +10 -10
- package/lib/base-app-domain/Modi/Action.js +14 -14
- package/lib/base-app-domain/Modi/Schema.d.ts +136 -136
- package/lib/base-app-domain/Modi/Storage.js +63 -63
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +384 -384
- package/lib/base-app-domain/ModiEntity/Storage.js +30 -30
- package/lib/base-app-domain/Oper/Schema.d.ts +153 -153
- package/lib/base-app-domain/Oper/Storage.js +38 -38
- package/lib/base-app-domain/OperEntity/Schema.d.ts +373 -373
- package/lib/base-app-domain/OperEntity/Storage.js +30 -30
- package/lib/base-app-domain/Path/Schema.d.ts +149 -149
- package/lib/base-app-domain/Path/Schema.js +2 -2
- package/lib/base-app-domain/Path/Storage.d.ts +3 -3
- package/lib/base-app-domain/Path/Storage.js +54 -54
- package/lib/base-app-domain/Relation/Schema.d.ts +188 -188
- package/lib/base-app-domain/Relation/Storage.js +54 -54
- package/lib/base-app-domain/Relation.d.ts +2 -2
- package/lib/base-app-domain/Relation.js +4 -4
- package/lib/base-app-domain/RelationAuth/Schema.d.ts +214 -214
- package/lib/base-app-domain/RelationAuth/Storage.js +44 -44
- package/lib/base-app-domain/Storage.js +31 -31
- package/lib/base-app-domain/User/Action.d.ts +10 -10
- package/lib/base-app-domain/User/Action.js +12 -12
- package/lib/base-app-domain/User/Schema.d.ts +210 -210
- package/lib/base-app-domain/User/Storage.js +33 -33
- package/lib/base-app-domain/UserEntityClaim/Schema.d.ts +264 -264
- package/lib/base-app-domain/UserEntityClaim/Schema.js +2 -2
- package/lib/base-app-domain/UserEntityClaim/Storage.d.ts +3 -3
- package/lib/base-app-domain/UserEntityClaim/Storage.js +37 -37
- package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +131 -131
- package/lib/base-app-domain/UserEntityGrant/Storage.js +25 -25
- package/lib/base-app-domain/UserRelation/Schema.d.ts +208 -208
- package/lib/base-app-domain/UserRelation/Storage.js +56 -56
- package/lib/base-app-domain/_SubQuery.d.ts +142 -142
- package/lib/base-app-domain/index.d.ts +4 -4
- package/lib/base-app-domain/index.js +7 -7
- package/lib/checkers/index.d.ts +5 -5
- package/lib/checkers/index.js +13 -13
- package/lib/compiler/entities.d.ts +2 -2
- package/lib/compiler/entities.js +7 -7
- package/lib/compiler/env.d.ts +13 -13
- package/lib/compiler/env.js +45 -45
- package/lib/compiler/localeBuilder.d.ts +1 -1
- package/lib/compiler/localeBuilder.js +49 -18
- package/lib/compiler/routerBuilder.d.ts +1 -0
- package/lib/compiler/routerBuilder.js +263 -0
- package/lib/compiler/schemalBuilder.d.ts +27 -27
- package/lib/compiler/schemalBuilder.js +3565 -3565
- package/lib/entities/ActionAuth.d.ts +10 -10
- package/lib/entities/ActionAuth.js +31 -31
- package/lib/entities/I18n.d.ts +9 -9
- package/lib/entities/I18n.js +36 -36
- package/lib/entities/Modi.js +49 -49
- package/lib/entities/ModiEntity.js +18 -18
- package/lib/entities/Oper.js +21 -21
- package/lib/entities/OperEntity.js +18 -18
- package/lib/entities/Path.d.ts +8 -8
- package/lib/entities/Path.js +35 -35
- package/lib/entities/Relation.d.ts +8 -8
- package/lib/entities/Relation.js +35 -35
- package/lib/entities/RelationAuth.d.ts +8 -8
- package/lib/entities/RelationAuth.js +34 -34
- package/lib/entities/User.js +31 -31
- package/lib/entities/UserEntityClaim.d.ts +13 -13
- package/lib/entities/UserEntityClaim.js +17 -17
- package/lib/entities/UserEntityGrant.d.ts +9 -9
- package/lib/entities/UserEntityGrant.js +15 -15
- package/lib/entities/UserRelation.d.ts +10 -10
- package/lib/entities/UserRelation.js +38 -38
- package/lib/index.d.ts +23 -23
- package/lib/index.js +37 -37
- package/lib/store/AsyncRowStore.d.ts +65 -65
- package/lib/store/AsyncRowStore.js +9 -5
- package/lib/store/CascadeStore.d.ts +109 -106
- package/lib/store/CascadeStore.js +1748 -1740
- package/lib/store/RelationAuth.d.ts +7 -0
- package/lib/store/RelationAuth.js +11 -4
- package/lib/store/SyncRowStore.d.ts +29 -29
- package/lib/store/SyncRowStore.js +50 -50
- package/lib/store/TriggerExecutor.d.ts +41 -41
- package/lib/store/TriggerExecutor.js +468 -468
- package/lib/store/actionAuth.d.ts +4 -4
- package/lib/store/actionAuth.js +25 -25
- package/lib/store/actionDef.d.ts +10 -10
- package/lib/store/actionDef.js +278 -278
- package/lib/store/checker.d.ts +26 -26
- package/lib/store/checker.js +2 -2
- package/lib/store/filter.d.ts +85 -85
- package/lib/store/filter.js +1652 -1652
- package/lib/store/modi.d.ts +13 -13
- package/lib/store/modi.js +254 -254
- package/lib/store/relation.d.ts +12 -12
- package/lib/store/relation.js +67 -67
- package/lib/timers/oper.d.ts +18 -18
- package/lib/timers/oper.js +57 -57
- package/lib/timers/vaccum.d.ts +20 -20
- package/lib/timers/vaccum.js +111 -111
- package/lib/triggers/index.d.ts +5 -5
- package/lib/triggers/index.js +8 -8
- package/lib/types/Action.d.ts +20 -20
- package/lib/types/AppLoader.d.ts +17 -17
- package/lib/types/AppLoader.js +10 -10
- package/lib/types/Auth.d.ts +70 -70
- package/lib/types/Cluster.d.ts +5 -5
- package/lib/types/Cluster.js +2 -2
- package/lib/types/Connector.d.ts +38 -38
- package/lib/types/Connector.js +2 -2
- package/lib/types/DataType.d.ts +25 -25
- package/lib/types/DataType.js +6 -6
- package/lib/types/Demand.d.ts +89 -89
- package/lib/types/Demand.js +10 -10
- package/lib/types/Endpoint.d.ts +11 -11
- package/lib/types/Entity.d.ts +209 -209
- package/lib/types/Entity.js +15 -15
- package/lib/types/EntityDesc.d.ts +9 -9
- package/lib/types/EntityDesc.js +2 -2
- package/lib/types/Environment.d.ts +90 -90
- package/lib/types/Environment.js +2 -2
- package/lib/types/Exception.d.ts +10 -2
- package/lib/types/Exception.js +32 -2
- package/lib/types/Expression.d.ts +163 -163
- package/lib/types/Expression.js +397 -397
- package/lib/types/Geo.d.ts +18 -18
- package/lib/types/Locale.d.ts +25 -25
- package/lib/types/Logger.d.ts +6 -6
- package/lib/types/Polyfill.d.ts +24 -24
- package/lib/types/Port.d.ts +18 -18
- package/lib/types/RowStore.d.ts +19 -19
- package/lib/types/RowStore.js +33 -33
- package/lib/types/Storage.d.ts +58 -58
- package/lib/types/Style.d.ts +11 -11
- package/lib/types/Timer.d.ts +20 -20
- package/lib/types/Trigger.d.ts +118 -118
- package/lib/types/Trigger.js +35 -35
- package/lib/types/Watcher.d.ts +19 -19
- package/lib/types/index.d.ts +26 -26
- package/lib/types/index.js +29 -29
- package/lib/types/schema/DataTypes.d.ts +34 -34
- package/lib/utils/SimpleConnector.d.ts +64 -64
- package/lib/utils/SimpleConnector.js +206 -206
- package/lib/utils/assert.d.ts +6 -5
- package/lib/utils/assert.js +9 -9
- package/lib/utils/concurrent.d.ts +15 -15
- package/lib/utils/concurrent.js +63 -63
- package/lib/utils/date.js +18 -18
- package/lib/utils/domain.d.ts +1 -1
- package/lib/utils/domain.js +11 -11
- package/lib/utils/geo.js +24 -24
- package/lib/utils/lodash.d.ts +24 -24
- package/lib/utils/lodash.js +46 -46
- package/lib/utils/mask.js +34 -34
- package/lib/utils/money.d.ts +6 -6
- package/lib/utils/money.js +51 -51
- package/lib/utils/projection.d.ts +4 -4
- package/lib/utils/projection.js +15 -15
- package/lib/utils/random/random.js +19 -19
- package/lib/utils/random/random.mp.js +14 -14
- package/lib/utils/random/random.native.d.ts +1 -1
- package/lib/utils/random/random.native.js +14 -14
- package/lib/utils/random/random.web.js +11 -11
- package/lib/utils/string.d.ts +28 -28
- package/lib/utils/string.js +69 -69
- package/lib/utils/url/index.d.ts +7 -7
- package/lib/utils/url/index.js +8 -8
- package/lib/utils/url/index.mp.d.ts +3 -3
- package/lib/utils/url/index.mp.js +8 -8
- package/lib/utils/url/index.native.d.ts +12 -12
- package/lib/utils/url/index.native.js +7 -7
- package/lib/utils/url/index.web.d.ts +12 -12
- package/lib/utils/url/index.web.js +7 -7
- package/lib/utils/url/whatwg-url/index.d.ts +3 -3
- package/lib/utils/url/whatwg-url/index.js +16 -16
- package/lib/utils/url/whatwg-url/lib/URL-impl.d.ts +20 -20
- package/lib/utils/url/whatwg-url/lib/URL-impl.js +175 -175
- package/lib/utils/url/whatwg-url/lib/URL.d.ts +1 -1
- package/lib/utils/url/whatwg-url/lib/URL.js +298 -298
- package/lib/utils/url/whatwg-url/lib/URLSearchParams-impl.d.ts +19 -19
- package/lib/utils/url/whatwg-url/lib/URLSearchParams-impl.js +126 -126
- package/lib/utils/url/whatwg-url/lib/URLSearchParams.d.ts +1 -1
- package/lib/utils/url/whatwg-url/lib/URLSearchParams.js +426 -426
- package/lib/utils/url/whatwg-url/lib/infra.d.ts +12 -12
- package/lib/utils/url/whatwg-url/lib/infra.js +25 -25
- package/lib/utils/url/whatwg-url/lib/url-state-machine.d.ts +24 -24
- package/lib/utils/url/whatwg-url/lib/url-state-machine.js +1238 -1238
- package/lib/utils/url/whatwg-url/lib/urlencoded.d.ts +15 -15
- package/lib/utils/url/whatwg-url/lib/urlencoded.js +162 -162
- package/lib/utils/url/whatwg-url/lib/utils.d.ts +37 -37
- package/lib/utils/url/whatwg-url/lib/utils.js +101 -101
- package/lib/utils/uuid.d.ts +17 -17
- package/lib/utils/uuid.js +218 -218
- package/lib/utils/validator.d.ts +26 -26
- package/lib/utils/validator.js +131 -131
- package/lib/utils/version.js +21 -21
- package/package.json +2 -1
package/lib/utils/validator.js
CHANGED
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Xc on 2018/12/23.
|
|
3
|
-
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.checkAttributesScope = exports.checkAttributesNotNull = exports.isEmail = 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
|
-
const types_1 = require("../types");
|
|
8
|
-
const isMobile = (text) => {
|
|
9
|
-
return ((text) && (typeof text === "string") && ((/^1[3|4|5|6|7|8|9]\d{9}$/.test(text))));
|
|
10
|
-
};
|
|
11
|
-
exports.isMobile = isMobile;
|
|
12
|
-
const isPassword = (text) => {
|
|
13
|
-
return ((text) && (typeof text === "string") && (/^[a-zA-Z0-9!.@]{8,16}$/.test(text)));
|
|
14
|
-
};
|
|
15
|
-
exports.isPassword = isPassword;
|
|
16
|
-
const isCaptcha = (text) => {
|
|
17
|
-
return ((text) && (typeof text === "string") && (/^\d{4}$/.test(text)));
|
|
18
|
-
};
|
|
19
|
-
exports.isCaptcha = isCaptcha;
|
|
20
|
-
const isIdCardNumber = (text) => {
|
|
21
|
-
return ((typeof text === "string") && text.length === 18 && (/^\d{6}(18|19|20)\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(text)));
|
|
22
|
-
};
|
|
23
|
-
exports.isIdCardNumber = isIdCardNumber;
|
|
24
|
-
const isPassportNumber = (text) => {
|
|
25
|
-
// 护照
|
|
26
|
-
// 规则: 14/15开头 + 7位数字, G + 8位数字, P + 7位数字, S/D + 7或8位数字,等
|
|
27
|
-
// 样本: 141234567, G12345678, P1234567
|
|
28
|
-
return typeof text === 'string' && /^([a-zA-z]|[0-9]){5,17}$/.test(text);
|
|
29
|
-
};
|
|
30
|
-
exports.isPassportNumber = isPassportNumber;
|
|
31
|
-
const isHkCardNumber = (text) => {
|
|
32
|
-
// 港澳居民来往内地通行证
|
|
33
|
-
// 规则: H/M + 10位或6位数字
|
|
34
|
-
// 样本: H1234567890
|
|
35
|
-
return typeof text === 'string' && /^([A-Z]\d{6,10}(\(\w{1}\))?)$/.test(text);
|
|
36
|
-
};
|
|
37
|
-
exports.isHkCardNumber = isHkCardNumber;
|
|
38
|
-
const isAmCardNumber = (text) => {
|
|
39
|
-
return typeof text === 'string' && /^([A-Z]\d{6,10}(\(\w{1}\))?)$/.test(text);
|
|
40
|
-
};
|
|
41
|
-
exports.isAmCardNumber = isAmCardNumber;
|
|
42
|
-
const isTwCardNumber = (text) => {
|
|
43
|
-
// 台湾居民来往大陆通行证
|
|
44
|
-
// 规则: 新版8位或18位数字, 旧版10位数字 + 英文字母
|
|
45
|
-
// 样本: 12345678 或 1234567890B
|
|
46
|
-
return typeof text === 'string' && /^\d{8}|^[a-zA-Z0-9]{10}|^\d{18}$/.test(text);
|
|
47
|
-
};
|
|
48
|
-
exports.isTwCardNumber = isTwCardNumber;
|
|
49
|
-
const isBirthNumber = (text) => {
|
|
50
|
-
return typeof text === 'string' && /^[a-zA-Z0-9]{5,21}$/.test(text);
|
|
51
|
-
};
|
|
52
|
-
exports.isBirthNumber = isBirthNumber;
|
|
53
|
-
const isSoldierNumber = (text) => {
|
|
54
|
-
// 军官证
|
|
55
|
-
// 规则: 军/兵/士/文/职/广/(其他中文) + "字第" + 4到8位字母或数字 + "号"
|
|
56
|
-
// 样本: 军字第2001988号, 士字第P011816X号
|
|
57
|
-
return typeof text === 'string' && /^[\u4E00-\u9FA5](字第)([0-9a-zA-Z]{4,8})(号?)$/.test(text);
|
|
58
|
-
};
|
|
59
|
-
exports.isSoldierNumber = isSoldierNumber;
|
|
60
|
-
const isUrl = (str) => {
|
|
61
|
-
const regex = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
|
|
62
|
-
return typeof str === "string" && regex.test(str);
|
|
63
|
-
};
|
|
64
|
-
exports.isUrl = isUrl;
|
|
65
|
-
const isNickname = (str) => {
|
|
66
|
-
return str && typeof str === "string" && str.trim().length > 0 && str.length < 16;
|
|
67
|
-
};
|
|
68
|
-
exports.isNickname = isNickname;
|
|
69
|
-
const isSizedCaptcha = (text, size) => {
|
|
70
|
-
return typeof text === 'string' && text.length === size && !isNaN(parseInt(text, 10));
|
|
71
|
-
};
|
|
72
|
-
exports.isSizedCaptcha = isSizedCaptcha;
|
|
73
|
-
const isDigital = (digital) => {
|
|
74
|
-
return /^\d{6,12}$/.test(digital);
|
|
75
|
-
};
|
|
76
|
-
exports.isDigital = isDigital;
|
|
77
|
-
const isPhone = (phone) => {
|
|
78
|
-
// return /^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/.test(phone);
|
|
79
|
-
return /^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/.test(phone);
|
|
80
|
-
};
|
|
81
|
-
exports.isPhone = isPhone;
|
|
82
|
-
const isTel = (text) => {
|
|
83
|
-
// 1、133xxxx4545 2、0571-630xx239 3、400-123-1400
|
|
84
|
-
const 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;
|
|
88
|
-
const isNumber = (str) => {
|
|
89
|
-
return /^[0-9]*$/.test(str);
|
|
90
|
-
};
|
|
91
|
-
exports.isNumber = isNumber;
|
|
92
|
-
const isMoney = (str, disableZero) => {
|
|
93
|
-
// 金额,最多可以有两位小数 默认包含零
|
|
94
|
-
if (disableZero) {
|
|
95
|
-
return /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/.test(str);
|
|
96
|
-
}
|
|
97
|
-
return /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(str);
|
|
98
|
-
};
|
|
99
|
-
exports.isMoney = isMoney;
|
|
100
|
-
const isVehicleNumber = (str) => {
|
|
101
|
-
const reg = /^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/;
|
|
102
|
-
return reg.test(str);
|
|
103
|
-
};
|
|
104
|
-
exports.isVehicleNumber = isVehicleNumber;
|
|
105
|
-
const isEmail = (str) => {
|
|
106
|
-
const reg = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
107
|
-
return reg.test(str);
|
|
108
|
-
};
|
|
109
|
-
exports.isEmail = isEmail;
|
|
110
|
-
function checkAttributesNotNull(entity, data, attributes, allowEmpty) {
|
|
111
|
-
const attrs = attributes.filter((attr) => {
|
|
112
|
-
if (data[attr] === null || data[attr] === '' || data[attr] === undefined) {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
if (!allowEmpty && !data.hasOwnProperty(attr)) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
if (attrs.length > 0) {
|
|
120
|
-
throw new types_1.OakAttrNotNullException(entity, attrs, '属性不能为空');
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.checkAttributesNotNull = checkAttributesNotNull;
|
|
124
|
-
;
|
|
125
|
-
function checkAttributesScope(entity, data, attributes) {
|
|
126
|
-
const attrs = attributes.filter(attr => !data.hasOwnProperty(attr));
|
|
127
|
-
if (attrs.length > 0) {
|
|
128
|
-
throw new types_1.OakInputIllegalException(entity, attrs, '多余的属性');
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.checkAttributesScope = checkAttributesScope;
|
|
1
|
+
/**
|
|
2
|
+
* Created by Xc on 2018/12/23.
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkAttributesScope = exports.checkAttributesNotNull = exports.isEmail = 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
|
+
const types_1 = require("../types");
|
|
8
|
+
const isMobile = (text) => {
|
|
9
|
+
return ((text) && (typeof text === "string") && ((/^1[3|4|5|6|7|8|9]\d{9}$/.test(text))));
|
|
10
|
+
};
|
|
11
|
+
exports.isMobile = isMobile;
|
|
12
|
+
const isPassword = (text) => {
|
|
13
|
+
return ((text) && (typeof text === "string") && (/^[a-zA-Z0-9!.@]{8,16}$/.test(text)));
|
|
14
|
+
};
|
|
15
|
+
exports.isPassword = isPassword;
|
|
16
|
+
const isCaptcha = (text) => {
|
|
17
|
+
return ((text) && (typeof text === "string") && (/^\d{4}$/.test(text)));
|
|
18
|
+
};
|
|
19
|
+
exports.isCaptcha = isCaptcha;
|
|
20
|
+
const isIdCardNumber = (text) => {
|
|
21
|
+
return ((typeof text === "string") && text.length === 18 && (/^\d{6}(18|19|20)\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(text)));
|
|
22
|
+
};
|
|
23
|
+
exports.isIdCardNumber = isIdCardNumber;
|
|
24
|
+
const isPassportNumber = (text) => {
|
|
25
|
+
// 护照
|
|
26
|
+
// 规则: 14/15开头 + 7位数字, G + 8位数字, P + 7位数字, S/D + 7或8位数字,等
|
|
27
|
+
// 样本: 141234567, G12345678, P1234567
|
|
28
|
+
return typeof text === 'string' && /^([a-zA-z]|[0-9]){5,17}$/.test(text);
|
|
29
|
+
};
|
|
30
|
+
exports.isPassportNumber = isPassportNumber;
|
|
31
|
+
const isHkCardNumber = (text) => {
|
|
32
|
+
// 港澳居民来往内地通行证
|
|
33
|
+
// 规则: H/M + 10位或6位数字
|
|
34
|
+
// 样本: H1234567890
|
|
35
|
+
return typeof text === 'string' && /^([A-Z]\d{6,10}(\(\w{1}\))?)$/.test(text);
|
|
36
|
+
};
|
|
37
|
+
exports.isHkCardNumber = isHkCardNumber;
|
|
38
|
+
const isAmCardNumber = (text) => {
|
|
39
|
+
return typeof text === 'string' && /^([A-Z]\d{6,10}(\(\w{1}\))?)$/.test(text);
|
|
40
|
+
};
|
|
41
|
+
exports.isAmCardNumber = isAmCardNumber;
|
|
42
|
+
const isTwCardNumber = (text) => {
|
|
43
|
+
// 台湾居民来往大陆通行证
|
|
44
|
+
// 规则: 新版8位或18位数字, 旧版10位数字 + 英文字母
|
|
45
|
+
// 样本: 12345678 或 1234567890B
|
|
46
|
+
return typeof text === 'string' && /^\d{8}|^[a-zA-Z0-9]{10}|^\d{18}$/.test(text);
|
|
47
|
+
};
|
|
48
|
+
exports.isTwCardNumber = isTwCardNumber;
|
|
49
|
+
const isBirthNumber = (text) => {
|
|
50
|
+
return typeof text === 'string' && /^[a-zA-Z0-9]{5,21}$/.test(text);
|
|
51
|
+
};
|
|
52
|
+
exports.isBirthNumber = isBirthNumber;
|
|
53
|
+
const isSoldierNumber = (text) => {
|
|
54
|
+
// 军官证
|
|
55
|
+
// 规则: 军/兵/士/文/职/广/(其他中文) + "字第" + 4到8位字母或数字 + "号"
|
|
56
|
+
// 样本: 军字第2001988号, 士字第P011816X号
|
|
57
|
+
return typeof text === 'string' && /^[\u4E00-\u9FA5](字第)([0-9a-zA-Z]{4,8})(号?)$/.test(text);
|
|
58
|
+
};
|
|
59
|
+
exports.isSoldierNumber = isSoldierNumber;
|
|
60
|
+
const isUrl = (str) => {
|
|
61
|
+
const regex = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
|
|
62
|
+
return typeof str === "string" && regex.test(str);
|
|
63
|
+
};
|
|
64
|
+
exports.isUrl = isUrl;
|
|
65
|
+
const isNickname = (str) => {
|
|
66
|
+
return str && typeof str === "string" && str.trim().length > 0 && str.length < 16;
|
|
67
|
+
};
|
|
68
|
+
exports.isNickname = isNickname;
|
|
69
|
+
const isSizedCaptcha = (text, size) => {
|
|
70
|
+
return typeof text === 'string' && text.length === size && !isNaN(parseInt(text, 10));
|
|
71
|
+
};
|
|
72
|
+
exports.isSizedCaptcha = isSizedCaptcha;
|
|
73
|
+
const isDigital = (digital) => {
|
|
74
|
+
return /^\d{6,12}$/.test(digital);
|
|
75
|
+
};
|
|
76
|
+
exports.isDigital = isDigital;
|
|
77
|
+
const isPhone = (phone) => {
|
|
78
|
+
// return /^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/.test(phone);
|
|
79
|
+
return /^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/.test(phone);
|
|
80
|
+
};
|
|
81
|
+
exports.isPhone = isPhone;
|
|
82
|
+
const isTel = (text) => {
|
|
83
|
+
// 1、133xxxx4545 2、0571-630xx239 3、400-123-1400
|
|
84
|
+
const 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;
|
|
88
|
+
const isNumber = (str) => {
|
|
89
|
+
return /^[0-9]*$/.test(str);
|
|
90
|
+
};
|
|
91
|
+
exports.isNumber = isNumber;
|
|
92
|
+
const isMoney = (str, disableZero) => {
|
|
93
|
+
// 金额,最多可以有两位小数 默认包含零
|
|
94
|
+
if (disableZero) {
|
|
95
|
+
return /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/.test(str);
|
|
96
|
+
}
|
|
97
|
+
return /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(str);
|
|
98
|
+
};
|
|
99
|
+
exports.isMoney = isMoney;
|
|
100
|
+
const isVehicleNumber = (str) => {
|
|
101
|
+
const reg = /^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/;
|
|
102
|
+
return reg.test(str);
|
|
103
|
+
};
|
|
104
|
+
exports.isVehicleNumber = isVehicleNumber;
|
|
105
|
+
const isEmail = (str) => {
|
|
106
|
+
const reg = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
107
|
+
return reg.test(str);
|
|
108
|
+
};
|
|
109
|
+
exports.isEmail = isEmail;
|
|
110
|
+
function checkAttributesNotNull(entity, data, attributes, allowEmpty) {
|
|
111
|
+
const attrs = attributes.filter((attr) => {
|
|
112
|
+
if (data[attr] === null || data[attr] === '' || data[attr] === undefined) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (!allowEmpty && !data.hasOwnProperty(attr)) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
if (attrs.length > 0) {
|
|
120
|
+
throw new types_1.OakAttrNotNullException(entity, attrs, '属性不能为空');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.checkAttributesNotNull = checkAttributesNotNull;
|
|
124
|
+
;
|
|
125
|
+
function checkAttributesScope(entity, data, attributes) {
|
|
126
|
+
const attrs = attributes.filter(attr => !data.hasOwnProperty(attr));
|
|
127
|
+
if (attrs.length > 0) {
|
|
128
|
+
throw new types_1.OakInputIllegalException(entity, attrs, '多余的属性');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.checkAttributesScope = checkAttributesScope;
|
package/lib/utils/version.js
CHANGED
|
@@ -1,21 +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
|
-
const compareVersion = (curVersion, reqVersion) => {
|
|
11
|
-
const v1 = curVersion.split('.');
|
|
12
|
-
const v2 = reqVersion.split('.');
|
|
13
|
-
for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
|
|
14
|
-
const num1 = i < v1.length ? parseInt(v1[i], 10) : 0;
|
|
15
|
-
const 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;
|
|
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
|
+
const compareVersion = (curVersion, reqVersion) => {
|
|
11
|
+
const v1 = curVersion.split('.');
|
|
12
|
+
const v2 = reqVersion.split('.');
|
|
13
|
+
for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
|
|
14
|
+
const num1 = i < v1.length ? parseInt(v1[i], 10) : 0;
|
|
15
|
+
const 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-domain",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "XuChang"
|
|
6
6
|
},
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"fs-extra": "^10.0.0",
|
|
38
38
|
"lodash": "^4.17.21",
|
|
39
39
|
"mocha": "^8.2.1",
|
|
40
|
+
"node-watch": "^0.7.4",
|
|
40
41
|
"ts-node": "^10.9.1",
|
|
41
42
|
"tslib": "^2.4.0",
|
|
42
43
|
"typescript": "^5.2.2"
|