"""Public surface of ``infrasynth.webhooks``. The exports are resolved lazily (PEP 562) so importing this package never triggers Django model imports before the app registry is ready. Import from here:: from infrasynth.webhooks import EventRegistry, sign_payload, BaseInboundHandler """ from __future__ import annotations from importlib import import_module from typing import Any __all__ = [ "BaseInboundHandler", "EventRegistry", "HMACInboundHandler", "InboundEndpoint", "InboundEvent", "OutboundDelivery", "OutboundEndpoint", "OutboundSubscription", "deliver_webhook", "process_inbound_event", "sign_payload", "verify_signature", ] # public name -> module (relative to the ``infrasynth`` package) that defines it _EXPORTS: dict[str, str] = { "BaseInboundHandler": "webhooks.inbound.handlers", "EventRegistry": "webhooks.registry", "HMACInboundHandler": "webhooks.inbound.handlers", "InboundEndpoint": "webhooks.models", "InboundEvent": "webhooks.models", "OutboundDelivery": "webhooks.models", "OutboundEndpoint": "webhooks.models", "OutboundSubscription": "webhooks.models", "deliver_webhook": "webhooks.dispatch", "process_inbound_event": "webhooks.dispatch", "sign_payload": "webhooks.signature", "verify_signature": "webhooks.signature", } def __getattr__(name: str) -> Any: module_path = _EXPORTS.get(name) if module_path is not None: return getattr(import_module(f"infrasynth.{module_path}"), name) # Let ``infrasynth..`` resolve as usual. try: return import_module(f"{__name__}.{name}") except ModuleNotFoundError as exc: raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from exc def __dir__() -> list[str]: return sorted(set(__all__) | set(globals()))