@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/dist/index.mjs CHANGED
@@ -2608,6 +2608,7 @@ function Jsonb(options) {
2608
2608
  * 瞬态属性装饰器,标记属性不持久化到数据库。
2609
2609
  *
2610
2610
  * 等效于 MikroORM `@Property({ persist: false })`,适用于仅在运行时使用的计算属性。
2611
+ * 同时向 ModelRegister 注册,以便类型系统正确识别该属性。
2611
2612
  *
2612
2613
  * @param options - 必须通过 `type` 指定属性类型(MikroORM v7 要求)
2613
2614
  *
@@ -2621,10 +2622,17 @@ function Jsonb(options) {
2621
2622
  * ```
2622
2623
  */
2623
2624
  function Transient(options) {
2624
- return Property$1({
2625
- persist: false,
2626
- type: options.type
2627
- });
2625
+ return (target, propertyName) => {
2626
+ ModelRegister.addProperty(target.constructor, propertyName, {
2627
+ kind: "scalar",
2628
+ optional: false,
2629
+ lazy: false
2630
+ });
2631
+ return Property$1({
2632
+ persist: false,
2633
+ type: options.type
2634
+ })(target, propertyName);
2635
+ };
2628
2636
  }
2629
2637
  //#endregion
2630
2638
  //#region src/modules/mikro-orm/decorators/columns/embedded.column.ts
@@ -3701,12 +3709,12 @@ let OpenBaoTokenManager = _OpenBaoTokenManager = class OpenBaoTokenManager {
3701
3709
  this.logger.log("Token renewed successfully");
3702
3710
  this.scheduleRenewal();
3703
3711
  } catch (renewError) {
3704
- this.logger.error("Failed to renew token, attempting re-authentication", renewError);
3712
+ this.logger.error("Failed to renew token, attempting re-authentication", renewError instanceof Error ? renewError.stack : void 0);
3705
3713
  try {
3706
3714
  await this.authenticate();
3707
3715
  this.scheduleRenewal();
3708
3716
  } catch (authError) {
3709
- this.logger.error("Re-authentication also failed, will retry in 5s", authError);
3717
+ this.logger.error("Re-authentication also failed, will retry in 5s", authError instanceof Error ? authError.stack : void 0);
3710
3718
  this.renewalTimer = setTimeout(() => {
3711
3719
  this.renewToken();
3712
3720
  }, 5e3);
@@ -9920,13 +9928,19 @@ let ObjectStorageService = _ObjectStorageService = class ObjectStorageService {
9920
9928
  * @param options - 可选配置,如是否自动添加前缀
9921
9929
  */
9922
9930
  async get(path, options) {
9931
+ const key = this.buildPath(path, options);
9923
9932
  const command = new GetObjectCommand({
9924
9933
  Bucket: this.config.bucket,
9925
- Key: this.buildPath(path, options)
9934
+ Key: key
9926
9935
  });
9927
- const res = await this.client.send(command);
9928
- if (!res.Body) throw new Error("No body");
9929
- return Readable.fromWeb(res.Body.transformToWebStream());
9936
+ try {
9937
+ const res = await this.client.send(command);
9938
+ if (!res.Body) throw new Error("No body");
9939
+ return Readable.fromWeb(res.Body.transformToWebStream());
9940
+ } catch (err) {
9941
+ this.logger.error(`对象存储下载失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
9942
+ throw err;
9943
+ }
9930
9944
  }
9931
9945
  /**
9932
9946
  * 上传文件内容到指定路径。
@@ -9938,41 +9952,55 @@ let ObjectStorageService = _ObjectStorageService = class ObjectStorageService {
9938
9952
  */
9939
9953
  async upload(path, contents, options) {
9940
9954
  const key = this.buildPath(path, options);
9941
- await new Upload({
9955
+ const upload = new Upload({
9942
9956
  client: this.client,
9943
9957
  params: {
9944
9958
  Bucket: this.config.bucket,
9945
9959
  Key: key,
9946
9960
  Body: contents
9947
9961
  }
9948
- }).done();
9949
- return key;
9962
+ });
9963
+ try {
9964
+ await upload.done();
9965
+ return key;
9966
+ } catch (err) {
9967
+ this.logger.error(`对象存储上传失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
9968
+ throw err;
9969
+ }
9950
9970
  }
9951
9971
  /**
9952
9972
  * 获取文件的元数据(metadata)。
9953
9973
  */
9954
9974
  async getMetadata(path, options) {
9975
+ const key = this.buildPath(path, options);
9955
9976
  const command = new HeadObjectCommand({
9956
9977
  Bucket: this.config.bucket,
9957
- Key: this.buildPath(path, options)
9978
+ Key: key
9958
9979
  });
9959
- const res = await this.client.send(command);
9960
- if (!res.Metadata) throw new Error("No metadata");
9961
- return res.Metadata;
9980
+ try {
9981
+ const res = await this.client.send(command);
9982
+ if (!res.Metadata) throw new Error("No metadata");
9983
+ return res.Metadata;
9984
+ } catch (err) {
9985
+ this.logger.error(`对象存储获取元数据失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
9986
+ throw err;
9987
+ }
9962
9988
  }
9963
9989
  /**
9964
9990
  * 检查文件是否存在。
9965
9991
  */
9966
9992
  async exists(path, options) {
9993
+ const key = this.buildPath(path, options);
9967
9994
  const command = new HeadObjectCommand({
9968
9995
  Bucket: this.config.bucket,
9969
- Key: this.buildPath(path, options)
9996
+ Key: key
9970
9997
  });
9971
9998
  try {
9972
9999
  await this.client.send(command);
9973
10000
  return true;
9974
10001
  } catch (err) {
9975
10002
  if (err instanceof Error && err.name === "NotFound") return false;
10003
+ this.logger.error(`对象存储检查文件存在性失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
9976
10004
  throw err;
9977
10005
  }
9978
10006
  }
@@ -9980,11 +10008,17 @@ let ObjectStorageService = _ObjectStorageService = class ObjectStorageService {
9980
10008
  * 删除指定路径的文件。
9981
10009
  */
9982
10010
  async remove(path, options) {
10011
+ const key = this.buildPath(path, options);
9983
10012
  const command = new DeleteObjectCommand({
9984
10013
  Bucket: this.config.bucket,
9985
- Key: this.buildPath(path, options)
10014
+ Key: key
9986
10015
  });
9987
- await this.client.send(command);
10016
+ try {
10017
+ await this.client.send(command);
10018
+ } catch (err) {
10019
+ this.logger.error(`对象存储删除文件失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
10020
+ throw err;
10021
+ }
9988
10022
  }
9989
10023
  /**
9990
10024
  * 获取文件的预签名 URL,用于临时授权访问。
@@ -9994,11 +10028,17 @@ let ObjectStorageService = _ObjectStorageService = class ObjectStorageService {
9994
10028
  * @param options - 可选配置
9995
10029
  */
9996
10030
  async getSignedUrl(path, expiresInSecond, options) {
10031
+ const key = this.buildPath(path, options);
9997
10032
  const command = new GetObjectCommand({
9998
10033
  Bucket: this.config.bucket,
9999
- Key: this.buildPath(path, options)
10034
+ Key: key
10000
10035
  });
10001
- return await getSignedUrl(this.client, command, { expiresIn: expiresInSecond });
10036
+ try {
10037
+ return await getSignedUrl(this.client, command, { expiresIn: expiresInSecond });
10038
+ } catch (err) {
10039
+ this.logger.error(`对象存储获取签名URL失败, bucket: ${this.config.bucket}, key: ${key}`, err instanceof Error ? err.stack : void 0);
10040
+ throw err;
10041
+ }
10002
10042
  }
10003
10043
  };
10004
10044
  ObjectStorageService = _ObjectStorageService = __decorate([