"""Shared dataclasses for the promotion pipeline."""

from __future__ import annotations

from dataclasses import dataclass, field
from datetime import datetime
from typing import Any, Dict, List, Optional
from uuid import UUID


@dataclass
class PromotionTargetRecord:
    """Row from promotion_targets used during promotion runs."""

    target_id: UUID
    list_source: str
    list_year: Optional[int]
    rank: Optional[int]
    company_name: str
    domain_claimed: Optional[str]
    ticker: Optional[str]
    country_code: Optional[str]
    rev_usd: Optional[int]
    employees: Optional[int]
    provenance: Dict[str, Any] = field(default_factory=dict)


@dataclass
class CandidateMatch:
    """Best candidate retrieved from the knowledge graph for a target."""

    wikidata_id: str
    label: Optional[str]
    domain: Optional[str]
    all_domains: List[str]
    tickers: List[str]
    authority_sources: List[str]
    countries: List[Dict[str, Any]]
    revenue: Optional[float]
    employees: Optional[int]
    last_refreshed: Optional[datetime]
    source: str = "wikidata"
    raw_profile: Dict[str, Any] = field(default_factory=dict)
    # GLEIF enrichment fields
    lei: Optional[str] = None
    gleif_parent_lei: Optional[str] = None
    gleif_parent_wikidata_id: Optional[str] = None
    gleif_relationship_type: Optional[str] = None  # IS_DIRECTLY_CONSOLIDATED_BY, IS_ULTIMATELY_CONSOLIDATED_BY
