"""Telegram message domain — model, schemas, validators, and repository."""

from repo_core.domains.telegram.message.model import TelegramMessage
from repo_core.domains.telegram.message.schema import (
    CreateTelegramMessageRequest,
    PatchTelegramMessageRequest,
    TelegramMessageResponse,
)
from repo_core.domains.telegram.message.validator import (
    TelegramMessageTextValidator,
    TelegramPeerIdValidator,
    build_telegram_message_pipeline,
)
from repo_core.domains.telegram.message.repository import TelegramMessageRepository

__all__ = [
    "TelegramMessage",
    "CreateTelegramMessageRequest",
    "PatchTelegramMessageRequest",
    "TelegramMessageResponse",
    "TelegramMessageTextValidator",
    "TelegramPeerIdValidator",
    "build_telegram_message_pipeline",
    "TelegramMessageRepository",
]


def create_repository() -> TelegramMessageRepository:
    """Create a TelegramMessageRepository auto-wired from environment variables.

    Requires PostgreSQL + Elasticsearch env vars.

    Usage::

        repo = create_repository()
        async with repo:
            messages = await repo.search_find_messages("hello")
    """
    return TelegramMessageRepository(model=TelegramMessage)
