import { ApiPropertyOptional } from '@nestjs/swagger'
import { IsString, IsBoolean, IsOptional, IsDateString } from 'class-validator'
import { Transform } from 'class-transformer'

export class UpdateVersionDto {
  @ApiPropertyOptional({ description: '下载地址' })
  @IsOptional()
  @IsString()
  downloadUrl?: string

  @ApiPropertyOptional({ description: '文件大小(字节)' })
  @IsOptional()
  @IsString()
  fileSize?: string

  @ApiPropertyOptional({ description: 'SHA256校验和' })
  @IsOptional()
  @IsString()
  fileSha256?: string

  @ApiPropertyOptional({ description: '更新日志' })
  @IsOptional()
  @IsString()
  changelog?: string

  @ApiPropertyOptional({ description: '是否强制更新' })
  @IsOptional()
  @Transform(({ value }) => value === 'true' || value === true)
  @IsBoolean()
  isForceUpdate?: boolean

  @ApiPropertyOptional({ description: '最低操作系统版本' })
  @IsOptional()
  @IsString()
  minOsVersion?: string | null

  @ApiPropertyOptional({ description: '发布日期' })
  @IsOptional()
  @IsDateString()
  releaseDate?: string | null
}
