Created At: 2026-11-18T07:45:28Z Completed At: 2026-11-18T07:45:28Z Command exited with code 0. Command output: ==> /root/telegram-saas/modules/audit/service.py <== from typing import Any, Optional from uuid import UUID from sqlalchemy.ext.asyncio import AsyncSession from modules.audit.models import AuditLog class AuditService: def __init__(self, db: AsyncSession): self.db = db async def log_action( self, action: str, resource: str, tenant_id: Optional[UUID] = None, user_id: Optional[UUID] = None, ip_address: Optional[str] = None, details: Optional[dict[str, Any]] = None, ) -> AuditLog: log_entry = AuditLog( tenant_id=tenant_id, user_id=user_id, action=action, resource=resource, ip_address=ip_address, details=details or {}, ) self.db.add(log_entry) await self.db.flush() return log_entry ==> /root/telegram-saas/modules/audit/models.py <== import uuid from sqlalchemy import ForeignKey, Index, String, Text from sqlalchemy.dialects.postgresql import UUID, JSONB from sqlalchemy.orm import Mapped, mapped_column from infrastructure.database.base import Base, UUIDPrimaryKeyMixin, TimestampMixin class AuditLog(Base, UUIDPrimaryKeyMixin, TimestampMixin): __tablename__ = "audit_logs" tenant_id: Mapped[uuid.UUID | None] = mapped_column( UUID(as_uuid=True), ForeignKey("tenants.id", ondelete="SET NULL"), nullable=True, index=True, ) user_id: Mapped[uuid.UUID | None] = mapped_column( UUID(as_uuid=True), ForeignKey("users.id", ondelete="SET NULL"), nullable=True, index=True, ) action: Mapped[str] = mapped_column(String(100), nullable=False, index=True) resource: Mapped[str] = mapped_column(String(100), nullable=False) ip_address: Mapped[str | None] = mapped_column(String(45), nullable=True) details: Mapped[dict | None] = mapped_column(JSONB, nullable=True)