"""
repo_core — modular Python repository framework.

Package layout
--------------
repo_core/
    base/                  All framework base classes
        repository.py      BaseRepository — wire backends together
        models.py          DomainModel base class
        schemas.py         BaseRequestSchema / BaseResponseSchema / BasePatchSchema
        validators.py      BaseValidator, ValidatorPipeline, built-in validators
    events/                Lifecycle hooks (@hook decorator)
    migrations/            Per-backend migration runners
    domains/               Domain-centric sub-packages (one folder per entity)
        article/           Article model + schemas + validators
        entity/            Entity model + schemas + validators

Framework bases (import from top-level)::

    from repo_core import (
        BaseRepository,
        DomainModel,
        BaseRequestSchema,
        BaseResponseSchema,
        BasePatchSchema,
        BaseValidator,
        ValidatorPipeline,
        ValidationError,
        RequiredValidator,
        MaxLengthValidator,
        DatabaseBackend,
        SearchBackend,
        CacheBackend,
        WarehouseBackend,
        ModelMigration,
        HookRegistry,
        hook,
    )

Domain types (import from the domain sub-package)::

    from repo_core.domains.article import Article, CreateArticleRequest, ArticleResponse
    from repo_core.domains.entity import Entity, CreateEntityRequest, EntityResponse
"""

from .base.repository import BaseRepository

from .base.models import DomainModel

from .base.schemas import BaseRequestSchema, BaseResponseSchema, BasePatchSchema

from .base.validators import (
    ValidationError,
    BaseValidator,
    ValidatorPipeline,
    RequiredValidator,
    MaxLengthValidator,
)

# Re-export db_core types for convenience
from db_core import PostgresClient, create_postgres_client, create_doris_client, QueryBuilder, QuerySet

from .migrations import (
    MigrationBuilder,
    Migration,
    MigrationRunner,
    Op,
    CreateTableOp,
    DropTableOp,
    AlterTableOp,
    discover_migrations,
)

from .events import HookRegistry, hook

__all__ = [
    # Repository
    "BaseRepository",
    # Models
    "DomainModel",
    # Schemas
    "BaseRequestSchema",
    "BaseResponseSchema",
    "BasePatchSchema",
    # Validators
    "ValidationError",
    "BaseValidator",
    "ValidatorPipeline",
    "RequiredValidator",
    "MaxLengthValidator",
    # db_core re-exports
    "PostgresClient",
    "create_postgres_client",
    "create_doris_client",
    "QueryBuilder",
    "QuerySet",
    # Migrations
    "MigrationBuilder",
    "Migration",
    "MigrationRunner",
    "Op",
    "CreateTableOp",
    "DropTableOp",
    "AlterTableOp",
    "discover_migrations",
    # Events
    "HookRegistry",
    "hook",
]
