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

from scribe.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 scribe.models.base import CreatedAtMixin, TimestampMixin  # noqa: E402, F401


from scribe.models.note import Note, TaskPriority, TaskStatus  # noqa: E402, F401
from scribe.models.setting import Setting  # noqa: E402, F401
from scribe.models.user import User  # noqa: E402, F401
from scribe.models.app_log import AppLog  # noqa: E402, F401
from scribe.models.password_reset import PasswordResetToken  # noqa: E402, F401
from scribe.models.invitation import InvitationToken  # noqa: E402, F401
from scribe.models.embedding import NoteEmbedding  # noqa: E402, F401
from scribe.models.retrieval_log import RetrievalLog  # noqa: E402, F401
from scribe.models.note_usage import NoteUsageEvent  # noqa: E402, F401
from scribe.models.project import Project  # noqa: E402, F401
from scribe.models.milestone import Milestone  # noqa: E402, F401
from scribe.models.task_log import TaskLog  # noqa: E402, F401
from scribe.models.note_draft import NoteDraft  # noqa: E402, F401
from scribe.models.note_version import NoteVersion  # noqa: E402, F401
from scribe.models.note_supersession import NoteSupersession  # noqa: E402, F401
from scribe.models.group import Group, GroupMembership  # noqa: E402, F401
from scribe.models.share import NoteShare, ProjectShare  # noqa: E402, F401
from scribe.models.notification import Notification  # noqa: E402, F401
from scribe.models.api_key import ApiKey  # noqa: E402, F401
from scribe.models.user_profile import UserProfile  # noqa: E402, F401
from scribe.models.rulebook import (  # noqa: E402, F401
    Rulebook, RulebookTopic, Rule, project_rulebook_subscriptions,
)
from scribe.models.repo_binding import RepoBinding  # noqa: E402, F401
from scribe.models.forge_connection import ForgeConnection  # noqa: E402, F401
from scribe.models.code_shape import CodeShape, CodeShapeEvent, CodeShapeUse  # noqa: E402, F401
from scribe.models.system import System, RecordSystem  # noqa: E402, F401
from scribe.models.design_system import DesignSystem, DesignToken  # noqa: E402, F401
