import {
  IsString,
  IsArray,
  IsOptional,
  IsDateString,
  MinLength,
  MaxLength,
  IsObject,
  ValidateNested,
  ArrayMinSize,
} from "class-validator";
import { Type } from "class-transformer";

/**
 * Represents a single message in a conversation session
 */
export class ConversationMessageDto {
  @IsString()
  role!: string;

  @IsString()
  @MinLength(1)
  content!: string;

  @IsOptional()
  @IsDateString()
  timestamp?: string;
}

/**
 * DTO for ingesting a conversation session log
 */
export class IngestConversationDto {
  @IsString()
  @MinLength(1)
  @MaxLength(500)
  sessionId!: string;

  @IsString()
  @MinLength(1)
  @MaxLength(500)
  agentId!: string;

  @IsArray()
  @ArrayMinSize(1)
  @ValidateNested({ each: true })
  @Type(() => ConversationMessageDto)
  messages!: ConversationMessageDto[];

  @IsString()
  @MinLength(1)
  summary!: string;

  @IsDateString()
  startedAt!: string;

  @IsOptional()
  @IsDateString()
  endedAt?: string;

  @IsOptional()
  @IsObject()
  metadata?: Record<string, unknown>;
}
