oak-domain 3.0.4 → 4.0.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.
Files changed (202) hide show
  1. package/lib/actions/action.d.ts +16 -16
  2. package/lib/actions/action.js +17 -17
  3. package/lib/actions/relation.d.ts +5 -5
  4. package/lib/actions/relation.js +25 -25
  5. package/lib/base-app-domain/ActionAuth/Schema.d.ts +186 -186
  6. package/lib/base-app-domain/ActionAuth/Storage.js +39 -39
  7. package/lib/base-app-domain/ActionDefDict.d.ts +8 -8
  8. package/lib/base-app-domain/ActionDefDict.js +9 -9
  9. package/lib/base-app-domain/EntityDict.d.ts +28 -28
  10. package/lib/base-app-domain/I18n/Schema.d.ts +129 -129
  11. package/lib/base-app-domain/I18n/Schema.js +2 -2
  12. package/lib/base-app-domain/I18n/Storage.d.ts +3 -3
  13. package/lib/base-app-domain/I18n/Storage.js +59 -59
  14. package/lib/base-app-domain/Modi/Action.d.ts +10 -10
  15. package/lib/base-app-domain/Modi/Action.js +14 -14
  16. package/lib/base-app-domain/Modi/Schema.d.ts +136 -136
  17. package/lib/base-app-domain/Modi/Storage.js +63 -63
  18. package/lib/base-app-domain/ModiEntity/Schema.d.ts +384 -384
  19. package/lib/base-app-domain/ModiEntity/Storage.js +30 -30
  20. package/lib/base-app-domain/Oper/Schema.d.ts +153 -153
  21. package/lib/base-app-domain/Oper/Storage.js +38 -38
  22. package/lib/base-app-domain/OperEntity/Schema.d.ts +373 -373
  23. package/lib/base-app-domain/OperEntity/Storage.js +30 -30
  24. package/lib/base-app-domain/Path/Schema.d.ts +149 -149
  25. package/lib/base-app-domain/Path/Schema.js +2 -2
  26. package/lib/base-app-domain/Path/Storage.d.ts +3 -3
  27. package/lib/base-app-domain/Path/Storage.js +54 -54
  28. package/lib/base-app-domain/Relation/Schema.d.ts +188 -188
  29. package/lib/base-app-domain/Relation/Storage.js +54 -54
  30. package/lib/base-app-domain/Relation.d.ts +2 -2
  31. package/lib/base-app-domain/Relation.js +4 -4
  32. package/lib/base-app-domain/RelationAuth/Schema.d.ts +214 -214
  33. package/lib/base-app-domain/RelationAuth/Storage.js +44 -44
  34. package/lib/base-app-domain/Storage.js +31 -31
  35. package/lib/base-app-domain/User/Action.d.ts +10 -10
  36. package/lib/base-app-domain/User/Action.js +12 -12
  37. package/lib/base-app-domain/User/Schema.d.ts +210 -210
  38. package/lib/base-app-domain/User/Storage.js +33 -33
  39. package/lib/base-app-domain/UserEntityClaim/Schema.d.ts +264 -264
  40. package/lib/base-app-domain/UserEntityClaim/Schema.js +2 -2
  41. package/lib/base-app-domain/UserEntityClaim/Storage.d.ts +3 -3
  42. package/lib/base-app-domain/UserEntityClaim/Storage.js +37 -37
  43. package/lib/base-app-domain/UserEntityGrant/Action.d.ts +5 -5
  44. package/lib/base-app-domain/UserEntityGrant/Action.js +5 -5
  45. package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +131 -131
  46. package/lib/base-app-domain/UserEntityGrant/Storage.js +25 -25
  47. package/lib/base-app-domain/UserRelation/Schema.d.ts +208 -208
  48. package/lib/base-app-domain/UserRelation/Storage.js +56 -56
  49. package/lib/base-app-domain/_SubQuery.d.ts +142 -142
  50. package/lib/base-app-domain/index.d.ts +4 -4
  51. package/lib/base-app-domain/index.js +7 -7
  52. package/lib/checkers/index.d.ts +5 -5
  53. package/lib/checkers/index.js +13 -13
  54. package/lib/compiler/entities.d.ts +2 -0
  55. package/lib/compiler/entities.js +7 -0
  56. package/lib/compiler/env.d.ts +13 -14
  57. package/lib/compiler/env.js +45 -48
  58. package/lib/compiler/localeBuilder.d.ts +27 -22
  59. package/lib/compiler/localeBuilder.js +184 -173
  60. package/lib/compiler/schemalBuilder.d.ts +27 -27
  61. package/lib/compiler/schemalBuilder.js +3569 -3569
  62. package/lib/entities/ActionAuth.d.ts +10 -10
  63. package/lib/entities/ActionAuth.js +31 -31
  64. package/lib/entities/I18n.d.ts +9 -9
  65. package/lib/entities/I18n.js +36 -37
  66. package/lib/entities/Modi.js +49 -49
  67. package/lib/entities/ModiEntity.js +18 -18
  68. package/lib/entities/Oper.js +21 -21
  69. package/lib/entities/OperEntity.js +18 -18
  70. package/lib/entities/Path.d.ts +8 -8
  71. package/lib/entities/Path.js +35 -35
  72. package/lib/entities/Relation.d.ts +8 -8
  73. package/lib/entities/Relation.js +35 -35
  74. package/lib/entities/RelationAuth.d.ts +8 -8
  75. package/lib/entities/RelationAuth.js +34 -34
  76. package/lib/entities/User.js +31 -31
  77. package/lib/entities/UserEntityClaim.d.ts +13 -13
  78. package/lib/entities/UserEntityClaim.js +17 -17
  79. package/lib/entities/UserEntityGrant.d.ts +9 -9
  80. package/lib/entities/UserEntityGrant.js +15 -15
  81. package/lib/entities/UserRelation.d.ts +10 -10
  82. package/lib/entities/UserRelation.js +38 -38
  83. package/lib/index.d.ts +23 -23
  84. package/lib/index.js +37 -37
  85. package/lib/store/AsyncRowStore.d.ts +60 -59
  86. package/lib/store/AsyncRowStore.js +118 -116
  87. package/lib/store/CascadeStore.d.ts +104 -103
  88. package/lib/store/CascadeStore.js +1688 -1662
  89. package/lib/store/RelationAuth.d.ts +96 -96
  90. package/lib/store/RelationAuth.js +1336 -1334
  91. package/lib/store/SyncRowStore.d.ts +29 -29
  92. package/lib/store/SyncRowStore.js +50 -50
  93. package/lib/store/TriggerExecutor.d.ts +38 -38
  94. package/lib/store/TriggerExecutor.js +459 -459
  95. package/lib/store/actionAuth.d.ts +4 -4
  96. package/lib/store/actionAuth.js +25 -25
  97. package/lib/store/actionDef.d.ts +10 -10
  98. package/lib/store/actionDef.js +278 -278
  99. package/lib/store/checker.d.ts +26 -26
  100. package/lib/store/checker.js +487 -487
  101. package/lib/store/filter.d.ts +85 -122
  102. package/lib/store/filter.js +1651 -1623
  103. package/lib/store/modi.d.ts +13 -13
  104. package/lib/store/modi.js +254 -254
  105. package/lib/store/relation.d.ts +12 -12
  106. package/lib/store/relation.js +67 -67
  107. package/lib/timers/oper.d.ts +18 -18
  108. package/lib/timers/oper.js +57 -57
  109. package/lib/timers/vaccum.d.ts +20 -20
  110. package/lib/timers/vaccum.js +111 -111
  111. package/lib/triggers/index.d.ts +5 -5
  112. package/lib/triggers/index.js +8 -8
  113. package/lib/types/Action.d.ts +20 -20
  114. package/lib/types/AppLoader.d.ts +17 -17
  115. package/lib/types/AppLoader.js +10 -10
  116. package/lib/types/Auth.d.ts +70 -70
  117. package/lib/types/Cluster.d.ts +5 -0
  118. package/lib/types/Cluster.js +2 -0
  119. package/lib/types/Connector.d.ts +38 -38
  120. package/lib/types/Connector.js +2 -2
  121. package/lib/types/DataType.d.ts +25 -25
  122. package/lib/types/DataType.js +6 -6
  123. package/lib/types/Demand.d.ts +88 -88
  124. package/lib/types/Demand.js +10 -10
  125. package/lib/types/Endpoint.d.ts +11 -11
  126. package/lib/types/Entity.d.ts +203 -202
  127. package/lib/types/Entity.js +15 -15
  128. package/lib/types/EntityDesc.d.ts +9 -9
  129. package/lib/types/EntityDesc.js +2 -2
  130. package/lib/types/Environment.d.ts +88 -57
  131. package/lib/types/Environment.js +2 -2
  132. package/lib/types/Exception.d.ts +147 -147
  133. package/lib/types/Exception.js +406 -406
  134. package/lib/types/Expression.d.ts +163 -163
  135. package/lib/types/Expression.js +397 -394
  136. package/lib/types/Geo.d.ts +18 -18
  137. package/lib/types/Locale.d.ts +25 -25
  138. package/lib/types/Logger.d.ts +6 -6
  139. package/lib/types/Polyfill.d.ts +24 -24
  140. package/lib/types/Port.d.ts +18 -18
  141. package/lib/types/RowStore.d.ts +18 -18
  142. package/lib/types/RowStore.js +33 -33
  143. package/lib/types/Storage.d.ts +58 -58
  144. package/lib/types/Style.d.ts +11 -11
  145. package/lib/types/Timer.d.ts +14 -14
  146. package/lib/types/Trigger.d.ts +124 -124
  147. package/lib/types/Trigger.js +58 -58
  148. package/lib/types/Watcher.d.ts +19 -19
  149. package/lib/types/index.d.ts +26 -25
  150. package/lib/types/index.js +29 -28
  151. package/lib/types/schema/DataTypes.d.ts +34 -34
  152. package/lib/utils/SimpleConnector.d.ts +64 -64
  153. package/lib/utils/SimpleConnector.js +206 -206
  154. package/lib/utils/assert.d.ts +5 -5
  155. package/lib/utils/assert.js +9 -9
  156. package/lib/utils/concurrent.d.ts +15 -15
  157. package/lib/utils/concurrent.js +63 -63
  158. package/lib/utils/date.js +18 -18
  159. package/lib/utils/{url.d.ts → domain.d.ts} +1 -1
  160. package/lib/utils/{url.js → domain.js} +11 -13
  161. package/lib/utils/geo.js +24 -24
  162. package/lib/utils/lodash.d.ts +24 -22
  163. package/lib/utils/lodash.js +46 -42
  164. package/lib/utils/mask.js +34 -34
  165. package/lib/utils/money.d.ts +6 -6
  166. package/lib/utils/money.js +51 -51
  167. package/lib/utils/projection.d.ts +4 -4
  168. package/lib/utils/projection.js +15 -15
  169. package/lib/utils/random/random.js +19 -19
  170. package/lib/utils/random/random.mp.js +14 -14
  171. package/lib/utils/random/random.native.d.ts +1 -0
  172. package/lib/utils/random/random.native.js +14 -0
  173. package/lib/utils/random/random.web.js +11 -11
  174. package/lib/utils/string.d.ts +28 -28
  175. package/lib/utils/string.js +69 -69
  176. package/lib/utils/url/index.d.ts +7 -0
  177. package/lib/utils/url/index.js +8 -0
  178. package/lib/utils/url/index.mp.d.ts +4 -0
  179. package/lib/utils/url/index.mp.js +8 -0
  180. package/lib/utils/url/index.native.d.ts +12 -0
  181. package/lib/utils/url/index.native.js +7 -0
  182. package/lib/utils/url/index.web.d.ts +12 -0
  183. package/lib/utils/url/index.web.js +7 -0
  184. package/lib/utils/uuid.d.ts +17 -17
  185. package/lib/utils/uuid.js +218 -218
  186. package/lib/utils/validator.d.ts +26 -26
  187. package/lib/utils/validator.js +131 -131
  188. package/lib/utils/version.js +21 -21
  189. package/package.json +51 -49
  190. package/src/entities/ActionAuth.ts +41 -41
  191. package/src/entities/I18n.ts +45 -46
  192. package/src/entities/Modi.ts +69 -69
  193. package/src/entities/ModiEntity.ts +26 -26
  194. package/src/entities/Oper.ts +32 -32
  195. package/src/entities/OperEntity.ts +27 -27
  196. package/src/entities/Path.ts +43 -43
  197. package/src/entities/Relation.ts +43 -43
  198. package/src/entities/RelationAuth.ts +44 -44
  199. package/src/entities/User.ts +48 -48
  200. package/src/entities/UserEntityClaim.ts +29 -29
  201. package/src/entities/UserEntityGrant.ts +24 -24
  202. package/src/entities/UserRelation.ts +50 -50
@@ -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;
@@ -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,49 +1,51 @@
1
- {
2
- "name": "oak-domain",
3
- "version": "3.0.4",
4
- "author": {
5
- "name": "XuChang"
6
- },
7
- "scripts": {
8
- "make:domain": "ts-node scripts/make.ts",
9
- "build": "tsc",
10
- "prebuild": "npm run make:domain",
11
- "test": "ts-node test/test.ts"
12
- },
13
- "files": [
14
- "lib/**/*",
15
- "src/entities/*"
16
- ],
17
- "main": "lib/index",
18
- "devDependencies": {
19
- "@babel/cli": "^7.12.13",
20
- "@babel/core": "^7.12.13",
21
- "@babel/plugin-proposal-class-properties": "^7.12.13",
22
- "@babel/preset-env": "^7.12.13",
23
- "@babel/preset-typescript": "^7.12.13",
24
- "@types/assert": "^1.5.6",
25
- "@types/cross-spawn": "^6.0.2",
26
- "@types/fs-extra": "^9.0.13",
27
- "@types/lodash": "^4.14.182",
28
- "@types/mocha": "^8.2.0",
29
- "@types/node": "^20.6.1",
30
- "@types/node-schedule": "^2.1.0",
31
- "@types/react": "^17.0.2",
32
- "@types/uuid": "^8.3.0",
33
- "@types/wechat-miniprogram": "^3.4.1",
34
- "assert": "^2.0.0",
35
- "cross-env": "^7.0.2",
36
- "cross-spawn": "^7.0.3",
37
- "fs-extra": "^10.0.0",
38
- "lodash": "^4.17.21",
39
- "mocha": "^8.2.1",
40
- "ts-node": "^10.9.1",
41
- "tslib": "^2.4.0",
42
- "typescript": "^5.2.2"
43
- },
44
- "dependencies": {
45
- "dayjs": "^1.11.9",
46
- "node-schedule": "^2.1.1",
47
- "uuid": "^9.0.0"
48
- }
49
- }
1
+ {
2
+ "name": "oak-domain",
3
+ "version": "4.0.0",
4
+ "author": {
5
+ "name": "XuChang"
6
+ },
7
+ "scripts": {
8
+ "make:domain": "ts-node scripts/make.ts",
9
+ "build": "tsc",
10
+ "prebuild": "npm run make:domain",
11
+ "test": "ts-node test/test.ts"
12
+ },
13
+ "files": [
14
+ "lib/**/*",
15
+ "src/entities/*"
16
+ ],
17
+ "main": "lib/index",
18
+ "devDependencies": {
19
+ "@babel/cli": "^7.12.13",
20
+ "@babel/core": "^7.12.13",
21
+ "@babel/plugin-proposal-class-properties": "^7.12.13",
22
+ "@babel/preset-env": "^7.12.13",
23
+ "@babel/preset-typescript": "^7.12.13",
24
+ "@types/assert": "^1.5.6",
25
+ "@types/cross-spawn": "^6.0.2",
26
+ "@types/fs-extra": "^9.0.13",
27
+ "@types/lodash": "^4.14.182",
28
+ "@types/mocha": "^8.2.0",
29
+ "@types/node": "^20.6.1",
30
+ "@types/node-schedule": "^2.1.0",
31
+ "@types/react": "^17.0.2",
32
+ "@types/uuid": "^8.3.0",
33
+ "@types/wechat-miniprogram": "^3.4.1",
34
+ "@types/whatwg-url": "^11.0.3",
35
+ "assert": "^2.0.0",
36
+ "cross-env": "^7.0.2",
37
+ "cross-spawn": "^7.0.3",
38
+ "fs-extra": "^10.0.0",
39
+ "lodash": "^4.17.21",
40
+ "mocha": "^8.2.1",
41
+ "ts-node": "^10.9.1",
42
+ "tslib": "^2.4.0",
43
+ "typescript": "^5.2.2"
44
+ },
45
+ "dependencies": {
46
+ "dayjs": "^1.11.9",
47
+ "node-schedule": "^2.1.1",
48
+ "uuid": "^9.0.0",
49
+ "whatwg-url": "^14.0.0"
50
+ }
51
+ }
@@ -1,41 +1,41 @@
1
- import { EntityShape } from '../types/Entity';
2
- import { Schema as Relation } from './Relation';
3
- import { EntityDesc } from '../types/EntityDesc';
4
- import { Schema as Path } from './Path';
5
-
6
- type Actions = string[];
7
-
8
- export interface Schema extends EntityShape {
9
- relation?: Relation;
10
- path: Path;
11
- deActions: Actions;
12
- };
13
-
14
- const entityDesc: EntityDesc<Schema> = {
15
- locales: {
16
- zh_CN: {
17
- name: '用户授权',
18
- attr: {
19
- relation: '关系',
20
- path: '路径',
21
- deActions: '目标对象动作',
22
- },
23
- },
24
- },
25
- indexes: [
26
- {
27
- name: 'index_relation_path',
28
- attributes: [
29
- {
30
- name: 'relation',
31
- },
32
- {
33
- name: 'path',
34
- }
35
- ],
36
- config: {
37
- unique: true,
38
- },
39
- },
40
- ],
41
- };
1
+ import { EntityShape } from '../types/Entity';
2
+ import { Schema as Relation } from './Relation';
3
+ import { EntityDesc } from '../types/EntityDesc';
4
+ import { Schema as Path } from './Path';
5
+
6
+ type Actions = string[];
7
+
8
+ export interface Schema extends EntityShape {
9
+ relation?: Relation;
10
+ path: Path;
11
+ deActions: Actions;
12
+ };
13
+
14
+ const entityDesc: EntityDesc<Schema> = {
15
+ locales: {
16
+ zh_CN: {
17
+ name: '用户授权',
18
+ attr: {
19
+ relation: '关系',
20
+ path: '路径',
21
+ deActions: '目标对象动作',
22
+ },
23
+ },
24
+ },
25
+ indexes: [
26
+ {
27
+ name: 'index_relation_path',
28
+ attributes: [
29
+ {
30
+ name: 'relation',
31
+ },
32
+ {
33
+ name: 'path',
34
+ }
35
+ ],
36
+ config: {
37
+ unique: true,
38
+ },
39
+ },
40
+ ],
41
+ };
@@ -1,46 +1,45 @@
1
- import { String } from '../types/DataType';
2
- import { EntityShape } from '../types/Entity';
3
- import { EntityDesc } from '../types/EntityDesc';
4
-
5
- export interface Schema extends EntityShape {
6
- module: String<64>;
7
- position: String<188>;
8
- namespace: String<256>;
9
- language: String<32>;
10
- data: Object;
11
- };
12
-
13
- const entityDesc: EntityDesc<Schema> = {
14
- locales: {
15
- zh_CN: {
16
- name: '用户授权',
17
- attr: {
18
- module: '模块',
19
- position: '文件位置',
20
- namespace: '命名空间',
21
- language: '语言',
22
- data: '数据'
23
- },
24
- },
25
- },
26
- indexes: [
27
- {
28
- name: 'namespace_language',
29
- attributes: [
30
- {
31
- name: 'namespace',
32
- },
33
- {
34
- name: 'language',
35
- }
36
- ],
37
- config: {
38
- unique: true,
39
- },
40
- }
41
- ],
42
- configuration: {
43
- actionType: 'readOnly',
44
- static: true,
45
- }
46
- };
1
+ import { String } from '../types/DataType';
2
+ import { EntityShape } from '../types/Entity';
3
+ import { EntityDesc } from '../types/EntityDesc';
4
+
5
+ export interface Schema extends EntityShape {
6
+ module: String<64>;
7
+ position: String<188>;
8
+ namespace: String<256>;
9
+ language: String<32>;
10
+ data: Object;
11
+ };
12
+
13
+ const entityDesc: EntityDesc<Schema> = {
14
+ locales: {
15
+ zh_CN: {
16
+ name: '用户授权',
17
+ attr: {
18
+ module: '模块',
19
+ position: '文件位置',
20
+ namespace: '命名空间',
21
+ language: '语言',
22
+ data: '数据'
23
+ },
24
+ },
25
+ },
26
+ indexes: [
27
+ {
28
+ name: 'namespace_language',
29
+ attributes: [
30
+ {
31
+ name: 'namespace',
32
+ },
33
+ {
34
+ name: 'language',
35
+ }
36
+ ],
37
+ config: {
38
+ unique: true,
39
+ },
40
+ }
41
+ ],
42
+ configuration: {
43
+ static: true,
44
+ },
45
+ };