from typing import List, Literal, Optional

from pydantic import BaseModel


class PostcodeSplitterTriggerRequest(BaseModel):
    task_id: str
    sub_task_id: str
    s3_uri: str


class CombinerTriggerRequest(BaseModel):
    task_id: str
    sub_task_id: str


class FlagsSummary(BaseModel):
    duplicates: int
    missing: int
    matched: int


class CombinedResultRow(BaseModel):
    row_index: int
    input_address: str
    internal_reference: Optional[str] = None
    uprn: Optional[str] = None
    matched_address: Optional[str] = None
    lexiscore: Optional[float] = None
    score_bucket: Optional[Literal["high", "med", "low"]] = None
    flags: List[Literal["duplicate", "missing"]] = []


class CombinedResultsResponse(BaseModel):
    task_id: str
    total: int
    offset: int
    limit: int
    flags_summary: FlagsSummary
    rows: List[CombinedResultRow]
