@fastcar/core 0.3.4 → 0.3.6

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 CHANGED
@@ -48,6 +48,8 @@ ComponentScanMust 0.2.58 声明一个必须要扫描注入的方法 防止被笼
48
48
 
49
49
  Hotter 指定热更新类 0.2.13 版本生效(当我们修改代码后,可以自动热加载文件)
50
50
 
51
+ HotterCallBack 更新类 0.3.5起生效(当修改代码后 可以自动调用该类下的自定义的fn方法,重新加载)
52
+
51
53
  BeanName 指明组件名称(每个组件具有一个系统生成id为"类名:16位随机值",为了便于调用可自定义逻辑名)
52
54
 
53
55
  Configure 表明为配置组件
package/annotation.d.ts CHANGED
@@ -43,6 +43,7 @@ export function ComponentScanExclusion(...names: string[]): Ret;
43
43
  export function ComponentInjection(target: any, ...names: string[]): void;
44
44
  export function ComponentScanMust(...names: string[]): Ret;
45
45
  export function Hotter(target: any): void;
46
+ export function HotterCallBack(fn: string): Ret;
46
47
 
47
48
  /***
48
49
  * 用于描述不同组件的作用类
@@ -133,6 +134,9 @@ export function Field(name: string): PMRet;
133
134
  //是否为主键
134
135
  export function PrimaryKey(target: any, propertyKey: string): void;
135
136
 
137
+ //是否为自增的
138
+ export function IsSerial(target: any, propertyKey: string): void;
139
+
136
140
  //标记表名
137
141
  export function Table(name: string): Ret;
138
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastcar/core",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "homepage": "https://github.com/williamDazhangyu/fast-car",
5
5
  "main": "target/index.js",
6
6
  "author": "william_zhong",
@@ -29,7 +29,7 @@
29
29
  "@fastcar/core"
30
30
  ],
31
31
  "engines": {
32
- "node": ">=16"
32
+ "node": ">=18"
33
33
  },
34
34
  "dependencies": {
35
35
  "reflect-metadata": "^0.2.2",
@@ -392,6 +392,10 @@ class FastCarApplication extends Events {
392
392
  let beforeInstance = this.getBean(beforeKey);
393
393
  if (!!beforeInstance) {
394
394
  MixTool.assign(beforeInstance, classZ);
395
+ let cb = Reflect.getMetadata(FastCarMetaData.HotterCallback, classZ.prototype);
396
+ if (cb && Reflect.has(beforeInstance, cb)) {
397
+ Reflect.apply(Reflect.get(beforeInstance, cb), beforeInstance, []);
398
+ }
395
399
  return;
396
400
  }
397
401
  }
@@ -0,0 +1,7 @@
1
+ import "reflect-metadata";
2
+ import { DesignMeta } from "../../db";
3
+
4
+ //是否为主键
5
+ export default function IsSerial(target: any, propertyKey: string) {
6
+ Reflect.defineMetadata(DesignMeta.isSerial, true, target, propertyKey);
7
+ }
@@ -16,6 +16,7 @@ export default function Table(name: string) {
16
16
  let field = Reflect.getOwnMetadata(DesignMeta.field, proto, c) || c;
17
17
  let dbType = Reflect.getOwnMetadata(DesignMeta.dbType, proto, c) || "varchar";
18
18
  let primaryKey = !!Reflect.getOwnMetadata(DesignMeta.primaryKey, proto, c);
19
+ let isSerial = Reflect.getOwnMetadata(DesignMeta.isSerial, proto, c);
19
20
 
20
21
  let tsName: string = tsType.name;
21
22
  let customeType = Reflect.getOwnMetadata(FastCarMetaData.CustomType, proto, c);
@@ -26,6 +27,7 @@ export default function Table(name: string) {
26
27
  field, //数据库列名
27
28
  dbType: dbType, //数据类型
28
29
  primaryKey, //是否为主键 默认为false
30
+ isSerial: isSerial || false,
29
31
  };
30
32
  dbFields.set(field, c);
31
33
  mappingMap.set(c, m);
@@ -0,0 +1,13 @@
1
+ import "reflect-metadata";
2
+ import { FastCarMetaData } from "../..";
3
+ import Hotter from "./Hotter";
4
+
5
+ /**
6
+ * @version 1.0 用于热更新的回调作用
7
+ */
8
+ export default function HotterCallBack(fn: string) {
9
+ return function (target: any) {
10
+ Hotter(target);
11
+ Reflect.defineMetadata(FastCarMetaData.HotterCallback, fn, target.prototype);
12
+ };
13
+ }
package/src/annotation.ts CHANGED
@@ -53,6 +53,8 @@ import ComponentScanMust from "./annotation/scan/ComponentScanMust";
53
53
  import DemandInjection from "./annotation/bind/DemandInjection";
54
54
  import Value from "./annotation/bind/Value";
55
55
  import AppEnv from "./annotation/bind/AppEnv";
56
+ import HotterCallBack from "./annotation/scan/HotterCallBack";
57
+ import IsSerial from "./annotation/data/IsSerial";
56
58
 
57
59
  //注解暴露出去
58
60
  export {
@@ -67,6 +69,7 @@ export {
67
69
  ComponentInjection,
68
70
  ComponentScanMust,
69
71
  Hotter,
72
+ HotterCallBack,
70
73
  BeanName,
71
74
  Configure,
72
75
  Controller,
@@ -109,6 +112,7 @@ export {
109
112
  Entity, //表和对应编程内的类型映射
110
113
  SqlSession, //连接会话 如果需要使用同一连接或者使用事务是传递
111
114
  Transactional, //事务管理
115
+ IsSerial, //自增管理
112
116
  };
113
117
 
114
118
  export { ENV, BaseFilePath, BasePath, BaseName, ApplicationSetting };
@@ -18,6 +18,7 @@ export enum FastCarMetaData {
18
18
  NotNull = "valid:notNull", //不为空
19
19
  ValidCustom = "valid:custom", //自定义校验方式
20
20
  Hotter = "hotter", //是否支持热更
21
+ HotterCallback = "HotterCallback", //热更回调
21
22
  InjectionUniqueKey = "injection_uniqueKey",
22
23
  Alias = "alias", //别名
23
24
  LoggerModule = "LoggerModule", //日志模块集合
package/src/db.ts CHANGED
@@ -160,6 +160,7 @@ export type MapperType = {
160
160
  dbType: string; //数据类型
161
161
  primaryKey?: boolean; //是否为主键 默认为false
162
162
  serialize?: Function; //序列化对象方法
163
+ isSerial?: boolean; //是否递增
163
164
  };
164
165
 
165
166
  export enum DesignMeta {
@@ -171,7 +172,8 @@ export enum DesignMeta {
171
172
  entity = "db:entity", //实例化的数据库类
172
173
  mapping = "db:mapping", //映射描述
173
174
  dbFields = "db:fields", //数据库名-ts名
174
- sqlSession = "SqlSession", //sql会话
175
+ sqlSession = "SqlSession",
176
+ isSerial = "isSerial", //sql会话
175
177
  }
176
178
 
177
179
  export interface DataSourceManager {
@@ -8,4 +8,5 @@ export enum DesignMeta {
8
8
  mapping = "db:mapping", //映射描述
9
9
  dbFields = "db:fields", //数据库名-ts名
10
10
  sqlSession = "SqlSession", //sql会话
11
+ isSerial = "db:isSerial", //是否递增
11
12
  }
@@ -5,4 +5,5 @@ export type MapperType = {
5
5
  dbType: string; //数据类型
6
6
  primaryKey?: boolean; //是否为主键 默认为false
7
7
  serialize?: Function; //序列化对象方法
8
+ isSerial: boolean; //是否为自增的
8
9
  };
@@ -345,6 +345,10 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
345
345
  let beforeInstance = this.getBean(beforeKey);
346
346
  if (!!beforeInstance) {
347
347
  Mix_1.default.assign(beforeInstance, classZ);
348
+ let cb = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.HotterCallback, classZ.prototype);
349
+ if (cb && Reflect.has(beforeInstance, cb)) {
350
+ Reflect.apply(Reflect.get(beforeInstance, cb), beforeInstance, []);
351
+ }
348
352
  return;
349
353
  }
350
354
  }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = IsSerial;
4
+ require("reflect-metadata");
5
+ const db_1 = require("../../db");
6
+ //是否为主键
7
+ function IsSerial(target, propertyKey) {
8
+ Reflect.defineMetadata(db_1.DesignMeta.isSerial, true, target, propertyKey);
9
+ }
@@ -16,6 +16,7 @@ function Table(name) {
16
16
  let field = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.field, proto, c) || c;
17
17
  let dbType = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.dbType, proto, c) || "varchar";
18
18
  let primaryKey = !!Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.primaryKey, proto, c);
19
+ let isSerial = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.isSerial, proto, c);
19
20
  let tsName = tsType.name;
20
21
  let customeType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.CustomType, proto, c);
21
22
  const m = {
@@ -24,6 +25,7 @@ function Table(name) {
24
25
  field, //数据库列名
25
26
  dbType: dbType, //数据类型
26
27
  primaryKey, //是否为主键 默认为false
28
+ isSerial: isSerial || false,
27
29
  };
28
30
  dbFields.set(field, c);
29
31
  mappingMap.set(c, m);
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = HotterCallBack;
4
+ require("reflect-metadata");
5
+ const __1 = require("../..");
6
+ const Hotter_1 = require("./Hotter");
7
+ /**
8
+ * @version 1.0 用于热更新的回调作用
9
+ */
10
+ function HotterCallBack(fn) {
11
+ return function (target) {
12
+ (0, Hotter_1.default)(target);
13
+ Reflect.defineMetadata(__1.FastCarMetaData.HotterCallback, fn, target.prototype);
14
+ };
15
+ }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Transactional = exports.SqlSession = exports.Entity = exports.Table = exports.PrimaryKey = exports.Field = exports.DBType = exports.DSIndex = exports.DS = exports.AppEnv = exports.Value = exports.CustomType = exports.ResourcePath = exports.Rule = exports.ValidForm = exports.ValidCustom = exports.Type = exports.Size = exports.NotNull = exports.DefaultVal = exports.AddChildValid = exports.AddRequireModule = exports.Log = exports.Readonly = exports.Override = exports.NotImplemented = exports.Deprecate = exports.ExceptionMonitor = exports.AliasInjection = exports.DemandInjection = exports.CallDependency = exports.Autowired = exports.Application = exports.Injection = exports.Repository = exports.Service = exports.Controller = exports.Configure = exports.BeanName = exports.Hotter = exports.ComponentScanMust = exports.ComponentInjection = exports.Component = exports.ComponentScanExclusion = exports.ComponentScan = exports.ApplicationDestory = exports.ApplicationInit = exports.ApplicationRunner = exports.ApplicationStop = exports.ApplicationStart = void 0;
4
- exports.ApplicationSetting = exports.BaseName = exports.BasePath = exports.BaseFilePath = exports.ENV = void 0;
3
+ exports.SqlSession = exports.Entity = exports.Table = exports.PrimaryKey = exports.Field = exports.DBType = exports.DSIndex = exports.DS = exports.AppEnv = exports.Value = exports.CustomType = exports.ResourcePath = exports.Rule = exports.ValidForm = exports.ValidCustom = exports.Type = exports.Size = exports.NotNull = exports.DefaultVal = exports.AddChildValid = exports.AddRequireModule = exports.Log = exports.Readonly = exports.Override = exports.NotImplemented = exports.Deprecate = exports.ExceptionMonitor = exports.AliasInjection = exports.DemandInjection = exports.CallDependency = exports.Autowired = exports.Application = exports.Injection = exports.Repository = exports.Service = exports.Controller = exports.Configure = exports.BeanName = exports.HotterCallBack = exports.Hotter = exports.ComponentScanMust = exports.ComponentInjection = exports.Component = exports.ComponentScanExclusion = exports.ComponentScan = exports.ApplicationDestory = exports.ApplicationInit = exports.ApplicationRunner = exports.ApplicationStop = exports.ApplicationStart = void 0;
4
+ exports.ApplicationSetting = exports.BaseName = exports.BasePath = exports.BaseFilePath = exports.ENV = exports.IsSerial = exports.Transactional = void 0;
5
5
  const Application_1 = require("./annotation/Application");
6
6
  exports.Application = Application_1.default;
7
7
  const Autowired_1 = require("./annotation/bind/Autowired");
@@ -112,3 +112,7 @@ const Value_1 = require("./annotation/bind/Value");
112
112
  exports.Value = Value_1.default;
113
113
  const AppEnv_1 = require("./annotation/bind/AppEnv");
114
114
  exports.AppEnv = AppEnv_1.default;
115
+ const HotterCallBack_1 = require("./annotation/scan/HotterCallBack");
116
+ exports.HotterCallBack = HotterCallBack_1.default;
117
+ const IsSerial_1 = require("./annotation/data/IsSerial");
118
+ exports.IsSerial = IsSerial_1.default;
@@ -22,6 +22,7 @@ var FastCarMetaData;
22
22
  FastCarMetaData["NotNull"] = "valid:notNull";
23
23
  FastCarMetaData["ValidCustom"] = "valid:custom";
24
24
  FastCarMetaData["Hotter"] = "hotter";
25
+ FastCarMetaData["HotterCallback"] = "HotterCallback";
25
26
  FastCarMetaData["InjectionUniqueKey"] = "injection_uniqueKey";
26
27
  FastCarMetaData["Alias"] = "alias";
27
28
  FastCarMetaData["LoggerModule"] = "LoggerModule";
package/target/db.js CHANGED
@@ -46,4 +46,5 @@ var DesignMeta;
46
46
  DesignMeta["mapping"] = "db:mapping";
47
47
  DesignMeta["dbFields"] = "db:fields";
48
48
  DesignMeta["sqlSession"] = "SqlSession";
49
+ DesignMeta["isSerial"] = "isSerial";
49
50
  })(DesignMeta || (exports.DesignMeta = DesignMeta = {}));
@@ -12,4 +12,5 @@ var DesignMeta;
12
12
  DesignMeta["mapping"] = "db:mapping";
13
13
  DesignMeta["dbFields"] = "db:fields";
14
14
  DesignMeta["sqlSession"] = "SqlSession";
15
+ DesignMeta["isSerial"] = "db:isSerial";
15
16
  })(DesignMeta || (exports.DesignMeta = DesignMeta = {}));
@@ -3,3 +3,11 @@
3
3
  {"timestamp":"2024-12-10 12:19:26.796","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
4
4
  {"timestamp":"2024-12-10 12:19:26.798","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
5
5
  {"timestamp":"2024-12-10 12:19:26.799","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
6
+ {"timestamp":"2024-12-25 22:17:05.503","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
7
+ {"timestamp":"2024-12-25 22:17:05.827","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
8
+ {"timestamp":"2024-12-25 22:17:05.829","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
9
+ {"timestamp":"2024-12-25 22:17:05.831","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
10
+ {"timestamp":"2024-12-25 22:17:05.832","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
11
+ {"timestamp":"2024-12-25 22:17:09.47","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
12
+ {"timestamp":"2024-12-25 22:17:16.221","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
13
+ {"timestamp":"2024-12-25 22:17:25.294","level":"ERROR","label":"fastcar-server.sys","message":"Caught exception: ⨯ Unable to compile TypeScript:\nfastcar-core/test/example/simple/service/HelloService.ts(7,2): error TS2564: Property 'hello' has no initializer and is not definitely assigned in the constructor.\r\n"}
@@ -0,0 +1,9 @@
1
+ {"timestamp":"2024-12-25 22:18:03.14","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
2
+ {"timestamp":"2024-12-25 22:18:03.378","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
3
+ {"timestamp":"2024-12-25 22:18:03.380","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
4
+ {"timestamp":"2024-12-25 22:18:03.383","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
5
+ {"timestamp":"2024-12-25 22:18:03.383","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
6
+ {"timestamp":"2024-12-25 22:18:13.857","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
7
+ {"timestamp":"2024-12-25 22:18:27.205","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
8
+ {"timestamp":"2024-12-25 22:18:47.545","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
9
+ {"timestamp":"2024-12-25 22:19:03.334","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
@@ -0,0 +1,13 @@
1
+ {"timestamp":"2024-12-25 22:21:34.898","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
2
+ {"timestamp":"2024-12-25 22:21:35.252","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
3
+ {"timestamp":"2024-12-25 22:21:35.255","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
4
+ {"timestamp":"2024-12-25 22:21:35.257","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
5
+ {"timestamp":"2024-12-25 22:21:35.258","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
6
+ {"timestamp":"2024-12-25 22:21:39.105","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
7
+ {"timestamp":"2024-12-25 22:21:46.811","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
8
+ {"timestamp":"2024-12-25 22:48:23.291","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
9
+ {"timestamp":"2024-12-25 22:48:23.536","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
10
+ {"timestamp":"2024-12-25 22:48:23.538","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
11
+ {"timestamp":"2024-12-25 22:48:23.539","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
12
+ {"timestamp":"2024-12-25 22:48:23.540","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
13
+ {"timestamp":"2024-12-25 22:48:29.09","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
@@ -0,0 +1,11 @@
1
+ {"timestamp":"2024-12-25 22:48:35.213","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
2
+ {"timestamp":"2024-12-25 22:48:41.354","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
3
+ {"timestamp":"2024-12-25 22:48:53.438","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
4
+ {"timestamp":"2024-12-25 22:49:05.829","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
5
+ {"timestamp":"2024-12-25 22:50:26.222","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
6
+ {"timestamp":"2024-12-25 22:50:26.701","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
7
+ {"timestamp":"2024-12-25 22:50:26.704","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
8
+ {"timestamp":"2024-12-25 22:50:26.706","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
9
+ {"timestamp":"2024-12-25 22:50:26.707","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
10
+ {"timestamp":"2024-12-25 22:50:29.663","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
11
+ {"timestamp":"2024-12-25 22:50:32.698","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
File without changes