from sqlalchemy import Boolean, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column

from app.models.base import Base, TimestampMixin


class ImageEngine(Base, TimestampMixin):
    __tablename__ = "image_engines"

    id: Mapped[str] = mapped_column(String(32), primary_key=True)
    name: Mapped[str] = mapped_column(String(64), nullable=False)
    provider: Mapped[str] = mapped_column(String(32), nullable=False)
    api_base: Mapped[str] = mapped_column(String(512), nullable=False)
    api_key: Mapped[str] = mapped_column(String(256), default="")
    model_name: Mapped[str] = mapped_column(String(128), default="")
    supported_models: Mapped[str] = mapped_column(Text, default='["doubao-seedream-5-0-260128"]')
    # {"2K":{"1:1":"2048×2048",...}, "4K":{"1:1":"4096×4096",...}}
    supported_sizes: Mapped[str] = mapped_column(Text, default='{}')
    default_size: Mapped[str] = mapped_column(String(32), default="2K")
    generate_url: Mapped[str | None] = mapped_column(String(512), nullable=True, default="")
    is_active: Mapped[bool] = mapped_column(Boolean, default=True)
    priority: Mapped[int] = mapped_column(Integer, default=0)
