import { Type } from 'class-transformer';
import { IsInt, IsOptional, IsString, Max, Min, MinLength } from 'class-validator';

/**
 * Query-string DTO for `GET /api/ai/rag/search`.
 *
 * Bounded — the upstream RAG service has its own server-side cap on
 * `top_k`, but the BFF rejects obviously-out-of-range values early
 * so a single SPA bug cannot induce repeated 400s round-tripped
 * through the AI service.
 */
export class RagSearchQueryDto {
  @IsString()
  @MinLength(1)
  query!: string;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(50)
  topK?: number;

  @IsOptional()
  @IsString()
  source?: string;

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