@warlock.js/herald 4.0.100

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 (82) hide show
  1. package/README.md +364 -0
  2. package/cjs/communicators/communicator-registry.d.ts +155 -0
  3. package/cjs/communicators/communicator-registry.d.ts.map +1 -0
  4. package/cjs/communicators/communicator-registry.js +206 -0
  5. package/cjs/communicators/communicator-registry.js.map +1 -0
  6. package/cjs/communicators/communicator.d.ts +90 -0
  7. package/cjs/communicators/communicator.d.ts.map +1 -0
  8. package/cjs/communicators/communicator.js +93 -0
  9. package/cjs/communicators/communicator.js.map +1 -0
  10. package/cjs/communicators/index.d.ts +3 -0
  11. package/cjs/communicators/index.d.ts.map +1 -0
  12. package/cjs/contracts/channel.contract.d.ts +175 -0
  13. package/cjs/contracts/channel.contract.d.ts.map +1 -0
  14. package/cjs/contracts/communicator-driver.contract.d.ts +168 -0
  15. package/cjs/contracts/communicator-driver.contract.d.ts.map +1 -0
  16. package/cjs/contracts/index.d.ts +3 -0
  17. package/cjs/contracts/index.d.ts.map +1 -0
  18. package/cjs/drivers/index.d.ts +2 -0
  19. package/cjs/drivers/index.d.ts.map +1 -0
  20. package/cjs/drivers/rabbitmq/index.d.ts +3 -0
  21. package/cjs/drivers/rabbitmq/index.d.ts.map +1 -0
  22. package/cjs/drivers/rabbitmq/rabbitmq-channel.d.ts +70 -0
  23. package/cjs/drivers/rabbitmq/rabbitmq-channel.d.ts.map +1 -0
  24. package/cjs/drivers/rabbitmq/rabbitmq-channel.js +400 -0
  25. package/cjs/drivers/rabbitmq/rabbitmq-channel.js.map +1 -0
  26. package/cjs/drivers/rabbitmq/rabbitmq-driver.d.ts +100 -0
  27. package/cjs/drivers/rabbitmq/rabbitmq-driver.d.ts.map +1 -0
  28. package/cjs/drivers/rabbitmq/rabbitmq-driver.js +299 -0
  29. package/cjs/drivers/rabbitmq/rabbitmq-driver.js.map +1 -0
  30. package/cjs/index.d.ts +45 -0
  31. package/cjs/index.d.ts.map +1 -0
  32. package/cjs/index.js +1 -0
  33. package/cjs/index.js.map +1 -0
  34. package/cjs/types.d.ts +396 -0
  35. package/cjs/types.d.ts.map +1 -0
  36. package/cjs/utils/connect-to-communicator.d.ts +86 -0
  37. package/cjs/utils/connect-to-communicator.d.ts.map +1 -0
  38. package/cjs/utils/connect-to-communicator.js +122 -0
  39. package/cjs/utils/connect-to-communicator.js.map +1 -0
  40. package/cjs/utils/index.d.ts +2 -0
  41. package/cjs/utils/index.d.ts.map +1 -0
  42. package/esm/communicators/communicator-registry.d.ts +155 -0
  43. package/esm/communicators/communicator-registry.d.ts.map +1 -0
  44. package/esm/communicators/communicator-registry.js +206 -0
  45. package/esm/communicators/communicator-registry.js.map +1 -0
  46. package/esm/communicators/communicator.d.ts +90 -0
  47. package/esm/communicators/communicator.d.ts.map +1 -0
  48. package/esm/communicators/communicator.js +93 -0
  49. package/esm/communicators/communicator.js.map +1 -0
  50. package/esm/communicators/index.d.ts +3 -0
  51. package/esm/communicators/index.d.ts.map +1 -0
  52. package/esm/contracts/channel.contract.d.ts +175 -0
  53. package/esm/contracts/channel.contract.d.ts.map +1 -0
  54. package/esm/contracts/communicator-driver.contract.d.ts +168 -0
  55. package/esm/contracts/communicator-driver.contract.d.ts.map +1 -0
  56. package/esm/contracts/index.d.ts +3 -0
  57. package/esm/contracts/index.d.ts.map +1 -0
  58. package/esm/drivers/index.d.ts +2 -0
  59. package/esm/drivers/index.d.ts.map +1 -0
  60. package/esm/drivers/rabbitmq/index.d.ts +3 -0
  61. package/esm/drivers/rabbitmq/index.d.ts.map +1 -0
  62. package/esm/drivers/rabbitmq/rabbitmq-channel.d.ts +70 -0
  63. package/esm/drivers/rabbitmq/rabbitmq-channel.d.ts.map +1 -0
  64. package/esm/drivers/rabbitmq/rabbitmq-channel.js +400 -0
  65. package/esm/drivers/rabbitmq/rabbitmq-channel.js.map +1 -0
  66. package/esm/drivers/rabbitmq/rabbitmq-driver.d.ts +100 -0
  67. package/esm/drivers/rabbitmq/rabbitmq-driver.d.ts.map +1 -0
  68. package/esm/drivers/rabbitmq/rabbitmq-driver.js +299 -0
  69. package/esm/drivers/rabbitmq/rabbitmq-driver.js.map +1 -0
  70. package/esm/index.d.ts +45 -0
  71. package/esm/index.d.ts.map +1 -0
  72. package/esm/index.js +1 -0
  73. package/esm/index.js.map +1 -0
  74. package/esm/types.d.ts +396 -0
  75. package/esm/types.d.ts.map +1 -0
  76. package/esm/utils/connect-to-communicator.d.ts +86 -0
  77. package/esm/utils/connect-to-communicator.d.ts.map +1 -0
  78. package/esm/utils/connect-to-communicator.js +122 -0
  79. package/esm/utils/connect-to-communicator.js.map +1 -0
  80. package/esm/utils/index.d.ts +2 -0
  81. package/esm/utils/index.d.ts.map +1 -0
  82. package/package.json +47 -0
@@ -0,0 +1,175 @@
1
+ import type { ChannelOptions, ChannelStats, MessageHandler, PublishOptions, RequestOptions, ResponseHandler, Subscription, SubscribeOptions } from "../types";
2
+ /**
3
+ * Channel contract - represents a queue (RabbitMQ) or topic (Kafka)
4
+ *
5
+ * Provides a unified pub/sub interface across different message brokers.
6
+ *
7
+ * @template TPayload - The typed payload for messages on this channel
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Get a typed channel
12
+ * const userChannel = communicators().channel<UserPayload>("user.created");
13
+ *
14
+ * // Publish
15
+ * await userChannel.publish({ userId: 1, email: "test@example.com" });
16
+ *
17
+ * // Subscribe
18
+ * userChannel.subscribe(async (message, ctx) => {
19
+ * console.log(message.payload.userId);
20
+ * await ctx.ack();
21
+ * });
22
+ * ```
23
+ */
24
+ export interface ChannelContract<TPayload = unknown> {
25
+ /**
26
+ * Channel name/routing key
27
+ */
28
+ readonly name: string;
29
+ /**
30
+ * Channel options
31
+ */
32
+ readonly options: ChannelOptions<TPayload>;
33
+ /**
34
+ * Publish a message to this channel
35
+ *
36
+ * @param payload - The message payload
37
+ * @param options - Optional publish options
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * await channel.publish({ orderId: 123 });
42
+ *
43
+ * // With options
44
+ * await channel.publish({ orderId: 123 }, {
45
+ * priority: 5,
46
+ * persistent: true,
47
+ * correlationId: "req-123",
48
+ * });
49
+ * ```
50
+ */
51
+ publish(payload: TPayload, options?: PublishOptions): Promise<void>;
52
+ /**
53
+ * Publish multiple messages in a batch
54
+ *
55
+ * More efficient than publishing one by one.
56
+ *
57
+ * @param messages - Array of payloads to publish
58
+ * @param options - Optional publish options (applied to all messages)
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * await channel.publishBatch([
63
+ * { event: "page_view", page: "/home" },
64
+ * { event: "page_view", page: "/products" },
65
+ * ]);
66
+ * ```
67
+ */
68
+ publishBatch(messages: TPayload[], options?: PublishOptions): Promise<void>;
69
+ /**
70
+ * Subscribe to messages on this channel
71
+ *
72
+ * @param handler - Function to handle incoming messages
73
+ * @param options - Optional subscribe options
74
+ * @returns Subscription object for managing the subscription
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const subscription = await channel.subscribe(
79
+ * async (message, ctx) => {
80
+ * await processOrder(message.payload);
81
+ * await ctx.ack();
82
+ * },
83
+ * {
84
+ * prefetch: 10,
85
+ * retry: { maxRetries: 3, delay: 1000 },
86
+ * }
87
+ * );
88
+ *
89
+ * // Later: unsubscribe
90
+ * await subscription.unsubscribe();
91
+ * ```
92
+ */
93
+ subscribe(handler: MessageHandler<TPayload>, options?: SubscribeOptions): Promise<Subscription>;
94
+ /**
95
+ * Request-Response pattern (RPC)
96
+ *
97
+ * Publishes a message and waits for a response.
98
+ *
99
+ * @param payload - The request payload
100
+ * @param options - Request options including timeout
101
+ * @returns Promise resolving to the response
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const result = await channel.request<ProcessResult>(
106
+ * { imageUrl: "https://..." },
107
+ * { timeout: 30000 }
108
+ * );
109
+ * console.log(result.processedUrl);
110
+ * ```
111
+ */
112
+ request<TResponse = unknown>(payload: TPayload, options?: RequestOptions): Promise<TResponse>;
113
+ /**
114
+ * Register a response handler for RPC pattern
115
+ *
116
+ * The return value of the handler becomes the response.
117
+ *
118
+ * @param handler - Function to handle requests and return responses
119
+ * @returns Subscription for managing the responder
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * channel.respond(async (message, ctx) => {
124
+ * const result = await processImage(message.payload);
125
+ * return { processedUrl: result.url };
126
+ * });
127
+ * ```
128
+ */
129
+ respond<TResponse = unknown>(handler: ResponseHandler<TPayload, TResponse>): Promise<Subscription>;
130
+ /**
131
+ * Get channel statistics
132
+ *
133
+ * @returns Channel stats including message count and consumer count
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const stats = await channel.stats();
138
+ * console.log(`Messages: ${stats.messageCount}, Consumers: ${stats.consumerCount}`);
139
+ * ```
140
+ */
141
+ stats(): Promise<ChannelStats>;
142
+ /**
143
+ * Purge all messages from the channel
144
+ *
145
+ * Use with caution - this deletes all pending messages.
146
+ *
147
+ * @returns Number of messages purged
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * const purgedCount = await channel.purge();
152
+ * console.log(`Purged ${purgedCount} messages`);
153
+ * ```
154
+ */
155
+ purge(): Promise<number>;
156
+ /**
157
+ * Check if the channel exists
158
+ *
159
+ * @returns True if the channel exists on the broker
160
+ */
161
+ exists(): Promise<boolean>;
162
+ /**
163
+ * Delete the channel
164
+ *
165
+ * Use with caution - this removes the queue/topic entirely.
166
+ */
167
+ delete(): Promise<void>;
168
+ /**
169
+ * Assert/create the channel with its options
170
+ *
171
+ * Creates the channel if it doesn't exist, or verifies options match.
172
+ */
173
+ assert(): Promise<void>;
174
+ }
175
+ //# sourceMappingURL=channel.contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/channel.contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EAEZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EACjB,MAA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O,CAAC,IAAI,CAAC,CAAC;IAExB;;;;OAIG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB"}
@@ -0,0 +1,168 @@
1
+ import type { ChannelContract } from "./channel.contract";
2
+ import type { ChannelOptions, CommunicatorEvent, CommunicatorEventListener, CommunicatorDriverType, HealthCheckResult } from "../types";
3
+ /**
4
+ * Communicator Driver Contract
5
+ *
6
+ * Base contract for all message bus drivers (RabbitMQ, Kafka, etc.)
7
+ * Similar to DriverContract in @warlock.js/cascade
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Driver implementation
12
+ * class RabbitMQDriver implements CommunicatorDriverContract {
13
+ * readonly name = "rabbitmq";
14
+ * // ...
15
+ * }
16
+ * ```
17
+ */
18
+ export interface CommunicatorDriverContract {
19
+ /**
20
+ * Driver name identifier
21
+ *
22
+ * @example "rabbitmq", "kafka", "redis-streams"
23
+ */
24
+ readonly name: CommunicatorDriverType;
25
+ /**
26
+ * Whether currently connected to the message broker
27
+ */
28
+ readonly isConnected: boolean;
29
+ /**
30
+ * Establish connection to the message broker
31
+ *
32
+ * @throws Error if connection fails
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * await driver.connect();
37
+ * console.log("Connected to RabbitMQ");
38
+ * ```
39
+ */
40
+ connect(): Promise<void>;
41
+ /**
42
+ * Close connection gracefully
43
+ *
44
+ * Ensures all pending operations complete before disconnecting.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * await driver.disconnect();
49
+ * ```
50
+ */
51
+ disconnect(): Promise<void>;
52
+ /**
53
+ * Register event listeners for driver lifecycle events
54
+ *
55
+ * @param event - Event name to listen for
56
+ * @param listener - Callback function
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * driver.on("connected", () => {
61
+ * console.log("Connected to broker");
62
+ * });
63
+ *
64
+ * driver.on("disconnected", () => {
65
+ * console.log("Disconnected from broker");
66
+ * });
67
+ *
68
+ * driver.on("error", (error) => {
69
+ * console.error("Driver error:", error);
70
+ * });
71
+ *
72
+ * driver.on("reconnecting", (attempt) => {
73
+ * console.log(`Reconnection attempt ${attempt}`);
74
+ * });
75
+ * ```
76
+ */
77
+ on(event: CommunicatorEvent, listener: CommunicatorEventListener): void;
78
+ /**
79
+ * Remove an event listener
80
+ *
81
+ * @param event - Event name
82
+ * @param listener - Callback to remove
83
+ */
84
+ off(event: CommunicatorEvent, listener: CommunicatorEventListener): void;
85
+ /**
86
+ * Get or create a channel
87
+ *
88
+ * Channels are lazy-created and cached for reuse.
89
+ *
90
+ * @param name - Channel/queue/topic name
91
+ * @param options - Channel configuration
92
+ * @returns Channel instance
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * // Simple channel
97
+ * const channel = driver.channel("user.created");
98
+ *
99
+ * // With options
100
+ * const orderChannel = driver.channel("orders", {
101
+ * durable: true,
102
+ * deadLetter: { channel: "orders.failed" },
103
+ * });
104
+ *
105
+ * // Typed channel
106
+ * const typedChannel = driver.channel<OrderPayload>("orders", {
107
+ * schema: OrderSchema,
108
+ * });
109
+ * ```
110
+ */
111
+ channel<TPayload = unknown>(name: string, options?: ChannelOptions<TPayload>): ChannelContract<TPayload>;
112
+ /**
113
+ * Start consuming messages from all subscribed channels
114
+ *
115
+ * Call this after setting up all subscriptions to begin processing.
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * // Set up subscriptions
120
+ * channel1.subscribe(handler1);
121
+ * channel2.subscribe(handler2);
122
+ *
123
+ * // Start consuming
124
+ * await driver.startConsuming();
125
+ * ```
126
+ */
127
+ startConsuming(): Promise<void>;
128
+ /**
129
+ * Stop consuming messages gracefully
130
+ *
131
+ * Waits for currently processing messages to complete.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * await driver.stopConsuming();
136
+ * ```
137
+ */
138
+ stopConsuming(): Promise<void>;
139
+ /**
140
+ * Perform a health check on the connection
141
+ *
142
+ * @returns Health check result with status and optional latency
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * const health = await driver.healthCheck();
147
+ * if (health.healthy) {
148
+ * console.log(`Healthy, latency: ${health.latency}ms`);
149
+ * } else {
150
+ * console.error(`Unhealthy: ${health.error}`);
151
+ * }
152
+ * ```
153
+ */
154
+ healthCheck(): Promise<HealthCheckResult>;
155
+ /**
156
+ * Get list of all channels managed by this driver
157
+ *
158
+ * @returns Array of channel names
159
+ */
160
+ getChannelNames(): string[];
161
+ /**
162
+ * Close and remove a specific channel
163
+ *
164
+ * @param name - Channel name to close
165
+ */
166
+ closeChannel(name: string): Promise<void>;
167
+ }
168
+ //# sourceMappingURL=communicator-driver.contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"communicator-driver.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/communicator-driver.contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAE9B;;;;;;;;;;OAUG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;;;;;;;;OASG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAExE;;;;;OAKG;IACH,GAAG,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAEzE;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,QAAQ,GAAG,OAAO,EACxB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,GACjC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAE7B;;;;;;;;;;;;;;OAcG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhC;;;;;;;;;OASG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/B;;;;;;;;;;;;;;OAcG;IACH,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE1C;;;;OAIG;IACH,eAAe,IAAI,MAAM,EAAE,CAAC;IAE5B;;;;OAIG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C"}
@@ -0,0 +1,3 @@
1
+ export * from "./channel.contract";
2
+ export * from "./communicator-driver.contract";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./rabbitmq";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drivers/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./rabbitmq-driver";
2
+ export * from "./rabbitmq-channel";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/drivers/rabbitmq/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,70 @@
1
+ import type { ChannelContract } from "../../contracts";
2
+ import type { ChannelOptions, ChannelStats, MessageHandler, PublishOptions, RequestOptions, ResponseHandler, SubscribeOptions, Subscription } from "../../types";
3
+ /**
4
+ * RabbitMQ Channel Implementation
5
+ *
6
+ * Wraps a RabbitMQ queue/exchange with a unified API.
7
+ *
8
+ * @template TPayload - The typed payload
9
+ */
10
+ export declare class RabbitMQChannel<TPayload = unknown> implements ChannelContract<TPayload> {
11
+ readonly name: string;
12
+ readonly options: ChannelOptions<TPayload>;
13
+ private readonly amqpChannel;
14
+ private readonly subscriptions;
15
+ private asserted;
16
+ /**
17
+ * Create a new RabbitMQ channel
18
+ */
19
+ constructor(name: string, amqpChannel: any, options?: ChannelOptions<TPayload>);
20
+ /**
21
+ * Assert the queue exists
22
+ */
23
+ assert(): Promise<void>;
24
+ /**
25
+ * Publish a message
26
+ */
27
+ publish(payload: TPayload, options?: PublishOptions): Promise<void>;
28
+ /**
29
+ * Publish multiple messages
30
+ */
31
+ publishBatch(messages: TPayload[], options?: PublishOptions): Promise<void>;
32
+ /**
33
+ * Subscribe to messages
34
+ *
35
+ * Smart auto-ack behavior (when autoAck is not true):
36
+ * - If handler completes successfully without explicit ack/nack/reject → auto-ack
37
+ * - If handler throws an error → auto-nack (with retry if configured)
38
+ * - If handler explicitly calls ack/nack/reject → respects that call
39
+ */
40
+ subscribe(handler: MessageHandler<TPayload>, options?: SubscribeOptions): Promise<Subscription>;
41
+ /**
42
+ * Send message to dead-letter queue
43
+ */
44
+ private sendToDeadLetter;
45
+ /**
46
+ * Request-response pattern
47
+ */
48
+ request<TResponse = unknown>(payload: TPayload, options?: RequestOptions): Promise<TResponse>;
49
+ /**
50
+ * Register response handler for RPC
51
+ */
52
+ respond<TResponse = unknown>(handler: ResponseHandler<TPayload, TResponse>): Promise<Subscription>;
53
+ /**
54
+ * Get queue statistics
55
+ */
56
+ stats(): Promise<ChannelStats>;
57
+ /**
58
+ * Purge all messages
59
+ */
60
+ purge(): Promise<number>;
61
+ /**
62
+ * Check if queue exists
63
+ */
64
+ exists(): Promise<boolean>;
65
+ /**
66
+ * Delete the queue
67
+ */
68
+ delete(): Promise<void>;
69
+ }
70
+ //# sourceMappingURL=rabbitmq-channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rabbitmq-channel.d.ts","sourceRoot":"","sources":["../../../src/drivers/rabbitmq/rabbitmq-channel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EAGZ,cAAc,EAEd,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,YAAY,EACb,MAAM,aAAa,CAAC;AAErB;;;;;;GAMG;AACH,qBAAa,eAAe,CAAC,QAAQ,GAAG,OAAO,CAAE,YAAW,eAAe,CAAC,QAAQ,CAAC;IACnF,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,OAAO,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAElD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAM;IAClC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA2C;IACzE,OAAO,CAAC,QAAQ,CAAS;IAEzB;;OAEG;gBACgB,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC;IAMrF;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBpC;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAkDhF;;OAEG;IACU,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxF;;;;;;;OAOG;IACU,SAAS,CACpB,OAAO,EAAE,cAAc,CAAC,QAAQ,CAAC,EACjC,OAAO,CAAC,EAAE,gBAAgB,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