// OUTGOING event — an event THIS app emits, declared ONCE and reaching every // audience that wants it. // // External systems subscribe at runtime via // `ctx.webhooks.subscribe({ event: 'order.completed', url })`; each subscriber // is a row in `_voltro_webhook_targets`. A publish fans out to every matching // target through a DURABLE delivery workflow — HMAC-signing the outbound // request, retrying with backoff, honouring Retry-After — and each attempt is // recorded in `_voltro_webhook_deliveries`. // // The `webhook:` block is what opts it into that. Without it this is an ordinary // declared event: connected clients and workflow triggers, no HTTP delivery. // // `key: Schema.Struct({})` is correct rather than a placeholder — a webhook // event is delivered to subscribed TARGETS, so there is nothing for a routing // key to address. Add one only if you also want browser clients to subscribe // per-something with `useEvent`. import { defineEvent } from '@voltro/protocol' import { Schema } from 'effect' export const orderCompleted = defineEvent({ name: 'order.completed', key: Schema.Struct({}), payload: Schema.Struct({ orderId: Schema.String, tenantId: Schema.String, sku: Schema.String, totalCents: Schema.Number, }), webhook: { description: 'An order moved to "fulfilled" — payment captured, items shipped.', version: 1, }, })