@geekmidas/events 9.5.0 → 9.6.1

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 (117) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/{PgBossConnection-B71ssr72.cjs → PgBossConnection-BNXd_eWO.cjs} +3 -4
  3. package/dist/PgBossConnection-BNXd_eWO.cjs.map +1 -0
  4. package/dist/{PgBossConnection-Bj_Wo1lQ.mjs → PgBossConnection-BUcauiA7.mjs} +3 -3
  5. package/dist/PgBossConnection-BUcauiA7.mjs.map +1 -0
  6. package/dist/PgBossConnection-DCfLGoHx.d.mts.map +1 -1
  7. package/dist/PgBossConnection-oto_CAbP.d.cts.map +1 -1
  8. package/dist/{Publisher-DDee6xau.d.cts → Publisher-BRD9Asio.d.cts} +8 -3
  9. package/dist/Publisher-BRD9Asio.d.cts.map +1 -0
  10. package/dist/{Publisher-ChLTrUeP.mjs → Publisher-DpRC2iZf.mjs} +3 -3
  11. package/dist/Publisher-DpRC2iZf.mjs.map +1 -0
  12. package/dist/{Publisher-CKloIGh6.cjs → Publisher-QwLaFS2C.cjs} +3 -3
  13. package/dist/Publisher-QwLaFS2C.cjs.map +1 -0
  14. package/dist/{Publisher-VHumMkrP.d.mts → Publisher-s3Oj6vUG.d.mts} +8 -3
  15. package/dist/Publisher-s3Oj6vUG.d.mts.map +1 -0
  16. package/dist/Publisher.cjs +1 -1
  17. package/dist/Publisher.d.cts +2 -2
  18. package/dist/Publisher.d.mts +2 -2
  19. package/dist/Publisher.mjs +1 -1
  20. package/dist/{RabbitMQConnection-Cg7mp8u-.mjs → RabbitMQConnection-CW-92QTt.mjs} +3 -3
  21. package/dist/RabbitMQConnection-CW-92QTt.mjs.map +1 -0
  22. package/dist/RabbitMQConnection-DV9t3VYp.d.mts.map +1 -1
  23. package/dist/{RabbitMQConnection-DddqvI3I.cjs → RabbitMQConnection-Diwv0RIa.cjs} +3 -4
  24. package/dist/RabbitMQConnection-Diwv0RIa.cjs.map +1 -0
  25. package/dist/RabbitMQConnection-jNME_eR7.d.cts.map +1 -1
  26. package/dist/{RabbitMQPublisher-BfTRUnpy.cjs → RabbitMQPublisher-C94q6g8q.cjs} +1 -1
  27. package/dist/{RabbitMQPublisher-BfTRUnpy.cjs.map → RabbitMQPublisher-C94q6g8q.cjs.map} +1 -1
  28. package/dist/{RabbitMQPublisher-Cxm1zSkD.mjs → RabbitMQPublisher-yUqWNq-P.mjs} +1 -1
  29. package/dist/{RabbitMQPublisher-Cxm1zSkD.mjs.map → RabbitMQPublisher-yUqWNq-P.mjs.map} +1 -1
  30. package/dist/{RabbitMQSubscriber-fP8G9OlK.mjs → RabbitMQSubscriber-BWniDtFs.mjs} +1 -1
  31. package/dist/{RabbitMQSubscriber-fP8G9OlK.mjs.map → RabbitMQSubscriber-BWniDtFs.mjs.map} +1 -1
  32. package/dist/{RabbitMQSubscriber-CWDdmt1M.cjs → RabbitMQSubscriber-DGEO-clQ.cjs} +1 -1
  33. package/dist/{RabbitMQSubscriber-CWDdmt1M.cjs.map → RabbitMQSubscriber-DGEO-clQ.cjs.map} +1 -1
  34. package/dist/{SNSConnection-DFehUWG1.cjs → SNSConnection-CAcbLQOy.cjs} +1 -1
  35. package/dist/{SNSConnection-DFehUWG1.cjs.map → SNSConnection-CAcbLQOy.cjs.map} +1 -1
  36. package/dist/{SNSConnection-CpMKzgx2.mjs → SNSConnection-CVjH93lb.mjs} +1 -1
  37. package/dist/{SNSConnection-CpMKzgx2.mjs.map → SNSConnection-CVjH93lb.mjs.map} +1 -1
  38. package/dist/{SNSPublisher-Drr4kHn6.mjs → SNSPublisher-CjlMS3Z2.mjs} +1 -1
  39. package/dist/{SNSPublisher-Drr4kHn6.mjs.map → SNSPublisher-CjlMS3Z2.mjs.map} +1 -1
  40. package/dist/{SNSPublisher-BoA8uLnw.cjs → SNSPublisher-DV_8GGsi.cjs} +1 -1
  41. package/dist/{SNSPublisher-BoA8uLnw.cjs.map → SNSPublisher-DV_8GGsi.cjs.map} +1 -1
  42. package/dist/{SNSSubscriber-DIXqA-VV.mjs → SNSSubscriber-BWaCQFl6.mjs} +3 -3
  43. package/dist/{SNSSubscriber-DIXqA-VV.mjs.map → SNSSubscriber-BWaCQFl6.mjs.map} +1 -1
  44. package/dist/{SNSSubscriber-ZIdCi6nQ.cjs → SNSSubscriber-ZE_-Hsps.cjs} +3 -3
  45. package/dist/{SNSSubscriber-ZIdCi6nQ.cjs.map → SNSSubscriber-ZE_-Hsps.cjs.map} +1 -1
  46. package/dist/{SQSConnection-BqZZnAZI.mjs → SQSConnection-CT3S7_zP.mjs} +1 -1
  47. package/dist/{SQSConnection-BqZZnAZI.mjs.map → SQSConnection-CT3S7_zP.mjs.map} +1 -1
  48. package/dist/{SQSConnection-yge9cB_f.cjs → SQSConnection-Y0mdVTcB.cjs} +1 -1
  49. package/dist/{SQSConnection-yge9cB_f.cjs.map → SQSConnection-Y0mdVTcB.cjs.map} +1 -1
  50. package/dist/{SQSPublisher-Dq5353oZ.cjs → SQSPublisher-Bq-qWTjH.cjs} +12 -5
  51. package/dist/SQSPublisher-Bq-qWTjH.cjs.map +1 -0
  52. package/dist/{SQSPublisher-qDE5Fp-N.d.mts → SQSPublisher-D7grG35F.d.mts} +12 -5
  53. package/dist/SQSPublisher-D7grG35F.d.mts.map +1 -0
  54. package/dist/{SQSPublisher-kyl5HW3N.d.cts → SQSPublisher-D9MHsTne.d.cts} +12 -5
  55. package/dist/SQSPublisher-D9MHsTne.d.cts.map +1 -0
  56. package/dist/{SQSPublisher-DG9o4ME3.mjs → SQSPublisher-DVOOa5dW.mjs} +12 -5
  57. package/dist/SQSPublisher-DVOOa5dW.mjs.map +1 -0
  58. package/dist/{SQSSubscriber-B4sRXVl6.cjs → SQSSubscriber-C4UA2hKq.cjs} +1 -1
  59. package/dist/{SQSSubscriber-B4sRXVl6.cjs.map → SQSSubscriber-C4UA2hKq.cjs.map} +1 -1
  60. package/dist/{SQSSubscriber-CVGhZ8Nr.mjs → SQSSubscriber-CQdSFzpe.mjs} +1 -1
  61. package/dist/{SQSSubscriber-CVGhZ8Nr.mjs.map → SQSSubscriber-CQdSFzpe.mjs.map} +1 -1
  62. package/dist/index.cjs +1 -1
  63. package/dist/index.d.cts +2 -2
  64. package/dist/index.d.mts +2 -2
  65. package/dist/index.mjs +1 -1
  66. package/dist/pgboss/PgBossConnection.cjs +1 -1
  67. package/dist/pgboss/PgBossConnection.mjs +1 -1
  68. package/dist/pgboss/index.cjs +1 -1
  69. package/dist/pgboss/index.mjs +1 -1
  70. package/dist/rabbitmq/RabbitMQConnection.cjs +1 -1
  71. package/dist/rabbitmq/RabbitMQConnection.mjs +1 -1
  72. package/dist/rabbitmq/RabbitMQPublisher.cjs +1 -1
  73. package/dist/rabbitmq/RabbitMQPublisher.mjs +1 -1
  74. package/dist/rabbitmq/RabbitMQSubscriber.cjs +1 -1
  75. package/dist/rabbitmq/RabbitMQSubscriber.mjs +1 -1
  76. package/dist/rabbitmq/index.cjs +3 -3
  77. package/dist/rabbitmq/index.mjs +3 -3
  78. package/dist/sns/SNSConnection.cjs +1 -1
  79. package/dist/sns/SNSConnection.mjs +1 -1
  80. package/dist/sns/SNSPublisher.cjs +1 -1
  81. package/dist/sns/SNSPublisher.mjs +1 -1
  82. package/dist/sns/SNSSubscriber.cjs +3 -3
  83. package/dist/sns/SNSSubscriber.mjs +3 -3
  84. package/dist/sns/index.cjs +5 -5
  85. package/dist/sns/index.mjs +5 -5
  86. package/dist/sqs/SQSConnection.cjs +1 -1
  87. package/dist/sqs/SQSConnection.mjs +1 -1
  88. package/dist/sqs/SQSPublisher.cjs +1 -1
  89. package/dist/sqs/SQSPublisher.d.cts +1 -1
  90. package/dist/sqs/SQSPublisher.d.mts +1 -1
  91. package/dist/sqs/SQSPublisher.mjs +1 -1
  92. package/dist/sqs/SQSSubscriber.cjs +1 -1
  93. package/dist/sqs/SQSSubscriber.mjs +1 -1
  94. package/dist/sqs/index.cjs +3 -3
  95. package/dist/sqs/index.d.cts +1 -1
  96. package/dist/sqs/index.d.mts +1 -1
  97. package/dist/sqs/index.mjs +3 -3
  98. package/package.json +4 -3
  99. package/src/Publisher.ts +12 -1
  100. package/src/__tests__/bundle.spec.ts +51 -0
  101. package/src/index.ts +4 -1
  102. package/src/pgboss/PgBossConnection.ts +5 -2
  103. package/src/rabbitmq/RabbitMQConnection.ts +5 -2
  104. package/src/sqs/SQSPublisher.ts +26 -5
  105. package/src/sqs/__tests__/SQSPublisher.fifo.spec.ts +63 -0
  106. package/dist/PgBossConnection-B71ssr72.cjs.map +0 -1
  107. package/dist/PgBossConnection-Bj_Wo1lQ.mjs.map +0 -1
  108. package/dist/Publisher-CKloIGh6.cjs.map +0 -1
  109. package/dist/Publisher-ChLTrUeP.mjs.map +0 -1
  110. package/dist/Publisher-DDee6xau.d.cts.map +0 -1
  111. package/dist/Publisher-VHumMkrP.d.mts.map +0 -1
  112. package/dist/RabbitMQConnection-Cg7mp8u-.mjs.map +0 -1
  113. package/dist/RabbitMQConnection-DddqvI3I.cjs.map +0 -1
  114. package/dist/SQSPublisher-DG9o4ME3.mjs.map +0 -1
  115. package/dist/SQSPublisher-Dq5353oZ.cjs.map +0 -1
  116. package/dist/SQSPublisher-kyl5HW3N.d.cts.map +0 -1
  117. package/dist/SQSPublisher-qDE5Fp-N.d.mts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @geekmidas/events
2
2
 
3
+ ## 9.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#526](https://github.com/geekmidas/toolbox/pull/526) [`38bccfa`](https://github.com/geekmidas/toolbox/commit/38bccfa66957b47257571b593ebef1ed534a9786) Thanks [@geekmidas](https://github.com/geekmidas)! - An app bundled into one file starts without `amqplib` or `pg-boss` installed
8
+
9
+ `RabbitMQConnection` and `PgBossConnection` imported their client library at the top of the module. `Publisher` and `Subscriber` only load those modules when a `rabbitmq://` or `pgboss://` string is used, but a bundler that inlines them (esbuild or rolldown with no code splitting, as a Lambda is built) moves that import to the top of the bundle, so a Lambda that only publishes to SQS crashed on load with `Cannot find package 'amqplib'`. Each connection now imports its library in `connect()`, the only place it is used.
10
+
11
+ - Updated dependencies []:
12
+ - @geekmidas/schema@9.6.1
13
+
14
+ ## 9.6.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [#466](https://github.com/geekmidas/toolbox/pull/466) [`6ca73be`](https://github.com/geekmidas/toolbox/commit/6ca73be57c19d21b7e14048968674a5fea9debd5) Thanks [@geekmidas](https://github.com/geekmidas)! - FIFO queues can be published to, with a message group per message
19
+
20
+ `q(...).fifo({ groupId })` gives each message its FIFO group, and the queue's `publisher` sends it as `MessageGroupId`. Before, the SQS publisher set no group, so publishing to a FIFO queue was refused. Messages in one group keep their order; different groups are processed in parallel.
21
+
22
+ ```ts
23
+ export const conversationQueue = q
24
+ .queue('processConversation')
25
+ .message(ConversationEventSchema)
26
+ .fifo({ groupId: (message) => message.conversationId })
27
+ .handle(async ({ records }) => { … });
28
+ ```
29
+
30
+ Underneath, `SQSPublisherOptions.groupId` and the new `PublisherOptions` argument to `Publisher.fromConnectionString` carry it; other transports ignore it. The queue must use content-based deduplication, since no deduplication id is sent. `.fifo()` and `.fifo(true)` work as before.
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies []:
35
+ - @geekmidas/schema@9.6.0
36
+
3
37
  ## 9.5.0
4
38
 
5
39
  ### Patch Changes
@@ -1,6 +1,4 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
1
  const require_types = require('./types-Byv8N9ma.cjs');
3
- const pg_boss = require_chunk.__toESM(require("pg-boss"));
4
2
 
5
3
  //#region src/pgboss/PgBossConnection.ts
6
4
  var PgBossConnection = class PgBossConnection {
@@ -34,7 +32,8 @@ var PgBossConnection = class PgBossConnection {
34
32
  }
35
33
  this.connecting = (async () => {
36
34
  try {
37
- const boss = new pg_boss.PgBoss({
35
+ const { PgBoss: Boss } = await import("pg-boss");
36
+ const boss = new Boss({
38
37
  connectionString: this.config.connectionString,
39
38
  ...this.config.schema && { schema: this.config.schema }
40
39
  });
@@ -77,4 +76,4 @@ Object.defineProperty(exports, 'PgBossConnection', {
77
76
  return PgBossConnection;
78
77
  }
79
78
  });
80
- //# sourceMappingURL=PgBossConnection-B71ssr72.cjs.map
79
+ //# sourceMappingURL=PgBossConnection-BNXd_eWO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PgBossConnection-BNXd_eWO.cjs","names":["EventPublisherType","config: PgBossConnectionConfig","connectionString: string"],"sources":["../src/pgboss/PgBossConnection.ts"],"sourcesContent":["import type { 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\t// Loaded here, not at the top of the module: an app bundled into one\n\t\t\t\t// file that never connects to pg-boss must not need it installed.\n\t\t\t\tconst { PgBoss: Boss } = await import('pg-boss');\n\t\t\t\tconst boss = new Boss({\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"],"mappings":";;;AASA,IAAa,mBAAb,MAAa,iBAA4C;CACxD,AAAS,OAAOA,iCAAmB;CACnC,AAAQ;CACR,AAAQ;CAER,YAAoBC,QAAgC;EAAhC;CAAkC;;;;;CAMtD,aAAa,qBACZC,kBAC4B;EAC5B,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,eAAe,aAAa,IAAI,YAAY,EAAE,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,GAAG,EAAE,IAAI,KAAK,EAAE,IAAI,SAAS;EAEnH,MAAMD,SAAiC;GACtC,kBAAkB;GAClB,QAAQ,OAAO,IAAI,SAAS;EAC5B;EAED,MAAM,aAAa,IAAI,iBAAiB;AACxC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAC9B,MAAI,KAAK,KAAM;AAEf,MAAI,KAAK,YAAY;AACpB,SAAM,KAAK;AACX;EACA;AAED,OAAK,aAAa,CAAC,YAAY;AAC9B,OAAI;IAGH,MAAM,EAAE,QAAQ,MAAM,GAAG,MAAM,OAAO;IACtC,MAAM,OAAO,IAAI,KAAK;KACrB,kBAAkB,KAAK,OAAO;KAC9B,GAAI,KAAK,OAAO,UAAU,EAAE,QAAQ,KAAK,OAAO,OAAQ;IACxD;AAED,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;GACZ,SAAQ,OAAO;AACf,SAAK,SAAS;AACd,UAAM;GACN;EACD,IAAG;AAEJ,QAAM,KAAK;AACX,OAAK;CACL;CAED,MAAM,QAAuB;AAC5B,MAAI;AACH,SAAM,KAAK,MAAM,KAAK,EAAE,UAAU,KAAM,EAAC;EACzC,QAAO,CAEP,UAAS;AACT,QAAK,SAAS;EACd;CACD;CAED,cAAuB;AACtB,WAAS,KAAK;CACd;CAED,AAAQ,UAAgB;AACvB,OAAK;AACL,OAAK;CACL;;;;CAKD,IAAI,WAA+B;AAClC,SAAO,KAAK;CACZ;AACD"}
@@ -1,5 +1,4 @@
1
1
  import { EventPublisherType } from "./types-BrdcSEnd.mjs";
2
- import { PgBoss } from "pg-boss";
3
2
 
4
3
  //#region src/pgboss/PgBossConnection.ts
5
4
  var PgBossConnection = class PgBossConnection {
@@ -33,7 +32,8 @@ var PgBossConnection = class PgBossConnection {
33
32
  }
34
33
  this.connecting = (async () => {
35
34
  try {
36
- const boss = new PgBoss({
35
+ const { PgBoss: Boss } = await import("pg-boss");
36
+ const boss = new Boss({
37
37
  connectionString: this.config.connectionString,
38
38
  ...this.config.schema && { schema: this.config.schema }
39
39
  });
@@ -71,4 +71,4 @@ var PgBossConnection = class PgBossConnection {
71
71
 
72
72
  //#endregion
73
73
  export { PgBossConnection };
74
- //# sourceMappingURL=PgBossConnection-Bj_Wo1lQ.mjs.map
74
+ //# sourceMappingURL=PgBossConnection-BUcauiA7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PgBossConnection-BUcauiA7.mjs","names":["config: PgBossConnectionConfig","connectionString: string"],"sources":["../src/pgboss/PgBossConnection.ts"],"sourcesContent":["import type { 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\t// Loaded here, not at the top of the module: an app bundled into one\n\t\t\t\t// file that never connects to pg-boss must not need it installed.\n\t\t\t\tconst { PgBoss: Boss } = await import('pg-boss');\n\t\t\t\tconst boss = new Boss({\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"],"mappings":";;;AASA,IAAa,mBAAb,MAAa,iBAA4C;CACxD,AAAS,OAAO,mBAAmB;CACnC,AAAQ;CACR,AAAQ;CAER,YAAoBA,QAAgC;EAAhC;CAAkC;;;;;CAMtD,aAAa,qBACZC,kBAC4B;EAC5B,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,eAAe,aAAa,IAAI,YAAY,EAAE,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,GAAG,EAAE,IAAI,KAAK,EAAE,IAAI,SAAS;EAEnH,MAAMD,SAAiC;GACtC,kBAAkB;GAClB,QAAQ,OAAO,IAAI,SAAS;EAC5B;EAED,MAAM,aAAa,IAAI,iBAAiB;AACxC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAC9B,MAAI,KAAK,KAAM;AAEf,MAAI,KAAK,YAAY;AACpB,SAAM,KAAK;AACX;EACA;AAED,OAAK,aAAa,CAAC,YAAY;AAC9B,OAAI;IAGH,MAAM,EAAE,QAAQ,MAAM,GAAG,MAAM,OAAO;IACtC,MAAM,OAAO,IAAI,KAAK;KACrB,kBAAkB,KAAK,OAAO;KAC9B,GAAI,KAAK,OAAO,UAAU,EAAE,QAAQ,KAAK,OAAO,OAAQ;IACxD;AAED,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;GACZ,SAAQ,OAAO;AACf,SAAK,SAAS;AACd,UAAM;GACN;EACD,IAAG;AAEJ,QAAM,KAAK;AACX,OAAK;CACL;CAED,MAAM,QAAuB;AAC5B,MAAI;AACH,SAAM,KAAK,MAAM,KAAK,EAAE,UAAU,KAAM,EAAC;EACzC,QAAO,CAEP,UAAS;AACT,QAAK,SAAS;EACd;CACD;CAED,cAAuB;AACtB,WAAS,KAAK;CACd;CAED,AAAQ,UAAgB;AACvB,OAAK;AACL,OAAK;CACL;;;;CAKD,IAAI,WAA+B;AAClC,SAAO,KAAK;CACZ;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"PgBossConnection-DCfLGoHx.d.mts","names":[],"sources":["../src/pgboss/PgBossConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,sBAAA;EAAA,gBAAA,EAAA,MAAA;EAKJ,MAAA,CAAA,EAAA,MAAA;;AACC,cADD,gBAAA,YAA4B,eAC3B,CAAA;EAAA,QAIe,MAAA;EAAsB,SAQvC,IAAA,GAZE,kBAAA,CAAA,MAAA;EAYc,QAAxB,IAAA;EAAO,QAgBO,UAAA;EAAO,WA2BT,CAAA,MAAA,EAnDa,sBAmDb;EAAO;;AAxDiC;;yDAapD,QAAQ;aAgBM;WA2BF;;;;;;kBAsBC"}
1
+ {"version":3,"file":"PgBossConnection-DCfLGoHx.d.mts","names":[],"sources":["../src/pgboss/PgBossConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,sBAAA;EAAA,gBAAA,EAAA,MAAA;EAKJ,MAAA,CAAA,EAAA,MAAA;;AACC,cADD,gBAAA,YAA4B,eAC3B,CAAA;EAAA,QAIe,MAAA;EAAsB,SAQvC,IAAA,GAZE,kBAAA,CAAA,MAAA;EAYc,QAAxB,IAAA;EAAO,QAgBO,UAAA;EAAO,WA8BT,CAAA,MAAA,EAtDa,sBAsDb;EAAO;;AA3DiC;;yDAapD,QAAQ;aAgBM;WA8BF;;;;;;kBAsBC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PgBossConnection-oto_CAbP.d.cts","names":[],"sources":["../src/pgboss/PgBossConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,sBAAA;EAAA,gBAAA,EAAA,MAAA;EAKJ,MAAA,CAAA,EAAA,MAAA;;AACC,cADD,gBAAA,YAA4B,eAC3B,CAAA;EAAA,QAIe,MAAA;EAAsB,SAQvC,IAAA,GAZE,kBAAA,CAAA,MAAA;EAYc,QAAxB,IAAA;EAAO,QAgBO,UAAA;EAAO,WA2BT,CAAA,MAAA,EAnDa,sBAmDb;EAAO;;AAxDiC;;yDAapD,QAAQ;aAgBM;WA2BF;;;;;;kBAsBC"}
1
+ {"version":3,"file":"PgBossConnection-oto_CAbP.d.cts","names":[],"sources":["../src/pgboss/PgBossConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,sBAAA;EAAA,gBAAA,EAAA,MAAA;EAKJ,MAAA,CAAA,EAAA,MAAA;;AACC,cADD,gBAAA,YAA4B,eAC3B,CAAA;EAAA,QAIe,MAAA;EAAsB,SAQvC,IAAA,GAZE,kBAAA,CAAA,MAAA;EAYc,QAAxB,IAAA;EAAO,QAgBO,UAAA;EAAO,WA8BT,CAAA,MAAA,EAtDa,sBAsDb;EAAO;;AA3DiC;;yDAapD,QAAQ;aAgBM;WA8BF;;;;;;kBAsBC"}
@@ -1,12 +1,17 @@
1
1
  import { EventConnection, EventPublisher, EventPublisherType, PublishableMessage } from "./types-Dj23od3e.cjs";
2
2
 
3
3
  //#region src/Publisher.d.ts
4
+ /** Options a transport uses when it supports them, ignored by the rest. */
5
+ interface PublisherOptions<TMessage extends PublishableMessage<string, any>> {
6
+ /** The FIFO message group for each message (SQS). */
7
+ groupId?: (message: TMessage) => string;
8
+ }
4
9
  declare class Publisher {
5
10
  /**
6
11
  * Create a publisher from a connection string
7
12
  * This creates both a connection and a publisher
8
13
  */
9
- static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionStr: EventPublisherConnectionString): Promise<EventPublisher<TMessage>>;
14
+ static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionStr: EventPublisherConnectionString, options?: PublisherOptions<TMessage>): Promise<EventPublisher<TMessage>>;
10
15
  /**
11
16
  * Create a publisher from an existing connection
12
17
  * This allows sharing connections between publishers and subscribers
@@ -17,5 +22,5 @@ type EventPublisherConnectionString = `${EventPublisherType}://${string}`;
17
22
  //# sourceMappingURL=Publisher.d.ts.map
18
23
 
19
24
  //#endregion
20
- export { EventPublisherConnectionString, Publisher };
21
- //# sourceMappingURL=Publisher-DDee6xau.d.cts.map
25
+ export { EventPublisherConnectionString, Publisher, PublisherOptions };
26
+ //# sourceMappingURL=Publisher-BRD9Asio.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Publisher-BRD9Asio.d.cts","names":[],"sources":["../src/Publisher.ts"],"sourcesContent":[],"mappings":";;;;AAQiB,UAAA,gBAAgB,CAAA,iBACf,kBADe,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA;EAAA;EAAA,OACf,CAAA,EAAA,CAAA,OAAA,EAGG,QAHH,EAAA,GAAA,MAAA;;AAGW,cAGhB,SAAA,CAHgB;EAGhB;;;;EAQkC,OACnB,oBAAA,CAAA,iBAHT,kBAGS,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,aAAA,EADX,8BACW,EAAA,OAAA,CAAA,EAAjB,gBAAiB,CAAA,QAAA,CAAA,CAAA,EACxB,OADwB,CAChB,cADgB,CACD,QADC,CAAA,CAAA;EAAQ;;;;EACzB,OAqCmC,cAAA,CAAA,iBAAA,kBAAA,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,UAAA,EAChC,eADgC,CAAA,EAE1C,OAF0C,CAElC,cAFkC,CAEnB,QAFmB,CAAA,CAAA;;AAEnB,KA2Cf,8BAAA,GA3Ce,GA4CvB,kBA5CuB,MAAA,MAAA,EAAA"}
@@ -6,7 +6,7 @@ var Publisher = class {
6
6
  * Create a publisher from a connection string
7
7
  * This creates both a connection and a publisher
8
8
  */
9
- static async fromConnectionString(connectionStr) {
9
+ static async fromConnectionString(connectionStr, options = {}) {
10
10
  const url = new URL(connectionStr);
11
11
  switch (url.protocol.replace(":", "")) {
12
12
  case EventPublisherType.Basic: {
@@ -20,7 +20,7 @@ var Publisher = class {
20
20
  }
21
21
  case EventPublisherType.SQS: {
22
22
  const { SQSPublisher } = await import("./sqs/index.mjs");
23
- return SQSPublisher.fromConnectionString(connectionStr);
23
+ return SQSPublisher.fromConnectionString(connectionStr, { groupId: options.groupId });
24
24
  }
25
25
  case EventPublisherType.SNS: {
26
26
  const { SNSPublisher } = await import("./sns/index.mjs");
@@ -71,4 +71,4 @@ var Publisher = class {
71
71
 
72
72
  //#endregion
73
73
  export { Publisher };
74
- //# sourceMappingURL=Publisher-ChLTrUeP.mjs.map
74
+ //# sourceMappingURL=Publisher-DpRC2iZf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Publisher-DpRC2iZf.mjs","names":["connectionStr: EventPublisherConnectionString","options: PublisherOptions<TMessage>","connection: EventConnection"],"sources":["../src/Publisher.ts"],"sourcesContent":["import type {\n\tEventConnection,\n\tEventPublisher,\n\tPublishableMessage,\n} from './types';\nimport { EventPublisherType } from './types';\n\n/** Options a transport uses when it supports them, ignored by the rest. */\nexport interface PublisherOptions<\n\tTMessage extends PublishableMessage<string, any>,\n> {\n\t/** The FIFO message group for each message (SQS). */\n\tgroupId?: (message: TMessage) => string;\n}\n\nexport class Publisher {\n\t/**\n\t * Create a publisher from a connection string\n\t * This creates both a connection and a publisher\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventPublisherConnectionString,\n\t\toptions: PublisherOptions<TMessage> = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\tconst url = new URL(connectionStr);\n\t\tswitch (url.protocol.replace(':', '')) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicConnection, BasicPublisher } = await import('./basic');\n\t\t\t\tconst connection =\n\t\t\t\t\tawait BasicConnection.fromConnectionString(connectionStr);\n\t\t\t\treturn new BasicPublisher<TMessage>(connection);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQPublisher } = await import('./rabbitmq');\n\t\t\t\treturn RabbitMQPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSPublisher } = await import('./sqs');\n\t\t\t\treturn SQSPublisher.fromConnectionString<TMessage>(connectionStr, {\n\t\t\t\t\tgroupId: options.groupId,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSPublisher } = await import('./sns');\n\t\t\t\treturn SNSPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossPublisher } = await import('./pgboss');\n\t\t\t\treturn PgBossPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\t// Future implementations for EventBridge, Kafka, etc.\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported event publisher type: ${url.protocol}`);\n\t\t}\n\t}\n\n\t/**\n\t * Create a publisher from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t): Promise<EventPublisher<TMessage>> {\n\t\tswitch (connection.type) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicPublisher } = await import('./basic');\n\t\t\t\tconst { BasicConnection } = await import('./basic');\n\t\t\t\treturn new BasicPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof BasicConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQPublisher } = await import('./rabbitmq');\n\t\t\t\tconst { RabbitMQConnection } = await import('./rabbitmq');\n\t\t\t\treturn new RabbitMQPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof RabbitMQConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSPublisher } = await import('./sqs');\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\treturn new SQSPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SQSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSPublisher } = await import('./sns');\n\t\t\t\tconst { SNSConnection } = await import('./sns');\n\t\t\t\treturn new SNSPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SNSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossPublisher } = await import('./pgboss');\n\t\t\t\tconst { PgBossConnection } = await import('./pgboss');\n\t\t\t\treturn new PgBossPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof PgBossConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported connection type: ${connection.type}`);\n\t\t}\n\t}\n}\n\nexport type EventPublisherConnectionString =\n\t`${EventPublisherType}://${string}`;\n"],"mappings":";;;AAeA,IAAa,YAAb,MAAuB;;;;;CAKtB,aAAa,qBAGZA,eACAC,UAAsC,CAAE,GACJ;EACpC,MAAM,MAAM,IAAI,IAAI;AACpB,UAAQ,IAAI,SAAS,QAAQ,KAAK,GAAG,EAArC;GACC,KAAK,mBAAmB,OAAO;IAC9B,MAAM,EAAE,iBAAiB,gBAAgB,GAAG,MAAM,OAAO;IACzD,MAAM,aACL,MAAM,gBAAgB,qBAAqB,cAAc;AAC1D,WAAO,IAAI,eAAyB;GACpC;GACD,KAAK,mBAAmB,UAAU;IACjC,MAAM,EAAE,mBAAmB,GAAG,MAAM,OAAO;AAC3C,WAAO,kBAAkB,qBAA+B,cAAc;GACtE;GACD,KAAK,mBAAmB,KAAK;IAC5B,MAAM,EAAE,cAAc,GAAG,MAAM,OAAO;AACtC,WAAO,aAAa,qBAA+B,eAAe,EACjE,SAAS,QAAQ,QACjB,EAAC;GACF;GACD,KAAK,mBAAmB,KAAK;IAC5B,MAAM,EAAE,cAAc,GAAG,MAAM,OAAO;AACtC,WAAO,aAAa,qBAA+B,cAAc;GACjE;GACD,KAAK,mBAAmB,QAAQ;IAC/B,MAAM,EAAE,iBAAiB,GAAG,MAAM,OAAO;AACzC,WAAO,gBAAgB,qBAA+B,cAAc;GACpE;GAED,QACC,OAAM,IAAI,OAAO,oCAAoC,IAAI,SAAS;EACnE;CACD;;;;;CAMD,aAAa,eACZC,YACoC;AACpC,UAAQ,WAAW,MAAnB;GACC,KAAK,mBAAmB,OAAO;IAC9B,MAAM,EAAE,gBAAgB,GAAG,MAAM,OAAO;IACxC,MAAM,EAAE,iBAAiB,GAAG,MAAM,OAAO;AACzC,WAAO,IAAI,eACV;GAED;GACD,KAAK,mBAAmB,UAAU;IACjC,MAAM,EAAE,mBAAmB,GAAG,MAAM,OAAO;IAC3C,MAAM,EAAE,oBAAoB,GAAG,MAAM,OAAO;AAC5C,WAAO,IAAI,kBACV;GAED;GACD,KAAK,mBAAmB,KAAK;IAC5B,MAAM,EAAE,cAAc,GAAG,MAAM,OAAO;IACtC,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;AACvC,WAAO,IAAI,aACV;GAED;GACD,KAAK,mBAAmB,KAAK;IAC5B,MAAM,EAAE,cAAc,GAAG,MAAM,OAAO;IACtC,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;AACvC,WAAO,IAAI,aACV;GAED;GACD,KAAK,mBAAmB,QAAQ;IAC/B,MAAM,EAAE,iBAAiB,GAAG,MAAM,OAAO;IACzC,MAAM,EAAE,kBAAkB,GAAG,MAAM,OAAO;AAC1C,WAAO,IAAI,gBACV;GAED;GACD,QACC,OAAM,IAAI,OAAO,+BAA+B,WAAW,KAAK;EACjE;CACD;AACD"}
@@ -6,7 +6,7 @@ var Publisher = class {
6
6
  * Create a publisher from a connection string
7
7
  * This creates both a connection and a publisher
8
8
  */
9
- static async fromConnectionString(connectionStr) {
9
+ static async fromConnectionString(connectionStr, options = {}) {
10
10
  const url = new URL(connectionStr);
11
11
  switch (url.protocol.replace(":", "")) {
12
12
  case require_types.EventPublisherType.Basic: {
@@ -20,7 +20,7 @@ var Publisher = class {
20
20
  }
21
21
  case require_types.EventPublisherType.SQS: {
22
22
  const { SQSPublisher } = await Promise.resolve().then(() => require("./sqs/index.cjs"));
23
- return SQSPublisher.fromConnectionString(connectionStr);
23
+ return SQSPublisher.fromConnectionString(connectionStr, { groupId: options.groupId });
24
24
  }
25
25
  case require_types.EventPublisherType.SNS: {
26
26
  const { SNSPublisher } = await Promise.resolve().then(() => require("./sns/index.cjs"));
@@ -76,4 +76,4 @@ Object.defineProperty(exports, 'Publisher', {
76
76
  return Publisher;
77
77
  }
78
78
  });
79
- //# sourceMappingURL=Publisher-CKloIGh6.cjs.map
79
+ //# sourceMappingURL=Publisher-QwLaFS2C.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Publisher-QwLaFS2C.cjs","names":["connectionStr: EventPublisherConnectionString","options: PublisherOptions<TMessage>","EventPublisherType","connection: EventConnection"],"sources":["../src/Publisher.ts"],"sourcesContent":["import type {\n\tEventConnection,\n\tEventPublisher,\n\tPublishableMessage,\n} from './types';\nimport { EventPublisherType } from './types';\n\n/** Options a transport uses when it supports them, ignored by the rest. */\nexport interface PublisherOptions<\n\tTMessage extends PublishableMessage<string, any>,\n> {\n\t/** The FIFO message group for each message (SQS). */\n\tgroupId?: (message: TMessage) => string;\n}\n\nexport class Publisher {\n\t/**\n\t * Create a publisher from a connection string\n\t * This creates both a connection and a publisher\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventPublisherConnectionString,\n\t\toptions: PublisherOptions<TMessage> = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\tconst url = new URL(connectionStr);\n\t\tswitch (url.protocol.replace(':', '')) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicConnection, BasicPublisher } = await import('./basic');\n\t\t\t\tconst connection =\n\t\t\t\t\tawait BasicConnection.fromConnectionString(connectionStr);\n\t\t\t\treturn new BasicPublisher<TMessage>(connection);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQPublisher } = await import('./rabbitmq');\n\t\t\t\treturn RabbitMQPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSPublisher } = await import('./sqs');\n\t\t\t\treturn SQSPublisher.fromConnectionString<TMessage>(connectionStr, {\n\t\t\t\t\tgroupId: options.groupId,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSPublisher } = await import('./sns');\n\t\t\t\treturn SNSPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossPublisher } = await import('./pgboss');\n\t\t\t\treturn PgBossPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\t// Future implementations for EventBridge, Kafka, etc.\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported event publisher type: ${url.protocol}`);\n\t\t}\n\t}\n\n\t/**\n\t * Create a publisher from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t): Promise<EventPublisher<TMessage>> {\n\t\tswitch (connection.type) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicPublisher } = await import('./basic');\n\t\t\t\tconst { BasicConnection } = await import('./basic');\n\t\t\t\treturn new BasicPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof BasicConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQPublisher } = await import('./rabbitmq');\n\t\t\t\tconst { RabbitMQConnection } = await import('./rabbitmq');\n\t\t\t\treturn new RabbitMQPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof RabbitMQConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSPublisher } = await import('./sqs');\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\treturn new SQSPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SQSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSPublisher } = await import('./sns');\n\t\t\t\tconst { SNSConnection } = await import('./sns');\n\t\t\t\treturn new SNSPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SNSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossPublisher } = await import('./pgboss');\n\t\t\t\tconst { PgBossConnection } = await import('./pgboss');\n\t\t\t\treturn new PgBossPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof PgBossConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported connection type: ${connection.type}`);\n\t\t}\n\t}\n}\n\nexport type EventPublisherConnectionString =\n\t`${EventPublisherType}://${string}`;\n"],"mappings":";;;AAeA,IAAa,YAAb,MAAuB;;;;;CAKtB,aAAa,qBAGZA,eACAC,UAAsC,CAAE,GACJ;EACpC,MAAM,MAAM,IAAI,IAAI;AACpB,UAAQ,IAAI,SAAS,QAAQ,KAAK,GAAG,EAArC;GACC,KAAKC,iCAAmB,OAAO;IAC9B,MAAM,EAAE,iBAAiB,gBAAgB,GAAG,2CAAM;IAClD,MAAM,aACL,MAAM,gBAAgB,qBAAqB,cAAc;AAC1D,WAAO,IAAI,eAAyB;GACpC;GACD,KAAKA,iCAAmB,UAAU;IACjC,MAAM,EAAE,mBAAmB,GAAG,2CAAM;AACpC,WAAO,kBAAkB,qBAA+B,cAAc;GACtE;GACD,KAAKA,iCAAmB,KAAK;IAC5B,MAAM,EAAE,cAAc,GAAG,2CAAM;AAC/B,WAAO,aAAa,qBAA+B,eAAe,EACjE,SAAS,QAAQ,QACjB,EAAC;GACF;GACD,KAAKA,iCAAmB,KAAK;IAC5B,MAAM,EAAE,cAAc,GAAG,2CAAM;AAC/B,WAAO,aAAa,qBAA+B,cAAc;GACjE;GACD,KAAKA,iCAAmB,QAAQ;IAC/B,MAAM,EAAE,iBAAiB,GAAG,2CAAM;AAClC,WAAO,gBAAgB,qBAA+B,cAAc;GACpE;GAED,QACC,OAAM,IAAI,OAAO,oCAAoC,IAAI,SAAS;EACnE;CACD;;;;;CAMD,aAAa,eACZC,YACoC;AACpC,UAAQ,WAAW,MAAnB;GACC,KAAKD,iCAAmB,OAAO;IAC9B,MAAM,EAAE,gBAAgB,GAAG,2CAAM;IACjC,MAAM,EAAE,iBAAiB,GAAG,2CAAM;AAClC,WAAO,IAAI,eACV;GAED;GACD,KAAKA,iCAAmB,UAAU;IACjC,MAAM,EAAE,mBAAmB,GAAG,2CAAM;IACpC,MAAM,EAAE,oBAAoB,GAAG,2CAAM;AACrC,WAAO,IAAI,kBACV;GAED;GACD,KAAKA,iCAAmB,KAAK;IAC5B,MAAM,EAAE,cAAc,GAAG,2CAAM;IAC/B,MAAM,EAAE,eAAe,GAAG,2CAAM;AAChC,WAAO,IAAI,aACV;GAED;GACD,KAAKA,iCAAmB,KAAK;IAC5B,MAAM,EAAE,cAAc,GAAG,2CAAM;IAC/B,MAAM,EAAE,eAAe,GAAG,2CAAM;AAChC,WAAO,IAAI,aACV;GAED;GACD,KAAKA,iCAAmB,QAAQ;IAC/B,MAAM,EAAE,iBAAiB,GAAG,2CAAM;IAClC,MAAM,EAAE,kBAAkB,GAAG,2CAAM;AACnC,WAAO,IAAI,gBACV;GAED;GACD,QACC,OAAM,IAAI,OAAO,+BAA+B,WAAW,KAAK;EACjE;CACD;AACD"}
@@ -1,12 +1,17 @@
1
1
  import { EventConnection, EventPublisher, EventPublisherType, PublishableMessage } from "./types-Dh9Jyinx.mjs";
2
2
 
3
3
  //#region src/Publisher.d.ts
4
+ /** Options a transport uses when it supports them, ignored by the rest. */
5
+ interface PublisherOptions<TMessage extends PublishableMessage<string, any>> {
6
+ /** The FIFO message group for each message (SQS). */
7
+ groupId?: (message: TMessage) => string;
8
+ }
4
9
  declare class Publisher {
5
10
  /**
6
11
  * Create a publisher from a connection string
7
12
  * This creates both a connection and a publisher
8
13
  */
9
- static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionStr: EventPublisherConnectionString): Promise<EventPublisher<TMessage>>;
14
+ static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionStr: EventPublisherConnectionString, options?: PublisherOptions<TMessage>): Promise<EventPublisher<TMessage>>;
10
15
  /**
11
16
  * Create a publisher from an existing connection
12
17
  * This allows sharing connections between publishers and subscribers
@@ -17,5 +22,5 @@ type EventPublisherConnectionString = `${EventPublisherType}://${string}`;
17
22
  //# sourceMappingURL=Publisher.d.ts.map
18
23
 
19
24
  //#endregion
20
- export { EventPublisherConnectionString, Publisher };
21
- //# sourceMappingURL=Publisher-VHumMkrP.d.mts.map
25
+ export { EventPublisherConnectionString, Publisher, PublisherOptions };
26
+ //# sourceMappingURL=Publisher-s3Oj6vUG.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Publisher-s3Oj6vUG.d.mts","names":[],"sources":["../src/Publisher.ts"],"sourcesContent":[],"mappings":";;;;AAQiB,UAAA,gBAAgB,CAAA,iBACf,kBADe,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA;EAAA;EAAA,OACf,CAAA,EAAA,CAAA,OAAA,EAGG,QAHH,EAAA,GAAA,MAAA;;AAGW,cAGhB,SAAA,CAHgB;EAGhB;;;;EAQkC,OACnB,oBAAA,CAAA,iBAHT,kBAGS,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,aAAA,EADX,8BACW,EAAA,OAAA,CAAA,EAAjB,gBAAiB,CAAA,QAAA,CAAA,CAAA,EACxB,OADwB,CAChB,cADgB,CACD,QADC,CAAA,CAAA;EAAQ;;;;EACzB,OAqCmC,cAAA,CAAA,iBAAA,kBAAA,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,UAAA,EAChC,eADgC,CAAA,EAE1C,OAF0C,CAElC,cAFkC,CAEnB,QAFmB,CAAA,CAAA;;AAEnB,KA2Cf,8BAAA,GA3Ce,GA4CvB,kBA5CuB,MAAA,MAAA,EAAA"}
@@ -1,4 +1,4 @@
1
1
  require('./types-Byv8N9ma.cjs');
2
- const require_Publisher = require('./Publisher-CKloIGh6.cjs');
2
+ const require_Publisher = require('./Publisher-QwLaFS2C.cjs');
3
3
 
4
4
  exports.Publisher = require_Publisher.Publisher;
@@ -1,3 +1,3 @@
1
1
  import "./types-Dj23od3e.cjs";
2
- import { EventPublisherConnectionString, Publisher } from "./Publisher-DDee6xau.cjs";
3
- export { EventPublisherConnectionString, Publisher };
2
+ import { EventPublisherConnectionString, Publisher, PublisherOptions } from "./Publisher-BRD9Asio.cjs";
3
+ export { EventPublisherConnectionString, Publisher, PublisherOptions };
@@ -1,3 +1,3 @@
1
1
  import "./types-Dh9Jyinx.mjs";
2
- import { EventPublisherConnectionString, Publisher } from "./Publisher-VHumMkrP.mjs";
3
- export { EventPublisherConnectionString, Publisher };
2
+ import { EventPublisherConnectionString, Publisher, PublisherOptions } from "./Publisher-s3Oj6vUG.mjs";
3
+ export { EventPublisherConnectionString, Publisher, PublisherOptions };
@@ -1,4 +1,4 @@
1
1
  import "./types-BrdcSEnd.mjs";
2
- import { Publisher } from "./Publisher-ChLTrUeP.mjs";
2
+ import { Publisher } from "./Publisher-DpRC2iZf.mjs";
3
3
 
4
4
  export { Publisher };
@@ -1,5 +1,4 @@
1
1
  import { EventPublisherType } from "./types-BrdcSEnd.mjs";
2
- import amqplib from "amqplib";
3
2
 
4
3
  //#region src/rabbitmq/RabbitMQConnection.ts
5
4
  var RabbitMQConnection = class RabbitMQConnection {
@@ -47,7 +46,8 @@ var RabbitMQConnection = class RabbitMQConnection {
47
46
  }
48
47
  this.connecting = (async () => {
49
48
  try {
50
- const connection = await amqplib.connect(this.config.url, { timeout: this.config.timeout });
49
+ const { default: amqp } = await import("amqplib");
50
+ const connection = await amqp.connect(this.config.url, { timeout: this.config.timeout });
51
51
  const channel = await connection.createChannel();
52
52
  await channel.assertExchange(this.config.exchange, this.config.exchangeType, this.config.exchangeOptions);
53
53
  connection.on("error", (_err) => {
@@ -104,4 +104,4 @@ var RabbitMQConnection = class RabbitMQConnection {
104
104
 
105
105
  //#endregion
106
106
  export { RabbitMQConnection };
107
- //# sourceMappingURL=RabbitMQConnection-Cg7mp8u-.mjs.map
107
+ //# sourceMappingURL=RabbitMQConnection-CW-92QTt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RabbitMQConnection-CW-92QTt.mjs","names":["config: RabbitMQConnectionConfig","connectionString: string","_err: Error"],"sources":["../src/rabbitmq/RabbitMQConnection.ts"],"sourcesContent":["import type 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\t// Loaded here, not at the top of the module: an app bundled into one\n\t\t\t\t// file that never connects to RabbitMQ must not need amqplib installed.\n\t\t\t\tconst { default: amqp } = await import('amqplib');\n\t\t\t\tconst connection = await amqp.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"],"mappings":";;;AAYA,IAAa,qBAAb,MAAa,mBAA8C;CAC1D,AAAS,OAAO,mBAAmB;CACnC,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAKR,YAAYA,QAAkC;AAC7C,OAAK,SAAS;GACb,GAAG;GACH,UAAU,OAAO,YAAY;GAC7B,cAAc,OAAO,gBAAgB;GACrC,SAAS,OAAO,WAAW;GAC3B,iBAAiB;IAChB,SAAS;IACT,GAAG,OAAO;GACV;EACD;CACD;;;;;CAMD,aAAa,qBACZC,kBAC8B;EAC9B,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAGnB,MAAM,WAAW,SAAS,IAAI,YAAY,EAAE,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,GAAG,EAAE,IAAI,KAAK,EAAE,IAAI,SAAS;EAE3G,MAAM,eAAe,OAAO,IAAI,UAAU;EAC1C,MAAMD,SAAmC;GACxC,KAAK;GACL,UAAU,OAAO,IAAI,WAAW,IAAI;GACpC,cAAe,OAAO,IAAI,OAAO,IAAY;GAC7C,SAAS,eAAe,OAAO,SAAS,cAAc,GAAG;EACzD;EAED,MAAM,aAAa,IAAI,mBAAmB;AAC1C,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAC9B,MAAI,KAAK,QAAS;AAGlB,MAAI,KAAK,YAAY;AACpB,SAAM,KAAK;AACX;EACA;AAED,OAAK,aAAa,CAAC,YAAY;AAC9B,OAAI;IAGH,MAAM,EAAE,SAAS,MAAM,GAAG,MAAM,OAAO;IACvC,MAAM,aAAa,MAAM,KAAK,QAAQ,KAAK,OAAO,KAAK,EACtD,SAAS,KAAK,OAAO,QACrB,EAAC;IACF,MAAM,UAAU,MAAM,WAAW,eAAe;AAGhD,UAAM,QAAQ,eACb,KAAK,OAAO,UACZ,KAAK,OAAO,cACZ,KAAK,OAAO,gBACZ;AAGD,eAAW,GAAG,SAAS,CAACE,SAAgB;AACvC,UAAK,SAAS;IACd,EAAC;AAEF,eAAW,GAAG,SAAS,MAAM;AAC5B,UAAK,SAAS;IACd,EAAC;AAGF,SAAK,aAAa;AAClB,SAAK,UAAU;GACf,SAAQ,OAAO;AACf,SAAK,SAAS;AACd,UAAM;GACN;EACD,IAAG;AAEJ,QAAM,KAAK;AACX,OAAK;CACL;CAED,MAAM,QAAuB;AAC5B,MAAI;AACH,SAAM,KAAK,SAAS,OAAO;AAC3B,SAAM,KAAK,YAAY,OAAO;EAC9B,SAAQ,QAAQ,CAEhB,UAAS;AACT,QAAK,SAAS;EACd;CACD;CAED,cAAuB;AACtB,WAAS,KAAK;CACd;CAED,AAAQ,UAAgB;AACvB,OAAK;AACL,OAAK;AACL,OAAK;CACL;;;;CAKD,IAAI,cAA2C;AAC9C,SAAO,KAAK;CACZ;;;;CAKD,IAAI,eAAuB;AAC1B,SAAO,KAAK,OAAO;CACnB;;;;CAKD,IAAI,eAAuB;AAC1B,SAAO,KAAK,OAAO;CACnB;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"RabbitMQConnection-DV9t3VYp.d.mts","names":[],"sources":["../src/rabbitmq/RabbitMQConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,wBAAA;EAAA,GAAA,EAAA,MAAA;EAQJ,QAAA,CAAA,EAAA,MAAA;EAAmB,YAAA,CAAA,EAAA,OAAA,GAAA,QAAA,GAAA,QAAA,GAAA,SAAA;EAAA,eAClB,CAAA,EALK,OAAA,CAAQ,OAAA,CAAQ,cAKrB;EAAA,OASO,CAAA,EAAA,MAAA;;AAmBjB,cA7BS,kBAAA,YAA8B,eA6BvC,CAAA;EAAO,SAoBO,IAAA,GAhDJ,kBAAA,CAAA,QAAA;EAgDW,QA6CT,UAAA;EAAO,QAwBH,OAAQ;EAAO,QAtHQ,UAAA;EAAe,QAAA,MAAA;sBAUrC;;;;;yDAmBjB,QAAQ;aAoBM;WA6CF;;;;;;qBAwBI,OAAA,CAAQ"}
1
+ {"version":3,"file":"RabbitMQConnection-DV9t3VYp.d.mts","names":[],"sources":["../src/rabbitmq/RabbitMQConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,wBAAA;EAAA,GAAA,EAAA,MAAA;EAQJ,QAAA,CAAA,EAAA,MAAA;EAAmB,YAAA,CAAA,EAAA,OAAA,GAAA,QAAA,GAAA,QAAA,GAAA,SAAA;EAAA,eAClB,CAAA,EALK,OAAA,CAAQ,OAAA,CAAQ,cAKrB;EAAA,OASO,CAAA,EAAA,MAAA;;AAmBjB,cA7BS,kBAAA,YAA8B,eA6BvC,CAAA;EAAO,SAoBO,IAAA,GAhDJ,kBAAA,CAAA,QAAA;EAgDW,QAgDT,UAAA;EAAO,QAwBH,OAAQ;EAAO,QAzHQ,UAAA;EAAe,QAAA,MAAA;sBAUrC;;;;;yDAmBjB,QAAQ;aAoBM;WAgDF;;;;;;qBAwBI,OAAA,CAAQ"}
@@ -1,6 +1,4 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
1
  const require_types = require('./types-Byv8N9ma.cjs');
3
- const amqplib = require_chunk.__toESM(require("amqplib"));
4
2
 
5
3
  //#region src/rabbitmq/RabbitMQConnection.ts
6
4
  var RabbitMQConnection = class RabbitMQConnection {
@@ -48,7 +46,8 @@ var RabbitMQConnection = class RabbitMQConnection {
48
46
  }
49
47
  this.connecting = (async () => {
50
48
  try {
51
- const connection = await amqplib.default.connect(this.config.url, { timeout: this.config.timeout });
49
+ const { default: amqp } = await import("amqplib");
50
+ const connection = await amqp.connect(this.config.url, { timeout: this.config.timeout });
52
51
  const channel = await connection.createChannel();
53
52
  await channel.assertExchange(this.config.exchange, this.config.exchangeType, this.config.exchangeOptions);
54
53
  connection.on("error", (_err) => {
@@ -110,4 +109,4 @@ Object.defineProperty(exports, 'RabbitMQConnection', {
110
109
  return RabbitMQConnection;
111
110
  }
112
111
  });
113
- //# sourceMappingURL=RabbitMQConnection-DddqvI3I.cjs.map
112
+ //# sourceMappingURL=RabbitMQConnection-Diwv0RIa.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RabbitMQConnection-Diwv0RIa.cjs","names":["EventPublisherType","config: RabbitMQConnectionConfig","connectionString: string","_err: Error"],"sources":["../src/rabbitmq/RabbitMQConnection.ts"],"sourcesContent":["import type 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\t// Loaded here, not at the top of the module: an app bundled into one\n\t\t\t\t// file that never connects to RabbitMQ must not need amqplib installed.\n\t\t\t\tconst { default: amqp } = await import('amqplib');\n\t\t\t\tconst connection = await amqp.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"],"mappings":";;;AAYA,IAAa,qBAAb,MAAa,mBAA8C;CAC1D,AAAS,OAAOA,iCAAmB;CACnC,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAKR,YAAYC,QAAkC;AAC7C,OAAK,SAAS;GACb,GAAG;GACH,UAAU,OAAO,YAAY;GAC7B,cAAc,OAAO,gBAAgB;GACrC,SAAS,OAAO,WAAW;GAC3B,iBAAiB;IAChB,SAAS;IACT,GAAG,OAAO;GACV;EACD;CACD;;;;;CAMD,aAAa,qBACZC,kBAC8B;EAC9B,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAGnB,MAAM,WAAW,SAAS,IAAI,YAAY,EAAE,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,GAAG,EAAE,IAAI,KAAK,EAAE,IAAI,SAAS;EAE3G,MAAM,eAAe,OAAO,IAAI,UAAU;EAC1C,MAAMD,SAAmC;GACxC,KAAK;GACL,UAAU,OAAO,IAAI,WAAW,IAAI;GACpC,cAAe,OAAO,IAAI,OAAO,IAAY;GAC7C,SAAS,eAAe,OAAO,SAAS,cAAc,GAAG;EACzD;EAED,MAAM,aAAa,IAAI,mBAAmB;AAC1C,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAC9B,MAAI,KAAK,QAAS;AAGlB,MAAI,KAAK,YAAY;AACpB,SAAM,KAAK;AACX;EACA;AAED,OAAK,aAAa,CAAC,YAAY;AAC9B,OAAI;IAGH,MAAM,EAAE,SAAS,MAAM,GAAG,MAAM,OAAO;IACvC,MAAM,aAAa,MAAM,KAAK,QAAQ,KAAK,OAAO,KAAK,EACtD,SAAS,KAAK,OAAO,QACrB,EAAC;IACF,MAAM,UAAU,MAAM,WAAW,eAAe;AAGhD,UAAM,QAAQ,eACb,KAAK,OAAO,UACZ,KAAK,OAAO,cACZ,KAAK,OAAO,gBACZ;AAGD,eAAW,GAAG,SAAS,CAACE,SAAgB;AACvC,UAAK,SAAS;IACd,EAAC;AAEF,eAAW,GAAG,SAAS,MAAM;AAC5B,UAAK,SAAS;IACd,EAAC;AAGF,SAAK,aAAa;AAClB,SAAK,UAAU;GACf,SAAQ,OAAO;AACf,SAAK,SAAS;AACd,UAAM;GACN;EACD,IAAG;AAEJ,QAAM,KAAK;AACX,OAAK;CACL;CAED,MAAM,QAAuB;AAC5B,MAAI;AACH,SAAM,KAAK,SAAS,OAAO;AAC3B,SAAM,KAAK,YAAY,OAAO;EAC9B,SAAQ,QAAQ,CAEhB,UAAS;AACT,QAAK,SAAS;EACd;CACD;CAED,cAAuB;AACtB,WAAS,KAAK;CACd;CAED,AAAQ,UAAgB;AACvB,OAAK;AACL,OAAK;AACL,OAAK;CACL;;;;CAKD,IAAI,cAA2C;AAC9C,SAAO,KAAK;CACZ;;;;CAKD,IAAI,eAAuB;AAC1B,SAAO,KAAK,OAAO;CACnB;;;;CAKD,IAAI,eAAuB;AAC1B,SAAO,KAAK,OAAO;CACnB;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"RabbitMQConnection-jNME_eR7.d.cts","names":[],"sources":["../src/rabbitmq/RabbitMQConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,wBAAA;EAAA,GAAA,EAAA,MAAA;EAQJ,QAAA,CAAA,EAAA,MAAA;EAAmB,YAAA,CAAA,EAAA,OAAA,GAAA,QAAA,GAAA,QAAA,GAAA,SAAA;EAAA,eAClB,CAAA,EALK,OAAA,CAAQ,OAAA,CAAQ,cAKrB;EAAA,OASO,CAAA,EAAA,MAAA;;AAmBjB,cA7BS,kBAAA,YAA8B,eA6BvC,CAAA;EAAO,SAoBO,IAAA,GAhDJ,kBAAA,CAAA,QAAA;EAgDW,QA6CT,UAAA;EAAO,QAwBH,OAAQ;EAAO,QAtHQ,UAAA;EAAe,QAAA,MAAA;sBAUrC;;;;;yDAmBjB,QAAQ;aAoBM;WA6CF;;;;;;qBAwBI,OAAA,CAAQ"}
1
+ {"version":3,"file":"RabbitMQConnection-jNME_eR7.d.cts","names":[],"sources":["../src/rabbitmq/RabbitMQConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,wBAAA;EAAA,GAAA,EAAA,MAAA;EAQJ,QAAA,CAAA,EAAA,MAAA;EAAmB,YAAA,CAAA,EAAA,OAAA,GAAA,QAAA,GAAA,QAAA,GAAA,SAAA;EAAA,eAClB,CAAA,EALK,OAAA,CAAQ,OAAA,CAAQ,cAKrB;EAAA,OASO,CAAA,EAAA,MAAA;;AAmBjB,cA7BS,kBAAA,YAA8B,eA6BvC,CAAA;EAAO,SAoBO,IAAA,GAhDJ,kBAAA,CAAA,QAAA;EAgDW,QAgDT,UAAA;EAAO,QAwBH,OAAQ;EAAO,QAzHQ,UAAA;EAAe,QAAA,MAAA;sBAUrC;;;;;yDAmBjB,QAAQ;aAoBM;WAgDF;;;;;;qBAwBI,OAAA,CAAQ"}
@@ -42,4 +42,4 @@ Object.defineProperty(exports, 'RabbitMQPublisher', {
42
42
  return RabbitMQPublisher;
43
43
  }
44
44
  });
45
- //# sourceMappingURL=RabbitMQPublisher-BfTRUnpy.cjs.map
45
+ //# sourceMappingURL=RabbitMQPublisher-C94q6g8q.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RabbitMQPublisher-BfTRUnpy.cjs","names":["connection: RabbitMQConnection","options: RabbitMQPublisherOptions","connectionString: string","messages: TMessage[]"],"sources":["../src/rabbitmq/RabbitMQPublisher.ts"],"sourcesContent":["import type amqplib from 'amqplib';\nimport type { EventPublisher, PublishableMessage } from '../types';\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 Error('Channel not initialized');\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"],"mappings":";;AAQA,IAAa,oBAAb,MAAa,kBAEb;CACC,YACSA,YACAC,UAAoC,CAAE,GAC7C;EAFO;EACA;CACL;;;;;CAMJ,aAAa,qBAEXC,kBAAgE;EACjE,MAAM,EAAE,oBAAoB,GAAG,2CAAM;EACrC,MAAM,aACL,MAAM,mBAAmB,qBAAqB,iBAAiB;AAChE,SAAO,IAAI,kBAA4B;CACvC;CAED,MAAM,QAAQC,UAAqC;AAClD,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,QACJ,OAAM,IAAI,MAAM;EAGjB,MAAM,WAAW,KAAK,WAAW;AAEjC,OAAK,MAAM,WAAW,UAAU;GAC/B,MAAM,UAAU,OAAO,KAAK,KAAK,UAAU,QAAQ,QAAQ,CAAC;GAG5D,MAAM,aAAa,QAAQ;GAE3B,MAAM,YAAY,QAAQ,QAAQ,UAAU,YAAY,SAAS;IAChE,aAAa;IACb,WAAW,KAAK,KAAK;IACrB,MAAM,QAAQ;IACd,YAAY;IACZ,GAAG,KAAK,QAAQ;GAChB,EAAC;AAGF,QAAK,UACJ,OAAM,IAAI,QAAQ,CAAC,YAAY,QAAQ,KAAK,SAAS,QAAQ;EAE9D;CACD;CAED,MAAM,QAAuB,CAG5B;AACD"}
1
+ {"version":3,"file":"RabbitMQPublisher-C94q6g8q.cjs","names":["connection: RabbitMQConnection","options: RabbitMQPublisherOptions","connectionString: string","messages: TMessage[]"],"sources":["../src/rabbitmq/RabbitMQPublisher.ts"],"sourcesContent":["import type amqplib from 'amqplib';\nimport type { EventPublisher, PublishableMessage } from '../types';\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 Error('Channel not initialized');\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"],"mappings":";;AAQA,IAAa,oBAAb,MAAa,kBAEb;CACC,YACSA,YACAC,UAAoC,CAAE,GAC7C;EAFO;EACA;CACL;;;;;CAMJ,aAAa,qBAEXC,kBAAgE;EACjE,MAAM,EAAE,oBAAoB,GAAG,2CAAM;EACrC,MAAM,aACL,MAAM,mBAAmB,qBAAqB,iBAAiB;AAChE,SAAO,IAAI,kBAA4B;CACvC;CAED,MAAM,QAAQC,UAAqC;AAClD,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,QACJ,OAAM,IAAI,MAAM;EAGjB,MAAM,WAAW,KAAK,WAAW;AAEjC,OAAK,MAAM,WAAW,UAAU;GAC/B,MAAM,UAAU,OAAO,KAAK,KAAK,UAAU,QAAQ,QAAQ,CAAC;GAG5D,MAAM,aAAa,QAAQ;GAE3B,MAAM,YAAY,QAAQ,QAAQ,UAAU,YAAY,SAAS;IAChE,aAAa;IACb,WAAW,KAAK,KAAK;IACrB,MAAM,QAAQ;IACd,YAAY;IACZ,GAAG,KAAK,QAAQ;GAChB,EAAC;AAGF,QAAK,UACJ,OAAM,IAAI,QAAQ,CAAC,YAAY,QAAQ,KAAK,SAAS,QAAQ;EAE9D;CACD;CAED,MAAM,QAAuB,CAG5B;AACD"}
@@ -36,4 +36,4 @@ var RabbitMQPublisher = class RabbitMQPublisher {
36
36
 
37
37
  //#endregion
38
38
  export { RabbitMQPublisher };
39
- //# sourceMappingURL=RabbitMQPublisher-Cxm1zSkD.mjs.map
39
+ //# sourceMappingURL=RabbitMQPublisher-yUqWNq-P.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RabbitMQPublisher-Cxm1zSkD.mjs","names":["connection: RabbitMQConnection","options: RabbitMQPublisherOptions","connectionString: string","messages: TMessage[]"],"sources":["../src/rabbitmq/RabbitMQPublisher.ts"],"sourcesContent":["import type amqplib from 'amqplib';\nimport type { EventPublisher, PublishableMessage } from '../types';\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 Error('Channel not initialized');\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"],"mappings":";AAQA,IAAa,oBAAb,MAAa,kBAEb;CACC,YACSA,YACAC,UAAoC,CAAE,GAC7C;EAFO;EACA;CACL;;;;;CAMJ,aAAa,qBAEXC,kBAAgE;EACjE,MAAM,EAAE,oBAAoB,GAAG,MAAM,OAAO;EAC5C,MAAM,aACL,MAAM,mBAAmB,qBAAqB,iBAAiB;AAChE,SAAO,IAAI,kBAA4B;CACvC;CAED,MAAM,QAAQC,UAAqC;AAClD,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,QACJ,OAAM,IAAI,MAAM;EAGjB,MAAM,WAAW,KAAK,WAAW;AAEjC,OAAK,MAAM,WAAW,UAAU;GAC/B,MAAM,UAAU,OAAO,KAAK,KAAK,UAAU,QAAQ,QAAQ,CAAC;GAG5D,MAAM,aAAa,QAAQ;GAE3B,MAAM,YAAY,QAAQ,QAAQ,UAAU,YAAY,SAAS;IAChE,aAAa;IACb,WAAW,KAAK,KAAK;IACrB,MAAM,QAAQ;IACd,YAAY;IACZ,GAAG,KAAK,QAAQ;GAChB,EAAC;AAGF,QAAK,UACJ,OAAM,IAAI,QAAQ,CAAC,YAAY,QAAQ,KAAK,SAAS,QAAQ;EAE9D;CACD;CAED,MAAM,QAAuB,CAG5B;AACD"}
1
+ {"version":3,"file":"RabbitMQPublisher-yUqWNq-P.mjs","names":["connection: RabbitMQConnection","options: RabbitMQPublisherOptions","connectionString: string","messages: TMessage[]"],"sources":["../src/rabbitmq/RabbitMQPublisher.ts"],"sourcesContent":["import type amqplib from 'amqplib';\nimport type { EventPublisher, PublishableMessage } from '../types';\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 Error('Channel not initialized');\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"],"mappings":";AAQA,IAAa,oBAAb,MAAa,kBAEb;CACC,YACSA,YACAC,UAAoC,CAAE,GAC7C;EAFO;EACA;CACL;;;;;CAMJ,aAAa,qBAEXC,kBAAgE;EACjE,MAAM,EAAE,oBAAoB,GAAG,MAAM,OAAO;EAC5C,MAAM,aACL,MAAM,mBAAmB,qBAAqB,iBAAiB;AAChE,SAAO,IAAI,kBAA4B;CACvC;CAED,MAAM,QAAQC,UAAqC;AAClD,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,QACJ,OAAM,IAAI,MAAM;EAGjB,MAAM,WAAW,KAAK,WAAW;AAEjC,OAAK,MAAM,WAAW,UAAU;GAC/B,MAAM,UAAU,OAAO,KAAK,KAAK,UAAU,QAAQ,QAAQ,CAAC;GAG5D,MAAM,aAAa,QAAQ;GAE3B,MAAM,YAAY,QAAQ,QAAQ,UAAU,YAAY,SAAS;IAChE,aAAa;IACb,WAAW,KAAK,KAAK;IACrB,MAAM,QAAQ;IACd,YAAY;IACZ,GAAG,KAAK,QAAQ;GAChB,EAAC;AAGF,QAAK,UACJ,OAAM,IAAI,QAAQ,CAAC,YAAY,QAAQ,KAAK,SAAS,QAAQ;EAE9D;CACD;CAED,MAAM,QAAuB,CAG5B;AACD"}
@@ -53,4 +53,4 @@ var RabbitMQSubscriber = class RabbitMQSubscriber {
53
53
 
54
54
  //#endregion
55
55
  export { RabbitMQSubscriber };
56
- //# sourceMappingURL=RabbitMQSubscriber-fP8G9OlK.mjs.map
56
+ //# sourceMappingURL=RabbitMQSubscriber-BWniDtFs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RabbitMQSubscriber-fP8G9OlK.mjs","names":["connection: RabbitMQConnection","options: RabbitMQSubscriberOptions","connectionString: string","messages: TMessage['type'][]","listener: (payload: TMessage) => Promise<void>","queueOptions: amqplib.Options.AssertQueue","fullMessage: TMessage"],"sources":["../src/rabbitmq/RabbitMQSubscriber.ts"],"sourcesContent":["import type amqplib from 'amqplib';\nimport type { EventSubscriber, PublishableMessage } from '../types';\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 Error('Channel not initialized');\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":";AAWA,IAAa,qBAAb,MAAa,mBAGb;CACC,YACSA,YACAC,UAAqC,CAAE,GAC9C;EAFO;EACA;CACL;;;;;CAMJ,aAAa,qBAEXC,kBAAiE;EAClE,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,EAAE,oBAAoB,GAAG,MAAM,OAAO;EAC5C,MAAM,aACL,MAAM,mBAAmB,qBAAqB,iBAAiB;EAEhE,MAAMD,UAAqC;GAC1C,WAAW,OAAO,IAAI,YAAY;GAClC,UAAU,OAAO,IAAI,WAAW,GAC7B,OAAO,SAAS,OAAO,IAAI,WAAW,EAAG,GAAG;EAE/C;AAED,SAAO,IAAI,mBAA6B,YAAY;CACpD;CAED,MAAM,UACLE,UACAC,UACgB;AAChB,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,QACJ,OAAM,IAAI,MAAM;EAGjB,MAAM,WAAW,KAAK,WAAW;AAGjC,MAAI,KAAK,QAAQ,SAChB,OAAM,QAAQ,SAAS,KAAK,QAAQ,SAAS;EAI9C,MAAM,YAAY,KAAK,QAAQ,aAAa;EAC5C,MAAMC,eAA4C;GACjD,SAAS;GACT,GAAG,KAAK,QAAQ;EAChB;EAED,MAAM,EAAE,OAAO,GAAG,MAAM,QAAQ,YAAY,WAAW,aAAa;AAGpE,OAAK,MAAM,eAAe,SACzB,OAAM,QAAQ,UAAU,OAAO,UAAU,YAAY;AAItD,QAAM,QAAQ,QACb,OACA,OAAO,QAAQ;AACd,QAAK,IAAK;AAEV,OAAI;IAEH,MAAM,UAAU,IAAI,QAAQ,UAAU;IACtC,MAAM,UAAU,KAAK,MAAM,QAAQ;IAGnC,MAAM,cAAc,IAAI,WAAW;IAGnC,MAAMC,cAAwB;KAC7B,MAAM;KACN;IACA;AAGD,UAAM,SAAS,YAAY;AAG3B,YAAQ,IAAI,IAAI;GAChB,SAAQ,QAAQ;AAChB,YAAQ,KAAK,KAAK,OAAO,KAAK;GAC9B;EACD,GACD,KAAK,QAAQ,eACb;CACD;AACD"}
1
+ {"version":3,"file":"RabbitMQSubscriber-BWniDtFs.mjs","names":["connection: RabbitMQConnection","options: RabbitMQSubscriberOptions","connectionString: string","messages: TMessage['type'][]","listener: (payload: TMessage) => Promise<void>","queueOptions: amqplib.Options.AssertQueue","fullMessage: TMessage"],"sources":["../src/rabbitmq/RabbitMQSubscriber.ts"],"sourcesContent":["import type amqplib from 'amqplib';\nimport type { EventSubscriber, PublishableMessage } from '../types';\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 Error('Channel not initialized');\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":";AAWA,IAAa,qBAAb,MAAa,mBAGb;CACC,YACSA,YACAC,UAAqC,CAAE,GAC9C;EAFO;EACA;CACL;;;;;CAMJ,aAAa,qBAEXC,kBAAiE;EAClE,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,EAAE,oBAAoB,GAAG,MAAM,OAAO;EAC5C,MAAM,aACL,MAAM,mBAAmB,qBAAqB,iBAAiB;EAEhE,MAAMD,UAAqC;GAC1C,WAAW,OAAO,IAAI,YAAY;GAClC,UAAU,OAAO,IAAI,WAAW,GAC7B,OAAO,SAAS,OAAO,IAAI,WAAW,EAAG,GAAG;EAE/C;AAED,SAAO,IAAI,mBAA6B,YAAY;CACpD;CAED,MAAM,UACLE,UACAC,UACgB;AAChB,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,QACJ,OAAM,IAAI,MAAM;EAGjB,MAAM,WAAW,KAAK,WAAW;AAGjC,MAAI,KAAK,QAAQ,SAChB,OAAM,QAAQ,SAAS,KAAK,QAAQ,SAAS;EAI9C,MAAM,YAAY,KAAK,QAAQ,aAAa;EAC5C,MAAMC,eAA4C;GACjD,SAAS;GACT,GAAG,KAAK,QAAQ;EAChB;EAED,MAAM,EAAE,OAAO,GAAG,MAAM,QAAQ,YAAY,WAAW,aAAa;AAGpE,OAAK,MAAM,eAAe,SACzB,OAAM,QAAQ,UAAU,OAAO,UAAU,YAAY;AAItD,QAAM,QAAQ,QACb,OACA,OAAO,QAAQ;AACd,QAAK,IAAK;AAEV,OAAI;IAEH,MAAM,UAAU,IAAI,QAAQ,UAAU;IACtC,MAAM,UAAU,KAAK,MAAM,QAAQ;IAGnC,MAAM,cAAc,IAAI,WAAW;IAGnC,MAAMC,cAAwB;KAC7B,MAAM;KACN;IACA;AAGD,UAAM,SAAS,YAAY;AAG3B,YAAQ,IAAI,IAAI;GAChB,SAAQ,QAAQ;AAChB,YAAQ,KAAK,KAAK,OAAO,KAAK;GAC9B;EACD,GACD,KAAK,QAAQ,eACb;CACD;AACD"}
@@ -59,4 +59,4 @@ Object.defineProperty(exports, 'RabbitMQSubscriber', {
59
59
  return RabbitMQSubscriber;
60
60
  }
61
61
  });
62
- //# sourceMappingURL=RabbitMQSubscriber-CWDdmt1M.cjs.map
62
+ //# sourceMappingURL=RabbitMQSubscriber-DGEO-clQ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RabbitMQSubscriber-CWDdmt1M.cjs","names":["connection: RabbitMQConnection","options: RabbitMQSubscriberOptions","connectionString: string","messages: TMessage['type'][]","listener: (payload: TMessage) => Promise<void>","queueOptions: amqplib.Options.AssertQueue","fullMessage: TMessage"],"sources":["../src/rabbitmq/RabbitMQSubscriber.ts"],"sourcesContent":["import type amqplib from 'amqplib';\nimport type { EventSubscriber, PublishableMessage } from '../types';\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 Error('Channel not initialized');\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":";;AAWA,IAAa,qBAAb,MAAa,mBAGb;CACC,YACSA,YACAC,UAAqC,CAAE,GAC9C;EAFO;EACA;CACL;;;;;CAMJ,aAAa,qBAEXC,kBAAiE;EAClE,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,EAAE,oBAAoB,GAAG,2CAAM;EACrC,MAAM,aACL,MAAM,mBAAmB,qBAAqB,iBAAiB;EAEhE,MAAMD,UAAqC;GAC1C,WAAW,OAAO,IAAI,YAAY;GAClC,UAAU,OAAO,IAAI,WAAW,GAC7B,OAAO,SAAS,OAAO,IAAI,WAAW,EAAG,GAAG;EAE/C;AAED,SAAO,IAAI,mBAA6B,YAAY;CACpD;CAED,MAAM,UACLE,UACAC,UACgB;AAChB,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,QACJ,OAAM,IAAI,MAAM;EAGjB,MAAM,WAAW,KAAK,WAAW;AAGjC,MAAI,KAAK,QAAQ,SAChB,OAAM,QAAQ,SAAS,KAAK,QAAQ,SAAS;EAI9C,MAAM,YAAY,KAAK,QAAQ,aAAa;EAC5C,MAAMC,eAA4C;GACjD,SAAS;GACT,GAAG,KAAK,QAAQ;EAChB;EAED,MAAM,EAAE,OAAO,GAAG,MAAM,QAAQ,YAAY,WAAW,aAAa;AAGpE,OAAK,MAAM,eAAe,SACzB,OAAM,QAAQ,UAAU,OAAO,UAAU,YAAY;AAItD,QAAM,QAAQ,QACb,OACA,OAAO,QAAQ;AACd,QAAK,IAAK;AAEV,OAAI;IAEH,MAAM,UAAU,IAAI,QAAQ,UAAU;IACtC,MAAM,UAAU,KAAK,MAAM,QAAQ;IAGnC,MAAM,cAAc,IAAI,WAAW;IAGnC,MAAMC,cAAwB;KAC7B,MAAM;KACN;IACA;AAGD,UAAM,SAAS,YAAY;AAG3B,YAAQ,IAAI,IAAI;GAChB,SAAQ,QAAQ;AAChB,YAAQ,KAAK,KAAK,OAAO,KAAK;GAC9B;EACD,GACD,KAAK,QAAQ,eACb;CACD;AACD"}
1
+ {"version":3,"file":"RabbitMQSubscriber-DGEO-clQ.cjs","names":["connection: RabbitMQConnection","options: RabbitMQSubscriberOptions","connectionString: string","messages: TMessage['type'][]","listener: (payload: TMessage) => Promise<void>","queueOptions: amqplib.Options.AssertQueue","fullMessage: TMessage"],"sources":["../src/rabbitmq/RabbitMQSubscriber.ts"],"sourcesContent":["import type amqplib from 'amqplib';\nimport type { EventSubscriber, PublishableMessage } from '../types';\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 Error('Channel not initialized');\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":";;AAWA,IAAa,qBAAb,MAAa,mBAGb;CACC,YACSA,YACAC,UAAqC,CAAE,GAC9C;EAFO;EACA;CACL;;;;;CAMJ,aAAa,qBAEXC,kBAAiE;EAClE,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,EAAE,oBAAoB,GAAG,2CAAM;EACrC,MAAM,aACL,MAAM,mBAAmB,qBAAqB,iBAAiB;EAEhE,MAAMD,UAAqC;GAC1C,WAAW,OAAO,IAAI,YAAY;GAClC,UAAU,OAAO,IAAI,WAAW,GAC7B,OAAO,SAAS,OAAO,IAAI,WAAW,EAAG,GAAG;EAE/C;AAED,SAAO,IAAI,mBAA6B,YAAY;CACpD;CAED,MAAM,UACLE,UACAC,UACgB;AAChB,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,QACJ,OAAM,IAAI,MAAM;EAGjB,MAAM,WAAW,KAAK,WAAW;AAGjC,MAAI,KAAK,QAAQ,SAChB,OAAM,QAAQ,SAAS,KAAK,QAAQ,SAAS;EAI9C,MAAM,YAAY,KAAK,QAAQ,aAAa;EAC5C,MAAMC,eAA4C;GACjD,SAAS;GACT,GAAG,KAAK,QAAQ;EAChB;EAED,MAAM,EAAE,OAAO,GAAG,MAAM,QAAQ,YAAY,WAAW,aAAa;AAGpE,OAAK,MAAM,eAAe,SACzB,OAAM,QAAQ,UAAU,OAAO,UAAU,YAAY;AAItD,QAAM,QAAQ,QACb,OACA,OAAO,QAAQ;AACd,QAAK,IAAK;AAEV,OAAI;IAEH,MAAM,UAAU,IAAI,QAAQ,UAAU;IACtC,MAAM,UAAU,KAAK,MAAM,QAAQ;IAGnC,MAAM,cAAc,IAAI,WAAW;IAGnC,MAAMC,cAAwB;KAC7B,MAAM;KACN;IACA;AAGD,UAAM,SAAS,YAAY;AAG3B,YAAQ,IAAI,IAAI;GAChB,SAAQ,QAAQ;AAChB,YAAQ,KAAK,KAAK,OAAO,KAAK;GAC9B;EACD,GACD,KAAK,QAAQ,eACb;CACD;AACD"}
@@ -73,4 +73,4 @@ Object.defineProperty(exports, 'SNSConnection', {
73
73
  return SNSConnection;
74
74
  }
75
75
  });
76
- //# sourceMappingURL=SNSConnection-DFehUWG1.cjs.map
76
+ //# sourceMappingURL=SNSConnection-CAcbLQOy.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SNSConnection-DFehUWG1.cjs","names":["EventPublisherType","config: SNSConnectionConfig","clientConfig: SNSClientConfig","SNSClient","connectionString: string"],"sources":["../src/sns/SNSConnection.ts"],"sourcesContent":["import { SNSClient, type SNSClientConfig } from '@aws-sdk/client-sns';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface SNSConnectionConfig {\n\ttopicArn: string;\n\tregion?: string;\n\tendpoint?: string; // Custom endpoint (e.g., for LocalStack)\n\tcredentials?: {\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t};\n}\n\nexport class SNSConnection implements EventConnection {\n\treadonly type = EventPublisherType.SNS;\n\tprivate client: SNSClient;\n\tprivate connected = false;\n\tprivate config: SNSConnectionConfig;\n\n\tconstructor(config: SNSConnectionConfig) {\n\t\tthis.config = config;\n\n\t\tconst clientConfig: SNSClientConfig = {\n\t\t\tregion: config.region,\n\t\t\tendpoint: config.endpoint,\n\t\t\tcredentials: config.credentials,\n\t\t};\n\n\t\tthis.client = new SNSClient(clientConfig);\n\t}\n\n\t/**\n\t * Create an SNSConnection from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic&region=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<SNSConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst topicArn = params.get('topicArn');\n\t\tif (!topicArn) {\n\t\t\tthrow new Error('topicArn parameter is required in connection string');\n\t\t}\n\n\t\tconst config: SNSConnectionConfig = {\n\t\t\ttopicArn,\n\t\t\tregion: params.get('region') || undefined,\n\t\t\tendpoint: params.get('endpoint') || undefined,\n\t\t};\n\n\t\t// Parse credentials if provided\n\t\tconst accessKeyId = params.get('accessKeyId');\n\t\tconst secretAccessKey = params.get('secretAccessKey');\n\t\tif (accessKeyId && secretAccessKey) {\n\t\t\tconfig.credentials = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey,\n\t\t\t\tsessionToken: params.get('sessionToken') || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst connection = new SNSConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\t// SNS doesn't have a traditional connection, but we mark as connected\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.client.destroy();\n\t\tthis.connected = false;\n\t}\n\n\tisConnected(): boolean {\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Get the underlying SNS client\n\t */\n\tget snsClient(): SNSClient {\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Get the topic ARN for this connection\n\t */\n\tget topicArn(): string {\n\t\treturn this.config.topicArn;\n\t}\n}\n"],"mappings":";;;;;AAeA,IAAa,gBAAb,MAAa,cAAyC;CACrD,AAAS,OAAOA,iCAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CACpB,AAAQ;CAER,YAAYC,QAA6B;AACxC,OAAK,SAAS;EAEd,MAAMC,eAAgC;GACrC,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,aAAa,OAAO;EACpB;AAED,OAAK,SAAS,IAAIC,+BAAU;CAC5B;;;;;CAMD,aAAa,qBACZC,kBACyB;EACzB,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,WAAW,OAAO,IAAI,WAAW;AACvC,OAAK,SACJ,OAAM,IAAI,MAAM;EAGjB,MAAMH,SAA8B;GACnC;GACA,QAAQ,OAAO,IAAI,SAAS;GAC5B,UAAU,OAAO,IAAI,WAAW;EAChC;EAGD,MAAM,cAAc,OAAO,IAAI,cAAc;EAC7C,MAAM,kBAAkB,OAAO,IAAI,kBAAkB;AACrD,MAAI,eAAe,gBAClB,QAAO,cAAc;GACpB;GACA;GACA,cAAc,OAAO,IAAI,eAAe;EACxC;EAGF,MAAM,aAAa,IAAI,cAAc;AACrC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAE9B,OAAK,YAAY;CACjB;CAED,MAAM,QAAuB;AAC5B,OAAK,OAAO,SAAS;AACrB,OAAK,YAAY;CACjB;CAED,cAAuB;AACtB,SAAO,KAAK;CACZ;;;;CAKD,IAAI,YAAuB;AAC1B,SAAO,KAAK;CACZ;;;;CAKD,IAAI,WAAmB;AACtB,SAAO,KAAK,OAAO;CACnB;AACD"}
1
+ {"version":3,"file":"SNSConnection-CAcbLQOy.cjs","names":["EventPublisherType","config: SNSConnectionConfig","clientConfig: SNSClientConfig","SNSClient","connectionString: string"],"sources":["../src/sns/SNSConnection.ts"],"sourcesContent":["import { SNSClient, type SNSClientConfig } from '@aws-sdk/client-sns';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface SNSConnectionConfig {\n\ttopicArn: string;\n\tregion?: string;\n\tendpoint?: string; // Custom endpoint (e.g., for LocalStack)\n\tcredentials?: {\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t};\n}\n\nexport class SNSConnection implements EventConnection {\n\treadonly type = EventPublisherType.SNS;\n\tprivate client: SNSClient;\n\tprivate connected = false;\n\tprivate config: SNSConnectionConfig;\n\n\tconstructor(config: SNSConnectionConfig) {\n\t\tthis.config = config;\n\n\t\tconst clientConfig: SNSClientConfig = {\n\t\t\tregion: config.region,\n\t\t\tendpoint: config.endpoint,\n\t\t\tcredentials: config.credentials,\n\t\t};\n\n\t\tthis.client = new SNSClient(clientConfig);\n\t}\n\n\t/**\n\t * Create an SNSConnection from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic&region=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<SNSConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst topicArn = params.get('topicArn');\n\t\tif (!topicArn) {\n\t\t\tthrow new Error('topicArn parameter is required in connection string');\n\t\t}\n\n\t\tconst config: SNSConnectionConfig = {\n\t\t\ttopicArn,\n\t\t\tregion: params.get('region') || undefined,\n\t\t\tendpoint: params.get('endpoint') || undefined,\n\t\t};\n\n\t\t// Parse credentials if provided\n\t\tconst accessKeyId = params.get('accessKeyId');\n\t\tconst secretAccessKey = params.get('secretAccessKey');\n\t\tif (accessKeyId && secretAccessKey) {\n\t\t\tconfig.credentials = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey,\n\t\t\t\tsessionToken: params.get('sessionToken') || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst connection = new SNSConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\t// SNS doesn't have a traditional connection, but we mark as connected\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.client.destroy();\n\t\tthis.connected = false;\n\t}\n\n\tisConnected(): boolean {\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Get the underlying SNS client\n\t */\n\tget snsClient(): SNSClient {\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Get the topic ARN for this connection\n\t */\n\tget topicArn(): string {\n\t\treturn this.config.topicArn;\n\t}\n}\n"],"mappings":";;;;;AAeA,IAAa,gBAAb,MAAa,cAAyC;CACrD,AAAS,OAAOA,iCAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CACpB,AAAQ;CAER,YAAYC,QAA6B;AACxC,OAAK,SAAS;EAEd,MAAMC,eAAgC;GACrC,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,aAAa,OAAO;EACpB;AAED,OAAK,SAAS,IAAIC,+BAAU;CAC5B;;;;;CAMD,aAAa,qBACZC,kBACyB;EACzB,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,WAAW,OAAO,IAAI,WAAW;AACvC,OAAK,SACJ,OAAM,IAAI,MAAM;EAGjB,MAAMH,SAA8B;GACnC;GACA,QAAQ,OAAO,IAAI,SAAS;GAC5B,UAAU,OAAO,IAAI,WAAW;EAChC;EAGD,MAAM,cAAc,OAAO,IAAI,cAAc;EAC7C,MAAM,kBAAkB,OAAO,IAAI,kBAAkB;AACrD,MAAI,eAAe,gBAClB,QAAO,cAAc;GACpB;GACA;GACA,cAAc,OAAO,IAAI,eAAe;EACxC;EAGF,MAAM,aAAa,IAAI,cAAc;AACrC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAE9B,OAAK,YAAY;CACjB;CAED,MAAM,QAAuB;AAC5B,OAAK,OAAO,SAAS;AACrB,OAAK,YAAY;CACjB;CAED,cAAuB;AACtB,SAAO,KAAK;CACZ;;;;CAKD,IAAI,YAAuB;AAC1B,SAAO,KAAK;CACZ;;;;CAKD,IAAI,WAAmB;AACtB,SAAO,KAAK,OAAO;CACnB;AACD"}
@@ -67,4 +67,4 @@ var SNSConnection = class SNSConnection {
67
67
 
68
68
  //#endregion
69
69
  export { SNSConnection };
70
- //# sourceMappingURL=SNSConnection-CpMKzgx2.mjs.map
70
+ //# sourceMappingURL=SNSConnection-CVjH93lb.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SNSConnection-CpMKzgx2.mjs","names":["config: SNSConnectionConfig","clientConfig: SNSClientConfig","connectionString: string"],"sources":["../src/sns/SNSConnection.ts"],"sourcesContent":["import { SNSClient, type SNSClientConfig } from '@aws-sdk/client-sns';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface SNSConnectionConfig {\n\ttopicArn: string;\n\tregion?: string;\n\tendpoint?: string; // Custom endpoint (e.g., for LocalStack)\n\tcredentials?: {\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t};\n}\n\nexport class SNSConnection implements EventConnection {\n\treadonly type = EventPublisherType.SNS;\n\tprivate client: SNSClient;\n\tprivate connected = false;\n\tprivate config: SNSConnectionConfig;\n\n\tconstructor(config: SNSConnectionConfig) {\n\t\tthis.config = config;\n\n\t\tconst clientConfig: SNSClientConfig = {\n\t\t\tregion: config.region,\n\t\t\tendpoint: config.endpoint,\n\t\t\tcredentials: config.credentials,\n\t\t};\n\n\t\tthis.client = new SNSClient(clientConfig);\n\t}\n\n\t/**\n\t * Create an SNSConnection from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic&region=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<SNSConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst topicArn = params.get('topicArn');\n\t\tif (!topicArn) {\n\t\t\tthrow new Error('topicArn parameter is required in connection string');\n\t\t}\n\n\t\tconst config: SNSConnectionConfig = {\n\t\t\ttopicArn,\n\t\t\tregion: params.get('region') || undefined,\n\t\t\tendpoint: params.get('endpoint') || undefined,\n\t\t};\n\n\t\t// Parse credentials if provided\n\t\tconst accessKeyId = params.get('accessKeyId');\n\t\tconst secretAccessKey = params.get('secretAccessKey');\n\t\tif (accessKeyId && secretAccessKey) {\n\t\t\tconfig.credentials = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey,\n\t\t\t\tsessionToken: params.get('sessionToken') || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst connection = new SNSConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\t// SNS doesn't have a traditional connection, but we mark as connected\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.client.destroy();\n\t\tthis.connected = false;\n\t}\n\n\tisConnected(): boolean {\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Get the underlying SNS client\n\t */\n\tget snsClient(): SNSClient {\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Get the topic ARN for this connection\n\t */\n\tget topicArn(): string {\n\t\treturn this.config.topicArn;\n\t}\n}\n"],"mappings":";;;;AAeA,IAAa,gBAAb,MAAa,cAAyC;CACrD,AAAS,OAAO,mBAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CACpB,AAAQ;CAER,YAAYA,QAA6B;AACxC,OAAK,SAAS;EAEd,MAAMC,eAAgC;GACrC,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,aAAa,OAAO;EACpB;AAED,OAAK,SAAS,IAAI,UAAU;CAC5B;;;;;CAMD,aAAa,qBACZC,kBACyB;EACzB,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,WAAW,OAAO,IAAI,WAAW;AACvC,OAAK,SACJ,OAAM,IAAI,MAAM;EAGjB,MAAMF,SAA8B;GACnC;GACA,QAAQ,OAAO,IAAI,SAAS;GAC5B,UAAU,OAAO,IAAI,WAAW;EAChC;EAGD,MAAM,cAAc,OAAO,IAAI,cAAc;EAC7C,MAAM,kBAAkB,OAAO,IAAI,kBAAkB;AACrD,MAAI,eAAe,gBAClB,QAAO,cAAc;GACpB;GACA;GACA,cAAc,OAAO,IAAI,eAAe;EACxC;EAGF,MAAM,aAAa,IAAI,cAAc;AACrC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAE9B,OAAK,YAAY;CACjB;CAED,MAAM,QAAuB;AAC5B,OAAK,OAAO,SAAS;AACrB,OAAK,YAAY;CACjB;CAED,cAAuB;AACtB,SAAO,KAAK;CACZ;;;;CAKD,IAAI,YAAuB;AAC1B,SAAO,KAAK;CACZ;;;;CAKD,IAAI,WAAmB;AACtB,SAAO,KAAK,OAAO;CACnB;AACD"}
1
+ {"version":3,"file":"SNSConnection-CVjH93lb.mjs","names":["config: SNSConnectionConfig","clientConfig: SNSClientConfig","connectionString: string"],"sources":["../src/sns/SNSConnection.ts"],"sourcesContent":["import { SNSClient, type SNSClientConfig } from '@aws-sdk/client-sns';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface SNSConnectionConfig {\n\ttopicArn: string;\n\tregion?: string;\n\tendpoint?: string; // Custom endpoint (e.g., for LocalStack)\n\tcredentials?: {\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t};\n}\n\nexport class SNSConnection implements EventConnection {\n\treadonly type = EventPublisherType.SNS;\n\tprivate client: SNSClient;\n\tprivate connected = false;\n\tprivate config: SNSConnectionConfig;\n\n\tconstructor(config: SNSConnectionConfig) {\n\t\tthis.config = config;\n\n\t\tconst clientConfig: SNSClientConfig = {\n\t\t\tregion: config.region,\n\t\t\tendpoint: config.endpoint,\n\t\t\tcredentials: config.credentials,\n\t\t};\n\n\t\tthis.client = new SNSClient(clientConfig);\n\t}\n\n\t/**\n\t * Create an SNSConnection from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic&region=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<SNSConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst topicArn = params.get('topicArn');\n\t\tif (!topicArn) {\n\t\t\tthrow new Error('topicArn parameter is required in connection string');\n\t\t}\n\n\t\tconst config: SNSConnectionConfig = {\n\t\t\ttopicArn,\n\t\t\tregion: params.get('region') || undefined,\n\t\t\tendpoint: params.get('endpoint') || undefined,\n\t\t};\n\n\t\t// Parse credentials if provided\n\t\tconst accessKeyId = params.get('accessKeyId');\n\t\tconst secretAccessKey = params.get('secretAccessKey');\n\t\tif (accessKeyId && secretAccessKey) {\n\t\t\tconfig.credentials = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey,\n\t\t\t\tsessionToken: params.get('sessionToken') || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst connection = new SNSConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\t// SNS doesn't have a traditional connection, but we mark as connected\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.client.destroy();\n\t\tthis.connected = false;\n\t}\n\n\tisConnected(): boolean {\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Get the underlying SNS client\n\t */\n\tget snsClient(): SNSClient {\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Get the topic ARN for this connection\n\t */\n\tget topicArn(): string {\n\t\treturn this.config.topicArn;\n\t}\n}\n"],"mappings":";;;;AAeA,IAAa,gBAAb,MAAa,cAAyC;CACrD,AAAS,OAAO,mBAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CACpB,AAAQ;CAER,YAAYA,QAA6B;AACxC,OAAK,SAAS;EAEd,MAAMC,eAAgC;GACrC,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,aAAa,OAAO;EACpB;AAED,OAAK,SAAS,IAAI,UAAU;CAC5B;;;;;CAMD,aAAa,qBACZC,kBACyB;EACzB,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,WAAW,OAAO,IAAI,WAAW;AACvC,OAAK,SACJ,OAAM,IAAI,MAAM;EAGjB,MAAMF,SAA8B;GACnC;GACA,QAAQ,OAAO,IAAI,SAAS;GAC5B,UAAU,OAAO,IAAI,WAAW;EAChC;EAGD,MAAM,cAAc,OAAO,IAAI,cAAc;EAC7C,MAAM,kBAAkB,OAAO,IAAI,kBAAkB;AACrD,MAAI,eAAe,gBAClB,QAAO,cAAc;GACpB;GACA;GACA,cAAc,OAAO,IAAI,eAAe;EACxC;EAGF,MAAM,aAAa,IAAI,cAAc;AACrC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAE9B,OAAK,YAAY;CACjB;CAED,MAAM,QAAuB;AAC5B,OAAK,OAAO,SAAS;AACrB,OAAK,YAAY;CACjB;CAED,cAAuB;AACtB,SAAO,KAAK;CACZ;;;;CAKD,IAAI,YAAuB;AAC1B,SAAO,KAAK;CACZ;;;;CAKD,IAAI,WAAmB;AACtB,SAAO,KAAK,OAAO;CACnB;AACD"}
@@ -38,4 +38,4 @@ var SNSPublisher = class SNSPublisher {
38
38
 
39
39
  //#endregion
40
40
  export { SNSPublisher };
41
- //# sourceMappingURL=SNSPublisher-Drr4kHn6.mjs.map
41
+ //# sourceMappingURL=SNSPublisher-CjlMS3Z2.mjs.map