@warlock.js/herald 5.29.0 → 5.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +15 -2
  2. package/README.md +17 -16
  3. package/cjs/index.cjs +10 -10
  4. package/cjs/index.cjs.map +1 -1
  5. package/esm/communicators/broker-registry.d.mts +1 -1
  6. package/esm/communicators/broker-registry.d.mts.map +1 -1
  7. package/esm/communicators/broker-registry.mjs +1 -1
  8. package/esm/communicators/broker-registry.mjs.map +1 -1
  9. package/esm/communicators/broker.d.mts +1 -1
  10. package/esm/communicators/broker.d.mts.map +1 -1
  11. package/esm/communicators/broker.mjs +1 -1
  12. package/esm/communicators/broker.mjs.map +1 -1
  13. package/esm/contracts/broker-driver.contract.d.mts +1 -1
  14. package/esm/contracts/broker-driver.contract.d.mts.map +1 -1
  15. package/esm/contracts/channel.contract.d.mts +1 -1
  16. package/esm/contracts/channel.contract.d.mts.map +1 -1
  17. package/esm/decorators/consumable.d.mts +1 -1
  18. package/esm/decorators/consumable.d.mts.map +1 -1
  19. package/esm/decorators/consumable.mjs +1 -1
  20. package/esm/decorators/consumable.mjs.map +1 -1
  21. package/esm/drivers/rabbitmq/rabbitmq-channel.d.mts +1 -1
  22. package/esm/drivers/rabbitmq/rabbitmq-channel.d.mts.map +1 -1
  23. package/esm/drivers/rabbitmq/rabbitmq-channel.mjs +1 -1
  24. package/esm/drivers/rabbitmq/rabbitmq-channel.mjs.map +1 -1
  25. package/esm/drivers/rabbitmq/rabbitmq-driver.d.mts +1 -1
  26. package/esm/drivers/rabbitmq/rabbitmq-driver.d.mts.map +1 -1
  27. package/esm/drivers/rabbitmq/rabbitmq-driver.mjs +1 -1
  28. package/esm/drivers/rabbitmq/rabbitmq-driver.mjs.map +1 -1
  29. package/esm/message-managers/event-consumer.d.mts +1 -1
  30. package/esm/message-managers/event-consumer.d.mts.map +1 -1
  31. package/esm/message-managers/event-consumer.mjs +1 -1
  32. package/esm/message-managers/event-consumer.mjs.map +1 -1
  33. package/esm/message-managers/event-message.d.mts +1 -1
  34. package/esm/message-managers/event-message.d.mts.map +1 -1
  35. package/esm/message-managers/event-message.mjs +1 -1
  36. package/esm/message-managers/event-message.mjs.map +1 -1
  37. package/esm/message-managers/prepare-consumer-subscription.mjs +1 -1
  38. package/esm/message-managers/prepare-consumer-subscription.mjs.map +1 -1
  39. package/esm/message-managers/types.d.mts +1 -1
  40. package/esm/message-managers/types.d.mts.map +1 -1
  41. package/esm/types/channel.types.d.mts +2 -2
  42. package/esm/types/channel.types.d.mts.map +1 -1
  43. package/esm/types/connection.types.d.mts +1 -1
  44. package/esm/types/connection.types.d.mts.map +1 -1
  45. package/esm/types/driver.types.d.mts +1 -1
  46. package/esm/types/driver.types.d.mts.map +1 -1
  47. package/esm/types/message.types.d.mts +1 -1
  48. package/esm/types/message.types.d.mts.map +1 -1
  49. package/esm/types/publish.types.d.mts +1 -1
  50. package/esm/types/publish.types.d.mts.map +1 -1
  51. package/esm/types/registry.types.d.mts +1 -1
  52. package/esm/types/registry.types.d.mts.map +1 -1
  53. package/esm/types/subscribe.types.d.mts +1 -1
  54. package/esm/types/subscribe.types.d.mts.map +1 -1
  55. package/esm/use-case-broadcast.d.mts +1 -1
  56. package/esm/use-case-broadcast.d.mts.map +1 -1
  57. package/esm/use-case-broadcast.mjs +1 -1
  58. package/esm/use-case-broadcast.mjs.map +1 -1
  59. package/esm/utils/connect-to-broker.d.mts +1 -1
  60. package/esm/utils/connect-to-broker.d.mts.map +1 -1
  61. package/esm/utils/connect-to-broker.mjs +1 -1
  62. package/esm/utils/connect-to-broker.mjs.map +1 -1
  63. package/llms-full.txt +62 -57
  64. package/package.json +5 -4
  65. package/skills/consume-message/SKILL.md +30 -28
  66. package/skills/herald-basics/SKILL.md +8 -8
  67. package/skills/index.md +4 -1
  68. package/skills/publish-message/SKILL.md +19 -16
  69. package/skills/request-and-respond/SKILL.md +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"channel.types.d.mts","names":[],"sources":["../../../../../../../herald/src/types/channel.types.ts"],"mappings":";;;;KAGY,cAAA;EACV,IAAA;EACA,OAAA;EACA,UAAA;EACA,SAAA;EACA,UAAA,GAAa,iBAAA;EACb,cAAA;EACA,UAAA;EACA,SAAA;EACA,MAAA,GAAS,aAAa;AAAA;AAAA,KAGZ,YAAA;EACV,YAAA;EACA,aAAA;EACA,IAAA;AAAA"}
1
+ {"version":3,"file":"channel.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/channel.types.ts"],"mappings":";;;;KAGY,cAAA;EACV,IAAA;EACA,OAAA;EACA,UAAA;EACA,SAAA;EACA,UAAA,GAAa,iBAAA;EACb,cAAA;EACA,UAAA;EACA,SAAA;EACA,MAAA,GAAS,aAAa;AAAA;AAAA,KAGZ,YAAA;EACV,YAAA;EACA,aAAA;EACA,IAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../herald/src/types/connection.types.d.ts
1
+ //#region ../../packages/herald/src/types/connection.types.d.ts
2
2
  type BaseConnectionOptions = {
3
3
  name?: string;
4
4
  isDefault?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"connection.types.d.mts","names":[],"sources":["../../../../../../../herald/src/types/connection.types.ts"],"mappings":";KAAY,qBAAA;EACV,IAAA;EACA,SAAS;AAAA;AAAA,KAGC,qBAAA;EACV,SAAA;EACA,OAAA;EACA,OAAA;EACA,EAAA,YAAc,MAAA,GAAS,KAAA,UAAe,MAAA;EACtC,IAAA,YAAgB,MAAA;EAChB,GAAA,YAAe,MAAA;EACf,UAAA;EACA,UAAA;EACA,kBAAA;AAAA;AAAA,KAGU,qBAAA;EACV,QAAA;EACA,UAAA;EACA,MAAA;EACA,MAAA,GAAS,qBAAqB;AAAA;AAAA,KAGpB,yBAAA,wBACa,qBAAA,GAAwB,qBAAA,IAC7C,qBAAA;EACF,MAAA;EACA,IAAA;EACA,IAAA;EACA,QAAA;EACA,QAAA;EACA,KAAA;EACA,GAAA;EACA,SAAA;EACA,iBAAA;EACA,SAAA;EACA,cAAA;EACA,QAAA;EACA,aAAA,GAAgB,cAAA;AAAA;AAAA,KAGN,kBAAA;EACV,KAAA;IACE,gBAAA;IACA,OAAA;IACA,YAAA;IACA,MAAA;IACA,UAAA;EAAA;EAEF,QAAA;EACA,UAAA;AAAA;AAAA,KAGU,sBAAA,wBAA8C,kBAAA,GAAqB,kBAAA,IAC7E,qBAAA;EACE,MAAA;EACA,OAAA;EACA,QAAA;EACA,iBAAA;EACA,cAAA;EACA,GAAA;EACA,IAAA;IACE,SAAA;IACA,QAAA;IACA,QAAA;EAAA;EAEF,aAAA,GAAgB,cAAA;AAAA;AAAA,KAGR,iBAAA,GAAoB,yBAAA,GAA4B,sBAAsB;AAAA,KAEtE,oBAAA,yBACR,yBAAA,CACE,cAAA,SAAuB,qBAAA,GAAwB,cAAA,GAAiB,qBAAA,IAElE,sBAAA,CACE,cAAA,SAAuB,kBAAA,GAAqB,cAAA,GAAiB,kBAAA"}
1
+ {"version":3,"file":"connection.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/connection.types.ts"],"mappings":";KAAY,qBAAA;EACV,IAAA;EACA,SAAS;AAAA;AAAA,KAGC,qBAAA;EACV,SAAA;EACA,OAAA;EACA,OAAA;EACA,EAAA,YAAc,MAAA,GAAS,KAAA,UAAe,MAAA;EACtC,IAAA,YAAgB,MAAA;EAChB,GAAA,YAAe,MAAA;EACf,UAAA;EACA,UAAA;EACA,kBAAA;AAAA;AAAA,KAGU,qBAAA;EACV,QAAA;EACA,UAAA;EACA,MAAA;EACA,MAAA,GAAS,qBAAqB;AAAA;AAAA,KAGpB,yBAAA,wBACa,qBAAA,GAAwB,qBAAA,IAC7C,qBAAA;EACF,MAAA;EACA,IAAA;EACA,IAAA;EACA,QAAA;EACA,QAAA;EACA,KAAA;EACA,GAAA;EACA,SAAA;EACA,iBAAA;EACA,SAAA;EACA,cAAA;EACA,QAAA;EACA,aAAA,GAAgB,cAAA;AAAA;AAAA,KAGN,kBAAA;EACV,KAAA;IACE,gBAAA;IACA,OAAA;IACA,YAAA;IACA,MAAA;IACA,UAAA;EAAA;EAEF,QAAA;EACA,UAAA;AAAA;AAAA,KAGU,sBAAA,wBAA8C,kBAAA,GAAqB,kBAAA,IAC7E,qBAAA;EACE,MAAA;EACA,OAAA;EACA,QAAA;EACA,iBAAA;EACA,cAAA;EACA,GAAA;EACA,IAAA;IACE,SAAA;IACA,QAAA;IACA,QAAA;EAAA;EAEF,aAAA,GAAgB,cAAA;AAAA;AAAA,KAGR,iBAAA,GAAoB,yBAAA,GAA4B,sBAAsB;AAAA,KAEtE,oBAAA,yBACR,yBAAA,CACE,cAAA,SAAuB,qBAAA,GAAwB,cAAA,GAAiB,qBAAA,IAElE,sBAAA,CACE,cAAA,SAAuB,kBAAA,GAAqB,cAAA,GAAiB,kBAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../herald/src/types/driver.types.d.ts
1
+ //#region ../../packages/herald/src/types/driver.types.d.ts
2
2
  type BrokerDriverType = "rabbitmq" | "kafka" | "redis-streams" | "sqs";
3
3
  type BrokerEvent = "connected" | "disconnected" | "error" | "reconnecting";
4
4
  type BrokerEventListener = (...args: unknown[]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"driver.types.d.mts","names":[],"sources":["../../../../../../../herald/src/types/driver.types.ts"],"mappings":";KAAY,gBAAA;AAAA,KAEA,WAAA;AAAA,KAEA,mBAAA,OAA0B,IAAI;AAAA,KAE9B,iBAAA;EACV,OAAA;EACA,OAAA;EACA,KAAA;EACA,OAAA,GAAU,MAAM;AAAA"}
1
+ {"version":3,"file":"driver.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/driver.types.ts"],"mappings":";KAAY,gBAAA;AAAA,KAEA,WAAA;AAAA,KAEA,mBAAA,OAA0B,IAAI;AAAA,KAE9B,iBAAA;EACV,OAAA;EACA,OAAA;EACA,KAAA;EACA,OAAA,GAAU,MAAM;AAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../herald/src/types/message.types.d.ts
1
+ //#region ../../packages/herald/src/types/message.types.d.ts
2
2
  type MessageMetadata = {
3
3
  messageId: string;
4
4
  correlationId?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"message.types.d.mts","names":[],"sources":["../../../../../../../herald/src/types/message.types.ts"],"mappings":";KAAY,eAAA;EACV,SAAA;EACA,aAAA;EACA,OAAA;EACA,QAAA;EACA,SAAA,EAAW,IAAA;EACX,OAAA,GAAU,MAAM;EAChB,UAAA;EACA,eAAA;AAAA;AAAA,KAGU,OAAA;EAAA,SACD,QAAA,EAAU,eAAA;EAAA,SACV,OAAA,EAAS,QAAQ;EAAA,SACjB,GAAA;AAAA;AAAA,KAGC,cAAA;EACV,GAAA,IAAO,OAAA;EACP,IAAA,CAAK,OAAA,aAAoB,OAAA;EACzB,MAAA,IAAU,OAAA;EACV,KAAA,IAAS,OAAA,EAAS,CAAA,GAAI,OAAA;EACtB,KAAA,CAAM,KAAA,YAAiB,OAAA;AAAA;AAAA,KAGb,YAAA;EAAA,SACD,EAAA;EAAA,SACA,OAAA;EAAA,SACA,WAAA;EACT,WAAA,IAAe,OAAA;EACf,KAAA,IAAS,OAAA;EACT,MAAA,IAAU,OAAA;EACV,QAAA;AAAA;AAAA,KAGU,cAAA,wBACV,OAAA,EAAS,OAAA,CAAQ,QAAA,GACjB,GAAA,EAAK,cAAA,KACF,OAAA;AAAA,KAEO,eAAA,6CACV,OAAA,EAAS,OAAA,CAAQ,QAAA,GACjB,GAAA,EAAK,cAAA,KACF,OAAA,CAAQ,SAAA,IAAa,SAAA"}
1
+ {"version":3,"file":"message.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/message.types.ts"],"mappings":";KAAY,eAAA;EACV,SAAA;EACA,aAAA;EACA,OAAA;EACA,QAAA;EACA,SAAA,EAAW,IAAA;EACX,OAAA,GAAU,MAAM;EAChB,UAAA;EACA,eAAA;AAAA;AAAA,KAGU,OAAA;EAAA,SACD,QAAA,EAAU,eAAA;EAAA,SACV,OAAA,EAAS,QAAQ;EAAA,SACjB,GAAA;AAAA;AAAA,KAGC,cAAA;EACV,GAAA,IAAO,OAAA;EACP,IAAA,CAAK,OAAA,aAAoB,OAAA;EACzB,MAAA,IAAU,OAAA;EACV,KAAA,IAAS,OAAA,EAAS,CAAA,GAAI,OAAA;EACtB,KAAA,CAAM,KAAA,YAAiB,OAAA;AAAA;AAAA,KAGb,YAAA;EAAA,SACD,EAAA;EAAA,SACA,OAAA;EAAA,SACA,WAAA;EACT,WAAA,IAAe,OAAA;EACf,KAAA,IAAS,OAAA;EACT,MAAA,IAAU,OAAA;EACV,QAAA;AAAA;AAAA,KAGU,cAAA,wBACV,OAAA,EAAS,OAAA,CAAQ,QAAA,GACjB,GAAA,EAAK,cAAA,KACF,OAAA;AAAA,KAEO,eAAA,6CACV,OAAA,EAAS,OAAA,CAAQ,QAAA,GACjB,GAAA,EAAK,cAAA,KACF,OAAA,CAAQ,SAAA,IAAa,SAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../herald/src/types/publish.types.d.ts
1
+ //#region ../../packages/herald/src/types/publish.types.d.ts
2
2
  type PublishOptions = {
3
3
  priority?: number;
4
4
  ttl?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"publish.types.d.mts","names":[],"sources":["../../../../../../../herald/src/types/publish.types.ts"],"mappings":";KAAY,cAAA;EACV,QAAA;EACA,GAAA;EACA,KAAA;EACA,OAAA,GAAU,MAAM;EAChB,UAAA;EACA,aAAA;EACA,UAAA;AAAA;AAAA,KAGU,cAAA,GAAiB,cAAc;EACzC,OAAO;AAAA"}
1
+ {"version":3,"file":"publish.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/publish.types.ts"],"mappings":";KAAY,cAAA;EACV,QAAA;EACA,GAAA;EACA,KAAA;EACA,OAAA,GAAU,MAAM;EAChB,UAAA;EACA,aAAA;EACA,UAAA;AAAA;AAAA,KAGU,cAAA,GAAiB,cAAc;EACzC,OAAO;AAAA"}
@@ -1,6 +1,6 @@
1
1
  import { Broker } from "../communicators/broker.mjs";
2
2
 
3
- //#region ../herald/src/types/registry.types.d.ts
3
+ //#region ../../packages/herald/src/types/registry.types.d.ts
4
4
  type BrokerRegistryEvent = "registered" | "default-registered" | "connected" | "disconnected";
5
5
  type BrokerRegistryListener = (broker: Broker) => void;
6
6
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"registry.types.d.mts","names":[],"sources":["../../../../../../../herald/src/types/registry.types.ts"],"mappings":";;;KAEY,mBAAA;AAAA,KAMA,sBAAA,IAA0B,MAAc,EAAN,MAAM"}
1
+ {"version":3,"file":"registry.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/registry.types.ts"],"mappings":";;;KAEY,mBAAA;AAAA,KAMA,sBAAA,IAA0B,MAAc,EAAN,MAAM"}
@@ -1,4 +1,4 @@
1
- //#region ../herald/src/types/subscribe.types.d.ts
1
+ //#region ../../packages/herald/src/types/subscribe.types.d.ts
2
2
  type RetryOptions = {
3
3
  maxRetries: number;
4
4
  delay: number | ((attempt: number) => number);
@@ -1 +1 @@
1
- {"version":3,"file":"subscribe.types.d.mts","names":[],"sources":["../../../../../../../herald/src/types/subscribe.types.ts"],"mappings":";KAAY,YAAA;EACV,UAAA;EACA,KAAA,aAAkB,OAAA;AAAA;AAAA,KAGR,iBAAA;EACV,OAAA;EACA,gBAAgB;AAAA;AAAA,KAGN,gBAAA;EACV,UAAA;EACA,KAAA;EACA,QAAA;EACA,OAAA;EACA,KAAA,GAAQ,YAAA;EACR,UAAA,GAAa,iBAAiB;EAC9B,SAAA;AAAA"}
1
+ {"version":3,"file":"subscribe.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/subscribe.types.ts"],"mappings":";KAAY,YAAA;EACV,UAAA;EACA,KAAA,aAAkB,OAAA;AAAA;AAAA,KAGR,iBAAA;EACV,OAAA;EACA,gBAAgB;AAAA;AAAA,KAGN,gBAAA;EACV,UAAA;EACA,KAAA;EACA,QAAA;EACA,OAAA;EACA,KAAA,GAAQ,YAAA;EACR,UAAA,GAAa,iBAAiB;EAC9B,SAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../herald/src/use-case-broadcast.d.ts
1
+ //#region ../../packages/herald/src/use-case-broadcast.d.ts
2
2
  /**
3
3
  * Minimal mirror of `@warlock.js/core`'s `UseCaseBroadcastEvent`.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"use-case-broadcast.d.mts","names":[],"sources":["../../../../../../herald/src/use-case-broadcast.ts"],"mappings":";;AASA;;;;;;KAAY,qBAAA;EACV,OAAA;EACA,KAAA;EACA,EAAA;EACA,EAAA,EAAI,IAAI;EACR,OAAA;AAAA;;;;;;;;;;;AAuBwD;;;;;;;;iBAF1C,eAAA,CAAgB,OAAA;EAAY,MAAA;AAAA;mBAEjB,qBAAA,GAAwB,OAAO;AAAA"}
1
+ {"version":3,"file":"use-case-broadcast.d.mts","names":[],"sources":["../../../../../../../packages/herald/src/use-case-broadcast.ts"],"mappings":";;AASA;;;;;;KAAY,qBAAA;EACV,OAAA;EACA,KAAA;EACA,EAAA;EACA,EAAA,EAAI,IAAI;EACR,OAAA;AAAA;;;;;;;;;;;AAuBwD;;;;;;;;iBAF1C,eAAA,CAAgB,OAAA;EAAY,MAAA;AAAA;mBAEjB,qBAAA,GAAwB,OAAO;AAAA"}
@@ -1,6 +1,6 @@
1
1
  import { herald } from "./utils/connect-to-broker.mjs";
2
2
 
3
- //#region ../herald/src/use-case-broadcast.ts
3
+ //#region ../../packages/herald/src/use-case-broadcast.ts
4
4
  /**
5
5
  * Channel adapter that publishes use-case broadcast events onto a herald broker.
6
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"use-case-broadcast.mjs","names":[],"sources":["../../../../../../herald/src/use-case-broadcast.ts"],"sourcesContent":["import { herald } from \"./utils/connect-to-broker\";\n\n/**\n * Minimal mirror of `@warlock.js/core`'s `UseCaseBroadcastEvent`.\n *\n * Kept local on purpose: this adapter is **structurally typed** so `@warlock.js/herald`\n * takes no dependency on `@warlock.js/core`. The shape only needs the fields the\n * adapter reads (`event` for the channel, `payload` for the body).\n */\nexport type UseCaseBroadcastEvent = {\n useCase: string;\n event: string;\n id: string;\n at: Date;\n payload: unknown;\n};\n\n/**\n * Channel adapter that publishes use-case broadcast events onto a herald broker.\n *\n * Register it in the use-cases config so successful use cases fan out to the bus:\n *\n * @example\n * // src/config/use-cases.ts\n * import { heraldBroadcast } from \"@warlock.js/herald\";\n *\n * export default {\n * broadcast: {\n * enabled: true,\n * channels: [heraldBroadcast({ broker: \"default\" })],\n * },\n * } satisfies UseCaseConfigurations;\n *\n * @param options - Optional broker name (defaults to the default broker)\n */\nexport function heraldBroadcast(options?: { broker?: string }) {\n return {\n async broadcast(event: UseCaseBroadcastEvent): Promise<void> {\n await herald(options?.broker).channel(event.event).publish(event.payload);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,gBAAgB,SAA+B;CAC7D,OAAO,EACL,MAAM,UAAU,OAA6C;EAC3D,MAAM,OAAO,SAAS,MAAM,CAAC,CAAC,QAAQ,MAAM,KAAK,CAAC,CAAC,QAAQ,MAAM,OAAO;CAC1E,EACF;AACF"}
1
+ {"version":3,"file":"use-case-broadcast.mjs","names":[],"sources":["../../../../../../../packages/herald/src/use-case-broadcast.ts"],"sourcesContent":["import { herald } from \"./utils/connect-to-broker\";\n\n/**\n * Minimal mirror of `@warlock.js/core`'s `UseCaseBroadcastEvent`.\n *\n * Kept local on purpose: this adapter is **structurally typed** so `@warlock.js/herald`\n * takes no dependency on `@warlock.js/core`. The shape only needs the fields the\n * adapter reads (`event` for the channel, `payload` for the body).\n */\nexport type UseCaseBroadcastEvent = {\n useCase: string;\n event: string;\n id: string;\n at: Date;\n payload: unknown;\n};\n\n/**\n * Channel adapter that publishes use-case broadcast events onto a herald broker.\n *\n * Register it in the use-cases config so successful use cases fan out to the bus:\n *\n * @example\n * // src/config/use-cases.ts\n * import { heraldBroadcast } from \"@warlock.js/herald\";\n *\n * export default {\n * broadcast: {\n * enabled: true,\n * channels: [heraldBroadcast({ broker: \"default\" })],\n * },\n * } satisfies UseCaseConfigurations;\n *\n * @param options - Optional broker name (defaults to the default broker)\n */\nexport function heraldBroadcast(options?: { broker?: string }) {\n return {\n async broadcast(event: UseCaseBroadcastEvent): Promise<void> {\n await herald(options?.broker).channel(event.event).publish(event.payload);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,gBAAgB,SAA+B;CAC7D,OAAO,EACL,MAAM,UAAU,OAA6C;EAC3D,MAAM,OAAO,SAAS,MAAM,CAAC,CAAC,QAAQ,MAAM,KAAK,CAAC,CAAC,QAAQ,MAAM,OAAO;CAC1E,EACF;AACF"}
@@ -4,7 +4,7 @@ import { ChannelContract } from "../contracts/channel.contract.mjs";
4
4
  import { EventMessage } from "../message-managers/event-message.mjs";
5
5
  import { EventConsumerClass } from "../message-managers/types.mjs";
6
6
  import { Broker } from "../communicators/broker.mjs";
7
- //#region ../herald/src/utils/connect-to-broker.d.ts
7
+ //#region ../../packages/herald/src/utils/connect-to-broker.d.ts
8
8
  /**
9
9
  * Connect to a message broker and register it.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"connect-to-broker.d.mts","names":[],"sources":["../../../../../../../herald/src/utils/connect-to-broker.ts"],"mappings":";;;;;;;;;;;;;;;AA0DA;;;;;;;;;;;;;AAAiF;AA6EjF;;;;AAA6C;AAoB7C;;;;;;;;;;;;;;;;;AAG2B;AAgB3B;;;;;;;;iBApHsB,eAAA,CAAgB,OAAA,EAAS,iBAAA,GAAoB,OAAA,CAAQ,MAAA;;;;;;;;AAoHqB;AAgBhG;;;;;;;;;;;;;;;;AACwC;;;;iBAxDxB,MAAA,CAAO,IAAA,YAAgB,MAAM;;;;;;;;;;;;;;;;;iBAoB7B,aAAA,qBACd,IAAA,UACA,OAAA,GAAU,cAAA,CAAe,QAAA,IACxB,eAAA,CAAgB,QAAA;;;;;;;;;;;;;iBAgBG,YAAA,YAAwB,MAAA,eAAqB,KAAA,EAAO,YAAA,CAAa,QAAA,IAAS,OAAA;;;;;;;;;;;;;iBAgB1E,iBAAA,YAA6B,MAAA,eACjD,QAAA,EAAU,kBAAA,CAAmB,QAAA,IAAS,OAAA"}
1
+ {"version":3,"file":"connect-to-broker.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/utils/connect-to-broker.ts"],"mappings":";;;;;;;;;;;;;;;AA0DA;;;;;;;;;;;;;AAAiF;AA6EjF;;;;AAA6C;AAoB7C;;;;;;;;;;;;;;;;;AAG2B;AAgB3B;;;;;;;;iBApHsB,eAAA,CAAgB,OAAA,EAAS,iBAAA,GAAoB,OAAA,CAAQ,MAAA;;;;;;;;AAoHqB;AAgBhG;;;;;;;;;;;;;;;;AACwC;;;;iBAxDxB,MAAA,CAAO,IAAA,YAAgB,MAAM;;;;;;;;;;;;;;;;;iBAoB7B,aAAA,qBACd,IAAA,UACA,OAAA,GAAU,cAAA,CAAe,QAAA,IACxB,eAAA,CAAgB,QAAA;;;;;;;;;;;;;iBAgBG,YAAA,YAAwB,MAAA,eAAqB,KAAA,EAAO,YAAA,CAAa,QAAA,IAAS,OAAA;;;;;;;;;;;;;iBAgB1E,iBAAA,YAA6B,MAAA,eACjD,QAAA,EAAU,kBAAA,CAAmB,QAAA,IAAS,OAAA"}
@@ -1,7 +1,7 @@
1
1
  import { brokerRegistry } from "../communicators/broker-registry.mjs";
2
2
  import "../communicators/index.mjs";
3
3
 
4
- //#region ../herald/src/utils/connect-to-broker.ts
4
+ //#region ../../packages/herald/src/utils/connect-to-broker.ts
5
5
  /**
6
6
  * Connect to a message broker and register it.
7
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"connect-to-broker.mjs","names":[],"sources":["../../../../../../../herald/src/utils/connect-to-broker.ts"],"sourcesContent":["import { Broker, brokerRegistry } from \"../communicators\";\nimport type { BrokerDriverContract, ChannelContract } from \"../contracts\";\nimport { type EventConsumerClass, EventMessage } from \"../message-managers\";\nimport type { ChannelOptions, ConnectionOptions, RabbitMQConnectionOptions } from \"../types\";\n\n/**\n * Connect to a message broker and register it.\n *\n * This is a high-level utility function that simplifies connection setup\n * for most projects. It handles driver instantiation, connection,\n * broker creation, and automatic registration.\n *\n * **Supported Drivers:**\n * - `rabbitmq` (default) - RabbitMQ/AMQP driver\n * - `kafka` - Apache Kafka driver (coming soon)\n *\n * @param options - Connection configuration options\n * @returns A connected and registered Broker instance\n * @throws {Error} If connection fails or driver is not implemented\n *\n * @example\n * ```typescript\n * // RabbitMQ connection\n * const broker = await connectToBroker({\n * driver: \"rabbitmq\",\n * host: \"localhost\",\n * port: 5672,\n * username: \"guest\",\n * password: \"guest\",\n * });\n *\n * // Use the broker\n * await broker.channel(\"user.created\").publish({ userId: 1 });\n * ```\n *\n * @example\n * ```typescript\n * // Multiple brokers\n * await connectToBroker({\n * driver: \"rabbitmq\",\n * name: \"notifications\",\n * isDefault: true,\n * host: process.env.RABBITMQ_HOST,\n * });\n *\n * await connectToBroker({\n * driver: \"rabbitmq\",\n * name: \"analytics\",\n * host: process.env.ANALYTICS_RABBITMQ_HOST,\n * });\n *\n * // Use default broker\n * herald().channel(\"notifications\").publish({ ... });\n *\n * // Use specific broker\n * herald(\"analytics\").channel(\"events\").publish({ ... });\n * ```\n */\nexport async function connectToBroker(options: ConnectionOptions): Promise<Broker> {\n // Default values\n const driverType = options.driver ?? \"rabbitmq\";\n const brokerName = options.name ?? \"default\";\n const isDefault = options.isDefault ?? true;\n\n // Create driver based on type\n let driver: BrokerDriverContract;\n\n switch (driverType) {\n case \"rabbitmq\": {\n const rabbitOptions = options as RabbitMQConnectionOptions;\n // Dynamic import to avoid requiring amqplib if not used\n const { RabbitMQDriver } = await import(\"../drivers/rabbitmq/rabbitmq-driver\");\n driver = new RabbitMQDriver(rabbitOptions);\n break;\n }\n\n case \"kafka\": {\n // const kafkaOptions = options as KafkaConnectionOptions;\n // Dynamic import to avoid requiring kafkajs if not used\n throw new Error(\n \"Kafka driver is not yet implemented. Coming soon! For now, please use RabbitMQ.\",\n );\n }\n\n default:\n throw new Error(`Unknown driver: \"${driverType}\". Supported drivers: rabbitmq, kafka`);\n }\n\n // Create broker\n const broker = brokerRegistry.register({\n name: brokerName,\n driver,\n isDefault,\n });\n\n // Connect to the message broker\n try {\n await driver.connect();\n } catch (error) {\n throw new Error(\n `Failed to connect to ${driverType}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n return broker;\n}\n\n/**\n * Get a broker by name or the default one.\n *\n * This is the main entry point for using brokers in your application.\n * Named after the package — `herald()` carries your messages!\n *\n * @param name - Optional broker name (uses default if not provided)\n * @returns Broker instance\n * @throws MissingBrokerError if broker not found\n *\n * @example\n * // Get default broker\n * const channel = herald().channel(\"user.created\");\n * await channel.publish({ userId: 1 });\n *\n * // Get specific broker\n * const analyticsChannel = herald(\"analytics\").channel(\"events\");\n * await analyticsChannel.publish({ event: \"page_view\" });\n *\n * // Subscribe to messages\n * herald()\n * .channel<UserPayload>(\"user.created\")\n * .subscribe(async (message, ctx) => {\n * console.log(\"User created:\", message.payload);\n * await ctx.ack();\n * });\n * ```\n */\nexport function herald(name?: string): Broker {\n return brokerRegistry.get(name);\n}\n\n/**\n * Get channel instance for the given name from default broker.\n *\n * Shorthand for `herald().channel(name, options)`.\n *\n * @param name - Channel name\n * @param options - Optional channel options\n * @returns Channel instance\n * @throws MissingBrokerError if broker not found\n *\n * @example\n * ```typescript\n * const channel = heraldChannel(\"user.created\");\n * await channel.publish({ userId: 1 });\n * ```\n */\nexport function heraldChannel<TPayload = unknown>(\n name: string,\n options?: ChannelOptions<TPayload>,\n): ChannelContract<TPayload> {\n return herald().channel<TPayload>(name, options);\n}\n\n/**\n * Publish an EventMessage to the default broker.\n *\n * @param event - Event message to publish\n * @returns Promise that resolves when the event is published\n * @throws Error if the broker is not connected\n *\n * @example\n * ```typescript\n * await publishEvent(new UserUpdatedEvent({ id: 1, name: \"John Doe\" }));\n * ```\n */\nexport async function publishEvent<TPayload = Record<string, any>>(event: EventMessage<TPayload>) {\n return herald().publish(event);\n}\n\n/**\n * Subscribe an EventConsumer class to the default broker.\n *\n * @param Consumer - Event consumer class\n * @returns Unsubscribe function\n * @throws MissingBrokerError if broker not found\n *\n * @example\n * ```typescript\n * await subscribeConsumer(UserUpdatedConsumer);\n * ```\n */\nexport async function subscribeConsumer<TPayload = Record<string, any>>(\n Consumer: EventConsumerClass<TPayload>,\n) {\n return herald().subscribe(Consumer);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,eAAsB,gBAAgB,SAA6C;CAEjF,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,aAAa,QAAQ,QAAQ;CACnC,MAAM,YAAY,QAAQ,aAAa;CAGvC,IAAI;CAEJ,QAAQ,YAAR;EACE,KAAK,YAAY;GACf,MAAM,gBAAgB;GAEtB,MAAM,EAAE,mBAAmB,MAAM,OAAO;GACxC,SAAS,IAAI,eAAe,aAAa;GACzC;EACF;EAEA,KAAK,SAGH,MAAM,IAAI,MACR,iFACF;EAGF,SACE,MAAM,IAAI,MAAM,oBAAoB,WAAW,sCAAsC;CACzF;CAGA,MAAM,SAAS,eAAe,SAAS;EACrC,MAAM;EACN;EACA;CACF,CAAC;CAGD,IAAI;EACF,MAAM,OAAO,QAAQ;CACvB,SAAS,OAAO;EACd,MAAM,IAAI,MACR,wBAAwB,WAAW,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC9F;CACF;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,OAAO,MAAuB;CAC5C,OAAO,eAAe,IAAI,IAAI;AAChC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,cACd,MACA,SAC2B;CAC3B,OAAO,OAAO,CAAC,CAAC,QAAkB,MAAM,OAAO;AACjD;;;;;;;;;;;;;AAcA,eAAsB,aAA6C,OAA+B;CAChG,OAAO,OAAO,CAAC,CAAC,QAAQ,KAAK;AAC/B;;;;;;;;;;;;;AAcA,eAAsB,kBACpB,UACA;CACA,OAAO,OAAO,CAAC,CAAC,UAAU,QAAQ;AACpC"}
1
+ {"version":3,"file":"connect-to-broker.mjs","names":[],"sources":["../../../../../../../../packages/herald/src/utils/connect-to-broker.ts"],"sourcesContent":["import { Broker, brokerRegistry } from \"../communicators\";\nimport type { BrokerDriverContract, ChannelContract } from \"../contracts\";\nimport { type EventConsumerClass, EventMessage } from \"../message-managers\";\nimport type { ChannelOptions, ConnectionOptions, RabbitMQConnectionOptions } from \"../types\";\n\n/**\n * Connect to a message broker and register it.\n *\n * This is a high-level utility function that simplifies connection setup\n * for most projects. It handles driver instantiation, connection,\n * broker creation, and automatic registration.\n *\n * **Supported Drivers:**\n * - `rabbitmq` (default) - RabbitMQ/AMQP driver\n * - `kafka` - Apache Kafka driver (coming soon)\n *\n * @param options - Connection configuration options\n * @returns A connected and registered Broker instance\n * @throws {Error} If connection fails or driver is not implemented\n *\n * @example\n * ```typescript\n * // RabbitMQ connection\n * const broker = await connectToBroker({\n * driver: \"rabbitmq\",\n * host: \"localhost\",\n * port: 5672,\n * username: \"guest\",\n * password: \"guest\",\n * });\n *\n * // Use the broker\n * await broker.channel(\"user.created\").publish({ userId: 1 });\n * ```\n *\n * @example\n * ```typescript\n * // Multiple brokers\n * await connectToBroker({\n * driver: \"rabbitmq\",\n * name: \"notifications\",\n * isDefault: true,\n * host: process.env.RABBITMQ_HOST,\n * });\n *\n * await connectToBroker({\n * driver: \"rabbitmq\",\n * name: \"analytics\",\n * host: process.env.ANALYTICS_RABBITMQ_HOST,\n * });\n *\n * // Use default broker\n * herald().channel(\"notifications\").publish({ ... });\n *\n * // Use specific broker\n * herald(\"analytics\").channel(\"events\").publish({ ... });\n * ```\n */\nexport async function connectToBroker(options: ConnectionOptions): Promise<Broker> {\n // Default values\n const driverType = options.driver ?? \"rabbitmq\";\n const brokerName = options.name ?? \"default\";\n const isDefault = options.isDefault ?? true;\n\n // Create driver based on type\n let driver: BrokerDriverContract;\n\n switch (driverType) {\n case \"rabbitmq\": {\n const rabbitOptions = options as RabbitMQConnectionOptions;\n // Dynamic import to avoid requiring amqplib if not used\n const { RabbitMQDriver } = await import(\"../drivers/rabbitmq/rabbitmq-driver\");\n driver = new RabbitMQDriver(rabbitOptions);\n break;\n }\n\n case \"kafka\": {\n // const kafkaOptions = options as KafkaConnectionOptions;\n // Dynamic import to avoid requiring kafkajs if not used\n throw new Error(\n \"Kafka driver is not yet implemented. Coming soon! For now, please use RabbitMQ.\",\n );\n }\n\n default:\n throw new Error(`Unknown driver: \"${driverType}\". Supported drivers: rabbitmq, kafka`);\n }\n\n // Create broker\n const broker = brokerRegistry.register({\n name: brokerName,\n driver,\n isDefault,\n });\n\n // Connect to the message broker\n try {\n await driver.connect();\n } catch (error) {\n throw new Error(\n `Failed to connect to ${driverType}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n return broker;\n}\n\n/**\n * Get a broker by name or the default one.\n *\n * This is the main entry point for using brokers in your application.\n * Named after the package — `herald()` carries your messages!\n *\n * @param name - Optional broker name (uses default if not provided)\n * @returns Broker instance\n * @throws MissingBrokerError if broker not found\n *\n * @example\n * // Get default broker\n * const channel = herald().channel(\"user.created\");\n * await channel.publish({ userId: 1 });\n *\n * // Get specific broker\n * const analyticsChannel = herald(\"analytics\").channel(\"events\");\n * await analyticsChannel.publish({ event: \"page_view\" });\n *\n * // Subscribe to messages\n * herald()\n * .channel<UserPayload>(\"user.created\")\n * .subscribe(async (message, ctx) => {\n * console.log(\"User created:\", message.payload);\n * await ctx.ack();\n * });\n * ```\n */\nexport function herald(name?: string): Broker {\n return brokerRegistry.get(name);\n}\n\n/**\n * Get channel instance for the given name from default broker.\n *\n * Shorthand for `herald().channel(name, options)`.\n *\n * @param name - Channel name\n * @param options - Optional channel options\n * @returns Channel instance\n * @throws MissingBrokerError if broker not found\n *\n * @example\n * ```typescript\n * const channel = heraldChannel(\"user.created\");\n * await channel.publish({ userId: 1 });\n * ```\n */\nexport function heraldChannel<TPayload = unknown>(\n name: string,\n options?: ChannelOptions<TPayload>,\n): ChannelContract<TPayload> {\n return herald().channel<TPayload>(name, options);\n}\n\n/**\n * Publish an EventMessage to the default broker.\n *\n * @param event - Event message to publish\n * @returns Promise that resolves when the event is published\n * @throws Error if the broker is not connected\n *\n * @example\n * ```typescript\n * await publishEvent(new UserUpdatedEvent({ id: 1, name: \"John Doe\" }));\n * ```\n */\nexport async function publishEvent<TPayload = Record<string, any>>(event: EventMessage<TPayload>) {\n return herald().publish(event);\n}\n\n/**\n * Subscribe an EventConsumer class to the default broker.\n *\n * @param Consumer - Event consumer class\n * @returns Unsubscribe function\n * @throws MissingBrokerError if broker not found\n *\n * @example\n * ```typescript\n * await subscribeConsumer(UserUpdatedConsumer);\n * ```\n */\nexport async function subscribeConsumer<TPayload = Record<string, any>>(\n Consumer: EventConsumerClass<TPayload>,\n) {\n return herald().subscribe(Consumer);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,eAAsB,gBAAgB,SAA6C;CAEjF,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,aAAa,QAAQ,QAAQ;CACnC,MAAM,YAAY,QAAQ,aAAa;CAGvC,IAAI;CAEJ,QAAQ,YAAR;EACE,KAAK,YAAY;GACf,MAAM,gBAAgB;GAEtB,MAAM,EAAE,mBAAmB,MAAM,OAAO;GACxC,SAAS,IAAI,eAAe,aAAa;GACzC;EACF;EAEA,KAAK,SAGH,MAAM,IAAI,MACR,iFACF;EAGF,SACE,MAAM,IAAI,MAAM,oBAAoB,WAAW,sCAAsC;CACzF;CAGA,MAAM,SAAS,eAAe,SAAS;EACrC,MAAM;EACN;EACA;CACF,CAAC;CAGD,IAAI;EACF,MAAM,OAAO,QAAQ;CACvB,SAAS,OAAO;EACd,MAAM,IAAI,MACR,wBAAwB,WAAW,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC9F;CACF;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,OAAO,MAAuB;CAC5C,OAAO,eAAe,IAAI,IAAI;AAChC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,cACd,MACA,SAC2B;CAC3B,OAAO,OAAO,CAAC,CAAC,QAAkB,MAAM,OAAO;AACjD;;;;;;;;;;;;;AAcA,eAAsB,aAA6C,OAA+B;CAChG,OAAO,OAAO,CAAC,CAAC,QAAQ,KAAK;AAC/B;;;;;;;;;;;;;AAcA,eAAsB,kBACpB,UACA;CACA,OAAO,OAAO,CAAC,CAAC,UAAU,QAAQ;AACpC"}
package/llms-full.txt CHANGED
@@ -25,9 +25,9 @@ herald()
25
25
  .subscribe(async (message, ctx) => {
26
26
  try {
27
27
  await sendWelcomeEmail(message.payload.email);
28
- await ctx.ack(); // success — message removed from queue
28
+ await ctx.ack(); // success — message removed from queue
29
29
  } catch (error) {
30
- await ctx.nack(true); // failure — requeue for redelivery
30
+ await ctx.nack(true); // failure — requeue for redelivery
31
31
  }
32
32
  });
33
33
  ```
@@ -38,7 +38,7 @@ herald()
38
38
  - Handler **throws** → herald **auto-nacks** (requeue, or DLQ/reject once retries are exhausted — see below).
39
39
  - Handler calls `ctx.ack()` / `ctx.nack()` / `ctx.reject()` / `ctx.retry()` → herald respects that and does nothing further.
40
40
 
41
- So the `try/catch` above is optional — letting the error throw produces the same auto-nack. Call `ctx` methods explicitly only when you want a *non-default* outcome (reject without requeue, route to DLQ, delayed retry). The one mode that loses messages is `autoAck: true`, where the broker acks on delivery before your handler runs.
41
+ So the `try/catch` above is optional — letting the error throw produces the same auto-nack. Call `ctx` methods explicitly only when you want a _non-default_ outcome (reject without requeue, route to DLQ, delayed retry). The one mode that loses messages is `autoAck: true`, where the broker acks on delivery before your handler runs.
42
42
 
43
43
  ## Message context — flow control
44
44
 
@@ -52,23 +52,23 @@ ctx.reply(payload); // for request-response pattern (see request-and-respond
52
52
 
53
53
  Pick by intent:
54
54
 
55
- | Intent | Use |
56
- | --- | --- |
57
- | Processed cleanly | `ctx.ack()` |
58
- | Transient failure, try again | `ctx.nack(true)` or `ctx.retry(5000)` |
59
- | Permanent failure, send to DLQ | `ctx.nack(false)` or `ctx.reject()` |
60
- | Validation failure (bad message) | `ctx.reject()` — don't requeue |
55
+ | Intent | Use |
56
+ | -------------------------------- | ------------------------------------- |
57
+ | Processed cleanly | `ctx.ack()` |
58
+ | Transient failure, try again | `ctx.nack(true)` or `ctx.retry(5000)` |
59
+ | Permanent failure, send to DLQ | `ctx.nack(false)` or `ctx.reject()` |
60
+ | Validation failure (bad message) | `ctx.reject()` — don't requeue |
61
61
 
62
62
  ## Subscribe options
63
63
 
64
64
  ```ts
65
65
  await channel.subscribe(handler, {
66
- group: "email-workers", // consumer group / tag — multiple consumers share work
67
- prefetch: 10, // concurrency — how many in-flight messages this consumer holds
68
- autoAck: false, // default; keep it false in production
69
- exclusive: false, // single consumer only on this channel?
66
+ group: "email-workers", // consumer group / tag — multiple consumers share work
67
+ prefetch: 10, // concurrency — how many in-flight messages this consumer holds
68
+ autoAck: false, // default; keep it false in production
69
+ exclusive: false, // single consumer only on this channel?
70
70
  retry: {
71
- maxRetries: 3, // redelivery ceiling on handler throw (delay not auto-applied — see below)
71
+ maxRetries: 3, // redelivery ceiling on handler throw (delay not auto-applied — see below)
72
72
  delay: 1000,
73
73
  },
74
74
  deadLetter: {
@@ -109,10 +109,12 @@ The DLQ always forwards the full original payload plus the message metadata, so
109
109
  Messages that exhausted retries land in `user.created.failed`. Subscribe to it separately for alerting / manual inspection:
110
110
 
111
111
  ```ts
112
- herald().channel("user.created.failed").subscribe(async (message, ctx) => {
113
- await alerts.notify(`Failed: ${JSON.stringify(message.payload)}`);
114
- await ctx.ack();
115
- });
112
+ herald()
113
+ .channel("user.created.failed")
114
+ .subscribe(async (message, ctx) => {
115
+ await alerts.notify(`Failed: ${JSON.stringify(message.payload)}`);
116
+ await ctx.ack();
117
+ });
116
118
  ```
117
119
 
118
120
  ## Decorator-style consumers — `@Consumable` + `EventConsumer`
@@ -123,7 +125,7 @@ For class-based consumers that pair with the `EventMessage` (the `publish-messag
123
125
  import { Consumable, EventConsumer } from "@warlock.js/herald";
124
126
  import type { ConsumedEventMessage } from "@warlock.js/herald";
125
127
 
126
- @Consumable() // or @Consumable({ broker: "analytics" }) to target a non-default broker
128
+ @Consumable() // or @Consumable({ broker: "analytics" }) to target a non-default broker
127
129
  export class UserCreatedConsumer extends EventConsumer<{ id: number; email: string }> {
128
130
  public static eventName = "user.created";
129
131
 
@@ -175,7 +177,7 @@ export class UserCreatedConsumer extends EventConsumer {
175
177
  import { defineConsumer } from "@warlock.js/herald";
176
178
 
177
179
  export const userCreatedConsumer = defineConsumer<{ id: number; email: string }>("user.created", {
178
- schema: userCreatedSchema, // optional seal validation
180
+ schema: userCreatedSchema, // optional seal validation
179
181
  handle: async (payload, event) => {
180
182
  await sendWelcomeEmail(payload.email);
181
183
  },
@@ -191,11 +193,11 @@ export const userCreatedConsumer = defineConsumer<{ id: number; email: string }>
191
193
  ```ts
192
194
  const subscription = await channel.subscribe(handler);
193
195
 
194
- subscription.id; // the consumer id (string)
195
- subscription.isActive(); // boolean
196
+ subscription.id; // the consumer id (string)
197
+ subscription.isActive(); // boolean
196
198
 
197
- await subscription.unsubscribe(); // cancel the consumer on the broker
198
- await subscription.pause(); // also cancels the consumer (RabbitMQ has no native pause)
199
+ await subscription.unsubscribe(); // cancel the consumer on the broker
200
+ await subscription.pause(); // also cancels the consumer (RabbitMQ has no native pause)
199
201
  ```
200
202
 
201
203
  On the RabbitMQ driver, `pause()` and `unsubscribe()` both cancel the consumer; `resume()` is **not supported and throws** — create a fresh subscription to start consuming again. You can also cancel by id from the channel: `await channel.unsubscribeById(consumerId)`, or drop every consumer on the channel with `await channel.stopConsuming()`.
@@ -206,10 +208,10 @@ The channel exposes queue-management helpers beyond pub/sub:
206
208
 
207
209
  ```ts
208
210
  const { messageCount, consumerCount } = await channel.stats(); // queue depth + live consumers
209
- const purged = await channel.purge(); // drop all pending messages, returns the count
210
- const ok = await channel.exists(); // does the queue exist on the broker?
211
- await channel.assert(); // create the queue with its options (idempotent)
212
- await channel.delete(); // remove the queue entirely
211
+ const purged = await channel.purge(); // drop all pending messages, returns the count
212
+ const ok = await channel.exists(); // does the queue exist on the broker?
213
+ await channel.assert(); // create the queue with its options (idempotent)
214
+ await channel.delete(); // remove the queue entirely
213
215
  ```
214
216
 
215
217
  `assert()` runs lazily on the first `publish` / `subscribe`, so you rarely call it directly — reach for it only to pre-create a queue before any traffic.
@@ -304,20 +306,20 @@ await connectToBroker({
304
306
  host: process.env.ANALYTICS_HOST,
305
307
  });
306
308
 
307
- herald().channel("emails").publish({ /* ... */ }); // → notifications
308
- herald("analytics").channel("events").publish({ /* ... */ }); // → analytics
309
+ herald().channel("emails").publish({/* ... */}); // → notifications
310
+ herald("analytics").channel("events").publish({/* ... */}); // → analytics
309
311
  ```
310
312
 
311
313
  `connectToBroker` defaults `isDefault` to `true`, and the registry promotes the most-recently-registered default. So when you register more than one broker, mark the secondaries `isDefault: false` — otherwise the last one wins and `herald()` returns the wrong broker.
312
314
 
313
315
  ## Pick a skill
314
316
 
315
- | If the task is about… | Load |
316
- | --- | --- |
317
- | Publishing messages — single + batch + publish options (priority, ttl, delay, persistent, headers) | the `publish-message` topic |
318
- | Subscribing to messages — handler signature, message context (ack/nack/retry), prefetch, retry policy, dead-letter | the `consume-message` topic |
319
- | Request/response (RPC) — `channel.request(...)` + `channel.respond(...)` for synchronous-style calls over a message bus | the `request-and-respond` topic |
320
- | Schema-validated channels — `.channel(name, { schema })` with `@warlock.js/seal` | See the `seal-basics` topic of the `warlock-js-seal` skill + skills below |
317
+ | If the task is about… | Load |
318
+ | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
319
+ | Publishing messages — single + batch + publish options (priority, ttl, delay, persistent, headers) | the `publish-message` topic |
320
+ | Subscribing to messages — handler signature, message context (ack/nack/retry), prefetch, retry policy, dead-letter | the `consume-message` topic |
321
+ | Request/response (RPC) — `channel.request(...)` + `channel.respond(...)` for synchronous-style calls over a message bus | the `request-and-respond` topic |
322
+ | Schema-validated channels — `.channel(name, { schema })` with `@warlock.js/seal` | See the `seal-basics` topic of the `warlock-js-seal` skill + skills below |
321
323
 
322
324
  ## Things NOT to do
323
325
 
@@ -363,8 +365,8 @@ type UserPayload = { userId: number; email: string };
363
365
 
364
366
  const channel = herald().channel<UserPayload>("user.created");
365
367
 
366
- await channel.publish({ userId: 1, email: "test@example.com" }); // ✅ typed
367
- await channel.publish({ userId: "1" } as never); // ❌ compile error
368
+ await channel.publish({ userId: 1, email: "test@example.com" }); // ✅ typed
369
+ await channel.publish({ userId: "1" } as never); // ❌ compile error
368
370
  ```
369
371
 
370
372
  Share the payload type between producer and consumer via a common `types/` file.
@@ -381,7 +383,7 @@ const userSchema = v.object({
381
383
 
382
384
  const channel = herald().channel("user.created", { schema: userSchema });
383
385
 
384
- await channel.publish({ userId: 1, email: "invalid" }); // Throws — fails .email()
386
+ await channel.publish({ userId: 1, email: "invalid" }); // Throws — fails .email()
385
387
  ```
386
388
 
387
389
  The schema runs `validate()` before the message hits the broker. Invalid payloads never leave the producer. See the `seal-basics` topic of the `warlock-js-seal` skill.
@@ -390,10 +392,10 @@ The schema runs `validate()` before the message hits the broker. Invalid payload
390
392
 
391
393
  ```ts
392
394
  await channel.publish(payload, {
393
- priority: 5, // 0-9, higher = served first
394
- expiration: 60_000, // ms — message expires if not consumed (RabbitMQ uses `expiration`, not `ttl`)
395
- delay: 5_000, // ms — delayed delivery (requires RabbitMQ delay plugin)
396
- persistent: true, // survive broker restart (default true)
395
+ priority: 5, // 0-9, higher = served first
396
+ expiration: 60_000, // ms — message expires if not consumed (RabbitMQ uses `expiration`, not `ttl`)
397
+ delay: 5_000, // ms — delayed delivery (requires RabbitMQ delay plugin)
398
+ persistent: true, // survive broker restart (default true)
397
399
  correlationId: "uuid", // for tracking across services
398
400
  headers: {
399
401
  tenantId: "42",
@@ -407,14 +409,17 @@ The headers field is free-form — consumers read `message.metadata.headers?.ten
407
409
  ## Batch publishing
408
410
 
409
411
  ```ts
410
- await channel.publishBatch([
411
- { userId: 1, email: "a@example.com" },
412
- { userId: 2, email: "b@example.com" },
413
- { userId: 3, email: "c@example.com" },
414
- ], {
415
- // Options apply to every message in the batch
416
- persistent: true,
417
- });
412
+ await channel.publishBatch(
413
+ [
414
+ { userId: 1, email: "a@example.com" },
415
+ { userId: 2, email: "b@example.com" },
416
+ { userId: 3, email: "c@example.com" },
417
+ ],
418
+ {
419
+ // Options apply to every message in the batch
420
+ persistent: true,
421
+ },
422
+ );
418
423
  ```
419
424
 
420
425
  Under the hood `publishBatch` iterates and calls `.publish()` per message — there's no AMQP-level batching today. It's an ergonomic shape for "emit these N items" (bulk import, fanout to many recipients), not a throughput optimization. The same `options` apply to every message.
@@ -464,7 +469,7 @@ export default {
464
469
  ```ts
465
470
  // The use case opts in — channel name defaults to the use case name.
466
471
  export const createUserUseCase = useCase({
467
- name: "users.create", // → publishes to channel "users.create"
472
+ name: "users.create", // → publishes to channel "users.create"
468
473
  schema: createUserSchema,
469
474
  handler: async (data) => User.create(data),
470
475
  broadcast: true,
@@ -548,12 +553,12 @@ The promise rejects if no reply arrives within `timeout` ms. Pick a sane number
548
553
 
549
554
  ## When to use it vs HTTP
550
555
 
551
- | Use HTTP | Use request/respond |
552
- | --- | --- |
556
+ | Use HTTP | Use request/respond |
557
+ | ------------------------------- | ------------------------------------------- |
553
558
  | Stateless, fast, idempotent ops | Slow / queued ops where the caller can wait |
554
- | Public API surface | Internal service-to-service |
555
- | Frontend consumption | Backend orchestration |
556
- | Synchronous user-facing flow | Async-but-needs-result patterns |
559
+ | Public API surface | Internal service-to-service |
560
+ | Frontend consumption | Backend orchestration |
561
+ | Synchronous user-facing flow | Async-but-needs-result patterns |
557
562
 
558
563
  The bus adds queue persistence and retry. HTTP is faster for sub-100ms ops; the bus shines when the operation has variable duration or needs a queue's backpressure.
559
564
 
package/package.json CHANGED
@@ -8,12 +8,13 @@
8
8
  "@mongez/copper": "^2.1.3",
9
9
  "@mongez/events": "^2.2.8",
10
10
  "@mongez/reinforcements": "^4.0.2",
11
- "@warlock.js/logger": "5.29.0",
12
- "@warlock.js/seal": "5.29.0"
11
+ "@warlock.js/logger": "5.31.0",
12
+ "@warlock.js/seal": "5.31.0"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/warlockjs/herald"
16
+ "url": "git+https://github.com/warlockjs/framework.git",
17
+ "directory": "packages/herald"
17
18
  },
18
19
  "peerDependencies": {
19
20
  "amqplib": "^0.10.0"
@@ -36,7 +37,7 @@
36
37
  ],
37
38
  "author": "hassanzohdy",
38
39
  "license": "MIT",
39
- "version": "5.29.0",
40
+ "version": "5.31.0",
40
41
  "main": "./cjs/index.cjs",
41
42
  "module": "./esm/index.mjs",
42
43
  "types": "./esm/index.d.mts",
@@ -17,9 +17,9 @@ herald()
17
17
  .subscribe(async (message, ctx) => {
18
18
  try {
19
19
  await sendWelcomeEmail(message.payload.email);
20
- await ctx.ack(); // success — message removed from queue
20
+ await ctx.ack(); // success — message removed from queue
21
21
  } catch (error) {
22
- await ctx.nack(true); // failure — requeue for redelivery
22
+ await ctx.nack(true); // failure — requeue for redelivery
23
23
  }
24
24
  });
25
25
  ```
@@ -30,7 +30,7 @@ herald()
30
30
  - Handler **throws** → herald **auto-nacks** (requeue, or DLQ/reject once retries are exhausted — see below).
31
31
  - Handler calls `ctx.ack()` / `ctx.nack()` / `ctx.reject()` / `ctx.retry()` → herald respects that and does nothing further.
32
32
 
33
- So the `try/catch` above is optional — letting the error throw produces the same auto-nack. Call `ctx` methods explicitly only when you want a *non-default* outcome (reject without requeue, route to DLQ, delayed retry). The one mode that loses messages is `autoAck: true`, where the broker acks on delivery before your handler runs.
33
+ So the `try/catch` above is optional — letting the error throw produces the same auto-nack. Call `ctx` methods explicitly only when you want a _non-default_ outcome (reject without requeue, route to DLQ, delayed retry). The one mode that loses messages is `autoAck: true`, where the broker acks on delivery before your handler runs.
34
34
 
35
35
  ## Message context — flow control
36
36
 
@@ -44,23 +44,23 @@ ctx.reply(payload); // for request-response pattern (see request-and-respond
44
44
 
45
45
  Pick by intent:
46
46
 
47
- | Intent | Use |
48
- | --- | --- |
49
- | Processed cleanly | `ctx.ack()` |
50
- | Transient failure, try again | `ctx.nack(true)` or `ctx.retry(5000)` |
51
- | Permanent failure, send to DLQ | `ctx.nack(false)` or `ctx.reject()` |
52
- | Validation failure (bad message) | `ctx.reject()` — don't requeue |
47
+ | Intent | Use |
48
+ | -------------------------------- | ------------------------------------- |
49
+ | Processed cleanly | `ctx.ack()` |
50
+ | Transient failure, try again | `ctx.nack(true)` or `ctx.retry(5000)` |
51
+ | Permanent failure, send to DLQ | `ctx.nack(false)` or `ctx.reject()` |
52
+ | Validation failure (bad message) | `ctx.reject()` — don't requeue |
53
53
 
54
54
  ## Subscribe options
55
55
 
56
56
  ```ts
57
57
  await channel.subscribe(handler, {
58
- group: "email-workers", // consumer group / tag — multiple consumers share work
59
- prefetch: 10, // concurrency — how many in-flight messages this consumer holds
60
- autoAck: false, // default; keep it false in production
61
- exclusive: false, // single consumer only on this channel?
58
+ group: "email-workers", // consumer group / tag — multiple consumers share work
59
+ prefetch: 10, // concurrency — how many in-flight messages this consumer holds
60
+ autoAck: false, // default; keep it false in production
61
+ exclusive: false, // single consumer only on this channel?
62
62
  retry: {
63
- maxRetries: 3, // redelivery ceiling on handler throw (delay not auto-applied — see below)
63
+ maxRetries: 3, // redelivery ceiling on handler throw (delay not auto-applied — see below)
64
64
  delay: 1000,
65
65
  },
66
66
  deadLetter: {
@@ -101,10 +101,12 @@ The DLQ always forwards the full original payload plus the message metadata, so
101
101
  Messages that exhausted retries land in `user.created.failed`. Subscribe to it separately for alerting / manual inspection:
102
102
 
103
103
  ```ts
104
- herald().channel("user.created.failed").subscribe(async (message, ctx) => {
105
- await alerts.notify(`Failed: ${JSON.stringify(message.payload)}`);
106
- await ctx.ack();
107
- });
104
+ herald()
105
+ .channel("user.created.failed")
106
+ .subscribe(async (message, ctx) => {
107
+ await alerts.notify(`Failed: ${JSON.stringify(message.payload)}`);
108
+ await ctx.ack();
109
+ });
108
110
  ```
109
111
 
110
112
  ## Decorator-style consumers — `@Consumable` + `EventConsumer`
@@ -115,7 +117,7 @@ For class-based consumers that pair with the `EventMessage` (the `publish-messag
115
117
  import { Consumable, EventConsumer } from "@warlock.js/herald";
116
118
  import type { ConsumedEventMessage } from "@warlock.js/herald";
117
119
 
118
- @Consumable() // or @Consumable({ broker: "analytics" }) to target a non-default broker
120
+ @Consumable() // or @Consumable({ broker: "analytics" }) to target a non-default broker
119
121
  export class UserCreatedConsumer extends EventConsumer<{ id: number; email: string }> {
120
122
  public static eventName = "user.created";
121
123
 
@@ -167,7 +169,7 @@ export class UserCreatedConsumer extends EventConsumer {
167
169
  import { defineConsumer } from "@warlock.js/herald";
168
170
 
169
171
  export const userCreatedConsumer = defineConsumer<{ id: number; email: string }>("user.created", {
170
- schema: userCreatedSchema, // optional seal validation
172
+ schema: userCreatedSchema, // optional seal validation
171
173
  handle: async (payload, event) => {
172
174
  await sendWelcomeEmail(payload.email);
173
175
  },
@@ -183,11 +185,11 @@ export const userCreatedConsumer = defineConsumer<{ id: number; email: string }>
183
185
  ```ts
184
186
  const subscription = await channel.subscribe(handler);
185
187
 
186
- subscription.id; // the consumer id (string)
187
- subscription.isActive(); // boolean
188
+ subscription.id; // the consumer id (string)
189
+ subscription.isActive(); // boolean
188
190
 
189
- await subscription.unsubscribe(); // cancel the consumer on the broker
190
- await subscription.pause(); // also cancels the consumer (RabbitMQ has no native pause)
191
+ await subscription.unsubscribe(); // cancel the consumer on the broker
192
+ await subscription.pause(); // also cancels the consumer (RabbitMQ has no native pause)
191
193
  ```
192
194
 
193
195
  On the RabbitMQ driver, `pause()` and `unsubscribe()` both cancel the consumer; `resume()` is **not supported and throws** — create a fresh subscription to start consuming again. You can also cancel by id from the channel: `await channel.unsubscribeById(consumerId)`, or drop every consumer on the channel with `await channel.stopConsuming()`.
@@ -198,10 +200,10 @@ The channel exposes queue-management helpers beyond pub/sub:
198
200
 
199
201
  ```ts
200
202
  const { messageCount, consumerCount } = await channel.stats(); // queue depth + live consumers
201
- const purged = await channel.purge(); // drop all pending messages, returns the count
202
- const ok = await channel.exists(); // does the queue exist on the broker?
203
- await channel.assert(); // create the queue with its options (idempotent)
204
- await channel.delete(); // remove the queue entirely
203
+ const purged = await channel.purge(); // drop all pending messages, returns the count
204
+ const ok = await channel.exists(); // does the queue exist on the broker?
205
+ await channel.assert(); // create the queue with its options (idempotent)
206
+ await channel.delete(); // remove the queue entirely
205
207
  ```
206
208
 
207
209
  `assert()` runs lazily on the first `publish` / `subscribe`, so you rarely call it directly — reach for it only to pre-create a queue before any traffic.
@@ -73,20 +73,20 @@ await connectToBroker({
73
73
  host: process.env.ANALYTICS_HOST,
74
74
  });
75
75
 
76
- herald().channel("emails").publish({ /* ... */ }); // → notifications
77
- herald("analytics").channel("events").publish({ /* ... */ }); // → analytics
76
+ herald().channel("emails").publish({/* ... */}); // → notifications
77
+ herald("analytics").channel("events").publish({/* ... */}); // → analytics
78
78
  ```
79
79
 
80
80
  `connectToBroker` defaults `isDefault` to `true`, and the registry promotes the most-recently-registered default. So when you register more than one broker, mark the secondaries `isDefault: false` — otherwise the last one wins and `herald()` returns the wrong broker.
81
81
 
82
82
  ## Pick a skill
83
83
 
84
- | If the task is about… | Load |
85
- | --- | --- |
86
- | Publishing messages — single + batch + publish options (priority, ttl, delay, persistent, headers) | the `publish-message` topic |
87
- | Subscribing to messages — handler signature, message context (ack/nack/retry), prefetch, retry policy, dead-letter | the `consume-message` topic |
88
- | Request/response (RPC) — `channel.request(...)` + `channel.respond(...)` for synchronous-style calls over a message bus | the `request-and-respond` topic |
89
- | Schema-validated channels — `.channel(name, { schema })` with `@warlock.js/seal` | See the `seal-basics` topic of the `warlock-js-seal` skill + skills below |
84
+ | If the task is about… | Load |
85
+ | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
86
+ | Publishing messages — single + batch + publish options (priority, ttl, delay, persistent, headers) | the `publish-message` topic |
87
+ | Subscribing to messages — handler signature, message context (ack/nack/retry), prefetch, retry policy, dead-letter | the `consume-message` topic |
88
+ | Request/response (RPC) — `channel.request(...)` + `channel.respond(...)` for synchronous-style calls over a message bus | the `request-and-respond` topic |
89
+ | Schema-validated channels — `.channel(name, { schema })` with `@warlock.js/seal` | See the `seal-basics` topic of the `warlock-js-seal` skill + skills below |
90
90
 
91
91
  ## Things NOT to do
92
92