from core_db import AuditMixin, Base, EntityMixin from sqlalchemy import Integer, String, Text from sqlalchemy.orm import Mapped, mapped_column class AppInvocationAudit(EntityMixin, AuditMixin, Base): __tablename__ = "app_invocation_audit" app_id: Mapped[str] = mapped_column(String(36), index=True) api_key_prefix: Mapped[str | None] = mapped_column(String(16), nullable=True) request_id: Mapped[str] = mapped_column(String(64), index=True) session_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True) run_request_id: Mapped[str | None] = mapped_column(String(36), nullable=True) target_type: Mapped[str] = mapped_column(String(32)) target_id: Mapped[str] = mapped_column(String(36)) invoke_type: Mapped[str] = mapped_column(String(16)) status: Mapped[str] = mapped_column(String(32), index=True) duration_ms: Mapped[int] = mapped_column(Integer) error_code: Mapped[str | None] = mapped_column(String(64), nullable=True) error_message: Mapped[str | None] = mapped_column(Text, nullable=True) client_metadata_json: Mapped[str | None] = mapped_column(Text, nullable=True)