import uuid from datetime import datetime, timezone from sqlalchemy import String, Text, DateTime from sqlalchemy.orm import Mapped, mapped_column from sqlalchemy.dialects.postgresql import UUID, ARRAY, JSONB from ..database import Base class TranslatedArticleEntity(Base): __tablename__ = "translated_articles" id: Mapped[uuid.UUID] = mapped_column( UUID(as_uuid=True), primary_key=True, default=uuid.uuid4 ) published_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), default=lambda: datetime.now(timezone.utc), ) source_language: Mapped[str] = mapped_column(String(10), nullable=False) target_language: Mapped[str] = mapped_column(String(10), nullable=False) target_complexities: Mapped[list[str]] = mapped_column(ARRAY(String(5)), nullable=False) # Content fields — nullable, filled in step-by-step during generation source_title: Mapped[str | None] = mapped_column(Text, nullable=True) source_body: Mapped[str | None] = mapped_column(Text, nullable=True) source_body_pos: Mapped[dict | None] = mapped_column(JSONB, nullable=True) target_title: Mapped[str | None] = mapped_column(Text, nullable=True) target_body: Mapped[str | None] = mapped_column(Text, nullable=True) audio_url: Mapped[str | None] = mapped_column(Text, nullable=True) target_body_pos: Mapped[dict | None] = mapped_column(JSONB, nullable=True) target_body_transcript: Mapped[dict | None] = mapped_column(JSONB, nullable=True)