@buka/nestjs-kit 4.3.5 → 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,12 @@
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
+
3
10
  ## [4.3.5](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.4...v4.3.5) (2026-06-02)
4
11
 
5
12
 
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
@@ -10010,6 +10010,58 @@ ObjectStorageModule = __decorate([(0, _nestjs_common.Global)(), (0, _nestjs_comm
10010
10010
  exports: [ObjectStorageService]
10011
10011
  })], ObjectStorageModule);
10012
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
10013
10065
  exports.AuthException = AuthException;
10014
10066
  exports.BUKA_MODULE_OPTIONS_TOKEN = BUKA_MODULE_OPTIONS_TOKEN;
10015
10067
  Object.defineProperty(exports, "Base32", {
@@ -10061,6 +10113,7 @@ Object.defineProperty(exports, "BukaPageQueryValidationPipe", {
10061
10113
  return BukaPageQueryValidationPipe;
10062
10114
  }
10063
10115
  });
10116
+ exports.BukaRequestException = BukaRequestException;
10064
10117
  Object.defineProperty(exports, "BukaValidationPipe", {
10065
10118
  enumerable: true,
10066
10119
  get: function() {
@@ -10307,5 +10360,6 @@ exports.isScalarClass = isScalarClass;
10307
10360
  exports.serializeModel = serializeModel;
10308
10361
  exports.setOpenBaoToken = setOpenBaoToken;
10309
10362
  exports.stableStringify = stableStringify;
10363
+ exports.throwOnResponseError = throwOnResponseError;
10310
10364
 
10311
10365
  //# sourceMappingURL=index.js.map