from pydantic import BaseModel, Field
from datetime import datetime
from enum import Enum
from typing import Optional, Dict, Any, List

class ActivityEventType(str, Enum):
    CHORE_COMPLETED = "chore_completed"
    CHORE_CREATED = "chore_created"
    EXPENSE_CREATED = "expense_created"
    EXPENSE_SETTLED = "expense_settled"
    ITEM_ADDED = "item_added"
    ITEM_COMPLETED = "item_completed"
    USER_JOINED_GROUP = "user_joined_group"

class ActivityUser(BaseModel):
    id: int
    name: Optional[str] = None

class Activity(BaseModel):
    id: str = Field(..., description="A unique ID for the activity event, e.g., 'chore_completed-123'")
    event_type: ActivityEventType
    timestamp: datetime
    user: ActivityUser
    details: Dict[str, Any] = Field({}, description="Structured data about the event.")
    message: str = Field(..., description="A human-readable message, e.g., 'John completed \"Wash dishes\".'")

    class Config:
        from_attributes = True

class PaginatedActivityResponse(BaseModel):
    items: List[Activity]
    cursor: Optional[int] = Field(None, description="The timestamp of the last item, for cursor-based pagination.") 