@warlock.js/herald 5.30.0 → 5.32.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 (67) hide show
  1. package/CHANGELOG.md +15 -2
  2. package/README.md +17 -16
  3. package/cjs/index.cjs +4 -3
  4. package/cjs/index.cjs.map +1 -1
  5. package/esm/communicators/broker-registry.d.mts +4 -3
  6. package/esm/communicators/broker-registry.d.mts.map +1 -1
  7. package/esm/communicators/broker.d.mts +5 -3
  8. package/esm/communicators/broker.d.mts.map +1 -1
  9. package/esm/communicators/index.d.mts +2 -1
  10. package/esm/communicators/index.mjs +1 -1
  11. package/esm/contracts/broker-driver.contract.d.mts +2 -2
  12. package/esm/contracts/broker-driver.contract.d.mts.map +1 -1
  13. package/esm/contracts/channel.contract.d.mts +2 -2
  14. package/esm/contracts/channel.contract.d.mts.map +1 -1
  15. package/esm/contracts/index.d.mts +2 -1
  16. package/esm/decorators/consumable.d.mts +3 -5
  17. package/esm/decorators/consumable.d.mts.map +1 -1
  18. package/esm/decorators/index.d.mts +2 -1
  19. package/esm/decorators/index.mjs +1 -1
  20. package/esm/drivers/index.d.mts +3 -1
  21. package/esm/drivers/index.mjs +1 -1
  22. package/esm/drivers/rabbitmq/index.d.mts +2 -1
  23. package/esm/drivers/rabbitmq/index.mjs +1 -1
  24. package/esm/drivers/rabbitmq/rabbitmq-channel.d.mts +3 -2
  25. package/esm/drivers/rabbitmq/rabbitmq-channel.d.mts.map +1 -1
  26. package/esm/drivers/rabbitmq/rabbitmq-channel.mjs +4 -3
  27. package/esm/drivers/rabbitmq/rabbitmq-channel.mjs.map +1 -1
  28. package/esm/drivers/rabbitmq/rabbitmq-driver.d.mts +3 -2
  29. package/esm/drivers/rabbitmq/rabbitmq-driver.d.mts.map +1 -1
  30. package/esm/drivers/rabbitmq/rabbitmq-driver.mjs.map +1 -1
  31. package/esm/index.d.mts +7 -0
  32. package/esm/message-managers/event-consumer.d.mts +3 -4
  33. package/esm/message-managers/event-consumer.d.mts.map +1 -1
  34. package/esm/message-managers/event-message.d.mts +3 -4
  35. package/esm/message-managers/event-message.d.mts.map +1 -1
  36. package/esm/message-managers/index.d.mts +2 -1
  37. package/esm/message-managers/index.mjs +1 -1
  38. package/esm/message-managers/types.d.mts +3 -3
  39. package/esm/message-managers/types.d.mts.map +1 -1
  40. package/esm/types/channel.types.d.mts +2 -4
  41. package/esm/types/channel.types.d.mts.map +1 -1
  42. package/esm/types/connection.types.d.mts +8 -9
  43. package/esm/types/connection.types.d.mts.map +1 -1
  44. package/esm/types/driver.types.d.mts +4 -5
  45. package/esm/types/driver.types.d.mts.map +1 -1
  46. package/esm/types/index.d.mts +2 -1
  47. package/esm/types/message.types.d.mts +6 -7
  48. package/esm/types/message.types.d.mts.map +1 -1
  49. package/esm/types/publish.types.d.mts +2 -3
  50. package/esm/types/publish.types.d.mts.map +1 -1
  51. package/esm/types/registry.types.d.mts +2 -4
  52. package/esm/types/registry.types.d.mts.map +1 -1
  53. package/esm/types/subscribe.types.d.mts +3 -4
  54. package/esm/types/subscribe.types.d.mts.map +1 -1
  55. package/esm/use-case-broadcast.d.mts +2 -3
  56. package/esm/use-case-broadcast.d.mts.map +1 -1
  57. package/esm/utils/connect-to-broker.d.mts +9 -6
  58. package/esm/utils/connect-to-broker.d.mts.map +1 -1
  59. package/esm/utils/index.d.mts +2 -1
  60. package/esm/utils/index.mjs +1 -1
  61. package/llms-full.txt +62 -57
  62. package/package.json +3 -3
  63. package/skills/consume-message/SKILL.md +30 -28
  64. package/skills/herald-basics/SKILL.md +8 -8
  65. package/skills/index.md +4 -1
  66. package/skills/publish-message/SKILL.md +19 -16
  67. package/skills/request-and-respond/SKILL.md +5 -5
@@ -1,9 +1,9 @@
1
1
  //#region ../../packages/herald/src/types/connection.types.d.ts
2
- type BaseConnectionOptions = {
2
+ export type BaseConnectionOptions = {
3
3
  name?: string;
4
4
  isDefault?: boolean;
5
5
  };
6
- type RabbitMQSocketOptions = {
6
+ export type RabbitMQSocketOptions = {
7
7
  keepAlive?: boolean | number;
8
8
  noDelay?: boolean;
9
9
  timeout?: number;
@@ -14,13 +14,13 @@ type RabbitMQSocketOptions = {
14
14
  servername?: string;
15
15
  rejectUnauthorized?: boolean;
16
16
  };
17
- type RabbitMQClientOptions = {
17
+ export type RabbitMQClientOptions = {
18
18
  frameMax?: number;
19
19
  channelMax?: number;
20
20
  locale?: string;
21
21
  socket?: RabbitMQSocketOptions;
22
22
  };
23
- type RabbitMQConnectionOptions<TClientOptions extends RabbitMQClientOptions = RabbitMQClientOptions> = BaseConnectionOptions & {
23
+ export type RabbitMQConnectionOptions<TClientOptions extends RabbitMQClientOptions = RabbitMQClientOptions> = BaseConnectionOptions & {
24
24
  driver: "rabbitmq";
25
25
  host?: string;
26
26
  port?: number;
@@ -35,7 +35,7 @@ type RabbitMQConnectionOptions<TClientOptions extends RabbitMQClientOptions = Ra
35
35
  prefetch?: number;
36
36
  clientOptions?: TClientOptions;
37
37
  };
38
- type KafkaClientOptions = {
38
+ export type KafkaClientOptions = {
39
39
  retry?: {
40
40
  initialRetryTime?: number;
41
41
  retries?: number;
@@ -46,7 +46,7 @@ type KafkaClientOptions = {
46
46
  logLevel?: number;
47
47
  logCreator?: any;
48
48
  };
49
- type KafkaConnectionOptions<TClientOptions extends KafkaClientOptions = KafkaClientOptions> = BaseConnectionOptions & {
49
+ export type KafkaConnectionOptions<TClientOptions extends KafkaClientOptions = KafkaClientOptions> = BaseConnectionOptions & {
50
50
  driver: "kafka";
51
51
  brokers: string[];
52
52
  clientId?: string;
@@ -60,8 +60,7 @@ type KafkaConnectionOptions<TClientOptions extends KafkaClientOptions = KafkaCli
60
60
  };
61
61
  clientOptions?: TClientOptions;
62
62
  };
63
- type ConnectionOptions = RabbitMQConnectionOptions | KafkaConnectionOptions;
64
- type BrokerConfigurations<TClientOptions = any> = RabbitMQConnectionOptions<TClientOptions extends RabbitMQClientOptions ? TClientOptions : RabbitMQClientOptions> | KafkaConnectionOptions<TClientOptions extends KafkaClientOptions ? TClientOptions : KafkaClientOptions>;
63
+ export type ConnectionOptions = RabbitMQConnectionOptions | KafkaConnectionOptions;
64
+ export type BrokerConfigurations<TClientOptions = any> = RabbitMQConnectionOptions<TClientOptions extends RabbitMQClientOptions ? TClientOptions : RabbitMQClientOptions> | KafkaConnectionOptions<TClientOptions extends KafkaClientOptions ? TClientOptions : KafkaClientOptions>;
65
65
  //#endregion
66
- export { BaseConnectionOptions, BrokerConfigurations, ConnectionOptions, KafkaClientOptions, KafkaConnectionOptions, RabbitMQClientOptions, RabbitMQConnectionOptions, RabbitMQSocketOptions };
67
66
  //# sourceMappingURL=connection.types.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"connection.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/connection.types.ts"],"mappings":";YAAY;EACV;EACA;;YAGU;EACV;EACA;EACA;EACA,cAAc,SAAS,eAAe;EACtC,gBAAgB;EAChB,eAAe;EACf;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA,SAAS;;YAGC,0BACV,uBAAuB,wBAAwB,yBAC7C;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,gBAAgB;;YAGN;EACV;IACE;IACA;IACA;IACA;IACA;;EAEF;EACA;;YAGU,uBAAuB,uBAAuB,qBAAqB,sBAC7E;EACE;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;;EAEF,gBAAgB;;YAGR,oBAAoB,4BAA4B;YAEhD,qBAAqB,wBAC7B,0BACE,uBAAuB,wBAAwB,iBAAiB,yBAElE,uBACE,uBAAuB,qBAAqB,iBAAiB"}
@@ -1,13 +1,12 @@
1
1
  //#region ../../packages/herald/src/types/driver.types.d.ts
2
- type BrokerDriverType = "rabbitmq" | "kafka" | "redis-streams" | "sqs";
3
- type BrokerEvent = "connected" | "disconnected" | "error" | "reconnecting";
4
- type BrokerEventListener = (...args: unknown[]) => void;
5
- type HealthCheckResult = {
2
+ export type BrokerDriverType = "rabbitmq" | "kafka" | "redis-streams" | "sqs";
3
+ export type BrokerEvent = "connected" | "disconnected" | "error" | "reconnecting";
4
+ export type BrokerEventListener = (...args: unknown[]) => void;
5
+ export type HealthCheckResult = {
6
6
  healthy: boolean;
7
7
  latency?: number;
8
8
  error?: string;
9
9
  details?: Record<string, unknown>;
10
10
  };
11
11
  //#endregion
12
- export { BrokerDriverType, BrokerEvent, BrokerEventListener, HealthCheckResult };
13
12
  //# sourceMappingURL=driver.types.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"driver.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/driver.types.ts"],"mappings":";YAAY;YAEA;YAEA,0BAA0B;YAE1B;EACV;EACA;EACA;EACA,UAAU"}
@@ -4,4 +4,5 @@ import { BaseConnectionOptions, BrokerConfigurations, ConnectionOptions, KafkaCl
4
4
  import { BrokerDriverType, BrokerEvent, BrokerEventListener, HealthCheckResult } from "./driver.types.mjs";
5
5
  import { Message, MessageContext, MessageHandler, MessageMetadata, ResponseHandler, Subscription } from "./message.types.mjs";
6
6
  import { PublishOptions, RequestOptions } from "./publish.types.mjs";
7
- import { BrokerRegistryEvent, BrokerRegistryListener } from "./registry.types.mjs";
7
+ import { BrokerRegistryEvent, BrokerRegistryListener } from "./registry.types.mjs";
8
+ export { BaseConnectionOptions, BrokerConfigurations, BrokerDriverType, BrokerEvent, BrokerEventListener, BrokerRegistryEvent, BrokerRegistryListener, ChannelOptions, ChannelStats, ConnectionOptions, DeadLetterOptions, HealthCheckResult, KafkaClientOptions, KafkaConnectionOptions, Message, MessageContext, MessageHandler, MessageMetadata, PublishOptions, RabbitMQClientOptions, RabbitMQConnectionOptions, RabbitMQSocketOptions, RequestOptions, ResponseHandler, RetryOptions, SubscribeOptions, Subscription };
@@ -1,5 +1,5 @@
1
1
  //#region ../../packages/herald/src/types/message.types.d.ts
2
- type MessageMetadata = {
2
+ export type MessageMetadata = {
3
3
  messageId: string;
4
4
  correlationId?: string;
5
5
  replyTo?: string;
@@ -9,19 +9,19 @@ type MessageMetadata = {
9
9
  retryCount?: number;
10
10
  originalChannel?: string;
11
11
  };
12
- type Message<TPayload = unknown> = {
12
+ export type Message<TPayload = unknown> = {
13
13
  readonly metadata: MessageMetadata;
14
14
  readonly payload: TPayload;
15
15
  readonly raw?: unknown;
16
16
  };
17
- type MessageContext = {
17
+ export type MessageContext = {
18
18
  ack(): Promise<void>;
19
19
  nack(requeue?: boolean): Promise<void>;
20
20
  reject(): Promise<void>;
21
21
  reply<T>(payload: T): Promise<void>;
22
22
  retry(delay?: number): Promise<void>;
23
23
  };
24
- type Subscription = {
24
+ export type Subscription = {
25
25
  readonly id: string;
26
26
  readonly channel: string;
27
27
  readonly consumerTag?: string;
@@ -30,8 +30,7 @@ type Subscription = {
30
30
  resume(): Promise<void>;
31
31
  isActive(): boolean;
32
32
  };
33
- type MessageHandler<TPayload = unknown> = (message: Message<TPayload>, ctx: MessageContext) => Promise<void> | void;
34
- type ResponseHandler<TPayload = unknown, TResponse = unknown> = (message: Message<TPayload>, ctx: MessageContext) => Promise<TResponse> | TResponse;
33
+ export type MessageHandler<TPayload = unknown> = (message: Message<TPayload>, ctx: MessageContext) => Promise<void> | void;
34
+ export type ResponseHandler<TPayload = unknown, TResponse = unknown> = (message: Message<TPayload>, ctx: MessageContext) => Promise<TResponse> | TResponse;
35
35
  //#endregion
36
- export { Message, MessageContext, MessageHandler, MessageMetadata, ResponseHandler, Subscription };
37
36
  //# sourceMappingURL=message.types.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"message.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/message.types.ts"],"mappings":";YAAY;EACV;EACA;EACA;EACA;EACA,WAAW;EACX,UAAU;EACV;EACA;;YAGU,QAAQ;WACT,UAAU;WACV,SAAS;WACT;;YAGC;EACV,OAAO;EACP,KAAK,oBAAoB;EACzB,UAAU;EACV,MAAM,GAAG,SAAS,IAAI;EACtB,MAAM,iBAAiB;;YAGb;WACD;WACA;WACA;EACT,eAAe;EACf,SAAS;EACT,UAAU;EACV;;YAGU,eAAe,uBACzB,SAAS,QAAQ,WACjB,KAAK,mBACF;YAEO,gBAAgB,oBAAoB,wBAC9C,SAAS,QAAQ,WACjB,KAAK,mBACF,QAAQ,aAAa"}
@@ -1,5 +1,5 @@
1
1
  //#region ../../packages/herald/src/types/publish.types.d.ts
2
- type PublishOptions = {
2
+ export type PublishOptions = {
3
3
  priority?: number;
4
4
  ttl?: number;
5
5
  delay?: number;
@@ -8,9 +8,8 @@ type PublishOptions = {
8
8
  correlationId?: string;
9
9
  expiration?: number;
10
10
  };
11
- type RequestOptions = PublishOptions & {
11
+ export type RequestOptions = PublishOptions & {
12
12
  timeout?: number;
13
13
  };
14
14
  //#endregion
15
- export { PublishOptions, RequestOptions };
16
15
  //# sourceMappingURL=publish.types.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"publish.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/publish.types.ts"],"mappings":";YAAY;EACV;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;;YAGU,iBAAiB;EAC3B"}
@@ -1,8 +1,6 @@
1
1
  import { Broker } from "../communicators/broker.mjs";
2
-
3
2
  //#region ../../packages/herald/src/types/registry.types.d.ts
4
- type BrokerRegistryEvent = "registered" | "default-registered" | "connected" | "disconnected";
5
- type BrokerRegistryListener = (broker: Broker) => void;
3
+ export type BrokerRegistryEvent = "registered" | "default-registered" | "connected" | "disconnected";
4
+ export type BrokerRegistryListener = (broker: Broker) => void;
6
5
  //#endregion
7
- export { BrokerRegistryEvent, BrokerRegistryListener };
8
6
  //# sourceMappingURL=registry.types.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"registry.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/registry.types.ts"],"mappings":";;YAEY;YAMA,0BAA0B,QAAQ"}
@@ -1,13 +1,13 @@
1
1
  //#region ../../packages/herald/src/types/subscribe.types.d.ts
2
- type RetryOptions = {
2
+ export type RetryOptions = {
3
3
  maxRetries: number;
4
4
  delay: number | ((attempt: number) => number);
5
5
  };
6
- type DeadLetterOptions = {
6
+ export type DeadLetterOptions = {
7
7
  channel: string;
8
8
  preserveOriginal?: boolean;
9
9
  };
10
- type SubscribeOptions = {
10
+ export type SubscribeOptions = {
11
11
  consumerId?: string;
12
12
  group?: string;
13
13
  prefetch?: number;
@@ -17,5 +17,4 @@ type SubscribeOptions = {
17
17
  exclusive?: boolean;
18
18
  };
19
19
  //#endregion
20
- export { DeadLetterOptions, RetryOptions, SubscribeOptions };
21
20
  //# sourceMappingURL=subscribe.types.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"subscribe.types.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/types/subscribe.types.ts"],"mappings":";YAAY;EACV;EACA,kBAAkB;;YAGR;EACV;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,QAAQ;EACR,aAAa;EACb"}
@@ -6,7 +6,7 @@
6
6
  * takes no dependency on `@warlock.js/core`. The shape only needs the fields the
7
7
  * adapter reads (`event` for the channel, `payload` for the body).
8
8
  */
9
- type UseCaseBroadcastEvent = {
9
+ export type UseCaseBroadcastEvent = {
10
10
  useCase: string;
11
11
  event: string;
12
12
  id: string;
@@ -31,11 +31,10 @@ type UseCaseBroadcastEvent = {
31
31
  *
32
32
  * @param options - Optional broker name (defaults to the default broker)
33
33
  */
34
- declare function heraldBroadcast(options?: {
34
+ export declare function heraldBroadcast(options?: {
35
35
  broker?: string;
36
36
  }): {
37
37
  broadcast(event: UseCaseBroadcastEvent): Promise<void>;
38
38
  };
39
39
  //#endregion
40
- export { UseCaseBroadcastEvent, heraldBroadcast };
41
40
  //# sourceMappingURL=use-case-broadcast.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"use-case-broadcast.d.mts","names":[],"sources":["../../../../../../../packages/herald/src/use-case-broadcast.ts"],"mappings":";;;;;;;;YASY;EACV;EACA;EACA;EACA,IAAI;EACJ;;;;;;;;;;;;;;;;;;;;wBAqBc,gBAAgB;EAAY;;EAElC,UAAS,OAAQ,wBAAwB"}
@@ -3,7 +3,11 @@ import { ConnectionOptions } from "../types/connection.types.mjs";
3
3
  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
+ import "../contracts/index.mjs";
6
7
  import { Broker } from "../communicators/broker.mjs";
8
+ import "../types/index.mjs";
9
+ import "../communicators/index.mjs";
10
+ import "../message-managers/index.mjs";
7
11
  //#region ../../packages/herald/src/utils/connect-to-broker.d.ts
8
12
  /**
9
13
  * Connect to a message broker and register it.
@@ -58,7 +62,7 @@ import { Broker } from "../communicators/broker.mjs";
58
62
  * herald("analytics").channel("events").publish({ ... });
59
63
  * ```
60
64
  */
61
- declare function connectToBroker(options: ConnectionOptions): Promise<Broker>;
65
+ export declare function connectToBroker(options: ConnectionOptions): Promise<Broker>;
62
66
  /**
63
67
  * Get a broker by name or the default one.
64
68
  *
@@ -87,7 +91,7 @@ declare function connectToBroker(options: ConnectionOptions): Promise<Broker>;
87
91
  * });
88
92
  * ```
89
93
  */
90
- declare function herald(name?: string): Broker;
94
+ export declare function herald(name?: string): Broker;
91
95
  /**
92
96
  * Get channel instance for the given name from default broker.
93
97
  *
@@ -104,7 +108,7 @@ declare function herald(name?: string): Broker;
104
108
  * await channel.publish({ userId: 1 });
105
109
  * ```
106
110
  */
107
- declare function heraldChannel<TPayload = unknown>(name: string, options?: ChannelOptions<TPayload>): ChannelContract<TPayload>;
111
+ export declare function heraldChannel<TPayload = unknown>(name: string, options?: ChannelOptions<TPayload>): ChannelContract<TPayload>;
108
112
  /**
109
113
  * Publish an EventMessage to the default broker.
110
114
  *
@@ -117,7 +121,7 @@ declare function heraldChannel<TPayload = unknown>(name: string, options?: Chann
117
121
  * await publishEvent(new UserUpdatedEvent({ id: 1, name: "John Doe" }));
118
122
  * ```
119
123
  */
120
- declare function publishEvent<TPayload = Record<string, any>>(event: EventMessage<TPayload>): Promise<void>;
124
+ export declare function publishEvent<TPayload = Record<string, any>>(event: EventMessage<TPayload>): Promise<void>;
121
125
  /**
122
126
  * Subscribe an EventConsumer class to the default broker.
123
127
  *
@@ -130,7 +134,6 @@ declare function publishEvent<TPayload = Record<string, any>>(event: EventMessag
130
134
  * await subscribeConsumer(UserUpdatedConsumer);
131
135
  * ```
132
136
  */
133
- declare function subscribeConsumer<TPayload = Record<string, any>>(Consumer: EventConsumerClass<TPayload>): Promise<() => void>;
137
+ export declare function subscribeConsumer<TPayload = Record<string, any>>(Consumer: EventConsumerClass<TPayload>): Promise<() => void>;
134
138
  //#endregion
135
- export { connectToBroker, herald, heraldChannel, publishEvent, subscribeConsumer };
136
139
  //# sourceMappingURL=connect-to-broker.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"connect-to-broker.d.mts","names":[],"sources":["../../../../../../../../packages/herald/src/utils/connect-to-broker.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0DsB,gBAAgB,SAAS,oBAAoB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA6E3D,OAAO,gBAAgB;;;;;;;;;;;;;;;;;wBAoBvB,cAAc,oBAC5B,cACA,UAAU,eAAe,YACxB,gBAAgB;;;;;;;;;;;;;wBAgBG,aAAa,WAAW,qBAAqB,OAAO,aAAa,YAAS;;;;;;;;;;;;;wBAgB1E,kBAAkB,WAAW,qBACjD,UAAU,mBAAmB,YAAS"}
@@ -1 +1,2 @@
1
- import { connectToBroker, herald, heraldChannel, publishEvent, subscribeConsumer } from "./connect-to-broker.mjs";
1
+ import { connectToBroker, herald, heraldChannel, publishEvent, subscribeConsumer } from "./connect-to-broker.mjs";
2
+ export { connectToBroker, herald, heraldChannel, publishEvent, subscribeConsumer };
@@ -1,3 +1,3 @@
1
1
  import { connectToBroker, herald, heraldChannel, publishEvent, subscribeConsumer } from "./connect-to-broker.mjs";
2
2
 
3
- export { };
3
+ export { connectToBroker, herald, heraldChannel, publishEvent, subscribeConsumer };
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,8 +8,8 @@
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.30.0",
12
- "@warlock.js/seal": "5.30.0"
11
+ "@warlock.js/logger": "5.32.0",
12
+ "@warlock.js/seal": "5.32.0"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "author": "hassanzohdy",
39
39
  "license": "MIT",
40
- "version": "5.30.0",
40
+ "version": "5.32.0",
41
41
  "main": "./cjs/index.cjs",
42
42
  "module": "./esm/index.mjs",
43
43
  "types": "./esm/index.d.mts",