@buka/nestjs-kit 4.4.1 → 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 +8 -0
- package/dist/index.d.mts +56 -5
- package/dist/index.d.ts +56 -5
- package/dist/index.js +90 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
3
11
|
## [4.4.1](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.0...v4.4.1) (2026-06-04)
|
|
4
12
|
|
|
5
13
|
|
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: () =>
|
|
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
|
|
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: () =>
|
|
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
|
|
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;
|
|
@@ -2460,7 +2513,7 @@ function Timestamptz(options) {
|
|
|
2460
2513
|
*
|
|
2461
2514
|
* @Entity()
|
|
2462
2515
|
* class User {
|
|
2463
|
-
* @Enum({ items: () =>
|
|
2516
|
+
* @Enum({ items: () => Status, enumName: 'Status', comment: '用户状态' })
|
|
2464
2517
|
* status: Status
|
|
2465
2518
|
* }
|
|
2466
2519
|
* ```
|
|
@@ -2469,19 +2522,44 @@ function Enum$1(options) {
|
|
|
2469
2522
|
return (target, propertyKey) => {
|
|
2470
2523
|
(0, _mikro_orm_decorators_legacy.Enum)(options)(target, propertyKey);
|
|
2471
2524
|
const items = options.items;
|
|
2472
|
-
|
|
2473
|
-
|
|
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({
|
|
2474
2552
|
optional: options.nullable,
|
|
2475
2553
|
lazy: options.lazy,
|
|
2476
2554
|
schema: {
|
|
2477
2555
|
description: options.comment,
|
|
2478
|
-
enum:
|
|
2556
|
+
enum: items,
|
|
2479
2557
|
enumName: options.enumName,
|
|
2480
2558
|
example: options.example,
|
|
2481
2559
|
examples: options.examples,
|
|
2482
2560
|
required: !options.nullable
|
|
2483
2561
|
}
|
|
2484
|
-
})
|
|
2562
|
+
})(target, propertyKey);
|
|
2485
2563
|
};
|
|
2486
2564
|
}
|
|
2487
2565
|
//#endregion
|
|
@@ -2536,7 +2614,11 @@ function Jsonb(options) {
|
|
|
2536
2614
|
Dictionary(decoratorOptions)(target, propertyKey);
|
|
2537
2615
|
break;
|
|
2538
2616
|
default:
|
|
2539
|
-
|
|
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);
|
|
2540
2622
|
break;
|
|
2541
2623
|
}
|
|
2542
2624
|
};
|
|
@@ -10252,12 +10334,14 @@ exports.HasAnyKey = HasAnyKey;
|
|
|
10252
10334
|
exports.HttpException = HttpException;
|
|
10253
10335
|
exports.IS_CROCKFORD_BASE32 = IS_CROCKFORD_BASE32;
|
|
10254
10336
|
exports.IS_DOMAIN_URN = IS_DOMAIN_URN;
|
|
10337
|
+
exports.IS_ENUM_COLUMN = IS_ENUM_COLUMN;
|
|
10255
10338
|
exports.IS_SCALAR_DICTIONARY = IS_SCALAR_DICTIONARY;
|
|
10256
10339
|
exports.IS_URN = IS_URN;
|
|
10257
10340
|
exports.InjectLogger = InjectLogger;
|
|
10258
10341
|
exports.IsBrowserRequest = IsBrowserRequest;
|
|
10259
10342
|
exports.IsCrockfordBase32 = IsCrockfordBase32;
|
|
10260
10343
|
exports.IsDomainUrn = IsDomainUrn;
|
|
10344
|
+
exports.IsEnumColumn = IsEnumColumn;
|
|
10261
10345
|
exports.IsScalar = IsScalar;
|
|
10262
10346
|
exports.IsScalarDictionary = IsScalarDictionary;
|
|
10263
10347
|
exports.IsUrn = IsUrn;
|