import { IsArray, IsNumber, IsOptional, IsString, MaxLength, MinLength } from "class-validator";

/**
 * DTO for a single jarvis-brain task record.
 * This matches the task object shape consumed by scripts/migrate-brain.ts.
 */
export class ImportTaskDto {
  @IsString({ message: "id must be a string" })
  @MinLength(1, { message: "id must not be empty" })
  @MaxLength(255, { message: "id must not exceed 255 characters" })
  id!: string;

  @IsString({ message: "title must be a string" })
  @MinLength(1, { message: "title must not be empty" })
  @MaxLength(255, { message: "title must not exceed 255 characters" })
  title!: string;

  @IsOptional()
  @IsString({ message: "domain must be a string" })
  domain?: string | null;

  @IsOptional()
  @IsString({ message: "project must be a string" })
  project?: string | null;

  @IsOptional()
  @IsArray({ message: "related must be an array" })
  @IsString({ each: true, message: "related items must be strings" })
  related?: string[];

  @IsOptional()
  @IsString({ message: "priority must be a string" })
  priority?: string | null;

  @IsOptional()
  @IsString({ message: "status must be a string" })
  status?: string | null;

  @IsOptional()
  @IsNumber({}, { message: "progress must be a number" })
  progress?: number | null;

  @IsOptional()
  @IsString({ message: "due must be a string" })
  due?: string | null;

  @IsOptional()
  @IsArray({ message: "blocks must be an array" })
  @IsString({ each: true, message: "blocks items must be strings" })
  blocks?: string[];

  @IsOptional()
  @IsArray({ message: "blocked_by must be an array" })
  @IsString({ each: true, message: "blocked_by items must be strings" })
  blocked_by?: string[];

  @IsOptional()
  @IsString({ message: "assignee must be a string" })
  assignee?: string | null;

  @IsOptional()
  @IsString({ message: "created must be a string" })
  created?: string | null;

  @IsOptional()
  @IsString({ message: "updated must be a string" })
  updated?: string | null;

  @IsOptional()
  @IsString({ message: "notes must be a string" })
  notes?: string | null;

  @IsOptional()
  @IsString({ message: "notes_nontechnical must be a string" })
  notes_nontechnical?: string | null;
}
