"""proxy domain — model, schemas, validators, and repository."""

from repo_core.domains.proxy.model import Proxy, ProxyLease, AccountType, LeaseMode
from repo_core.domains.proxy.schema import (
    CreateProxyRequest,
    ProxyResponse,
    ProxyListResponse,
    PatchProxyRequest,
    CreateLeaseRequest,
    LeaseResponse,
    LeaseListResponse,
    PatchLeaseRequest,
)
from repo_core.domains.proxy.validator import (
    ProxyAddressValidator,
    ProxyPortValidator,
    build_proxy_pipeline,
)
from repo_core.domains.proxy.repository import ProxyRepository
from repo_core.domains.proxy.lease_repository import ProxyLeaseRepository


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

    Requires PostgreSQL env vars (DATABASE_URL, or PG_HOST/PG_PORT/PG_DATABASE).

    Usage::

        repo = create_repository()
        async with repo:
            proxies, total = await repo.list_all(20, 0)
    """
    return ProxyRepository(model=Proxy)


__all__ = [
    # Models
    "Proxy",
    "ProxyLease",
    "AccountType",
    "LeaseMode",
    # Proxy schemas
    "CreateProxyRequest",
    "ProxyResponse",
    "ProxyListResponse",
    "PatchProxyRequest",
    # Lease schemas
    "CreateLeaseRequest",
    "LeaseResponse",
    "LeaseListResponse",
    "PatchLeaseRequest",
    # Validators
    "ProxyAddressValidator",
    "ProxyPortValidator",
    "build_proxy_pipeline",
    # Repositories
    "ProxyRepository",
    "ProxyLeaseRepository",
    # Factory
    "create_repository",
]
