import uuid from datetime import datetime from pydantic import BaseModel, ConfigDict, Field class RegisterRequest(BaseModel): username: str = Field(min_length=3, max_length=32) password: str = Field(min_length=8, max_length=128) # users.email is VARCHAR(255): without a cap here an over-long address # reached Postgres and surfaced as a 500 instead of a validation error. email: str | None = Field(default=None, max_length=255) class UserOut(BaseModel): id: uuid.UUID username: str essence: int = 0 unlocks: list[str] = Field(default_factory=list) model_config = ConfigDict(from_attributes=True) class LoginRequest(BaseModel): username: str password: str class UnlockOut(BaseModel): unlock_key: str unlocked_at: datetime model_config = ConfigDict(from_attributes=True) class PurchaseOut(BaseModel): unlock_key: str unlocked_at: datetime essence: int class InventoryItemOut(BaseModel): id: uuid.UUID item_type: str item_key: str payload: dict obtained_at: datetime model_config = ConfigDict(from_attributes=True) class SigilIn(BaseModel): name: str = Field(min_length=1, max_length=64) design: dict class SigilOut(BaseModel): id: uuid.UUID name: str design: dict created_at: datetime model_config = ConfigDict(from_attributes=True) class MessageIn(BaseModel): """A whisper sent from one hunter to another (Workstream S).""" # Length rules live in routes/messages.py, not here: an empty or # oversized body is a 400 with in-fiction copy the UI can show, which # is friendlier than Pydantic's 422 validation envelope. to: str body: str