{"version":3,"file":"herald-queue.mjs","names":[],"sources":["../../../../../../../notifications/src/queue/herald-queue.ts"],"sourcesContent":["/**\n * Herald-backed `QueueDispatcher` — the production backend for `.queue()`.\n *\n * `defineNotification` renders payloads + resolves routes BEFORE handing a job\n * to the dispatcher, so the job is fully serializable (`{ channel, route,\n * payload, options }`) — no model re-hydration or closure serialization. This\n * dispatcher just publishes the job onto a herald channel; the worker\n * (`startNotificationsWorker`) consumes it and runs `channel.send`.\n *\n * Connection is the app's job — the `@warlock.js/herald` connector connects the\n * broker from `config/herald.ts` at boot; this dispatcher only calls `herald()`.\n *\n * @example  src/config/notifications.ts — declarative; the connector registers it\n *   import { type NotificationConfig, heraldQueue, inApp, mailChannel } from \"@warlock.js/notifications\";\n *\n *   const config: NotificationConfig = {\n *     channels: { mail: mailChannel(), database: inApp.configure({ model: Notification }) },\n *     queue: heraldQueue(),                 // → `.queue()` now works\n *   };\n *\n *   export default config;\n */\nimport type { QueueDispatcher } from \"../contracts\";\nimport { DEFAULT_QUEUE_CHANNEL, loadHerald } from \"./load-herald\";\n\nexport type HeraldQueueOptions = {\n  /** Herald channel to publish jobs to. Default `\"notifications.dispatch\"`. */\n  channel?: string;\n  /** Herald broker name (multi-broker setups). Default broker if omitted. */\n  broker?: string;\n};\n\nexport function heraldQueue(options: HeraldQueueOptions = {}): QueueDispatcher {\n  const channelName = options.channel ?? DEFAULT_QUEUE_CHANNEL;\n\n  return {\n    async dispatch(job) {\n      const { herald } = await loadHerald();\n      await herald(options.broker).channel(channelName).publish(job);\n    },\n  };\n}\n"],"mappings":";;;AAgCA,SAAgB,YAAY,UAA8B,CAAC,GAAoB;CAC7E,MAAM,cAAc,QAAQ;CAE5B,OAAO,EACL,MAAM,SAAS,KAAK;EAClB,MAAM,EAAE,WAAW,MAAM,WAAW;EACpC,MAAM,OAAO,QAAQ,MAAM,CAAC,CAAC,QAAQ,WAAW,CAAC,CAAC,QAAQ,GAAG;CAC/D,EACF;AACF"}