xtandardWebhooksSink
function xtandardWebhooksSink(webhooks, options?): AuditSink;Defined in: src/sinks/xtandard-webhooks.ts:80
Create a sink that publishes into an @xtandard/webhooks core.
Each item becomes one message with idempotencyKey = the event /
checkpoint id, so a re-sent batch is deduplicated by the webhooks core
(within its retention). A re-publish whose payload changed since (an event
erased under ADR 0011) is treated as already delivered — the endpoint got
the original, and the erasure is itself an audit event.
With requireKnownEventTypes, register the event types first
(audit.<action> for each action you stream, plus audit.checkpoint).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
webhooks |
WebhooksPublisher |
options? |
XtandardWebhooksSinkOptions |
Returns
Section titled “Returns”Example
Section titled “Example”import { createWebhooksCore } from "@xtandard/webhooks";import { createStreamRunner } from "@xtandard/audit";import { xtandardWebhooksSink } from "@xtandard/audit/sinks/xtandard-webhooks";
const webhooks = createWebhooksCore({ storage: webhooksStorage });
createStreamRunner(audit, { streams: [ { name: "tenant-webhooks", sink: xtandardWebhooksSink(webhooks, { // one webhooks application per audit tenant applicationKey: (tenant) => `org_${tenant}`, }), }, ],}).start();