// Event → workflow trigger. Auto-discovered (`*.trigger.tsx`); no // app.config wiring needed. // // When any handler publishes `order.placed` (the `orders.place` mutation does, // on commit), this trigger starts the `orders.fulfill` workflow. It binds the // DECLARED event rather than its name, so renaming the event moves this file // with it instead of silently matching nothing. The event payload IS the workflow payload here (both are // `{ orderId, tenantId }`), so no `payload` mapper is needed — pass one // when the shapes differ. // // `idempotencyKey` dedups deliveries: if the same event is re-delivered // (crash + replay), the matching key short-circuits the second start. import { defineEventTrigger } from '@voltro/runtime' import { orderPlaced } from '../events/orders.event' export default defineEventTrigger< { orderId: string; tenantId: string } >({ on: orderPlaced, workflow: 'orders.fulfill', idempotencyKey: (event) => `order.placed:${event.data.orderId}`, })