@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.
- package/README.md +5 -2
- package/annotation.d.ts +3 -0
- package/index.d.ts +57 -50
- package/package.json +4 -4
- package/src/FastCarApplication.ts +184 -123
- package/src/annotation/Application.ts +3 -1
- package/src/annotation/bind/AddInjectionService.ts +17 -0
- package/src/annotation/bind/AddRequireModule.ts +1 -1
- package/src/annotation/bind/AliasInjection.ts +8 -15
- package/src/annotation/bind/Autowired.ts +1 -1
- package/src/annotation/bind/CallDependency.ts +7 -17
- package/src/annotation/bind/DemandInjection.ts +16 -0
- package/src/annotation/stereotype/Log.ts +13 -9
- package/src/annotation/stereotype/Value.ts +5 -0
- package/src/annotation.ts +2 -0
- package/src/constant/FastCarMetaData.ts +2 -0
- package/src/model/WinstonLogger.ts +1 -1
- package/src/type/ClassConstructor.ts +5 -0
- package/src/type/ComponentDesc.ts +13 -0
- package/src/type/FileHotterDesc.ts +6 -0
- package/src/utils/ClassLoader.ts +2 -1
- package/src/utils/ValidationUtil.ts +1 -1
- package/target/FastCarApplication.js +764 -708
- package/target/annotation/Application.js +46 -45
- package/target/annotation/ExceptionMonitor.js +16 -16
- package/target/annotation/bind/AddInjectionService.js +16 -0
- package/target/annotation/bind/AddRequireModule.js +21 -21
- package/target/annotation/bind/AliasInjection.js +19 -23
- package/target/annotation/bind/Autowired.js +13 -13
- package/target/annotation/bind/CallDependency.js +16 -23
- package/target/annotation/bind/DemandInjection.js +15 -0
- package/target/annotation/data/DBType.js +11 -11
- package/target/annotation/data/DS.js +54 -54
- package/target/annotation/data/DSIndex.js +9 -9
- package/target/annotation/data/Entity.js +10 -10
- package/target/annotation/data/Field.js +18 -18
- package/target/annotation/data/PrimaryKey.js +9 -9
- package/target/annotation/data/SqlSession.js +9 -9
- package/target/annotation/data/Table.js +35 -35
- package/target/annotation/data/Transactional.js +52 -52
- package/target/annotation/env/ApplicationSetting.js +25 -25
- package/target/annotation/env/BaseFilePath.js +14 -14
- package/target/annotation/env/BaseName.js +9 -9
- package/target/annotation/env/BasePath.js +14 -14
- package/target/annotation/env/ENV.js +10 -10
- package/target/annotation/env/ResourcePath.js +9 -9
- package/target/annotation/lifeCycle/AddLifeCycleItem.js +17 -18
- package/target/annotation/lifeCycle/ApplicationDestory.js +15 -15
- package/target/annotation/lifeCycle/ApplicationInit.js +15 -15
- package/target/annotation/lifeCycle/ApplicationRunner.js +7 -7
- package/target/annotation/lifeCycle/ApplicationStart.js +24 -24
- package/target/annotation/lifeCycle/ApplicationStop.js +20 -20
- package/target/annotation/property/Deprecate.js +19 -19
- package/target/annotation/property/NotImplemented.js +8 -8
- package/target/annotation/property/Override.js +7 -7
- package/target/annotation/property/Readonly.js +16 -16
- package/target/annotation/scan/ComponentInjection.js +21 -21
- package/target/annotation/scan/ComponentScan.js +9 -9
- package/target/annotation/scan/ComponentScanExclusion.js +25 -25
- package/target/annotation/scan/ComponentScanMust.js +25 -25
- package/target/annotation/scan/Hotter.js +8 -8
- package/target/annotation/stereotype/BeanName.js +11 -11
- package/target/annotation/stereotype/Component.js +8 -8
- package/target/annotation/stereotype/Configure.js +14 -14
- package/target/annotation/stereotype/Controller.js +9 -9
- package/target/annotation/stereotype/Injection.js +12 -12
- package/target/annotation/stereotype/Log.js +19 -17
- package/target/annotation/stereotype/Repository.js +9 -9
- package/target/annotation/stereotype/Service.js +9 -9
- package/target/annotation/stereotype/Value.js +5 -0
- package/target/annotation/valid/AddChildValid.js +56 -56
- package/target/annotation/valid/CustomType.js +11 -11
- package/target/annotation/valid/DefaultVal.js +10 -10
- package/target/annotation/valid/NotNull.js +8 -8
- package/target/annotation/valid/Rule.js +99 -100
- package/target/annotation/valid/Size.js +10 -10
- package/target/annotation/valid/Type.js +10 -10
- package/target/annotation/valid/ValidCustom.js +17 -17
- package/target/annotation/valid/ValidForm.js +133 -133
- package/target/annotation.js +110 -108
- package/target/config/ApplicationConfig.js +2 -2
- package/target/config/SysConfig.js +19 -19
- package/target/constant/AppStatusEnum.js +9 -9
- package/target/constant/BootPriority.js +11 -11
- package/target/constant/CommonConstant.js +18 -18
- package/target/constant/ComponentKind.js +11 -11
- package/target/constant/DataTypes.js +19 -19
- package/target/constant/FastCarMetaData.js +33 -31
- package/target/constant/LifeCycleModule.js +9 -9
- package/target/db.js +49 -49
- package/target/index.js +21 -21
- package/target/interface/ApplicationHook.js +2 -2
- package/target/interface/ApplicationInterface.js +2 -2
- package/target/interface/ApplicationRunnerService.js +2 -2
- package/target/interface/DataSourceManager.js +2 -2
- package/target/interface/Logger.js +5 -5
- package/target/model/BaseMapper.js +103 -98
- package/target/model/DataMap.js +87 -87
- package/target/model/FormRuleModel.js +2 -2
- package/target/model/ValidError.js +5 -5
- package/target/model/WinstonLogger.js +98 -96
- package/target/type/ClassConstructor.js +2 -0
- package/target/type/ComponentDesc.js +9 -2
- package/target/type/DesignMeta.js +15 -15
- package/target/type/FileHotterDesc.js +9 -2
- package/target/type/MapperType.js +2 -2
- package/target/type/ProcessType.js +2 -2
- package/target/type/SqlError.js +5 -5
- package/target/type/WinstonLoggerType.js +9 -9
- package/target/utils/ClassLoader.js +66 -65
- package/target/utils/ClassUtils.js +35 -35
- package/target/utils/CryptoUtil.js +86 -86
- package/target/utils/DataFormat.js +88 -88
- package/target/utils/DateUtil.js +71 -71
- package/target/utils/FileUtil.js +153 -153
- package/target/utils/FormatStr.js +14 -14
- package/target/utils/IPUtils.js +34 -34
- package/target/utils/Id.js +8 -9
- package/target/utils/Mix.js +62 -62
- package/target/utils/ReflectUtil.js +22 -22
- package/target/utils/TypeUtil.js +53 -53
- package/target/utils/ValidationUtil.js +123 -123
- package/target/utils.js +25 -25
- package/test/example/logs/fastcar-server.app.log +0 -0
- package/test/example/logs/fastcar-server.sys.log +10 -0
- package/test/example/logs/fastcar-server.sys1.log +8 -0
- package/test/example/logs/fastcar-server.sys2.log +11 -0
- package/test/example/logs/fastcar-server.sys3.log +0 -0
- package/test/example/logs/other-server.app.log +0 -0
- package/test/example/logs/other-server.sys.log +5 -0
- package/test/example/logs/sys.log +0 -0
- package/test/example/logs/sys1.log +0 -0
- package/test/example/resource/application.yml +2 -0
- package/test/example/resource/hello.yml +1 -1
- package/test/example/simple/app-test.ts +2 -1
- package/test/example/simple/app.ts +16 -16
- package/test/example/simple/service/CallService.ts +2 -0
- package/test/example/simple/service/HelloService.ts +2 -0
- package/test/unit/sys2.log +6 -0
- package/test/unit/sys3.log +6 -0
- package/test/unit/sys4.log +6 -0
- package/test/unit/sys5.log +6 -0
- package/test/unit/sys6.log +6 -0
package/README.md
CHANGED
|
@@ -64,7 +64,9 @@ Application 声明为一个应用
|
|
|
64
64
|
|
|
65
65
|
Autowired 自动注入依赖的组件,现在等同为CallDependency
|
|
66
66
|
|
|
67
|
-
CallDependency 调用时注入组件
|
|
67
|
+
CallDependency 调用时注入组件 0.2.11版本以上生效
|
|
68
|
+
|
|
69
|
+
DemandInjection 当注入组件时在实例化对象时进行扫描注入 0.3.0版本以上生效
|
|
68
70
|
|
|
69
71
|
AliasInjection 根据别名注入组件
|
|
70
72
|
|
|
@@ -261,8 +263,9 @@ class HelloConfig {
|
|
|
261
263
|
```ts
|
|
262
264
|
//调用依赖版本示例
|
|
263
265
|
import HelloService from "./HelloService";
|
|
264
|
-
import { CallDependency } from "@fastcar/core/annotation";
|
|
266
|
+
import { CallDependency, DemandInjection } from "@fastcar/core/annotation";
|
|
265
267
|
|
|
268
|
+
@DemandInjection //如果没有标明是一个组件则需要使用该方法表明是一个延迟组件
|
|
266
269
|
export default class CallService {
|
|
267
270
|
|
|
268
271
|
//仅在调用时才会注入组件信息
|
package/annotation.d.ts
CHANGED
|
@@ -71,6 +71,9 @@ export function Autowired(target: any, propertyKey: string): void;
|
|
|
71
71
|
//调用时注入类
|
|
72
72
|
export function CallDependency(target: any, propertyKey: string): void;
|
|
73
73
|
|
|
74
|
+
//按需注入加载
|
|
75
|
+
export function DemandInjection(target: any): any;
|
|
76
|
+
|
|
74
77
|
//异常方法类
|
|
75
78
|
export function ExceptionMonitor(target: any): void;
|
|
76
79
|
|
package/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { ComponentKind } from "./src/constant/ComponentKind";
|
|
|
4
4
|
import { LifeCycleModule } from "./src/constant/LifeCycleModule";
|
|
5
5
|
import { FIELDTYPE } from "./src/model/DataMap";
|
|
6
6
|
import { ProcessType } from "./src/type/ProcessType";
|
|
7
|
+
import { HotReloadEnum } from "./src/type/FileHotterDesc";
|
|
8
|
+
import { ClassConstructor } from "./src/type/ClassConstructor";
|
|
7
9
|
|
|
8
10
|
declare type ComponentDesc = {
|
|
9
11
|
id: string;
|
|
@@ -56,26 +58,29 @@ export class FastCarApplication extends Events {
|
|
|
56
58
|
|
|
57
59
|
/***
|
|
58
60
|
* @version 1.0 热更新组件
|
|
61
|
+
* @version 1.1 热更新配置文件
|
|
59
62
|
*/
|
|
60
63
|
addHot(): void;
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
addDelayHot(fp: string, loadType: HotReloadEnum): void;
|
|
66
|
+
|
|
67
|
+
reloadFiles(): void;
|
|
68
|
+
|
|
69
|
+
/***
|
|
63
70
|
* @version 1.0 获取资源路径
|
|
64
71
|
*/
|
|
65
72
|
getResourcePath(): string;
|
|
66
|
-
|
|
67
73
|
/***
|
|
68
74
|
* @version 1.0 获取项目的基本路径
|
|
69
75
|
*
|
|
70
76
|
*/
|
|
71
77
|
getBasePath(): string;
|
|
72
78
|
|
|
73
|
-
|
|
74
|
-
* @version 1.0
|
|
79
|
+
/**
|
|
80
|
+
* @version 1.0 获取项目读取的基本配置路径
|
|
75
81
|
*/
|
|
76
82
|
getBaseName(): string;
|
|
77
|
-
|
|
78
|
-
/**
|
|
83
|
+
/***
|
|
79
84
|
* @version 1.0 加载系统配置 加载顺序为 default json < yaml < env
|
|
80
85
|
*
|
|
81
86
|
*/
|
|
@@ -83,29 +88,23 @@ export class FastCarApplication extends Events {
|
|
|
83
88
|
|
|
84
89
|
setSetting(key: string | symbol, value: any): void;
|
|
85
90
|
|
|
86
|
-
|
|
91
|
+
/***
|
|
87
92
|
* @version 1.0 获取自定义设置 设置优先级 配置自定义>系统配置>初始化
|
|
88
|
-
*
|
|
93
|
+
*
|
|
89
94
|
*/
|
|
90
95
|
getSetting(key: string | symbol): any;
|
|
91
96
|
|
|
92
|
-
|
|
97
|
+
/***
|
|
93
98
|
* @version 1.0 获取应用配置
|
|
94
|
-
* @return
|
|
95
99
|
*/
|
|
96
100
|
getapplicationConfig(): ApplicationConfig;
|
|
97
|
-
|
|
98
|
-
/**
|
|
101
|
+
/***
|
|
99
102
|
* @version 1.0 扫描组件
|
|
103
|
+
* @version 1.1 新增手动注入组件
|
|
104
|
+
* @version 1.2 改成统一入口
|
|
100
105
|
*/
|
|
101
106
|
loadClass(): void;
|
|
102
107
|
|
|
103
|
-
/***
|
|
104
|
-
* @version 1.0 装配单个模块
|
|
105
|
-
* @deprecated 修改为主动查找时装配
|
|
106
|
-
*/
|
|
107
|
-
injectionModule(instance: any, instanceName: string | symbol): void;
|
|
108
|
-
|
|
109
108
|
/***
|
|
110
109
|
* @version 1.0 根据名称获取组件的加载情况
|
|
111
110
|
*
|
|
@@ -118,35 +117,45 @@ export class FastCarApplication extends Events {
|
|
|
118
117
|
*/
|
|
119
118
|
getComponentDetailByTarget(target: Object): ComponentDesc | undefined;
|
|
120
119
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
* @
|
|
120
|
+
getInjectionUniqueKeyByFilePath(fp: string, name: string): string | symbol | null;
|
|
121
|
+
/***
|
|
122
|
+
* @version 1.0 转成实例对象
|
|
123
|
+
* @version 1.0.1 新增加载时识别载入配置选项
|
|
124
|
+
*
|
|
124
125
|
*/
|
|
125
|
-
|
|
126
|
+
convertInstance(classZ: any, fp: string): void;
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
/***
|
|
128
129
|
* @version 1.0 根据类型获取组件
|
|
129
|
-
* @param name
|
|
130
|
-
* @return
|
|
131
130
|
*/
|
|
132
131
|
getComponentByType(name: ComponentKind): any[];
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
/***
|
|
135
134
|
* @version 1.0 获取全部的组件列表
|
|
136
|
-
* @return
|
|
137
135
|
*/
|
|
138
|
-
getComponentList():
|
|
139
|
-
|
|
140
|
-
/**
|
|
136
|
+
getComponentList(): (Object | ClassConstructor<Object>)[];
|
|
137
|
+
/***
|
|
141
138
|
* @version 1.0 根据名称组件
|
|
142
|
-
* @param name
|
|
143
139
|
*/
|
|
144
|
-
getComponentByName(name: string | symbol):
|
|
140
|
+
getComponentByName(name: string | symbol): Object | null;
|
|
141
|
+
/**
|
|
142
|
+
* @version 1.0 组件改成按需加载的模式
|
|
143
|
+
*/
|
|
144
|
+
getBean(key: string | symbol): Object | null;
|
|
145
|
+
|
|
146
|
+
loadInjectionService(instance: Object): void;
|
|
147
|
+
|
|
148
|
+
loadLoggerIOC(instance: Object): void;
|
|
149
|
+
|
|
150
|
+
/***
|
|
151
|
+
* @version 1.0 判断是否拥有组件名称
|
|
152
|
+
*/
|
|
153
|
+
hasComponentByName(name: string | symbol): boolean;
|
|
145
154
|
|
|
146
155
|
/***
|
|
147
156
|
* @version 1.0 根据原型获取实例
|
|
148
157
|
*/
|
|
149
|
-
getComponentByTarget(target: Object):
|
|
158
|
+
getComponentByTarget<T>(target: Object): T | null;
|
|
150
159
|
|
|
151
160
|
/**
|
|
152
161
|
* @version 1.0 获取组件详情列表
|
|
@@ -154,17 +163,13 @@ export class FastCarApplication extends Events {
|
|
|
154
163
|
*/
|
|
155
164
|
getComponentDetailsList(): ComponentDesc[];
|
|
156
165
|
|
|
157
|
-
/**
|
|
158
|
-
* @version 1.0 判断组件是否存在
|
|
159
|
-
*/
|
|
160
|
-
hasComponentByName(name: string | symbol): boolean;
|
|
161
|
-
|
|
162
166
|
/**
|
|
163
167
|
* @version 1.0 开启日志系统
|
|
168
|
+
* @version 1.1 更改为采用winston日志
|
|
164
169
|
*/
|
|
165
170
|
startLog(): void;
|
|
166
171
|
|
|
167
|
-
|
|
172
|
+
/***
|
|
168
173
|
* @version 1.0 初始化应用
|
|
169
174
|
*/
|
|
170
175
|
init(): void;
|
|
@@ -173,6 +178,8 @@ export class FastCarApplication extends Events {
|
|
|
173
178
|
* @version 1.0 退出事件监听
|
|
174
179
|
*
|
|
175
180
|
*/
|
|
181
|
+
exitEvent(msg: string): Promise<void>;
|
|
182
|
+
|
|
176
183
|
addExitEvent(): void;
|
|
177
184
|
|
|
178
185
|
/***
|
|
@@ -180,28 +187,24 @@ export class FastCarApplication extends Events {
|
|
|
180
187
|
*/
|
|
181
188
|
addExecptionEvent(): void;
|
|
182
189
|
|
|
183
|
-
|
|
190
|
+
/***
|
|
184
191
|
* @version 1.0 自动调用方法
|
|
185
|
-
* @param name
|
|
186
192
|
*/
|
|
187
|
-
automaticRun(name: LifeCycleModule): void
|
|
193
|
+
automaticRun(name: LifeCycleModule): Promise<void>;
|
|
188
194
|
|
|
189
195
|
/**
|
|
190
196
|
* @version 1.0 开启应用前执行的操作 加载配置,扫描组件,注入依赖组件
|
|
191
197
|
*/
|
|
192
198
|
beforeStartServer(): void;
|
|
193
|
-
|
|
194
|
-
/**
|
|
199
|
+
/***
|
|
195
200
|
* @version 1.0 启动服务
|
|
196
201
|
*/
|
|
197
|
-
startServer(): void
|
|
198
|
-
|
|
199
|
-
/**
|
|
202
|
+
startServer(): Promise<void>;
|
|
203
|
+
/***
|
|
200
204
|
* @version 1.0 停止服务前自动调用服务
|
|
201
205
|
*/
|
|
202
|
-
beforeStopServer(): void
|
|
203
|
-
|
|
204
|
-
/**
|
|
206
|
+
beforeStopServer(): Promise<void>;
|
|
207
|
+
/***
|
|
205
208
|
* @version 1.0 停止服务
|
|
206
209
|
*/
|
|
207
210
|
stopServer(): void;
|
|
@@ -233,6 +236,10 @@ export class FastCarApplication extends Events {
|
|
|
233
236
|
*
|
|
234
237
|
*/
|
|
235
238
|
isHotter(): boolean;
|
|
239
|
+
/***
|
|
240
|
+
* @version 1.0 是否支持资源文件热更
|
|
241
|
+
*/
|
|
242
|
+
isHotterSysConfig(): boolean;
|
|
236
243
|
|
|
237
244
|
/**
|
|
238
245
|
* @version 1.0 指定热更新文件
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastcar/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"homepage": "https://github.com/williamDazhangyu/fast-car",
|
|
5
5
|
"main": "target/index.js",
|
|
6
6
|
"author": "william_zhong",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"@fastcar/core"
|
|
30
30
|
],
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=20"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"reflect-metadata": "^0.
|
|
35
|
+
"reflect-metadata": "^0.2.2",
|
|
36
36
|
"winston": "^3.10.0",
|
|
37
|
-
"yaml": "^
|
|
37
|
+
"yaml": "^2.6.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/mocha": "^9.0.0",
|