"""Platform capability contracts — interfaces only; no implementations in Delivery."""
from __future__ import annotations

from typing import Any, Protocol
from uuid import UUID


class AccountingProvider(Protocol):
    """Contract for Accounting. Delivery must not post journals."""

    async def create_settlement_ref(
        self, *, tenant_id: UUID, reference: str, payload: dict[str, Any]
    ) -> dict[str, Any]: ...


class CRMProvider(Protocol):
    """Contract for CRM. Delivery stores external contact refs only."""

    async def resolve_contact(
        self, *, tenant_id: UUID, contact_ref: str
    ) -> dict[str, Any]: ...


class LoyaltyProvider(Protocol):
    """Contract for Loyalty. Delivery must not own points/ledger."""

    async def resolve_member(
        self, *, tenant_id: UUID, member_ref: str
    ) -> dict[str, Any]: ...


class CommunicationProvider(Protocol):
    """Contract for Communication Platform. Delivery must not own SMS providers."""

    async def send(
        self,
        *,
        tenant_id: UUID,
        channel: str,
        template_key: str,
        to: str,
        payload: dict[str, Any],
    ) -> None: ...


class NotificationProvider(Protocol):
    """Contract for Notification fanout. Delivery must not own message delivery."""

    async def notify(
        self,
        *,
        tenant_id: UUID,
        channel: str,
        template_key: str,
        payload: dict[str, Any],
    ) -> None: ...


class StorageProvider(Protocol):
    """Contract for File Storage. Delivery stores file refs only (e.g. POD)."""

    async def resolve_file(
        self, *, tenant_id: UUID, file_ref: str
    ) -> dict[str, Any]: ...


class AIProvider(Protocol):
    """Contract for AI Platform. Delivery must not own model inference."""

    async def suggest(
        self, *, tenant_id: UUID, task: str, context: dict[str, Any]
    ) -> dict[str, Any]: ...


class IdentityProvider(Protocol):
    """Contract for Identity. Delivery stores external_user_ref only."""

    async def resolve_user(
        self, *, tenant_id: UUID, user_ref: str
    ) -> dict[str, Any]: ...


class RoutingEngineProvider(Protocol):
    """Contract for pluggable routing engines — adapters live in Delivery."""

    async def plan_route(
        self, *, tenant_id: UUID, request: dict[str, Any]
    ) -> dict[str, Any]: ...


class FleetProvider(Protocol):
    """Contract for external fleet/courier providers — adapters live in Delivery."""

    async def request_fulfillment(
        self, *, tenant_id: UUID, request: dict[str, Any]
    ) -> dict[str, Any]: ...
