@buka/nestjs-kit 4.3.4 → 4.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.4.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.5...v4.4.0) (2026-06-03)
4
+
5
+
6
+ ### Features
7
+
8
+ * add throwOnResponseError handle request exception ([847d3ba](https://github.com/buka-ltd/npm.nestjs-kit/commit/847d3bab337750eab915db975029e2e46fd40a37))
9
+
10
+ ## [4.3.5](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.4...v4.3.5) (2026-06-02)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * 修复ManyToMany和OneToMany立刻获取type数据导致的循环引用报错问题 ([c2c44c1](https://github.com/buka-ltd/npm.nestjs-kit/commit/c2c44c1d3e5d7ac2110f480f303fc9123a73087e))
16
+
3
17
  ## [4.3.4](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.3...v4.3.4) (2026-05-27)
4
18
 
5
19
 
package/dist/index.d.mts CHANGED
@@ -3,8 +3,8 @@ import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpSt
3
3
  import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
4
4
  import { ValidationOptions } from "class-validator";
5
5
  import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
6
- import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest } from "keq";
7
- import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCodeOptions } from "@buka/error-codes";
6
+ import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest, RequestException } from "keq";
7
+ import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCode as ErrorCode$1, ErrorCodeOptions } from "@buka/error-codes";
8
8
  import { Exception, ExceptionDetail, ExceptionDetail as ExceptionDetail$1, ExceptionOptions as ExceptionOptions$1 } from "@buka/exception";
9
9
  import { Logger, LoggerErrorInterceptor } from "nestjs-pino";
10
10
  import { Readable } from "node:stream";
@@ -18629,11 +18629,36 @@ declare class ObjectStorageService implements OnModuleInit {
18629
18629
  getSignedUrl(path: string, expiresInSecond: number, options?: ObjectStorageOptions): Promise<string>;
18630
18630
  }
18631
18631
  //#endregion
18632
+ //#region src/modules/keq/buka-request.exception.d.ts
18633
+ interface BukaRequestExceptionOptions {
18634
+ code: string;
18635
+ details?: ExceptionDetail$1[];
18636
+ response?: Response;
18637
+ fatal?: boolean;
18638
+ }
18639
+ declare class BukaRequestException extends RequestException {
18640
+ readonly code: string;
18641
+ readonly errorCode: ErrorCode$1;
18642
+ readonly details: ExceptionDetail$1[];
18643
+ constructor(statusCode: number, message: string, options: BukaRequestExceptionOptions);
18644
+ }
18645
+ //#endregion
18646
+ //#region src/modules/keq/throw-on-response-error.middleware.d.ts
18647
+ interface ThrowOnResponseErrorOptions {
18648
+ errorDispatchers?: Record<string, new (statusCode: number, message: string, options: BukaRequestExceptionOptions) => BukaRequestException>;
18649
+ /**
18650
+ * 开启后,错误体解析失败时输出 debug 日志
18651
+ * @default false
18652
+ */
18653
+ debug?: boolean;
18654
+ }
18655
+ declare function throwOnResponseError(options?: ThrowOnResponseErrorOptions): KeqMiddleware;
18656
+ //#endregion
18632
18657
  //#region src/utils/stable-stringify.d.ts
18633
18658
  /**
18634
18659
  * 稳定的 JSON 序列化,确保键按字母顺序排列,忽略 null 和 undefined
18635
18660
  */
18636
18661
  declare function stableStringify(value: unknown): string;
18637
18662
  //#endregion
18638
- export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, type EncryptCommand, EncryptedPayload, EntityDto, EntityDtoShape, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, MatchesUrn, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18663
+ export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaRequestException, type BukaRequestExceptionOptions, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, type EncryptCommand, EncryptedPayload, EntityDto, EntityDtoShape, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, MatchesUrn, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, type ThrowOnResponseErrorOptions, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify, throwOnResponseError };
18639
18664
  //# sourceMappingURL=index.d.mts.map
package/dist/index.d.ts CHANGED
@@ -5,8 +5,8 @@ import * as _$_nestjs_common0 from "@nestjs/common";
5
5
  import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
6
6
  import { ValidationOptions } from "class-validator";
7
7
  import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
8
- import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest } from "keq";
9
- import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCodeOptions } from "@buka/error-codes";
8
+ import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest, RequestException } from "keq";
9
+ import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCode as ErrorCode$1, ErrorCodeOptions } from "@buka/error-codes";
10
10
  import { Exception, ExceptionDetail, ExceptionDetail as ExceptionDetail$1, ExceptionOptions as ExceptionOptions$1 } from "@buka/exception";
11
11
  import { Logger, LoggerErrorInterceptor } from "nestjs-pino";
12
12
  import { IncomingMessage } from "http";
@@ -18629,11 +18629,36 @@ declare class ObjectStorageService implements OnModuleInit {
18629
18629
  getSignedUrl(path: string, expiresInSecond: number, options?: ObjectStorageOptions): Promise<string>;
18630
18630
  }
18631
18631
  //#endregion
18632
+ //#region src/modules/keq/buka-request.exception.d.ts
18633
+ interface BukaRequestExceptionOptions {
18634
+ code: string;
18635
+ details?: ExceptionDetail$1[];
18636
+ response?: Response;
18637
+ fatal?: boolean;
18638
+ }
18639
+ declare class BukaRequestException extends RequestException {
18640
+ readonly code: string;
18641
+ readonly errorCode: ErrorCode$1;
18642
+ readonly details: ExceptionDetail$1[];
18643
+ constructor(statusCode: number, message: string, options: BukaRequestExceptionOptions);
18644
+ }
18645
+ //#endregion
18646
+ //#region src/modules/keq/throw-on-response-error.middleware.d.ts
18647
+ interface ThrowOnResponseErrorOptions {
18648
+ errorDispatchers?: Record<string, new (statusCode: number, message: string, options: BukaRequestExceptionOptions) => BukaRequestException>;
18649
+ /**
18650
+ * 开启后,错误体解析失败时输出 debug 日志
18651
+ * @default false
18652
+ */
18653
+ debug?: boolean;
18654
+ }
18655
+ declare function throwOnResponseError(options?: ThrowOnResponseErrorOptions): KeqMiddleware;
18656
+ //#endregion
18632
18657
  //#region src/utils/stable-stringify.d.ts
18633
18658
  /**
18634
18659
  * 稳定的 JSON 序列化,确保键按字母顺序排列,忽略 null 和 undefined
18635
18660
  */
18636
18661
  declare function stableStringify(value: unknown): string;
18637
18662
  //#endregion
18638
- export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, type EncryptCommand, EncryptedPayload, EntityDto, EntityDtoShape, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, MatchesUrn, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18663
+ export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaRequestException, type BukaRequestExceptionOptions, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, type EncryptCommand, EncryptedPayload, EntityDto, EntityDtoShape, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, MatchesUrn, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, type ThrowOnResponseErrorOptions, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify, throwOnResponseError };
18639
18664
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -2782,6 +2782,21 @@ function resolveEntityType(entityRef, eager) {
2782
2782
  if (!cls) return Object;
2783
2783
  return eager ? cls : PrimaryKeyType(cls);
2784
2784
  }
2785
+ /**
2786
+ * 为 Swagger schema 解析实体类引用。始终返回完整实体类(非 PrimaryKeyType),
2787
+ * 保证 `$ref` 指向正确注册的 schema。
2788
+ *
2789
+ * 返回函数形式以支持延迟求值,避免装饰器执行时的循环引用问题。
2790
+ */
2791
+ function resolveEntitySchemaType(entityRef) {
2792
+ return () => {
2793
+ if (!entityRef) return Object;
2794
+ const result = entityRef();
2795
+ const entityName = Array.isArray(result) ? result[0] : result;
2796
+ if (!entityName) return Object;
2797
+ return resolveEntityClass(entityName) || Object;
2798
+ };
2799
+ }
2785
2800
  //#endregion
2786
2801
  //#region src/modules/mikro-orm/decorators/cardinality/many-to-one.cardinality.ts
2787
2802
  /**
@@ -2894,8 +2909,8 @@ function OneToMany(options) {
2894
2909
  },
2895
2910
  schema: {
2896
2911
  description: options.comment,
2897
- type: "array",
2898
- items: { $ref: (0, _nestjs_swagger.getSchemaPath)(type()) }
2912
+ type: resolveEntitySchemaType(entityRef),
2913
+ isArray: true
2899
2914
  }
2900
2915
  })(target, propertyKey);
2901
2916
  };
@@ -2935,8 +2950,8 @@ function ManyToMany(entity, mappedBy, options) {
2935
2950
  },
2936
2951
  schema: {
2937
2952
  description: resolvedOptions?.comment,
2938
- type: "array",
2939
- items: { $ref: (0, _nestjs_swagger.getSchemaPath)(type()) }
2953
+ type: resolveEntitySchemaType(entityRef),
2954
+ isArray: true
2940
2955
  }
2941
2956
  })(target, propertyKey);
2942
2957
  };
@@ -9995,6 +10010,58 @@ ObjectStorageModule = __decorate([(0, _nestjs_common.Global)(), (0, _nestjs_comm
9995
10010
  exports: [ObjectStorageService]
9996
10011
  })], ObjectStorageModule);
9997
10012
  //#endregion
10013
+ //#region src/modules/keq/buka-request.exception.ts
10014
+ var BukaRequestException = class extends keq.RequestException {
10015
+ code;
10016
+ errorCode;
10017
+ details;
10018
+ constructor(statusCode, message, options) {
10019
+ super(statusCode, message, {
10020
+ response: options.response,
10021
+ fatal: options.fatal
10022
+ });
10023
+ this.code = options.code;
10024
+ this.errorCode = _buka_error_codes.ErrorCode.fromString(options.code);
10025
+ this.details = options.details ?? [];
10026
+ }
10027
+ };
10028
+ //#endregion
10029
+ //#region src/modules/keq/throw-on-response-error.middleware.ts
10030
+ const logger = new _nestjs_common.Logger("KeqMiddleware:throwOnResponseError");
10031
+ function throwOnResponseError(options) {
10032
+ const { errorDispatchers, debug } = options ?? {};
10033
+ const middleware = async (ctx, next) => {
10034
+ await next();
10035
+ if (!ctx.response || ctx.response.status >= 200 && ctx.response.status < 400) return;
10036
+ const response = ctx.response;
10037
+ if (!response.headers.get("content-type")?.includes("application/json")) throw (0, _keq_request_exception.createExceptionByStatusCode)(response);
10038
+ const body = await response.json();
10039
+ if (body !== null && typeof body === "object" && "error" in body) try {
10040
+ const { error } = body;
10041
+ const exceptionOptions = {
10042
+ code: error.code,
10043
+ details: error.details,
10044
+ response,
10045
+ fatal: [
10046
+ 401,
10047
+ 403,
10048
+ 404
10049
+ ].includes(response.status)
10050
+ };
10051
+ if (errorDispatchers && error.code in errorDispatchers) {
10052
+ const ExceptionClass = errorDispatchers[error.code];
10053
+ throw new ExceptionClass(response.status, error.message, exceptionOptions);
10054
+ }
10055
+ throw new BukaRequestException(response.status, error.message, exceptionOptions);
10056
+ } catch (caught) {
10057
+ if (debug) logger.debug("解析响应错误体失败,降级为通用异常", caught instanceof Error ? caught.stack : caught);
10058
+ }
10059
+ throw (0, _keq_request_exception.createExceptionByStatusCode)(response);
10060
+ };
10061
+ middleware.__keqMiddlewareName__ = "throwOnResponseError";
10062
+ return middleware;
10063
+ }
10064
+ //#endregion
9998
10065
  exports.AuthException = AuthException;
9999
10066
  exports.BUKA_MODULE_OPTIONS_TOKEN = BUKA_MODULE_OPTIONS_TOKEN;
10000
10067
  Object.defineProperty(exports, "Base32", {
@@ -10046,6 +10113,7 @@ Object.defineProperty(exports, "BukaPageQueryValidationPipe", {
10046
10113
  return BukaPageQueryValidationPipe;
10047
10114
  }
10048
10115
  });
10116
+ exports.BukaRequestException = BukaRequestException;
10049
10117
  Object.defineProperty(exports, "BukaValidationPipe", {
10050
10118
  enumerable: true,
10051
10119
  get: function() {
@@ -10292,5 +10360,6 @@ exports.isScalarClass = isScalarClass;
10292
10360
  exports.serializeModel = serializeModel;
10293
10361
  exports.setOpenBaoToken = setOpenBaoToken;
10294
10362
  exports.stableStringify = stableStringify;
10363
+ exports.throwOnResponseError = throwOnResponseError;
10295
10364
 
10296
10365
  //# sourceMappingURL=index.js.map