@fastcar/core 0.2.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +379 -0
- package/annotation.d.ts +157 -0
- package/db.d.ts +272 -0
- package/index.d.ts +262 -0
- package/package.json +53 -0
- package/src/FastCarApplication.ts +761 -0
- package/src/annotation/Application.ts +46 -0
- package/src/annotation/ExceptionMonitor.ts +15 -0
- package/src/annotation/bind/AddRequireModule.ts +18 -0
- package/src/annotation/bind/AliasInjection.ts +24 -0
- package/src/annotation/bind/Autowired.ts +11 -0
- package/src/annotation/bind/CallDependency.ts +24 -0
- package/src/annotation/data/DBType.ts +9 -0
- package/src/annotation/data/DS.ts +58 -0
- package/src/annotation/data/DSIndex.ts +7 -0
- package/src/annotation/data/Entity.ts +8 -0
- package/src/annotation/data/Field.ts +15 -0
- package/src/annotation/data/PrimaryKey.ts +7 -0
- package/src/annotation/data/SqlSession.ts +7 -0
- package/src/annotation/data/Table.ts +37 -0
- package/src/annotation/data/Transactional.ts +60 -0
- package/src/annotation/env/ApplicationSetting.ts +24 -0
- package/src/annotation/env/BaseFilePath.ts +12 -0
- package/src/annotation/env/BasePath.ts +12 -0
- package/src/annotation/env/ENV.ts +8 -0
- package/src/annotation/env/ResourcePath.ts +7 -0
- package/src/annotation/lifeCycle/AddLifeCycleItem.ts +25 -0
- package/src/annotation/lifeCycle/ApplicationDestory.ts +13 -0
- package/src/annotation/lifeCycle/ApplicationInit.ts +13 -0
- package/src/annotation/lifeCycle/ApplicationRunner.ts +5 -0
- package/src/annotation/lifeCycle/ApplicationStart.ts +23 -0
- package/src/annotation/lifeCycle/ApplicationStop.ts +18 -0
- package/src/annotation/property/Deprecate.ts +17 -0
- package/src/annotation/property/NotImplemented.ts +5 -0
- package/src/annotation/property/Override.ts +4 -0
- package/src/annotation/property/Readonly.ts +12 -0
- package/src/annotation/scan/ComponentInjection.ts +22 -0
- package/src/annotation/scan/ComponentScan.ts +7 -0
- package/src/annotation/scan/ComponentScanExclusion.ts +26 -0
- package/src/annotation/scan/Hotter.ts +6 -0
- package/src/annotation/stereotype/BeanName.ts +9 -0
- package/src/annotation/stereotype/Component.ts +6 -0
- package/src/annotation/stereotype/Configure.ts +12 -0
- package/src/annotation/stereotype/Controller.ts +7 -0
- package/src/annotation/stereotype/Injection.ts +10 -0
- package/src/annotation/stereotype/Log.ts +17 -0
- package/src/annotation/stereotype/Repository.ts +7 -0
- package/src/annotation/stereotype/Service.ts +7 -0
- package/src/annotation/valid/AddChildValid.ts +61 -0
- package/src/annotation/valid/DefaultVal.ts +8 -0
- package/src/annotation/valid/NotNull.ts +7 -0
- package/src/annotation/valid/Rule.ts +104 -0
- package/src/annotation/valid/Size.ts +13 -0
- package/src/annotation/valid/Type.ts +8 -0
- package/src/annotation/valid/ValidCustom.ts +21 -0
- package/src/annotation/valid/ValidForm.ts +146 -0
- package/src/annotation.ts +103 -0
- package/src/config/ApplicationConfig.ts +5 -0
- package/src/config/SysConfig.ts +28 -0
- package/src/constant/AppStatusEnum.ts +5 -0
- package/src/constant/BootPriority.ts +7 -0
- package/src/constant/CommonConstant.ts +14 -0
- package/src/constant/ComponentKind.ts +7 -0
- package/src/constant/DataTypes.ts +15 -0
- package/src/constant/FastCarMetaData.ts +25 -0
- package/src/constant/LifeCycleModule.ts +5 -0
- package/src/db.ts +182 -0
- package/src/index.ts +11 -0
- package/src/interface/ApplicationHook.ts +9 -0
- package/src/interface/ApplicationRunnerService.ts +3 -0
- package/src/interface/DataSourceManager.ts +14 -0
- package/src/interface/Logger.ts +9 -0
- package/src/model/BaseMapper.ts +115 -0
- package/src/model/DataMap.ts +103 -0
- package/src/model/FormRuleModel.ts +23 -0
- package/src/model/ValidError.ts +1 -0
- package/src/model/WinstonLogger.ts +119 -0
- package/src/type/ComponentDesc.ts +5 -0
- package/src/type/DesignMeta.ts +11 -0
- package/src/type/FileHotterDesc.ts +4 -0
- package/src/type/MapperType.ts +8 -0
- package/src/type/ProcessType.ts +12 -0
- package/src/type/SqlError.ts +3 -0
- package/src/type/WinstonLoggerType.ts +18 -0
- package/src/utils/ClassLoader.ts +72 -0
- package/src/utils/ClassUtils.ts +38 -0
- package/src/utils/CryptoUtil.ts +106 -0
- package/src/utils/DataFormat.ts +97 -0
- package/src/utils/DateUtil.ts +85 -0
- package/src/utils/FileUtil.ts +172 -0
- package/src/utils/FormatStr.ts +13 -0
- package/src/utils/Mix.ts +69 -0
- package/src/utils/ReflectUtil.ts +22 -0
- package/src/utils/TypeUtil.ts +56 -0
- package/src/utils/ValidationUtil.ts +138 -0
- package/src/utils.ts +13 -0
- package/target/FastCarApplication.js +661 -0
- package/target/annotation/AddRequireModule.js +21 -0
- package/target/annotation/Application.js +45 -0
- package/target/annotation/Autowired.js +15 -0
- package/target/annotation/Calldependency.js +18 -0
- package/target/annotation/ExceptionMonitor.js +16 -0
- package/target/annotation/bind/AddRequireModule.js +21 -0
- package/target/annotation/bind/AliasInjection.js +23 -0
- package/target/annotation/bind/Autowired.js +13 -0
- package/target/annotation/bind/CallDependency.js +23 -0
- package/target/annotation/data/DBType.js +11 -0
- package/target/annotation/data/DS.js +54 -0
- package/target/annotation/data/DSIndex.js +9 -0
- package/target/annotation/data/Entity.js +10 -0
- package/target/annotation/data/Field.js +18 -0
- package/target/annotation/data/PrimaryKey.js +9 -0
- package/target/annotation/data/SqlSession.js +9 -0
- package/target/annotation/data/Table.js +34 -0
- package/target/annotation/data/Transactional.js +52 -0
- package/target/annotation/env/ApplicationSetting.js +25 -0
- package/target/annotation/env/BaseFilePath.js +14 -0
- package/target/annotation/env/BasePath.js +14 -0
- package/target/annotation/env/ENV.js +10 -0
- package/target/annotation/env/ResourcePath.js +9 -0
- package/target/annotation/lifeCycle/AddLifeCycleItem.js +18 -0
- package/target/annotation/lifeCycle/ApplicationDestory.js +15 -0
- package/target/annotation/lifeCycle/ApplicationInit.js +15 -0
- package/target/annotation/lifeCycle/ApplicationRunner.js +7 -0
- package/target/annotation/lifeCycle/ApplicationStart.js +24 -0
- package/target/annotation/lifeCycle/ApplicationStop.js +20 -0
- package/target/annotation/property/Deprecate.js +19 -0
- package/target/annotation/property/NotImplemented.js +8 -0
- package/target/annotation/property/Override.js +7 -0
- package/target/annotation/property/Readonly.js +16 -0
- package/target/annotation/scan/ComponentInjection.js +21 -0
- package/target/annotation/scan/ComponentScan.js +9 -0
- package/target/annotation/scan/ComponentScanExclusion.js +25 -0
- package/target/annotation/scan/Hotter.js +8 -0
- package/target/annotation/stereotype/BeanName.js +11 -0
- package/target/annotation/stereotype/Component.js +8 -0
- package/target/annotation/stereotype/Configure.js +14 -0
- package/target/annotation/stereotype/Controller.js +9 -0
- package/target/annotation/stereotype/Injection.js +12 -0
- package/target/annotation/stereotype/Log.js +16 -0
- package/target/annotation/stereotype/Repository.js +9 -0
- package/target/annotation/stereotype/Service.js +9 -0
- package/target/annotation/valid/AddChildValid.js +56 -0
- package/target/annotation/valid/DefaultVal.js +10 -0
- package/target/annotation/valid/NotNull.js +8 -0
- package/target/annotation/valid/Rule.js +100 -0
- package/target/annotation/valid/Size.js +10 -0
- package/target/annotation/valid/Type.js +10 -0
- package/target/annotation/valid/ValidCustom.js +17 -0
- package/target/annotation/valid/ValidForm.js +131 -0
- package/target/annotation.js +101 -0
- package/target/config/ApplicationConfig.js +2 -0
- package/target/config/SysConfig.js +19 -0
- package/target/constant/AppStatusEnum.js +9 -0
- package/target/constant/BootPriority.js +11 -0
- package/target/constant/CommonConstant.js +16 -0
- package/target/constant/ComponentKind.js +11 -0
- package/target/constant/DataTypes.js +19 -0
- package/target/constant/FastCarMetaData.js +29 -0
- package/target/constant/LifeCycleModule.js +9 -0
- package/target/db.js +46 -0
- package/target/index.js +21 -0
- package/target/interface/ApplicationHook.js +2 -0
- package/target/interface/ApplicationRunnerService.js +2 -0
- package/target/interface/DataSourceManager.js +2 -0
- package/target/interface/Logger.js +5 -0
- package/target/model/BaseMapper.js +98 -0
- package/target/model/DataMap.js +87 -0
- package/target/model/FormRuleModel.js +2 -0
- package/target/model/ValidError.js +5 -0
- package/target/model/WinstonLogger.js +95 -0
- package/target/type/ComponentDesc.js +2 -0
- package/target/type/DesignMeta.js +15 -0
- package/target/type/FileHotterDesc.js +2 -0
- package/target/type/MapperType.js +2 -0
- package/target/type/ProcessType.js +2 -0
- package/target/type/SqlError.js +5 -0
- package/target/type/WinstonLoggerType.js +9 -0
- package/target/utils/ClassUtils.js +35 -0
- package/target/utils/CryptoUtil.js +84 -0
- package/target/utils/DataFormat.js +84 -0
- package/target/utils/DateUtil.js +71 -0
- package/target/utils/FileUtil.js +153 -0
- package/target/utils/FormatStr.js +14 -0
- package/target/utils/Mix.js +62 -0
- package/target/utils/ReflectUtil.js +22 -0
- package/target/utils/TypeUtil.js +47 -0
- package/target/utils/ValidationUtil.js +118 -0
- package/target/utils/classLoader.js +65 -0
- package/target/utils.js +23 -0
- package/test/example/logs/app.log +0 -0
- package/test/example/logs/logger.log +12 -0
- package/test/example/logs/logger1.log +12 -0
- package/test/example/logs/logger2.log +12 -0
- package/test/example/logs/logger3.log +12 -0
- package/test/example/logs/logger4.log +12 -0
- package/test/example/logs/logger5.log +6 -0
- package/test/example/logs/sys.log +7 -0
- package/test/example/logs/sys1.log +14 -0
- package/test/example/logs/sys10.log +12 -0
- package/test/example/logs/sys11.log +5 -0
- package/test/example/logs/sys13.log +5 -0
- package/test/example/logs/sys2.log +3 -0
- package/test/example/logs/sys4.log +15 -0
- package/test/example/logs/sys5.log +9 -0
- package/test/example/logs/sys6.log +10 -0
- package/test/example/logs/sys7.log +15 -0
- package/test/example/logs/sys8.log +11 -0
- package/test/example/logs/sys9.log +10 -0
- package/test/example/resource/application-test.yml +0 -0
- package/test/example/resource/application.yml +7 -0
- package/test/example/resource/evnconfig-test.yml +1 -0
- package/test/example/resource/hello.yml +1 -0
- package/test/example/simple/app.ts +99 -0
- package/test/example/simple/component/StartRunner.ts +10 -0
- package/test/example/simple/component/StopRunner.ts +14 -0
- package/test/example/simple/config/EnvConfig.ts +6 -0
- package/test/example/simple/config/HelloConfig.ts +8 -0
- package/test/example/simple/controller/AliasController.ts +6 -0
- package/test/example/simple/controller/HelloController.ts +39 -0
- package/test/example/simple/controller/NotFoundController.ts +20 -0
- package/test/example/simple/service/CallService.ts +11 -0
- package/test/example/simple/service/HelloService.ts +10 -0
- package/test/example/simple/service/LogService.ts +19 -0
- package/test/logs/logger.log +0 -0
- package/test/logs/sys.log +227 -0
- package/test/multi/app.ts +15 -0
- package/test/multi/service/aService.ts +16 -0
- package/test/multi/service/bService.ts +18 -0
- package/test/multi/service/cService.ts +21 -0
- package/test/unit/dataMap-test.ts +48 -0
- package/test/unit/decorators-test.ts +38 -0
- package/test/unit/ds-test.ts +33 -0
- package/test/unit/logs/sys.log +24 -0
- package/test/unit/reflectMetadata-test.ts +15 -0
- package/test/unit/valid-test.ts +65 -0
- package/test/unit/winston-test.ts +15 -0
- package/utils.d.ts +166 -0
|
@@ -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,16 @@
|
|
|
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
|
+
};
|
|
16
|
+
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,29 @@
|
|
|
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 = 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 = {}));
|
package/target/db.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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 = exports.OperatorEnum || (exports.OperatorEnum = {}));
|
|
25
|
+
var JoinEnum;
|
|
26
|
+
(function (JoinEnum) {
|
|
27
|
+
JoinEnum["and"] = "AND";
|
|
28
|
+
JoinEnum["or"] = "OR";
|
|
29
|
+
})(JoinEnum = exports.JoinEnum || (exports.JoinEnum = {}));
|
|
30
|
+
var OrderEnum;
|
|
31
|
+
(function (OrderEnum) {
|
|
32
|
+
OrderEnum["asc"] = "ASC";
|
|
33
|
+
OrderEnum["desc"] = "DESC";
|
|
34
|
+
})(OrderEnum = exports.OrderEnum || (exports.OrderEnum = {}));
|
|
35
|
+
var DesignMeta;
|
|
36
|
+
(function (DesignMeta) {
|
|
37
|
+
DesignMeta["table"] = "db:table";
|
|
38
|
+
DesignMeta["field"] = "db:field";
|
|
39
|
+
DesignMeta["fieldMap"] = "db:fieldMap";
|
|
40
|
+
DesignMeta["dbType"] = "db:dbType";
|
|
41
|
+
DesignMeta["primaryKey"] = "db:primaryKey";
|
|
42
|
+
DesignMeta["entity"] = "db:entity";
|
|
43
|
+
DesignMeta["mapping"] = "db:mapping";
|
|
44
|
+
DesignMeta["dbFields"] = "db:fields";
|
|
45
|
+
DesignMeta["sqlSession"] = "SqlSession";
|
|
46
|
+
})(DesignMeta = exports.DesignMeta || (exports.DesignMeta = {}));
|
package/target/index.js
ADDED
|
@@ -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,98 @@
|
|
|
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
|
+
/***
|
|
7
|
+
* @version 1.0 对于类型做一个转换
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
let tClass = Reflect.getMetadata(DesignMeta_1.DesignMeta.entity, this);
|
|
11
|
+
this.classZ = tClass;
|
|
12
|
+
let tableName = Reflect.getMetadata(DesignMeta_1.DesignMeta.table, tClass);
|
|
13
|
+
if (!tableName) {
|
|
14
|
+
throw new Error(`This class ${tClass.name} has no annotation table name`);
|
|
15
|
+
}
|
|
16
|
+
this.tableName = tableName;
|
|
17
|
+
this.mappingMap = Reflect.getMetadata(DesignMeta_1.DesignMeta.mapping, tClass); //映射关系
|
|
18
|
+
this.dbFields = Reflect.getMetadata(DesignMeta_1.DesignMeta.dbFields, tClass); //作用的列名
|
|
19
|
+
this.mappingList = Array.of();
|
|
20
|
+
this.mappingMap.forEach(item => {
|
|
21
|
+
this.mappingList.push(item);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//获取数据库别名通过代码内的名称
|
|
25
|
+
getFieldName(name) {
|
|
26
|
+
let info = this.mappingMap.get(name);
|
|
27
|
+
return info ? info.field : name;
|
|
28
|
+
}
|
|
29
|
+
setRow(rowData) {
|
|
30
|
+
let t = new this.classZ();
|
|
31
|
+
this.mappingMap.forEach((item, key) => {
|
|
32
|
+
let value = Reflect.get(rowData, item.field) || Reflect.get(rowData, key);
|
|
33
|
+
if (value != null) {
|
|
34
|
+
let fvalue = DataFormat_1.default.formatValue(value, item.type);
|
|
35
|
+
Reflect.set(t, key, fvalue);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return t;
|
|
39
|
+
}
|
|
40
|
+
setRows(rowDataList) {
|
|
41
|
+
let list = Array.of();
|
|
42
|
+
rowDataList.forEach(item => {
|
|
43
|
+
list.push(this.setRow(item));
|
|
44
|
+
});
|
|
45
|
+
return list;
|
|
46
|
+
}
|
|
47
|
+
saveORUpdate(rows, ds, sessionId) {
|
|
48
|
+
throw new Error("Method not implemented.");
|
|
49
|
+
}
|
|
50
|
+
saveOne(row, ds, sessionId) {
|
|
51
|
+
throw new Error("Method not implemented.");
|
|
52
|
+
}
|
|
53
|
+
saveList(rows, ds, sessionId) {
|
|
54
|
+
throw new Error("Method not implemented.");
|
|
55
|
+
}
|
|
56
|
+
update({ row, where, limit }, ds, sessionId) {
|
|
57
|
+
throw new Error("Method not implemented.");
|
|
58
|
+
}
|
|
59
|
+
updateOne(sqlUpdate, ds, sessionId) {
|
|
60
|
+
throw new Error("Method not implemented.");
|
|
61
|
+
}
|
|
62
|
+
updateByPrimaryKey(row, ds, sessionId) {
|
|
63
|
+
throw new Error("Method not implemented.");
|
|
64
|
+
}
|
|
65
|
+
select(conditions, ds, sessionId) {
|
|
66
|
+
throw new Error("Method not implemented.");
|
|
67
|
+
}
|
|
68
|
+
/***
|
|
69
|
+
* @version 1.0 查询单个对象
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
async selectOne(conditions, ds, sessionId) {
|
|
73
|
+
throw new Error("Method not implemented.");
|
|
74
|
+
}
|
|
75
|
+
/***
|
|
76
|
+
* @version 1.0 通过主键查找对象
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
async selectByPrimaryKey(row, ds, sessionId) {
|
|
80
|
+
throw new Error("Method not implemented.");
|
|
81
|
+
}
|
|
82
|
+
exist(where, ds, sessionId) {
|
|
83
|
+
throw new Error("Method not implemented.");
|
|
84
|
+
}
|
|
85
|
+
count(where, ds, sessionId) {
|
|
86
|
+
throw new Error("Method not implemented.");
|
|
87
|
+
}
|
|
88
|
+
delete(conditions, ds, sessionId) {
|
|
89
|
+
throw new Error("Method not implemented.");
|
|
90
|
+
}
|
|
91
|
+
deleteOne(where, ds, sessionId) {
|
|
92
|
+
throw new Error("Method not implemented.");
|
|
93
|
+
}
|
|
94
|
+
deleteByPrimaryKey(row, ds, sessionId) {
|
|
95
|
+
throw new Error("Method not implemented.");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
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,95 @@
|
|
|
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
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.categoryMap = new Map();
|
|
13
|
+
}
|
|
14
|
+
//控制台着色
|
|
15
|
+
colorize(str, level) {
|
|
16
|
+
let colorStyle = Reflect.get(WinstonLoggerType_1.ColorLevelType, level);
|
|
17
|
+
if (!colorStyle) {
|
|
18
|
+
return str;
|
|
19
|
+
}
|
|
20
|
+
return `\x1B[${colorStyle[0]}m ${str} \x1B[${colorStyle[1]}m`;
|
|
21
|
+
}
|
|
22
|
+
//数据着色为白色
|
|
23
|
+
colorizeData(data) {
|
|
24
|
+
let msg = utils_1.ValidationUtil.isObject(data) ? JSON.stringify(data) : data;
|
|
25
|
+
return `\x1B[37m ${msg} \x1B[39m`;
|
|
26
|
+
}
|
|
27
|
+
setConfig(config) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
}
|
|
30
|
+
hasLogger(category) {
|
|
31
|
+
return winston.loggers.has(category);
|
|
32
|
+
}
|
|
33
|
+
getLogger(category) {
|
|
34
|
+
return this.categoryMap.get(category);
|
|
35
|
+
}
|
|
36
|
+
addLogger(category) {
|
|
37
|
+
if (this.categoryMap.has(category)) {
|
|
38
|
+
winston.loggers.close(category);
|
|
39
|
+
}
|
|
40
|
+
let newLogger = winston.loggers.add(category, {
|
|
41
|
+
format: winston.format.combine(winston.format.label({ label: category }), winston.format.printf(info => {
|
|
42
|
+
//debug模式等级时仅为控制台输出
|
|
43
|
+
let level = info.level.toUpperCase();
|
|
44
|
+
let timestamp = utils_1.DateUtil.toDateTimeMS();
|
|
45
|
+
let content = {
|
|
46
|
+
timestamp,
|
|
47
|
+
level,
|
|
48
|
+
label: info.label,
|
|
49
|
+
message: info.message,
|
|
50
|
+
};
|
|
51
|
+
if (Reflect.has(info, SPLAT)) {
|
|
52
|
+
Reflect.set(content, "splat", JSON.stringify(Reflect.get(info, SPLAT)));
|
|
53
|
+
}
|
|
54
|
+
if (info.stack) {
|
|
55
|
+
Reflect.set(content, "stack", info.stack);
|
|
56
|
+
}
|
|
57
|
+
Reflect.set(info, "timestamp", content.timestamp);
|
|
58
|
+
//新增打印控制台
|
|
59
|
+
if (this.config.printConsole) {
|
|
60
|
+
let text = this.colorize(util.format("[%s] [%s] %s - ", timestamp, level, info.label), info.level);
|
|
61
|
+
text += this.colorizeData(content.message);
|
|
62
|
+
if (Reflect.has(info, SPLAT)) {
|
|
63
|
+
let splatMsg = Reflect.get(info, SPLAT);
|
|
64
|
+
splatMsg.forEach(item => {
|
|
65
|
+
text += " " + this.colorizeData(item);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (info.stack) {
|
|
69
|
+
text += this.colorizeData(`\nstatck: ${info.stack}`);
|
|
70
|
+
}
|
|
71
|
+
let fn = console.info;
|
|
72
|
+
if (Reflect.has(console, info.level)) {
|
|
73
|
+
fn = Reflect.get(console, info.level);
|
|
74
|
+
}
|
|
75
|
+
Reflect.apply(fn, console, [text]);
|
|
76
|
+
}
|
|
77
|
+
return util.format("%j", content);
|
|
78
|
+
})),
|
|
79
|
+
transports: [
|
|
80
|
+
new winston.transports.File({
|
|
81
|
+
level: this.config.fileLevel,
|
|
82
|
+
filename: path.join(this.config.rootPath, `${category}.log`),
|
|
83
|
+
maxsize: this.config.maxsize,
|
|
84
|
+
maxFiles: this.config.maxFiles,
|
|
85
|
+
}),
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
this.categoryMap.set(category, newLogger);
|
|
89
|
+
return newLogger;
|
|
90
|
+
}
|
|
91
|
+
getLoggerList() {
|
|
92
|
+
return [...this.categoryMap.values()];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.default = WinstonLogger;
|
|
@@ -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,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ClassUtils {
|
|
4
|
+
//获取一个类所有的proto属性 采用递归的形式
|
|
5
|
+
static getProtoType(t) {
|
|
6
|
+
if (!t?.prototype) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
let keys = Reflect.ownKeys(t?.prototype).map((item) => {
|
|
10
|
+
return item;
|
|
11
|
+
});
|
|
12
|
+
let parentObj = Reflect.getPrototypeOf(t);
|
|
13
|
+
if (!parentObj || !Reflect.has(parentObj, "prototype")) {
|
|
14
|
+
return keys;
|
|
15
|
+
}
|
|
16
|
+
let parentKeys = ClassUtils.getProtoType(parentObj);
|
|
17
|
+
let s = new Set([...keys, ...parentKeys]);
|
|
18
|
+
return [...s];
|
|
19
|
+
}
|
|
20
|
+
static getProtoDesc(t, key) {
|
|
21
|
+
if (!t?.prototype) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
let desc = Object.getOwnPropertyDescriptor(t.prototype, key);
|
|
25
|
+
if (!!desc) {
|
|
26
|
+
return desc;
|
|
27
|
+
}
|
|
28
|
+
let parentObj = Reflect.getPrototypeOf(t);
|
|
29
|
+
if (!parentObj || !Reflect.has(parentObj, "prototype")) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return ClassUtils.getProtoDesc(parentObj, key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = ClassUtils;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const crypto = require("crypto");
|
|
4
|
+
class CryptoUtil {
|
|
5
|
+
static aesDecode(cryptkey, iv, secretdata, aesType = "aes-256-cbc" /* aes */) {
|
|
6
|
+
let decipher = crypto.createDecipheriv(aesType, cryptkey, iv);
|
|
7
|
+
let decoded = decipher.update(secretdata, "base64", "utf8");
|
|
8
|
+
decoded += decipher.final("utf8");
|
|
9
|
+
return decoded;
|
|
10
|
+
}
|
|
11
|
+
static aesEncode(cryptkey, iv, cleardata, aesType = "aes-256-cbc" /* aes */) {
|
|
12
|
+
let encipher = crypto.createCipheriv("aes-256-cbc" /* aes */, cryptkey, iv);
|
|
13
|
+
let encoded = encipher.update(cleardata, "utf8", "base64");
|
|
14
|
+
encoded += encipher.final("base64");
|
|
15
|
+
return encoded;
|
|
16
|
+
}
|
|
17
|
+
static shaEncode(cryptkey, data) {
|
|
18
|
+
let hash = crypto.createHmac("sha256", cryptkey);
|
|
19
|
+
return hash.update(data).digest("base64");
|
|
20
|
+
}
|
|
21
|
+
static gcmEncrypt(password, msg) {
|
|
22
|
+
try {
|
|
23
|
+
let pwd = Buffer.from(password, "hex");
|
|
24
|
+
let iv = crypto.randomBytes(12);
|
|
25
|
+
let cipher = crypto.createCipheriv("aes-128-gcm", pwd, iv);
|
|
26
|
+
//加密
|
|
27
|
+
let enc = cipher.update(msg, "utf8", "base64");
|
|
28
|
+
enc += cipher.final("base64");
|
|
29
|
+
//cipher.getAuthTag() 方法返回一个 Buffer,它包含已从给定数据计算后的认证标签。
|
|
30
|
+
//cipher.getAuthTag() 方法只能在使用 cipher.final() 之后调用 这里返回的是一个十六进制后的数组
|
|
31
|
+
let tags = cipher.getAuthTag();
|
|
32
|
+
let encStr = Buffer.from(enc, "base64");
|
|
33
|
+
//由于和java对应的AES/GCM/PKCS5Padding模式对应 所以采用这个拼接
|
|
34
|
+
let totalLength = iv.length + encStr.length + tags.length;
|
|
35
|
+
let bufferMsg = Buffer.concat([iv, encStr, tags], totalLength);
|
|
36
|
+
return bufferMsg.toString("base64");
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
console.log("Encrypt is error", e);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
static gcmDecrypt(password, serect) {
|
|
44
|
+
try {
|
|
45
|
+
let tmpSerect = Buffer.from(serect, "base64");
|
|
46
|
+
let pwd = Buffer.from(password, "hex");
|
|
47
|
+
//读取数组
|
|
48
|
+
let iv = tmpSerect.slice(0, 12);
|
|
49
|
+
let cipher = crypto.createDecipheriv("aes-128-gcm", pwd, iv);
|
|
50
|
+
//这边的数据为 去除头的iv12位和尾部的tags的16位
|
|
51
|
+
let msg = cipher.update(tmpSerect.slice(12, tmpSerect.length - 16));
|
|
52
|
+
return msg.toString("utf8");
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
console.log("Decrypt is error", e);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
static sha256Encode(text, serect = crypto.randomBytes(32).toString("hex"), encoding = "base64") {
|
|
60
|
+
let msg = crypto
|
|
61
|
+
.createHmac("sha256", serect)
|
|
62
|
+
.update(text)
|
|
63
|
+
.digest(encoding);
|
|
64
|
+
return {
|
|
65
|
+
salt: serect,
|
|
66
|
+
msg: msg,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
static sha256EncodeContent(str, encoding = "base64") {
|
|
70
|
+
let msg = crypto
|
|
71
|
+
.createHash("sha256")
|
|
72
|
+
.update(str)
|
|
73
|
+
.digest(encoding);
|
|
74
|
+
return msg;
|
|
75
|
+
}
|
|
76
|
+
static sha256Very(msg, serect, encodeMsg, encoding = "base64") {
|
|
77
|
+
let result = this.sha256Encode(msg, serect, encoding);
|
|
78
|
+
return result.msg === encodeMsg;
|
|
79
|
+
}
|
|
80
|
+
static getHashStr(num = 16) {
|
|
81
|
+
return crypto.randomBytes(num).toString("hex");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.default = CryptoUtil;
|