@buka/nestjs-kit 4.5.0 → 4.6.0

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/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { BadRequestException, Catch, ConfigurableModuleBuilder, Controller, Get,
2
2
  import { APP_FILTER, APP_PIPE } from "@nestjs/core";
3
3
  import { BigIntType, Config, Cursor, EntityManager, EntityMetadata, EntitySchema, FlushMode, HiddenProps, MetadataStorage, MikroORM, OptionalProps, PrimaryKeyProp, Reference, Utils, helper } from "@mikro-orm/core";
4
4
  import { Embeddable, Embedded, Enum as Enum$1, ManyToMany, ManyToOne, OneToMany, OneToOne, PrimaryKey, Property as Property$1 } from "@mikro-orm/decorators/legacy";
5
- import { ArrayMinSize, IS_OPTIONAL, IsArray, IsBoolean, IsCurrency, IsDefined, IsEnum, IsISO8601, IsIn, IsInt, IsNotEmpty, IsNumber, IsNumberString, IsObject, IsOptional, IsString, IsUUID, IsUrl, MaxLength, Min, MinLength, ValidateNested, getMetadataStorage, isEnum, registerDecorator, validate, validateSync } from "class-validator";
5
+ import { ArrayMinSize, IS_OPTIONAL, IsArray, IsBoolean, IsCurrency, IsDefined, IsEnum, IsISO8601, IsIn, IsInt, IsNotEmpty, IsNumber, IsNumberString, IsObject, IsOptional, IsString, IsUUID, IsUrl, Matches, MaxLength, Min, MinLength, ValidateNested, getMetadataStorage, isEnum, registerDecorator, validate, validateSync } from "class-validator";
6
6
  import { validate as validate$1 } from "jsonschema";
7
7
  import { ApiExtraModels, ApiHideProperty, ApiOkResponse, ApiOperation, ApiProperty, ApiPropertyOptional, ApiQuery, ApiSchema, ApiTags, IntersectionType as IntersectionType$1, OmitType as OmitType$1, PartialType as PartialType$1, PickType as PickType$1, getSchemaPath } from "@nestjs/swagger";
8
8
  import { Transform, Type as Type$1, plainToInstance } from "class-transformer";
@@ -2493,6 +2493,47 @@ function Uuid(options) {
2493
2493
  };
2494
2494
  }
2495
2495
  //#endregion
2496
+ //#region src/modules/mikro-orm/decorators/columns/date.column.ts
2497
+ /**
2498
+ * DATE 列装饰器,声明一个只含日期的列(无时间、无时区)。
2499
+ *
2500
+ * 自动应用 MikroORM `@Property({ type: 'date' })`、`@Matches()` + `@IsISO8601({ strict: true })`
2501
+ * 验证及 Swagger schema(format: date)。
2502
+ *
2503
+ * MikroORM `DateType` 在 JS 侧表示为 `YYYY-MM-DD` 字符串,不是 `Date` 对象,也不代表某个绝对时刻。
2504
+ *
2505
+ * @param options - 列配置
2506
+ *
2507
+ * @example
2508
+ * ```typescript
2509
+ * @Entity()
2510
+ * class CourseOccurrence {
2511
+ * @Date({ comment: '计划日期' })
2512
+ * date: string
2513
+ * }
2514
+ * ```
2515
+ */
2516
+ function Date$1(options) {
2517
+ return (target, propertyKey) => {
2518
+ Property$1({
2519
+ ...options,
2520
+ type: "date"
2521
+ })(target, propertyKey);
2522
+ applyDecorators(Matches(/^\d{4}-\d{2}-\d{2}$/, { message: "$property must be a date in YYYY-MM-DD format" }), IsISO8601({ strict: true }), Property({
2523
+ optional: options?.nullable,
2524
+ lazy: options?.lazy,
2525
+ schema: {
2526
+ type: "string",
2527
+ format: "date",
2528
+ description: options?.comment,
2529
+ example: options?.example,
2530
+ examples: options?.examples,
2531
+ required: !options?.nullable
2532
+ }
2533
+ }))(target, propertyKey);
2534
+ };
2535
+ }
2536
+ //#endregion
2496
2537
  //#region src/modules/mikro-orm/decorators/columns/timestamptz.column.ts
2497
2538
  /**
2498
2539
  * TIMESTAMPTZ 列装饰器,声明一个带时区的时间戳列。
@@ -2741,6 +2782,7 @@ const Column = {
2741
2782
  Numeric,
2742
2783
  Boolean: Boolean$1,
2743
2784
  Uuid,
2785
+ Date: Date$1,
2744
2786
  Timestamptz,
2745
2787
  Enum: Enum$2,
2746
2788
  Jsonb,