""" Data models for sync operations. """ from dataclasses import dataclass, field from datetime import datetime from typing import Optional @dataclass class SyncOperation: """ Model for tracking sync operations. Attributes: entity_type: Type of entity being synced ("merchant" | "catalogue" | "employee" | "warehouse") entity_id: Unique identifier of the entity operation: Type of operation ("create" | "update" | "activate" | "deactivate") timestamp: When the sync operation was created retry_count: Number of retry attempts made last_error: Last error message if sync failed """ entity_type: str entity_id: str operation: str timestamp: datetime = field(default_factory=datetime.utcnow) retry_count: int = 0 last_error: Optional[str] = None def __post_init__(self): """Validate entity_type and operation values""" valid_entity_types = {"merchant", "catalogue", "employee", "warehouse", "catalogues", "merchants", "warehouses", "employees", "uom"} if self.entity_type not in valid_entity_types: raise ValueError(f"entity_type must be one of {valid_entity_types}, got {self.entity_type}") valid_operations = {"create", "update", "activate", "deactivate"} if self.operation not in valid_operations: raise ValueError(f"operation must be one of {valid_operations}, got {self.operation}")