from typing import Generic, TypeVar, List, Optional
from pydantic import BaseModel, ConfigDict

class ProductTemplateRead(BaseModel):
    """
    Response schema for returning product template metadata.

    Fields include:
    - Basic info (id, name, user, paths)
    - PSD preview PNG
    - Safe-zone metadata for design placement
    - Aspect ratio of full PSD (e.g., "5:3")
    - Extracted design layer metadata JSON
    - Timestamps
    """

    id: int
    name: str
    preview_png_path: Optional[str]
    ratio: Optional[str] = None

    model_config = ConfigDict(
        from_attributes=True,
        extra="ignore",
        populate_by_name=True
    )

class ProductTemplateListResponse(BaseModel):
    total: int
    page: int
    page_size: int
    items: List[ProductTemplateRead]

    model_config = ConfigDict(from_attributes=True, extra="ignore")