@fastcar/core 0.2.59 → 0.2.61

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 (225) hide show
  1. package/package.json +2 -4
  2. package/src/db.ts +1 -0
  3. package/src/model/WinstonLogger.ts +4 -3
  4. package/src/utils/ClassLoader.ts +1 -1
  5. package/src/utils/ValidationUtil.ts +10 -1
  6. package/target/FastCarApplication.js +692 -692
  7. package/target/annotation/Application.js +45 -45
  8. package/target/annotation/ExceptionMonitor.js +16 -16
  9. package/target/annotation/bind/AddRequireModule.js +21 -21
  10. package/target/annotation/bind/AliasInjection.js +23 -23
  11. package/target/annotation/bind/Autowired.js +13 -13
  12. package/target/annotation/bind/CallDependency.js +23 -23
  13. package/target/annotation/data/DBType.js +11 -11
  14. package/target/annotation/data/DS.js +54 -54
  15. package/target/annotation/data/DSIndex.js +9 -9
  16. package/target/annotation/data/Entity.js +10 -10
  17. package/target/annotation/data/Field.js +18 -18
  18. package/target/annotation/data/PrimaryKey.js +9 -9
  19. package/target/annotation/data/SqlSession.js +9 -9
  20. package/target/annotation/data/Table.js +35 -35
  21. package/target/annotation/data/Transactional.js +52 -52
  22. package/target/annotation/env/ApplicationSetting.js +25 -25
  23. package/target/annotation/env/BaseFilePath.js +14 -14
  24. package/target/annotation/env/BaseName.js +9 -9
  25. package/target/annotation/env/BasePath.js +14 -14
  26. package/target/annotation/env/ENV.js +10 -10
  27. package/target/annotation/env/ResourcePath.js +9 -9
  28. package/target/annotation/lifeCycle/AddLifeCycleItem.js +18 -18
  29. package/target/annotation/lifeCycle/ApplicationDestory.js +15 -15
  30. package/target/annotation/lifeCycle/ApplicationInit.js +15 -15
  31. package/target/annotation/lifeCycle/ApplicationRunner.js +7 -7
  32. package/target/annotation/lifeCycle/ApplicationStart.js +24 -24
  33. package/target/annotation/lifeCycle/ApplicationStop.js +20 -20
  34. package/target/annotation/property/Deprecate.js +19 -19
  35. package/target/annotation/property/NotImplemented.js +8 -8
  36. package/target/annotation/property/Override.js +7 -7
  37. package/target/annotation/property/Readonly.js +16 -16
  38. package/target/annotation/scan/ComponentInjection.js +21 -21
  39. package/target/annotation/scan/ComponentScan.js +9 -9
  40. package/target/annotation/scan/ComponentScanExclusion.js +25 -25
  41. package/target/annotation/scan/ComponentScanMust.js +25 -25
  42. package/target/annotation/scan/Hotter.js +8 -8
  43. package/target/annotation/stereotype/BeanName.js +11 -11
  44. package/target/annotation/stereotype/Component.js +8 -8
  45. package/target/annotation/stereotype/Configure.js +14 -14
  46. package/target/annotation/stereotype/Controller.js +9 -9
  47. package/target/annotation/stereotype/Injection.js +12 -12
  48. package/target/annotation/stereotype/Log.js +17 -17
  49. package/target/annotation/stereotype/Repository.js +9 -9
  50. package/target/annotation/stereotype/Service.js +9 -9
  51. package/target/annotation/valid/AddChildValid.js +56 -56
  52. package/target/annotation/valid/CustomType.js +11 -11
  53. package/target/annotation/valid/DefaultVal.js +10 -10
  54. package/target/annotation/valid/NotNull.js +8 -8
  55. package/target/annotation/valid/Rule.js +100 -100
  56. package/target/annotation/valid/Size.js +10 -10
  57. package/target/annotation/valid/Type.js +10 -10
  58. package/target/annotation/valid/ValidCustom.js +17 -17
  59. package/target/annotation/valid/ValidForm.js +133 -133
  60. package/target/annotation.js +108 -108
  61. package/target/config/ApplicationConfig.js +2 -2
  62. package/target/config/SysConfig.js +19 -19
  63. package/target/constant/AppStatusEnum.js +9 -9
  64. package/target/constant/BootPriority.js +11 -11
  65. package/target/constant/CommonConstant.js +18 -18
  66. package/target/constant/ComponentKind.js +11 -11
  67. package/target/constant/DataTypes.js +19 -19
  68. package/target/constant/FastCarMetaData.js +31 -31
  69. package/target/constant/LifeCycleModule.js +9 -9
  70. package/target/db.js +49 -48
  71. package/target/index.js +21 -21
  72. package/target/interface/ApplicationHook.js +2 -2
  73. package/target/interface/ApplicationInterface.js +2 -2
  74. package/target/interface/ApplicationRunnerService.js +2 -2
  75. package/target/interface/DataSourceManager.js +2 -2
  76. package/target/interface/Logger.js +5 -5
  77. package/target/model/BaseMapper.js +98 -98
  78. package/target/model/DataMap.js +87 -87
  79. package/target/model/FormRuleModel.js +2 -2
  80. package/target/model/ValidError.js +5 -5
  81. package/target/model/WinstonLogger.js +96 -95
  82. package/target/src/FastCarApplication.js +704 -0
  83. package/target/src/annotation/Application.js +45 -0
  84. package/target/src/annotation/ExceptionMonitor.js +16 -0
  85. package/target/src/annotation/bind/AddRequireModule.js +21 -0
  86. package/target/src/annotation/bind/AliasInjection.js +23 -0
  87. package/target/src/annotation/bind/Autowired.js +13 -0
  88. package/target/src/annotation/bind/CallDependency.js +23 -0
  89. package/target/src/annotation/data/DBType.js +11 -0
  90. package/target/src/annotation/data/DS.js +54 -0
  91. package/target/src/annotation/data/DSIndex.js +9 -0
  92. package/target/src/annotation/data/Entity.js +10 -0
  93. package/target/src/annotation/data/Field.js +18 -0
  94. package/target/src/annotation/data/PrimaryKey.js +9 -0
  95. package/target/src/annotation/data/SqlSession.js +9 -0
  96. package/target/src/annotation/data/Table.js +35 -0
  97. package/target/src/annotation/data/Transactional.js +52 -0
  98. package/target/src/annotation/env/ApplicationSetting.js +25 -0
  99. package/target/src/annotation/env/BaseFilePath.js +14 -0
  100. package/target/src/annotation/env/BaseName.js +9 -0
  101. package/target/src/annotation/env/BasePath.js +14 -0
  102. package/target/src/annotation/env/ENV.js +10 -0
  103. package/target/src/annotation/env/ResourcePath.js +9 -0
  104. package/target/src/annotation/lifeCycle/AddLifeCycleItem.js +18 -0
  105. package/target/src/annotation/lifeCycle/ApplicationDestory.js +15 -0
  106. package/target/src/annotation/lifeCycle/ApplicationInit.js +15 -0
  107. package/target/src/annotation/lifeCycle/ApplicationRunner.js +7 -0
  108. package/target/src/annotation/lifeCycle/ApplicationStart.js +24 -0
  109. package/target/src/annotation/lifeCycle/ApplicationStop.js +20 -0
  110. package/target/src/annotation/property/Deprecate.js +19 -0
  111. package/target/src/annotation/property/NotImplemented.js +8 -0
  112. package/target/src/annotation/property/Override.js +7 -0
  113. package/target/src/annotation/property/Readonly.js +16 -0
  114. package/target/src/annotation/scan/ComponentInjection.js +21 -0
  115. package/target/src/annotation/scan/ComponentScan.js +9 -0
  116. package/target/src/annotation/scan/ComponentScanExclusion.js +25 -0
  117. package/target/src/annotation/scan/ComponentScanMust.js +25 -0
  118. package/target/src/annotation/scan/Hotter.js +8 -0
  119. package/target/src/annotation/stereotype/BeanName.js +11 -0
  120. package/target/src/annotation/stereotype/Component.js +8 -0
  121. package/target/src/annotation/stereotype/Configure.js +14 -0
  122. package/target/src/annotation/stereotype/Controller.js +9 -0
  123. package/target/src/annotation/stereotype/Injection.js +12 -0
  124. package/target/src/annotation/stereotype/Log.js +22 -0
  125. package/target/src/annotation/stereotype/Repository.js +9 -0
  126. package/target/src/annotation/stereotype/Service.js +9 -0
  127. package/target/src/annotation/valid/AddChildValid.js +56 -0
  128. package/target/src/annotation/valid/CustomType.js +11 -0
  129. package/target/src/annotation/valid/DefaultVal.js +10 -0
  130. package/target/src/annotation/valid/NotNull.js +8 -0
  131. package/target/src/annotation/valid/Rule.js +100 -0
  132. package/target/src/annotation/valid/Size.js +10 -0
  133. package/target/src/annotation/valid/Type.js +10 -0
  134. package/target/src/annotation/valid/ValidCustom.js +17 -0
  135. package/target/src/annotation/valid/ValidForm.js +133 -0
  136. package/target/src/annotation.js +108 -0
  137. package/target/src/config/ApplicationConfig.js +2 -0
  138. package/target/src/config/SysConfig.js +19 -0
  139. package/target/src/constant/AppStatusEnum.js +9 -0
  140. package/target/src/constant/BootPriority.js +11 -0
  141. package/target/src/constant/CommonConstant.js +18 -0
  142. package/target/src/constant/ComponentKind.js +11 -0
  143. package/target/src/constant/DataTypes.js +19 -0
  144. package/target/src/constant/FastCarMetaData.js +31 -0
  145. package/target/src/constant/LifeCycleModule.js +9 -0
  146. package/target/src/db.js +49 -0
  147. package/target/src/index.js +21 -0
  148. package/target/src/interface/ApplicationHook.js +2 -0
  149. package/target/src/interface/ApplicationInterface.js +2 -0
  150. package/target/src/interface/ApplicationRunnerService.js +2 -0
  151. package/target/src/interface/DataSourceManager.js +2 -0
  152. package/target/src/interface/Logger.js +5 -0
  153. package/target/src/model/BaseMapper.js +103 -0
  154. package/target/src/model/DataMap.js +87 -0
  155. package/target/src/model/FormRuleModel.js +2 -0
  156. package/target/src/model/ValidError.js +5 -0
  157. package/target/src/model/WinstonLogger.js +97 -0
  158. package/target/src/type/ComponentDesc.js +2 -0
  159. package/target/src/type/DesignMeta.js +15 -0
  160. package/target/src/type/FileHotterDesc.js +2 -0
  161. package/target/src/type/MapperType.js +2 -0
  162. package/target/src/type/ProcessType.js +2 -0
  163. package/target/src/type/SqlError.js +5 -0
  164. package/target/src/type/WinstonLoggerType.js +9 -0
  165. package/target/src/utils/ClassLoader.js +65 -0
  166. package/target/src/utils/ClassUtils.js +35 -0
  167. package/target/src/utils/CryptoUtil.js +86 -0
  168. package/target/src/utils/DataFormat.js +88 -0
  169. package/target/src/utils/DateUtil.js +71 -0
  170. package/target/src/utils/FileUtil.js +153 -0
  171. package/target/src/utils/FormatStr.js +14 -0
  172. package/target/src/utils/IPUtils.js +34 -0
  173. package/target/src/utils/Id.js +9 -0
  174. package/target/src/utils/Mix.js +62 -0
  175. package/target/src/utils/ReflectUtil.js +22 -0
  176. package/target/src/utils/TypeUtil.js +53 -0
  177. package/target/src/utils/ValidationUtil.js +118 -0
  178. package/target/src/utils.js +25 -0
  179. package/target/test/example/simple/app-test.js +57 -0
  180. package/target/test/example/simple/app.js +116 -0
  181. package/target/test/example/simple/component/StartRunner.js +19 -0
  182. package/target/test/example/simple/component/StopRunner.js +23 -0
  183. package/target/test/example/simple/config/EnvConfig.js +16 -0
  184. package/target/test/example/simple/config/HelloConfig.js +16 -0
  185. package/target/test/example/simple/config/HotConfig.js +18 -0
  186. package/target/test/example/simple/controller/AliasController.js +17 -0
  187. package/target/test/example/simple/controller/HelloController.js +55 -0
  188. package/target/test/example/simple/controller/NotFoundController.js +36 -0
  189. package/target/test/example/simple/noclude/excludeApp.js +17 -0
  190. package/target/test/example/simple/service/CallService.js +24 -0
  191. package/target/test/example/simple/service/HelloService.js +18 -0
  192. package/target/test/example/simple/service/LogService.js +32 -0
  193. package/target/test/multi/app.js +29 -0
  194. package/target/test/multi/service/aService.js +33 -0
  195. package/target/test/multi/service/bService.js +35 -0
  196. package/target/test/multi/service/cService.js +40 -0
  197. package/target/test/unit/dataMap-test.js +35 -0
  198. package/target/test/unit/decorators-test.js +59 -0
  199. package/target/test/unit/ds-test.js +58 -0
  200. package/target/test/unit/reflectMetadata-test.js +27 -0
  201. package/target/test/unit/valid-test.js +99 -0
  202. package/target/test/unit/winston-test.js +15 -0
  203. package/target/type/ComponentDesc.js +2 -2
  204. package/target/type/DesignMeta.js +15 -15
  205. package/target/type/FileHotterDesc.js +2 -2
  206. package/target/type/MapperType.js +2 -2
  207. package/target/type/ProcessType.js +2 -2
  208. package/target/type/SqlError.js +5 -5
  209. package/target/type/WinstonLoggerType.js +9 -9
  210. package/target/utils/ClassLoader.js +65 -65
  211. package/target/utils/ClassUtils.js +35 -35
  212. package/target/utils/CryptoUtil.js +86 -86
  213. package/target/utils/DataFormat.js +88 -88
  214. package/target/utils/DateUtil.js +71 -71
  215. package/target/utils/FileUtil.js +153 -153
  216. package/target/utils/FormatStr.js +14 -14
  217. package/target/utils/IPUtils.js +34 -34
  218. package/target/utils/Id.js +9 -9
  219. package/target/utils/Mix.js +62 -62
  220. package/target/utils/ReflectUtil.js +22 -22
  221. package/target/utils/TypeUtil.js +53 -53
  222. package/target/utils/ValidationUtil.js +124 -118
  223. package/target/utils.js +25 -25
  224. package/test/unit/decorators-test.ts +3 -3
  225. package/test/unit/logs/sys.log +0 -24
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogDefaultConfig = exports.SYSDefaultConfig = void 0;
4
+ exports.SYSDefaultConfig = {
5
+ application: {
6
+ name: "app",
7
+ env: "development",
8
+ version: "1.0.0",
9
+ },
10
+ settings: new Map(), //自定义配置
11
+ };
12
+ exports.LogDefaultConfig = {
13
+ consoleLevel: "info",
14
+ fileLevel: "info",
15
+ rootPath: __dirname,
16
+ maxsize: 1024 * 1024 * 10,
17
+ maxFiles: 30,
18
+ printConsole: true,
19
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppStatusEnum = void 0;
4
+ var AppStatusEnum;
5
+ (function (AppStatusEnum) {
6
+ AppStatusEnum["READY"] = "ready";
7
+ AppStatusEnum["RUN"] = "run";
8
+ AppStatusEnum["STOP"] = "stop";
9
+ })(AppStatusEnum = exports.AppStatusEnum || (exports.AppStatusEnum = {}));
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BootPriority = void 0;
4
+ var BootPriority;
5
+ (function (BootPriority) {
6
+ BootPriority[BootPriority["Base"] = 0] = "Base";
7
+ BootPriority[BootPriority["Sys"] = 1] = "Sys";
8
+ BootPriority[BootPriority["Common"] = 2] = "Common";
9
+ BootPriority[BootPriority["Other"] = 3] = "Other";
10
+ BootPriority[BootPriority["Lowest"] = 10000] = "Lowest";
11
+ })(BootPriority = exports.BootPriority || (exports.BootPriority = {}));
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileResSuffix = exports.CommonConstant = void 0;
4
+ exports.CommonConstant = {
5
+ Application: "application",
6
+ Settings: "settings",
7
+ Resource: "resource",
8
+ ENV: Symbol("env"),
9
+ BasePath: Symbol("basePath"),
10
+ BaseFileName: Symbol("baseFileName"),
11
+ SYSLOGGER: "sys",
12
+ FastcarApp: Symbol("FastcarApp"),
13
+ FastcarSetting: Symbol("FastcarSetting"),
14
+ ResourcePath: "resourcePath",
15
+ APPId: "appid",
16
+ BaseName: "basename", //设置基础的文件名称
17
+ };
18
+ exports.FileResSuffix = ["json", "yml", "js"];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComponentKind = void 0;
4
+ //实例类型
5
+ var ComponentKind;
6
+ (function (ComponentKind) {
7
+ ComponentKind["Controller"] = "Controller";
8
+ ComponentKind["Service"] = "Service";
9
+ ComponentKind["Component"] = "Component";
10
+ ComponentKind["Repository"] = "Repository";
11
+ })(ComponentKind = exports.ComponentKind || (exports.ComponentKind = {}));
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataTypes = void 0;
4
+ //数据类型枚举
5
+ var DataTypes;
6
+ (function (DataTypes) {
7
+ DataTypes["BOOLEAN"] = "boolean";
8
+ DataTypes["NUMBER"] = "number";
9
+ DataTypes["STRING"] = "string";
10
+ DataTypes["INT"] = "int";
11
+ DataTypes["FLOAT"] = "float";
12
+ DataTypes["DATE"] = "date";
13
+ DataTypes["Object"] = "object";
14
+ DataTypes["ARRAYNUMBER"] = "arraynumber";
15
+ DataTypes["ARRAYINT"] = "arrayint";
16
+ DataTypes["ARRAYFLOAT"] = "arrayfloat";
17
+ DataTypes["ARRAYSTRING"] = "arraystring";
18
+ DataTypes["ARRAYOBJECT"] = "arrayobject";
19
+ })(DataTypes = exports.DataTypes || (exports.DataTypes = {}));
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FastCarMetaData = void 0;
4
+ //元数据加载模块
5
+ var FastCarMetaData;
6
+ (function (FastCarMetaData) {
7
+ FastCarMetaData["paramTypes"] = "design:paramtypes";
8
+ FastCarMetaData["returnType"] = "design:returntype";
9
+ FastCarMetaData["designType"] = "design:type";
10
+ FastCarMetaData["InjectionMap"] = "InjectionMap";
11
+ FastCarMetaData["IocModule"] = "IocModule";
12
+ FastCarMetaData["ComponentScan"] = "ComponentScan";
13
+ FastCarMetaData["ComponentScanExclusion"] = "ComponentScanExclusion";
14
+ FastCarMetaData["RouterMap"] = "RouterMap";
15
+ FastCarMetaData["SpecifyMap"] = "SpecifyMap";
16
+ FastCarMetaData["APP"] = "APP";
17
+ FastCarMetaData["DS"] = "dynamicDataSource";
18
+ FastCarMetaData["DSIndex"] = "dynamicDataSourceIndex";
19
+ FastCarMetaData["ValidFormRules"] = "validFormRules";
20
+ FastCarMetaData["ValidChildFormRules"] = "validChildFormRules";
21
+ FastCarMetaData["ValidSize"] = "valid:size";
22
+ FastCarMetaData["NotNull"] = "valid:notNull";
23
+ FastCarMetaData["ValidCustom"] = "valid:custom";
24
+ FastCarMetaData["Hotter"] = "hotter";
25
+ FastCarMetaData["InjectionUniqueKey"] = "injection_uniqueKey";
26
+ FastCarMetaData["Alias"] = "alias";
27
+ FastCarMetaData["LoggerModule"] = "LoggerModule";
28
+ FastCarMetaData["HotterSysConfig"] = "hotterSysConfig";
29
+ FastCarMetaData["CustomType"] = "custom:type";
30
+ FastCarMetaData["ComponentScanMust"] = "ComponentScanMust";
31
+ })(FastCarMetaData = exports.FastCarMetaData || (exports.FastCarMetaData = {}));
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LifeCycleModule = void 0;
4
+ var LifeCycleModule;
5
+ (function (LifeCycleModule) {
6
+ LifeCycleModule["ApplicationStart"] = "applicationStart";
7
+ LifeCycleModule["ApplicationStop"] = "applicationStop";
8
+ LifeCycleModule["LoadConfigure"] = "loadConfigure";
9
+ })(LifeCycleModule = exports.LifeCycleModule || (exports.LifeCycleModule = {}));
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DesignMeta = exports.SqlError = exports.BaseMapper = exports.OrderEnum = exports.JoinEnum = exports.OperatorEnum = void 0;
4
+ const BaseMapper_1 = require("./model/BaseMapper");
5
+ exports.BaseMapper = BaseMapper_1.default;
6
+ const SqlError_1 = require("./type/SqlError");
7
+ exports.SqlError = SqlError_1.default;
8
+ var OperatorEnum;
9
+ (function (OperatorEnum) {
10
+ OperatorEnum["eq"] = "=";
11
+ OperatorEnum["neq"] = "!=";
12
+ OperatorEnum["gt"] = ">";
13
+ OperatorEnum["gte"] = ">=";
14
+ OperatorEnum["lt"] = "<";
15
+ OperatorEnum["lte"] = "<=";
16
+ OperatorEnum["like"] = "LIKE";
17
+ OperatorEnum["in"] = "IN";
18
+ OperatorEnum["isNUll"] = "ISNULL";
19
+ OperatorEnum["isNotNull"] = "IS NOT NULL";
20
+ OperatorEnum["inc"] = "+";
21
+ OperatorEnum["dec"] = "-";
22
+ OperatorEnum["multiply"] = "*";
23
+ OperatorEnum["division"] = "/";
24
+ OperatorEnum["notin"] = "NOT IN";
25
+ OperatorEnum["custom"] = "CUSTOM";
26
+ })(OperatorEnum = exports.OperatorEnum || (exports.OperatorEnum = {}));
27
+ var JoinEnum;
28
+ (function (JoinEnum) {
29
+ JoinEnum["and"] = "AND";
30
+ JoinEnum["or"] = "OR";
31
+ JoinEnum["not"] = "NOT";
32
+ })(JoinEnum = exports.JoinEnum || (exports.JoinEnum = {}));
33
+ var OrderEnum;
34
+ (function (OrderEnum) {
35
+ OrderEnum["asc"] = "ASC";
36
+ OrderEnum["desc"] = "DESC";
37
+ })(OrderEnum = exports.OrderEnum || (exports.OrderEnum = {}));
38
+ var DesignMeta;
39
+ (function (DesignMeta) {
40
+ DesignMeta["table"] = "db:table";
41
+ DesignMeta["field"] = "db:field";
42
+ DesignMeta["fieldMap"] = "db:fieldMap";
43
+ DesignMeta["dbType"] = "db:dbType";
44
+ DesignMeta["primaryKey"] = "db:primaryKey";
45
+ DesignMeta["entity"] = "db:entity";
46
+ DesignMeta["mapping"] = "db:mapping";
47
+ DesignMeta["dbFields"] = "db:fields";
48
+ DesignMeta["sqlSession"] = "SqlSession";
49
+ })(DesignMeta = exports.DesignMeta || (exports.DesignMeta = {}));
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommonConstant = exports.Logger = exports.DataMap = exports.ValidError = exports.FastCarMetaData = exports.FastCarApplication = exports.BootPriority = exports.ComponentKind = exports.LifeCycleModule = void 0;
4
+ const BootPriority_1 = require("./constant/BootPriority");
5
+ Object.defineProperty(exports, "BootPriority", { enumerable: true, get: function () { return BootPriority_1.BootPriority; } });
6
+ const CommonConstant_1 = require("./constant/CommonConstant");
7
+ Object.defineProperty(exports, "CommonConstant", { enumerable: true, get: function () { return CommonConstant_1.CommonConstant; } });
8
+ const ComponentKind_1 = require("./constant/ComponentKind");
9
+ Object.defineProperty(exports, "ComponentKind", { enumerable: true, get: function () { return ComponentKind_1.ComponentKind; } });
10
+ const FastCarMetaData_1 = require("./constant/FastCarMetaData");
11
+ Object.defineProperty(exports, "FastCarMetaData", { enumerable: true, get: function () { return FastCarMetaData_1.FastCarMetaData; } });
12
+ const LifeCycleModule_1 = require("./constant/LifeCycleModule");
13
+ Object.defineProperty(exports, "LifeCycleModule", { enumerable: true, get: function () { return LifeCycleModule_1.LifeCycleModule; } });
14
+ const FastCarApplication_1 = require("./FastCarApplication");
15
+ exports.FastCarApplication = FastCarApplication_1.default;
16
+ const Logger_1 = require("./interface/Logger");
17
+ exports.Logger = Logger_1.default;
18
+ const DataMap_1 = require("./model/DataMap");
19
+ exports.DataMap = DataMap_1.default;
20
+ const ValidError_1 = require("./model/ValidError");
21
+ exports.ValidError = ValidError_1.default;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Logger {
4
+ }
5
+ exports.default = Logger;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const DesignMeta_1 = require("../type/DesignMeta");
4
+ const DataFormat_1 = require("../utils/DataFormat");
5
+ class BaseMapper {
6
+ tableName;
7
+ classZ; //映射的原型类
8
+ mappingMap; //代码别名-映射关系
9
+ mappingList;
10
+ dbFields; //数据库别名-代码别名
11
+ /***
12
+ * @version 1.0 对于类型做一个转换
13
+ */
14
+ constructor() {
15
+ let tClass = Reflect.getMetadata(DesignMeta_1.DesignMeta.entity, this);
16
+ this.classZ = tClass;
17
+ let tableName = Reflect.getMetadata(DesignMeta_1.DesignMeta.table, tClass);
18
+ if (!tableName) {
19
+ throw new Error(`This class ${tClass.name} has no annotation table name`);
20
+ }
21
+ this.tableName = tableName;
22
+ this.mappingMap = Reflect.getMetadata(DesignMeta_1.DesignMeta.mapping, tClass); //映射关系
23
+ this.dbFields = Reflect.getMetadata(DesignMeta_1.DesignMeta.dbFields, tClass); //作用的列名
24
+ this.mappingList = Array.of();
25
+ this.mappingMap.forEach(item => {
26
+ this.mappingList.push(item);
27
+ });
28
+ }
29
+ //获取数据库别名通过代码内的名称
30
+ getFieldName(name) {
31
+ let info = this.mappingMap.get(name);
32
+ return info ? info.field : name;
33
+ }
34
+ setRow(rowData) {
35
+ let t = new this.classZ();
36
+ this.mappingMap.forEach((item, key) => {
37
+ let value = Reflect.get(rowData, item.field) || Reflect.get(rowData, key);
38
+ if (value != null) {
39
+ let fvalue = DataFormat_1.default.formatValue(value, item.type);
40
+ Reflect.set(t, key, fvalue);
41
+ }
42
+ });
43
+ return t;
44
+ }
45
+ setRows(rowDataList) {
46
+ let list = Array.of();
47
+ rowDataList.forEach(item => {
48
+ list.push(this.setRow(item));
49
+ });
50
+ return list;
51
+ }
52
+ saveORUpdate(rows, ds, sessionId) {
53
+ throw new Error("Method not implemented.");
54
+ }
55
+ saveOne(row, ds, sessionId) {
56
+ throw new Error("Method not implemented.");
57
+ }
58
+ saveList(rows, ds, sessionId) {
59
+ throw new Error("Method not implemented.");
60
+ }
61
+ update({ row, where, limit }, ds, sessionId) {
62
+ throw new Error("Method not implemented.");
63
+ }
64
+ updateOne(sqlUpdate, ds, sessionId) {
65
+ throw new Error("Method not implemented.");
66
+ }
67
+ updateByPrimaryKey(row, ds, sessionId) {
68
+ throw new Error("Method not implemented.");
69
+ }
70
+ select(conditions, ds, sessionId) {
71
+ throw new Error("Method not implemented.");
72
+ }
73
+ /***
74
+ * @version 1.0 查询单个对象
75
+ *
76
+ */
77
+ async selectOne(conditions, ds, sessionId) {
78
+ throw new Error("Method not implemented.");
79
+ }
80
+ /***
81
+ * @version 1.0 通过主键查找对象
82
+ *
83
+ */
84
+ async selectByPrimaryKey(row, ds, sessionId) {
85
+ throw new Error("Method not implemented.");
86
+ }
87
+ exist(where, ds, sessionId) {
88
+ throw new Error("Method not implemented.");
89
+ }
90
+ count(where, ds, sessionId) {
91
+ throw new Error("Method not implemented.");
92
+ }
93
+ delete(conditions, ds, sessionId) {
94
+ throw new Error("Method not implemented.");
95
+ }
96
+ deleteOne(where, ds, sessionId) {
97
+ throw new Error("Method not implemented.");
98
+ }
99
+ deleteByPrimaryKey(row, ds, sessionId) {
100
+ throw new Error("Method not implemented.");
101
+ }
102
+ }
103
+ exports.default = BaseMapper;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class DataMap extends Map {
4
+ constructor() {
5
+ super();
6
+ }
7
+ toValues() {
8
+ return [...this.values()];
9
+ }
10
+ toKeys() {
11
+ return [...this.keys()];
12
+ }
13
+ toObject() {
14
+ let o = {};
15
+ this.forEach((v, k) => {
16
+ Reflect.set(o, k, v);
17
+ });
18
+ return o;
19
+ }
20
+ //自定义排序 支持多个排序
21
+ sort(sorts, list) {
22
+ list = !list ? this.toValues() : list;
23
+ if (!sorts || sorts?.length == 0) {
24
+ return list;
25
+ }
26
+ let total = sorts.length;
27
+ list.sort((a, b) => {
28
+ let resultNum = 0;
29
+ sorts.some((f, index) => {
30
+ let field = f.field;
31
+ let aValue = Reflect.get(a, field);
32
+ let bValue = Reflect.get(b, field);
33
+ let flag = f.compare ? f.compare(aValue, bValue) : aValue > bValue;
34
+ resultNum = flag ? total - index : index - total;
35
+ //降序则倒着
36
+ if (f.order) {
37
+ resultNum = -resultNum;
38
+ }
39
+ return !!flag;
40
+ });
41
+ return resultNum;
42
+ });
43
+ return list;
44
+ }
45
+ /***
46
+ * @version 1.0 查找属性名称
47
+ * @params atts代表属性键值对匹配
48
+ *
49
+ */
50
+ findByAtts(atts) {
51
+ let list = [];
52
+ let keys = Object.keys(atts);
53
+ this.forEach((item) => {
54
+ let flag = keys.every((key) => {
55
+ let v = Reflect.get(atts, key);
56
+ //这边判断 是不是一个复合属性
57
+ if (Reflect.has(item, key)) {
58
+ let itemV = Reflect.get(item, key);
59
+ return itemV == v;
60
+ }
61
+ else {
62
+ let keyList = key.split(".");
63
+ if (keyList.length > 1) {
64
+ let tmpV = item;
65
+ let f = keyList.every((tk) => {
66
+ if (!Reflect.has(tmpV, tk)) {
67
+ return false;
68
+ }
69
+ tmpV = Reflect.get(tmpV, tk);
70
+ return true;
71
+ });
72
+ if (!f) {
73
+ return false;
74
+ }
75
+ return tmpV == v;
76
+ }
77
+ }
78
+ return false;
79
+ });
80
+ if (flag) {
81
+ list.push(item);
82
+ }
83
+ });
84
+ return list;
85
+ }
86
+ }
87
+ exports.default = DataMap;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ValidError extends Error {
4
+ }
5
+ exports.default = ValidError;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const winston = require("winston");
4
+ const WinstonLoggerType_1 = require("../type/WinstonLoggerType");
5
+ const path = require("path");
6
+ const utils_1 = require("../utils");
7
+ const util = require("util");
8
+ const SPLAT = Symbol.for("splat");
9
+ class WinstonLogger {
10
+ config;
11
+ categoryMap;
12
+ constructor(config) {
13
+ this.config = config;
14
+ this.categoryMap = new Map();
15
+ }
16
+ //控制台着色
17
+ colorize(str, level) {
18
+ let colorStyle = Reflect.get(WinstonLoggerType_1.ColorLevelType, level);
19
+ if (!colorStyle) {
20
+ return str;
21
+ }
22
+ return `\x1B[${colorStyle[0]}m ${str} \x1B[${colorStyle[1]}m`;
23
+ }
24
+ //数据着色为白色
25
+ colorizeData(data) {
26
+ let msg = utils_1.ValidationUtil.isObject(data) ? JSON.stringify(data) : data;
27
+ return `\x1B[37m ${msg} \x1B[39m`;
28
+ }
29
+ setConfig(config) {
30
+ this.config = config;
31
+ }
32
+ hasLogger(category) {
33
+ return winston.loggers.has(category);
34
+ }
35
+ getLogger(category) {
36
+ return this.categoryMap.get(category);
37
+ }
38
+ addLogger(category) {
39
+ if (this.categoryMap.has(category)) {
40
+ winston.loggers.close(category);
41
+ }
42
+ let newLogger = winston.loggers.add(category, {
43
+ format: winston.format.combine(winston.format.label({ label: category }), winston.format.printf(info => {
44
+ //debug模式等级时仅为控制台输出
45
+ let level = info.level.toUpperCase();
46
+ let timestamp = utils_1.DateUtil.toDateTimeMS();
47
+ let content = {
48
+ timestamp,
49
+ level,
50
+ label: info.label,
51
+ message: info.message,
52
+ };
53
+ if (Reflect.has(info, SPLAT)) {
54
+ Reflect.set(content, "splat", JSON.stringify(Reflect.get(info, SPLAT)));
55
+ }
56
+ if (info.stack) {
57
+ Reflect.set(content, "stack", info.stack);
58
+ }
59
+ Reflect.set(info, "timestamp", content.timestamp);
60
+ //新增打印控制台
61
+ if (this.config.printConsole) {
62
+ let text = this.colorize(util.format("[%s] [%s] %s - ", timestamp, level, info.label), info.level);
63
+ text += this.colorizeData(content.message);
64
+ if (Reflect.has(info, SPLAT)) {
65
+ let splatMsg = Reflect.get(info, SPLAT);
66
+ splatMsg.forEach(item => {
67
+ text += " " + this.colorizeData(item);
68
+ });
69
+ }
70
+ if (info.stack) {
71
+ text += this.colorizeData(`\nstatck: ${info.stack}`);
72
+ }
73
+ let fn = console.info;
74
+ if (Reflect.has(console, info.level)) {
75
+ fn = Reflect.get(console, info.level);
76
+ }
77
+ Reflect.apply(fn, console, [text]);
78
+ }
79
+ return util.format("%j", content);
80
+ })),
81
+ transports: [
82
+ new winston.transports.File({
83
+ level: this.config.fileLevel,
84
+ filename: path.join(this.config.rootPath, `${category}.log`),
85
+ maxsize: this.config.maxsize,
86
+ maxFiles: this.config.maxFiles,
87
+ }),
88
+ ],
89
+ });
90
+ this.categoryMap.set(category, newLogger);
91
+ return newLogger;
92
+ }
93
+ getLoggerList() {
94
+ return [...this.categoryMap.values()];
95
+ }
96
+ }
97
+ exports.default = WinstonLogger;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DesignMeta = void 0;
4
+ var DesignMeta;
5
+ (function (DesignMeta) {
6
+ DesignMeta["table"] = "db:table";
7
+ DesignMeta["field"] = "db:field";
8
+ DesignMeta["fieldMap"] = "db:fieldMap";
9
+ DesignMeta["dbType"] = "db:dbType";
10
+ DesignMeta["primaryKey"] = "db:primaryKey";
11
+ DesignMeta["entity"] = "db:entity";
12
+ DesignMeta["mapping"] = "db:mapping";
13
+ DesignMeta["dbFields"] = "db:fields";
14
+ DesignMeta["sqlSession"] = "SqlSession";
15
+ })(DesignMeta = exports.DesignMeta || (exports.DesignMeta = {}));
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class SqlError extends Error {
4
+ }
5
+ exports.default = SqlError;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColorLevelType = void 0;
4
+ exports.ColorLevelType = {
5
+ info: [32, 39],
6
+ debug: [36, 39],
7
+ warn: [33, 39],
8
+ error: [91, 39], //red
9
+ };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const TypeUtil_1 = require("./TypeUtil");
4
+ const FileUtil_1 = require("./FileUtil");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ class ClassLoader {
8
+ /***
9
+ * @version 1.0 加载模块
10
+ * @version 1.1 新增是否强制重载模块
11
+ *
12
+ */
13
+ static loadModule(filePath, force = false) {
14
+ //校验后缀名是否为js或者ts
15
+ if (!TypeUtil_1.default.isTSORJS(filePath)) {
16
+ return null;
17
+ }
18
+ //避免重复加载或者想要重新进行挂载
19
+ if (Reflect.has(require.cache, filePath)) {
20
+ if (force) {
21
+ Reflect.deleteProperty(require.cache, filePath);
22
+ }
23
+ }
24
+ //可能不止一个方法
25
+ const modulesMap = new Map();
26
+ //进行方法加载
27
+ let moduleClass = require(filePath);
28
+ let keys = Object.keys(moduleClass);
29
+ let fileName = FileUtil_1.default.getFileName(filePath);
30
+ keys.forEach((key) => {
31
+ let instance = moduleClass[key];
32
+ if (TypeUtil_1.default.isFunction(instance)) {
33
+ modulesMap.set(instance.name, instance);
34
+ return;
35
+ }
36
+ if (TypeUtil_1.default.isObject(instance)) {
37
+ modulesMap.set(fileName, instance);
38
+ }
39
+ });
40
+ return modulesMap;
41
+ }
42
+ /**
43
+ * @version 1.0 监听某个文件或者文件夹
44
+ */
45
+ static watchServices(fp, context, eventName = "reload") {
46
+ if (typeof context.emit != "function") {
47
+ return false;
48
+ }
49
+ const currStats = fs.statSync(fp);
50
+ let fileFlag = currStats.isFile();
51
+ //添加热更方法
52
+ fs.watch(fp, function (event, filename) {
53
+ if (event === "change") {
54
+ if (!fileFlag) {
55
+ context.emit(eventName, path.join(fp, filename));
56
+ }
57
+ else {
58
+ context.emit(eventName, fp);
59
+ }
60
+ }
61
+ });
62
+ return true;
63
+ }
64
+ }
65
+ exports.default = ClassLoader;