"""
Pydantic models for sync metadata and tracking.
"""

from datetime import date, datetime
from typing import Optional
from pydantic import BaseModel, Field


class SyncRecord(BaseModel):
    """Record of a sync operation."""

    id: Optional[int] = None
    data_type: str = Field(..., description="Type of data synced")
    start_date: date = Field(..., description="Start date of sync range")
    end_date: date = Field(..., description="End date of sync range")
    status: str = Field(..., description="Sync status: success, failed, partial")
    records_synced: int = Field(default=0, description="Number of records synced")
    error_message: Optional[str] = Field(
        default=None, description="Error message if sync failed"
    )
    created_at: Optional[datetime] = None


class LastSyncState(BaseModel):
    """Last sync state for a data type."""

    data_type: str = Field(..., description="Type of data")
    last_sync_date: date = Field(..., description="Last successfully synced date")
    total_records: int = Field(default=0, description="Total records synced")
    updated_at: Optional[datetime] = None
