@buka/nestjs-kit 4.3.5 → 4.4.1

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.1](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.0...v4.4.1) (2026-06-04)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * 修复 EntityDto 导致swagger属性丢失的问题 ([b6b2f69](https://github.com/buka-ltd/npm.nestjs-kit/commit/b6b2f6902f3eb6ccd8bc4373b0c9b12a772b385d))
9
+
10
+ ## [4.4.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.5...v4.4.0) (2026-06-03)
11
+
12
+
13
+ ### Features
14
+
15
+ * add throwOnResponseError handle request exception ([847d3ba](https://github.com/buka-ltd/npm.nestjs-kit/commit/847d3bab337750eab915db975029e2e46fd40a37))
16
+
3
17
  ## [4.3.5](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.4...v4.3.5) (2026-06-02)
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
@@ -1442,9 +1442,19 @@ function isString(value) {
1442
1442
  }
1443
1443
  //#endregion
1444
1444
  //#region src/utils/internals/nestjs-swagger.ts
1445
+ /**
1446
+ * 模拟 @nestjs/swagger 的 DECORATORS 常量。
1447
+ *
1448
+ * `@nestjs/swagger` 的类型声明(`index.d.ts`)未导出 `DECORATORS`,
1449
+ * 仅在运行时可用。为避免 `ts(2305)` 错误,直接内联其常量值。
1450
+ */
1451
+ const DECORATORS = {
1452
+ API_MODEL_PROPERTIES: "swagger/apiModelProperties",
1453
+ API_MODEL_PROPERTIES_ARRAY: "swagger/apiModelPropertiesArray"
1454
+ };
1445
1455
  const METADATA_FACTORY_NAME = "_OPENAPI_METADATA_FACTORY";
1446
1456
  function getModelProperties(prototype) {
1447
- return (Reflect.getMetadata(_nestjs_swagger.DECORATORS.API_MODEL_PROPERTIES_ARRAY, prototype) || []).filter(isString).filter((key) => key.charAt(0) === ":" && !isFunction(prototype[key])).map((key) => key.slice(1));
1457
+ return (Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES_ARRAY, prototype) || []).filter(isString).filter((key) => key.charAt(0) === ":" && !isFunction(prototype[key])).map((key) => key.slice(1));
1448
1458
  }
1449
1459
  function clonePluginMetadataFactory(target, parent, transformFn = (x) => x) {
1450
1460
  let targetMetadata = {};
@@ -1478,9 +1488,9 @@ function cloneMetadata(target, source, keys) {
1478
1488
  }
1479
1489
  }
1480
1490
  function getMetadataOfDecorator(classRef, propertyKey) {
1481
- if (propertyKey) return Reflect.getMetadata(_nestjs_swagger.DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, propertyKey);
1491
+ if (propertyKey) return Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, propertyKey);
1482
1492
  const props = getModelProperties(classRef.prototype);
1483
- return ramda.fromPairs(props.map((prop) => [prop, Reflect.getMetadata(_nestjs_swagger.DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, prop)]));
1493
+ return ramda.fromPairs(props.map((prop) => [prop, Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, prop)]));
1484
1494
  }
1485
1495
  function getMetadataOfPlugin(classRef, propertyKey) {
1486
1496
  const propsInPlugin = typeof classRef["_OPENAPI_METADATA_FACTORY"] === "function" ? classRef[METADATA_FACTORY_NAME]() : {};
@@ -2714,6 +2724,11 @@ __decorate([
2714
2724
  function EntityDto(classRef) {
2715
2725
  if (!ModelRegister.isModel(classRef)) throw new TypeError("EntityDto only accepts a class annotated with @Model().");
2716
2726
  class EntityDtoClass {}
2727
+ /**
2728
+ * 收集从源实体复制的 Swagger 属性元数据,
2729
+ * 用于构建 `_OPENAPI_METADATA_FACTORY`。
2730
+ */
2731
+ const swaggerProps = {};
2717
2732
  for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
2718
2733
  if (ModelRegister.getProperty(classRef, propertyKey)?.lazy) continue;
2719
2734
  ModelRegister.copyProperty(classRef, EntityDtoClass, propertyKey);
@@ -2723,7 +2738,26 @@ function EntityDto(classRef) {
2723
2738
  if (Reflect.hasMetadata(metadataKey, EntityDtoClass.prototype, propertyKey)) continue;
2724
2739
  Reflect.defineMetadata(metadataKey, value, EntityDtoClass.prototype, propertyKey);
2725
2740
  }
2741
+ /**
2742
+ * 收集已复制的 `@ApiProperty` 元数据,后续通过
2743
+ * `_OPENAPI_METADATA_FACTORY` 暴露给 `@nestjs/swagger`,
2744
+ * 使 applyMetadataFactory() 遍历原型链时能发现这些属性。
2745
+ */
2746
+ if (typeof propertyKey === "string") {
2747
+ const swaggerMeta = Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, EntityDtoClass.prototype, propertyKey);
2748
+ if (swaggerMeta) swaggerProps[propertyKey] = swaggerMeta;
2749
+ }
2726
2750
  }
2751
+ /**
2752
+ * 设置 `_OPENAPI_METADATA_FACTORY` 静态方法。
2753
+ *
2754
+ * `@nestjs/swagger` 插件在编译时无法识别 `EntityDto`,
2755
+ * 只对子类(如 `CourseBriefDto`)中直接声明的属性生成 factory。
2756
+ * 当 `applyMetadataFactory()` 遍历原型链时,
2757
+ * 它会在 `EntityDtoClass` 上找到此 factory,
2758
+ * 并将源实体属性应用到子类的 prototype 上。
2759
+ */
2760
+ if (Object.keys(swaggerProps).length > 0) EntityDtoClass[METADATA_FACTORY_NAME] = () => swaggerProps;
2727
2761
  return EntityDtoClass;
2728
2762
  }
2729
2763
  //#endregion
@@ -10010,6 +10044,58 @@ ObjectStorageModule = __decorate([(0, _nestjs_common.Global)(), (0, _nestjs_comm
10010
10044
  exports: [ObjectStorageService]
10011
10045
  })], ObjectStorageModule);
10012
10046
  //#endregion
10047
+ //#region src/modules/keq/buka-request.exception.ts
10048
+ var BukaRequestException = class extends keq.RequestException {
10049
+ code;
10050
+ errorCode;
10051
+ details;
10052
+ constructor(statusCode, message, options) {
10053
+ super(statusCode, message, {
10054
+ response: options.response,
10055
+ fatal: options.fatal
10056
+ });
10057
+ this.code = options.code;
10058
+ this.errorCode = _buka_error_codes.ErrorCode.fromString(options.code);
10059
+ this.details = options.details ?? [];
10060
+ }
10061
+ };
10062
+ //#endregion
10063
+ //#region src/modules/keq/throw-on-response-error.middleware.ts
10064
+ const logger = new _nestjs_common.Logger("KeqMiddleware:throwOnResponseError");
10065
+ function throwOnResponseError(options) {
10066
+ const { errorDispatchers, debug } = options ?? {};
10067
+ const middleware = async (ctx, next) => {
10068
+ await next();
10069
+ if (!ctx.response || ctx.response.status >= 200 && ctx.response.status < 400) return;
10070
+ const response = ctx.response;
10071
+ if (!response.headers.get("content-type")?.includes("application/json")) throw (0, _keq_request_exception.createExceptionByStatusCode)(response);
10072
+ const body = await response.json();
10073
+ if (body !== null && typeof body === "object" && "error" in body) try {
10074
+ const { error } = body;
10075
+ const exceptionOptions = {
10076
+ code: error.code,
10077
+ details: error.details,
10078
+ response,
10079
+ fatal: [
10080
+ 401,
10081
+ 403,
10082
+ 404
10083
+ ].includes(response.status)
10084
+ };
10085
+ if (errorDispatchers && error.code in errorDispatchers) {
10086
+ const ExceptionClass = errorDispatchers[error.code];
10087
+ throw new ExceptionClass(response.status, error.message, exceptionOptions);
10088
+ }
10089
+ throw new BukaRequestException(response.status, error.message, exceptionOptions);
10090
+ } catch (caught) {
10091
+ if (debug) logger.debug("解析响应错误体失败,降级为通用异常", caught instanceof Error ? caught.stack : caught);
10092
+ }
10093
+ throw (0, _keq_request_exception.createExceptionByStatusCode)(response);
10094
+ };
10095
+ middleware.__keqMiddlewareName__ = "throwOnResponseError";
10096
+ return middleware;
10097
+ }
10098
+ //#endregion
10013
10099
  exports.AuthException = AuthException;
10014
10100
  exports.BUKA_MODULE_OPTIONS_TOKEN = BUKA_MODULE_OPTIONS_TOKEN;
10015
10101
  Object.defineProperty(exports, "Base32", {
@@ -10061,6 +10147,7 @@ Object.defineProperty(exports, "BukaPageQueryValidationPipe", {
10061
10147
  return BukaPageQueryValidationPipe;
10062
10148
  }
10063
10149
  });
10150
+ exports.BukaRequestException = BukaRequestException;
10064
10151
  Object.defineProperty(exports, "BukaValidationPipe", {
10065
10152
  enumerable: true,
10066
10153
  get: function() {
@@ -10307,5 +10394,6 @@ exports.isScalarClass = isScalarClass;
10307
10394
  exports.serializeModel = serializeModel;
10308
10395
  exports.setOpenBaoToken = setOpenBaoToken;
10309
10396
  exports.stableStringify = stableStringify;
10397
+ exports.throwOnResponseError = throwOnResponseError;
10310
10398
 
10311
10399
  //# sourceMappingURL=index.js.map