import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsOptional, IsNumber, IsIn, MaxLength } from 'class-validator';

const SOURCE_TYPES = ['file', 'link', 'manual', 'paste'] as const;

export class AddSourceDto {
  @ApiPropertyOptional({ description: '关联的上传文件 ID' })
  @IsOptional()
  @IsString()
  fileId?: string;

  @ApiPropertyOptional({ description: '来源类型', enum: SOURCE_TYPES, default: 'file' })
  @IsOptional()
  @IsString()
  @IsIn(SOURCE_TYPES)
  type?: string;

  @ApiPropertyOptional({ description: '来源标题', example: '机器学习笔记' })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  title?: string;

  @ApiPropertyOptional({ description: '原始文件名', example: 'notes.pdf' })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  originalFilename?: string;

  @ApiPropertyOptional({ description: 'MIME 类型', example: 'application/pdf' })
  @IsOptional()
  @IsString()
  mimeType?: string;

  @ApiPropertyOptional({ description: '文件大小（字节）', example: 1048576 })
  @IsOptional()
  @IsNumber()
  sizeBytes?: number;

  @ApiPropertyOptional({ description: 'COS 对象 Key' })
  @IsOptional()
  @IsString()
  originalObjectKey?: string;
}
