@geekmidas/events 9.6.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.
- package/CHANGELOG.md +11 -0
- package/dist/{BasicConnection-DyGmgDSX.cjs → BasicConnection-CxfNEvlb.cjs} +1 -1
- package/dist/{BasicConnection-DyGmgDSX.cjs.map → BasicConnection-CxfNEvlb.cjs.map} +1 -1
- package/dist/{BasicConnection-CVyEy5R6.mjs → BasicConnection-hl-Ogz3a.mjs} +1 -1
- package/dist/{BasicConnection-CVyEy5R6.mjs.map → BasicConnection-hl-Ogz3a.mjs.map} +1 -1
- package/dist/{BasicPublisher-Bv4TTrtI.cjs → BasicPublisher-CXAVKxgq.cjs} +1 -1
- package/dist/{BasicPublisher-Bv4TTrtI.cjs.map → BasicPublisher-CXAVKxgq.cjs.map} +1 -1
- package/dist/{BasicPublisher-7rE-7TTf.mjs → BasicPublisher-DogbeHAH.mjs} +1 -1
- package/dist/{BasicPublisher-7rE-7TTf.mjs.map → BasicPublisher-DogbeHAH.mjs.map} +1 -1
- package/dist/{BasicSubscriber-Cm4qZZf4.mjs → BasicSubscriber-BJSZN22M.mjs} +1 -1
- package/dist/{BasicSubscriber-Cm4qZZf4.mjs.map → BasicSubscriber-BJSZN22M.mjs.map} +1 -1
- package/dist/{BasicSubscriber-BYemML6q.cjs → BasicSubscriber-mVJRMXhZ.cjs} +1 -1
- package/dist/{BasicSubscriber-BYemML6q.cjs.map → BasicSubscriber-mVJRMXhZ.cjs.map} +1 -1
- package/dist/{PgBossConnection-B71ssr72.cjs → PgBossConnection-BNXd_eWO.cjs} +3 -4
- package/dist/PgBossConnection-BNXd_eWO.cjs.map +1 -0
- package/dist/{PgBossConnection-Bj_Wo1lQ.mjs → PgBossConnection-BUcauiA7.mjs} +3 -3
- package/dist/PgBossConnection-BUcauiA7.mjs.map +1 -0
- package/dist/PgBossConnection-DCfLGoHx.d.mts.map +1 -1
- package/dist/PgBossConnection-oto_CAbP.d.cts.map +1 -1
- package/dist/{RabbitMQConnection-CniiDhWq.mjs → RabbitMQConnection-CW-92QTt.mjs} +3 -3
- package/dist/RabbitMQConnection-CW-92QTt.mjs.map +1 -0
- package/dist/RabbitMQConnection-DV9t3VYp.d.mts.map +1 -1
- package/dist/{RabbitMQConnection-Dw-HpHyE.cjs → RabbitMQConnection-Diwv0RIa.cjs} +3 -4
- package/dist/RabbitMQConnection-Diwv0RIa.cjs.map +1 -0
- package/dist/RabbitMQConnection-jNME_eR7.d.cts.map +1 -1
- package/dist/{RabbitMQPublisher-CSCn6gMA.cjs → RabbitMQPublisher-C94q6g8q.cjs} +1 -1
- package/dist/{RabbitMQPublisher-CSCn6gMA.cjs.map → RabbitMQPublisher-C94q6g8q.cjs.map} +1 -1
- package/dist/{RabbitMQPublisher-BZX0edgL.mjs → RabbitMQPublisher-yUqWNq-P.mjs} +1 -1
- package/dist/{RabbitMQPublisher-BZX0edgL.mjs.map → RabbitMQPublisher-yUqWNq-P.mjs.map} +1 -1
- package/dist/{RabbitMQSubscriber-CiCsdiOM.mjs → RabbitMQSubscriber-BWniDtFs.mjs} +1 -1
- package/dist/{RabbitMQSubscriber-CiCsdiOM.mjs.map → RabbitMQSubscriber-BWniDtFs.mjs.map} +1 -1
- package/dist/{RabbitMQSubscriber-fUmIyY0t.cjs → RabbitMQSubscriber-DGEO-clQ.cjs} +1 -1
- package/dist/{RabbitMQSubscriber-fUmIyY0t.cjs.map → RabbitMQSubscriber-DGEO-clQ.cjs.map} +1 -1
- package/dist/{SNSConnection-DFehUWG1.cjs → SNSConnection-CAcbLQOy.cjs} +1 -1
- package/dist/{SNSConnection-DFehUWG1.cjs.map → SNSConnection-CAcbLQOy.cjs.map} +1 -1
- package/dist/{SNSConnection-CpMKzgx2.mjs → SNSConnection-CVjH93lb.mjs} +1 -1
- package/dist/{SNSConnection-CpMKzgx2.mjs.map → SNSConnection-CVjH93lb.mjs.map} +1 -1
- package/dist/{SNSPublisher-Drr4kHn6.mjs → SNSPublisher-CjlMS3Z2.mjs} +1 -1
- package/dist/{SNSPublisher-Drr4kHn6.mjs.map → SNSPublisher-CjlMS3Z2.mjs.map} +1 -1
- package/dist/{SNSPublisher-BoA8uLnw.cjs → SNSPublisher-DV_8GGsi.cjs} +1 -1
- package/dist/{SNSPublisher-BoA8uLnw.cjs.map → SNSPublisher-DV_8GGsi.cjs.map} +1 -1
- package/dist/{SNSSubscriber-DIXqA-VV.mjs → SNSSubscriber-BWaCQFl6.mjs} +3 -3
- package/dist/{SNSSubscriber-DIXqA-VV.mjs.map → SNSSubscriber-BWaCQFl6.mjs.map} +1 -1
- package/dist/{SNSSubscriber-ZIdCi6nQ.cjs → SNSSubscriber-ZE_-Hsps.cjs} +3 -3
- package/dist/{SNSSubscriber-ZIdCi6nQ.cjs.map → SNSSubscriber-ZE_-Hsps.cjs.map} +1 -1
- package/dist/{SQSConnection-BqZZnAZI.mjs → SQSConnection-CT3S7_zP.mjs} +1 -1
- package/dist/{SQSConnection-BqZZnAZI.mjs.map → SQSConnection-CT3S7_zP.mjs.map} +1 -1
- package/dist/{SQSConnection-yge9cB_f.cjs → SQSConnection-Y0mdVTcB.cjs} +1 -1
- package/dist/{SQSConnection-yge9cB_f.cjs.map → SQSConnection-Y0mdVTcB.cjs.map} +1 -1
- package/dist/{SQSPublisher-CT0VFeeh.cjs → SQSPublisher-Bq-qWTjH.cjs} +1 -1
- package/dist/{SQSPublisher-CT0VFeeh.cjs.map → SQSPublisher-Bq-qWTjH.cjs.map} +1 -1
- package/dist/{SQSPublisher-Bn1lwlln.mjs → SQSPublisher-DVOOa5dW.mjs} +1 -1
- package/dist/{SQSPublisher-Bn1lwlln.mjs.map → SQSPublisher-DVOOa5dW.mjs.map} +1 -1
- package/dist/{SQSSubscriber-B4sRXVl6.cjs → SQSSubscriber-C4UA2hKq.cjs} +1 -1
- package/dist/{SQSSubscriber-B4sRXVl6.cjs.map → SQSSubscriber-C4UA2hKq.cjs.map} +1 -1
- package/dist/{SQSSubscriber-CVGhZ8Nr.mjs → SQSSubscriber-CQdSFzpe.mjs} +1 -1
- package/dist/{SQSSubscriber-CVGhZ8Nr.mjs.map → SQSSubscriber-CQdSFzpe.mjs.map} +1 -1
- package/dist/basic/BasicConnection.cjs +1 -1
- package/dist/basic/BasicConnection.mjs +1 -1
- package/dist/basic/BasicPublisher.cjs +1 -1
- package/dist/basic/BasicPublisher.mjs +1 -1
- package/dist/basic/BasicSubscriber.cjs +1 -1
- package/dist/basic/BasicSubscriber.mjs +1 -1
- package/dist/basic/index.cjs +3 -3
- package/dist/basic/index.mjs +3 -3
- package/dist/pgboss/PgBossConnection.cjs +1 -1
- package/dist/pgboss/PgBossConnection.mjs +1 -1
- package/dist/pgboss/index.cjs +1 -1
- package/dist/pgboss/index.mjs +1 -1
- package/dist/rabbitmq/RabbitMQConnection.cjs +1 -1
- package/dist/rabbitmq/RabbitMQConnection.mjs +1 -1
- package/dist/rabbitmq/RabbitMQPublisher.cjs +1 -1
- package/dist/rabbitmq/RabbitMQPublisher.mjs +1 -1
- package/dist/rabbitmq/RabbitMQSubscriber.cjs +1 -1
- package/dist/rabbitmq/RabbitMQSubscriber.mjs +1 -1
- package/dist/rabbitmq/index.cjs +3 -3
- package/dist/rabbitmq/index.mjs +3 -3
- package/dist/sns/SNSConnection.cjs +1 -1
- package/dist/sns/SNSConnection.mjs +1 -1
- package/dist/sns/SNSPublisher.cjs +1 -1
- package/dist/sns/SNSPublisher.mjs +1 -1
- package/dist/sns/SNSSubscriber.cjs +3 -3
- package/dist/sns/SNSSubscriber.mjs +3 -3
- package/dist/sns/index.cjs +5 -5
- package/dist/sns/index.mjs +5 -5
- package/dist/sqs/SQSConnection.cjs +1 -1
- package/dist/sqs/SQSConnection.mjs +1 -1
- package/dist/sqs/SQSPublisher.cjs +1 -1
- package/dist/sqs/SQSPublisher.mjs +1 -1
- package/dist/sqs/SQSSubscriber.cjs +1 -1
- package/dist/sqs/SQSSubscriber.mjs +1 -1
- package/dist/sqs/index.cjs +3 -3
- package/dist/sqs/index.mjs +3 -3
- package/package.json +4 -3
- package/src/__tests__/bundle.spec.ts +51 -0
- package/src/pgboss/PgBossConnection.ts +5 -2
- package/src/rabbitmq/RabbitMQConnection.ts +5 -2
- package/dist/PgBossConnection-B71ssr72.cjs.map +0 -1
- package/dist/PgBossConnection-Bj_Wo1lQ.mjs.map +0 -1
- package/dist/RabbitMQConnection-CniiDhWq.mjs.map +0 -1
- package/dist/RabbitMQConnection-Dw-HpHyE.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
3
14
|
## 9.6.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicConnection-
|
|
1
|
+
{"version":3,"file":"BasicConnection-CxfNEvlb.cjs","names":["EventPublisherType","EventEmitter","_connectionString: string"],"sources":["../src/basic/BasicConnection.ts"],"sourcesContent":["import { EventEmitter } from 'node:events';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport class BasicConnection implements EventConnection {\n\treadonly type = EventPublisherType.Basic;\n\tprivate emitter: EventEmitter;\n\tprivate connected = false;\n\n\tconstructor() {\n\t\tthis.emitter = new EventEmitter();\n\t}\n\n\t/**\n\t * Create a BasicConnection from a connection string\n\t * Format: basic://\n\t */\n\tstatic async fromConnectionString(\n\t\t_connectionString: string,\n\t): Promise<BasicConnection> {\n\t\t// Basic connection doesn't need any configuration\n\t\tconst connection = new BasicConnection();\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.emitter.removeAllListeners();\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 EventEmitter\n\t * Used by BasicPublisher and BasicSubscriber\n\t */\n\tget eventEmitter(): EventEmitter {\n\t\treturn this.emitter;\n\t}\n}\n"],"mappings":";;;;;AAIA,IAAa,kBAAb,MAAa,gBAA2C;CACvD,AAAS,OAAOA,iCAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CAEpB,cAAc;AACb,OAAK,UAAU,IAAIC;CACnB;;;;;CAMD,aAAa,qBACZC,mBAC2B;EAE3B,MAAM,aAAa,IAAI;AACvB,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAC9B,OAAK,YAAY;CACjB;CAED,MAAM,QAAuB;AAC5B,OAAK,QAAQ,oBAAoB;AACjC,OAAK,YAAY;CACjB;CAED,cAAuB;AACtB,SAAO,KAAK;CACZ;;;;;CAMD,IAAI,eAA6B;AAChC,SAAO,KAAK;CACZ;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicConnection-
|
|
1
|
+
{"version":3,"file":"BasicConnection-hl-Ogz3a.mjs","names":["_connectionString: string"],"sources":["../src/basic/BasicConnection.ts"],"sourcesContent":["import { EventEmitter } from 'node:events';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport class BasicConnection implements EventConnection {\n\treadonly type = EventPublisherType.Basic;\n\tprivate emitter: EventEmitter;\n\tprivate connected = false;\n\n\tconstructor() {\n\t\tthis.emitter = new EventEmitter();\n\t}\n\n\t/**\n\t * Create a BasicConnection from a connection string\n\t * Format: basic://\n\t */\n\tstatic async fromConnectionString(\n\t\t_connectionString: string,\n\t): Promise<BasicConnection> {\n\t\t// Basic connection doesn't need any configuration\n\t\tconst connection = new BasicConnection();\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.emitter.removeAllListeners();\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 EventEmitter\n\t * Used by BasicPublisher and BasicSubscriber\n\t */\n\tget eventEmitter(): EventEmitter {\n\t\treturn this.emitter;\n\t}\n}\n"],"mappings":";;;;AAIA,IAAa,kBAAb,MAAa,gBAA2C;CACvD,AAAS,OAAO,mBAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CAEpB,cAAc;AACb,OAAK,UAAU,IAAI;CACnB;;;;;CAMD,aAAa,qBACZA,mBAC2B;EAE3B,MAAM,aAAa,IAAI;AACvB,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAC9B,OAAK,YAAY;CACjB;CAED,MAAM,QAAuB;AAC5B,OAAK,QAAQ,oBAAoB;AACjC,OAAK,YAAY;CACjB;CAED,cAAuB;AACtB,SAAO,KAAK;CACZ;;;;;CAMD,IAAI,eAA6B;AAChC,SAAO,KAAK;CACZ;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicPublisher-
|
|
1
|
+
{"version":3,"file":"BasicPublisher-CXAVKxgq.cjs","names":["connection: BasicConnection","messages: TMessage[]"],"sources":["../src/basic/BasicPublisher.ts"],"sourcesContent":["import type { EventPublisher, PublishableMessage } from '../types';\nimport type { BasicConnection } from './BasicConnection';\n\nexport class BasicPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(private connection: BasicConnection) {}\n\n\tasync publish(messages: TMessage[]) {\n\t\tconst emitter = this.connection.eventEmitter;\n\t\tfor (const message of messages) {\n\t\t\temitter.emit(message.type, message);\n\t\t}\n\t}\n}\n"],"mappings":";;AAGA,IAAa,iBAAb,MAEA;CACC,YAAoBA,YAA6B;EAA7B;CAA+B;CAEnD,MAAM,QAAQC,UAAsB;EACnC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,MAAM,WAAW,SACrB,SAAQ,KAAK,QAAQ,MAAM,QAAQ;CAEpC;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicPublisher-
|
|
1
|
+
{"version":3,"file":"BasicPublisher-DogbeHAH.mjs","names":["connection: BasicConnection","messages: TMessage[]"],"sources":["../src/basic/BasicPublisher.ts"],"sourcesContent":["import type { EventPublisher, PublishableMessage } from '../types';\nimport type { BasicConnection } from './BasicConnection';\n\nexport class BasicPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(private connection: BasicConnection) {}\n\n\tasync publish(messages: TMessage[]) {\n\t\tconst emitter = this.connection.eventEmitter;\n\t\tfor (const message of messages) {\n\t\t\temitter.emit(message.type, message);\n\t\t}\n\t}\n}\n"],"mappings":";AAGA,IAAa,iBAAb,MAEA;CACC,YAAoBA,YAA6B;EAA7B;CAA+B;CAEnD,MAAM,QAAQC,UAAsB;EACnC,MAAM,UAAU,KAAK,WAAW;AAChC,OAAK,MAAM,WAAW,SACrB,SAAQ,KAAK,QAAQ,MAAM,QAAQ;CAEpC;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicSubscriber-
|
|
1
|
+
{"version":3,"file":"BasicSubscriber-BJSZN22M.mjs","names":["connection: BasicConnection","messages: TMessage['type'][]","listener: (payload: TMessage) => Promise<void>","message: TMessage"],"sources":["../src/basic/BasicSubscriber.ts"],"sourcesContent":["import type { EventSubscriber, PublishableMessage } from '../types';\nimport type { BasicConnection } from './BasicConnection';\n\nexport class BasicSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tconstructor(private connection: BasicConnection) {}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tconst emitter = this.connection.eventEmitter;\n\n\t\tfor (const messageType of messages) {\n\t\t\temitter.on(messageType, (message: TMessage) => {\n\t\t\t\tlistener(message).catch((_error) => {});\n\t\t\t});\n\t\t}\n\t}\n}\n"],"mappings":";AAGA,IAAa,kBAAb,MAEA;CACC,YAAoBA,YAA6B;EAA7B;CAA+B;CAEnD,MAAM,UACLC,UACAC,UACgB;EAChB,MAAM,UAAU,KAAK,WAAW;AAEhC,OAAK,MAAM,eAAe,SACzB,SAAQ,GAAG,aAAa,CAACC,YAAsB;AAC9C,YAAS,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAE,EAAC;EACvC,EAAC;CAEH;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicSubscriber-
|
|
1
|
+
{"version":3,"file":"BasicSubscriber-mVJRMXhZ.cjs","names":["connection: BasicConnection","messages: TMessage['type'][]","listener: (payload: TMessage) => Promise<void>","message: TMessage"],"sources":["../src/basic/BasicSubscriber.ts"],"sourcesContent":["import type { EventSubscriber, PublishableMessage } from '../types';\nimport type { BasicConnection } from './BasicConnection';\n\nexport class BasicSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tconstructor(private connection: BasicConnection) {}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tconst emitter = this.connection.eventEmitter;\n\n\t\tfor (const messageType of messages) {\n\t\t\temitter.on(messageType, (message: TMessage) => {\n\t\t\t\tlistener(message).catch((_error) => {});\n\t\t\t});\n\t\t}\n\t}\n}\n"],"mappings":";;AAGA,IAAa,kBAAb,MAEA;CACC,YAAoBA,YAA6B;EAA7B;CAA+B;CAEnD,MAAM,UACLC,UACAC,UACgB;EAChB,MAAM,UAAU,KAAK,WAAW;AAEhC,OAAK,MAAM,eAAe,SACzB,SAAQ,GAAG,aAAa,CAACC,YAAsB;AAC9C,YAAS,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAE,EAAC;EACvC,EAAC;CAEH;AACD"}
|
|
@@ -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
|
|
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-
|
|
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
|
|
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-
|
|
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,
|
|
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,
|
|
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,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
|
|
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-
|
|
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,
|
|
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
|
|
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-
|
|
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,
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RabbitMQPublisher-
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RabbitMQPublisher-
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RabbitMQSubscriber-
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RabbitMQSubscriber-
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SNSConnection-
|
|
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®ion=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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SNSConnection-
|
|
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®ion=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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SNSPublisher-
|
|
1
|
+
{"version":3,"file":"SNSPublisher-CjlMS3Z2.mjs","names":["connection: SNSConnection","_options: SNSPublisherOptions","connectionString: string","messages: TMessage[]","message: TMessage"],"sources":["../src/sns/SNSPublisher.ts"],"sourcesContent":["import { PublishCommand } from '@aws-sdk/client-sns';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport type { SNSConnection } from './SNSConnection';\n\nexport type SNSPublisherOptions = {};\n\nexport class SNSPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: SNSConnection,\n\t\t_options: SNSPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create an SNSPublisher from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic®ion=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SNSPublisher<TMessage>> {\n\t\tconst { SNSConnection } = await import('./SNSConnection');\n\t\tconst connection =\n\t\t\tawait SNSConnection.fromConnectionString(connectionString);\n\n\t\treturn new SNSPublisher<TMessage>(connection);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (messages.length === 0) return;\n\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\t// Publish all messages\n\t\tawait Promise.all(messages.map((message) => this.publishMessage(message)));\n\t}\n\n\tprivate async publishMessage(message: TMessage): Promise<void> {\n\t\tconst command = new PublishCommand({\n\t\t\tTopicArn: this.connection.topicArn,\n\t\t\tMessage: JSON.stringify({\n\t\t\t\ttype: message.type,\n\t\t\t\tpayload: message.payload,\n\t\t\t}),\n\t\t\tMessageAttributes: {\n\t\t\t\ttype: {\n\t\t\t\t\tDataType: 'String',\n\t\t\t\t\tStringValue: message.type,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tawait this.connection.snsClient.send(command);\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":";;;AAMA,IAAa,eAAb,MAAa,aAEb;CACC,YACSA,YACRC,WAAgC,CAAE,GACjC;EAFO;CAEL;;;;;CAMJ,aAAa,qBAEXC,kBAA2D;EAC5D,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;EACvC,MAAM,aACL,MAAM,cAAc,qBAAqB,iBAAiB;AAE3D,SAAO,IAAI,aAAuB;CAClC;CAED,MAAM,QAAQC,UAAqC;AAClD,MAAI,SAAS,WAAW,EAAG;AAE3B,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;AAIhC,QAAM,QAAQ,IAAI,SAAS,IAAI,CAAC,YAAY,KAAK,eAAe,QAAQ,CAAC,CAAC;CAC1E;CAED,MAAc,eAAeC,SAAkC;EAC9D,MAAM,UAAU,IAAI,eAAe;GAClC,UAAU,KAAK,WAAW;GAC1B,SAAS,KAAK,UAAU;IACvB,MAAM,QAAQ;IACd,SAAS,QAAQ;GACjB,EAAC;GACF,mBAAmB,EAClB,MAAM;IACL,UAAU;IACV,aAAa,QAAQ;GACrB,EACD;EACD;AAED,QAAM,KAAK,WAAW,UAAU,KAAK,QAAQ;CAC7C;CAED,MAAM,QAAuB,CAG5B;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SNSPublisher-
|
|
1
|
+
{"version":3,"file":"SNSPublisher-DV_8GGsi.cjs","names":["connection: SNSConnection","_options: SNSPublisherOptions","connectionString: string","messages: TMessage[]","message: TMessage","PublishCommand"],"sources":["../src/sns/SNSPublisher.ts"],"sourcesContent":["import { PublishCommand } from '@aws-sdk/client-sns';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport type { SNSConnection } from './SNSConnection';\n\nexport type SNSPublisherOptions = {};\n\nexport class SNSPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: SNSConnection,\n\t\t_options: SNSPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create an SNSPublisher from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic®ion=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SNSPublisher<TMessage>> {\n\t\tconst { SNSConnection } = await import('./SNSConnection');\n\t\tconst connection =\n\t\t\tawait SNSConnection.fromConnectionString(connectionString);\n\n\t\treturn new SNSPublisher<TMessage>(connection);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (messages.length === 0) return;\n\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\t// Publish all messages\n\t\tawait Promise.all(messages.map((message) => this.publishMessage(message)));\n\t}\n\n\tprivate async publishMessage(message: TMessage): Promise<void> {\n\t\tconst command = new PublishCommand({\n\t\t\tTopicArn: this.connection.topicArn,\n\t\t\tMessage: JSON.stringify({\n\t\t\t\ttype: message.type,\n\t\t\t\tpayload: message.payload,\n\t\t\t}),\n\t\t\tMessageAttributes: {\n\t\t\t\ttype: {\n\t\t\t\t\tDataType: 'String',\n\t\t\t\t\tStringValue: message.type,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tawait this.connection.snsClient.send(command);\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":";;;;AAMA,IAAa,eAAb,MAAa,aAEb;CACC,YACSA,YACRC,WAAgC,CAAE,GACjC;EAFO;CAEL;;;;;CAMJ,aAAa,qBAEXC,kBAA2D;EAC5D,MAAM,EAAE,eAAe,GAAG,2CAAM;EAChC,MAAM,aACL,MAAM,cAAc,qBAAqB,iBAAiB;AAE3D,SAAO,IAAI,aAAuB;CAClC;CAED,MAAM,QAAQC,UAAqC;AAClD,MAAI,SAAS,WAAW,EAAG;AAE3B,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;AAIhC,QAAM,QAAQ,IAAI,SAAS,IAAI,CAAC,YAAY,KAAK,eAAe,QAAQ,CAAC,CAAC;CAC1E;CAED,MAAc,eAAeC,SAAkC;EAC9D,MAAM,UAAU,IAAIC,oCAAe;GAClC,UAAU,KAAK,WAAW;GAC1B,SAAS,KAAK,UAAU;IACvB,MAAM,QAAQ;IACd,SAAS,QAAQ;GACjB,EAAC;GACF,mBAAmB,EAClB,MAAM;IACL,UAAU;IACV,aAAa,QAAQ;GACrB,EACD;EACD;AAED,QAAM,KAAK,WAAW,UAAU,KAAK,QAAQ;CAC7C;CAED,MAAM,QAAuB,CAG5B;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SQSConnection } from "./SQSConnection-
|
|
2
|
-
import { SQSSubscriber } from "./SQSSubscriber-
|
|
1
|
+
import { SQSConnection } from "./SQSConnection-CT3S7_zP.mjs";
|
|
2
|
+
import { SQSSubscriber } from "./SQSSubscriber-CQdSFzpe.mjs";
|
|
3
3
|
import { SubscribeCommand, UnsubscribeCommand } from "@aws-sdk/client-sns";
|
|
4
4
|
import { CreateQueueCommand, DeleteQueueCommand, GetQueueAttributesCommand, SQSClient, SetQueueAttributesCommand } from "@aws-sdk/client-sqs";
|
|
5
5
|
|
|
@@ -136,4 +136,4 @@ var SNSSubscriber = class SNSSubscriber {
|
|
|
136
136
|
|
|
137
137
|
//#endregion
|
|
138
138
|
export { SNSSubscriber };
|
|
139
|
-
//# sourceMappingURL=SNSSubscriber-
|
|
139
|
+
//# sourceMappingURL=SNSSubscriber-BWaCQFl6.mjs.map
|