import {
  IsString,
  IsOptional,
  IsIn,
  IsObject,
  IsNumber,
  IsBoolean,
  Min,
  Max,
} from "class-validator";

/**
 * DTO for querying list widget data
 */
export class ListQueryDto {
  @IsString({ message: "dataSource must be a string" })
  @IsIn(["tasks", "events", "projects"], {
    message: "dataSource must be one of: tasks, events, projects",
  })
  dataSource!: "tasks" | "events" | "projects";

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

  @IsOptional()
  @IsString({ message: "sortOrder must be a string" })
  @IsIn(["asc", "desc"], { message: "sortOrder must be asc or desc" })
  sortOrder?: "asc" | "desc";

  @IsOptional()
  @IsNumber({}, { message: "limit must be a number" })
  @Min(1, { message: "limit must be at least 1" })
  @Max(50, { message: "limit must not exceed 50" })
  limit?: number;

  @IsOptional()
  @IsObject({ message: "filter must be an object" })
  filter?: Record<string, unknown>;

  @IsOptional()
  @IsBoolean({ message: "showStatus must be a boolean" })
  showStatus?: boolean;

  @IsOptional()
  @IsBoolean({ message: "showDueDate must be a boolean" })
  showDueDate?: boolean;
}
