@buka/nestjs-kit 4.4.0 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.4.2](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.1...v4.4.2) (2026-06-07)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * 修复 Column.Enum 不兼容 arrary 类型的问题 ([0b1e5e1](https://github.com/buka-ltd/npm.nestjs-kit/commit/0b1e5e1d6e5b94349aae4eeebc68c615719e252e))
9
+ * 修复jsonb不支持schalar class的问题 ([281e61e](https://github.com/buka-ltd/npm.nestjs-kit/commit/281e61ef8124b4464f050b9cf335510715d3b213))
10
+
11
+ ## [4.4.1](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.0...v4.4.1) (2026-06-04)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * 修复 EntityDto 导致swagger属性丢失的问题 ([b6b2f69](https://github.com/buka-ltd/npm.nestjs-kit/commit/b6b2f6902f3eb6ccd8bc4373b0c9b12a772b385d))
17
+
3
18
  ## [4.4.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.5...v4.4.0) (2026-06-03)
4
19
 
5
20
 
package/dist/index.d.mts CHANGED
@@ -183,6 +183,38 @@ declare const IS_CROCKFORD_BASE32 = "isCrockfordBase32";
183
183
  */
184
184
  declare function IsCrockfordBase32(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
185
185
  //#endregion
186
+ //#region src/modules/core/decorators/class-validator/is-enum-column.d.ts
187
+ declare const IS_ENUM_COLUMN = "isEnumColumn";
188
+ /**
189
+ * 枚举列验证器,验证单个值是否为合法的枚举值。
190
+ *
191
+ * 延迟解析 `items`(在验证阶段才调用工厂函数),避免装饰器阶段因循环引用报错。
192
+ * 同时兼容两种写法:枚举对象 `() => Status` 和值数组 `() => Object.values(Status)`。
193
+ *
194
+ * 验证逻辑委托给 class-validator 内置的 `isEnum` / `Array.includes`。
195
+ * 如需校验数组,配合 `IsArray()` 和 `{ each: true }` 使用。
196
+ *
197
+ * @param items - 枚举对象、值数组,或返回它们的工厂函数
198
+ * @param validationOptions - class-validator 的验证选项
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * // 单值校验
203
+ * class MyDto {
204
+ * @IsEnumColumn(() => Status)
205
+ * status: Status
206
+ * }
207
+ *
208
+ * // 数组校验
209
+ * class MyDto {
210
+ * @IsArray()
211
+ * @IsEnumColumn(() => Status, { each: true })
212
+ * statuses: Status[]
213
+ * }
214
+ * ```
215
+ */
216
+ declare function IsEnumColumn(items: (() => object | (string | number)[]) | object | (string | number)[], validationOptions?: ValidationOptions): PropertyDecorator;
217
+ //#endregion
186
218
  //#region src/modules/core/decorators/class-validator/is-scalar.d.ts
187
219
  type ScalarClass = typeof String | typeof Number | typeof Boolean;
188
220
  type ExcludeScalarClass<T> = T extends ScalarClass ? never : T;
@@ -416,7 +448,13 @@ interface EnumPropertyMetadata extends PropertyMetadataBase {
416
448
  kind: 'enum';
417
449
  type?: () => object;
418
450
  values?: (string | number)[];
451
+ /**
452
+ * MikroORM `@Enum()` 列装饰器传入的原始 `items` 参数。
453
+ * 保持原始格式(数组或惰性函数),不立即求值以避免循环引用。
454
+ */
455
+ items?: (() => (string | number)[]) | (string | number)[];
419
456
  enumName?: string;
457
+ array?: boolean;
420
458
  }
421
459
  type PropertyMetadata = ScalarPropertyMetadata | CompositePropertyMetadata | ListPropertyMetadata | DictionaryPropertyMetadata | EnumPropertyMetadata;
422
460
  type PropertyKind = 'scalar' | 'composite' | 'list' | 'dictionary' | 'enum';
@@ -1625,7 +1663,7 @@ interface ColumnEnumOptions extends Omit<EnumOptions<AnyEntity>, 'type' | 'colum
1625
1663
  *
1626
1664
  * @Entity()
1627
1665
  * class User {
1628
- * @Enum({ items: () => Object.values(Status), enumName: 'Status', comment: '用户状态' })
1666
+ * @Enum({ items: () => Status, enumName: 'Status', comment: '用户状态' })
1629
1667
  * status: Status
1630
1668
  * }
1631
1669
  * ```
@@ -1633,11 +1671,24 @@ interface ColumnEnumOptions extends Omit<EnumOptions<AnyEntity>, 'type' | 'colum
1633
1671
  declare function Enum$1<T extends object>(options: ColumnEnumOptions): (target: T, propertyName: string) => void;
1634
1672
  //#endregion
1635
1673
  //#region src/modules/mikro-orm/decorators/columns/jsonb.column.d.ts
1636
- interface JsonbOptions<T extends object> extends Omit<PropertyOptions<T>, 'type' | 'columnType'> {
1637
- type: () => Class<object>;
1638
- kind?: 'composite' | 'list' | 'dictionary';
1674
+ interface JsonbOptionsBase<T extends object> extends Omit<PropertyOptions<T>, 'type' | 'columnType'> {
1639
1675
  schema?: ApiPropertyOptions;
1640
1676
  }
1677
+ /**
1678
+ * kind = 'composite'(默认)时,type 必须是 class 引用,不能是标量类型。
1679
+ */
1680
+ interface JsonbOptionsComposite<T extends object> extends JsonbOptionsBase<T> {
1681
+ type: () => Class<object>;
1682
+ kind?: 'composite';
1683
+ }
1684
+ /**
1685
+ * kind = 'list' | 'dictionary' 时,type 可以是 class 引用或标量类型(String / Number / Boolean)。
1686
+ */
1687
+ interface JsonbOptionsListOrDict<T extends object> extends JsonbOptionsBase<T> {
1688
+ type: (() => Class<object>) | ScalarClass;
1689
+ kind: 'list' | 'dictionary';
1690
+ }
1691
+ type JsonbOptions<T extends object> = JsonbOptionsComposite<T> | JsonbOptionsListOrDict<T>;
1641
1692
  /**
1642
1693
  * JSONB 列装饰器,声明一个 JSONB 类型的数据库列。
1643
1694
  *
@@ -18660,5 +18711,5 @@ declare function throwOnResponseError(options?: ThrowOnResponseErrorOptions): Ke
18660
18711
  */
18661
18712
  declare function stableStringify(value: unknown): string;
18662
18713
  //#endregion
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 };
18714
+ 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_ENUM_COLUMN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, 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 };
18664
18715
  //# sourceMappingURL=index.d.mts.map
package/dist/index.d.ts CHANGED
@@ -183,6 +183,38 @@ declare const IS_CROCKFORD_BASE32 = "isCrockfordBase32";
183
183
  */
184
184
  declare function IsCrockfordBase32(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
185
185
  //#endregion
186
+ //#region src/modules/core/decorators/class-validator/is-enum-column.d.ts
187
+ declare const IS_ENUM_COLUMN = "isEnumColumn";
188
+ /**
189
+ * 枚举列验证器,验证单个值是否为合法的枚举值。
190
+ *
191
+ * 延迟解析 `items`(在验证阶段才调用工厂函数),避免装饰器阶段因循环引用报错。
192
+ * 同时兼容两种写法:枚举对象 `() => Status` 和值数组 `() => Object.values(Status)`。
193
+ *
194
+ * 验证逻辑委托给 class-validator 内置的 `isEnum` / `Array.includes`。
195
+ * 如需校验数组,配合 `IsArray()` 和 `{ each: true }` 使用。
196
+ *
197
+ * @param items - 枚举对象、值数组,或返回它们的工厂函数
198
+ * @param validationOptions - class-validator 的验证选项
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * // 单值校验
203
+ * class MyDto {
204
+ * @IsEnumColumn(() => Status)
205
+ * status: Status
206
+ * }
207
+ *
208
+ * // 数组校验
209
+ * class MyDto {
210
+ * @IsArray()
211
+ * @IsEnumColumn(() => Status, { each: true })
212
+ * statuses: Status[]
213
+ * }
214
+ * ```
215
+ */
216
+ declare function IsEnumColumn(items: (() => object | (string | number)[]) | object | (string | number)[], validationOptions?: ValidationOptions): PropertyDecorator;
217
+ //#endregion
186
218
  //#region src/modules/core/decorators/class-validator/is-scalar.d.ts
187
219
  type ScalarClass = typeof String | typeof Number | typeof Boolean;
188
220
  type ExcludeScalarClass<T> = T extends ScalarClass ? never : T;
@@ -416,7 +448,13 @@ interface EnumPropertyMetadata extends PropertyMetadataBase {
416
448
  kind: 'enum';
417
449
  type?: () => object;
418
450
  values?: (string | number)[];
451
+ /**
452
+ * MikroORM `@Enum()` 列装饰器传入的原始 `items` 参数。
453
+ * 保持原始格式(数组或惰性函数),不立即求值以避免循环引用。
454
+ */
455
+ items?: (() => (string | number)[]) | (string | number)[];
419
456
  enumName?: string;
457
+ array?: boolean;
420
458
  }
421
459
  type PropertyMetadata = ScalarPropertyMetadata | CompositePropertyMetadata | ListPropertyMetadata | DictionaryPropertyMetadata | EnumPropertyMetadata;
422
460
  type PropertyKind = 'scalar' | 'composite' | 'list' | 'dictionary' | 'enum';
@@ -1625,7 +1663,7 @@ interface ColumnEnumOptions extends Omit<EnumOptions<AnyEntity>, 'type' | 'colum
1625
1663
  *
1626
1664
  * @Entity()
1627
1665
  * class User {
1628
- * @Enum({ items: () => Object.values(Status), enumName: 'Status', comment: '用户状态' })
1666
+ * @Enum({ items: () => Status, enumName: 'Status', comment: '用户状态' })
1629
1667
  * status: Status
1630
1668
  * }
1631
1669
  * ```
@@ -1633,11 +1671,24 @@ interface ColumnEnumOptions extends Omit<EnumOptions<AnyEntity>, 'type' | 'colum
1633
1671
  declare function Enum$1<T extends object>(options: ColumnEnumOptions): (target: T, propertyName: string) => void;
1634
1672
  //#endregion
1635
1673
  //#region src/modules/mikro-orm/decorators/columns/jsonb.column.d.ts
1636
- interface JsonbOptions<T extends object> extends Omit<PropertyOptions<T>, 'type' | 'columnType'> {
1637
- type: () => Class<object>;
1638
- kind?: 'composite' | 'list' | 'dictionary';
1674
+ interface JsonbOptionsBase<T extends object> extends Omit<PropertyOptions<T>, 'type' | 'columnType'> {
1639
1675
  schema?: ApiPropertyOptions;
1640
1676
  }
1677
+ /**
1678
+ * kind = 'composite'(默认)时,type 必须是 class 引用,不能是标量类型。
1679
+ */
1680
+ interface JsonbOptionsComposite<T extends object> extends JsonbOptionsBase<T> {
1681
+ type: () => Class<object>;
1682
+ kind?: 'composite';
1683
+ }
1684
+ /**
1685
+ * kind = 'list' | 'dictionary' 时,type 可以是 class 引用或标量类型(String / Number / Boolean)。
1686
+ */
1687
+ interface JsonbOptionsListOrDict<T extends object> extends JsonbOptionsBase<T> {
1688
+ type: (() => Class<object>) | ScalarClass;
1689
+ kind: 'list' | 'dictionary';
1690
+ }
1691
+ type JsonbOptions<T extends object> = JsonbOptionsComposite<T> | JsonbOptionsListOrDict<T>;
1641
1692
  /**
1642
1693
  * JSONB 列装饰器,声明一个 JSONB 类型的数据库列。
1643
1694
  *
@@ -18660,5 +18711,5 @@ declare function throwOnResponseError(options?: ThrowOnResponseErrorOptions): Ke
18660
18711
  */
18661
18712
  declare function stableStringify(value: unknown): string;
18662
18713
  //#endregion
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 };
18714
+ 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_ENUM_COLUMN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, 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 };
18664
18715
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -291,6 +291,59 @@ function IsCrockfordBase32(validationOptions) {
291
291
  };
292
292
  }
293
293
  //#endregion
294
+ //#region src/modules/core/decorators/class-validator/is-enum-column.ts
295
+ const IS_ENUM_COLUMN = "isEnumColumn";
296
+ /**
297
+ * 枚举列验证器,验证单个值是否为合法的枚举值。
298
+ *
299
+ * 延迟解析 `items`(在验证阶段才调用工厂函数),避免装饰器阶段因循环引用报错。
300
+ * 同时兼容两种写法:枚举对象 `() => Status` 和值数组 `() => Object.values(Status)`。
301
+ *
302
+ * 验证逻辑委托给 class-validator 内置的 `isEnum` / `Array.includes`。
303
+ * 如需校验数组,配合 `IsArray()` 和 `{ each: true }` 使用。
304
+ *
305
+ * @param items - 枚举对象、值数组,或返回它们的工厂函数
306
+ * @param validationOptions - class-validator 的验证选项
307
+ *
308
+ * @example
309
+ * ```typescript
310
+ * // 单值校验
311
+ * class MyDto {
312
+ * @IsEnumColumn(() => Status)
313
+ * status: Status
314
+ * }
315
+ *
316
+ * // 数组校验
317
+ * class MyDto {
318
+ * @IsArray()
319
+ * @IsEnumColumn(() => Status, { each: true })
320
+ * statuses: Status[]
321
+ * }
322
+ * ```
323
+ */
324
+ function IsEnumColumn(items, validationOptions) {
325
+ return function(object, propertyName) {
326
+ (0, class_validator.registerDecorator)({
327
+ name: IS_ENUM_COLUMN,
328
+ target: object.constructor,
329
+ propertyName,
330
+ constraints: [items],
331
+ options: validationOptions,
332
+ validator: {
333
+ validate(value) {
334
+ const rawValues = typeof items === "function" ? items() : items;
335
+ if (Array.isArray(rawValues)) return rawValues.includes(value);
336
+ return (0, class_validator.isEnum)(value, rawValues);
337
+ },
338
+ defaultMessage() {
339
+ const rawValues = typeof items === "function" ? items() : items;
340
+ return `$property 必须是以下之一: ${(Array.isArray(rawValues) ? rawValues : Object.values(rawValues).filter((v) => isNaN(Number(v)))).join(", ")}`;
341
+ }
342
+ }
343
+ });
344
+ };
345
+ }
346
+ //#endregion
294
347
  //#region src/modules/core/decorators/class-validator/is-scalar.ts
295
348
  function isScalarClass(ctor) {
296
349
  return ctor === String || ctor === Number || ctor === Boolean;
@@ -1442,9 +1495,19 @@ function isString(value) {
1442
1495
  }
1443
1496
  //#endregion
1444
1497
  //#region src/utils/internals/nestjs-swagger.ts
1498
+ /**
1499
+ * 模拟 @nestjs/swagger 的 DECORATORS 常量。
1500
+ *
1501
+ * `@nestjs/swagger` 的类型声明(`index.d.ts`)未导出 `DECORATORS`,
1502
+ * 仅在运行时可用。为避免 `ts(2305)` 错误,直接内联其常量值。
1503
+ */
1504
+ const DECORATORS = {
1505
+ API_MODEL_PROPERTIES: "swagger/apiModelProperties",
1506
+ API_MODEL_PROPERTIES_ARRAY: "swagger/apiModelPropertiesArray"
1507
+ };
1445
1508
  const METADATA_FACTORY_NAME = "_OPENAPI_METADATA_FACTORY";
1446
1509
  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));
1510
+ 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
1511
  }
1449
1512
  function clonePluginMetadataFactory(target, parent, transformFn = (x) => x) {
1450
1513
  let targetMetadata = {};
@@ -1478,9 +1541,9 @@ function cloneMetadata(target, source, keys) {
1478
1541
  }
1479
1542
  }
1480
1543
  function getMetadataOfDecorator(classRef, propertyKey) {
1481
- if (propertyKey) return Reflect.getMetadata(_nestjs_swagger.DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, propertyKey);
1544
+ if (propertyKey) return Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, propertyKey);
1482
1545
  const props = getModelProperties(classRef.prototype);
1483
- return ramda.fromPairs(props.map((prop) => [prop, Reflect.getMetadata(_nestjs_swagger.DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, prop)]));
1546
+ return ramda.fromPairs(props.map((prop) => [prop, Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, prop)]));
1484
1547
  }
1485
1548
  function getMetadataOfPlugin(classRef, propertyKey) {
1486
1549
  const propsInPlugin = typeof classRef["_OPENAPI_METADATA_FACTORY"] === "function" ? classRef[METADATA_FACTORY_NAME]() : {};
@@ -2450,7 +2513,7 @@ function Timestamptz(options) {
2450
2513
  *
2451
2514
  * @Entity()
2452
2515
  * class User {
2453
- * @Enum({ items: () => Object.values(Status), enumName: 'Status', comment: '用户状态' })
2516
+ * @Enum({ items: () => Status, enumName: 'Status', comment: '用户状态' })
2454
2517
  * status: Status
2455
2518
  * }
2456
2519
  * ```
@@ -2459,19 +2522,44 @@ function Enum$1(options) {
2459
2522
  return (target, propertyKey) => {
2460
2523
  (0, _mikro_orm_decorators_legacy.Enum)(options)(target, propertyKey);
2461
2524
  const items = options.items;
2462
- const values = typeof items === "function" ? items() : items;
2463
- (0, _nestjs_common.applyDecorators)(Property({
2525
+ if (options.array) {
2526
+ (0, class_validator.IsArray)()(target, propertyKey);
2527
+ IsEnumColumn(items, { each: true })(target, propertyKey);
2528
+ if (options.nullable) (0, class_validator.IsOptional)()(target, propertyKey);
2529
+ else (0, class_validator.IsDefined)()(target, propertyKey);
2530
+ if (!options.lazy) {
2531
+ const schema = {
2532
+ description: options.comment,
2533
+ enum: items,
2534
+ isArray: true,
2535
+ enumName: options.enumName,
2536
+ example: options.example,
2537
+ examples: options.examples,
2538
+ required: !options.nullable
2539
+ };
2540
+ if (options.nullable) (0, _nestjs_swagger.ApiPropertyOptional)(schema)(target, propertyKey);
2541
+ else (0, _nestjs_swagger.ApiProperty)(schema)(target, propertyKey);
2542
+ }
2543
+ ModelRegister.addProperty(target.constructor, propertyKey, {
2544
+ kind: "enum",
2545
+ optional: options.nullable ?? false,
2546
+ lazy: options.lazy ?? false,
2547
+ items,
2548
+ enumName: options.enumName,
2549
+ array: options.array
2550
+ });
2551
+ } else Property({
2464
2552
  optional: options.nullable,
2465
2553
  lazy: options.lazy,
2466
2554
  schema: {
2467
2555
  description: options.comment,
2468
- enum: values,
2556
+ enum: items,
2469
2557
  enumName: options.enumName,
2470
2558
  example: options.example,
2471
2559
  examples: options.examples,
2472
2560
  required: !options.nullable
2473
2561
  }
2474
- }))(target, propertyKey);
2562
+ })(target, propertyKey);
2475
2563
  };
2476
2564
  }
2477
2565
  //#endregion
@@ -2526,7 +2614,11 @@ function Jsonb(options) {
2526
2614
  Dictionary(decoratorOptions)(target, propertyKey);
2527
2615
  break;
2528
2616
  default:
2529
- Composite(decoratorOptions)(target, propertyKey);
2617
+ if (isScalarClass(type)) throw new TypeError(`Jsonb with kind='composite' requires a class reference (() => Class), but got scalar type: ${type.name}`);
2618
+ Composite({
2619
+ ...decoratorOptions,
2620
+ type
2621
+ })(target, propertyKey);
2530
2622
  break;
2531
2623
  }
2532
2624
  };
@@ -2714,6 +2806,11 @@ __decorate([
2714
2806
  function EntityDto(classRef) {
2715
2807
  if (!ModelRegister.isModel(classRef)) throw new TypeError("EntityDto only accepts a class annotated with @Model().");
2716
2808
  class EntityDtoClass {}
2809
+ /**
2810
+ * 收集从源实体复制的 Swagger 属性元数据,
2811
+ * 用于构建 `_OPENAPI_METADATA_FACTORY`。
2812
+ */
2813
+ const swaggerProps = {};
2717
2814
  for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
2718
2815
  if (ModelRegister.getProperty(classRef, propertyKey)?.lazy) continue;
2719
2816
  ModelRegister.copyProperty(classRef, EntityDtoClass, propertyKey);
@@ -2723,7 +2820,26 @@ function EntityDto(classRef) {
2723
2820
  if (Reflect.hasMetadata(metadataKey, EntityDtoClass.prototype, propertyKey)) continue;
2724
2821
  Reflect.defineMetadata(metadataKey, value, EntityDtoClass.prototype, propertyKey);
2725
2822
  }
2823
+ /**
2824
+ * 收集已复制的 `@ApiProperty` 元数据,后续通过
2825
+ * `_OPENAPI_METADATA_FACTORY` 暴露给 `@nestjs/swagger`,
2826
+ * 使 applyMetadataFactory() 遍历原型链时能发现这些属性。
2827
+ */
2828
+ if (typeof propertyKey === "string") {
2829
+ const swaggerMeta = Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, EntityDtoClass.prototype, propertyKey);
2830
+ if (swaggerMeta) swaggerProps[propertyKey] = swaggerMeta;
2831
+ }
2726
2832
  }
2833
+ /**
2834
+ * 设置 `_OPENAPI_METADATA_FACTORY` 静态方法。
2835
+ *
2836
+ * `@nestjs/swagger` 插件在编译时无法识别 `EntityDto`,
2837
+ * 只对子类(如 `CourseBriefDto`)中直接声明的属性生成 factory。
2838
+ * 当 `applyMetadataFactory()` 遍历原型链时,
2839
+ * 它会在 `EntityDtoClass` 上找到此 factory,
2840
+ * 并将源实体属性应用到子类的 prototype 上。
2841
+ */
2842
+ if (Object.keys(swaggerProps).length > 0) EntityDtoClass[METADATA_FACTORY_NAME] = () => swaggerProps;
2727
2843
  return EntityDtoClass;
2728
2844
  }
2729
2845
  //#endregion
@@ -10218,12 +10334,14 @@ exports.HasAnyKey = HasAnyKey;
10218
10334
  exports.HttpException = HttpException;
10219
10335
  exports.IS_CROCKFORD_BASE32 = IS_CROCKFORD_BASE32;
10220
10336
  exports.IS_DOMAIN_URN = IS_DOMAIN_URN;
10337
+ exports.IS_ENUM_COLUMN = IS_ENUM_COLUMN;
10221
10338
  exports.IS_SCALAR_DICTIONARY = IS_SCALAR_DICTIONARY;
10222
10339
  exports.IS_URN = IS_URN;
10223
10340
  exports.InjectLogger = InjectLogger;
10224
10341
  exports.IsBrowserRequest = IsBrowserRequest;
10225
10342
  exports.IsCrockfordBase32 = IsCrockfordBase32;
10226
10343
  exports.IsDomainUrn = IsDomainUrn;
10344
+ exports.IsEnumColumn = IsEnumColumn;
10227
10345
  exports.IsScalar = IsScalar;
10228
10346
  exports.IsScalarDictionary = IsScalarDictionary;
10229
10347
  exports.IsUrn = IsUrn;