AshHooks (AshHooks v0.2.2)

Copy Markdown View Source

Webhooks for Ash Framework — inbound (receive, verify, dedup → domain events) and outbound (sign, deliver, retry, track).

Attach to a resource:

use Ash.Resource,
  extensions: [AshHooks]

webhooks do
  # convention-resolves to AshHooks.Provider.ComplyCube
  inbound :comply_cube do
    secret {:app_env, [:my_app, :complycube_secret]}
    # optional: extract a stable event id (payload -> {:ok, id} | :error);
    # without it a deterministic content-hash identity is used
  end

  # convention-resolves to AshHooks.Provider.HubSpotV3 — the
  # vendor-default 300s replay window applies; override it either way
  inbound :hub_spot_v3 do
    secret {:app_env, [:my_app, :hubspot_client_secret]}
  end

  outbound :order_paid do
    signing_mode :dual
  end
end

Both halves are independently consumable: inbound-only consumers pull no queue infrastructure (ADR-0004).

Summary

Functions

Fans an outbound event out to its subscribed endpoints — the outbound entry point, delegating to AshHooks.Dispatcher.dispatch/4 (the AshHooks.Ingress.ingest/4 twin).

Schema validator for the secret option — accepts only secret SOURCES, rejecting a literal binary at DSL parse time (ADR-0005).

Functions

dispatch(resource, name, event, opts \\ [])

Fans an outbound event out to its subscribed endpoints — the outbound entry point, delegating to AshHooks.Dispatcher.dispatch/4 (the AshHooks.Ingress.ingest/4 twin).

validate_secret_source(source)

@spec validate_secret_source(term()) :: {:ok, term()} | {:error, String.t()}

Schema validator for the secret option — accepts only secret SOURCES, rejecting a literal binary at DSL parse time (ADR-0005).

webhooks(body)

(macro)