"""Public interface for the CHORM package."""

__version__ = "0.2.1"

from chorm.async_engine import AsyncConnection, AsyncEngine, create_async_engine
from chorm.async_pool import AsyncConnectionPool
from chorm.async_session import AsyncSession
from chorm.batch import (
    BatchInsert,
    BatchUpdate,
    BatchDelete,
    batch_insert,
    batch_update,
    batch_delete,
)
from chorm.batch_optimized import (
    ClickHouseBatchInsert,
    ClickHouseBatchInsertFromDataFrame,
    bulk_insert,
    DEFAULT_BATCH_SIZE,
    RECOMMENDED_MIN_BATCH,
)
from chorm.declarative import Column, DeclarativeError, Table
from chorm.ddl import format_ddl
from chorm.engine import Connection, Engine, EngineConfig, create_engine
from chorm.metadata import MetaData
from chorm.health import AsyncHealthCheck, HealthCheck
from chorm.profiler import QueryAnalyzer, QueryComplexity
from chorm.metrics import (
    MetricsCollector,
    QueryMetrics,
    enable_global_metrics,
    disable_global_metrics,
    get_global_collector,
)
from chorm.pool import ConnectionPool
from chorm.query_cache import (
    QueryCache,
    CachedQuery,
    enable_global_cache,
    disable_global_cache,
    get_global_cache,
)
from chorm.codecs import (
    Codec,
    ZSTD,
    LZ4,
    LZ4HC,
    Delta,
    DoubleDelta,
    Gorilla,
    T64,
    FPC,
)
from chorm.query_settings import (
    QuerySettings,
    ExecutionStats,
    QueryOptimizer,
    get_preset,
    SETTINGS_PRESETS,
)
from chorm.result import Result
from chorm.retry import RetryConfig, async_with_retry, with_retry
from chorm.session import Session
from chorm.sql import (
    delete,
    func,
    insert,
    select,
    text,
    update,
    cte,
    window,
    drop_table,
    truncate_table,
    rename_table,
    add_column,
    drop_column,
    modify_column,
    rename_column,
    add_index,
    drop_index,
    modify_ttl,
    detach_partition,
    attach_partition,
    drop_partition,
    fetch_partition,
    create_materialized_view,
    optimize_table,
    create_dictionary,
    Explain,
)
from chorm.exceptions import (
    CHORMError,
    DatabaseError,
    DatabaseSyntaxError,
    DatabaseConnectionError,
    DatabaseAuthenticationError,
    DatabaseStorageError,
    DatabaseMemoryError,
    QueryError,
    InvalidQueryError,
    QueryValidationError,
    ResultError,
    NoResultFound,
    MultipleResultsFound,
    TypeConversionError,
    ValidationError,
    ConfigurationError,
    # Backward compatibility
    EngineConfigurationError,
    ConversionError,
)
from chorm.validators import (
    Validator,
    RangeValidator,
    LengthValidator,
    RegexValidator,
    EmailValidator,
    InValidator,
    NotInValidator,
    CustomValidator,
    validate_value,
)
from chorm.table_engines import (
    ENGINE_CLASSES,
    MergeTree,
    ReplacingMergeTree,
    SummingMergeTree,
    AggregatingMergeTree,
    CollapsingMergeTree,
    VersionedCollapsingMergeTree,
    GraphiteMergeTree,
    ReplicatedMergeTree,
    ReplicatedReplacingMergeTree,
    ReplicatedSummingMergeTree,
    ReplicatedAggregatingMergeTree,
    ReplicatedCollapsingMergeTree,
    ReplicatedVersionedCollapsingMergeTree,
    ReplicatedGraphiteMergeTree,
    Log,
    TinyLog,
    StripeLog,
    Memory,
    File,
    Null,
    Set,
    Join,
    View,
    Distributed,
    Kafka,
    MySQL,
    PostgreSQL,
    ODBC,
    JDBC,
    MaterializedView,
)

__all__ = [
    "__version__",
    "BatchInsert",
    "BatchUpdate",
    "BatchDelete",
    "batch_insert",
    "batch_update",
    "batch_delete",
    "ClickHouseBatchInsert",
    "ClickHouseBatchInsertFromDataFrame",
    "bulk_insert",
    "DEFAULT_BATCH_SIZE",
    "RECOMMENDED_MIN_BATCH",
    "CachedQuery",
    "Connection",
    "ConnectionPool",
    "Engine",
    "EngineConfig",
    "create_engine",
    "MetaData",
    "HealthCheck",
    "MetricsCollector",
    "QueryAnalyzer",
    "QueryCache",
    "QueryComplexity",
    "QueryMetrics",
    "QuerySettings",
    "QueryOptimizer",
    "ExecutionStats",
    "get_preset",
    "SETTINGS_PRESETS",
    "enable_global_cache",
    "disable_global_cache",
    "get_global_cache",
    "enable_global_metrics",
    "disable_global_metrics",
    "get_global_collector",
    "Result",
    "RetryConfig",
    "Session",
    "with_retry",
    "async_with_retry",
    "delete",
    "func",
    "insert",
    "select",
    "text",
    "update",
    "cte",
    "window",
    # DDL operations
    "drop_table",
    "truncate_table",
    "rename_table",
    "add_column",
    "drop_column",
    "modify_column",
    "rename_column",
    "add_index",
    "drop_index",
    "modify_ttl",
    "detach_partition",
    "attach_partition",
    "drop_partition",
    "fetch_partition",
    "create_materialized_view",
    "optimize_table",
    "create_dictionary",
    "Explain",
    "AsyncConnection",
    "AsyncConnectionPool",
    "AsyncEngine",
    "AsyncHealthCheck",
    "AsyncSession",
    "create_async_engine",
    "Column",
    "DeclarativeError",
    "Table",
    "format_ddl",
    # Exceptions
    "CHORMError",
    "DatabaseError",
    "DatabaseSyntaxError",
    "DatabaseConnectionError",
    "DatabaseAuthenticationError",
    "DatabaseStorageError",
    "DatabaseMemoryError",
    "QueryError",
    "InvalidQueryError",
    "QueryValidationError",
    "ResultError",
    "NoResultFound",
    "MultipleResultsFound",
    "TypeConversionError",
    "ValidationError",
    "ConfigurationError",
    "EngineConfigurationError",
    "ConversionError",
    # Validators
    "Validator",
    "RangeValidator",
    "LengthValidator",
    "RegexValidator",
    "EmailValidator",
    "InValidator",
    "NotInValidator",
    "CustomValidator",
    "validate_value",
    # Table engines
    "ENGINE_CLASSES",
    "MergeTree",
    "ReplacingMergeTree",
    "SummingMergeTree",
    "AggregatingMergeTree",
    "CollapsingMergeTree",
    "VersionedCollapsingMergeTree",
    "GraphiteMergeTree",
    "ReplicatedMergeTree",
    "ReplicatedReplacingMergeTree",
    "ReplicatedSummingMergeTree",
    "ReplicatedAggregatingMergeTree",
    "ReplicatedCollapsingMergeTree",
    "ReplicatedVersionedCollapsingMergeTree",
    "ReplicatedGraphiteMergeTree",
    "Log",
    "TinyLog",
    "StripeLog",
    "Memory",
    "File",
    "Null",
    "Set",
    "Join",
    "View",
    "Distributed",
    "Kafka",
    "MySQL",
    "PostgreSQL",
    "ODBC",
    "JDBC",
    "MaterializedView",
    # Codecs
    "Codec",
    "ZSTD",
    "LZ4",
    "LZ4HC",
    "Delta",
    "DoubleDelta",
    "Gorilla",
    "T64",
    "FPC",
]
