import { Type } from "class-transformer";
import {
  ArrayMinSize,
  IsArray,
  IsNotEmpty,
  IsOptional,
  IsString,
  ValidateNested,
} from "class-validator";

export interface ChatMessage {
  role: string;
  content: string;
}

export class ChatMessageDto implements ChatMessage {
  @IsString({ message: "role must be a string" })
  @IsNotEmpty({ message: "role is required" })
  role!: string;

  @IsString({ message: "content must be a string" })
  @IsNotEmpty({ message: "content is required" })
  content!: string;
}

export class ChatStreamDto {
  @IsArray({ message: "messages must be an array" })
  @ArrayMinSize(1, { message: "messages must contain at least one message" })
  @ValidateNested({ each: true })
  @Type(() => ChatMessageDto)
  messages!: ChatMessageDto[];

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