@buka/nestjs-kit 4.3.0 → 4.3.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.3.2](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.1...v4.3.2) (2026-05-26)
4
+
5
+
6
+ ### Performance Improvements
7
+
8
+ * 对象存储模块添加错误日志 ([968aaab](https://github.com/buka-ltd/npm.nestjs-kit/commit/968aaab5542e3a1f952027f61ad17cafca8fd4ba))
9
+
10
+ ## [4.3.1](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.0...v4.3.1) (2026-05-25)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * 因 Transient 装饰器未注册 Proptery 导致无法执行正确的转换 ([6a23663](https://github.com/buka-ltd/npm.nestjs-kit/commit/6a2366359bf62164e67909b2387672f8b7282cd9))
16
+
3
17
  ## [4.3.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.2.0...v4.3.0) (2026-05-24)
4
18
 
5
19
 
package/dist/index.d.mts CHANGED
@@ -1728,6 +1728,7 @@ interface TransientOptions {
1728
1728
  * 瞬态属性装饰器,标记属性不持久化到数据库。
1729
1729
  *
1730
1730
  * 等效于 MikroORM `@Property({ persist: false })`,适用于仅在运行时使用的计算属性。
1731
+ * 同时向 ModelRegister 注册,以便类型系统正确识别该属性。
1731
1732
  *
1732
1733
  * @param options - 必须通过 `type` 指定属性类型(MikroORM v7 要求)
1733
1734
  *
package/dist/index.d.ts CHANGED
@@ -1728,6 +1728,7 @@ interface TransientOptions {
1728
1728
  * 瞬态属性装饰器,标记属性不持久化到数据库。
1729
1729
  *
1730
1730
  * 等效于 MikroORM `@Property({ persist: false })`,适用于仅在运行时使用的计算属性。
1731
+ * 同时向 ModelRegister 注册,以便类型系统正确识别该属性。
1731
1732
  *
1732
1733
  * @param options - 必须通过 `type` 指定属性类型(MikroORM v7 要求)
1733
1734
  *
package/dist/index.js CHANGED
@@ -2636,6 +2636,7 @@ function Jsonb(options) {
2636
2636
  * 瞬态属性装饰器,标记属性不持久化到数据库。
2637
2637
  *
2638
2638
  * 等效于 MikroORM `@Property({ persist: false })`,适用于仅在运行时使用的计算属性。
2639
+ * 同时向 ModelRegister 注册,以便类型系统正确识别该属性。
2639
2640
  *
2640
2641
  * @param options - 必须通过 `type` 指定属性类型(MikroORM v7 要求)
2641
2642
  *
@@ -2649,10 +2650,17 @@ function Jsonb(options) {
2649
2650
  * ```
2650
2651
  */
2651
2652
  function Transient(options) {
2652
- return (0, _mikro_orm_decorators_legacy.Property)({
2653
- persist: false,
2654
- type: options.type
2655
- });
2653
+ return (target, propertyName) => {
2654
+ ModelRegister.addProperty(target.constructor, propertyName, {
2655
+ kind: "scalar",
2656
+ optional: false,
2657
+ lazy: false
2658
+ });
2659
+ return (0, _mikro_orm_decorators_legacy.Property)({
2660
+ persist: false,
2661
+ type: options.type
2662
+ })(target, propertyName);
2663
+ };
2656
2664
  }
2657
2665
  //#endregion
2658
2666
  //#region src/modules/mikro-orm/decorators/columns/embedded.column.ts
@@ -3729,12 +3737,12 @@ let OpenBaoTokenManager = _OpenBaoTokenManager = class OpenBaoTokenManager {
3729
3737
  this.logger.log("Token renewed successfully");
3730
3738
  this.scheduleRenewal();
3731
3739
  } catch (renewError) {
3732
- this.logger.error("Failed to renew token, attempting re-authentication", renewError);
3740
+ this.logger.error("Failed to renew token, attempting re-authentication", renewError instanceof Error ? renewError.stack : void 0);
3733
3741
  try {
3734
3742
  await this.authenticate();
3735
3743
  this.scheduleRenewal();
3736
3744
  } catch (authError) {
3737
- this.logger.error("Re-authentication also failed, will retry in 5s", authError);
3745
+ this.logger.error("Re-authentication also failed, will retry in 5s", authError instanceof Error ? authError.stack : void 0);
3738
3746
  this.renewalTimer = setTimeout(() => {
3739
3747
  this.renewToken();
3740
3748
  }, 5e3);
@@ -9948,13 +9956,19 @@ let ObjectStorageService = _ObjectStorageService = class ObjectStorageService {
9948
9956
  * @param options - 可选配置,如是否自动添加前缀
9949
9957
  */
9950
9958
  async get(path, options) {
9959
+ const key = this.buildPath(path, options);
9951
9960
  const command = new _aws_sdk_client_s3.GetObjectCommand({
9952
9961
  Bucket: this.config.bucket,
9953
- Key: this.buildPath(path, options)
9962
+ Key: key
9954
9963
  });
9955
- const res = await this.client.send(command);
9956
- if (!res.Body) throw new Error("No body");
9957
- return node_stream.Readable.fromWeb(res.Body.transformToWebStream());
9964
+ try {
9965
+ const res = await this.client.send(command);
9966
+ if (!res.Body) throw new Error("No body");
9967
+ return node_stream.Readable.fromWeb(res.Body.transformToWebStream());
9968
+ } catch (err) {
9969
+ this.logger.error(`对象存储下载失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
9970
+ throw err;
9971
+ }
9958
9972
  }
9959
9973
  /**
9960
9974
  * 上传文件内容到指定路径。
@@ -9966,41 +9980,55 @@ let ObjectStorageService = _ObjectStorageService = class ObjectStorageService {
9966
9980
  */
9967
9981
  async upload(path, contents, options) {
9968
9982
  const key = this.buildPath(path, options);
9969
- await new _aws_sdk_lib_storage.Upload({
9983
+ const upload = new _aws_sdk_lib_storage.Upload({
9970
9984
  client: this.client,
9971
9985
  params: {
9972
9986
  Bucket: this.config.bucket,
9973
9987
  Key: key,
9974
9988
  Body: contents
9975
9989
  }
9976
- }).done();
9977
- return key;
9990
+ });
9991
+ try {
9992
+ await upload.done();
9993
+ return key;
9994
+ } catch (err) {
9995
+ this.logger.error(`对象存储上传失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
9996
+ throw err;
9997
+ }
9978
9998
  }
9979
9999
  /**
9980
10000
  * 获取文件的元数据(metadata)。
9981
10001
  */
9982
10002
  async getMetadata(path, options) {
10003
+ const key = this.buildPath(path, options);
9983
10004
  const command = new _aws_sdk_client_s3.HeadObjectCommand({
9984
10005
  Bucket: this.config.bucket,
9985
- Key: this.buildPath(path, options)
10006
+ Key: key
9986
10007
  });
9987
- const res = await this.client.send(command);
9988
- if (!res.Metadata) throw new Error("No metadata");
9989
- return res.Metadata;
10008
+ try {
10009
+ const res = await this.client.send(command);
10010
+ if (!res.Metadata) throw new Error("No metadata");
10011
+ return res.Metadata;
10012
+ } catch (err) {
10013
+ this.logger.error(`对象存储获取元数据失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
10014
+ throw err;
10015
+ }
9990
10016
  }
9991
10017
  /**
9992
10018
  * 检查文件是否存在。
9993
10019
  */
9994
10020
  async exists(path, options) {
10021
+ const key = this.buildPath(path, options);
9995
10022
  const command = new _aws_sdk_client_s3.HeadObjectCommand({
9996
10023
  Bucket: this.config.bucket,
9997
- Key: this.buildPath(path, options)
10024
+ Key: key
9998
10025
  });
9999
10026
  try {
10000
10027
  await this.client.send(command);
10001
10028
  return true;
10002
10029
  } catch (err) {
10003
10030
  if (err instanceof Error && err.name === "NotFound") return false;
10031
+ this.logger.error(`对象存储检查文件存在性失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
10004
10032
  throw err;
10005
10033
  }
10006
10034
  }
@@ -10008,11 +10036,17 @@ let ObjectStorageService = _ObjectStorageService = class ObjectStorageService {
10008
10036
  * 删除指定路径的文件。
10009
10037
  */
10010
10038
  async remove(path, options) {
10039
+ const key = this.buildPath(path, options);
10011
10040
  const command = new _aws_sdk_client_s3.DeleteObjectCommand({
10012
10041
  Bucket: this.config.bucket,
10013
- Key: this.buildPath(path, options)
10042
+ Key: key
10014
10043
  });
10015
- await this.client.send(command);
10044
+ try {
10045
+ await this.client.send(command);
10046
+ } catch (err) {
10047
+ this.logger.error(`对象存储删除文件失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
10048
+ throw err;
10049
+ }
10016
10050
  }
10017
10051
  /**
10018
10052
  * 获取文件的预签名 URL,用于临时授权访问。
@@ -10022,11 +10056,17 @@ let ObjectStorageService = _ObjectStorageService = class ObjectStorageService {
10022
10056
  * @param options - 可选配置
10023
10057
  */
10024
10058
  async getSignedUrl(path, expiresInSecond, options) {
10059
+ const key = this.buildPath(path, options);
10025
10060
  const command = new _aws_sdk_client_s3.GetObjectCommand({
10026
10061
  Bucket: this.config.bucket,
10027
- Key: this.buildPath(path, options)
10062
+ Key: key
10028
10063
  });
10029
- return await (0, _aws_sdk_s3_request_presigner.getSignedUrl)(this.client, command, { expiresIn: expiresInSecond });
10064
+ try {
10065
+ return await (0, _aws_sdk_s3_request_presigner.getSignedUrl)(this.client, command, { expiresIn: expiresInSecond });
10066
+ } catch (err) {
10067
+ this.logger.error(`对象存储获取签名URL失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
10068
+ throw err;
10069
+ }
10030
10070
  }
10031
10071
  };
10032
10072
  ObjectStorageService = _ObjectStorageService = __decorate([