import { IsString, MinLength, MaxLength, IsOptional, IsBoolean } from "class-validator";
import type { IntentType, ExtractedEntity } from "../interfaces";

/** Maximum query length to prevent DoS and excessive LLM costs */
export const MAX_QUERY_LENGTH = 500;

/**
 * DTO for intent classification request
 */
export class ClassifyIntentDto {
  @IsString()
  @MinLength(1, { message: "query must not be empty" })
  @MaxLength(MAX_QUERY_LENGTH, {
    message: `query must not exceed ${String(MAX_QUERY_LENGTH)} characters`,
  })
  query!: string;

  @IsOptional()
  @IsBoolean()
  useLlm?: boolean;
}

/**
 * DTO for intent classification result
 */
export class IntentClassificationResultDto {
  intent!: IntentType;
  confidence!: number;
  entities!: ExtractedEntity[];
  method!: "rule" | "llm";
  query!: string;
}
