@buka/nestjs-kit 4.3.1 → 4.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.3.3](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.2...v4.3.3) (2026-05-27)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * 修正Entity默认产生的swagger格式与findOne默认查询结果不一致的问题 ([03bf307](https://github.com/buka-ltd/npm.nestjs-kit/commit/03bf307882cdf0e451a36e5b970e0e86f9179e01))
9
+
10
+ ## [4.3.2](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.1...v4.3.2) (2026-05-26)
11
+
12
+
13
+ ### Performance Improvements
14
+
15
+ * 对象存储模块添加错误日志 ([968aaab](https://github.com/buka-ltd/npm.nestjs-kit/commit/968aaab5542e3a1f952027f61ad17cafca8fd4ba))
16
+
3
17
  ## [4.3.1](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.3.0...v4.3.1) (2026-05-25)
4
18
 
5
19
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _$_nestjs_common0 from "@nestjs/common";
2
2
  import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
3
- import { AnyEntity, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
3
+ import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
4
4
  import { ValidationOptions } from "class-validator";
5
5
  import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
6
6
  import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest } from "keq";
@@ -453,7 +453,8 @@ interface ScalarPropertyOptions {
453
453
  optional?: boolean;
454
454
  /**
455
455
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
456
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
456
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
457
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
457
458
  *
458
459
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
459
460
  */
@@ -526,7 +527,8 @@ interface CompositeOptions {
526
527
  optional?: boolean;
527
528
  /**
528
529
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
529
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
530
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
531
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
530
532
  *
531
533
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
532
534
  */
@@ -572,7 +574,8 @@ interface ListOptionsBase {
572
574
  optional?: boolean;
573
575
  /**
574
576
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
575
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
577
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
578
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
576
579
  *
577
580
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
578
581
  */
@@ -629,7 +632,8 @@ interface DictionaryOptionsBase {
629
632
  optional?: boolean;
630
633
  /**
631
634
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
632
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
635
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
636
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
633
637
  *
634
638
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
635
639
  */
@@ -693,7 +697,8 @@ interface EnumOptionsBase {
693
697
  optional?: boolean;
694
698
  /**
695
699
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
696
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
700
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
701
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
697
702
  *
698
703
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
699
704
  */
@@ -1122,32 +1127,6 @@ interface ResourceIdUrn extends Urn {
1122
1127
  withResourceId: never;
1123
1128
  }
1124
1129
  //#endregion
1125
- //#region src/modules/core/converters/eager-type/eager-type.d.ts
1126
- /**
1127
- * 从模型中排除所有标记为 `lazy: true` 的属性,生成仅包含非懒加载字段的新类型。
1128
- *
1129
- * 适用于 API 响应场景,避免返回未加载的字段。
1130
- *
1131
- * @param classRef - 使用 `@Model()` 标注的类引用
1132
- * @returns 排除了 lazy 属性的新类
1133
- *
1134
- * @example
1135
- * ```typescript
1136
- * @Model()
1137
- * class User {
1138
- * @Property()
1139
- * name: string
1140
- *
1141
- * @Property({ lazy: true })
1142
- * bio: string
1143
- * }
1144
- *
1145
- * const UserResponse = EagerType(User)
1146
- * // UserResponse 仅包含 name,不包含 bio
1147
- * ```
1148
- */
1149
- declare function EagerType<T>(classRef: Class<T>): Class<T>;
1150
- //#endregion
1151
1130
  //#region src/modules/core/converters/filter-query-type/decorators/filter-query-operators.decorator.d.ts
1152
1131
  type FilterQueryOperator = 'eq' | 'ne' | 'lt' | 'gt' | 'lte' | 'gte' | 'in' | 'nin' | 'some' | 'every' | 'none';
1153
1132
  declare const FilterQueryOperatorsMetadataKey = "buka:filter-query-operators";
@@ -1351,6 +1330,49 @@ declare abstract class DiscreteEntity<Optional = never> extends TimestampedEntit
1351
1330
  id: string;
1352
1331
  }
1353
1332
  //#endregion
1333
+ //#region src/modules/mikro-orm/converters/entity-dto-type/entity-dto-type.d.ts
1334
+ /**
1335
+ * 从实体中排除 `Collection` 类型的属性键。
1336
+ *
1337
+ * `Collection` 对应 OneToMany / ManyToMany 关系,默认 `lazy: true`,
1338
+ * 不应出现在 EntityDto 中。
1339
+ */
1340
+ type IsCollection<T> = T extends Collection<any> ? true : false;
1341
+ /**
1342
+ * 将实体的 MikroORM 类型转换为 DTO 友好的类型:
1343
+ * - `Collection<Entity>` → 键被排除(lazy,不在默认 Swagger 中)
1344
+ * - `Ref<Entity>` → **保留原样**(`Ref` 是 nestjs-kit 的一等公民类型,
1345
+ * 序列化层会自动处理:populated 时完整序列化,否则仅返回主键)
1346
+ * - `Xxx & Opt` → 去除 `Opt` 标记
1347
+ */
1348
+ type EntityDtoShape<T> = { [K in keyof T as IsCollection<T[K]> extends true ? never : K]: ExcludeOpt<T[K]> };
1349
+ /**
1350
+ * 基于实体生成一个无继承关系的纯 DTO 类,用于安全派生。
1351
+ *
1352
+ * 返回的类:
1353
+ * - 不继承实体类,避免 `Collection` 类型与 DTO 字段冲突
1354
+ * - 仅包含非 `lazy: true` 的 Model 属性
1355
+ * - 保留 `Ref<Entity>` 类型(序列化层自动处理:populated 时完整序列化,否则仅主键)
1356
+ * - 保留所有 Swagger、class-validator、class-transformer 元数据
1357
+ * - Swagger schema 与 `findOne()` 不加 populate 的结果一致
1358
+ *
1359
+ * @param classRef - 使用 `@Model()` 标注的实体类引用
1360
+ * @returns 可用于 `extends` 派生的纯 DTO 类
1361
+ *
1362
+ * @example
1363
+ * ```typescript
1364
+ * // 基本用法:派生不含 Collection 的 DTO
1365
+ * class UserProfileBriefDto extends EntityDto(UserProfile) {}
1366
+ *
1367
+ * // 扩展用法:手动添加 lazy 属性
1368
+ * class UserProfileDetailDto extends EntityDto(UserProfile) {
1369
+ * @List({ type: () => PrimaryKeyType(Avatar) })
1370
+ * avatars!: PrimaryKeyTypeClass[]
1371
+ * }
1372
+ * ```
1373
+ */
1374
+ declare function EntityDto<T extends object>(classRef: Class<T>): Class<EntityDtoShape<T>>;
1375
+ //#endregion
1354
1376
  //#region src/modules/mikro-orm/converters/entity-primary-key-type/types/entity-primary-key.d.ts
1355
1377
  type IEntityPrimaryKey<T extends object> = { [K in keyof T as K extends PrimaryProperty<T> ? K : never]: Primary<T> };
1356
1378
  //#endregion
@@ -18695,5 +18717,5 @@ declare class ObjectStorageService implements OnModuleInit {
18695
18717
  */
18696
18718
  declare function stableStringify(value: unknown): string;
18697
18719
  //#endregion
18698
- export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, DomainUrn, EagerType, type EncryptCommand, EncryptedPayload, 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_RESOURCE_ID_URN, IS_RESOURCE_TYPE_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsResourceIdUrn, IsResourceTypeUrn, 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, ResourceIdUrn, ResourceTypeUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18720
+ export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, DomainUrn, 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_RESOURCE_ID_URN, IS_RESOURCE_TYPE_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsResourceIdUrn, IsResourceTypeUrn, 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, ResourceIdUrn, ResourceTypeUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18699
18721
  //# sourceMappingURL=index.d.mts.map
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { Class, JsonValue, ValueOf } from "type-fest";
4
4
  import * as _$_nestjs_common0 from "@nestjs/common";
5
5
  import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
6
6
  import { ValidationOptions } from "class-validator";
7
- import { AnyEntity, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
7
+ import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
8
8
  import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest } from "keq";
9
9
  import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCodeOptions } from "@buka/error-codes";
10
10
  import { Exception, ExceptionDetail, ExceptionDetail as ExceptionDetail$1, ExceptionOptions as ExceptionOptions$1 } from "@buka/exception";
@@ -453,7 +453,8 @@ interface ScalarPropertyOptions {
453
453
  optional?: boolean;
454
454
  /**
455
455
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
456
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
456
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
457
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
457
458
  *
458
459
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
459
460
  */
@@ -526,7 +527,8 @@ interface CompositeOptions {
526
527
  optional?: boolean;
527
528
  /**
528
529
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
529
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
530
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
531
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
530
532
  *
531
533
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
532
534
  */
@@ -572,7 +574,8 @@ interface ListOptionsBase {
572
574
  optional?: boolean;
573
575
  /**
574
576
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
575
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
577
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
578
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
576
579
  *
577
580
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
578
581
  */
@@ -629,7 +632,8 @@ interface DictionaryOptionsBase {
629
632
  optional?: boolean;
630
633
  /**
631
634
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
632
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
635
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
636
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
633
637
  *
634
638
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
635
639
  */
@@ -693,7 +697,8 @@ interface EnumOptionsBase {
693
697
  optional?: boolean;
694
698
  /**
695
699
  * 标记该属性为懒加载。懒加载属性存在除 `undefined` 之外的第三种状态——"未加载",
696
- * 即该属性并非不存在,而是尚未被加载。可通过 `EagerType()` converter 从 DTO 中排除这些字段。
700
+ * 即该属性并非不存在,而是尚未被加载。懒加载属性默认不注册 Swagger schema,
701
+ * 因此不会出现在 API 文档中。如需包含,请在派生 DTO 中手动声明。
697
702
  *
698
703
  * 在 MikroORM 场景下,对应 `lazy: true` 的列,查询时不会默认 SELECT 该列,需显式 `populate` 才会加载。
699
704
  */
@@ -1122,32 +1127,6 @@ interface ResourceIdUrn extends Urn {
1122
1127
  withResourceId: never;
1123
1128
  }
1124
1129
  //#endregion
1125
- //#region src/modules/core/converters/eager-type/eager-type.d.ts
1126
- /**
1127
- * 从模型中排除所有标记为 `lazy: true` 的属性,生成仅包含非懒加载字段的新类型。
1128
- *
1129
- * 适用于 API 响应场景,避免返回未加载的字段。
1130
- *
1131
- * @param classRef - 使用 `@Model()` 标注的类引用
1132
- * @returns 排除了 lazy 属性的新类
1133
- *
1134
- * @example
1135
- * ```typescript
1136
- * @Model()
1137
- * class User {
1138
- * @Property()
1139
- * name: string
1140
- *
1141
- * @Property({ lazy: true })
1142
- * bio: string
1143
- * }
1144
- *
1145
- * const UserResponse = EagerType(User)
1146
- * // UserResponse 仅包含 name,不包含 bio
1147
- * ```
1148
- */
1149
- declare function EagerType<T>(classRef: Class<T>): Class<T>;
1150
- //#endregion
1151
1130
  //#region src/modules/core/converters/filter-query-type/decorators/filter-query-operators.decorator.d.ts
1152
1131
  type FilterQueryOperator = 'eq' | 'ne' | 'lt' | 'gt' | 'lte' | 'gte' | 'in' | 'nin' | 'some' | 'every' | 'none';
1153
1132
  declare const FilterQueryOperatorsMetadataKey = "buka:filter-query-operators";
@@ -1351,6 +1330,49 @@ declare abstract class DiscreteEntity<Optional = never> extends TimestampedEntit
1351
1330
  id: string;
1352
1331
  }
1353
1332
  //#endregion
1333
+ //#region src/modules/mikro-orm/converters/entity-dto-type/entity-dto-type.d.ts
1334
+ /**
1335
+ * 从实体中排除 `Collection` 类型的属性键。
1336
+ *
1337
+ * `Collection` 对应 OneToMany / ManyToMany 关系,默认 `lazy: true`,
1338
+ * 不应出现在 EntityDto 中。
1339
+ */
1340
+ type IsCollection<T> = T extends Collection<any> ? true : false;
1341
+ /**
1342
+ * 将实体的 MikroORM 类型转换为 DTO 友好的类型:
1343
+ * - `Collection<Entity>` → 键被排除(lazy,不在默认 Swagger 中)
1344
+ * - `Ref<Entity>` → **保留原样**(`Ref` 是 nestjs-kit 的一等公民类型,
1345
+ * 序列化层会自动处理:populated 时完整序列化,否则仅返回主键)
1346
+ * - `Xxx & Opt` → 去除 `Opt` 标记
1347
+ */
1348
+ type EntityDtoShape<T> = { [K in keyof T as IsCollection<T[K]> extends true ? never : K]: ExcludeOpt<T[K]> };
1349
+ /**
1350
+ * 基于实体生成一个无继承关系的纯 DTO 类,用于安全派生。
1351
+ *
1352
+ * 返回的类:
1353
+ * - 不继承实体类,避免 `Collection` 类型与 DTO 字段冲突
1354
+ * - 仅包含非 `lazy: true` 的 Model 属性
1355
+ * - 保留 `Ref<Entity>` 类型(序列化层自动处理:populated 时完整序列化,否则仅主键)
1356
+ * - 保留所有 Swagger、class-validator、class-transformer 元数据
1357
+ * - Swagger schema 与 `findOne()` 不加 populate 的结果一致
1358
+ *
1359
+ * @param classRef - 使用 `@Model()` 标注的实体类引用
1360
+ * @returns 可用于 `extends` 派生的纯 DTO 类
1361
+ *
1362
+ * @example
1363
+ * ```typescript
1364
+ * // 基本用法:派生不含 Collection 的 DTO
1365
+ * class UserProfileBriefDto extends EntityDto(UserProfile) {}
1366
+ *
1367
+ * // 扩展用法:手动添加 lazy 属性
1368
+ * class UserProfileDetailDto extends EntityDto(UserProfile) {
1369
+ * @List({ type: () => PrimaryKeyType(Avatar) })
1370
+ * avatars!: PrimaryKeyTypeClass[]
1371
+ * }
1372
+ * ```
1373
+ */
1374
+ declare function EntityDto<T extends object>(classRef: Class<T>): Class<EntityDtoShape<T>>;
1375
+ //#endregion
1354
1376
  //#region src/modules/mikro-orm/converters/entity-primary-key-type/types/entity-primary-key.d.ts
1355
1377
  type IEntityPrimaryKey<T extends object> = { [K in keyof T as K extends PrimaryProperty<T> ? K : never]: Primary<T> };
1356
1378
  //#endregion
@@ -18695,5 +18717,5 @@ declare class ObjectStorageService implements OnModuleInit {
18695
18717
  */
18696
18718
  declare function stableStringify(value: unknown): string;
18697
18719
  //#endregion
18698
- export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, DomainUrn, EagerType, type EncryptCommand, EncryptedPayload, 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_RESOURCE_ID_URN, IS_RESOURCE_TYPE_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsResourceIdUrn, IsResourceTypeUrn, 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, ResourceIdUrn, ResourceTypeUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18720
+ export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, DomainUrn, 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_RESOURCE_ID_URN, IS_RESOURCE_TYPE_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsResourceIdUrn, IsResourceTypeUrn, 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, ResourceIdUrn, ResourceTypeUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18699
18721
  //# sourceMappingURL=index.d.ts.map