from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.orm import DeclarativeBase

from fabledassistant.config import Config

engine = create_async_engine(
    Config.DATABASE_URL,
    echo=False,
    pool_pre_ping=True,
    pool_recycle=1800,
)
async_session = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)


class Base(DeclarativeBase):
    pass


from fabledassistant.models.base import CreatedAtMixin, TimestampMixin  # noqa: E402, F401


from fabledassistant.models.note import Note, TaskPriority, TaskStatus  # noqa: E402, F401
from fabledassistant.models.conversation import Conversation, Message  # noqa: E402, F401
from fabledassistant.models.setting import Setting  # noqa: E402, F401
from fabledassistant.models.user import User  # noqa: E402, F401
from fabledassistant.models.app_log import AppLog  # noqa: E402, F401
from fabledassistant.models.password_reset import PasswordResetToken  # noqa: E402, F401
from fabledassistant.models.invitation import InvitationToken  # noqa: E402, F401
from fabledassistant.models.embedding import NoteEmbedding  # noqa: E402, F401
from fabledassistant.models.image_cache import ImageCache  # noqa: E402, F401
from fabledassistant.models.project import Project  # noqa: E402, F401
from fabledassistant.models.push_subscription import PushSubscription  # noqa: E402, F401
from fabledassistant.models.event import Event  # noqa: E402, F401
from fabledassistant.models.milestone import Milestone  # noqa: E402, F401
from fabledassistant.models.task_log import TaskLog  # noqa: E402, F401
from fabledassistant.models.note_draft import NoteDraft  # noqa: E402, F401
from fabledassistant.models.note_version import NoteVersion  # noqa: E402, F401
from fabledassistant.models.group import Group, GroupMembership  # noqa: E402, F401
from fabledassistant.models.share import NoteShare, ProjectShare  # noqa: E402, F401
from fabledassistant.models.notification import Notification  # noqa: E402, F401
from fabledassistant.models.weather_cache import WeatherCache  # noqa: E402, F401
from fabledassistant.models.api_key import ApiKey  # noqa: E402, F401
from fabledassistant.models.user_profile import UserProfile  # noqa: E402, F401
from fabledassistant.models.moment import (  # noqa: E402, F401
    Moment,
    MomentEmbedding,
    moment_people,
    moment_places,
    moment_tasks,
    moment_notes,
)
from fabledassistant.models.generation_tool_log import GenerationToolLog  # noqa: E402, F401
