@buka/nestjs-kit 4.4.10 → 4.4.12
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 +16 -0
- package/dist/index.d.mts +29 -2
- package/dist/index.d.ts +29 -2
- package/dist/index.js +89 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.4.12](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.11...v4.4.12) (2026-08-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* 修复collection类型处理filter错误 ([1896dc8](https://github.com/buka-ltd/npm.nestjs-kit/commit/1896dc8770d2f6bf2bece9f076dd78a6a38961f4))
|
|
9
|
+
* 修复getModelPropertyKeys未遍历原型链导致父类属性丢失 ([a4f7dee](https://github.com/buka-ltd/npm.nestjs-kit/commit/a4f7dee73a99ba4d331712572ecb3b1cfca7c847))
|
|
10
|
+
|
|
11
|
+
## [4.4.11](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.10...v4.4.11) (2026-07-27)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* should export IntersectionType ([350af46](https://github.com/buka-ltd/npm.nestjs-kit/commit/350af460f2aa45700f68a7ea0fe224fff2735d8e))
|
|
17
|
+
* 修复QueryType的循环引用问题 ([c94d110](https://github.com/buka-ltd/npm.nestjs-kit/commit/c94d11008eccadee3c6cff02fd1a71b1a2e24faa))
|
|
18
|
+
|
|
3
19
|
## [4.4.10](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.9...v4.4.10) (2026-07-06)
|
|
4
20
|
|
|
5
21
|
|
package/dist/index.d.mts
CHANGED
|
@@ -911,7 +911,15 @@ interface IFilterQueryCollectionCondition<T> {
|
|
|
911
911
|
$none?: IFilterQueryNestedProperty<T>;
|
|
912
912
|
}
|
|
913
913
|
type IFilterQueryNestedProperty<T> = T extends Array<infer U> ? IFilterQueryCollectionCondition<U> : IFilterQueryObject<T>;
|
|
914
|
-
|
|
914
|
+
/**
|
|
915
|
+
* MikroORM Collection 类型检测
|
|
916
|
+
*
|
|
917
|
+
* 注意:必须使用 `Collection<any>` 而非 `Collection<infer U>`,参考 `EntityDtoType` 的实现。
|
|
918
|
+
* `Collection` 含有两个泛型参数(`T`、`O`),`infer U` 在条件类型中可能因 TypeScript
|
|
919
|
+
* 泛型推断限制而匹配失败。
|
|
920
|
+
*/
|
|
921
|
+
type IsCollection$1<T> = T extends Collection<any> ? true : false;
|
|
922
|
+
type IFilterQueryProperty<T> = T extends Relation ? IFilterQueryNestedProperty<T> : IsCollection$1<T> extends true ? IFilterQueryCollectionCondition<T extends Collection<infer U> ? U : never> : T extends Ref<infer U> ? IFilterQueryCondition<Primary<U>> : IFilterQueryCondition<T>;
|
|
915
923
|
type IFilterQueryObject<T> = { [K in keyof T as K extends string ? K : never]: IFilterQueryProperty<Exclude<T[K], undefined>> };
|
|
916
924
|
type IFilter<T> = IFilterQueryObject<T> | undefined;
|
|
917
925
|
interface IFilterQuery<T> {
|
|
@@ -1161,6 +1169,25 @@ declare function OmitType<T, K extends keyof T>(classRef: Class<T>, keys: K[]):
|
|
|
1161
1169
|
*/
|
|
1162
1170
|
declare function PartialType<T>(classRef: Class<T>): Class<Partial<T>>;
|
|
1163
1171
|
//#endregion
|
|
1172
|
+
//#region src/modules/core/converters/intersection-type/intersection-type.d.ts
|
|
1173
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
1174
|
+
type ClassRefsToConstructors<T extends Type[]> = { [U in keyof T]: T[U] extends Type<infer V> ? V : never };
|
|
1175
|
+
type Intersection<T extends Type[]> = Type<UnionToIntersection<ClassRefsToConstructors<T>[number]>>;
|
|
1176
|
+
/**
|
|
1177
|
+
* 将多个模型类合并为一个交叉类型。
|
|
1178
|
+
*
|
|
1179
|
+
* 类似 TypeScript 的交叉类型 `A & B`,同时合并 class-validator、class-transformer 和 Swagger 的元数据。
|
|
1180
|
+
*
|
|
1181
|
+
* @param classRefs - 需要合并的模型类引用列表
|
|
1182
|
+
* @returns 包含所有类属性的新类
|
|
1183
|
+
*
|
|
1184
|
+
* @example
|
|
1185
|
+
* ```typescript
|
|
1186
|
+
* const CreateUserDTO = IntersectionType(UserBaseDTO, UserProfileDTO)
|
|
1187
|
+
* ```
|
|
1188
|
+
*/
|
|
1189
|
+
declare function IntersectionType<T extends Type[]>(...classRefs: T): Intersection<T>;
|
|
1190
|
+
//#endregion
|
|
1164
1191
|
//#region src/modules/core/converters/order-query-type/types/order-query.d.ts
|
|
1165
1192
|
interface IOrderQuery<T> {
|
|
1166
1193
|
orderBy?: QueryOrderMap<T> | QueryOrderMap<T>[];
|
|
@@ -17848,5 +17875,5 @@ declare function throwOnResponseError(options?: ThrowOnResponseErrorOptions): Ke
|
|
|
17848
17875
|
*/
|
|
17849
17876
|
declare function stableStringify(value: unknown): string;
|
|
17850
17877
|
//#endregion
|
|
17851
|
-
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 };
|
|
17878
|
+
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, 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, Relation, 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 };
|
|
17852
17879
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -911,7 +911,15 @@ interface IFilterQueryCollectionCondition<T> {
|
|
|
911
911
|
$none?: IFilterQueryNestedProperty<T>;
|
|
912
912
|
}
|
|
913
913
|
type IFilterQueryNestedProperty<T> = T extends Array<infer U> ? IFilterQueryCollectionCondition<U> : IFilterQueryObject<T>;
|
|
914
|
-
|
|
914
|
+
/**
|
|
915
|
+
* MikroORM Collection 类型检测
|
|
916
|
+
*
|
|
917
|
+
* 注意:必须使用 `Collection<any>` 而非 `Collection<infer U>`,参考 `EntityDtoType` 的实现。
|
|
918
|
+
* `Collection` 含有两个泛型参数(`T`、`O`),`infer U` 在条件类型中可能因 TypeScript
|
|
919
|
+
* 泛型推断限制而匹配失败。
|
|
920
|
+
*/
|
|
921
|
+
type IsCollection$1<T> = T extends Collection<any> ? true : false;
|
|
922
|
+
type IFilterQueryProperty<T> = T extends Relation ? IFilterQueryNestedProperty<T> : IsCollection$1<T> extends true ? IFilterQueryCollectionCondition<T extends Collection<infer U> ? U : never> : T extends Ref<infer U> ? IFilterQueryCondition<Primary<U>> : IFilterQueryCondition<T>;
|
|
915
923
|
type IFilterQueryObject<T> = { [K in keyof T as K extends string ? K : never]: IFilterQueryProperty<Exclude<T[K], undefined>> };
|
|
916
924
|
type IFilter<T> = IFilterQueryObject<T> | undefined;
|
|
917
925
|
interface IFilterQuery<T> {
|
|
@@ -1161,6 +1169,25 @@ declare function OmitType<T, K extends keyof T>(classRef: Class<T>, keys: K[]):
|
|
|
1161
1169
|
*/
|
|
1162
1170
|
declare function PartialType<T>(classRef: Class<T>): Class<Partial<T>>;
|
|
1163
1171
|
//#endregion
|
|
1172
|
+
//#region src/modules/core/converters/intersection-type/intersection-type.d.ts
|
|
1173
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
1174
|
+
type ClassRefsToConstructors<T extends Type[]> = { [U in keyof T]: T[U] extends Type<infer V> ? V : never };
|
|
1175
|
+
type Intersection<T extends Type[]> = Type<UnionToIntersection<ClassRefsToConstructors<T>[number]>>;
|
|
1176
|
+
/**
|
|
1177
|
+
* 将多个模型类合并为一个交叉类型。
|
|
1178
|
+
*
|
|
1179
|
+
* 类似 TypeScript 的交叉类型 `A & B`,同时合并 class-validator、class-transformer 和 Swagger 的元数据。
|
|
1180
|
+
*
|
|
1181
|
+
* @param classRefs - 需要合并的模型类引用列表
|
|
1182
|
+
* @returns 包含所有类属性的新类
|
|
1183
|
+
*
|
|
1184
|
+
* @example
|
|
1185
|
+
* ```typescript
|
|
1186
|
+
* const CreateUserDTO = IntersectionType(UserBaseDTO, UserProfileDTO)
|
|
1187
|
+
* ```
|
|
1188
|
+
*/
|
|
1189
|
+
declare function IntersectionType<T extends Type[]>(...classRefs: T): Intersection<T>;
|
|
1190
|
+
//#endregion
|
|
1164
1191
|
//#region src/modules/core/converters/order-query-type/types/order-query.d.ts
|
|
1165
1192
|
interface IOrderQuery<T> {
|
|
1166
1193
|
orderBy?: QueryOrderMap<T> | QueryOrderMap<T>[];
|
|
@@ -17848,5 +17875,5 @@ declare function throwOnResponseError(options?: ThrowOnResponseErrorOptions): Ke
|
|
|
17848
17875
|
*/
|
|
17849
17876
|
declare function stableStringify(value: unknown): string;
|
|
17850
17877
|
//#endregion
|
|
17851
|
-
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 };
|
|
17878
|
+
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, 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, Relation, 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 };
|
|
17852
17879
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -850,8 +850,14 @@ var ModelRegister = class {
|
|
|
850
850
|
* ```
|
|
851
851
|
*/
|
|
852
852
|
static getModelPropertyKeys(target) {
|
|
853
|
-
const
|
|
854
|
-
|
|
853
|
+
const keys = /* @__PURE__ */ new Set();
|
|
854
|
+
let current = target;
|
|
855
|
+
while (current && current !== Object) {
|
|
856
|
+
const metadata = this.getModel(current);
|
|
857
|
+
if (metadata) for (const key of metadata.propertyKeys) keys.add(key);
|
|
858
|
+
current = Object.getPrototypeOf(current.prototype)?.constructor ?? null;
|
|
859
|
+
}
|
|
860
|
+
return Array.from(keys);
|
|
855
861
|
}
|
|
856
862
|
static getProperties(target) {
|
|
857
863
|
return this.getModelPropertyKeys(target).map((propertyKey) => this.getProperty(target, propertyKey)).filter((property) => !!property);
|
|
@@ -1602,7 +1608,7 @@ function swaggerMetadataToJsonSchema(metadata) {
|
|
|
1602
1608
|
}
|
|
1603
1609
|
//#endregion
|
|
1604
1610
|
//#region src/modules/core/converters/filter-query-type/get-filter-query-schema.ts
|
|
1605
|
-
function getObjectSchema(classRef) {
|
|
1611
|
+
function getObjectSchema(classRef, visited = /* @__PURE__ */ new WeakSet()) {
|
|
1606
1612
|
const properties = {};
|
|
1607
1613
|
const requiredKeys = [];
|
|
1608
1614
|
const schema = {
|
|
@@ -1610,24 +1616,28 @@ function getObjectSchema(classRef) {
|
|
|
1610
1616
|
properties,
|
|
1611
1617
|
additionalProperties: false
|
|
1612
1618
|
};
|
|
1619
|
+
visited.add(classRef);
|
|
1613
1620
|
for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
|
|
1614
1621
|
if (typeof propertyKey !== "string") continue;
|
|
1615
1622
|
const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey);
|
|
1616
1623
|
const isCollection = propertyMetadata?.association?.kind === "1:m" || propertyMetadata?.association?.kind === "m:n";
|
|
1617
1624
|
const isRelation = !!propertyMetadata?.association;
|
|
1618
1625
|
if (!!!propertyMetadata?.optional) requiredKeys.push(propertyKey);
|
|
1619
|
-
if (isRelation)
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1626
|
+
if (isRelation) {
|
|
1627
|
+
const relationClassRef = propertyMetadata.association.type();
|
|
1628
|
+
if (visited.has(relationClassRef)) continue;
|
|
1629
|
+
if (isCollection) {
|
|
1630
|
+
const sub = getObjectSchema(relationClassRef, visited);
|
|
1631
|
+
const operators = getCollectionOperators(classRef, propertyKey);
|
|
1632
|
+
const wrapper = {
|
|
1633
|
+
type: "object",
|
|
1634
|
+
properties: {},
|
|
1635
|
+
additionalProperties: false
|
|
1636
|
+
};
|
|
1637
|
+
for (const operator of operators) wrapper.properties[operator] = sub;
|
|
1638
|
+
properties[propertyKey] = wrapper;
|
|
1639
|
+
} else properties[propertyKey] = getObjectSchema(relationClassRef, visited);
|
|
1640
|
+
} else {
|
|
1631
1641
|
const propertySchema = {
|
|
1632
1642
|
type: "object",
|
|
1633
1643
|
properties: {},
|
|
@@ -1708,41 +1718,45 @@ function createFilterQueryPropertyClassRef(classRef, propertyKey) {
|
|
|
1708
1718
|
}
|
|
1709
1719
|
return propertyClass;
|
|
1710
1720
|
}
|
|
1711
|
-
function createFilterQueryObjectClassRef(classRef) {
|
|
1721
|
+
function createFilterQueryObjectClassRef(classRef, visited = /* @__PURE__ */ new WeakSet()) {
|
|
1712
1722
|
class FilterQueryObjectClass {}
|
|
1713
1723
|
ModelRegister.addModel(FilterQueryObjectClass);
|
|
1724
|
+
visited.add(classRef);
|
|
1714
1725
|
for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
|
|
1715
1726
|
if (typeof propertyKey !== "string") continue;
|
|
1716
1727
|
const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey);
|
|
1717
1728
|
const isCollection = propertyMetadata?.association?.kind === "1:m" || propertyMetadata?.association?.kind === "m:n";
|
|
1718
1729
|
const isRelation = !!propertyMetadata?.association;
|
|
1719
1730
|
const isOptional = !!propertyMetadata?.optional;
|
|
1720
|
-
if (isRelation)
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1731
|
+
if (isRelation) {
|
|
1732
|
+
const relationClassRef = propertyMetadata.association.type();
|
|
1733
|
+
if (visited.has(relationClassRef)) continue;
|
|
1734
|
+
if (isCollection) {
|
|
1735
|
+
class FilterQueryCollectionClass {}
|
|
1736
|
+
ModelRegister.addModel(FilterQueryCollectionClass);
|
|
1737
|
+
const sub = createFilterQueryObjectClassRef(relationClassRef, visited);
|
|
1738
|
+
const operators = getCollectionOperators(classRef, propertyKey);
|
|
1739
|
+
for (const operator of operators) {
|
|
1740
|
+
Composite({
|
|
1741
|
+
type: () => sub,
|
|
1742
|
+
optional: true
|
|
1743
|
+
})(FilterQueryCollectionClass.prototype, operator);
|
|
1744
|
+
if (!isOptional) HasAnyKey(getFilterQueryOperators(classRef, propertyKey))(FilterQueryCollectionClass.prototype, operator);
|
|
1745
|
+
(0, class_validator.IsOptional)()(FilterQueryCollectionClass.prototype, operator);
|
|
1746
|
+
}
|
|
1747
|
+
Composite({
|
|
1748
|
+
type: () => FilterQueryCollectionClass,
|
|
1749
|
+
optional: isOptional
|
|
1750
|
+
})(FilterQueryObjectClass.prototype, propertyKey);
|
|
1751
|
+
if (!isOptional) HasAnyKey(operators)(FilterQueryObjectClass.prototype, propertyKey);
|
|
1752
|
+
} else {
|
|
1753
|
+
const sub = createFilterQueryObjectClassRef(relationClassRef, visited);
|
|
1726
1754
|
Composite({
|
|
1727
1755
|
type: () => sub,
|
|
1728
|
-
optional:
|
|
1729
|
-
})(
|
|
1730
|
-
if (!isOptional) HasAnyKey(getFilterQueryOperators(classRef, propertyKey))(FilterQueryCollectionClass.prototype, operator);
|
|
1731
|
-
(0, class_validator.IsOptional)()(FilterQueryCollectionClass.prototype, operator);
|
|
1756
|
+
optional: isOptional
|
|
1757
|
+
})(FilterQueryObjectClass.prototype, propertyKey);
|
|
1732
1758
|
}
|
|
1733
|
-
Composite({
|
|
1734
|
-
type: () => FilterQueryCollectionClass,
|
|
1735
|
-
optional: isOptional
|
|
1736
|
-
})(FilterQueryObjectClass.prototype, propertyKey);
|
|
1737
|
-
if (!isOptional) HasAnyKey(operators)(FilterQueryObjectClass.prototype, propertyKey);
|
|
1738
1759
|
} else {
|
|
1739
|
-
const sub = createFilterQueryObjectClassRef(propertyMetadata.association.type());
|
|
1740
|
-
Composite({
|
|
1741
|
-
type: () => sub,
|
|
1742
|
-
optional: isOptional
|
|
1743
|
-
})(FilterQueryObjectClass.prototype, propertyKey);
|
|
1744
|
-
}
|
|
1745
|
-
else {
|
|
1746
1760
|
const propertyClass = createFilterQueryPropertyClassRef(classRef, propertyKey);
|
|
1747
1761
|
Composite({
|
|
1748
1762
|
type: () => propertyClass,
|
|
@@ -2951,11 +2965,12 @@ function ManyToOne(entity, options) {
|
|
|
2951
2965
|
return;
|
|
2952
2966
|
}
|
|
2953
2967
|
const type = () => resolveEntityType(entityRef, resolvedOptions?.eager);
|
|
2968
|
+
const fullEntityType = () => resolveEntityType(entityRef, true);
|
|
2954
2969
|
Composite({
|
|
2955
2970
|
type,
|
|
2956
2971
|
association: {
|
|
2957
2972
|
kind: "m:1",
|
|
2958
|
-
type
|
|
2973
|
+
type: fullEntityType
|
|
2959
2974
|
},
|
|
2960
2975
|
schema: {
|
|
2961
2976
|
description: resolvedOptions?.comment,
|
|
@@ -2989,11 +3004,12 @@ function OneToOne(entity, mappedByOrOptions, options) {
|
|
|
2989
3004
|
return;
|
|
2990
3005
|
}
|
|
2991
3006
|
const type = () => resolveEntityType(entityRef, resolvedOptions?.eager);
|
|
3007
|
+
const fullEntityType = () => resolveEntityType(entityRef, true);
|
|
2992
3008
|
Composite({
|
|
2993
3009
|
type,
|
|
2994
3010
|
association: {
|
|
2995
3011
|
kind: "1:1",
|
|
2996
|
-
type
|
|
3012
|
+
type: fullEntityType
|
|
2997
3013
|
},
|
|
2998
3014
|
schema: {
|
|
2999
3015
|
description: resolvedOptions?.comment,
|
|
@@ -3027,13 +3043,14 @@ function OneToMany(options) {
|
|
|
3027
3043
|
}
|
|
3028
3044
|
const entityRef = options.entity;
|
|
3029
3045
|
const type = () => resolveEntityType(entityRef, options.eager);
|
|
3046
|
+
const fullEntityType = () => resolveEntityType(entityRef, true);
|
|
3030
3047
|
List({
|
|
3031
3048
|
type,
|
|
3032
3049
|
optional: options.nullable,
|
|
3033
3050
|
lazy: options.eager !== true,
|
|
3034
3051
|
association: {
|
|
3035
3052
|
kind: "1:m",
|
|
3036
|
-
type
|
|
3053
|
+
type: fullEntityType
|
|
3037
3054
|
},
|
|
3038
3055
|
schema: {
|
|
3039
3056
|
description: options.comment,
|
|
@@ -3068,13 +3085,14 @@ function ManyToMany(entity, mappedBy, options) {
|
|
|
3068
3085
|
return;
|
|
3069
3086
|
}
|
|
3070
3087
|
const type = () => resolveEntityType(entityRef, resolvedOptions?.eager);
|
|
3088
|
+
const fullEntityType = () => resolveEntityType(entityRef, true);
|
|
3071
3089
|
List({
|
|
3072
3090
|
type,
|
|
3073
3091
|
optional: resolvedOptions?.nullable,
|
|
3074
3092
|
lazy: resolvedOptions?.eager !== true,
|
|
3075
3093
|
association: {
|
|
3076
3094
|
kind: "m:n",
|
|
3077
|
-
type
|
|
3095
|
+
type: fullEntityType
|
|
3078
3096
|
},
|
|
3079
3097
|
schema: {
|
|
3080
3098
|
description: resolvedOptions?.comment,
|
|
@@ -3476,6 +3494,34 @@ function PartialType(classRef) {
|
|
|
3476
3494
|
return PartialTypeClass;
|
|
3477
3495
|
}
|
|
3478
3496
|
//#endregion
|
|
3497
|
+
//#region src/modules/core/converters/intersection-type/intersection-type.ts
|
|
3498
|
+
/**
|
|
3499
|
+
* 将多个模型类合并为一个交叉类型。
|
|
3500
|
+
*
|
|
3501
|
+
* 类似 TypeScript 的交叉类型 `A & B`,同时合并 class-validator、class-transformer 和 Swagger 的元数据。
|
|
3502
|
+
*
|
|
3503
|
+
* @param classRefs - 需要合并的模型类引用列表
|
|
3504
|
+
* @returns 包含所有类属性的新类
|
|
3505
|
+
*
|
|
3506
|
+
* @example
|
|
3507
|
+
* ```typescript
|
|
3508
|
+
* const CreateUserDTO = IntersectionType(UserBaseDTO, UserProfileDTO)
|
|
3509
|
+
* ```
|
|
3510
|
+
*/
|
|
3511
|
+
function IntersectionType(...classRefs) {
|
|
3512
|
+
const IntersectionTypeClass = (0, _nestjs_swagger.IntersectionType)(...classRefs);
|
|
3513
|
+
for (const classRef of classRefs) for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
|
|
3514
|
+
ModelRegister.copyProperty(classRef, IntersectionTypeClass, propertyKey);
|
|
3515
|
+
const metadataKeys = Reflect.getMetadataKeys(classRef.prototype, propertyKey);
|
|
3516
|
+
for (const metadataKey of metadataKeys) {
|
|
3517
|
+
const metadata = Reflect.getMetadata(metadataKey, classRef.prototype, propertyKey);
|
|
3518
|
+
if (Reflect.hasMetadata(metadataKey, IntersectionTypeClass.prototype, propertyKey)) continue;
|
|
3519
|
+
Reflect.defineMetadata(metadataKey, metadata, IntersectionTypeClass.prototype, propertyKey);
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
return IntersectionTypeClass;
|
|
3523
|
+
}
|
|
3524
|
+
//#endregion
|
|
3479
3525
|
//#region src/modules/core/converters/order-query-type/get-order-query-schema.ts
|
|
3480
3526
|
function getOrderQueryEnum() {
|
|
3481
3527
|
return {
|
|
@@ -8630,6 +8676,7 @@ exports.IS_ENUM_COLUMN = IS_ENUM_COLUMN;
|
|
|
8630
8676
|
exports.IS_SCALAR_DICTIONARY = IS_SCALAR_DICTIONARY;
|
|
8631
8677
|
exports.IS_URN = IS_URN;
|
|
8632
8678
|
exports.InjectLogger = InjectLogger;
|
|
8679
|
+
exports.IntersectionType = IntersectionType;
|
|
8633
8680
|
exports.IsBrowserRequest = IsBrowserRequest;
|
|
8634
8681
|
exports.IsCrockfordBase32 = IsCrockfordBase32;
|
|
8635
8682
|
exports.IsDomainUrn = IsDomainUrn;
|