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

export class KycFileRequestDto {
  @ApiProperty({
    enum: ['frontImage', 'backImage', 'selfieImage'],
    description: 'KYC image field identifier',
  })
  @IsIn(['frontImage', 'backImage', 'selfieImage'])
  field!: 'frontImage' | 'backImage' | 'selfieImage';

  @ApiProperty({
    description: 'MIME type of the file (image/jpeg, image/png, image/webp)',
    example: 'image/jpeg',
  })
  @IsString()
  @MinLength(1)
  mimeType!: string;

  @ApiProperty({
    description: 'Original file name',
    example: 'cccd-front.jpg',
  })
  @IsString()
  @MinLength(1)
  fileName!: string;
}

export class GenerateKycUploadUrlsDto {
  @ApiProperty({
    type: [KycFileRequestDto],
    description: 'List of KYC files to generate upload URLs for (1-3)',
    minItems: 1,
    maxItems: 3,
  })
  @IsArray()
  @ArrayMinSize(1)
  @ArrayMaxSize(3)
  @ValidateNested({ each: true })
  @Type(() => KycFileRequestDto)
  files!: KycFileRequestDto[];
}
