"""Custom embedded pages model.""" from datetime import datetime, timezone from typing import Optional from sqlalchemy import Integer, String, Boolean, DateTime, Text from sqlalchemy.orm import mapped_column, Mapped from app.database import Base class CustomPage(Base): __tablename__ = "custom_pages" id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True) name: Mapped[str] = mapped_column(String(128), nullable=False) url: Mapped[str] = mapped_column(String(2048), nullable=False) icon: Mapped[str] = mapped_column(String(64), default="Link") sort_order: Mapped[int] = mapped_column(Integer, default=0) enabled: Mapped[bool] = mapped_column(Boolean, default=True) use_proxy: Mapped[bool] = mapped_column(Boolean, default=False) access_mode: Mapped[str] = mapped_column(String(32), default="direct", nullable=False) description: Mapped[Optional[str]] = mapped_column(Text, nullable=True) login_username: Mapped[Optional[str]] = mapped_column(String(255), nullable=True) login_password: Mapped[Optional[str]] = mapped_column(Text, nullable=True) login_username_selector: Mapped[Optional[str]] = mapped_column(String(512), nullable=True) login_password_selector: Mapped[Optional[str]] = mapped_column(String(512), nullable=True) login_submit_selector: Mapped[Optional[str]] = mapped_column(String(512), nullable=True) login_autofill_enabled: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) login_autofill_backfilled_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True) created_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.now(timezone.utc)) updated_at: Mapped[datetime] = mapped_column( DateTime, default=lambda: datetime.now(timezone.utc), onupdate=lambda: datetime.now(timezone.utc), )