"""Error response helpers for gRPC service mixins.

Consolidates the 34+ duplicated `await context.abort()` patterns
into reusable helper functions. Also provides domain error handling.

This module provides:
- Abort helpers: abort_not_found, abort_invalid_argument, etc.
- UUID parse helpers: parse_*_id functions for ID validation
- Feature requirement helpers: require_feature_* for UoW capability checks
- Service requirement helpers: require_*_service for optional service checks
- Get-or-abort helpers: get_*_or_abort for fetch + not-found patterns
"""

from ._abort import (
    ERR_CANCELLED_BY_USER,
    AbortableContext,
    abort_already_exists,
    abort_database_required,
    abort_failed_precondition,
    abort_internal,
    abort_invalid_argument,
    abort_not_found,
    abort_unavailable,
    domain_error_handler,
    handle_domain_error,
)
from ._fetch import (
    ENTITY_ENTITY,
    ENTITY_INTEGRATION,
    ENTITY_MEETING,
    ENTITY_PROJECT,
    ENTITY_SYNC_RUN,
    ENTITY_WEBHOOK,
    get_meeting_or_abort,
    get_project_or_abort,
    get_webhook_or_abort,
)
from ._parse import (
    parse_entity_id,
    parse_integration_id,
    parse_meeting_id,
    parse_project_id,
    parse_webhook_id,
    parse_workspace_id,
)
from ._require import (
    FEATURE_ENTITIES,
    FEATURE_INTEGRATIONS,
    FEATURE_WEBHOOKS,
    FEATURE_WORKSPACES,
    require_feature_entities,
    require_feature_integrations,
    require_feature_projects,
    require_feature_webhooks,
    require_feature_workspaces,
    require_ner_service,
    require_project_service,
)

# Backward compatibility alias
_AbortableContext = AbortableContext

__all__ = [
    "ENTITY_ENTITY",
    "ENTITY_INTEGRATION",
    "ENTITY_MEETING",
    "ENTITY_PROJECT",
    "ENTITY_SYNC_RUN",
    "ENTITY_WEBHOOK",
    "ERR_CANCELLED_BY_USER",
    "FEATURE_ENTITIES",
    "FEATURE_INTEGRATIONS",
    "FEATURE_WEBHOOKS",
    "FEATURE_WORKSPACES",
    "AbortableContext",
    "_AbortableContext",  # Backward compatibility
    "abort_already_exists",
    "abort_database_required",
    "abort_failed_precondition",
    "abort_internal",
    "abort_invalid_argument",
    "abort_not_found",
    "abort_unavailable",
    "domain_error_handler",
    "get_meeting_or_abort",
    "get_project_or_abort",
    "get_webhook_or_abort",
    "handle_domain_error",
    "parse_entity_id",
    "parse_integration_id",
    "parse_meeting_id",
    "parse_project_id",
    "parse_webhook_id",
    "parse_workspace_id",
    "require_feature_entities",
    "require_feature_integrations",
    "require_feature_projects",
    "require_feature_webhooks",
    "require_feature_workspaces",
    "require_ner_service",
    "require_project_service",
]
