from pydantic import BaseModel from typing import Optional, List class CategoryCreate(BaseModel): name: str color: Optional[str] = None sort_order: int = 0 class CategoryUpdate(BaseModel): name: Optional[str] = None color: Optional[str] = None sort_order: Optional[int] = None class CategoryOut(BaseModel): id: int name: str color: Optional[str] = None sort_order: int = 0 model_config = {"from_attributes": True} class CategoryReorderItem(BaseModel): id: int sort_order: int # ── Options ────────────────────────────────────────────────────────────────── class ProductOptionBase(BaseModel): name: str extra_cost: float = 0.0 class ProductOptionCreate(ProductOptionBase): pass class ProductOptionOut(ProductOptionBase): id: int product_id: int model_config = {"from_attributes": True} # ── Ingredients ─────────────────────────────────────────────────────────────── class ProductIngredientBase(BaseModel): name: str extra_cost: float = 0.0 class ProductIngredientCreate(ProductIngredientBase): pass class ProductIngredientOut(ProductIngredientBase): id: int product_id: int model_config = {"from_attributes": True} # ── Preferences ─────────────────────────────────────────────────────────────── class PreferenceChoiceBase(BaseModel): name: str extra_cost: float = 0.0 class PreferenceChoiceCreate(PreferenceChoiceBase): pass class PreferenceChoiceOut(PreferenceChoiceBase): id: int set_id: int model_config = {"from_attributes": True} class PreferenceSetBase(BaseModel): name: str class PreferenceSetCreate(PreferenceSetBase): choices: List[PreferenceChoiceCreate] = [] class PreferenceSetOut(PreferenceSetBase): id: int product_id: int choices: List[PreferenceChoiceOut] = [] model_config = {"from_attributes": True} # ── Products ────────────────────────────────────────────────────────────────── class ProductBase(BaseModel): name: str category_id: Optional[int] = None base_price: float is_available: bool = True printer_zone_id: Optional[int] = None class ProductCreate(ProductBase): options: List[ProductOptionCreate] = [] ingredients: List[ProductIngredientCreate] = [] preference_sets: List[PreferenceSetCreate] = [] class ProductUpdate(BaseModel): name: Optional[str] = None category_id: Optional[int] = None base_price: Optional[float] = None is_available: Optional[bool] = None printer_zone_id: Optional[int] = None options: Optional[List[ProductOptionCreate]] = None ingredients: Optional[List[ProductIngredientCreate]] = None preference_sets: Optional[List[PreferenceSetCreate]] = None class ProductOut(ProductBase): id: int options: List[ProductOptionOut] = [] ingredients: List[ProductIngredientOut] = [] preference_sets: List[PreferenceSetOut] = [] image_url: Optional[str] = None model_config = {"from_attributes": True}