from .types import AsyncSendFn, ProviderSpec, SendFn

PROVIDERS: dict[str, "ProviderSpec"] = {}


def register_provider(
    name: str,
    *,
    send: SendFn,
    async_send: AsyncSendFn | None = None,
    string_key: str | None = None,
) -> None:
    if name in PROVIDERS:
        raise ValueError(f"Provider '{name}' already registered.")

    PROVIDERS[name] = ProviderSpec(
        name=name,
        send=send,
        async_send=async_send,
        string_key=string_key,
    )
