from pydantic import BaseModel, Field from typing import List, Optional class User(BaseModel): id: str username: str display_name: str created_at: str class CreateUser(BaseModel): username: str = Field(..., pattern=r"^[a-z0-9_]{3,32}$") display_name: str = Field(..., min_length=1, max_length=100) password: str = Field(..., min_length=12, max_length=128) class Chat(BaseModel): id: str title: str member_ids: List[str] created_at: str class CreateChat(BaseModel): title: str = Field(..., min_length=1, max_length=100) member_ids: List[str] = Field(..., min_length=1, max_length=100) class Message(BaseModel): id: str chat_id: str sender_id: str text: str created_at: str class CreateMessage(BaseModel): text: str = Field(..., min_length=1, max_length=4000) class ChatPage(BaseModel): items: List[Chat] next_cursor: Optional[str] = None class MessagePage(BaseModel): items: List[Message] next_cursor: Optional[str] = None class Health(BaseModel): status: str = "ok" class Session(BaseModel): token: str token_type: str = "Bearer" expires_at: str user: User class ErrorBody(BaseModel): code: str message: str request_id: str class ErrorResponse(BaseModel): error: ErrorBody