"""Asset schemas (CRUD)."""

from datetime import datetime
from typing import List, Optional

from pydantic import BaseModel, Field


class AssetUpdate(BaseModel):
    """Request to update asset metadata."""

    name: Optional[str] = Field(None, min_length=1, max_length=100, description="Display name")
    description: Optional[str] = Field(None, max_length=500, description="Optional description")
    tags: Optional[List[str]] = Field(None, description="User-defined tags")


class AssetResponse(BaseModel):
    """Asset response."""

    id: str = Field(description="Asset ID")
    name: str = Field(description="Display name")
    filename: str = Field(description="Original upload filename")
    mime_type: str = Field(description="MIME type")
    asset_type: str = Field(description="Asset type: sound, image, video, other")
    size_bytes: int = Field(description="File size in bytes")
    description: Optional[str] = Field(None, description="Description")
    tags: List[str] = Field(default_factory=list, description="User-defined tags")
    prebuilt: bool = Field(False, description="Whether this is a shipped prebuilt asset")
    created_at: datetime = Field(description="Creation timestamp")
    updated_at: datetime = Field(description="Last update timestamp")


class AssetListResponse(BaseModel):
    """List of assets."""

    assets: List[AssetResponse] = Field(description="List of assets")
    count: int = Field(description="Number of assets")
