@fastcar/core 0.2.62 → 0.2.63

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 (233) hide show
  1. package/package.json +1 -1
  2. package/src/FastCarApplication.ts +30 -9
  3. package/target/FastCarApplication.js +708 -692
  4. package/target/annotation/Application.js +45 -45
  5. package/target/annotation/ExceptionMonitor.js +16 -16
  6. package/target/annotation/bind/AddRequireModule.js +21 -21
  7. package/target/annotation/bind/AliasInjection.js +23 -23
  8. package/target/annotation/bind/Autowired.js +13 -13
  9. package/target/annotation/bind/CallDependency.js +23 -23
  10. package/target/annotation/data/DBType.js +11 -11
  11. package/target/annotation/data/DS.js +54 -54
  12. package/target/annotation/data/DSIndex.js +9 -9
  13. package/target/annotation/data/Entity.js +10 -10
  14. package/target/annotation/data/Field.js +18 -18
  15. package/target/annotation/data/PrimaryKey.js +9 -9
  16. package/target/annotation/data/SqlSession.js +9 -9
  17. package/target/annotation/data/Table.js +35 -35
  18. package/target/annotation/data/Transactional.js +52 -52
  19. package/target/annotation/env/ApplicationSetting.js +25 -25
  20. package/target/annotation/env/BaseFilePath.js +14 -14
  21. package/target/annotation/env/BaseName.js +9 -9
  22. package/target/annotation/env/BasePath.js +14 -14
  23. package/target/annotation/env/ENV.js +10 -10
  24. package/target/annotation/env/ResourcePath.js +9 -9
  25. package/target/annotation/lifeCycle/AddLifeCycleItem.js +18 -18
  26. package/target/annotation/lifeCycle/ApplicationDestory.js +15 -15
  27. package/target/annotation/lifeCycle/ApplicationInit.js +15 -15
  28. package/target/annotation/lifeCycle/ApplicationRunner.js +7 -7
  29. package/target/annotation/lifeCycle/ApplicationStart.js +24 -24
  30. package/target/annotation/lifeCycle/ApplicationStop.js +20 -20
  31. package/target/annotation/property/Deprecate.js +19 -19
  32. package/target/annotation/property/NotImplemented.js +8 -8
  33. package/target/annotation/property/Override.js +7 -7
  34. package/target/annotation/property/Readonly.js +16 -16
  35. package/target/annotation/scan/ComponentInjection.js +21 -21
  36. package/target/annotation/scan/ComponentScan.js +9 -9
  37. package/target/annotation/scan/ComponentScanExclusion.js +25 -25
  38. package/target/annotation/scan/ComponentScanMust.js +25 -25
  39. package/target/annotation/scan/Hotter.js +8 -8
  40. package/target/annotation/stereotype/BeanName.js +11 -11
  41. package/target/annotation/stereotype/Component.js +8 -8
  42. package/target/annotation/stereotype/Configure.js +14 -14
  43. package/target/annotation/stereotype/Controller.js +9 -9
  44. package/target/annotation/stereotype/Injection.js +12 -12
  45. package/target/annotation/stereotype/Log.js +17 -17
  46. package/target/annotation/stereotype/Repository.js +9 -9
  47. package/target/annotation/stereotype/Service.js +9 -9
  48. package/target/annotation/valid/AddChildValid.js +56 -56
  49. package/target/annotation/valid/CustomType.js +11 -11
  50. package/target/annotation/valid/DefaultVal.js +10 -10
  51. package/target/annotation/valid/NotNull.js +8 -8
  52. package/target/annotation/valid/Rule.js +100 -100
  53. package/target/annotation/valid/Size.js +10 -10
  54. package/target/annotation/valid/Type.js +10 -10
  55. package/target/annotation/valid/ValidCustom.js +17 -17
  56. package/target/annotation/valid/ValidForm.js +133 -133
  57. package/target/annotation.js +108 -108
  58. package/target/config/ApplicationConfig.js +2 -2
  59. package/target/config/SysConfig.js +19 -19
  60. package/target/constant/AppStatusEnum.js +9 -9
  61. package/target/constant/BootPriority.js +11 -11
  62. package/target/constant/CommonConstant.js +18 -18
  63. package/target/constant/ComponentKind.js +11 -11
  64. package/target/constant/DataTypes.js +19 -19
  65. package/target/constant/FastCarMetaData.js +31 -31
  66. package/target/constant/LifeCycleModule.js +9 -9
  67. package/target/db.js +49 -49
  68. package/target/index.js +21 -21
  69. package/target/interface/ApplicationHook.js +2 -2
  70. package/target/interface/ApplicationInterface.js +2 -2
  71. package/target/interface/ApplicationRunnerService.js +2 -2
  72. package/target/interface/DataSourceManager.js +2 -2
  73. package/target/interface/Logger.js +5 -5
  74. package/target/model/BaseMapper.js +98 -98
  75. package/target/model/DataMap.js +87 -87
  76. package/target/model/FormRuleModel.js +2 -2
  77. package/target/model/ValidError.js +5 -5
  78. package/target/model/WinstonLogger.js +96 -96
  79. package/target/type/ComponentDesc.js +2 -2
  80. package/target/type/DesignMeta.js +15 -15
  81. package/target/type/FileHotterDesc.js +2 -2
  82. package/target/type/MapperType.js +2 -2
  83. package/target/type/ProcessType.js +2 -2
  84. package/target/type/SqlError.js +5 -5
  85. package/target/type/WinstonLoggerType.js +9 -9
  86. package/target/utils/ClassLoader.js +65 -65
  87. package/target/utils/ClassUtils.js +35 -35
  88. package/target/utils/CryptoUtil.js +86 -86
  89. package/target/utils/DataFormat.js +88 -88
  90. package/target/utils/DateUtil.js +71 -71
  91. package/target/utils/FileUtil.js +153 -153
  92. package/target/utils/FormatStr.js +14 -14
  93. package/target/utils/IPUtils.js +34 -34
  94. package/target/utils/Id.js +9 -9
  95. package/target/utils/Mix.js +62 -62
  96. package/target/utils/ReflectUtil.js +22 -22
  97. package/target/utils/TypeUtil.js +53 -53
  98. package/target/utils/ValidationUtil.js +123 -123
  99. package/target/utils.js +25 -25
  100. package/test/unit/decorators-test.ts +3 -3
  101. package/test/unit/valid-test.ts +49 -54
  102. package/target/src/FastCarApplication.js +0 -704
  103. package/target/src/annotation/Application.js +0 -45
  104. package/target/src/annotation/ExceptionMonitor.js +0 -16
  105. package/target/src/annotation/bind/AddRequireModule.js +0 -21
  106. package/target/src/annotation/bind/AliasInjection.js +0 -23
  107. package/target/src/annotation/bind/Autowired.js +0 -13
  108. package/target/src/annotation/bind/CallDependency.js +0 -23
  109. package/target/src/annotation/data/DBType.js +0 -11
  110. package/target/src/annotation/data/DS.js +0 -54
  111. package/target/src/annotation/data/DSIndex.js +0 -9
  112. package/target/src/annotation/data/Entity.js +0 -10
  113. package/target/src/annotation/data/Field.js +0 -18
  114. package/target/src/annotation/data/PrimaryKey.js +0 -9
  115. package/target/src/annotation/data/SqlSession.js +0 -9
  116. package/target/src/annotation/data/Table.js +0 -35
  117. package/target/src/annotation/data/Transactional.js +0 -52
  118. package/target/src/annotation/env/ApplicationSetting.js +0 -25
  119. package/target/src/annotation/env/BaseFilePath.js +0 -14
  120. package/target/src/annotation/env/BaseName.js +0 -9
  121. package/target/src/annotation/env/BasePath.js +0 -14
  122. package/target/src/annotation/env/ENV.js +0 -10
  123. package/target/src/annotation/env/ResourcePath.js +0 -9
  124. package/target/src/annotation/lifeCycle/AddLifeCycleItem.js +0 -18
  125. package/target/src/annotation/lifeCycle/ApplicationDestory.js +0 -15
  126. package/target/src/annotation/lifeCycle/ApplicationInit.js +0 -15
  127. package/target/src/annotation/lifeCycle/ApplicationRunner.js +0 -7
  128. package/target/src/annotation/lifeCycle/ApplicationStart.js +0 -24
  129. package/target/src/annotation/lifeCycle/ApplicationStop.js +0 -20
  130. package/target/src/annotation/property/Deprecate.js +0 -19
  131. package/target/src/annotation/property/NotImplemented.js +0 -8
  132. package/target/src/annotation/property/Override.js +0 -7
  133. package/target/src/annotation/property/Readonly.js +0 -16
  134. package/target/src/annotation/scan/ComponentInjection.js +0 -21
  135. package/target/src/annotation/scan/ComponentScan.js +0 -9
  136. package/target/src/annotation/scan/ComponentScanExclusion.js +0 -25
  137. package/target/src/annotation/scan/ComponentScanMust.js +0 -25
  138. package/target/src/annotation/scan/Hotter.js +0 -8
  139. package/target/src/annotation/stereotype/BeanName.js +0 -11
  140. package/target/src/annotation/stereotype/Component.js +0 -8
  141. package/target/src/annotation/stereotype/Configure.js +0 -14
  142. package/target/src/annotation/stereotype/Controller.js +0 -9
  143. package/target/src/annotation/stereotype/Injection.js +0 -12
  144. package/target/src/annotation/stereotype/Log.js +0 -22
  145. package/target/src/annotation/stereotype/Repository.js +0 -9
  146. package/target/src/annotation/stereotype/Service.js +0 -9
  147. package/target/src/annotation/valid/AddChildValid.js +0 -56
  148. package/target/src/annotation/valid/CustomType.js +0 -11
  149. package/target/src/annotation/valid/DefaultVal.js +0 -10
  150. package/target/src/annotation/valid/NotNull.js +0 -8
  151. package/target/src/annotation/valid/Rule.js +0 -100
  152. package/target/src/annotation/valid/Size.js +0 -10
  153. package/target/src/annotation/valid/Type.js +0 -10
  154. package/target/src/annotation/valid/ValidCustom.js +0 -17
  155. package/target/src/annotation/valid/ValidForm.js +0 -133
  156. package/target/src/annotation.js +0 -108
  157. package/target/src/config/ApplicationConfig.js +0 -2
  158. package/target/src/config/SysConfig.js +0 -19
  159. package/target/src/constant/AppStatusEnum.js +0 -9
  160. package/target/src/constant/BootPriority.js +0 -11
  161. package/target/src/constant/CommonConstant.js +0 -18
  162. package/target/src/constant/ComponentKind.js +0 -11
  163. package/target/src/constant/DataTypes.js +0 -19
  164. package/target/src/constant/FastCarMetaData.js +0 -31
  165. package/target/src/constant/LifeCycleModule.js +0 -9
  166. package/target/src/db.js +0 -49
  167. package/target/src/index.js +0 -21
  168. package/target/src/interface/ApplicationHook.js +0 -2
  169. package/target/src/interface/ApplicationInterface.js +0 -2
  170. package/target/src/interface/ApplicationRunnerService.js +0 -2
  171. package/target/src/interface/DataSourceManager.js +0 -2
  172. package/target/src/interface/Logger.js +0 -5
  173. package/target/src/model/BaseMapper.js +0 -103
  174. package/target/src/model/DataMap.js +0 -87
  175. package/target/src/model/FormRuleModel.js +0 -2
  176. package/target/src/model/ValidError.js +0 -5
  177. package/target/src/model/WinstonLogger.js +0 -97
  178. package/target/src/type/ComponentDesc.js +0 -2
  179. package/target/src/type/DesignMeta.js +0 -15
  180. package/target/src/type/FileHotterDesc.js +0 -2
  181. package/target/src/type/MapperType.js +0 -2
  182. package/target/src/type/ProcessType.js +0 -2
  183. package/target/src/type/SqlError.js +0 -5
  184. package/target/src/type/WinstonLoggerType.js +0 -9
  185. package/target/src/utils/ClassLoader.js +0 -65
  186. package/target/src/utils/ClassUtils.js +0 -35
  187. package/target/src/utils/CryptoUtil.js +0 -86
  188. package/target/src/utils/DataFormat.js +0 -88
  189. package/target/src/utils/DateUtil.js +0 -71
  190. package/target/src/utils/FileUtil.js +0 -153
  191. package/target/src/utils/FormatStr.js +0 -14
  192. package/target/src/utils/IPUtils.js +0 -34
  193. package/target/src/utils/Id.js +0 -9
  194. package/target/src/utils/Mix.js +0 -62
  195. package/target/src/utils/ReflectUtil.js +0 -22
  196. package/target/src/utils/TypeUtil.js +0 -53
  197. package/target/src/utils/ValidationUtil.js +0 -118
  198. package/target/src/utils.js +0 -25
  199. package/target/test/example/simple/app-test.js +0 -57
  200. package/target/test/example/simple/app.js +0 -116
  201. package/target/test/example/simple/component/StartRunner.js +0 -19
  202. package/target/test/example/simple/component/StopRunner.js +0 -23
  203. package/target/test/example/simple/config/EnvConfig.js +0 -16
  204. package/target/test/example/simple/config/HelloConfig.js +0 -16
  205. package/target/test/example/simple/config/HotConfig.js +0 -18
  206. package/target/test/example/simple/controller/AliasController.js +0 -17
  207. package/target/test/example/simple/controller/HelloController.js +0 -55
  208. package/target/test/example/simple/controller/NotFoundController.js +0 -36
  209. package/target/test/example/simple/noclude/excludeApp.js +0 -17
  210. package/target/test/example/simple/service/CallService.js +0 -24
  211. package/target/test/example/simple/service/HelloService.js +0 -18
  212. package/target/test/example/simple/service/LogService.js +0 -32
  213. package/target/test/multi/app.js +0 -29
  214. package/target/test/multi/service/aService.js +0 -33
  215. package/target/test/multi/service/bService.js +0 -35
  216. package/target/test/multi/service/cService.js +0 -40
  217. package/target/test/unit/dataMap-test.js +0 -35
  218. package/target/test/unit/decorators-test.js +0 -59
  219. package/target/test/unit/ds-test.js +0 -58
  220. package/target/test/unit/reflectMetadata-test.js +0 -27
  221. package/target/test/unit/valid-test.js +0 -99
  222. package/target/test/unit/winston-test.js +0 -15
  223. package/test/example/logs/fastcar-server.sys.log +0 -3
  224. package/test/example/logs/other-server.app.log +0 -0
  225. package/test/example/logs/other-server.sys.log +0 -0
  226. package/test/example/logs/other-server.sys1.log +0 -0
  227. package/test/example/logs/other-server.sys2.log +0 -0
  228. package/test/example/logs/other-server.sys3.log +0 -6
  229. package/test/example/logs/other-server.sys4.log +0 -0
  230. package/test/example/logs/other-server.sys5.log +0 -0
  231. package/test/example/logs/other-server.sys6.log +0 -2
  232. package/test/logs/logger.log +0 -0
  233. package/test/logs/sys.log +0 -227
@@ -1,34 +1,34 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getIPNum = function (address) {
4
- let ip = address.split(".");
5
- let total = 0;
6
- ip.forEach((item, index) => {
7
- total += parseInt(item) * Math.pow(256, 3 - index);
8
- });
9
- return total;
10
- };
11
- const InnerIPList = [
12
- ["10.0.0.0", "10.255.255.255"],
13
- ["172.16.0.0", "172.31.255.255"],
14
- ["192.168.0.0", "192.168.255.255"],
15
- ["127.0.0.0", "127.255.255.255"],
16
- ].map((item) => {
17
- return [getIPNum(item[0]), getIPNum(item[1])];
18
- });
19
- class IPUtils {
20
- }
21
- IPUtils.isInnerIP = (ip) => {
22
- if (["0.0.0.0", "localhost"].includes(ip)) {
23
- return true;
24
- }
25
- let n = ip.split(".");
26
- if (n.length != 4) {
27
- return false;
28
- }
29
- let ipn = getIPNum(ip);
30
- return InnerIPList.some((item) => {
31
- return ipn >= item[0] && ipn <= item[1];
32
- });
33
- };
34
- exports.default = IPUtils;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const getIPNum = function (address) {
4
+ let ip = address.split(".");
5
+ let total = 0;
6
+ ip.forEach((item, index) => {
7
+ total += parseInt(item) * Math.pow(256, 3 - index);
8
+ });
9
+ return total;
10
+ };
11
+ const InnerIPList = [
12
+ ["10.0.0.0", "10.255.255.255"],
13
+ ["172.16.0.0", "172.31.255.255"],
14
+ ["192.168.0.0", "192.168.255.255"],
15
+ ["127.0.0.0", "127.255.255.255"],
16
+ ].map((item) => {
17
+ return [getIPNum(item[0]), getIPNum(item[1])];
18
+ });
19
+ class IPUtils {
20
+ }
21
+ exports.default = IPUtils;
22
+ IPUtils.isInnerIP = (ip) => {
23
+ if (["0.0.0.0", "localhost"].includes(ip)) {
24
+ return true;
25
+ }
26
+ let n = ip.split(".");
27
+ if (n.length != 4) {
28
+ return false;
29
+ }
30
+ let ipn = getIPNum(ip);
31
+ return InnerIPList.some((item) => {
32
+ return ipn >= item[0] && ipn <= item[1];
33
+ });
34
+ };
@@ -1,9 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.id = void 0;
4
- //生成唯一ID
5
- let idCounter = 0;
6
- function id() {
7
- return ++idCounter;
8
- }
9
- exports.id = id;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.id = void 0;
4
+ //生成唯一ID
5
+ let idCounter = 0;
6
+ function id() {
7
+ return ++idCounter;
8
+ }
9
+ exports.id = id;
@@ -1,62 +1,62 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ClassUtils_1 = require("./ClassUtils");
4
- const BASETYPE = ["constructor", "prototype", "name"];
5
- /***
6
- * @version 1.0 混合多个类
7
- *
8
- */
9
- class MixTool {
10
- static mix(...mixins) {
11
- class Mix {
12
- constructor() {
13
- for (let mixin of mixins) {
14
- MixTool.copyProperties(this, new mixin()); // 拷贝实例属性
15
- }
16
- }
17
- }
18
- for (let mixin of mixins) {
19
- MixTool.copyProperties(Mix, mixin); // 拷贝静态属性
20
- MixTool.copyProperties(Mix.prototype, mixin.prototype); // 拷贝原型属性
21
- }
22
- return Mix;
23
- }
24
- static copyProperties(target, source) {
25
- let keys = Reflect.ownKeys(source);
26
- for (let key of keys) {
27
- if (!BASETYPE.includes(key.toString())) {
28
- let desc = Object.getOwnPropertyDescriptor(source, key);
29
- if (desc) {
30
- Object.defineProperty(target, key, desc);
31
- }
32
- }
33
- }
34
- }
35
- //仅仅改变属性的值
36
- static copPropertyValue(target, source) {
37
- let keys = Reflect.ownKeys(source);
38
- for (let key of keys) {
39
- if (!BASETYPE.includes(key.toString())) {
40
- let desc = Reflect.getOwnPropertyDescriptor(source, key);
41
- if (!!desc) {
42
- Reflect.defineProperty(target, key, desc);
43
- }
44
- }
45
- }
46
- }
47
- //多个对象赋值
48
- static assign(target, source) {
49
- Object.assign(target, source);
50
- let keys = ClassUtils_1.default.getProtoType(source);
51
- keys.forEach((key) => {
52
- let keyStr = key.toString();
53
- if (!BASETYPE.includes(keyStr)) {
54
- let desc = Object.getOwnPropertyDescriptor(source?.prototype, key);
55
- if (desc) {
56
- Reflect.defineProperty(target, key, desc);
57
- }
58
- }
59
- });
60
- }
61
- }
62
- exports.default = MixTool;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ClassUtils_1 = require("./ClassUtils");
4
+ const BASETYPE = ["constructor", "prototype", "name"];
5
+ /***
6
+ * @version 1.0 混合多个类
7
+ *
8
+ */
9
+ class MixTool {
10
+ static mix(...mixins) {
11
+ class Mix {
12
+ constructor() {
13
+ for (let mixin of mixins) {
14
+ MixTool.copyProperties(this, new mixin()); // 拷贝实例属性
15
+ }
16
+ }
17
+ }
18
+ for (let mixin of mixins) {
19
+ MixTool.copyProperties(Mix, mixin); // 拷贝静态属性
20
+ MixTool.copyProperties(Mix.prototype, mixin.prototype); // 拷贝原型属性
21
+ }
22
+ return Mix;
23
+ }
24
+ static copyProperties(target, source) {
25
+ let keys = Reflect.ownKeys(source);
26
+ for (let key of keys) {
27
+ if (!BASETYPE.includes(key.toString())) {
28
+ let desc = Object.getOwnPropertyDescriptor(source, key);
29
+ if (desc) {
30
+ Object.defineProperty(target, key, desc);
31
+ }
32
+ }
33
+ }
34
+ }
35
+ //仅仅改变属性的值
36
+ static copPropertyValue(target, source) {
37
+ let keys = Reflect.ownKeys(source);
38
+ for (let key of keys) {
39
+ if (!BASETYPE.includes(key.toString())) {
40
+ let desc = Reflect.getOwnPropertyDescriptor(source, key);
41
+ if (!!desc) {
42
+ Reflect.defineProperty(target, key, desc);
43
+ }
44
+ }
45
+ }
46
+ }
47
+ //多个对象赋值
48
+ static assign(target, source) {
49
+ Object.assign(target, source);
50
+ let keys = ClassUtils_1.default.getProtoType(source);
51
+ keys.forEach((key) => {
52
+ let keyStr = key.toString();
53
+ if (!BASETYPE.includes(keyStr)) {
54
+ let desc = Object.getOwnPropertyDescriptor(source?.prototype, key);
55
+ if (desc) {
56
+ Reflect.defineProperty(target, key, desc);
57
+ }
58
+ }
59
+ });
60
+ }
61
+ }
62
+ exports.default = MixTool;
@@ -1,22 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const FastCarMetaData_1 = require("../constant/FastCarMetaData");
4
- const FormatStr_1 = require("./FormatStr");
5
- const SpecWords = ["Boolean", "Number", "String", "Object"];
6
- class ReflectUtil {
7
- static getNameByPropertyKey(target, propertyKey) {
8
- const designType = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.designType, target, propertyKey);
9
- let key = "";
10
- let name = "";
11
- if (designType) {
12
- name = designType.name;
13
- key = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.InjectionUniqueKey, designType); //放入至原型中
14
- }
15
- //获取不到注入的值时默认为别名的值
16
- if (!name || SpecWords.includes(name)) {
17
- key = FormatStr_1.default.formatFirstToUp(propertyKey);
18
- }
19
- return key;
20
- }
21
- }
22
- exports.default = ReflectUtil;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const FastCarMetaData_1 = require("../constant/FastCarMetaData");
4
+ const FormatStr_1 = require("./FormatStr");
5
+ const SpecWords = ["Boolean", "Number", "String", "Object"];
6
+ class ReflectUtil {
7
+ static getNameByPropertyKey(target, propertyKey) {
8
+ const designType = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.designType, target, propertyKey);
9
+ let key = "";
10
+ let name = "";
11
+ if (designType) {
12
+ name = designType.name;
13
+ key = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.InjectionUniqueKey, designType); //放入至原型中
14
+ }
15
+ //获取不到注入的值时默认为别名的值
16
+ if (!name || SpecWords.includes(name)) {
17
+ key = FormatStr_1.default.formatFirstToUp(propertyKey);
18
+ }
19
+ return key;
20
+ }
21
+ }
22
+ exports.default = ReflectUtil;
@@ -1,53 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const FileUtil_1 = require("./FileUtil");
4
- const BasicTypes = ["boolean", "number", "string"];
5
- class TypeUtil {
6
- static isFunction(f) {
7
- let typeName = typeof f;
8
- return typeName == "function";
9
- }
10
- static isClass(f) {
11
- if (f.prototype === undefined) {
12
- return false;
13
- }
14
- if (!f.prototype.constructor) {
15
- return false;
16
- }
17
- return TypeUtil.isFunction(f);
18
- }
19
- static isString(str) {
20
- let typeName = typeof str;
21
- return typeName == "string";
22
- }
23
- static isObject(f) {
24
- let typeName = typeof f;
25
- return typeName == "object";
26
- }
27
- //忽略.d.ts文件
28
- static isTSORJS(fp) {
29
- let suffix = FileUtil_1.default.getSuffix(fp);
30
- return ["ts", "js"].includes(suffix) && !fp.endsWith(".d.ts");
31
- }
32
- static isPromise(f) {
33
- return f.constructor.name === "AsyncFunction";
34
- }
35
- static isArray(value) {
36
- return Array.isArray(value);
37
- }
38
- static isDate(value) {
39
- return value instanceof Date;
40
- }
41
- //是否为基本类型
42
- static isBasic(name) {
43
- let fname = name.toLowerCase();
44
- return BasicTypes.includes(fname);
45
- }
46
- static isMap(value) {
47
- return value instanceof Map;
48
- }
49
- static isSet(value) {
50
- return value instanceof Set;
51
- }
52
- }
53
- exports.default = TypeUtil;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const FileUtil_1 = require("./FileUtil");
4
+ const BasicTypes = ["boolean", "number", "string"];
5
+ class TypeUtil {
6
+ static isFunction(f) {
7
+ let typeName = typeof f;
8
+ return typeName == "function";
9
+ }
10
+ static isClass(f) {
11
+ if (f.prototype === undefined) {
12
+ return false;
13
+ }
14
+ if (!f.prototype.constructor) {
15
+ return false;
16
+ }
17
+ return TypeUtil.isFunction(f);
18
+ }
19
+ static isString(str) {
20
+ let typeName = typeof str;
21
+ return typeName == "string";
22
+ }
23
+ static isObject(f) {
24
+ let typeName = typeof f;
25
+ return typeName == "object";
26
+ }
27
+ //忽略.d.ts文件
28
+ static isTSORJS(fp) {
29
+ let suffix = FileUtil_1.default.getSuffix(fp);
30
+ return ["ts", "js"].includes(suffix) && !fp.endsWith(".d.ts");
31
+ }
32
+ static isPromise(f) {
33
+ return f.constructor.name === "AsyncFunction";
34
+ }
35
+ static isArray(value) {
36
+ return Array.isArray(value);
37
+ }
38
+ static isDate(value) {
39
+ return value instanceof Date;
40
+ }
41
+ //是否为基本类型
42
+ static isBasic(name) {
43
+ let fname = name.toLowerCase();
44
+ return BasicTypes.includes(fname);
45
+ }
46
+ static isMap(value) {
47
+ return value instanceof Map;
48
+ }
49
+ static isSet(value) {
50
+ return value instanceof Set;
51
+ }
52
+ }
53
+ exports.default = TypeUtil;
@@ -1,123 +1,123 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const TypeUtil_1 = require("./TypeUtil");
4
- //类型校验器
5
- class ValidationUtil {
6
- //是否为空
7
- static isNotNull(param) {
8
- if (param != undefined && param != null) {
9
- if (TypeUtil_1.default.isString(param)) {
10
- return param.length > 0;
11
- }
12
- if (TypeUtil_1.default.isObject(param)) {
13
- if (TypeUtil_1.default.isDate(param) || TypeUtil_1.default.isMap(param) || TypeUtil_1.default.isSet(param)) {
14
- return true;
15
- }
16
- return Reflect.ownKeys(param).length > 0;
17
- }
18
- return true;
19
- }
20
- else {
21
- return false;
22
- }
23
- }
24
- static isNull(param) {
25
- return !ValidationUtil.isNotNull(param);
26
- }
27
- //修改数字的判断方法
28
- static isNumber(param) {
29
- return !isNaN(param);
30
- }
31
- static isString(param) {
32
- return typeof param === "string";
33
- }
34
- static isBoolean(param) {
35
- return typeof param === "boolean";
36
- }
37
- static isDate(param) {
38
- return param instanceof Date;
39
- }
40
- static isObject(param) {
41
- return typeof param == "object";
42
- }
43
- // poaram >= value
44
- static isNotMinSize(param, value) {
45
- if (ValidationUtil.isString(param)) {
46
- return param.length >= value;
47
- }
48
- if (ValidationUtil.isNumber(param)) {
49
- return param >= value;
50
- }
51
- if (ValidationUtil.isBoolean(param)) {
52
- return true;
53
- }
54
- //修正数组的判断
55
- if (Array.isArray(param)) {
56
- return param.length >= value;
57
- }
58
- let v = ValidationUtil.isNotNull(param) ? param.toString() : "";
59
- return v.length >= value;
60
- }
61
- static isNotMaxSize(param, value) {
62
- return !ValidationUtil.isNotMinSize(param, value + 1);
63
- }
64
- static isArray(param, type) {
65
- if (!Array.isArray(param)) {
66
- return false;
67
- }
68
- //修正校验数组的错误
69
- if (type.startsWith("array")) {
70
- type = type.replace(/array/, "");
71
- }
72
- let checkFun = this.getCheckFun(type);
73
- if (checkFun) {
74
- return param.every((item) => {
75
- return Reflect.apply(checkFun, ValidationUtil, [item]);
76
- });
77
- }
78
- return true;
79
- }
80
- static getCheckFun(type) {
81
- //判定类型
82
- if (type.startsWith("array")) {
83
- return ValidationUtil.isArray;
84
- }
85
- let formatFun = null;
86
- switch (type) {
87
- case "string": {
88
- formatFun = ValidationUtil.isString;
89
- break;
90
- }
91
- case "boolean": {
92
- formatFun = ValidationUtil.isBoolean;
93
- break;
94
- }
95
- case "object": {
96
- formatFun = ValidationUtil.isObject;
97
- break;
98
- }
99
- case "int":
100
- case "float":
101
- case "number": {
102
- formatFun = ValidationUtil.isNumber;
103
- break;
104
- }
105
- case "date": {
106
- formatFun = ValidationUtil.isDate;
107
- break;
108
- }
109
- default: {
110
- break;
111
- }
112
- }
113
- return formatFun;
114
- }
115
- static checkType(param, type) {
116
- let formatFun = ValidationUtil.getCheckFun(type);
117
- if (!formatFun) {
118
- return false;
119
- }
120
- return Reflect.apply(formatFun, ValidationUtil, [param, type]);
121
- }
122
- }
123
- exports.default = ValidationUtil;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const TypeUtil_1 = require("./TypeUtil");
4
+ //类型校验器
5
+ class ValidationUtil {
6
+ //是否为空
7
+ static isNotNull(param) {
8
+ if (param != undefined && param != null) {
9
+ if (TypeUtil_1.default.isString(param)) {
10
+ return param.length > 0;
11
+ }
12
+ if (TypeUtil_1.default.isObject(param)) {
13
+ if (TypeUtil_1.default.isDate(param) || TypeUtil_1.default.isMap(param) || TypeUtil_1.default.isSet(param)) {
14
+ return true;
15
+ }
16
+ return Reflect.ownKeys(param).length > 0;
17
+ }
18
+ return true;
19
+ }
20
+ else {
21
+ return false;
22
+ }
23
+ }
24
+ static isNull(param) {
25
+ return !ValidationUtil.isNotNull(param);
26
+ }
27
+ //修改数字的判断方法
28
+ static isNumber(param) {
29
+ return !isNaN(param);
30
+ }
31
+ static isString(param) {
32
+ return typeof param === "string";
33
+ }
34
+ static isBoolean(param) {
35
+ return typeof param === "boolean";
36
+ }
37
+ static isDate(param) {
38
+ return param instanceof Date;
39
+ }
40
+ static isObject(param) {
41
+ return typeof param == "object";
42
+ }
43
+ // poaram >= value
44
+ static isNotMinSize(param, value) {
45
+ if (ValidationUtil.isString(param)) {
46
+ return param.length >= value;
47
+ }
48
+ if (ValidationUtil.isNumber(param)) {
49
+ return param >= value;
50
+ }
51
+ if (ValidationUtil.isBoolean(param)) {
52
+ return true;
53
+ }
54
+ //修正数组的判断
55
+ if (Array.isArray(param)) {
56
+ return param.length >= value;
57
+ }
58
+ let v = ValidationUtil.isNotNull(param) ? param.toString() : "";
59
+ return v.length >= value;
60
+ }
61
+ static isNotMaxSize(param, value) {
62
+ return !ValidationUtil.isNotMinSize(param, value + 1);
63
+ }
64
+ static isArray(param, type) {
65
+ if (!Array.isArray(param)) {
66
+ return false;
67
+ }
68
+ //修正校验数组的错误
69
+ if (type.startsWith("array")) {
70
+ type = type.replace(/array/, "");
71
+ }
72
+ let checkFun = this.getCheckFun(type);
73
+ if (checkFun) {
74
+ return param.every((item) => {
75
+ return Reflect.apply(checkFun, ValidationUtil, [item]);
76
+ });
77
+ }
78
+ return true;
79
+ }
80
+ static getCheckFun(type) {
81
+ //判定类型
82
+ if (type.startsWith("array")) {
83
+ return ValidationUtil.isArray;
84
+ }
85
+ let formatFun = null;
86
+ switch (type) {
87
+ case "string": {
88
+ formatFun = ValidationUtil.isString;
89
+ break;
90
+ }
91
+ case "boolean": {
92
+ formatFun = ValidationUtil.isBoolean;
93
+ break;
94
+ }
95
+ case "object": {
96
+ formatFun = ValidationUtil.isObject;
97
+ break;
98
+ }
99
+ case "int":
100
+ case "float":
101
+ case "number": {
102
+ formatFun = ValidationUtil.isNumber;
103
+ break;
104
+ }
105
+ case "date": {
106
+ formatFun = ValidationUtil.isDate;
107
+ break;
108
+ }
109
+ default: {
110
+ break;
111
+ }
112
+ }
113
+ return formatFun;
114
+ }
115
+ static checkType(param, type) {
116
+ let formatFun = ValidationUtil.getCheckFun(type);
117
+ if (!formatFun) {
118
+ return false;
119
+ }
120
+ return Reflect.apply(formatFun, ValidationUtil, [param, type]);
121
+ }
122
+ }
123
+ exports.default = ValidationUtil;
package/target/utils.js CHANGED
@@ -1,25 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IPUtils = exports.MixTool = exports.ClassLoader = exports.ClassUtils = exports.FormatStr = exports.ValidationUtil = exports.TypeUtil = exports.FileUtil = exports.CryptoUtil = exports.DataFormat = exports.DateUtil = void 0;
4
- const ClassLoader_1 = require("./utils/ClassLoader");
5
- exports.ClassLoader = ClassLoader_1.default;
6
- const ClassUtils_1 = require("./utils/ClassUtils");
7
- exports.ClassUtils = ClassUtils_1.default;
8
- const CryptoUtil_1 = require("./utils/CryptoUtil");
9
- exports.CryptoUtil = CryptoUtil_1.default;
10
- const DataFormat_1 = require("./utils/DataFormat");
11
- exports.DataFormat = DataFormat_1.default;
12
- const DateUtil_1 = require("./utils/DateUtil");
13
- exports.DateUtil = DateUtil_1.default;
14
- const FileUtil_1 = require("./utils/FileUtil");
15
- exports.FileUtil = FileUtil_1.default;
16
- const FormatStr_1 = require("./utils/FormatStr");
17
- exports.FormatStr = FormatStr_1.default;
18
- const Mix_1 = require("./utils/Mix");
19
- exports.MixTool = Mix_1.default;
20
- const TypeUtil_1 = require("./utils/TypeUtil");
21
- exports.TypeUtil = TypeUtil_1.default;
22
- const ValidationUtil_1 = require("./utils/ValidationUtil");
23
- exports.ValidationUtil = ValidationUtil_1.default;
24
- const IPUtils_1 = require("./utils/IPUtils");
25
- exports.IPUtils = IPUtils_1.default;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IPUtils = exports.MixTool = exports.ClassLoader = exports.ClassUtils = exports.FormatStr = exports.ValidationUtil = exports.TypeUtil = exports.FileUtil = exports.CryptoUtil = exports.DataFormat = exports.DateUtil = void 0;
4
+ const ClassLoader_1 = require("./utils/ClassLoader");
5
+ exports.ClassLoader = ClassLoader_1.default;
6
+ const ClassUtils_1 = require("./utils/ClassUtils");
7
+ exports.ClassUtils = ClassUtils_1.default;
8
+ const CryptoUtil_1 = require("./utils/CryptoUtil");
9
+ exports.CryptoUtil = CryptoUtil_1.default;
10
+ const DataFormat_1 = require("./utils/DataFormat");
11
+ exports.DataFormat = DataFormat_1.default;
12
+ const DateUtil_1 = require("./utils/DateUtil");
13
+ exports.DateUtil = DateUtil_1.default;
14
+ const FileUtil_1 = require("./utils/FileUtil");
15
+ exports.FileUtil = FileUtil_1.default;
16
+ const FormatStr_1 = require("./utils/FormatStr");
17
+ exports.FormatStr = FormatStr_1.default;
18
+ const Mix_1 = require("./utils/Mix");
19
+ exports.MixTool = Mix_1.default;
20
+ const TypeUtil_1 = require("./utils/TypeUtil");
21
+ exports.TypeUtil = TypeUtil_1.default;
22
+ const ValidationUtil_1 = require("./utils/ValidationUtil");
23
+ exports.ValidationUtil = ValidationUtil_1.default;
24
+ const IPUtils_1 = require("./utils/IPUtils");
25
+ exports.IPUtils = IPUtils_1.default;