"""
Route registration for the Semantic Models API.

All API blueprints are registered here.
"""

from flask import Flask

from semantic_models.routes import autogen, config, dss_resources, glossary, indexing, playground, semantic_models
from semantic_models.routes.common import handle_error


def register_all_routes(app: Flask) -> None:
    """
    Register all route blueprints and error handlers with the Flask app.

    Blueprints are organized by domain:
    - config: App configuration endpoint
    - semantic_models: Semantic Model CRUD, versions, drafts, golden queries
    - playground: Query generation and execution (uses agentic pipeline)
    - dss_resources: DSS resource discovery (datasets, LLMs)
    - indexing: DSS distinct-values indexing actions
    - autogen: LLM-based auto-generation of entities from datasets
    - glossary: Glossary extraction and mapping
    """
    # Register global error handler
    app.register_error_handler(Exception, handle_error)

    # Register all blueprints
    app.register_blueprint(config.bp)
    app.register_blueprint(semantic_models.bp)
    app.register_blueprint(playground.bp)
    app.register_blueprint(dss_resources.bp)
    app.register_blueprint(indexing.bp)
    app.register_blueprint(autogen.bp)
    app.register_blueprint(glossary.bp)
