import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { ArrayMaxSize, ArrayMinSize, IsArray, IsMimeType, IsOptional, IsString, ValidateNested } from 'class-validator';

class UploadFileSpec {
  @ApiProperty({ example: 'sofa-front.jpg' })
  @IsString()
  fileName!: string;

  @ApiProperty({ example: 'image/jpeg' })
  @IsMimeType()
  mimeType!: string;
}

export class GenerateTransferUploadUrlsDto {
  @ApiProperty({ required: false, description: 'Listing ID (null for draft uploads)' })
  @IsOptional()
  @IsString()
  listingId?: string;

  @ApiProperty({ type: [UploadFileSpec], minItems: 1, maxItems: 10 })
  @IsArray()
  @ArrayMinSize(1)
  @ArrayMaxSize(10)
  @ValidateNested({ each: true })
  @Type(() => UploadFileSpec)
  files!: UploadFileSpec[];
}
