@buka/nestjs-kit 4.6.0 → 4.7.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.7.1](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.7.0...v4.7.1) (2026-11-13)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **validation-pipe:** 列表与字典中的 PrimaryKeyType 转换为托管引用 ([4134d36](https://github.com/buka-ltd/npm.nestjs-kit/commit/4134d36aaf5962c6a6adbe256067e61bb4602816))
9
+
10
+ ## [4.7.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.6.0...v4.7.0) (2026-11-01)
11
+
12
+
13
+ ### Features
14
+
15
+ * **swagger-patcher:** 支持按 operation 跳过统一异常响应 ([57e6d3f](https://github.com/buka-ltd/npm.nestjs-kit/commit/57e6d3f430267d41e111d540397e3e2a2cd4d3b6))
16
+
3
17
  ## [4.6.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.5.0...v4.6.0) (2026-10-26)
4
18
 
5
19
 
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
+ import { ApiExtension, ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
1
2
  import * as _$_nestjs_common0 from "@nestjs/common";
2
3
  import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
3
4
  import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, Loaded, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
4
5
  import { ValidationOptions } from "class-validator";
5
- import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
6
6
  import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest, RequestException } from "keq";
7
7
  import { KeqConsumer, KeqModuleOptions } from "@keq-request/nestjs";
8
8
  import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCode as ErrorCode$1, ErrorCodeOptions } from "@buka/error-codes";
@@ -31,12 +31,42 @@ import { IncomingMessage } from "http";
31
31
  */
32
32
  declare function deepObjectifyQueries(openapi: OpenAPIObject): void;
33
33
  //#endregion
34
+ //#region src/swagger-patcher/openapi-helpers.d.ts
35
+ type ReferenceObject = {
36
+ $ref: string;
37
+ };
38
+ type SchemaObject = Exclude<ValueOf<Required<Required<OpenAPIObject>['components']>['schemas']>, ReferenceObject>;
39
+ /**
40
+ * OpenAPI operation 对象
41
+ *
42
+ * `@nestjs/swagger` 未公开导出 `OperationObject`,这里从 `PathItemObject` 派生。
43
+ */
44
+ type OperationObject = NonNullable<OpenAPIObject['paths'][string]['get']>;
45
+ //#endregion
34
46
  //#region src/swagger-patcher/unify-exception-responses.d.ts
47
+ /** 参与统一异常响应的 HTTP 方法 */
48
+ type SwaggerHttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';
49
+ /** `filter` 回调的上下文 */
50
+ interface UnifyExceptionResponsesFilterContext {
51
+ /** OpenAPI 路径模板,如 `/api/v1/oauth2/token` */
52
+ pathname: string;
53
+ /** HTTP 方法 */
54
+ method: SwaggerHttpMethod;
55
+ /** 该 operation 的 OpenAPI 对象 */
56
+ operation: OperationObject;
57
+ }
35
58
  interface UnifyExceptionResponsesOptions {
36
59
  /** 覆写已有的哪些响应,支持 `'4xx'`、`'5xx'`、`'default'` 或具体数字状态码,默认 `[]` */
37
60
  overwrite?: ('4xx' | '5xx' | 'default' | number)[];
38
61
  /** 插入新的状态码响应(无论是否已存在),默认 `[]` */
39
62
  insert?: (number | 'default')[];
63
+ /**
64
+ * 是否处理该 operation;返回 `false` 时完全跳过(既不覆写也不插入)。
65
+ *
66
+ * 用于无法添加 `@SkipUnifiedExceptionResponse()` 装饰器的 operation;
67
+ * 未提供时处理全部 operation。
68
+ */
69
+ filter?: (context: UnifyExceptionResponsesFilterContext) => boolean;
40
70
  }
41
71
  /**
42
72
  * 将统一异常响应结构注入 OpenAPI 文档。
@@ -45,10 +75,16 @@ interface UnifyExceptionResponsesOptions {
45
75
  * 在 `components.responses` 注册可复用的 `ExceptionResponse` 响应对象,
46
76
  * 并根据选项覆写或插入 operation 的异常响应。
47
77
  *
78
+ * 标记了 `@SkipUnifiedExceptionResponse()`(即 operation 上存在
79
+ * `x-buka-skip-unified-exception-response` 扩展)或 `filter` 返回 `false`
80
+ * 的 operation 会被完全跳过:既不覆写也不插入,需自行声明错误响应。
81
+ * `components` 属于全局组件,仍会照常注册。
82
+ *
48
83
  * @param openapi - OpenAPI 文档对象(会被原地修改)
49
84
  * @param options - 控制覆写和插入行为
50
85
  * @param options.overwrite - 覆写已有的哪些响应,支持 `'4xx'`、`'5xx'`、`'default'` 或具体数字状态码,默认 `[]`
51
86
  * @param options.insert - 插入新的状态码响应(无论是否已存在),默认 `[]`
87
+ * @param options.filter - 返回 `false` 的 operation 完全跳过,默认处理全部
52
88
  *
53
89
  * @example
54
90
  * ```typescript
@@ -72,16 +108,16 @@ interface UnifyExceptionResponsesOptions {
72
108
  * overwrite: ['5xx'],
73
109
  * insert: [401, 403],
74
110
  * })
111
+ *
112
+ * // 按路径豁免无法添加装饰器的 operation
113
+ * SwaggerPatcher.unifyExceptionResponses(document, {
114
+ * overwrite: ['4xx', '5xx'],
115
+ * filter: ({ pathname }) => pathname !== '/health',
116
+ * })
75
117
  * ```
76
118
  */
77
119
  declare function unifyExceptionResponses(openapi: OpenAPIObject, options?: UnifyExceptionResponsesOptions): void;
78
120
  //#endregion
79
- //#region src/swagger-patcher/openapi-helpers.d.ts
80
- type ReferenceObject = {
81
- $ref: string;
82
- };
83
- type SchemaObject = Exclude<ValueOf<Required<Required<OpenAPIObject>['components']>['schemas']>, ReferenceObject>;
84
- //#endregion
85
121
  //#region src/swagger-patcher/swagger-patcher.d.ts
86
122
  /**
87
123
  * Swagger/OpenAPI 文档修补工具,用于修正生成的 OpenAPI 文档中的已知问题。
@@ -91,6 +127,35 @@ declare class SwaggerPatcher {
91
127
  static unifyExceptionResponses: typeof unifyExceptionResponses;
92
128
  }
93
129
  //#endregion
130
+ //#region src/swagger-patcher/decorators/skip-unified-exception-response.decorator.d.ts
131
+ /**
132
+ * 跳过统一异常响应(`SwaggerPatcher.unifyExceptionResponses`)
133
+ *
134
+ * 标记在 controller 方法上时,仅该 operation 不被覆写/插入 `ExceptionResponse`;
135
+ * 标记在 controller 类上时,该类所有 operation 均跳过。
136
+ *
137
+ * 用于错误响应遵循其他规范、不符合 Buka 统一信封的端点(如 OAuth2 token、
138
+ * 健康检查)。被跳过的 operation 需要自行通过 `@ApiResponse` 声明错误响应。
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * @Post('token')
143
+ * @SkipUnifiedExceptionResponse()
144
+ * @ApiResponse({ status: 400, type: OAuth2ErrorResponseDto })
145
+ * exchangeToken() {}
146
+ * ```
147
+ */
148
+ declare function SkipUnifiedExceptionResponse(): ReturnType<typeof ApiExtension>;
149
+ //#endregion
150
+ //#region src/swagger-patcher/constants.d.ts
151
+ /**
152
+ * 标记 operation 跳过统一异常响应的 OpenAPI 扩展键
153
+ *
154
+ * 由 `@SkipUnifiedExceptionResponse()` 写入,`SwaggerPatcher.unifyExceptionResponses`
155
+ * 读取后完全跳过该 operation(既不覆写也不插入)。
156
+ */
157
+ declare const SKIP_UNIFIED_EXCEPTION_RESPONSE_EXTENSION = "x-buka-skip-unified-exception-response";
158
+ //#endregion
94
159
  //#region src/modules/core/buka-module-options.d.ts
95
160
  interface BukaModuleOptions {
96
161
  validation?: ValidationPipeOptions;
@@ -17983,5 +18048,5 @@ declare function throwOnResponseError(options?: ThrowOnResponseErrorOptions): Ke
17983
18048
  */
17984
18049
  declare function stableStringify(value: unknown): string;
17985
18050
  //#endregion
17986
- 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, ICollectionOperator, IEntityPrimaryKey, IFilter, IFilterQuery, IListResponseBody, IListResponseBodyMeta, INestedOperator, INextCursorPageParameters, IObjectOperator, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IPropertyOperator, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_ENUM_COLUMN, IS_SCALAR_DICTIONARY, IS_URN, IScalarOperator, InjectLogger, IntersectionType, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsEnumColumn, 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 };
18051
+ 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, ICollectionOperator, IEntityPrimaryKey, IFilter, IFilterQuery, IListResponseBody, IListResponseBodyMeta, INestedOperator, INextCursorPageParameters, IObjectOperator, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IPropertyOperator, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_ENUM_COLUMN, IS_SCALAR_DICTIONARY, IS_URN, IScalarOperator, InjectLogger, IntersectionType, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsEnumColumn, 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, type OperationObject, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResponseBodyType, SKIP_UNIFIED_EXCEPTION_RESPONSE_EXTENSION, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, SkipUnifiedExceptionResponse, Slice, type SwaggerHttpMethod, SwaggerPatcher, SystemException, ThirdPartyException, type ThrowOnResponseErrorOptions, TimestampedEntity, type UnifyExceptionResponsesFilterContext, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify, throwOnResponseError };
17987
18052
  //# sourceMappingURL=index.d.mts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
1
+ import { ApiExtension, ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
2
2
  import * as _$type_fest0 from "type-fest";
3
3
  import { Class, JsonValue, ValueOf } from "type-fest";
4
4
  import * as _$_nestjs_common0 from "@nestjs/common";
@@ -31,12 +31,42 @@ import { Readable } from "node:stream";
31
31
  */
32
32
  declare function deepObjectifyQueries(openapi: OpenAPIObject): void;
33
33
  //#endregion
34
+ //#region src/swagger-patcher/openapi-helpers.d.ts
35
+ type ReferenceObject = {
36
+ $ref: string;
37
+ };
38
+ type SchemaObject = Exclude<ValueOf<Required<Required<OpenAPIObject>['components']>['schemas']>, ReferenceObject>;
39
+ /**
40
+ * OpenAPI operation 对象
41
+ *
42
+ * `@nestjs/swagger` 未公开导出 `OperationObject`,这里从 `PathItemObject` 派生。
43
+ */
44
+ type OperationObject = NonNullable<OpenAPIObject['paths'][string]['get']>;
45
+ //#endregion
34
46
  //#region src/swagger-patcher/unify-exception-responses.d.ts
47
+ /** 参与统一异常响应的 HTTP 方法 */
48
+ type SwaggerHttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';
49
+ /** `filter` 回调的上下文 */
50
+ interface UnifyExceptionResponsesFilterContext {
51
+ /** OpenAPI 路径模板,如 `/api/v1/oauth2/token` */
52
+ pathname: string;
53
+ /** HTTP 方法 */
54
+ method: SwaggerHttpMethod;
55
+ /** 该 operation 的 OpenAPI 对象 */
56
+ operation: OperationObject;
57
+ }
35
58
  interface UnifyExceptionResponsesOptions {
36
59
  /** 覆写已有的哪些响应,支持 `'4xx'`、`'5xx'`、`'default'` 或具体数字状态码,默认 `[]` */
37
60
  overwrite?: ('4xx' | '5xx' | 'default' | number)[];
38
61
  /** 插入新的状态码响应(无论是否已存在),默认 `[]` */
39
62
  insert?: (number | 'default')[];
63
+ /**
64
+ * 是否处理该 operation;返回 `false` 时完全跳过(既不覆写也不插入)。
65
+ *
66
+ * 用于无法添加 `@SkipUnifiedExceptionResponse()` 装饰器的 operation;
67
+ * 未提供时处理全部 operation。
68
+ */
69
+ filter?: (context: UnifyExceptionResponsesFilterContext) => boolean;
40
70
  }
41
71
  /**
42
72
  * 将统一异常响应结构注入 OpenAPI 文档。
@@ -45,10 +75,16 @@ interface UnifyExceptionResponsesOptions {
45
75
  * 在 `components.responses` 注册可复用的 `ExceptionResponse` 响应对象,
46
76
  * 并根据选项覆写或插入 operation 的异常响应。
47
77
  *
78
+ * 标记了 `@SkipUnifiedExceptionResponse()`(即 operation 上存在
79
+ * `x-buka-skip-unified-exception-response` 扩展)或 `filter` 返回 `false`
80
+ * 的 operation 会被完全跳过:既不覆写也不插入,需自行声明错误响应。
81
+ * `components` 属于全局组件,仍会照常注册。
82
+ *
48
83
  * @param openapi - OpenAPI 文档对象(会被原地修改)
49
84
  * @param options - 控制覆写和插入行为
50
85
  * @param options.overwrite - 覆写已有的哪些响应,支持 `'4xx'`、`'5xx'`、`'default'` 或具体数字状态码,默认 `[]`
51
86
  * @param options.insert - 插入新的状态码响应(无论是否已存在),默认 `[]`
87
+ * @param options.filter - 返回 `false` 的 operation 完全跳过,默认处理全部
52
88
  *
53
89
  * @example
54
90
  * ```typescript
@@ -72,16 +108,16 @@ interface UnifyExceptionResponsesOptions {
72
108
  * overwrite: ['5xx'],
73
109
  * insert: [401, 403],
74
110
  * })
111
+ *
112
+ * // 按路径豁免无法添加装饰器的 operation
113
+ * SwaggerPatcher.unifyExceptionResponses(document, {
114
+ * overwrite: ['4xx', '5xx'],
115
+ * filter: ({ pathname }) => pathname !== '/health',
116
+ * })
75
117
  * ```
76
118
  */
77
119
  declare function unifyExceptionResponses(openapi: OpenAPIObject, options?: UnifyExceptionResponsesOptions): void;
78
120
  //#endregion
79
- //#region src/swagger-patcher/openapi-helpers.d.ts
80
- type ReferenceObject = {
81
- $ref: string;
82
- };
83
- type SchemaObject = Exclude<ValueOf<Required<Required<OpenAPIObject>['components']>['schemas']>, ReferenceObject>;
84
- //#endregion
85
121
  //#region src/swagger-patcher/swagger-patcher.d.ts
86
122
  /**
87
123
  * Swagger/OpenAPI 文档修补工具,用于修正生成的 OpenAPI 文档中的已知问题。
@@ -91,6 +127,35 @@ declare class SwaggerPatcher {
91
127
  static unifyExceptionResponses: typeof unifyExceptionResponses;
92
128
  }
93
129
  //#endregion
130
+ //#region src/swagger-patcher/decorators/skip-unified-exception-response.decorator.d.ts
131
+ /**
132
+ * 跳过统一异常响应(`SwaggerPatcher.unifyExceptionResponses`)
133
+ *
134
+ * 标记在 controller 方法上时,仅该 operation 不被覆写/插入 `ExceptionResponse`;
135
+ * 标记在 controller 类上时,该类所有 operation 均跳过。
136
+ *
137
+ * 用于错误响应遵循其他规范、不符合 Buka 统一信封的端点(如 OAuth2 token、
138
+ * 健康检查)。被跳过的 operation 需要自行通过 `@ApiResponse` 声明错误响应。
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * @Post('token')
143
+ * @SkipUnifiedExceptionResponse()
144
+ * @ApiResponse({ status: 400, type: OAuth2ErrorResponseDto })
145
+ * exchangeToken() {}
146
+ * ```
147
+ */
148
+ declare function SkipUnifiedExceptionResponse(): ReturnType<typeof ApiExtension>;
149
+ //#endregion
150
+ //#region src/swagger-patcher/constants.d.ts
151
+ /**
152
+ * 标记 operation 跳过统一异常响应的 OpenAPI 扩展键
153
+ *
154
+ * 由 `@SkipUnifiedExceptionResponse()` 写入,`SwaggerPatcher.unifyExceptionResponses`
155
+ * 读取后完全跳过该 operation(既不覆写也不插入)。
156
+ */
157
+ declare const SKIP_UNIFIED_EXCEPTION_RESPONSE_EXTENSION = "x-buka-skip-unified-exception-response";
158
+ //#endregion
94
159
  //#region src/modules/core/buka-module-options.d.ts
95
160
  interface BukaModuleOptions {
96
161
  validation?: ValidationPipeOptions;
@@ -17983,5 +18048,5 @@ declare function throwOnResponseError(options?: ThrowOnResponseErrorOptions): Ke
17983
18048
  */
17984
18049
  declare function stableStringify(value: unknown): string;
17985
18050
  //#endregion
17986
- 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, ICollectionOperator, IEntityPrimaryKey, IFilter, IFilterQuery, IListResponseBody, IListResponseBodyMeta, INestedOperator, INextCursorPageParameters, IObjectOperator, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IPropertyOperator, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_ENUM_COLUMN, IS_SCALAR_DICTIONARY, IS_URN, IScalarOperator, InjectLogger, IntersectionType, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsEnumColumn, 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 };
18051
+ 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, ICollectionOperator, IEntityPrimaryKey, IFilter, IFilterQuery, IListResponseBody, IListResponseBodyMeta, INestedOperator, INextCursorPageParameters, IObjectOperator, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IPropertyOperator, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_ENUM_COLUMN, IS_SCALAR_DICTIONARY, IS_URN, IScalarOperator, InjectLogger, IntersectionType, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsEnumColumn, 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, type OperationObject, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResponseBodyType, SKIP_UNIFIED_EXCEPTION_RESPONSE_EXTENSION, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, SkipUnifiedExceptionResponse, Slice, type SwaggerHttpMethod, SwaggerPatcher, SystemException, ThirdPartyException, type ThrowOnResponseErrorOptions, TimestampedEntity, type UnifyExceptionResponsesFilterContext, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify, throwOnResponseError };
17987
18052
  //# sourceMappingURL=index.d.ts.map