@geekmidas/events 10.0.0-alpha.15 → 10.0.0-alpha.151

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 (84) hide show
  1. package/README.md +46 -1
  2. package/dist/{SQSSubscriber-BXLE_1L3.mjs → SQSSubscriber-BEJBfNTe.mjs} +94 -10
  3. package/dist/SQSSubscriber-BEJBfNTe.mjs.map +1 -0
  4. package/dist/{SQSSubscriber-DtRUaZB3.cjs → SQSSubscriber-COTqWvOk.cjs} +101 -10
  5. package/dist/SQSSubscriber-COTqWvOk.cjs.map +1 -0
  6. package/dist/basic/index.cjs +35 -4
  7. package/dist/basic/index.cjs.map +1 -1
  8. package/dist/basic/index.d.cts +8 -1
  9. package/dist/basic/index.d.cts.map +1 -1
  10. package/dist/basic/index.d.mts +8 -1
  11. package/dist/basic/index.d.mts.map +1 -1
  12. package/dist/basic/index.mjs +35 -5
  13. package/dist/basic/index.mjs.map +1 -1
  14. package/dist/index.cjs +45 -142
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +80 -20
  17. package/dist/index.d.cts.map +1 -1
  18. package/dist/index.d.mts +80 -20
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +33 -141
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/pgboss/index.cjs +121 -34
  23. package/dist/pgboss/index.cjs.map +1 -1
  24. package/dist/pgboss/index.d.cts +45 -4
  25. package/dist/pgboss/index.d.cts.map +1 -1
  26. package/dist/pgboss/index.d.mts +45 -4
  27. package/dist/pgboss/index.d.mts.map +1 -1
  28. package/dist/pgboss/index.mjs +119 -34
  29. package/dist/pgboss/index.mjs.map +1 -1
  30. package/dist/rabbitmq/index.cjs +60 -27
  31. package/dist/rabbitmq/index.cjs.map +1 -1
  32. package/dist/rabbitmq/index.d.cts +9 -1
  33. package/dist/rabbitmq/index.d.cts.map +1 -1
  34. package/dist/rabbitmq/index.d.mts +9 -1
  35. package/dist/rabbitmq/index.d.mts.map +1 -1
  36. package/dist/rabbitmq/index.mjs +61 -27
  37. package/dist/rabbitmq/index.mjs.map +1 -1
  38. package/dist/{types-gGaoT8qc.d.cts → registry-DIx25Q5s.d.cts} +108 -2
  39. package/dist/registry-DIx25Q5s.d.cts.map +1 -0
  40. package/dist/{types-gGaoT8qc.d.mts → registry-DIx25Q5s.d.mts} +108 -2
  41. package/dist/registry-DIx25Q5s.d.mts.map +1 -0
  42. package/dist/registry-DXLY1Xf6.mjs +99 -0
  43. package/dist/registry-DXLY1Xf6.mjs.map +1 -0
  44. package/dist/registry-DlT36229.cjs +122 -0
  45. package/dist/registry-DlT36229.cjs.map +1 -0
  46. package/dist/sns/index.cjs +425 -11
  47. package/dist/sns/index.cjs.map +1 -1
  48. package/dist/sns/index.d.cts +255 -8
  49. package/dist/sns/index.d.cts.map +1 -1
  50. package/dist/sns/index.d.mts +255 -8
  51. package/dist/sns/index.d.mts.map +1 -1
  52. package/dist/sns/index.mjs +410 -12
  53. package/dist/sns/index.mjs.map +1 -1
  54. package/dist/sns/snsUrl.d.cts.map +1 -1
  55. package/dist/sns/snsUrl.d.mts.map +1 -1
  56. package/dist/sqs/index.cjs +22 -66
  57. package/dist/sqs/index.cjs.map +1 -1
  58. package/dist/sqs/index.d.cts +10 -1
  59. package/dist/sqs/index.d.cts.map +1 -1
  60. package/dist/sqs/index.d.mts +10 -1
  61. package/dist/sqs/index.d.mts.map +1 -1
  62. package/dist/sqs/index.mjs +20 -63
  63. package/dist/sqs/index.mjs.map +1 -1
  64. package/dist/sqs/sqsUrl.d.cts.map +1 -1
  65. package/dist/sqs/sqsUrl.d.mts.map +1 -1
  66. package/dist/telemetry-DG3l807O.cjs +309 -0
  67. package/dist/telemetry-DG3l807O.cjs.map +1 -0
  68. package/dist/telemetry-DjjgJMul.mjs +244 -0
  69. package/dist/telemetry-DjjgJMul.mjs.map +1 -0
  70. package/package.json +8 -3
  71. package/dist/PgBossConnection-CywKoAZU.cjs +0 -2
  72. package/dist/PgBossConnection-DjoqT84r.mjs +0 -2
  73. package/dist/RabbitMQConnection-C9eccBL8.cjs +0 -2
  74. package/dist/RabbitMQConnection-CAp7VqyT.mjs +0 -2
  75. package/dist/SNSConnection-BWDC1wAF.cjs +0 -2
  76. package/dist/SNSConnection-ezQvVrDv.mjs +0 -2
  77. package/dist/SQSSubscriber-BXLE_1L3.mjs.map +0 -1
  78. package/dist/SQSSubscriber-DtRUaZB3.cjs.map +0 -1
  79. package/dist/types-BcZjLxVV.cjs +0 -51
  80. package/dist/types-BcZjLxVV.cjs.map +0 -1
  81. package/dist/types-Bk5JM6MP.mjs +0 -40
  82. package/dist/types-Bk5JM6MP.mjs.map +0 -1
  83. package/dist/types-gGaoT8qc.d.cts.map +0 -1
  84. package/dist/types-gGaoT8qc.d.mts.map +0 -1
@@ -1,15 +1,35 @@
1
- import { i as EventSubscriber, n as EventPublisher, r as EventPublisherType, s as PublishableMessage, t as EventConnection } from "../types-gGaoT8qc.mjs";
1
+ import { d as EventPublisher, f as EventPublisherType, g as PublishableMessage, p as EventSubscriber, t as EventsDriver, u as EventConnection } from "../registry-DIx25Q5s.mjs";
2
2
  import { PgBoss } from "pg-boss";
3
+ //#region src/pgboss/driver.d.ts
4
+ /**
5
+ * `pgboss://` — queues and topics in Postgres. Register it with
6
+ * `registerEventsDriver(pgbossEventsDriver)`; this subpath is the only one
7
+ * that imports `pg-boss`.
8
+ */
9
+ export declare const pgbossEventsDriver: EventsDriver;
10
+ //#endregion
3
11
  //#region src/pgboss/errors.d.ts
4
12
  /** pg-boss connected but its instance never started. */
5
13
  export declare class PgBossNotStarted extends Error {
6
14
  constructor();
7
15
  }
16
+ /** A topic subscription with no name to give the subscriber's own queue. */
17
+ export declare class PgBossSubscriptionNeedsName extends Error {
18
+ readonly topic: string;
19
+ constructor(topic: string);
20
+ }
8
21
  //#endregion
9
22
  //#region src/pgboss/PgBossConnection.d.ts
10
23
  interface PgBossConnectionConfig {
11
24
  connectionString: string;
12
25
  schema?: string;
26
+ /**
27
+ * Who this connection is to Postgres. Defaults to `GKM_APP_NAME`, which a
28
+ * generated entry sets to the construct it runs — so the broker's
29
+ * connections are named for the process that holds them, as its database
30
+ * pools are, rather than all being `pgboss`.
31
+ */
32
+ applicationName?: string;
13
33
  }
14
34
  export declare class PgBossConnection implements EventConnection {
15
35
  private config;
@@ -33,14 +53,25 @@ export declare class PgBossConnection implements EventConnection {
33
53
  }
34
54
  //#endregion
35
55
  //#region src/pgboss/PgBossPublisher.d.ts
56
+ interface PgBossPublisherOptions {
57
+ /**
58
+ * Publishing to a topic: each message is fanned out to every subscriber's
59
+ * own queue rather than inserted into one shared queue. Without it, a
60
+ * message goes to the queue named by its type — a work queue, one consumer.
61
+ */
62
+ topic?: string;
63
+ }
64
+ /** The pg-boss event a topic's message type is published as. */
65
+ export declare function topicEvent(topic: string, type: string): string;
36
66
  export declare class PgBossPublisher<TMessage extends PublishableMessage<string, any>> implements EventPublisher<TMessage> {
37
67
  private connection;
38
- constructor(connection: PgBossConnection);
68
+ private options;
69
+ constructor(connection: PgBossConnection, options?: PgBossPublisherOptions);
39
70
  /**
40
71
  * Create a PgBossPublisher from a connection string.
41
72
  * Format: pgboss://user:pass@host:5432/database?schema=pgboss
42
73
  */
43
- static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string): Promise<PgBossPublisher<TMessage>>;
74
+ static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string, options?: PgBossPublisherOptions): Promise<PgBossPublisher<TMessage>>;
44
75
  publish(messages: TMessage[]): Promise<void>;
45
76
  close(): Promise<void>;
46
77
  }
@@ -49,6 +80,16 @@ export declare class PgBossPublisher<TMessage extends PublishableMessage<string,
49
80
  interface PgBossSubscriberOptions {
50
81
  batchSize?: number;
51
82
  pollingIntervalSeconds?: number;
83
+ /**
84
+ * Subscribing to a topic. Each subscriber then drains a queue of its own,
85
+ * `<topic>/<subscription>`, bound to the events it names — so every
86
+ * subscriber sees every message, and replicas of one subscriber share it.
87
+ * Without it, messages are drained from the queue named by their type:
88
+ * work shared among whoever drains it.
89
+ */
90
+ topic?: string;
91
+ /** The subscriber's own name on the topic. Required with `topic`. */
92
+ subscription?: string;
52
93
  }
53
94
  export declare class PgBossSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
54
95
  private connection;
@@ -62,5 +103,5 @@ export declare class PgBossSubscriber<TMessage extends PublishableMessage<string
62
103
  subscribe(messages: TMessage['type'][], listener: (payload: TMessage) => Promise<void>): Promise<void>;
63
104
  }
64
105
  //#endregion
65
- export type { PgBossConnectionConfig, PgBossSubscriberOptions };
106
+ export type { PgBossConnectionConfig, PgBossPublisherOptions, PgBossSubscriberOptions };
66
107
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/pgboss/errors.ts","../../src/pgboss/PgBossConnection.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"mappings":";;;;qBAKa,yBAAyB;EAAA;;;;UCDrB;EAChB;EACA;;qBAGY,4BAA4B;UAKpB;WAJX,OAAI,mBAAA;UACL;UACA;EAEY,YAAA,QAAQ;;;;;SAMf,qBACZ,2BACE,QAAQ;EAgBL,WAAW;EA2BX,SAAS;EAUf;UAIQ;;;;MAQJ,YAAY;;;;qBCnFJ,gBAAgB,iBAAiB,4CAClC,eAAe;UAEN;EAAA,YAAA,YAAY;;;;;SAMnB,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,gBAAgB;EAO/C,QAAQ,UAAU,aAAa;EAwB/B,SAAS;;;;UC1CC;EAChB;EACA;;qBAGY,iBAAiB,iBAAiB,4CACnC,gBAAgB;UAGlB;UACA;EADA,YAAA,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,iBAAiB;EAoBhD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/pgboss/driver.ts","../../src/pgboss/errors.ts","../../src/pgboss/PgBossConnection.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"mappings":";;;;;;;;qBAWa,oBAAoB;;;;qBCNpB,yBAAyB;EACrC;;;qBASY,oCAAoC;WAC3B;EAArB,YAAqB;;;;UCZL;EAChB;EACA;;;;;;;EAOA;;qBAGY,4BAA4B;UAKpB;WAJX,OAAI,mBAAA;UACL;UACA;EAER,YAAoB,QAAQ;;;;;SAMf,qBACZ,2BACE,QAAQ;EAgBL,WAAW;EA8BX,SAAS;EAUf;UAIQ;;;;MAQJ,YAAY;;;;UC5FA;;;;;;EAMhB;;;wBAIe,WAAW,eAAe;qBAI7B,gBAAgB,iBAAiB,4CAClC,eAAe;UAGjB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAEjB,0BACA,UAAS,yBACP,QAAQ,gBAAgB;EAOrB,QAAQ,UAAU,aAAa;EAqD/B,SAAS;;;;UC1FC;EAChB;EACA;;;;;;;;EAQA;;EAEA;;qBAGY,iBAAiB,iBAAiB,4CACnC,gBAAgB;UAGlB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,iBAAiB;EAoBhD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
@@ -1,15 +1,8 @@
1
- import "../types-Bk5JM6MP.mjs";
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { a as consumeTraced, c as withTraceKey, l as withoutTraceKey, s as publishTraced } from "../telemetry-DjjgJMul.mjs";
2
3
  import { PgBoss } from "pg-boss";
3
- //#region src/pgboss/errors.ts
4
- /** pg-boss connected but its instance never started. */
5
- var PgBossNotStarted = class extends Error {
6
- constructor() {
7
- super("pg-boss did not start. Check the database in the connection string is reachable and the role may create the pg-boss schema.");
8
- this.name = "PgBossNotStarted";
9
- }
10
- };
11
- //#endregion
12
4
  //#region src/pgboss/PgBossConnection.ts
5
+ var PgBossConnection_exports = /* @__PURE__ */ __exportAll({ PgBossConnection: () => PgBossConnection });
13
6
  var PgBossConnection = class PgBossConnection {
14
7
  config;
15
8
  type = "pgboss";
@@ -41,9 +34,11 @@ var PgBossConnection = class PgBossConnection {
41
34
  }
42
35
  this.connecting = (async () => {
43
36
  try {
37
+ const applicationName = this.config.applicationName ?? process.env.GKM_APP_NAME;
44
38
  const boss = new PgBoss({
45
39
  connectionString: this.config.connectionString,
46
- ...this.config.schema && { schema: this.config.schema }
40
+ ...this.config.schema && { schema: this.config.schema },
41
+ ...applicationName && { application_name: applicationName }
47
42
  });
48
43
  await boss.start();
49
44
  this.boss = boss;
@@ -77,35 +72,79 @@ var PgBossConnection = class PgBossConnection {
77
72
  }
78
73
  };
79
74
  //#endregion
75
+ //#region src/pgboss/errors.ts
76
+ /** pg-boss connected but its instance never started. */
77
+ var PgBossNotStarted = class extends Error {
78
+ constructor() {
79
+ super("pg-boss did not start. Check the database in the connection string is reachable and the role may create the pg-boss schema.");
80
+ this.name = "PgBossNotStarted";
81
+ }
82
+ };
83
+ /** A topic subscription with no name to give the subscriber's own queue. */
84
+ var PgBossSubscriptionNeedsName = class extends Error {
85
+ topic;
86
+ constructor(topic) {
87
+ super(`Subscribing to topic '${topic}' on pg-boss needs a subscription name: each subscriber drains a queue of its own, and that queue is named for it. Pass \`subscription\`.`);
88
+ this.topic = topic;
89
+ this.name = "PgBossSubscriptionNeedsName";
90
+ }
91
+ };
92
+ //#endregion
80
93
  //#region src/pgboss/PgBossPublisher.ts
94
+ /** The pg-boss event a topic's message type is published as. */
95
+ function topicEvent(topic, type) {
96
+ return `${topic}/${type}`;
97
+ }
81
98
  var PgBossPublisher = class PgBossPublisher {
82
99
  connection;
83
- constructor(connection) {
100
+ options;
101
+ constructor(connection, options = {}) {
84
102
  this.connection = connection;
103
+ this.options = options;
85
104
  }
86
105
  /**
87
106
  * Create a PgBossPublisher from a connection string.
88
107
  * Format: pgboss://user:pass@host:5432/database?schema=pgboss
89
108
  */
90
- static async fromConnectionString(connectionString) {
91
- const { PgBossConnection } = await import("../PgBossConnection-DjoqT84r.mjs");
109
+ static async fromConnectionString(connectionString, options = {}) {
110
+ const { PgBossConnection } = await Promise.resolve().then(() => PgBossConnection_exports);
92
111
  const connection = await PgBossConnection.fromConnectionString(connectionString);
93
- return new PgBossPublisher(connection);
112
+ return new PgBossPublisher(connection, options);
94
113
  }
95
114
  async publish(messages) {
96
115
  if (!this.connection.isConnected()) await this.connection.connect();
97
116
  const boss = this.connection.instance;
98
117
  if (!boss) throw new PgBossNotStarted();
99
- const groups = /* @__PURE__ */ new Map();
100
- for (const m of messages) {
101
- const list = groups.get(m.type) ?? [];
102
- list.push({ data: m.payload });
103
- groups.set(m.type, list);
104
- }
105
- for (const [name, jobs] of groups) {
106
- await boss.createQueue(name);
107
- await boss.insert(name, jobs);
118
+ const { topic } = this.options;
119
+ if (topic) {
120
+ await publishTraced(messages, (m) => ({
121
+ system: "pgboss",
122
+ destination: topic,
123
+ type: m.type
124
+ }), async (carriers) => {
125
+ for (const [i, m] of messages.entries()) await boss.publish(topicEvent(topic, m.type), withTraceKey({
126
+ type: m.type,
127
+ payload: m.payload
128
+ }, carriers[i]));
129
+ });
130
+ return;
108
131
  }
132
+ await publishTraced(messages, (m) => ({
133
+ system: "pgboss",
134
+ destination: m.type,
135
+ type: m.type
136
+ }), async (carriers) => {
137
+ const groups = /* @__PURE__ */ new Map();
138
+ for (const [i, m] of messages.entries()) {
139
+ const list = groups.get(m.type) ?? [];
140
+ list.push({ data: withTraceKey(m.payload, carriers[i]) });
141
+ groups.set(m.type, list);
142
+ }
143
+ for (const [name, jobs] of groups) {
144
+ await boss.createQueue(name);
145
+ await boss.insert(name, jobs);
146
+ }
147
+ });
109
148
  }
110
149
  async close() {}
111
150
  };
@@ -124,7 +163,7 @@ var PgBossSubscriber = class PgBossSubscriber {
124
163
  */
125
164
  static async fromConnectionString(connectionString) {
126
165
  const params = new URL(connectionString).searchParams;
127
- const { PgBossConnection } = await import("../PgBossConnection-DjoqT84r.mjs");
166
+ const { PgBossConnection } = await Promise.resolve().then(() => PgBossConnection_exports);
128
167
  const connection = await PgBossConnection.fromConnectionString(connectionString);
129
168
  const options = {
130
169
  batchSize: params.get("batchSize") ? Number.parseInt(params.get("batchSize"), 10) : void 0,
@@ -136,21 +175,67 @@ var PgBossSubscriber = class PgBossSubscriber {
136
175
  if (!this.connection.isConnected()) await this.connection.connect();
137
176
  const boss = this.connection.instance;
138
177
  if (!boss) throw new PgBossNotStarted();
178
+ const work = {
179
+ ...this.options.batchSize && { batchSize: this.options.batchSize },
180
+ ...this.options.pollingIntervalSeconds && { pollingIntervalSeconds: this.options.pollingIntervalSeconds }
181
+ };
182
+ const { topic, subscription } = this.options;
183
+ if (topic) {
184
+ if (!subscription) throw new PgBossSubscriptionNeedsName(topic);
185
+ const queue = topicEvent(topic, subscription);
186
+ await boss.createQueue(queue);
187
+ for (const type of messages) await boss.subscribe(topicEvent(topic, type), queue);
188
+ await boss.work(queue, work, async (jobs) => {
189
+ for (const job of jobs) {
190
+ const { data, carrier } = withoutTraceKey(job.data);
191
+ await consumeTraced({
192
+ system: "pgboss",
193
+ destination: topic,
194
+ type: data.type,
195
+ messageId: job.id
196
+ }, carrier, () => listener({
197
+ type: data.type,
198
+ payload: data.payload
199
+ }));
200
+ }
201
+ });
202
+ return;
203
+ }
139
204
  for (const messageType of messages) {
140
205
  await boss.createQueue(messageType);
141
- await boss.work(messageType, {
142
- ...this.options.batchSize && { batchSize: this.options.batchSize },
143
- ...this.options.pollingIntervalSeconds && { pollingIntervalSeconds: this.options.pollingIntervalSeconds }
144
- }, async (jobs) => {
145
- for (const job of jobs) await listener({
146
- type: job.name,
147
- payload: job.data
148
- });
206
+ await boss.work(messageType, work, async (jobs) => {
207
+ for (const job of jobs) {
208
+ const { data, carrier } = withoutTraceKey(job.data);
209
+ await consumeTraced({
210
+ system: "pgboss",
211
+ destination: messageType,
212
+ type: job.name,
213
+ messageId: job.id
214
+ }, carrier, () => listener({
215
+ type: job.name,
216
+ payload: data
217
+ }));
218
+ }
149
219
  });
150
220
  }
151
221
  }
152
222
  };
153
223
  //#endregion
154
- export { PgBossConnection, PgBossNotStarted, PgBossPublisher, PgBossSubscriber };
224
+ //#region src/pgboss/driver.ts
225
+ /**
226
+ * `pgboss://` — queues and topics in Postgres. Register it with
227
+ * `registerEventsDriver(pgbossEventsDriver)`; this subpath is the only one
228
+ * that imports `pg-boss`.
229
+ */
230
+ const pgbossEventsDriver = {
231
+ scheme: "pgboss",
232
+ connect: (url) => PgBossConnection.fromConnectionString(url),
233
+ publisher: (url, options) => PgBossPublisher.fromConnectionString(url, options),
234
+ publisherFor: (connection, options) => new PgBossPublisher(connection, options),
235
+ subscriber: (url) => PgBossSubscriber.fromConnectionString(url),
236
+ subscriberFor: (connection, options) => new PgBossSubscriber(connection, options)
237
+ };
238
+ //#endregion
239
+ export { PgBossConnection, PgBossNotStarted, PgBossPublisher, PgBossSubscriber, PgBossSubscriptionNeedsName, pgbossEventsDriver, topicEvent };
155
240
 
156
241
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/pgboss/errors.ts","../../src/pgboss/PgBossConnection.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"sourcesContent":["// Beside the adapter but apart from its connection module, which imports\n// the broker's client: the publisher and subscriber load that lazily, and\n// importing an error class from it would load it eagerly.\n\n/** pg-boss connected but its instance never started. */\nexport class PgBossNotStarted extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'pg-boss did not start. Check the database in the connection string is reachable and the role may create the pg-boss schema.',\n\t\t);\n\t\tthis.name = 'PgBossNotStarted';\n\t}\n}\n","import { PgBoss } from 'pg-boss';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface PgBossConnectionConfig {\n\tconnectionString: string;\n\tschema?: string;\n}\n\nexport class PgBossConnection implements EventConnection {\n\treadonly type = EventPublisherType.PgBoss;\n\tprivate boss?: PgBoss;\n\tprivate connecting?: Promise<void>;\n\n\tconstructor(private config: PgBossConnectionConfig) {}\n\n\t/**\n\t * Create a PgBossConnection from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<PgBossConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst postgresUrl = `postgres://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst config: PgBossConnectionConfig = {\n\t\t\tconnectionString: postgresUrl,\n\t\t\tschema: params.get('schema') || undefined,\n\t\t};\n\n\t\tconst connection = new PgBossConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.boss) return;\n\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst boss = new PgBoss({\n\t\t\t\t\tconnectionString: this.config.connectionString,\n\t\t\t\t\t...(this.config.schema && { schema: this.config.schema }),\n\t\t\t\t});\n\n\t\t\t\tawait boss.start();\n\t\t\t\tthis.boss = boss;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.boss?.stop({ graceful: true });\n\t\t} catch {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.boss;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.boss = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying pg-boss instance for publishing/subscribing\n\t */\n\tget instance(): PgBoss | undefined {\n\t\treturn this.boss;\n\t}\n}\n","import type { EventPublisher, PublishableMessage } from '../types';\nimport { PgBossNotStarted } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\n\nexport class PgBossPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(private connection: PgBossConnection) {}\n\n\t/**\n\t * Create a PgBossPublisher from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<PgBossPublisher<TMessage>> {\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\t\treturn new PgBossPublisher<TMessage>(connection);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\t// Group jobs by queue name (v11+ requires per-queue insert calls)\n\t\tconst groups = new Map<string, { data: TMessage['payload'] }[]>();\n\t\tfor (const m of messages) {\n\t\t\tconst list = groups.get(m.type) ?? [];\n\t\t\tlist.push({ data: m.payload });\n\t\t\tgroups.set(m.type, list);\n\t\t}\n\n\t\tfor (const [name, jobs] of groups) {\n\t\t\tawait boss.createQueue(name);\n\t\t\tawait boss.insert(name, jobs);\n\t\t}\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t}\n}\n","import type { EventSubscriber, PublishableMessage } from '../types';\nimport { PgBossNotStarted } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\n\nexport interface PgBossSubscriberOptions {\n\tbatchSize?: number;\n\tpollingIntervalSeconds?: number;\n}\n\nexport class PgBossSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossSubscriber from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss&batchSize=5\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<PgBossSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\n\t\tconst options: PgBossSubscriberOptions = {\n\t\t\tbatchSize: params.get('batchSize')\n\t\t\t\t? Number.parseInt(params.get('batchSize')!, 10)\n\t\t\t\t: undefined,\n\t\t\tpollingIntervalSeconds: params.get('pollingIntervalSeconds')\n\t\t\t\t? Number.parseInt(params.get('pollingIntervalSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new PgBossSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\tfor (const messageType of messages) {\n\t\t\tawait boss.createQueue(messageType);\n\t\t\tawait boss.work(\n\t\t\t\tmessageType,\n\t\t\t\t{\n\t\t\t\t\t...(this.options.batchSize && {\n\t\t\t\t\t\tbatchSize: this.options.batchSize,\n\t\t\t\t\t}),\n\t\t\t\t\t...(this.options.pollingIntervalSeconds && {\n\t\t\t\t\t\tpollingIntervalSeconds: this.options.pollingIntervalSeconds,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tasync (jobs) => {\n\t\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t\tconst fullMessage = {\n\t\t\t\t\t\t\ttype: job.name,\n\t\t\t\t\t\t\tpayload: job.data,\n\t\t\t\t\t\t} as TMessage;\n\n\t\t\t\t\t\tawait listener(fullMessage);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n}\n"],"mappings":";;;;AAKA,IAAa,mBAAb,cAAsC,MAAM;CAC3C,cAAc;EACb,MACC,6HACD;EACA,KAAK,OAAO;CACb;AACD;;;ACHA,IAAa,mBAAb,MAAa,iBAA4C;CAKpC;CAJpB,OAAS;CACT;CACA;CAEA,YAAY,QAAwC;EAAhC,KAAA,SAAA;CAAiC;;;;;CAMrD,aAAa,qBACZ,kBAC4B;EAC5B,MAAM,MAAM,IAAI,IAAI,gBAAgB;EACpC,MAAM,SAAS,IAAI;EAInB,MAAM,SAAiC;GACtC,kBAAkB,cAHe,IAAI,WAAW,GAAG,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,KAAK,IAAI,OAAO,IAAI;GAIzG,QAAQ,OAAO,IAAI,QAAQ,KAAK,KAAA;EACjC;EAEA,MAAM,aAAa,IAAI,iBAAiB,MAAM;EAC9C,MAAM,WAAW,QAAQ;EACzB,OAAO;CACR;CAEA,MAAM,UAAyB;EAC9B,IAAI,KAAK,MAAM;EAEf,IAAI,KAAK,YAAY;GACpB,MAAM,KAAK;GACX;EACD;EAEA,KAAK,cAAc,YAAY;GAC9B,IAAI;IACH,MAAM,OAAO,IAAI,OAAO;KACvB,kBAAkB,KAAK,OAAO;KAC9B,GAAI,KAAK,OAAO,UAAU,EAAE,QAAQ,KAAK,OAAO,OAAO;IACxD,CAAC;IAED,MAAM,KAAK,MAAM;IACjB,KAAK,OAAO;GACb,SAAS,OAAO;IACf,KAAK,QAAQ;IACb,MAAM;GACP;EACD,EAAA,CAAG;EA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A;EACA,KAAA,UAAA;CACN;;;;;CAMH,aAAa,qBAEX,kBAA+D;EAEhE,MAAM,SAAS,IADC,IAAI,gBACH,CAAC,CAAC;EAEnB,MAAM,EAAE,qBAAqB,MAAM,OAAO;EAC1C,MAAM,aACL,MAAM,iBAAiB,qBAAqB,gBAAgB;EAE7D,MAAM,UAAmC;GACxC,WAAW,OAAO,IAAI,WAAW,IAC9B,OAAO,SAAS,OAAO,IAAI,WAAW,GAAI,EAAE,IAC5C,KAAA;GACH,wBAAwB,OAAO,IAAI,wBAAwB,IACxD,OAAO,SAAS,OAAO,IAAI,wBAAwB,GAAI,EAAE,IACzD,KAAA;EACJ;EAEA,OAAO,IAAI,iBAA2B,YAAY,OAAO;CAC1D;CAEA,MAAM,UACL,UACA,UACgB;EAChB,IAAI,CAAC,KAAK,WAAW,YAAY,GAChC,MAAM,KAAK,WAAW,QAAQ;EAG/B,MAAM,OAAO,KAAK,WAAW;EAC7B,IAAI,CAAC,MACJ,MAAM,IAAI,iBAAiB;EAG5B,KAAK,MAAM,eAAe,UAAU;GACnC,MAAM,KAAK,YAAY,WAAW;GAClC,MAAM,KAAK,KACV,aACA;IACC,GAAI,KAAK,QAAQ,aAAa,EAC7B,WAAW,KAAK,QAAQ,UACzB;IACA,GAAI,KAAK,QAAQ,0BAA0B,EAC1C,wBAAwB,KAAK,QAAQ,uBACtC;GACD,GACA,OAAO,SAAS;IACf,KAAK,MAAM,OAAO,MAMjB,MAAM,SAAS;KAJd,MAAM,IAAI;KACV,SAAS,IAAI;IAGW,CAAC;GAE5B,CACD;EACD;CACD;AACD"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/pgboss/PgBossConnection.ts","../../src/pgboss/errors.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts","../../src/pgboss/driver.ts"],"sourcesContent":["import { PgBoss } from 'pg-boss';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface PgBossConnectionConfig {\n\tconnectionString: string;\n\tschema?: string;\n\t/**\n\t * Who this connection is to Postgres. Defaults to `GKM_APP_NAME`, which a\n\t * generated entry sets to the construct it runs — so the broker's\n\t * connections are named for the process that holds them, as its database\n\t * pools are, rather than all being `pgboss`.\n\t */\n\tapplicationName?: string;\n}\n\nexport class PgBossConnection implements EventConnection {\n\treadonly type = EventPublisherType.PgBoss;\n\tprivate boss?: PgBoss;\n\tprivate connecting?: Promise<void>;\n\n\tconstructor(private config: PgBossConnectionConfig) {}\n\n\t/**\n\t * Create a PgBossConnection from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<PgBossConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst postgresUrl = `postgres://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst config: PgBossConnectionConfig = {\n\t\t\tconnectionString: postgresUrl,\n\t\t\tschema: params.get('schema') || undefined,\n\t\t};\n\n\t\tconst connection = new PgBossConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.boss) return;\n\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst applicationName =\n\t\t\t\t\tthis.config.applicationName ?? process.env.GKM_APP_NAME;\n\t\t\t\tconst boss = new PgBoss({\n\t\t\t\t\tconnectionString: this.config.connectionString,\n\t\t\t\t\t...(this.config.schema && { schema: this.config.schema }),\n\t\t\t\t\t...(applicationName && { application_name: applicationName }),\n\t\t\t\t});\n\n\t\t\t\tawait boss.start();\n\t\t\t\tthis.boss = boss;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.boss?.stop({ graceful: true });\n\t\t} catch {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.boss;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.boss = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying pg-boss instance for publishing/subscribing\n\t */\n\tget instance(): PgBoss | undefined {\n\t\treturn this.boss;\n\t}\n}\n","// Beside the adapter but apart from its connection module, which imports\n// the broker's client: the publisher and subscriber load that lazily, and\n// importing an error class from it would load it eagerly.\n\n/** pg-boss connected but its instance never started. */\nexport class PgBossNotStarted extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'pg-boss did not start. Check the database in the connection string is reachable and the role may create the pg-boss schema.',\n\t\t);\n\t\tthis.name = 'PgBossNotStarted';\n\t}\n}\n\n/** A topic subscription with no name to give the subscriber's own queue. */\nexport class PgBossSubscriptionNeedsName extends Error {\n\tconstructor(readonly topic: string) {\n\t\tsuper(\n\t\t\t`Subscribing to topic '${topic}' on pg-boss needs a subscription name: ` +\n\t\t\t\t'each subscriber drains a queue of its own, and that queue is named ' +\n\t\t\t\t'for it. Pass `subscription`.',\n\t\t);\n\t\tthis.name = 'PgBossSubscriptionNeedsName';\n\t}\n}\n","import { publishTraced, withTraceKey } from '../telemetry';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport { PgBossNotStarted } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\n\nexport interface PgBossPublisherOptions {\n\t/**\n\t * Publishing to a topic: each message is fanned out to every subscriber's\n\t * own queue rather than inserted into one shared queue. Without it, a\n\t * message goes to the queue named by its type — a work queue, one consumer.\n\t */\n\ttopic?: string;\n}\n\n/** The pg-boss event a topic's message type is published as. */\nexport function topicEvent(topic: string, type: string): string {\n\treturn `${topic}/${type}`;\n}\n\nexport class PgBossPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossPublisher from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionString: string,\n\t\toptions: PgBossPublisherOptions = {},\n\t): Promise<PgBossPublisher<TMessage>> {\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\t\treturn new PgBossPublisher<TMessage>(connection, options);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\t// A topic: pg-boss copies the job into every queue subscribed to the\n\t\t// event — one per subscriber — so each subscriber sees each message.\n\t\t// The type rides in the data, because the job is named for the queue.\n\t\t//\n\t\t// pg-boss has no header field, so the trace context rides in the data\n\t\t// too, under a reserved key the subscriber removes before the handler.\n\t\tconst { topic } = this.options;\n\t\tif (topic) {\n\t\t\tawait publishTraced(\n\t\t\t\tmessages,\n\t\t\t\t(m) => ({ system: 'pgboss', destination: topic, type: m.type }),\n\t\t\t\tasync (carriers) => {\n\t\t\t\t\tfor (const [i, m] of messages.entries()) {\n\t\t\t\t\t\tawait boss.publish(\n\t\t\t\t\t\t\ttopicEvent(topic, m.type),\n\t\t\t\t\t\t\twithTraceKey({ type: m.type, payload: m.payload }, carriers[i]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tawait publishTraced(\n\t\t\tmessages,\n\t\t\t(m) => ({ system: 'pgboss', destination: m.type, type: m.type }),\n\t\t\tasync (carriers) => {\n\t\t\t\t// Group jobs by queue name (v11+ requires per-queue insert calls)\n\t\t\t\tconst groups = new Map<string, { data: TMessage['payload'] }[]>();\n\t\t\t\tfor (const [i, m] of messages.entries()) {\n\t\t\t\t\tconst list = groups.get(m.type) ?? [];\n\t\t\t\t\tlist.push({ data: withTraceKey(m.payload, carriers[i]) });\n\t\t\t\t\tgroups.set(m.type, list);\n\t\t\t\t}\n\n\t\t\t\tfor (const [name, jobs] of groups) {\n\t\t\t\t\tawait boss.createQueue(name);\n\t\t\t\t\tawait boss.insert(name, jobs);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t}\n}\n","import { consumeTraced, withoutTraceKey } from '../telemetry';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport { PgBossNotStarted, PgBossSubscriptionNeedsName } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\nimport { topicEvent } from './PgBossPublisher';\n\nexport interface PgBossSubscriberOptions {\n\tbatchSize?: number;\n\tpollingIntervalSeconds?: number;\n\t/**\n\t * Subscribing to a topic. Each subscriber then drains a queue of its own,\n\t * `<topic>/<subscription>`, bound to the events it names — so every\n\t * subscriber sees every message, and replicas of one subscriber share it.\n\t * Without it, messages are drained from the queue named by their type:\n\t * work shared among whoever drains it.\n\t */\n\ttopic?: string;\n\t/** The subscriber's own name on the topic. Required with `topic`. */\n\tsubscription?: string;\n}\n\nexport class PgBossSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossSubscriber from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss&batchSize=5\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<PgBossSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\n\t\tconst options: PgBossSubscriberOptions = {\n\t\t\tbatchSize: params.get('batchSize')\n\t\t\t\t? Number.parseInt(params.get('batchSize')!, 10)\n\t\t\t\t: undefined,\n\t\t\tpollingIntervalSeconds: params.get('pollingIntervalSeconds')\n\t\t\t\t? Number.parseInt(params.get('pollingIntervalSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new PgBossSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\tconst work = {\n\t\t\t...(this.options.batchSize && { batchSize: this.options.batchSize }),\n\t\t\t...(this.options.pollingIntervalSeconds && {\n\t\t\t\tpollingIntervalSeconds: this.options.pollingIntervalSeconds,\n\t\t\t}),\n\t\t};\n\n\t\tconst { topic, subscription } = this.options;\n\t\tif (topic) {\n\t\t\tif (!subscription) throw new PgBossSubscriptionNeedsName(topic);\n\n\t\t\tconst queue = topicEvent(topic, subscription);\n\t\t\tawait boss.createQueue(queue);\n\t\t\tfor (const type of messages) {\n\t\t\t\tawait boss.subscribe(topicEvent(topic, type), queue);\n\t\t\t}\n\t\t\tawait boss.work<{ type: string; payload: unknown }>(\n\t\t\t\tqueue,\n\t\t\t\twork,\n\t\t\t\tasync (jobs) => {\n\t\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t\tconst { data, carrier } = withoutTraceKey(job.data);\n\t\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsystem: 'pgboss',\n\t\t\t\t\t\t\t\tdestination: topic,\n\t\t\t\t\t\t\t\ttype: data.type,\n\t\t\t\t\t\t\t\tmessageId: job.id,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcarrier,\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tlistener({\n\t\t\t\t\t\t\t\t\ttype: data.type,\n\t\t\t\t\t\t\t\t\tpayload: data.payload,\n\t\t\t\t\t\t\t\t} as TMessage),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const messageType of messages) {\n\t\t\tawait boss.createQueue(messageType);\n\t\t\tawait boss.work(messageType, work, async (jobs) => {\n\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t// The trace context is taken out of the data here, so the\n\t\t\t\t\t// handler's payload is exactly what was published.\n\t\t\t\t\tconst { data, carrier } = withoutTraceKey(job.data);\n\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsystem: 'pgboss',\n\t\t\t\t\t\t\tdestination: messageType,\n\t\t\t\t\t\t\ttype: job.name,\n\t\t\t\t\t\t\tmessageId: job.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcarrier,\n\t\t\t\t\t\t() => listener({ type: job.name, payload: data } as TMessage),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n","import type { EventsDriver } from '../registry';\nimport { EventPublisherType } from '../types';\nimport { PgBossConnection } from './PgBossConnection';\nimport { PgBossPublisher } from './PgBossPublisher';\nimport { PgBossSubscriber } from './PgBossSubscriber';\n\n/**\n * `pgboss://` — queues and topics in Postgres. Register it with\n * `registerEventsDriver(pgbossEventsDriver)`; this subpath is the only one\n * that imports `pg-boss`.\n */\nexport const pgbossEventsDriver: EventsDriver = {\n\tscheme: EventPublisherType.PgBoss,\n\tconnect: (url) => PgBossConnection.fromConnectionString(url),\n\tpublisher: (url, options) =>\n\t\tPgBossPublisher.fromConnectionString(url, options),\n\tpublisherFor: (connection, options) =>\n\t\tnew PgBossPublisher(connection as PgBossConnection, options),\n\tsubscriber: (url) => PgBossSubscriber.fromConnectionString(url),\n\tsubscriberFor: (connection, options) =>\n\t\tnew PgBossSubscriber(connection as PgBossConnection, options),\n};\n"],"mappings":";;;;;AAgBA,IAAa,mBAAb,MAAa,iBAA4C;CAKpC;CAJpB,OAAS;CACT;CACA;CAEA,YAAY,QAAwC;EAAhC,KAAA,SAAA;CAAiC;;;;;CAMrD,aAAa,qBACZ,kBAC4B;EAC5B,MAAM,MAAM,IAAI,IAAI,gBAAgB;EACpC,MAAM,SAAS,IAAI;EAInB,MAAM,SAAiC;GACtC,kBAAkB,cAHe,IAAI,WAAW,GAAG,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,KAAK,IAAI,OAAO,IAAI;GAIzG,QAAQ,OAAO,IAAI,QAAQ,KAAK,KAAA;EACjC;EAEA,MAAM,aAAa,IAAI,iBAAiB,MAAM;EAC9C,MAAM,WAAW,QAAQ;EACzB,OAAO;CACR;CAEA,MAAM,UAAyB;EAC9B,IAAI,KAAK,MAAM;EAEf,IAAI,KAAK,YAAY;GACpB,MAAM,KAAK;GACX;EACD;EAEA,KAAK,cAAc,YAAY;GAC9B,IAAI;IACH,MAAM,kBACL,KAAK,OAAO,mBAAmB,QAAQ,IAAI;IAC5C,MAAM,OAAO,IAAI,OAAO;KACvB,kBAAkB,KAAK,OAAO;KAC9B,GAAI,KAAK,OAAO,UAAU,EAAE,QAAQ,KAAK,OAAO,OAAO;KACvD,GAAI,mBAAmB,EAAE,kBAAkB,gBAAgB;IAC5D,CAAC;IAED,MAAM,KAAK,MAAM;IACjB,KAAK,OAAO;GACb,SAAS,OAAO;IACf,KAAK,QAAQ;IACb,MAAM;GACP;EACD,EAAA,CAAG;EAEH,MAAM,KAAK;EACX,KA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b,MAAM,IAAI;MACV,WAAW,IAAI;KAChB,GACA,eACM,SAAS;MAAE,MAAM,IAAI;MAAM,SAAS;KAAK,CAAa,CAC7D;IACD;GACD,CAAC;EACF;CACD;AACD;;;;;;;;ACxHA,MAAa,qBAAmC;CAC/C,QAAA;CACA,UAAU,QAAQ,iBAAiB,qBAAqB,GAAG;CAC3D,YAAY,KAAK,YAChB,gBAAgB,qBAAqB,KAAK,OAAO;CAClD,eAAe,YAAY,YAC1B,IAAI,gBAAgB,YAAgC,OAAO;CAC5D,aAAa,QAAQ,iBAAiB,qBAAqB,GAAG;CAC9D,gBAAgB,YAAY,YAC3B,IAAI,iBAAiB,YAAgC,OAAO;AAC9D"}
@@ -1,18 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("../rolldown-runtime-C0BPl7ul.cjs");
3
- require("../types-BcZjLxVV.cjs");
3
+ const require_telemetry = require("../telemetry-DG3l807O.cjs");
4
4
  let amqplib = require("amqplib");
5
5
  amqplib = require_rolldown_runtime.__toESM(amqplib, 1);
6
- //#region src/rabbitmq/errors.ts
7
- /** The connection opened but has no channel to publish or consume on. */
8
- var RabbitMQChannelUnavailable = class extends Error {
9
- constructor() {
10
- super("RabbitMQ connected without a channel. Check the broker is reachable and the connection string names a vhost the user can open channels on.");
11
- this.name = "RabbitMQChannelUnavailable";
12
- }
13
- };
14
- //#endregion
15
6
  //#region src/rabbitmq/RabbitMQConnection.ts
7
+ var RabbitMQConnection_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ RabbitMQConnection: () => RabbitMQConnection });
16
8
  var RabbitMQConnection = class RabbitMQConnection {
17
9
  type = "rabbitmq";
18
10
  connection;
@@ -113,6 +105,15 @@ var RabbitMQConnection = class RabbitMQConnection {
113
105
  }
114
106
  };
115
107
  //#endregion
108
+ //#region src/rabbitmq/errors.ts
109
+ /** The connection opened but has no channel to publish or consume on. */
110
+ var RabbitMQChannelUnavailable = class extends Error {
111
+ constructor() {
112
+ super("RabbitMQ connected without a channel. Check the broker is reachable and the connection string names a vhost the user can open channels on.");
113
+ this.name = "RabbitMQChannelUnavailable";
114
+ }
115
+ };
116
+ //#endregion
116
117
  //#region src/rabbitmq/RabbitMQPublisher.ts
117
118
  var RabbitMQPublisher = class RabbitMQPublisher {
118
119
  connection;
@@ -126,7 +127,7 @@ var RabbitMQPublisher = class RabbitMQPublisher {
126
127
  * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&timeout=5000
127
128
  */
128
129
  static async fromConnectionString(connectionString) {
129
- const { RabbitMQConnection } = await Promise.resolve().then(() => require("../RabbitMQConnection-C9eccBL8.cjs"));
130
+ const { RabbitMQConnection } = await Promise.resolve().then(() => RabbitMQConnection_exports);
130
131
  const connection = await RabbitMQConnection.fromConnectionString(connectionString);
131
132
  return new RabbitMQPublisher(connection);
132
133
  }
@@ -135,17 +136,27 @@ var RabbitMQPublisher = class RabbitMQPublisher {
135
136
  const channel = this.connection.amqpChannel;
136
137
  if (!channel) throw new RabbitMQChannelUnavailable();
137
138
  const exchange = this.connection.exchangeName;
138
- for (const message of messages) {
139
- const content = Buffer.from(JSON.stringify(message.payload));
140
- const routingKey = message.type;
141
- if (!channel.publish(exchange, routingKey, content, {
142
- contentType: "application/json",
143
- timestamp: Date.now(),
144
- type: message.type,
145
- persistent: true,
146
- ...this.options.publishOptions
147
- })) await new Promise((resolve) => channel.once("drain", resolve));
148
- }
139
+ await require_telemetry.publishTraced(messages, (message) => ({
140
+ system: "rabbitmq",
141
+ destination: exchange,
142
+ type: message.type
143
+ }), async (carriers) => {
144
+ for (const [i, message] of messages.entries()) {
145
+ const content = Buffer.from(JSON.stringify(message.payload));
146
+ const { headers, ...publishOptions } = this.options.publishOptions ?? {};
147
+ if (!channel.publish(exchange, message.type, content, {
148
+ contentType: "application/json",
149
+ timestamp: Date.now(),
150
+ type: message.type,
151
+ persistent: true,
152
+ ...publishOptions,
153
+ ...(headers || carriers[i]) && { headers: {
154
+ ...headers,
155
+ ...carriers[i]
156
+ } }
157
+ })) await new Promise((resolve) => channel.once("drain", resolve));
158
+ }
159
+ });
149
160
  }
150
161
  async close() {}
151
162
  };
@@ -164,7 +175,7 @@ var RabbitMQSubscriber = class RabbitMQSubscriber {
164
175
  */
165
176
  static async fromConnectionString(connectionString) {
166
177
  const params = new URL(connectionString).searchParams;
167
- const { RabbitMQConnection } = await Promise.resolve().then(() => require("../RabbitMQConnection-C9eccBL8.cjs"));
178
+ const { RabbitMQConnection } = await Promise.resolve().then(() => RabbitMQConnection_exports);
168
179
  const connection = await RabbitMQConnection.fromConnectionString(connectionString);
169
180
  const options = {
170
181
  queueName: params.get("queueName") || void 0,
@@ -190,10 +201,17 @@ var RabbitMQSubscriber = class RabbitMQSubscriber {
190
201
  try {
191
202
  const content = msg.content.toString();
192
203
  const payload = JSON.parse(content);
193
- await listener({
194
- type: msg.properties.type,
204
+ const messageType = msg.properties.type;
205
+ const fullMessage = {
206
+ type: messageType,
195
207
  payload
196
- });
208
+ };
209
+ await require_telemetry.consumeTraced({
210
+ system: "rabbitmq",
211
+ destination: queue,
212
+ type: messageType,
213
+ messageId: msg.properties.messageId
214
+ }, require_telemetry.carrierFromAttributes(msg.properties.headers), () => listener(fullMessage));
197
215
  channel.ack(msg);
198
216
  } catch (_error) {
199
217
  channel.nack(msg, false, true);
@@ -202,10 +220,25 @@ var RabbitMQSubscriber = class RabbitMQSubscriber {
202
220
  }
203
221
  };
204
222
  //#endregion
223
+ //#region src/rabbitmq/driver.ts
224
+ /**
225
+ * `rabbitmq://` — an AMQP exchange. Register it with
226
+ * `registerEventsDriver(rabbitmqEventsDriver)`; this subpath is the only one
227
+ * that imports `amqplib`.
228
+ */
229
+ const rabbitmqEventsDriver = {
230
+ scheme: "rabbitmq",
231
+ connect: (url) => RabbitMQConnection.fromConnectionString(url),
232
+ publisher: (url) => RabbitMQPublisher.fromConnectionString(url),
233
+ publisherFor: (connection) => new RabbitMQPublisher(connection),
234
+ subscriber: (url) => RabbitMQSubscriber.fromConnectionString(url),
235
+ subscriberFor: (connection) => new RabbitMQSubscriber(connection)
236
+ };
237
+ //#endregion
205
238
  exports.RabbitMQChannelUnavailable = RabbitMQChannelUnavailable;
206
239
  exports.RabbitMQConnection = RabbitMQConnection;
207
- exports.RabbitMQConnection$1 = RabbitMQConnection;
208
240
  exports.RabbitMQPublisher = RabbitMQPublisher;
209
241
  exports.RabbitMQSubscriber = RabbitMQSubscriber;
242
+ exports.rabbitmqEventsDriver = rabbitmqEventsDriver;
210
243
 
211
244
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/rabbitmq/errors.ts","../../src/rabbitmq/RabbitMQConnection.ts","../../src/rabbitmq/RabbitMQPublisher.ts","../../src/rabbitmq/RabbitMQSubscriber.ts"],"sourcesContent":["// Beside the adapter but apart from its connection module, which imports\n// the broker's client: the publisher and subscriber load that lazily, and\n// importing an error class from it would load it eagerly.\n\n/** The connection opened but has no channel to publish or consume on. */\nexport class RabbitMQChannelUnavailable extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'RabbitMQ connected without a channel. Check the broker is reachable and the connection string names a vhost the user can open channels on.',\n\t\t);\n\t\tthis.name = 'RabbitMQChannelUnavailable';\n\t}\n}\n","import amqplib from 'amqplib';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface RabbitMQConnectionConfig {\n\turl: string;\n\texchange?: string;\n\texchangeType?: 'topic' | 'direct' | 'fanout' | 'headers';\n\texchangeOptions?: amqplib.Options.AssertExchange;\n\ttimeout?: number; // Connection timeout in milliseconds (default: 5000)\n}\n\nexport class RabbitMQConnection implements EventConnection {\n\treadonly type = EventPublisherType.RabbitMQ;\n\tprivate connection?: amqplib.ChannelModel;\n\tprivate channel?: amqplib.Channel;\n\tprivate connecting?: Promise<void>;\n\tprivate config: Required<\n\t\tPick<RabbitMQConnectionConfig, 'exchange' | 'exchangeType' | 'timeout'>\n\t> &\n\t\tRabbitMQConnectionConfig;\n\n\tconstructor(config: RabbitMQConnectionConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\texchange: config.exchange || 'geekmidas.events',\n\t\t\texchangeType: config.exchangeType || 'topic',\n\t\t\ttimeout: config.timeout ?? 5000,\n\t\t\texchangeOptions: {\n\t\t\t\tdurable: true,\n\t\t\t\t...config.exchangeOptions,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Create a RabbitMQConnection from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&timeout=5000\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<RabbitMQConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\t// Extract connection URL without query params\n\t\tconst baseUrl = `amqp://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst timeoutParam = params.get('timeout');\n\t\tconst config: RabbitMQConnectionConfig = {\n\t\t\turl: baseUrl,\n\t\t\texchange: params.get('exchange') || 'geekmidas.events',\n\t\t\texchangeType: (params.get('type') as any) || 'topic',\n\t\t\ttimeout: timeoutParam ? Number.parseInt(timeoutParam, 10) : undefined,\n\t\t};\n\n\t\tconst connection = new RabbitMQConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.channel) return;\n\n\t\t// Prevent multiple simultaneous connection attempts\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst connection = await amqplib.connect(this.config.url, {\n\t\t\t\t\ttimeout: this.config.timeout,\n\t\t\t\t});\n\t\t\t\tconst channel = await connection.createChannel();\n\n\t\t\t\t// Assert the exchange exists\n\t\t\t\tawait channel.assertExchange(\n\t\t\t\t\tthis.config.exchange!,\n\t\t\t\t\tthis.config.exchangeType!,\n\t\t\t\t\tthis.config.exchangeOptions,\n\t\t\t\t);\n\n\t\t\t\t// Handle connection errors\n\t\t\t\tconnection.on('error', (_err: Error) => {\n\t\t\t\t\tthis.cleanup();\n\t\t\t\t});\n\n\t\t\t\tconnection.on('close', () => {\n\t\t\t\t\tthis.cleanup();\n\t\t\t\t});\n\n\t\t\t\t// Only set after successful setup\n\t\t\t\tthis.connection = connection;\n\t\t\t\tthis.channel = channel;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.channel?.close();\n\t\t\tawait this.connection?.close();\n\t\t} catch (_error) {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.channel;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.channel = undefined;\n\t\tthis.connection = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying channel for publishing/subscribing\n\t */\n\tget amqpChannel(): amqplib.Channel | undefined {\n\t\treturn this.channel;\n\t}\n\n\t/**\n\t * Get the exchange name for this connection\n\t */\n\tget exchangeName(): string {\n\t\treturn this.config.exchange;\n\t}\n\n\t/**\n\t * Get the exchange type for this connection\n\t */\n\tget exchangeType(): string {\n\t\treturn this.config.exchangeType;\n\t}\n}\n","import type amqplib from 'amqplib';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport { RabbitMQChannelUnavailable } from './errors';\nimport type { RabbitMQConnection } from './RabbitMQConnection';\n\nexport interface RabbitMQPublisherOptions {\n\tpublishOptions?: amqplib.Options.Publish;\n}\n\nexport class RabbitMQPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: RabbitMQConnection,\n\t\tprivate options: RabbitMQPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create a RabbitMQPublisher from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&timeout=5000\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<RabbitMQPublisher<TMessage>> {\n\t\tconst { RabbitMQConnection } = await import('./RabbitMQConnection');\n\t\tconst connection =\n\t\t\tawait RabbitMQConnection.fromConnectionString(connectionString);\n\t\treturn new RabbitMQPublisher<TMessage>(connection);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst channel = this.connection.amqpChannel;\n\t\tif (!channel) {\n\t\t\tthrow new RabbitMQChannelUnavailable();\n\t\t}\n\n\t\tconst exchange = this.connection.exchangeName;\n\n\t\tfor (const message of messages) {\n\t\t\tconst content = Buffer.from(JSON.stringify(message.payload));\n\n\t\t\t// Use message type as routing key for topic exchanges\n\t\t\tconst routingKey = message.type;\n\n\t\t\tconst published = channel.publish(exchange, routingKey, content, {\n\t\t\t\tcontentType: 'application/json',\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\ttype: message.type,\n\t\t\t\tpersistent: true,\n\t\t\t\t...this.options.publishOptions,\n\t\t\t});\n\n\t\t\t// Handle backpressure\n\t\t\tif (!published) {\n\t\t\t\tawait new Promise((resolve) => channel.once('drain', resolve));\n\t\t\t}\n\t\t}\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t\t// Connection should be closed by whoever created it\n\t}\n}\n","import type amqplib from 'amqplib';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport { RabbitMQChannelUnavailable } from './errors';\nimport type { RabbitMQConnection } from './RabbitMQConnection';\n\nexport interface RabbitMQSubscriberOptions {\n\tqueueName?: string; // If not provided, a unique queue will be generated\n\tqueueOptions?: amqplib.Options.AssertQueue;\n\tconsumeOptions?: amqplib.Options.Consume;\n\tprefetch?: number; // Number of messages to prefetch (default: 1)\n}\n\nexport class RabbitMQSubscriber<\n\tTMessage extends PublishableMessage<string, any>,\n> implements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: RabbitMQConnection,\n\t\tprivate options: RabbitMQSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a RabbitMQSubscriber from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&queueName=myqueue&prefetch=10\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<RabbitMQSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { RabbitMQConnection } = await import('./RabbitMQConnection');\n\t\tconst connection =\n\t\t\tawait RabbitMQConnection.fromConnectionString(connectionString);\n\n\t\tconst options: RabbitMQSubscriberOptions = {\n\t\t\tqueueName: params.get('queueName') || undefined,\n\t\t\tprefetch: params.get('prefetch')\n\t\t\t\t? Number.parseInt(params.get('prefetch')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new RabbitMQSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst channel = this.connection.amqpChannel;\n\t\tif (!channel) {\n\t\t\tthrow new RabbitMQChannelUnavailable();\n\t\t}\n\n\t\tconst exchange = this.connection.exchangeName;\n\n\t\t// Set prefetch if specified\n\t\tif (this.options.prefetch) {\n\t\t\tawait channel.prefetch(this.options.prefetch);\n\t\t}\n\n\t\t// Assert queue\n\t\tconst queueName = this.options.queueName || '';\n\t\tconst queueOptions: amqplib.Options.AssertQueue = {\n\t\t\tdurable: true,\n\t\t\t...this.options.queueOptions,\n\t\t};\n\n\t\tconst { queue } = await channel.assertQueue(queueName, queueOptions);\n\n\t\t// Bind queue to exchange for each message type\n\t\tfor (const messageType of messages) {\n\t\t\tawait channel.bindQueue(queue, exchange, messageType);\n\t\t}\n\n\t\t// Consume messages\n\t\tawait channel.consume(\n\t\t\tqueue,\n\t\t\tasync (msg) => {\n\t\t\t\tif (!msg) return;\n\n\t\t\t\ttry {\n\t\t\t\t\t// Parse message payload\n\t\t\t\t\tconst content = msg.content.toString();\n\t\t\t\t\tconst payload = JSON.parse(content);\n\n\t\t\t\t\t// Get message type from properties\n\t\t\t\t\tconst messageType = msg.properties.type;\n\n\t\t\t\t\t// Reconstruct full message\n\t\t\t\t\tconst fullMessage: TMessage = {\n\t\t\t\t\t\ttype: messageType,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t} as TMessage;\n\n\t\t\t\t\t// Call listener\n\t\t\t\t\tawait listener(fullMessage);\n\n\t\t\t\t\t// Ack message\n\t\t\t\t\tchannel.ack(msg);\n\t\t\t\t} catch (_error) {\n\t\t\t\t\tchannel.nack(msg, false, true);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.options.consumeOptions,\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;AAKA,IAAa,6BAAb,cAAgD,MAAM;CACrD,cAAc;EACb,MACC,4IACD;EACA,KAAK,OAAO;CACb;AACD;;;ACAA,IAAa,qBAAb,MAAa,mBAA8C;CAC1D,OAAS;CACT;CACA;CACA;CACA;CAKA,YAAY,QAAkC;EAC7C,KAAK,SAAS;GACb,GAAG;GACH,UAAU,OAAO,YAAY;GAC7B,cAAc,OAAO,gBAAgB;GACrC,SAAS,OAAO,WAAW;GAC3B,iBAAiB;IAChB,SAAS;IACT,GAAG,OAAO;GACX;EACD;CACD;;;;;CAMA,aAAa,qBACZ,kBAC8B;EAC9B,MAAM,MAAM,IAAI,IAAI,gBAAgB;EACpC,MAAM,SAAS,IAAI;EAGnB,MAAM,UAAU,UAAU,IAAI,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CACD;AACD"}
1
+ {"version":3,"file":"index.cjs","names":["publishTraced","consumeTraced","carrierFromAttributes"],"sources":["../../src/rabbitmq/RabbitMQConnection.ts","../../src/rabbitmq/errors.ts","../../src/rabbitmq/RabbitMQPublisher.ts","../../src/rabbitmq/RabbitMQSubscriber.ts","../../src/rabbitmq/driver.ts"],"sourcesContent":["import amqplib from 'amqplib';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface RabbitMQConnectionConfig {\n\turl: string;\n\texchange?: string;\n\texchangeType?: 'topic' | 'direct' | 'fanout' | 'headers';\n\texchangeOptions?: amqplib.Options.AssertExchange;\n\ttimeout?: number; // Connection timeout in milliseconds (default: 5000)\n}\n\nexport class RabbitMQConnection implements EventConnection {\n\treadonly type = EventPublisherType.RabbitMQ;\n\tprivate connection?: amqplib.ChannelModel;\n\tprivate channel?: amqplib.Channel;\n\tprivate connecting?: Promise<void>;\n\tprivate config: Required<\n\t\tPick<RabbitMQConnectionConfig, 'exchange' | 'exchangeType' | 'timeout'>\n\t> &\n\t\tRabbitMQConnectionConfig;\n\n\tconstructor(config: RabbitMQConnectionConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\texchange: config.exchange || 'geekmidas.events',\n\t\t\texchangeType: config.exchangeType || 'topic',\n\t\t\ttimeout: config.timeout ?? 5000,\n\t\t\texchangeOptions: {\n\t\t\t\tdurable: true,\n\t\t\t\t...config.exchangeOptions,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Create a RabbitMQConnection from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&timeout=5000\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<RabbitMQConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\t// Extract connection URL without query params\n\t\tconst baseUrl = `amqp://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst timeoutParam = params.get('timeout');\n\t\tconst config: RabbitMQConnectionConfig = {\n\t\t\turl: baseUrl,\n\t\t\texchange: params.get('exchange') || 'geekmidas.events',\n\t\t\texchangeType: (params.get('type') as any) || 'topic',\n\t\t\ttimeout: timeoutParam ? Number.parseInt(timeoutParam, 10) : undefined,\n\t\t};\n\n\t\tconst connection = new RabbitMQConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.channel) return;\n\n\t\t// Prevent multiple simultaneous connection attempts\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst connection = await amqplib.connect(this.config.url, {\n\t\t\t\t\ttimeout: this.config.timeout,\n\t\t\t\t});\n\t\t\t\tconst channel = await connection.createChannel();\n\n\t\t\t\t// Assert the exchange exists\n\t\t\t\tawait channel.assertExchange(\n\t\t\t\t\tthis.config.exchange!,\n\t\t\t\t\tthis.config.exchangeType!,\n\t\t\t\t\tthis.config.exchangeOptions,\n\t\t\t\t);\n\n\t\t\t\t// Handle connection errors\n\t\t\t\tconnection.on('error', (_err: Error) => {\n\t\t\t\t\tthis.cleanup();\n\t\t\t\t});\n\n\t\t\t\tconnection.on('close', () => {\n\t\t\t\t\tthis.cleanup();\n\t\t\t\t});\n\n\t\t\t\t// Only set after successful setup\n\t\t\t\tthis.connection = connection;\n\t\t\t\tthis.channel = channel;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.channel?.close();\n\t\t\tawait this.connection?.close();\n\t\t} catch (_error) {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.channel;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.channel = undefined;\n\t\tthis.connection = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying channel for publishing/subscribing\n\t */\n\tget amqpChannel(): amqplib.Channel | undefined {\n\t\treturn this.channel;\n\t}\n\n\t/**\n\t * Get the exchange name for this connection\n\t */\n\tget exchangeName(): string {\n\t\treturn this.config.exchange;\n\t}\n\n\t/**\n\t * Get the exchange type for this connection\n\t */\n\tget exchangeType(): string {\n\t\treturn this.config.exchangeType;\n\t}\n}\n","// Beside the adapter but apart from its connection module, which imports\n// the broker's client: the publisher and subscriber load that lazily, and\n// importing an error class from it would load it eagerly.\n\n/** The connection opened but has no channel to publish or consume on. */\nexport class RabbitMQChannelUnavailable extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'RabbitMQ connected without a channel. Check the broker is reachable and the connection string names a vhost the user can open channels on.',\n\t\t);\n\t\tthis.name = 'RabbitMQChannelUnavailable';\n\t}\n}\n","import type amqplib from 'amqplib';\nimport { publishTraced } from '../telemetry';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport { RabbitMQChannelUnavailable } from './errors';\nimport type { RabbitMQConnection } from './RabbitMQConnection';\n\nexport interface RabbitMQPublisherOptions {\n\tpublishOptions?: amqplib.Options.Publish;\n}\n\nexport class RabbitMQPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: RabbitMQConnection,\n\t\tprivate options: RabbitMQPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create a RabbitMQPublisher from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&timeout=5000\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<RabbitMQPublisher<TMessage>> {\n\t\tconst { RabbitMQConnection } = await import('./RabbitMQConnection');\n\t\tconst connection =\n\t\t\tawait RabbitMQConnection.fromConnectionString(connectionString);\n\t\treturn new RabbitMQPublisher<TMessage>(connection);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst channel = this.connection.amqpChannel;\n\t\tif (!channel) {\n\t\t\tthrow new RabbitMQChannelUnavailable();\n\t\t}\n\n\t\tconst exchange = this.connection.exchangeName;\n\n\t\tawait publishTraced(\n\t\t\tmessages,\n\t\t\t(message) => ({\n\t\t\t\tsystem: 'rabbitmq',\n\t\t\t\tdestination: exchange,\n\t\t\t\ttype: message.type,\n\t\t\t}),\n\t\t\tasync (carriers) => {\n\t\t\t\tfor (const [i, message] of messages.entries()) {\n\t\t\t\t\tconst content = Buffer.from(JSON.stringify(message.payload));\n\t\t\t\t\tconst { headers, ...publishOptions } =\n\t\t\t\t\t\tthis.options.publishOptions ?? {};\n\n\t\t\t\t\t// Use message type as routing key for topic exchanges; the trace\n\t\t\t\t\t// context goes in the message's headers.\n\t\t\t\t\tconst published = channel.publish(exchange, message.type, content, {\n\t\t\t\t\t\tcontentType: 'application/json',\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\ttype: message.type,\n\t\t\t\t\t\tpersistent: true,\n\t\t\t\t\t\t...publishOptions,\n\t\t\t\t\t\t...((headers || carriers[i]) && {\n\t\t\t\t\t\t\theaders: { ...headers, ...carriers[i] },\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\t// Handle backpressure\n\t\t\t\t\tif (!published) {\n\t\t\t\t\t\tawait new Promise((resolve) => channel.once('drain', resolve));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t\t// Connection should be closed by whoever created it\n\t}\n}\n","import type amqplib from 'amqplib';\nimport { carrierFromAttributes, consumeTraced } from '../telemetry';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport { RabbitMQChannelUnavailable } from './errors';\nimport type { RabbitMQConnection } from './RabbitMQConnection';\n\nexport interface RabbitMQSubscriberOptions {\n\tqueueName?: string; // If not provided, a unique queue will be generated\n\tqueueOptions?: amqplib.Options.AssertQueue;\n\tconsumeOptions?: amqplib.Options.Consume;\n\tprefetch?: number; // Number of messages to prefetch (default: 1)\n}\n\nexport class RabbitMQSubscriber<\n\tTMessage extends PublishableMessage<string, any>,\n> implements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: RabbitMQConnection,\n\t\tprivate options: RabbitMQSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a RabbitMQSubscriber from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&queueName=myqueue&prefetch=10\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<RabbitMQSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { RabbitMQConnection } = await import('./RabbitMQConnection');\n\t\tconst connection =\n\t\t\tawait RabbitMQConnection.fromConnectionString(connectionString);\n\n\t\tconst options: RabbitMQSubscriberOptions = {\n\t\t\tqueueName: params.get('queueName') || undefined,\n\t\t\tprefetch: params.get('prefetch')\n\t\t\t\t? Number.parseInt(params.get('prefetch')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new RabbitMQSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst channel = this.connection.amqpChannel;\n\t\tif (!channel) {\n\t\t\tthrow new RabbitMQChannelUnavailable();\n\t\t}\n\n\t\tconst exchange = this.connection.exchangeName;\n\n\t\t// Set prefetch if specified\n\t\tif (this.options.prefetch) {\n\t\t\tawait channel.prefetch(this.options.prefetch);\n\t\t}\n\n\t\t// Assert queue\n\t\tconst queueName = this.options.queueName || '';\n\t\tconst queueOptions: amqplib.Options.AssertQueue = {\n\t\t\tdurable: true,\n\t\t\t...this.options.queueOptions,\n\t\t};\n\n\t\tconst { queue } = await channel.assertQueue(queueName, queueOptions);\n\n\t\t// Bind queue to exchange for each message type\n\t\tfor (const messageType of messages) {\n\t\t\tawait channel.bindQueue(queue, exchange, messageType);\n\t\t}\n\n\t\t// Consume messages\n\t\tawait channel.consume(\n\t\t\tqueue,\n\t\t\tasync (msg) => {\n\t\t\t\tif (!msg) return;\n\n\t\t\t\ttry {\n\t\t\t\t\t// Parse message payload\n\t\t\t\t\tconst content = msg.content.toString();\n\t\t\t\t\tconst payload = JSON.parse(content);\n\n\t\t\t\t\t// Get message type from properties\n\t\t\t\t\tconst messageType = msg.properties.type;\n\n\t\t\t\t\t// Reconstruct full message\n\t\t\t\t\tconst fullMessage: TMessage = {\n\t\t\t\t\t\ttype: messageType,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t} as TMessage;\n\n\t\t\t\t\t// Call listener, as a child of the publisher's span\n\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsystem: 'rabbitmq',\n\t\t\t\t\t\t\tdestination: queue,\n\t\t\t\t\t\t\ttype: messageType,\n\t\t\t\t\t\t\tmessageId: msg.properties.messageId,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcarrierFromAttributes(msg.properties.headers),\n\t\t\t\t\t\t() => listener(fullMessage),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Ack message\n\t\t\t\t\tchannel.ack(msg);\n\t\t\t\t} catch (_error) {\n\t\t\t\t\tchannel.nack(msg, false, true);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.options.consumeOptions,\n\t\t);\n\t}\n}\n","import type { EventsDriver } from '../registry';\nimport { EventPublisherType } from '../types';\nimport { RabbitMQConnection } from './RabbitMQConnection';\nimport { RabbitMQPublisher } from './RabbitMQPublisher';\nimport { RabbitMQSubscriber } from './RabbitMQSubscriber';\n\n/**\n * `rabbitmq://` — an AMQP exchange. Register it with\n * `registerEventsDriver(rabbitmqEventsDriver)`; this subpath is the only one\n * that imports `amqplib`.\n */\nexport const rabbitmqEventsDriver: EventsDriver = {\n\tscheme: EventPublisherType.RabbitMQ,\n\tconnect: (url) => RabbitMQConnection.fromConnectionString(url),\n\tpublisher: (url) => RabbitMQPublisher.fromConnectionString(url),\n\tpublisherFor: (connection) =>\n\t\tnew RabbitMQPublisher(connection as RabbitMQConnection),\n\tsubscriber: (url) => RabbitMQSubscriber.fromConnectionString(url),\n\tsubscriberFor: (connection) =>\n\t\tnew RabbitMQSubscriber(connection as RabbitMQConnection),\n};\n"],"mappings":";;;;;;;AAYA,IAAa,qBAAb,MAAa,mBAA8C;CAC1D,OAAS;CACT;CACA;CACA;CACA;CAKA,YAAY,QAAkC;EAC7C,KAAK,SAAS;GACb,GAAG;GACH,UAAU,OAAO,YAAY;GAC7B,cAAc,OAAO,gBAAgB;GACrC,SAAS,OAAO,WAAW;GAC3B,iBAAiB;IAChB,SAAS;IACT,GAAG,OAAO;GACX;EACD;CACD;;;;;CAMA,aAAa,qBACZ,kBAC8B;EAC9B,MAAM,MAAM,IAAI,IAAI,gBAAgB;EACpC,MAAM,SAAS,IAAI;EAGnB,MAAM,UAAU,UAAU,IAAI,WAAW,GAAG,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,KAAK,IAAI,OAAO,IAAI;EAElG,MAAM,eAAe,OAAO,IAAI,SAAS;EACzC,MAAM,SAAmC;GACxC,KAAK;GACL,UAAU,OAAO,IAAI,UAAU,KAAK;GACpC,cAAe,OAAO,IAAI,MAAM,KAAa;GAC7C,SAAS,eAAe,OAAO,SAAS,cAAc,EAAE,IAAI,KAAA;EAC7D;EAEA,MAAM,aAAa,IAAI,mBAAmB,MAAM;EAChD,MAAM,WAAW,QAAQ;EACzB,OAAO;CACR;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AAS,WAAW,CAC3B;IAGA,QAAQ,IAAI,GAAG;GAChB,SAAS,QAAQ;IAChB,QAAQ,KAAK,KAAK,OAAO,IAAI;GAC9B;EACD,GACA,KAAK,QAAQ,cACd;CACD;AACD;;;;;;;;AC9GA,MAAa,uBAAqC;CACjD,QAAA;CACA,UAAU,QAAQ,mBAAmB,qBAAqB,GAAG;CAC7D,YAAY,QAAQ,kBAAkB,qBAAqB,GAAG;CAC9D,eAAe,eACd,IAAI,kBAAkB,UAAgC;CACvD,aAAa,QAAQ,mBAAmB,qBAAqB,GAAG;CAChE,gBAAgB,eACf,IAAI,mBAAmB,UAAgC;AACzD"}
@@ -1,5 +1,13 @@
1
- import { i as EventSubscriber, n as EventPublisher, r as EventPublisherType, s as PublishableMessage, t as EventConnection } from "../types-gGaoT8qc.cjs";
1
+ import { d as EventPublisher, f as EventPublisherType, g as PublishableMessage, p as EventSubscriber, t as EventsDriver, u as EventConnection } from "../registry-DIx25Q5s.cjs";
2
2
  import amqplib from "amqplib";
3
+ //#region src/rabbitmq/driver.d.ts
4
+ /**
5
+ * `rabbitmq://` — an AMQP exchange. Register it with
6
+ * `registerEventsDriver(rabbitmqEventsDriver)`; this subpath is the only one
7
+ * that imports `amqplib`.
8
+ */
9
+ export declare const rabbitmqEventsDriver: EventsDriver;
10
+ //#endregion
3
11
  //#region src/rabbitmq/errors.d.ts
4
12
  /** The connection opened but has no channel to publish or consume on. */
5
13
  export declare class RabbitMQChannelUnavailable extends Error {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/rabbitmq/errors.ts","../../src/rabbitmq/RabbitMQConnection.ts","../../src/rabbitmq/RabbitMQPublisher.ts","../../src/rabbitmq/RabbitMQSubscriber.ts"],"mappings":";;;;qBAKa,mCAAmC;EAAA;;;;UCD/B;EAChB;EACA;EACA;EACA,kBAAkB,QAAQ,QAAQ;EAClC;;qBAGY,8BAA8B;WACjC,OAAI,mBAAA;UACL;UACA;UACA;UACA;EAKI,YAAA,QAAQ;;;;;SAiBP,qBACZ,2BACE,QAAQ;EAoBL,WAAW;EA6CX,SAAS;EAWf;UAIQ;;;;MASJ,eAAe,QAAQ;;;;MAOvB;;;;MAOA;;;;UC3IY;EAChB,iBAAiB,QAAQ,QAAQ;;qBAGrB,kBAAkB,iBAAiB,4CACpC,eAAe;UAGjB;UACA;EADA,YAAA,YAAY,oBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,kBAAkB;EAOjD,QAAQ,UAAU,aAAa;EAiC/B,SAAS;;;;UC1DC;EAChB;EACA,eAAe,QAAQ,QAAQ;EAC/B,iBAAiB,QAAQ,QAAQ;EACjC;;qBAGY,mBACZ,iBAAiB,4CACL,gBAAgB;UAGnB;UACA;EADA,YAAA,YAAY,oBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,mBAAmB;EAkBlD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/rabbitmq/driver.ts","../../src/rabbitmq/errors.ts","../../src/rabbitmq/RabbitMQConnection.ts","../../src/rabbitmq/RabbitMQPublisher.ts","../../src/rabbitmq/RabbitMQSubscriber.ts"],"mappings":";;;;;;;;qBAWa,sBAAsB;;;;qBCNtB,mCAAmC;EAC/C;;;;UCFgB;EAChB;EACA;EACA;EACA,kBAAkB,QAAQ,QAAQ;EAClC;;qBAGY,8BAA8B;WACjC,OAAI,mBAAA;UACL;UACA;UACA;UACA;EAKR,YAAY,QAAQ;;;;;SAiBP,qBACZ,2BACE,QAAQ;EAoBL,WAAW;EA6CX,SAAS;EAWf;UAIQ;;;;MASJ,eAAe,QAAQ;;;;MAOvB;;;;MAOA;;;;UC1IY;EAChB,iBAAiB,QAAQ,QAAQ;;qBAGrB,kBAAkB,iBAAiB,4CACpC,eAAe;UAGjB;UACA;EAFT,YACS,YAAY,oBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,kBAAkB;EAOjD,QAAQ,UAAU,aAAa;EA+C/B,SAAS;;;;UCxEC;EAChB;EACA,eAAe,QAAQ,QAAQ;EAC/B,iBAAiB,QAAQ,QAAQ;EACjC;;qBAGY,mBACZ,iBAAiB,4CACL,gBAAgB;UAGnB;UACA;EAFT,YACS,YAAY,oBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,mBAAmB;EAkBlD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
@@ -1,5 +1,13 @@
1
- import { i as EventSubscriber, n as EventPublisher, r as EventPublisherType, s as PublishableMessage, t as EventConnection } from "../types-gGaoT8qc.mjs";
1
+ import { d as EventPublisher, f as EventPublisherType, g as PublishableMessage, p as EventSubscriber, t as EventsDriver, u as EventConnection } from "../registry-DIx25Q5s.mjs";
2
2
  import amqplib from "amqplib";
3
+ //#region src/rabbitmq/driver.d.ts
4
+ /**
5
+ * `rabbitmq://` — an AMQP exchange. Register it with
6
+ * `registerEventsDriver(rabbitmqEventsDriver)`; this subpath is the only one
7
+ * that imports `amqplib`.
8
+ */
9
+ export declare const rabbitmqEventsDriver: EventsDriver;
10
+ //#endregion
3
11
  //#region src/rabbitmq/errors.d.ts
4
12
  /** The connection opened but has no channel to publish or consume on. */
5
13
  export declare class RabbitMQChannelUnavailable extends Error {