"""Common schemas.""" from pydantic import BaseModel, Field from typing import Optional, Any class PaginationParams(BaseModel): """Pagination parameters.""" page: int = Field(1, ge=1, description="Page number") page_size: int = Field(10, ge=1, le=100, description="Items per page") @property def offset(self) -> int: """Calculate offset for pagination.""" return (self.page - 1) * self.page_size class MessageResponse(BaseModel): """Generic success message response.""" message: str success: bool = True class ErrorResponse(BaseModel): """Generic error response.""" message: str error_code: Optional[str] = None success: bool = False class PaginatedResponse(BaseModel): """Generic paginated response.""" items: list[Any] total: int page: int page_size: int total_pages: int @classmethod def create( cls, items: list[Any], total: int, page: int, page_size: int ) -> "PaginatedResponse": """Create paginated response.""" total_pages = (total + page_size - 1) // page_size return cls( items=items, total=total, page=page, page_size=page_size, total_pages=total_pages )