@fastcar/core 0.2.63 → 0.3.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 (143) hide show
  1. package/README.md +5 -2
  2. package/annotation.d.ts +3 -0
  3. package/index.d.ts +57 -50
  4. package/package.json +4 -4
  5. package/src/FastCarApplication.ts +184 -123
  6. package/src/annotation/Application.ts +3 -1
  7. package/src/annotation/bind/AddInjectionService.ts +17 -0
  8. package/src/annotation/bind/AddRequireModule.ts +1 -1
  9. package/src/annotation/bind/AliasInjection.ts +8 -15
  10. package/src/annotation/bind/Autowired.ts +1 -1
  11. package/src/annotation/bind/CallDependency.ts +7 -17
  12. package/src/annotation/bind/DemandInjection.ts +16 -0
  13. package/src/annotation/stereotype/Log.ts +13 -9
  14. package/src/annotation/stereotype/Value.ts +5 -0
  15. package/src/annotation.ts +2 -0
  16. package/src/constant/FastCarMetaData.ts +2 -0
  17. package/src/model/WinstonLogger.ts +1 -1
  18. package/src/type/ClassConstructor.ts +5 -0
  19. package/src/type/ComponentDesc.ts +13 -0
  20. package/src/type/FileHotterDesc.ts +6 -0
  21. package/src/utils/ClassLoader.ts +2 -1
  22. package/src/utils/ValidationUtil.ts +1 -1
  23. package/target/FastCarApplication.js +764 -708
  24. package/target/annotation/Application.js +46 -45
  25. package/target/annotation/ExceptionMonitor.js +16 -16
  26. package/target/annotation/bind/AddInjectionService.js +16 -0
  27. package/target/annotation/bind/AddRequireModule.js +21 -21
  28. package/target/annotation/bind/AliasInjection.js +19 -23
  29. package/target/annotation/bind/Autowired.js +13 -13
  30. package/target/annotation/bind/CallDependency.js +16 -23
  31. package/target/annotation/bind/DemandInjection.js +15 -0
  32. package/target/annotation/data/DBType.js +11 -11
  33. package/target/annotation/data/DS.js +54 -54
  34. package/target/annotation/data/DSIndex.js +9 -9
  35. package/target/annotation/data/Entity.js +10 -10
  36. package/target/annotation/data/Field.js +18 -18
  37. package/target/annotation/data/PrimaryKey.js +9 -9
  38. package/target/annotation/data/SqlSession.js +9 -9
  39. package/target/annotation/data/Table.js +35 -35
  40. package/target/annotation/data/Transactional.js +52 -52
  41. package/target/annotation/env/ApplicationSetting.js +25 -25
  42. package/target/annotation/env/BaseFilePath.js +14 -14
  43. package/target/annotation/env/BaseName.js +9 -9
  44. package/target/annotation/env/BasePath.js +14 -14
  45. package/target/annotation/env/ENV.js +10 -10
  46. package/target/annotation/env/ResourcePath.js +9 -9
  47. package/target/annotation/lifeCycle/AddLifeCycleItem.js +17 -18
  48. package/target/annotation/lifeCycle/ApplicationDestory.js +15 -15
  49. package/target/annotation/lifeCycle/ApplicationInit.js +15 -15
  50. package/target/annotation/lifeCycle/ApplicationRunner.js +7 -7
  51. package/target/annotation/lifeCycle/ApplicationStart.js +24 -24
  52. package/target/annotation/lifeCycle/ApplicationStop.js +20 -20
  53. package/target/annotation/property/Deprecate.js +19 -19
  54. package/target/annotation/property/NotImplemented.js +8 -8
  55. package/target/annotation/property/Override.js +7 -7
  56. package/target/annotation/property/Readonly.js +16 -16
  57. package/target/annotation/scan/ComponentInjection.js +21 -21
  58. package/target/annotation/scan/ComponentScan.js +9 -9
  59. package/target/annotation/scan/ComponentScanExclusion.js +25 -25
  60. package/target/annotation/scan/ComponentScanMust.js +25 -25
  61. package/target/annotation/scan/Hotter.js +8 -8
  62. package/target/annotation/stereotype/BeanName.js +11 -11
  63. package/target/annotation/stereotype/Component.js +8 -8
  64. package/target/annotation/stereotype/Configure.js +14 -14
  65. package/target/annotation/stereotype/Controller.js +9 -9
  66. package/target/annotation/stereotype/Injection.js +12 -12
  67. package/target/annotation/stereotype/Log.js +19 -17
  68. package/target/annotation/stereotype/Repository.js +9 -9
  69. package/target/annotation/stereotype/Service.js +9 -9
  70. package/target/annotation/stereotype/Value.js +5 -0
  71. package/target/annotation/valid/AddChildValid.js +56 -56
  72. package/target/annotation/valid/CustomType.js +11 -11
  73. package/target/annotation/valid/DefaultVal.js +10 -10
  74. package/target/annotation/valid/NotNull.js +8 -8
  75. package/target/annotation/valid/Rule.js +99 -100
  76. package/target/annotation/valid/Size.js +10 -10
  77. package/target/annotation/valid/Type.js +10 -10
  78. package/target/annotation/valid/ValidCustom.js +17 -17
  79. package/target/annotation/valid/ValidForm.js +133 -133
  80. package/target/annotation.js +110 -108
  81. package/target/config/ApplicationConfig.js +2 -2
  82. package/target/config/SysConfig.js +19 -19
  83. package/target/constant/AppStatusEnum.js +9 -9
  84. package/target/constant/BootPriority.js +11 -11
  85. package/target/constant/CommonConstant.js +18 -18
  86. package/target/constant/ComponentKind.js +11 -11
  87. package/target/constant/DataTypes.js +19 -19
  88. package/target/constant/FastCarMetaData.js +33 -31
  89. package/target/constant/LifeCycleModule.js +9 -9
  90. package/target/db.js +49 -49
  91. package/target/index.js +21 -21
  92. package/target/interface/ApplicationHook.js +2 -2
  93. package/target/interface/ApplicationInterface.js +2 -2
  94. package/target/interface/ApplicationRunnerService.js +2 -2
  95. package/target/interface/DataSourceManager.js +2 -2
  96. package/target/interface/Logger.js +5 -5
  97. package/target/model/BaseMapper.js +103 -98
  98. package/target/model/DataMap.js +87 -87
  99. package/target/model/FormRuleModel.js +2 -2
  100. package/target/model/ValidError.js +5 -5
  101. package/target/model/WinstonLogger.js +98 -96
  102. package/target/type/ClassConstructor.js +2 -0
  103. package/target/type/ComponentDesc.js +9 -2
  104. package/target/type/DesignMeta.js +15 -15
  105. package/target/type/FileHotterDesc.js +9 -2
  106. package/target/type/MapperType.js +2 -2
  107. package/target/type/ProcessType.js +2 -2
  108. package/target/type/SqlError.js +5 -5
  109. package/target/type/WinstonLoggerType.js +9 -9
  110. package/target/utils/ClassLoader.js +66 -65
  111. package/target/utils/ClassUtils.js +35 -35
  112. package/target/utils/CryptoUtil.js +86 -86
  113. package/target/utils/DataFormat.js +88 -88
  114. package/target/utils/DateUtil.js +71 -71
  115. package/target/utils/FileUtil.js +153 -153
  116. package/target/utils/FormatStr.js +14 -14
  117. package/target/utils/IPUtils.js +34 -34
  118. package/target/utils/Id.js +8 -9
  119. package/target/utils/Mix.js +62 -62
  120. package/target/utils/ReflectUtil.js +22 -22
  121. package/target/utils/TypeUtil.js +53 -53
  122. package/target/utils/ValidationUtil.js +123 -123
  123. package/target/utils.js +25 -25
  124. package/test/example/logs/fastcar-server.app.log +0 -0
  125. package/test/example/logs/fastcar-server.sys.log +10 -0
  126. package/test/example/logs/fastcar-server.sys1.log +8 -0
  127. package/test/example/logs/fastcar-server.sys2.log +11 -0
  128. package/test/example/logs/fastcar-server.sys3.log +0 -0
  129. package/test/example/logs/other-server.app.log +0 -0
  130. package/test/example/logs/other-server.sys.log +5 -0
  131. package/test/example/logs/sys.log +0 -0
  132. package/test/example/logs/sys1.log +0 -0
  133. package/test/example/resource/application.yml +2 -0
  134. package/test/example/resource/hello.yml +1 -1
  135. package/test/example/simple/app-test.ts +2 -1
  136. package/test/example/simple/app.ts +16 -16
  137. package/test/example/simple/service/CallService.ts +2 -0
  138. package/test/example/simple/service/HelloService.ts +2 -0
  139. package/test/unit/sys2.log +6 -0
  140. package/test/unit/sys3.log +6 -0
  141. package/test/unit/sys4.log +6 -0
  142. package/test/unit/sys5.log +6 -0
  143. package/test/unit/sys6.log +6 -0
@@ -1,35 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("reflect-metadata");
4
- const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
5
- const DesignMeta_1 = require("../../type/DesignMeta");
6
- //表名称 不缺省
7
- function Table(name) {
8
- return function (target) {
9
- const proto = target.prototype;
10
- let fields = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.fieldMap, proto);
11
- let mappingMap = new Map();
12
- let dbFields = new Map();
13
- fields.forEach((c) => {
14
- let tsType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.designType, proto, c);
15
- let field = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.field, proto, c) || c;
16
- let dbType = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.dbType, proto, c) || "varchar";
17
- let primaryKey = !!Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.primaryKey, proto, c);
18
- let tsName = tsType.name;
19
- let customeType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.CustomType, proto, c);
20
- const m = {
21
- name: c,
22
- type: customeType || tsName.toLowerCase(),
23
- field,
24
- dbType: dbType,
25
- primaryKey, //是否为主键 默认为false
26
- };
27
- dbFields.set(field, c);
28
- mappingMap.set(c, m);
29
- });
30
- Reflect.defineMetadata(DesignMeta_1.DesignMeta.dbFields, dbFields, target); //作用的列名
31
- Reflect.defineMetadata(DesignMeta_1.DesignMeta.mapping, mappingMap, target); //映射关系
32
- Reflect.defineMetadata(DesignMeta_1.DesignMeta.table, name, target); //注入表名
33
- };
34
- }
35
- exports.default = Table;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = Table;
4
+ require("reflect-metadata");
5
+ const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
6
+ const DesignMeta_1 = require("../../type/DesignMeta");
7
+ //表名称 不缺省
8
+ function Table(name) {
9
+ return function (target) {
10
+ const proto = target.prototype;
11
+ let fields = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.fieldMap, proto);
12
+ let mappingMap = new Map();
13
+ let dbFields = new Map();
14
+ fields.forEach((c) => {
15
+ let tsType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.designType, proto, c);
16
+ let field = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.field, proto, c) || c;
17
+ let dbType = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.dbType, proto, c) || "varchar";
18
+ let primaryKey = !!Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.primaryKey, proto, c);
19
+ let tsName = tsType.name;
20
+ let customeType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.CustomType, proto, c);
21
+ const m = {
22
+ name: c, //变量名称
23
+ type: customeType || tsName.toLowerCase(), //ts类型
24
+ field, //数据库列名
25
+ dbType: dbType, //数据类型
26
+ primaryKey, //是否为主键 默认为false
27
+ };
28
+ dbFields.set(field, c);
29
+ mappingMap.set(c, m);
30
+ });
31
+ Reflect.defineMetadata(DesignMeta_1.DesignMeta.dbFields, dbFields, target); //作用的列名
32
+ Reflect.defineMetadata(DesignMeta_1.DesignMeta.mapping, mappingMap, target); //映射关系
33
+ Reflect.defineMetadata(DesignMeta_1.DesignMeta.table, name, target); //注入表名
34
+ };
35
+ }
@@ -1,52 +1,52 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("reflect-metadata");
4
- const CommonConstant_1 = require("../../constant/CommonConstant");
5
- const DesignMeta_1 = require("../../type/DesignMeta");
6
- const SqlError_1 = require("../../type/SqlError");
7
- /**
8
- * @version 1.0 事务管理 不建议多个事务的嵌套(避免长事务) 尽量做到一个方法一个事务
9
- * */
10
- function Transactional(driver = "MysqlDataSourceManager") {
11
- return function (target, methodName, descriptor) {
12
- const orignFunction = descriptor.value;
13
- //在初始化时就应该检测是否注入了sessionID
14
- const paramsIndex = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.sqlSession, target, methodName);
15
- if (typeof paramsIndex != "number") {
16
- throw new SqlError_1.default(`${methodName} needs to inject the SqlSession`);
17
- }
18
- descriptor.value = async function (...args) {
19
- //创建会话id
20
- let app = Reflect.get(global, CommonConstant_1.CommonConstant.FastcarApp);
21
- let sysLogger = app.getSysLogger() || console;
22
- let dsm = app.getComponentByName(driver);
23
- if (!dsm) {
24
- sysLogger.error(`DataSourceManager ${driver} not found`);
25
- return Promise.reject(new SqlError_1.default(`DataSourceManager ${driver} not found`));
26
- }
27
- let sessionId = args[paramsIndex];
28
- if (sessionId) {
29
- return Promise.resolve(Reflect.apply(orignFunction, this, args));
30
- }
31
- let errFlag = false;
32
- sessionId = dsm.createSession();
33
- args[paramsIndex] = sessionId;
34
- let res = null;
35
- return new Promise((resolve, reject) => {
36
- Reflect.apply(orignFunction, this, args)
37
- .then((result) => {
38
- res = result;
39
- })
40
- .catch((e) => {
41
- sysLogger.error(e);
42
- errFlag = true;
43
- })
44
- .finally(async () => {
45
- await dsm.destorySession(sessionId, errFlag);
46
- return !errFlag ? resolve(res) : reject(new SqlError_1.default(`${methodName} exec fail `));
47
- });
48
- });
49
- };
50
- };
51
- }
52
- exports.default = Transactional;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = Transactional;
4
+ require("reflect-metadata");
5
+ const CommonConstant_1 = require("../../constant/CommonConstant");
6
+ const DesignMeta_1 = require("../../type/DesignMeta");
7
+ const SqlError_1 = require("../../type/SqlError");
8
+ /**
9
+ * @version 1.0 事务管理 不建议多个事务的嵌套(避免长事务) 尽量做到一个方法一个事务
10
+ * */
11
+ function Transactional(driver = "MysqlDataSourceManager") {
12
+ return function (target, methodName, descriptor) {
13
+ const orignFunction = descriptor.value;
14
+ //在初始化时就应该检测是否注入了sessionID
15
+ const paramsIndex = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.sqlSession, target, methodName);
16
+ if (typeof paramsIndex != "number") {
17
+ throw new SqlError_1.default(`${methodName} needs to inject the SqlSession`);
18
+ }
19
+ descriptor.value = async function (...args) {
20
+ //创建会话id
21
+ let app = Reflect.get(global, CommonConstant_1.CommonConstant.FastcarApp);
22
+ let sysLogger = app.getSysLogger() || console;
23
+ let dsm = app.getComponentByName(driver);
24
+ if (!dsm) {
25
+ sysLogger.error(`DataSourceManager ${driver} not found`);
26
+ return Promise.reject(new SqlError_1.default(`DataSourceManager ${driver} not found`));
27
+ }
28
+ let sessionId = args[paramsIndex];
29
+ if (sessionId) {
30
+ return Promise.resolve(Reflect.apply(orignFunction, this, args));
31
+ }
32
+ let errFlag = false;
33
+ sessionId = dsm.createSession();
34
+ args[paramsIndex] = sessionId;
35
+ let res = null;
36
+ return new Promise((resolve, reject) => {
37
+ Reflect.apply(orignFunction, this, args)
38
+ .then((result) => {
39
+ res = result;
40
+ })
41
+ .catch((e) => {
42
+ sysLogger.error(e);
43
+ errFlag = true;
44
+ })
45
+ .finally(async () => {
46
+ await dsm.destorySession(sessionId, errFlag);
47
+ return !errFlag ? resolve(res) : reject(new SqlError_1.default(`${methodName} exec fail `));
48
+ });
49
+ });
50
+ };
51
+ };
52
+ }
@@ -1,25 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const CommonConstant_1 = require("../../constant/CommonConstant");
4
- const FastCarApplication_1 = require("../../FastCarApplication");
5
- //应用程序设置 具有最高权限
6
- function ApplicationSetting(setting) {
7
- return function (target) {
8
- let fastcarSetting = Reflect.getMetadata(CommonConstant_1.CommonConstant.FastcarSetting, FastCarApplication_1.default.prototype);
9
- if (!fastcarSetting) {
10
- fastcarSetting = new Map();
11
- }
12
- Object.keys(setting).forEach((key) => {
13
- let afterConfig = setting[key];
14
- let beforeConfig = fastcarSetting.get(key);
15
- if (beforeConfig) {
16
- if (typeof beforeConfig == "object") {
17
- afterConfig = Object.assign(beforeConfig, afterConfig);
18
- }
19
- }
20
- fastcarSetting.set(key, afterConfig);
21
- });
22
- Reflect.defineMetadata(CommonConstant_1.CommonConstant.FastcarSetting, fastcarSetting, FastCarApplication_1.default.prototype);
23
- };
24
- }
25
- exports.default = ApplicationSetting;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ApplicationSetting;
4
+ const CommonConstant_1 = require("../../constant/CommonConstant");
5
+ const FastCarApplication_1 = require("../../FastCarApplication");
6
+ //应用程序设置 具有最高权限
7
+ function ApplicationSetting(setting) {
8
+ return function (target) {
9
+ let fastcarSetting = Reflect.getMetadata(CommonConstant_1.CommonConstant.FastcarSetting, FastCarApplication_1.default.prototype);
10
+ if (!fastcarSetting) {
11
+ fastcarSetting = new Map();
12
+ }
13
+ Object.keys(setting).forEach((key) => {
14
+ let afterConfig = setting[key];
15
+ let beforeConfig = fastcarSetting.get(key);
16
+ if (beforeConfig) {
17
+ if (typeof beforeConfig == "object") {
18
+ afterConfig = Object.assign(beforeConfig, afterConfig);
19
+ }
20
+ }
21
+ fastcarSetting.set(key, afterConfig);
22
+ });
23
+ Reflect.defineMetadata(CommonConstant_1.CommonConstant.FastcarSetting, fastcarSetting, FastCarApplication_1.default.prototype);
24
+ };
25
+ }
@@ -1,14 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const CommonConstant_1 = require("../../constant/CommonConstant");
4
- const fs = require("fs");
5
- //设置运行是的主路径
6
- function BaseFilePath(name) {
7
- return function (target) {
8
- let stats = fs.statSync(name);
9
- if (stats.isFile()) {
10
- Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BaseFileName, name);
11
- }
12
- };
13
- }
14
- exports.default = BaseFilePath;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = BaseFilePath;
4
+ const CommonConstant_1 = require("../../constant/CommonConstant");
5
+ const fs = require("fs");
6
+ //设置运行是的主路径
7
+ function BaseFilePath(name) {
8
+ return function (target) {
9
+ let stats = fs.statSync(name);
10
+ if (stats.isFile()) {
11
+ Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BaseFileName, name);
12
+ }
13
+ };
14
+ }
@@ -1,9 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const CommonConstant_1 = require("../../constant/CommonConstant");
4
- function BaseName(name) {
5
- return function (target) {
6
- Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BaseName, name);
7
- };
8
- }
9
- exports.default = BaseName;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = BaseName;
4
+ const CommonConstant_1 = require("../../constant/CommonConstant");
5
+ function BaseName(name) {
6
+ return function (target) {
7
+ Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BaseName, name);
8
+ };
9
+ }
@@ -1,14 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const CommonConstant_1 = require("../../constant/CommonConstant");
4
- const fs = require("fs");
5
- //设置运行是的主路径
6
- function BasePath(name) {
7
- return function (target) {
8
- let stats = fs.statSync(name);
9
- if (stats.isDirectory()) {
10
- Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BasePath, name);
11
- }
12
- };
13
- }
14
- exports.default = BasePath;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = BasePath;
4
+ const CommonConstant_1 = require("../../constant/CommonConstant");
5
+ const fs = require("fs");
6
+ //设置运行是的主路径
7
+ function BasePath(name) {
8
+ return function (target) {
9
+ let stats = fs.statSync(name);
10
+ if (stats.isDirectory()) {
11
+ Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BasePath, name);
12
+ }
13
+ };
14
+ }
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const CommonConstant_1 = require("../../constant/CommonConstant");
4
- //设置初始化的env 注入在原始的application上面
5
- function ENV(name) {
6
- return function (target) {
7
- Reflect.set(target.prototype, CommonConstant_1.CommonConstant.ENV, name);
8
- };
9
- }
10
- exports.default = ENV;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ENV;
4
+ const CommonConstant_1 = require("../../constant/CommonConstant");
5
+ //设置初始化的env 注入在原始的application上面
6
+ function ENV(name) {
7
+ return function (target) {
8
+ Reflect.set(target.prototype, CommonConstant_1.CommonConstant.ENV, name);
9
+ };
10
+ }
@@ -1,9 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const CommonConstant_1 = require("../../constant/CommonConstant");
4
- function ResourcePath(name) {
5
- return function (target) {
6
- Reflect.set(target.prototype, CommonConstant_1.CommonConstant.ResourcePath, name);
7
- };
8
- }
9
- exports.default = ResourcePath;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ResourcePath;
4
+ const CommonConstant_1 = require("../../constant/CommonConstant");
5
+ function ResourcePath(name) {
6
+ return function (target) {
7
+ Reflect.set(target.prototype, CommonConstant_1.CommonConstant.ResourcePath, name);
8
+ };
9
+ }
@@ -1,18 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AddLifeCycleItem = void 0;
4
- function AddLifeCycleItem(target, lifeCycle, item) {
5
- let list = Reflect.getMetadata(lifeCycle, target);
6
- if (!list) {
7
- list = [];
8
- }
9
- let exist = list.some((fitem) => {
10
- return item.exec == fitem.exec;
11
- });
12
- if (exist) {
13
- return;
14
- }
15
- list.push(item);
16
- Reflect.defineMetadata(lifeCycle, list, target);
17
- }
18
- exports.AddLifeCycleItem = AddLifeCycleItem;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddLifeCycleItem = AddLifeCycleItem;
4
+ function AddLifeCycleItem(target, lifeCycle, item) {
5
+ let list = Reflect.getMetadata(lifeCycle, target);
6
+ if (!list) {
7
+ list = [];
8
+ }
9
+ let exist = list.some((fitem) => {
10
+ return item.exec == fitem.exec;
11
+ });
12
+ if (exist) {
13
+ return;
14
+ }
15
+ list.push(item);
16
+ Reflect.defineMetadata(lifeCycle, list, target);
17
+ }
@@ -1,15 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const BootPriority_1 = require("../../constant/BootPriority");
4
- const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
5
- const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
6
- //启动时机
7
- function ApplicationDestory(order = BootPriority_1.BootPriority.Sys) {
8
- return function (target, method, value) {
9
- (0, AddLifeCycleItem_1.AddLifeCycleItem)(target, LifeCycleModule_1.LifeCycleModule.ApplicationStop, {
10
- order,
11
- exec: method,
12
- });
13
- };
14
- }
15
- exports.default = ApplicationDestory;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ApplicationDestory;
4
+ const BootPriority_1 = require("../../constant/BootPriority");
5
+ const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
6
+ const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
7
+ //启动时机
8
+ function ApplicationDestory(order = BootPriority_1.BootPriority.Sys) {
9
+ return function (target, method, value) {
10
+ (0, AddLifeCycleItem_1.AddLifeCycleItem)(target, LifeCycleModule_1.LifeCycleModule.ApplicationStop, {
11
+ order,
12
+ exec: method,
13
+ });
14
+ };
15
+ }
@@ -1,15 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const BootPriority_1 = require("../../constant/BootPriority");
4
- const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
5
- const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
6
- //启动时机
7
- function ApplicationInit(order = BootPriority_1.BootPriority.Sys) {
8
- return function (target, method, value) {
9
- (0, AddLifeCycleItem_1.AddLifeCycleItem)(target, LifeCycleModule_1.LifeCycleModule.ApplicationStart, {
10
- order,
11
- exec: method,
12
- });
13
- };
14
- }
15
- exports.default = ApplicationInit;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ApplicationInit;
4
+ const BootPriority_1 = require("../../constant/BootPriority");
5
+ const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
6
+ const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
7
+ //启动时机
8
+ function ApplicationInit(order = BootPriority_1.BootPriority.Sys) {
9
+ return function (target, method, value) {
10
+ (0, AddLifeCycleItem_1.AddLifeCycleItem)(target, LifeCycleModule_1.LifeCycleModule.ApplicationStart, {
11
+ order,
12
+ exec: method,
13
+ });
14
+ };
15
+ }
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const Component_1 = require("../stereotype/Component");
4
- function ApplicationRunner(target) {
5
- (0, Component_1.default)(target);
6
- }
7
- exports.default = ApplicationRunner;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ApplicationRunner;
4
+ const Component_1 = require("../stereotype/Component");
5
+ function ApplicationRunner(target) {
6
+ (0, Component_1.default)(target);
7
+ }
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const BootPriority_1 = require("../../constant/BootPriority");
4
- const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
5
- const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
6
- const ApplicationRunner_1 = require("./ApplicationRunner");
7
- /****
8
- * @version 1.0 在应用启动后自动执行
9
- * @params order 排序 序号越小排在越前面 系统级的组件 如数据库等一般为0
10
- * @params exec 执行方法
11
- */
12
- function ApplicationStart(order = BootPriority_1.BootPriority.Sys, exec = "run") {
13
- return function (target) {
14
- if (!Reflect.has(target.prototype, exec)) {
15
- throw new Error(`${target.name} has no implementation ${exec} method`);
16
- }
17
- (0, ApplicationRunner_1.default)(target);
18
- (0, AddLifeCycleItem_1.AddLifeCycleItem)(target.prototype, LifeCycleModule_1.LifeCycleModule.ApplicationStart, {
19
- order,
20
- exec,
21
- });
22
- };
23
- }
24
- exports.default = ApplicationStart;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ApplicationStart;
4
+ const BootPriority_1 = require("../../constant/BootPriority");
5
+ const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
6
+ const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
7
+ const ApplicationRunner_1 = require("./ApplicationRunner");
8
+ /****
9
+ * @version 1.0 在应用启动后自动执行
10
+ * @params order 排序 序号越小排在越前面 系统级的组件 如数据库等一般为0
11
+ * @params exec 执行方法
12
+ */
13
+ function ApplicationStart(order = BootPriority_1.BootPriority.Sys, exec = "run") {
14
+ return function (target) {
15
+ if (!Reflect.has(target.prototype, exec)) {
16
+ throw new Error(`${target.name} has no implementation ${exec} method`);
17
+ }
18
+ (0, ApplicationRunner_1.default)(target);
19
+ (0, AddLifeCycleItem_1.AddLifeCycleItem)(target.prototype, LifeCycleModule_1.LifeCycleModule.ApplicationStart, {
20
+ order,
21
+ exec,
22
+ });
23
+ };
24
+ }
@@ -1,20 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const BootPriority_1 = require("../../constant/BootPriority");
4
- const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
5
- const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
6
- const ApplicationRunner_1 = require("./ApplicationRunner");
7
- //在应用停止前触发
8
- function ApplicationStop(order = BootPriority_1.BootPriority.Sys, exec = "run") {
9
- return function (target) {
10
- if (!Reflect.has(target.prototype, exec)) {
11
- throw new Error(`${target.name} has no implementation ${exec} method`);
12
- }
13
- (0, ApplicationRunner_1.default)(target);
14
- (0, AddLifeCycleItem_1.AddLifeCycleItem)(target.prototype, LifeCycleModule_1.LifeCycleModule.ApplicationStop, {
15
- order,
16
- exec,
17
- });
18
- };
19
- }
20
- exports.default = ApplicationStop;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ApplicationStop;
4
+ const BootPriority_1 = require("../../constant/BootPriority");
5
+ const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
6
+ const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
7
+ const ApplicationRunner_1 = require("./ApplicationRunner");
8
+ //在应用停止前触发
9
+ function ApplicationStop(order = BootPriority_1.BootPriority.Sys, exec = "run") {
10
+ return function (target) {
11
+ if (!Reflect.has(target.prototype, exec)) {
12
+ throw new Error(`${target.name} has no implementation ${exec} method`);
13
+ }
14
+ (0, ApplicationRunner_1.default)(target);
15
+ (0, AddLifeCycleItem_1.AddLifeCycleItem)(target.prototype, LifeCycleModule_1.LifeCycleModule.ApplicationStop, {
16
+ order,
17
+ exec,
18
+ });
19
+ };
20
+ }
@@ -1,19 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const DEFAULT_MSG = "This function will be removed in future versions.";
4
- /****
5
- * @version 1.0 用于标记弃用
6
- */
7
- function Deprecate(msg = DEFAULT_MSG) {
8
- return function (target, prop, descriptor) {
9
- console.warn(prop ? prop : Reflect.get(target, "name"), msg);
10
- if (descriptor) {
11
- const fn = descriptor.value;
12
- descriptor.value = function (...args) {
13
- console.warn(prop, msg);
14
- return Reflect.apply(fn, this, args);
15
- };
16
- }
17
- };
18
- }
19
- exports.default = Deprecate;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = Deprecate;
4
+ const DEFAULT_MSG = "This function will be removed in future versions.";
5
+ /****
6
+ * @version 1.0 用于标记弃用
7
+ */
8
+ function Deprecate(msg = DEFAULT_MSG) {
9
+ return function (target, prop, descriptor) {
10
+ console.warn(prop ? prop : Reflect.get(target, "name"), msg);
11
+ if (descriptor) {
12
+ const fn = descriptor.value;
13
+ descriptor.value = function (...args) {
14
+ console.warn(prop, msg);
15
+ return Reflect.apply(fn, this, args);
16
+ };
17
+ }
18
+ };
19
+ }
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /***
4
- * @version 1.0 不实现说明
5
- *
6
- */
7
- function NotImplemented(target, name, descriptor) { }
8
- exports.default = NotImplemented;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = NotImplemented;
4
+ /***
5
+ * @version 1.0 不实现说明
6
+ *
7
+ */
8
+ function NotImplemented(target, name, descriptor) { }