import { IsString, IsArray, ValidateNested, IsOptional, IsIn } from 'class-validator';
import { Type } from 'class-transformer';

export class DecomposeReqMemberDto {
  @IsString()
  name!: string;

  @IsString()
  role!: string;
}

export class DecomposeReqRequirementDto {
  @IsString()
  id!: string;

  @IsString()
  code!: string;

  @IsString()
  title!: string;

  @IsString()
  @IsOptional()
  description?: string;
}

export class DecomposeDto {
  @IsString()
  prototypeUrl!: string;

  @IsString()
  versionId!: string;

  @IsString()
  planId!: string;

  @IsOptional()
  @IsIn(['all', 'dev_tasks', 'test_cases'])
  target?: 'all' | 'dev_tasks' | 'test_cases';

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => DecomposeReqRequirementDto)
  requirements!: DecomposeReqRequirementDto[];

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => DecomposeReqMemberDto)
  members!: DecomposeReqMemberDto[];
}
