@geekmidas/events 10.0.0-alpha.99 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +116 -0
- package/README.md +1 -46
- package/dist/BasicConnection-CQsJpx2J.d.cts +27 -0
- package/dist/BasicConnection-CQsJpx2J.d.cts.map +1 -0
- package/dist/BasicConnection-CxfNEvlb.cjs +48 -0
- package/dist/BasicConnection-CxfNEvlb.cjs.map +1 -0
- package/dist/BasicConnection-DcRelT64.d.mts +27 -0
- package/dist/BasicConnection-DcRelT64.d.mts.map +1 -0
- package/dist/BasicConnection-hl-Ogz3a.mjs +42 -0
- package/dist/BasicConnection-hl-Ogz3a.mjs.map +1 -0
- package/dist/BasicPublisher-C-hMX2Hy.d.mts +14 -0
- package/dist/BasicPublisher-C-hMX2Hy.d.mts.map +1 -0
- package/dist/BasicPublisher-CGMXg2I2.d.cts +14 -0
- package/dist/BasicPublisher-CGMXg2I2.d.cts.map +1 -0
- package/dist/BasicPublisher-CXAVKxgq.cjs +20 -0
- package/dist/BasicPublisher-CXAVKxgq.cjs.map +1 -0
- package/dist/BasicPublisher-DogbeHAH.mjs +14 -0
- package/dist/BasicPublisher-DogbeHAH.mjs.map +1 -0
- package/dist/BasicSubscriber-BJSZN22M.mjs +16 -0
- package/dist/BasicSubscriber-BJSZN22M.mjs.map +1 -0
- package/dist/BasicSubscriber-HzSJ_MbB.d.mts +14 -0
- package/dist/BasicSubscriber-HzSJ_MbB.d.mts.map +1 -0
- package/dist/BasicSubscriber-mVJRMXhZ.cjs +22 -0
- package/dist/BasicSubscriber-mVJRMXhZ.cjs.map +1 -0
- package/dist/BasicSubscriber-uW3IOyBj.d.cts +14 -0
- package/dist/BasicSubscriber-uW3IOyBj.d.cts.map +1 -0
- package/dist/EventConnection-4niMI6D8.d.mts +13 -0
- package/dist/EventConnection-4niMI6D8.d.mts.map +1 -0
- package/dist/EventConnection-BkA9FSVL.cjs +45 -0
- package/dist/EventConnection-BkA9FSVL.cjs.map +1 -0
- package/dist/EventConnection-Kr32GAzq.mjs +40 -0
- package/dist/EventConnection-Kr32GAzq.mjs.map +1 -0
- package/dist/EventConnection-dP42P87q.d.cts +13 -0
- package/dist/EventConnection-dP42P87q.d.cts.map +1 -0
- package/dist/EventConnection.cjs +5 -0
- package/dist/EventConnection.d.cts +3 -0
- package/dist/EventConnection.d.mts +3 -0
- package/dist/EventConnection.mjs +4 -0
- package/dist/PgBossConnection-B71ssr72.cjs +80 -0
- package/dist/PgBossConnection-B71ssr72.cjs.map +1 -0
- package/dist/PgBossConnection-Bj_Wo1lQ.mjs +74 -0
- package/dist/PgBossConnection-Bj_Wo1lQ.mjs.map +1 -0
- package/dist/PgBossConnection-DCfLGoHx.d.mts +32 -0
- package/dist/PgBossConnection-DCfLGoHx.d.mts.map +1 -0
- package/dist/PgBossConnection-oto_CAbP.d.cts +32 -0
- package/dist/PgBossConnection-oto_CAbP.d.cts.map +1 -0
- package/dist/PgBossPublisher-Bwo7qSoH.mjs +35 -0
- package/dist/PgBossPublisher-Bwo7qSoH.mjs.map +1 -0
- package/dist/PgBossPublisher-CqjigBVC.d.mts +20 -0
- package/dist/PgBossPublisher-CqjigBVC.d.mts.map +1 -0
- package/dist/PgBossPublisher-FTdYh58W.cjs +41 -0
- package/dist/PgBossPublisher-FTdYh58W.cjs.map +1 -0
- package/dist/PgBossPublisher-JIiB1zpA.d.cts +20 -0
- package/dist/PgBossPublisher-JIiB1zpA.d.cts.map +1 -0
- package/dist/PgBossSubscriber-BUiB1JKf.d.mts +24 -0
- package/dist/PgBossSubscriber-BUiB1JKf.d.mts.map +1 -0
- package/dist/PgBossSubscriber-BubVfuWm.cjs +52 -0
- package/dist/PgBossSubscriber-BubVfuWm.cjs.map +1 -0
- package/dist/PgBossSubscriber-Cozijfdj.d.cts +24 -0
- package/dist/PgBossSubscriber-Cozijfdj.d.cts.map +1 -0
- package/dist/PgBossSubscriber-DopATe80.mjs +46 -0
- package/dist/PgBossSubscriber-DopATe80.mjs.map +1 -0
- package/dist/Publisher-CKloIGh6.cjs +79 -0
- package/dist/Publisher-CKloIGh6.cjs.map +1 -0
- package/dist/Publisher-ChLTrUeP.mjs +74 -0
- package/dist/Publisher-ChLTrUeP.mjs.map +1 -0
- package/dist/Publisher-DDee6xau.d.cts +21 -0
- package/dist/Publisher-DDee6xau.d.cts.map +1 -0
- package/dist/Publisher-VHumMkrP.d.mts +21 -0
- package/dist/Publisher-VHumMkrP.d.mts.map +1 -0
- package/dist/Publisher.cjs +4 -0
- package/dist/Publisher.d.cts +3 -0
- package/dist/Publisher.d.mts +3 -0
- package/dist/Publisher.mjs +4 -0
- package/dist/RabbitMQConnection-BtKZjtZY.mjs +107 -0
- package/dist/RabbitMQConnection-BtKZjtZY.mjs.map +1 -0
- package/dist/RabbitMQConnection-DV9t3VYp.d.mts +44 -0
- package/dist/RabbitMQConnection-DV9t3VYp.d.mts.map +1 -0
- package/dist/RabbitMQConnection-DmMMosT4.cjs +113 -0
- package/dist/RabbitMQConnection-DmMMosT4.cjs.map +1 -0
- package/dist/RabbitMQConnection-jNME_eR7.d.cts +44 -0
- package/dist/RabbitMQConnection-jNME_eR7.d.cts.map +1 -0
- package/dist/RabbitMQPublisher-C94q6g8q.cjs +45 -0
- package/dist/RabbitMQPublisher-C94q6g8q.cjs.map +1 -0
- package/dist/RabbitMQPublisher-DKmgwqVj.d.mts +25 -0
- package/dist/RabbitMQPublisher-DKmgwqVj.d.mts.map +1 -0
- package/dist/RabbitMQPublisher-d257OHLa.d.cts +25 -0
- package/dist/RabbitMQPublisher-d257OHLa.d.cts.map +1 -0
- package/dist/RabbitMQPublisher-yUqWNq-P.mjs +39 -0
- package/dist/RabbitMQPublisher-yUqWNq-P.mjs.map +1 -0
- package/dist/RabbitMQSubscriber-BF7JGfYm.d.cts +27 -0
- package/dist/RabbitMQSubscriber-BF7JGfYm.d.cts.map +1 -0
- package/dist/RabbitMQSubscriber-BWniDtFs.mjs +56 -0
- package/dist/RabbitMQSubscriber-BWniDtFs.mjs.map +1 -0
- package/dist/RabbitMQSubscriber-CdbUy5mB.d.mts +27 -0
- package/dist/RabbitMQSubscriber-CdbUy5mB.d.mts.map +1 -0
- package/dist/RabbitMQSubscriber-DGEO-clQ.cjs +62 -0
- package/dist/RabbitMQSubscriber-DGEO-clQ.cjs.map +1 -0
- package/dist/SNSConnection-CAcbLQOy.cjs +76 -0
- package/dist/SNSConnection-CAcbLQOy.cjs.map +1 -0
- package/dist/SNSConnection-CG4iEwA8.d.mts +41 -0
- package/dist/SNSConnection-CG4iEwA8.d.mts.map +1 -0
- package/dist/SNSConnection-CVjH93lb.mjs +70 -0
- package/dist/SNSConnection-CVjH93lb.mjs.map +1 -0
- package/dist/SNSConnection-Dol9FuxA.d.cts +41 -0
- package/dist/SNSConnection-Dol9FuxA.d.cts.map +1 -0
- package/dist/SNSPublisher-CjlMS3Z2.mjs +41 -0
- package/dist/SNSPublisher-CjlMS3Z2.mjs.map +1 -0
- package/dist/SNSPublisher-D50dPCEh.d.mts +22 -0
- package/dist/SNSPublisher-D50dPCEh.d.mts.map +1 -0
- package/dist/SNSPublisher-DQunY4NM.d.cts +22 -0
- package/dist/SNSPublisher-DQunY4NM.d.cts.map +1 -0
- package/dist/SNSPublisher-DV_8GGsi.cjs +47 -0
- package/dist/SNSPublisher-DV_8GGsi.cjs.map +1 -0
- package/dist/SNSSubscriber-BWaCQFl6.mjs +139 -0
- package/dist/SNSSubscriber-BWaCQFl6.mjs.map +1 -0
- package/dist/SNSSubscriber-CUgHK4W2.d.mts +55 -0
- package/dist/SNSSubscriber-CUgHK4W2.d.mts.map +1 -0
- package/dist/SNSSubscriber-ZE_-Hsps.cjs +145 -0
- package/dist/SNSSubscriber-ZE_-Hsps.cjs.map +1 -0
- package/dist/SNSSubscriber-ZGJjhXFQ.d.cts +55 -0
- package/dist/SNSSubscriber-ZGJjhXFQ.d.cts.map +1 -0
- package/dist/SQSConnection-BtEkDha8.d.cts +41 -0
- package/dist/SQSConnection-BtEkDha8.d.cts.map +1 -0
- package/dist/SQSConnection-CT3S7_zP.mjs +70 -0
- package/dist/SQSConnection-CT3S7_zP.mjs.map +1 -0
- package/dist/SQSConnection-DVy43GCV.d.mts +41 -0
- package/dist/SQSConnection-DVy43GCV.d.mts.map +1 -0
- package/dist/SQSConnection-Y0mdVTcB.cjs +76 -0
- package/dist/SQSConnection-Y0mdVTcB.cjs.map +1 -0
- package/dist/SQSPublisher-B-32CC4G.mjs +57 -0
- package/dist/SQSPublisher-B-32CC4G.mjs.map +1 -0
- package/dist/SQSPublisher-CgUduk6H.cjs +63 -0
- package/dist/SQSPublisher-CgUduk6H.cjs.map +1 -0
- package/dist/SQSPublisher-kyl5HW3N.d.cts +25 -0
- package/dist/SQSPublisher-kyl5HW3N.d.cts.map +1 -0
- package/dist/SQSPublisher-qDE5Fp-N.d.mts +25 -0
- package/dist/SQSPublisher-qDE5Fp-N.d.mts.map +1 -0
- package/dist/SQSSubscriber-C4UA2hKq.cjs +120 -0
- package/dist/SQSSubscriber-C4UA2hKq.cjs.map +1 -0
- package/dist/SQSSubscriber-CDvaG4ij.d.cts +44 -0
- package/dist/SQSSubscriber-CDvaG4ij.d.cts.map +1 -0
- package/dist/SQSSubscriber-CQdSFzpe.mjs +114 -0
- package/dist/SQSSubscriber-CQdSFzpe.mjs.map +1 -0
- package/dist/SQSSubscriber-JfFuAAoP.d.mts +44 -0
- package/dist/SQSSubscriber-JfFuAAoP.d.mts.map +1 -0
- package/dist/Subscriber-CG_QUQZs.d.cts +21 -0
- package/dist/Subscriber-CG_QUQZs.d.cts.map +1 -0
- package/dist/Subscriber-CghW0A02.cjs +88 -0
- package/dist/Subscriber-CghW0A02.cjs.map +1 -0
- package/dist/Subscriber-DiYHmuF0.d.mts +21 -0
- package/dist/Subscriber-DiYHmuF0.d.mts.map +1 -0
- package/dist/Subscriber-bnkFtSvt.mjs +83 -0
- package/dist/Subscriber-bnkFtSvt.mjs.map +1 -0
- package/dist/Subscriber.cjs +4 -0
- package/dist/Subscriber.d.cts +3 -0
- package/dist/Subscriber.d.mts +3 -0
- package/dist/Subscriber.mjs +4 -0
- package/dist/basic/BasicConnection.cjs +4 -0
- package/dist/basic/BasicConnection.d.cts +3 -0
- package/dist/basic/BasicConnection.d.mts +3 -0
- package/dist/basic/BasicConnection.mjs +4 -0
- package/dist/basic/BasicPublisher.cjs +3 -0
- package/dist/basic/BasicPublisher.d.cts +4 -0
- package/dist/basic/BasicPublisher.d.mts +4 -0
- package/dist/basic/BasicPublisher.mjs +3 -0
- package/dist/basic/BasicSubscriber.cjs +3 -0
- package/dist/basic/BasicSubscriber.d.cts +4 -0
- package/dist/basic/BasicSubscriber.d.mts +4 -0
- package/dist/basic/BasicSubscriber.mjs +3 -0
- package/dist/basic/index.cjs +7 -100
- package/dist/basic/index.d.cts +5 -45
- package/dist/basic/index.d.mts +5 -45
- package/dist/basic/index.mjs +5 -96
- package/dist/{rolldown-runtime-C0BPl7ul.cjs → chunk-CUT6urMc.cjs} +10 -23
- package/dist/index.cjs +8 -87
- package/dist/index.d.cts +5 -102
- package/dist/index.d.mts +5 -102
- package/dist/index.mjs +5 -71
- package/dist/pgboss/PgBossConnection.cjs +4 -0
- package/dist/pgboss/PgBossConnection.d.cts +3 -0
- package/dist/pgboss/PgBossConnection.d.mts +3 -0
- package/dist/pgboss/PgBossConnection.mjs +4 -0
- package/dist/pgboss/PgBossPublisher.cjs +3 -0
- package/dist/pgboss/PgBossPublisher.d.cts +4 -0
- package/dist/pgboss/PgBossPublisher.d.mts +4 -0
- package/dist/pgboss/PgBossPublisher.mjs +3 -0
- package/dist/pgboss/PgBossSubscriber.cjs +3 -0
- package/dist/pgboss/PgBossSubscriber.d.cts +4 -0
- package/dist/pgboss/PgBossSubscriber.d.mts +4 -0
- package/dist/pgboss/PgBossSubscriber.mjs +3 -0
- package/dist/pgboss/index.cjs +7 -247
- package/dist/pgboss/index.d.cts +5 -107
- package/dist/pgboss/index.d.mts +5 -107
- package/dist/pgboss/index.mjs +5 -240
- package/dist/rabbitmq/RabbitMQConnection.cjs +4 -0
- package/dist/rabbitmq/RabbitMQConnection.d.cts +3 -0
- package/dist/rabbitmq/RabbitMQConnection.d.mts +3 -0
- package/dist/rabbitmq/RabbitMQConnection.mjs +4 -0
- package/dist/rabbitmq/RabbitMQPublisher.cjs +3 -0
- package/dist/rabbitmq/RabbitMQPublisher.d.cts +4 -0
- package/dist/rabbitmq/RabbitMQPublisher.d.mts +4 -0
- package/dist/rabbitmq/RabbitMQPublisher.mjs +3 -0
- package/dist/rabbitmq/RabbitMQSubscriber.cjs +3 -0
- package/dist/rabbitmq/RabbitMQSubscriber.d.cts +4 -0
- package/dist/rabbitmq/RabbitMQSubscriber.d.mts +4 -0
- package/dist/rabbitmq/RabbitMQSubscriber.mjs +3 -0
- package/dist/rabbitmq/index.cjs +7 -243
- package/dist/rabbitmq/index.d.cts +5 -92
- package/dist/rabbitmq/index.d.mts +5 -92
- package/dist/rabbitmq/index.mjs +5 -237
- package/dist/sns/SNSConnection.cjs +4 -0
- package/dist/sns/SNSConnection.d.cts +3 -0
- package/dist/sns/SNSConnection.d.mts +3 -0
- package/dist/sns/SNSConnection.mjs +4 -0
- package/dist/sns/SNSPublisher.cjs +3 -0
- package/dist/sns/SNSPublisher.d.cts +4 -0
- package/dist/sns/SNSPublisher.d.mts +4 -0
- package/dist/sns/SNSPublisher.mjs +3 -0
- package/dist/sns/SNSSubscriber.cjs +6 -0
- package/dist/sns/SNSSubscriber.d.cts +4 -0
- package/dist/sns/SNSSubscriber.d.mts +4 -0
- package/dist/sns/SNSSubscriber.mjs +6 -0
- package/dist/sns/index.cjs +9 -551
- package/dist/sns/index.d.cts +5 -273
- package/dist/sns/index.d.mts +5 -273
- package/dist/sns/index.mjs +7 -527
- package/dist/sqs/SQSConnection.cjs +4 -0
- package/dist/sqs/SQSConnection.d.cts +3 -0
- package/dist/sqs/SQSConnection.d.mts +3 -0
- package/dist/sqs/SQSConnection.mjs +4 -0
- package/dist/sqs/SQSPublisher.cjs +3 -0
- package/dist/sqs/SQSPublisher.d.cts +4 -0
- package/dist/sqs/SQSPublisher.d.mts +4 -0
- package/dist/sqs/SQSPublisher.mjs +3 -0
- package/dist/sqs/SQSSubscriber.cjs +3 -0
- package/dist/sqs/SQSSubscriber.d.cts +4 -0
- package/dist/sqs/SQSSubscriber.d.mts +4 -0
- package/dist/sqs/SQSSubscriber.mjs +3 -0
- package/dist/sqs/index.cjs +7 -35
- package/dist/sqs/index.d.cts +5 -118
- package/dist/sqs/index.d.mts +5 -118
- package/dist/sqs/index.mjs +5 -24
- package/dist/types-BrdcSEnd.mjs +18 -0
- package/dist/types-BrdcSEnd.mjs.map +1 -0
- package/dist/types-Byv8N9ma.cjs +24 -0
- package/dist/types-Byv8N9ma.cjs.map +1 -0
- package/dist/types-Dh9Jyinx.d.mts +67 -0
- package/dist/types-Dh9Jyinx.d.mts.map +1 -0
- package/dist/types-Dj23od3e.d.cts +67 -0
- package/dist/types-Dj23od3e.d.cts.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +3 -0
- package/package.json +12 -40
- package/src/EventConnection.ts +43 -0
- package/src/Publisher.ts +98 -0
- package/src/Subscriber.ts +113 -0
- package/src/__tests__/EventConnection.spec.ts +42 -0
- package/src/__tests__/Publisher.spec.ts +96 -0
- package/src/__tests__/Subscriber.spec.ts +109 -0
- package/src/basic/BasicConnection.ts +47 -0
- package/src/basic/BasicPublisher.ts +15 -0
- package/src/basic/BasicSubscriber.ts +21 -0
- package/src/basic/__tests__/BasicSubscriber.spec.ts +166 -0
- package/src/basic/index.ts +3 -0
- package/src/index.ts +25 -0
- package/src/pgboss/PgBossConnection.ts +91 -0
- package/src/pgboss/PgBossPublisher.ts +49 -0
- package/src/pgboss/PgBossSubscriber.ts +81 -0
- package/src/pgboss/__tests__/pgboss.spec.ts +196 -0
- package/src/pgboss/__tests__/setup.ts +21 -0
- package/src/pgboss/index.ts +5 -0
- package/src/rabbitmq/RabbitMQConnection.ts +148 -0
- package/src/rabbitmq/RabbitMQPublisher.ts +67 -0
- package/src/rabbitmq/RabbitMQSubscriber.ts +111 -0
- package/src/rabbitmq/__tests__/RabbitMQPublisher.spec.ts +378 -0
- package/src/rabbitmq/__tests__/RabbitMQSubscriber.spec.ts +292 -0
- package/src/rabbitmq/index.ts +6 -0
- package/src/sns/SNSConnection.ts +98 -0
- package/src/sns/SNSPublisher.ts +62 -0
- package/src/sns/SNSSubscriber.ts +218 -0
- package/src/sns/__tests__/SNS-SQS-Integration.spec.ts +389 -0
- package/src/sns/__tests__/SNSPublisher.spec.ts +449 -0
- package/src/sns/__tests__/SNSSubscriber.spec.ts +527 -0
- package/src/sns/index.ts +6 -0
- package/src/sqs/SQSConnection.ts +97 -0
- package/src/sqs/SQSPublisher.ts +105 -0
- package/src/sqs/SQSSubscriber.ts +181 -0
- package/src/sqs/__tests__/SQSPublisher.spec.ts +189 -0
- package/src/sqs/index.ts +6 -0
- package/src/types.ts +76 -0
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +10 -0
- package/dist/SQSSubscriber-BEJBfNTe.mjs +0 -264
- package/dist/SQSSubscriber-BEJBfNTe.mjs.map +0 -1
- package/dist/SQSSubscriber-COTqWvOk.cjs +0 -288
- package/dist/SQSSubscriber-COTqWvOk.cjs.map +0 -1
- package/dist/basic/index.cjs.map +0 -1
- package/dist/basic/index.d.cts.map +0 -1
- package/dist/basic/index.d.mts.map +0 -1
- package/dist/basic/index.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/pgboss/index.cjs.map +0 -1
- package/dist/pgboss/index.d.cts.map +0 -1
- package/dist/pgboss/index.d.mts.map +0 -1
- package/dist/pgboss/index.mjs.map +0 -1
- package/dist/rabbitmq/index.cjs.map +0 -1
- package/dist/rabbitmq/index.d.cts.map +0 -1
- package/dist/rabbitmq/index.d.mts.map +0 -1
- package/dist/rabbitmq/index.mjs.map +0 -1
- package/dist/registry-DIx25Q5s.d.cts +0 -255
- package/dist/registry-DIx25Q5s.d.cts.map +0 -1
- package/dist/registry-DIx25Q5s.d.mts +0 -255
- package/dist/registry-DIx25Q5s.d.mts.map +0 -1
- package/dist/registry-DXLY1Xf6.mjs +0 -99
- package/dist/registry-DXLY1Xf6.mjs.map +0 -1
- package/dist/registry-DlT36229.cjs +0 -122
- package/dist/registry-DlT36229.cjs.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
- package/dist/sns/index.cjs.map +0 -1
- package/dist/sns/index.d.cts.map +0 -1
- package/dist/sns/index.d.mts.map +0 -1
- package/dist/sns/index.mjs.map +0 -1
- package/dist/sns/snsUrl.cjs +0 -92
- package/dist/sns/snsUrl.cjs.map +0 -1
- package/dist/sns/snsUrl.d.cts +0 -57
- package/dist/sns/snsUrl.d.cts.map +0 -1
- package/dist/sns/snsUrl.d.mts +0 -57
- package/dist/sns/snsUrl.d.mts.map +0 -1
- package/dist/sns/snsUrl.mjs +0 -82
- package/dist/sns/snsUrl.mjs.map +0 -1
- package/dist/sqs/index.cjs.map +0 -1
- package/dist/sqs/index.d.cts.map +0 -1
- package/dist/sqs/index.d.mts.map +0 -1
- package/dist/sqs/index.mjs.map +0 -1
- package/dist/sqs/sqsUrl.cjs +0 -93
- package/dist/sqs/sqsUrl.cjs.map +0 -1
- package/dist/sqs/sqsUrl.d.cts +0 -56
- package/dist/sqs/sqsUrl.d.cts.map +0 -1
- package/dist/sqs/sqsUrl.d.mts +0 -56
- package/dist/sqs/sqsUrl.d.mts.map +0 -1
- package/dist/sqs/sqsUrl.mjs +0 -83
- package/dist/sqs/sqsUrl.mjs.map +0 -1
- package/dist/telemetry-DG3l807O.cjs +0 -309
- package/dist/telemetry-DG3l807O.cjs.map +0 -1
- package/dist/telemetry-DjjgJMul.mjs +0 -244
- package/dist/telemetry-DjjgJMul.mjs.map +0 -1
package/dist/basic/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/basic/BasicConnection.ts","../../src/basic/BasicPublisher.ts","../../src/basic/BasicSubscriber.ts","../../src/basic/driver.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","import { publishTraced } from '../telemetry';\nimport 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\t// The trace context rides beside the message, as the emitter's second\n\t\t// argument, so the message a listener receives is the one published.\n\t\tawait publishTraced(\n\t\t\tmessages,\n\t\t\t(message) => ({\n\t\t\t\tsystem: 'basic',\n\t\t\t\tdestination: message.type,\n\t\t\t\ttype: message.type,\n\t\t\t}),\n\t\t\tasync (carriers) => {\n\t\t\t\tmessages.forEach((message, i) => {\n\t\t\t\t\temitter.emit(message.type, message, carriers[i]);\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t}\n}\n","import { consumeTraced, type TraceCarrier } from '../telemetry';\nimport 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, carrier?: TraceCarrier) => {\n\t\t\t\tconsumeTraced(\n\t\t\t\t\t{ system: 'basic', destination: messageType, type: messageType },\n\t\t\t\t\tcarrier,\n\t\t\t\t\t() => listener(message),\n\t\t\t\t).catch((_error) => {});\n\t\t\t});\n\t\t}\n\t}\n}\n","import type { EventsDriver } from '../registry';\nimport { EventPublisherType } from '../types';\nimport { BasicConnection } from './BasicConnection';\nimport { BasicPublisher } from './BasicPublisher';\nimport { BasicSubscriber } from './BasicSubscriber';\n\n/**\n * `basic://` — an in-process `EventEmitter`. Register it with\n * `registerEventsDriver(basicEventsDriver)`.\n */\nexport const basicEventsDriver: EventsDriver = {\n\tscheme: EventPublisherType.Basic,\n\tconnect: (url) => BasicConnection.fromConnectionString(url),\n\tasync publisher(url) {\n\t\treturn new BasicPublisher(await BasicConnection.fromConnectionString(url));\n\t},\n\tpublisherFor: (connection) =>\n\t\tnew BasicPublisher(connection as BasicConnection),\n\tasync subscriber(url) {\n\t\treturn new BasicSubscriber(await BasicConnection.fromConnectionString(url));\n\t},\n\tsubscriberFor: (connection) =>\n\t\tnew BasicSubscriber(connection as BasicConnection),\n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AU,KAAK;EACpB,OAAO,IAAI,eAAe,MAAM,gBAAgB,qBAAqB,GAAG,CAAC;CAC1E;CACA,eAAe,eACd,IAAI,eAAe,UAA6B;CACjD,MAAM,WAAW,KAAK;EACrB,OAAO,IAAI,gBAAgB,MAAM,gBAAgB,qBAAqB,GAAG,CAAC;CAC3E;CACA,gBAAgB,eACf,IAAI,gBAAgB,UAA6B;AACnD"}
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["eventsDriverFor","eventsDriverFor","eventsDriverFor"],"sources":["../src/EventConnection.ts","../src/Publisher.ts","../src/Subscriber.ts"],"sourcesContent":["import { eventsDriverFor } from './registry';\nimport type { EventConnection } from './types';\n\nexport class EventConnectionFactory {\n\t/**\n\t * Create an EventConnection from a connection string, through whichever\n\t * driver is registered for its scheme — see `registerEventsDriver`.\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionStr: string,\n\t): Promise<EventConnection> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'connection').connect(connectionStr);\n\t}\n}\n\nexport type { EventConnection } from './types';\nexport { EventPublisherType } from './types';\n","import { eventsDriverFor } from './registry';\nimport type {\n\tEventConnection,\n\tEventPublisher,\n\tEventPublisherType,\n\tPublishableMessage,\n} from './types';\n\n/** How a publisher is used, beyond the address it reaches. */\nexport interface PublisherOptions {\n\t/**\n\t * The topic this publisher fans out to. SNS and RabbitMQ name the topic in\n\t * their address already; pg-boss has one address for every topic and queue,\n\t * so it is told here that a message goes to every subscriber rather than to\n\t * one queue.\n\t */\n\ttopic?: string;\n}\n\n/**\n * Publishers for a connection string or a connection, through whichever\n * driver is registered for its scheme — see `registerEventsDriver`.\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\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventPublisherConnectionString,\n\t\toptions: PublisherOptions = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'publisher').publisher<TMessage>(\n\t\t\tconnectionStr,\n\t\t\toptions,\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\toptions: PublisherOptions = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\treturn eventsDriverFor(connection.type, 'publisher').publisherFor<TMessage>(\n\t\t\tconnection,\n\t\t\toptions,\n\t\t);\n\t}\n}\n\nexport type EventPublisherConnectionString =\n\t`${EventPublisherType}://${string}`;\n","import { eventsDriverFor, type SubscriberOptions } from './registry';\nimport type {\n\tEventConnection,\n\tEventPublisherType,\n\tEventSubscriber,\n\tPublishableMessage,\n} from './types';\n\n/**\n * Subscribers for a connection string or a connection, through whichever\n * driver is registered for its scheme — see `registerEventsDriver`.\n */\nexport class Subscriber {\n\t/**\n\t * Create a subscriber from a connection string\n\t * This creates both a connection and a subscriber\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventSubscriberConnectionString,\n\t): Promise<EventSubscriber<TMessage>> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'subscriber').subscriber<TMessage>(\n\t\t\tconnectionStr,\n\t\t);\n\t}\n\n\t/**\n\t * Create a subscriber 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\t/**\n\t\t * Subscribing to a topic as a named subscriber. pg-boss needs both to\n\t\t * give each subscriber its own queue; the other transports carry the\n\t\t * topic in their address and ignore it.\n\t\t */\n\t\toptions: SubscriberOptions = {},\n\t): Promise<EventSubscriber<TMessage>> {\n\t\treturn eventsDriverFor(\n\t\t\tconnection.type,\n\t\t\t'subscriber',\n\t\t).subscriberFor<TMessage>(connection, options);\n\t}\n}\n\nexport type EventSubscriberConnectionString =\n\t`${EventPublisherType}://${string}`;\n"],"mappings":";;;;AAGA,IAAa,yBAAb,MAAoC;;;;;;;;CAQnC,aAAa,qBACZ,eAC2B;EAC3B,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAOA,iBAAAA,gBAAgB,QAAQ,YAAY,CAAC,CAAC,QAAQ,aAAa;CACnE;AACD;;;;;;;ACMA,IAAa,YAAb,MAAuB;;;;;;;;CAQtB,aAAa,qBAGZ,eACA,UAA4B,CAAC,GACO;EACpC,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAOC,iBAAAA,gBAAgB,QAAQ,WAAW,CAAC,CAAC,UAC3C,eACA,OACD;CACD;;;;;CAMA,aAAa,eACZ,YACA,UAA4B,CAAC,GACO;EACpC,OAAOA,iBAAAA,gBAAgB,WAAW,MAAM,WAAW,CAAC,CAAC,aACpD,YACA,OACD;CACD;AACD;;;;;;;AC7CA,IAAa,aAAb,MAAwB;;;;;;;;CAQvB,aAAa,qBAGZ,eACqC;EACrC,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAOC,iBAAAA,gBAAgB,QAAQ,YAAY,CAAC,CAAC,WAC5C,aACD;CACD;;;;;CAMA,aAAa,eACZ,YAMA,UAA6B,CAAC,GACO;EACrC,OAAOA,iBAAAA,gBACN,WAAW,MACX,YACD,CAAC,CAAC,cAAwB,YAAY,OAAO;CAC9C;AACD"}
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/EventConnection.ts","../src/Subscriber.ts","../src/telemetry.ts"],"mappings":";;;qBAGa;;;;;;;;SAQC,qBACZ,wBACE,QAAQ;;;;;;;;qBCDC;;;;;;;;SAQC,qBACZ,iBAAiB,iCAEjB,eAAe,kCACb,QAAQ,gBAAgB;;;;;SAWd,eAAe,iBAAiB,iCAC5C,YAAY,iBAMZ;;;;;;EAAA,UAAS,oBACP,QAAQ,gBAAgB;;KAQhB,qCACR;;;;;;;;qBCjBS;;KAGD,eAAe;;UAGV;;EAEhB;;EAEA;;EAEA;;EAEA;;;;;;wBA+DqB,cAAc,GAAG,GACtC,gBAAgB,KAChB,WAAW,MAAM,MAAM,iBACvB,OAAO,WAAW,gCAAgC,QAAQ,KACxD,QAAQ;;;;;wBAiBK,oBACf,SAAS,2BACP;;;;;;;wBAgBa,cAAc,GAC7B,QAAQ,iBACR,SAAS,0BACT,UAAU,QAAQ,KAChB,QAAQ;;;;;;wBAUK,mBAAmB,GAClC,QAAQ,iBACR,oBAAoB,6BACpB,UAAU,QAAQ,KAChB,QAAQ;;;;;;wBAwDK,sBACf,YAAY,6CACV;;;;;wBA+Da,gBAAgB,GAAG,MAAM;EACxC,MAAM;EACN,SAAS"}
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/EventConnection.ts","../src/Subscriber.ts","../src/telemetry.ts"],"mappings":";;;qBAGa;;;;;;;;SAQC,qBACZ,wBACE,QAAQ;;;;;;;;qBCDC;;;;;;;;SAQC,qBACZ,iBAAiB,iCAEjB,eAAe,kCACb,QAAQ,gBAAgB;;;;;SAWd,eAAe,iBAAiB,iCAC5C,YAAY,iBAMZ;;;;;;EAAA,UAAS,oBACP,QAAQ,gBAAgB;;KAQhB,qCACR;;;;;;;;qBCjBS;;KAGD,eAAe;;UAGV;;EAEhB;;EAEA;;EAEA;;EAEA;;;;;;wBA+DqB,cAAc,GAAG,GACtC,gBAAgB,KAChB,WAAW,MAAM,MAAM,iBACvB,OAAO,WAAW,gCAAgC,QAAQ,KACxD,QAAQ;;;;;wBAiBK,oBACf,SAAS,2BACP;;;;;;;wBAgBa,cAAc,GAC7B,QAAQ,iBACR,SAAS,0BACT,UAAU,QAAQ,KAChB,QAAQ;;;;;;wBAUK,mBAAmB,GAClC,QAAQ,iBACR,oBAAoB,6BACpB,UAAU,QAAQ,KAChB,QAAQ;;;;;;wBAwDK,sBACf,YAAY,6CACV;;;;;wBA+Da,gBAAgB,GAAG,MAAM;EACxC,MAAM;EACN,SAAS"}
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/EventConnection.ts","../src/Publisher.ts","../src/Subscriber.ts"],"sourcesContent":["import { eventsDriverFor } from './registry';\nimport type { EventConnection } from './types';\n\nexport class EventConnectionFactory {\n\t/**\n\t * Create an EventConnection from a connection string, through whichever\n\t * driver is registered for its scheme — see `registerEventsDriver`.\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionStr: string,\n\t): Promise<EventConnection> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'connection').connect(connectionStr);\n\t}\n}\n\nexport type { EventConnection } from './types';\nexport { EventPublisherType } from './types';\n","import { eventsDriverFor } from './registry';\nimport type {\n\tEventConnection,\n\tEventPublisher,\n\tEventPublisherType,\n\tPublishableMessage,\n} from './types';\n\n/** How a publisher is used, beyond the address it reaches. */\nexport interface PublisherOptions {\n\t/**\n\t * The topic this publisher fans out to. SNS and RabbitMQ name the topic in\n\t * their address already; pg-boss has one address for every topic and queue,\n\t * so it is told here that a message goes to every subscriber rather than to\n\t * one queue.\n\t */\n\ttopic?: string;\n}\n\n/**\n * Publishers for a connection string or a connection, through whichever\n * driver is registered for its scheme — see `registerEventsDriver`.\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\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventPublisherConnectionString,\n\t\toptions: PublisherOptions = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'publisher').publisher<TMessage>(\n\t\t\tconnectionStr,\n\t\t\toptions,\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\toptions: PublisherOptions = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\treturn eventsDriverFor(connection.type, 'publisher').publisherFor<TMessage>(\n\t\t\tconnection,\n\t\t\toptions,\n\t\t);\n\t}\n}\n\nexport type EventPublisherConnectionString =\n\t`${EventPublisherType}://${string}`;\n","import { eventsDriverFor, type SubscriberOptions } from './registry';\nimport type {\n\tEventConnection,\n\tEventPublisherType,\n\tEventSubscriber,\n\tPublishableMessage,\n} from './types';\n\n/**\n * Subscribers for a connection string or a connection, through whichever\n * driver is registered for its scheme — see `registerEventsDriver`.\n */\nexport class Subscriber {\n\t/**\n\t * Create a subscriber from a connection string\n\t * This creates both a connection and a subscriber\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventSubscriberConnectionString,\n\t): Promise<EventSubscriber<TMessage>> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'subscriber').subscriber<TMessage>(\n\t\t\tconnectionStr,\n\t\t);\n\t}\n\n\t/**\n\t * Create a subscriber 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\t/**\n\t\t * Subscribing to a topic as a named subscriber. pg-boss needs both to\n\t\t * give each subscriber its own queue; the other transports carry the\n\t\t * topic in their address and ignore it.\n\t\t */\n\t\toptions: SubscriberOptions = {},\n\t): Promise<EventSubscriber<TMessage>> {\n\t\treturn eventsDriverFor(\n\t\t\tconnection.type,\n\t\t\t'subscriber',\n\t\t).subscriberFor<TMessage>(connection, options);\n\t}\n}\n\nexport type EventSubscriberConnectionString =\n\t`${EventPublisherType}://${string}`;\n"],"mappings":";;;AAGA,IAAa,yBAAb,MAAoC;;;;;;;;CAQnC,aAAa,qBACZ,eAC2B;EAC3B,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAO,gBAAgB,QAAQ,YAAY,CAAC,CAAC,QAAQ,aAAa;CACnE;AACD;;;;;;;ACMA,IAAa,YAAb,MAAuB;;;;;;;;CAQtB,aAAa,qBAGZ,eACA,UAA4B,CAAC,GACO;EACpC,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAO,gBAAgB,QAAQ,WAAW,CAAC,CAAC,UAC3C,eACA,OACD;CACD;;;;;CAMA,aAAa,eACZ,YACA,UAA4B,CAAC,GACO;EACpC,OAAO,gBAAgB,WAAW,MAAM,WAAW,CAAC,CAAC,aACpD,YACA,OACD;CACD;AACD;;;;;;;AC7CA,IAAa,aAAb,MAAwB;;;;;;;;CAQvB,aAAa,qBAGZ,eACqC;EACrC,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAO,gBAAgB,QAAQ,YAAY,CAAC,CAAC,WAC5C,aACD;CACD;;;;;CAMA,aAAa,eACZ,YAMA,UAA6B,CAAC,GACO;EACrC,OAAO,gBACN,WAAW,MACX,YACD,CAAC,CAAC,cAAwB,YAAY,OAAO;CAC9C;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["PgBoss","publishTraced","withTraceKey","withoutTraceKey","consumeTraced"],"sources":["../../src/pgboss/PgBossConnection.ts","../../src/pgboss/errors.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts","../../src/pgboss/driver.ts"],"sourcesContent":["import { PgBoss } from 'pg-boss';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface PgBossConnectionConfig {\n\tconnectionString: string;\n\tschema?: string;\n\t/**\n\t * Who this connection is to Postgres. Defaults to `GKM_APP_NAME`, which a\n\t * generated entry sets to the construct it runs — so the broker's\n\t * connections are named for the process that holds them, as its database\n\t * pools are, rather than all being `pgboss`.\n\t */\n\tapplicationName?: string;\n}\n\nexport class PgBossConnection implements EventConnection {\n\treadonly type = EventPublisherType.PgBoss;\n\tprivate boss?: PgBoss;\n\tprivate connecting?: Promise<void>;\n\n\tconstructor(private config: PgBossConnectionConfig) {}\n\n\t/**\n\t * Create a PgBossConnection from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<PgBossConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst postgresUrl = `postgres://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst config: PgBossConnectionConfig = {\n\t\t\tconnectionString: postgresUrl,\n\t\t\tschema: params.get('schema') || undefined,\n\t\t};\n\n\t\tconst connection = new PgBossConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.boss) return;\n\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst applicationName =\n\t\t\t\t\tthis.config.applicationName ?? process.env.GKM_APP_NAME;\n\t\t\t\tconst boss = new PgBoss({\n\t\t\t\t\tconnectionString: this.config.connectionString,\n\t\t\t\t\t...(this.config.schema && { schema: this.config.schema }),\n\t\t\t\t\t...(applicationName && { application_name: applicationName }),\n\t\t\t\t});\n\n\t\t\t\tawait boss.start();\n\t\t\t\tthis.boss = boss;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.boss?.stop({ graceful: true });\n\t\t} catch {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.boss;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.boss = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying pg-boss instance for publishing/subscribing\n\t */\n\tget instance(): PgBoss | undefined {\n\t\treturn this.boss;\n\t}\n}\n","// Beside the adapter but apart from its connection module, which imports\n// the broker's client: the publisher and subscriber load that lazily, and\n// importing an error class from it would load it eagerly.\n\n/** pg-boss connected but its instance never started. */\nexport class PgBossNotStarted extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'pg-boss did not start. Check the database in the connection string is reachable and the role may create the pg-boss schema.',\n\t\t);\n\t\tthis.name = 'PgBossNotStarted';\n\t}\n}\n\n/** A topic subscription with no name to give the subscriber's own queue. */\nexport class PgBossSubscriptionNeedsName extends Error {\n\tconstructor(readonly topic: string) {\n\t\tsuper(\n\t\t\t`Subscribing to topic '${topic}' on pg-boss needs a subscription name: ` +\n\t\t\t\t'each subscriber drains a queue of its own, and that queue is named ' +\n\t\t\t\t'for it. Pass `subscription`.',\n\t\t);\n\t\tthis.name = 'PgBossSubscriptionNeedsName';\n\t}\n}\n","import { publishTraced, withTraceKey } from '../telemetry';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport { PgBossNotStarted } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\n\nexport interface PgBossPublisherOptions {\n\t/**\n\t * Publishing to a topic: each message is fanned out to every subscriber's\n\t * own queue rather than inserted into one shared queue. Without it, a\n\t * message goes to the queue named by its type — a work queue, one consumer.\n\t */\n\ttopic?: string;\n}\n\n/** The pg-boss event a topic's message type is published as. */\nexport function topicEvent(topic: string, type: string): string {\n\treturn `${topic}/${type}`;\n}\n\nexport class PgBossPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossPublisher from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionString: string,\n\t\toptions: PgBossPublisherOptions = {},\n\t): Promise<PgBossPublisher<TMessage>> {\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\t\treturn new PgBossPublisher<TMessage>(connection, options);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\t// A topic: pg-boss copies the job into every queue subscribed to the\n\t\t// event — one per subscriber — so each subscriber sees each message.\n\t\t// The type rides in the data, because the job is named for the queue.\n\t\t//\n\t\t// pg-boss has no header field, so the trace context rides in the data\n\t\t// too, under a reserved key the subscriber removes before the handler.\n\t\tconst { topic } = this.options;\n\t\tif (topic) {\n\t\t\tawait publishTraced(\n\t\t\t\tmessages,\n\t\t\t\t(m) => ({ system: 'pgboss', destination: topic, type: m.type }),\n\t\t\t\tasync (carriers) => {\n\t\t\t\t\tfor (const [i, m] of messages.entries()) {\n\t\t\t\t\t\tawait boss.publish(\n\t\t\t\t\t\t\ttopicEvent(topic, m.type),\n\t\t\t\t\t\t\twithTraceKey({ type: m.type, payload: m.payload }, carriers[i]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tawait publishTraced(\n\t\t\tmessages,\n\t\t\t(m) => ({ system: 'pgboss', destination: m.type, type: m.type }),\n\t\t\tasync (carriers) => {\n\t\t\t\t// Group jobs by queue name (v11+ requires per-queue insert calls)\n\t\t\t\tconst groups = new Map<string, { data: TMessage['payload'] }[]>();\n\t\t\t\tfor (const [i, m] of messages.entries()) {\n\t\t\t\t\tconst list = groups.get(m.type) ?? [];\n\t\t\t\t\tlist.push({ data: withTraceKey(m.payload, carriers[i]) });\n\t\t\t\t\tgroups.set(m.type, list);\n\t\t\t\t}\n\n\t\t\t\tfor (const [name, jobs] of groups) {\n\t\t\t\t\tawait boss.createQueue(name);\n\t\t\t\t\tawait boss.insert(name, jobs);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t}\n}\n","import { consumeTraced, withoutTraceKey } from '../telemetry';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport { PgBossNotStarted, PgBossSubscriptionNeedsName } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\nimport { topicEvent } from './PgBossPublisher';\n\nexport interface PgBossSubscriberOptions {\n\tbatchSize?: number;\n\tpollingIntervalSeconds?: number;\n\t/**\n\t * Subscribing to a topic. Each subscriber then drains a queue of its own,\n\t * `<topic>/<subscription>`, bound to the events it names — so every\n\t * subscriber sees every message, and replicas of one subscriber share it.\n\t * Without it, messages are drained from the queue named by their type:\n\t * work shared among whoever drains it.\n\t */\n\ttopic?: string;\n\t/** The subscriber's own name on the topic. Required with `topic`. */\n\tsubscription?: string;\n}\n\nexport class PgBossSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossSubscriber from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss&batchSize=5\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<PgBossSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\n\t\tconst options: PgBossSubscriberOptions = {\n\t\t\tbatchSize: params.get('batchSize')\n\t\t\t\t? Number.parseInt(params.get('batchSize')!, 10)\n\t\t\t\t: undefined,\n\t\t\tpollingIntervalSeconds: params.get('pollingIntervalSeconds')\n\t\t\t\t? Number.parseInt(params.get('pollingIntervalSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new PgBossSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\tconst work = {\n\t\t\t...(this.options.batchSize && { batchSize: this.options.batchSize }),\n\t\t\t...(this.options.pollingIntervalSeconds && {\n\t\t\t\tpollingIntervalSeconds: this.options.pollingIntervalSeconds,\n\t\t\t}),\n\t\t};\n\n\t\tconst { topic, subscription } = this.options;\n\t\tif (topic) {\n\t\t\tif (!subscription) throw new PgBossSubscriptionNeedsName(topic);\n\n\t\t\tconst queue = topicEvent(topic, subscription);\n\t\t\tawait boss.createQueue(queue);\n\t\t\tfor (const type of messages) {\n\t\t\t\tawait boss.subscribe(topicEvent(topic, type), queue);\n\t\t\t}\n\t\t\tawait boss.work<{ type: string; payload: unknown }>(\n\t\t\t\tqueue,\n\t\t\t\twork,\n\t\t\t\tasync (jobs) => {\n\t\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t\tconst { data, carrier } = withoutTraceKey(job.data);\n\t\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsystem: 'pgboss',\n\t\t\t\t\t\t\t\tdestination: topic,\n\t\t\t\t\t\t\t\ttype: data.type,\n\t\t\t\t\t\t\t\tmessageId: job.id,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcarrier,\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tlistener({\n\t\t\t\t\t\t\t\t\ttype: data.type,\n\t\t\t\t\t\t\t\t\tpayload: data.payload,\n\t\t\t\t\t\t\t\t} as TMessage),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const messageType of messages) {\n\t\t\tawait boss.createQueue(messageType);\n\t\t\tawait boss.work(messageType, work, async (jobs) => {\n\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t// The trace context is taken out of the data here, so the\n\t\t\t\t\t// handler's payload is exactly what was published.\n\t\t\t\t\tconst { data, carrier } = withoutTraceKey(job.data);\n\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsystem: 'pgboss',\n\t\t\t\t\t\t\tdestination: messageType,\n\t\t\t\t\t\t\ttype: job.name,\n\t\t\t\t\t\t\tmessageId: job.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcarrier,\n\t\t\t\t\t\t() => listener({ type: job.name, payload: data } as TMessage),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n","import type { EventsDriver } from '../registry';\nimport { EventPublisherType } from '../types';\nimport { PgBossConnection } from './PgBossConnection';\nimport { PgBossPublisher } from './PgBossPublisher';\nimport { PgBossSubscriber } from './PgBossSubscriber';\n\n/**\n * `pgboss://` — queues and topics in Postgres. Register it with\n * `registerEventsDriver(pgbossEventsDriver)`; this subpath is the only one\n * that imports `pg-boss`.\n */\nexport const pgbossEventsDriver: EventsDriver = {\n\tscheme: EventPublisherType.PgBoss,\n\tconnect: (url) => PgBossConnection.fromConnectionString(url),\n\tpublisher: (url, options) =>\n\t\tPgBossPublisher.fromConnectionString(url, options),\n\tpublisherFor: (connection, options) =>\n\t\tnew PgBossPublisher(connection as PgBossConnection, options),\n\tsubscriber: (url) => PgBossSubscriber.fromConnectionString(url),\n\tsubscriberFor: (connection, options) =>\n\t\tnew PgBossSubscriber(connection as PgBossConnection, options),\n};\n"],"mappings":";;;;;;AAgBA,IAAa,mBAAb,MAAa,iBAA4C;CAKpC;CAJpB,OAAS;CACT;CACA;CAEA,YAAY,QAAwC;EAAhC,KAAA,SAAA;CAAiC;;;;;CAMrD,aAAa,qBACZ,kBAC4B;EAC5B,MAAM,MAAM,IAAI,IAAI,gBAAgB;EACpC,MAAM,SAAS,IAAI;EAInB,MAAM,SAAiC;GACtC,kBAAkB,cAHe,IAAI,WAAW,GAAG,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,KAAK,IAAI,OAAO,IAAI;GAIzG,QAAQ,OAAO,IAAI,QAAQ,KAAK,KAAA;EACjC;EAEA,MAAM,aAAa,IAAI,iBAAiB,MAAM;EAC9C,MAAM,WAAW,QAAQ;EACzB,OAAO;CACR;CAEA,MAAM,UAAyB;EAC9B,IAAI,KAAK,MAAM;EAEf,IAAI,KAAK,YAAY;GACpB,MAAM,KAAK;GACX;EACD;EAEA,KAAK,cAAc,YAAY;GAC9B,IAAI;IACH,M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AI,IAAI;KAClD,MAAMC,kBAAAA,cACL;MACC,QAAQ;MACR,aAAa;MACb,MAAM,KAAK;MACX,WAAW,IAAI;KAChB,GACA,eAEC,SAAS;MACR,MAAM,KAAK;MACX,SAAS,KAAK;KACf,CAAa,CACf;IACD;GACD,CACD;GACA;EACD;EAEA,KAAK,MAAM,eAAe,UAAU;GACnC,MAAM,KAAK,YAAY,WAAW;GAClC,MAAM,KAAK,KAAK,aAAa,MAAM,OAAO,SAAS;IAClD,KAAK,MAAM,OAAO,MAAM;KAGvB,MAAM,EAAE,MAAM,YAAYD,kBAAAA,gBAAgB,IAAI,IAAI;KAClD,MAAMC,kBAAAA,cACL;MACC,QAAQ;MACR,aAAa;MACb,MAAM,IAAI;MACV,WAAW,IAAI;KAChB,GACA,eACM,SAAS;MAAE,MAAM,IAAI;MAAM,SAAS;KAAK,CAAa,CAC7D;IACD;GACD,CAAC;EACF;CACD;AACD;;;;;;;;ACxHA,MAAa,qBAAmC;CAC/C,QAAA;CACA,UAAU,QAAQ,iBAAiB,qBAAqB,GAAG;CAC3D,YAAY,KAAK,YAChB,gBAAgB,qBAAqB,KAAK,OAAO;CAClD,eAAe,YAAY,YAC1B,IAAI,gBAAgB,YAAgC,OAAO;CAC5D,aAAa,QAAQ,iBAAiB,qBAAqB,GAAG;CAC9D,gBAAgB,YAAY,YAC3B,IAAI,iBAAiB,YAAgC,OAAO;AAC9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/pgboss/driver.ts","../../src/pgboss/errors.ts","../../src/pgboss/PgBossConnection.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"mappings":";;;;;;;;qBAWa,oBAAoB;;;;qBCNpB,yBAAyB;EACrC;;;qBASY,oCAAoC;WAC3B;EAArB,YAAqB;;;;UCZL;EAChB;EACA;;;;;;;EAOA;;qBAGY,4BAA4B;UAKpB;WAJX,OAAI,mBAAA;UACL;UACA;EAER,YAAoB,QAAQ;;;;;SAMf,qBACZ,2BACE,QAAQ;EAgBL,WAAW;EA8BX,SAAS;EAUf;UAIQ;;;;MAQJ,YAAY;;;;UC5FA;;;;;;EAMhB;;;wBAIe,WAAW,eAAe;qBAI7B,gBAAgB,iBAAiB,4CAClC,eAAe;UAGjB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAEjB,0BACA,UAAS,yBACP,QAAQ,gBAAgB;EAOrB,QAAQ,UAAU,aAAa;EAqD/B,SAAS;;;;UC1FC;EAChB;EACA;;;;;;;;EAQA;;EAEA;;qBAGY,iBAAiB,iBAAiB,4CACnC,gBAAgB;UAGlB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,iBAAiB;EAoBhD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/pgboss/driver.ts","../../src/pgboss/errors.ts","../../src/pgboss/PgBossConnection.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"mappings":";;;;;;;;qBAWa,oBAAoB;;;;qBCNpB,yBAAyB;EACrC;;;qBASY,oCAAoC;WAC3B;EAArB,YAAqB;;;;UCZL;EAChB;EACA;;;;;;;EAOA;;qBAGY,4BAA4B;UAKpB;WAJX,OAAI,mBAAA;UACL;UACA;EAER,YAAoB,QAAQ;;;;;SAMf,qBACZ,2BACE,QAAQ;EAgBL,WAAW;EA8BX,SAAS;EAUf;UAIQ;;;;MAQJ,YAAY;;;;UC5FA;;;;;;EAMhB;;;wBAIe,WAAW,eAAe;qBAI7B,gBAAgB,iBAAiB,4CAClC,eAAe;UAGjB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAEjB,0BACA,UAAS,yBACP,QAAQ,gBAAgB;EAOrB,QAAQ,UAAU,aAAa;EAqD/B,SAAS;;;;UC1FC;EAChB;EACA;;;;;;;;EAQA;;EAEA;;qBAGY,iBAAiB,iBAAiB,4CACnC,gBAAgB;UAGlB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,iBAAiB;EAoBhD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/pgboss/PgBossConnection.ts","../../src/pgboss/errors.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts","../../src/pgboss/driver.ts"],"sourcesContent":["import { PgBoss } from 'pg-boss';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface PgBossConnectionConfig {\n\tconnectionString: string;\n\tschema?: string;\n\t/**\n\t * Who this connection is to Postgres. Defaults to `GKM_APP_NAME`, which a\n\t * generated entry sets to the construct it runs — so the broker's\n\t * connections are named for the process that holds them, as its database\n\t * pools are, rather than all being `pgboss`.\n\t */\n\tapplicationName?: string;\n}\n\nexport class PgBossConnection implements EventConnection {\n\treadonly type = EventPublisherType.PgBoss;\n\tprivate boss?: PgBoss;\n\tprivate connecting?: Promise<void>;\n\n\tconstructor(private config: PgBossConnectionConfig) {}\n\n\t/**\n\t * Create a PgBossConnection from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<PgBossConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst postgresUrl = `postgres://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst config: PgBossConnectionConfig = {\n\t\t\tconnectionString: postgresUrl,\n\t\t\tschema: params.get('schema') || undefined,\n\t\t};\n\n\t\tconst connection = new PgBossConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.boss) return;\n\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst applicationName =\n\t\t\t\t\tthis.config.applicationName ?? process.env.GKM_APP_NAME;\n\t\t\t\tconst boss = new PgBoss({\n\t\t\t\t\tconnectionString: this.config.connectionString,\n\t\t\t\t\t...(this.config.schema && { schema: this.config.schema }),\n\t\t\t\t\t...(applicationName && { application_name: applicationName }),\n\t\t\t\t});\n\n\t\t\t\tawait boss.start();\n\t\t\t\tthis.boss = boss;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.boss?.stop({ graceful: true });\n\t\t} catch {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.boss;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.boss = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying pg-boss instance for publishing/subscribing\n\t */\n\tget instance(): PgBoss | undefined {\n\t\treturn this.boss;\n\t}\n}\n","// Beside the adapter but apart from its connection module, which imports\n// the broker's client: the publisher and subscriber load that lazily, and\n// importing an error class from it would load it eagerly.\n\n/** pg-boss connected but its instance never started. */\nexport class PgBossNotStarted extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'pg-boss did not start. Check the database in the connection string is reachable and the role may create the pg-boss schema.',\n\t\t);\n\t\tthis.name = 'PgBossNotStarted';\n\t}\n}\n\n/** A topic subscription with no name to give the subscriber's own queue. */\nexport class PgBossSubscriptionNeedsName extends Error {\n\tconstructor(readonly topic: string) {\n\t\tsuper(\n\t\t\t`Subscribing to topic '${topic}' on pg-boss needs a subscription name: ` +\n\t\t\t\t'each subscriber drains a queue of its own, and that queue is named ' +\n\t\t\t\t'for it. Pass `subscription`.',\n\t\t);\n\t\tthis.name = 'PgBossSubscriptionNeedsName';\n\t}\n}\n","import { publishTraced, withTraceKey } from '../telemetry';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport { PgBossNotStarted } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\n\nexport interface PgBossPublisherOptions {\n\t/**\n\t * Publishing to a topic: each message is fanned out to every subscriber's\n\t * own queue rather than inserted into one shared queue. Without it, a\n\t * message goes to the queue named by its type — a work queue, one consumer.\n\t */\n\ttopic?: string;\n}\n\n/** The pg-boss event a topic's message type is published as. */\nexport function topicEvent(topic: string, type: string): string {\n\treturn `${topic}/${type}`;\n}\n\nexport class PgBossPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossPublisher from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionString: string,\n\t\toptions: PgBossPublisherOptions = {},\n\t): Promise<PgBossPublisher<TMessage>> {\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\t\treturn new PgBossPublisher<TMessage>(connection, options);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\t// A topic: pg-boss copies the job into every queue subscribed to the\n\t\t// event — one per subscriber — so each subscriber sees each message.\n\t\t// The type rides in the data, because the job is named for the queue.\n\t\t//\n\t\t// pg-boss has no header field, so the trace context rides in the data\n\t\t// too, under a reserved key the subscriber removes before the handler.\n\t\tconst { topic } = this.options;\n\t\tif (topic) {\n\t\t\tawait publishTraced(\n\t\t\t\tmessages,\n\t\t\t\t(m) => ({ system: 'pgboss', destination: topic, type: m.type }),\n\t\t\t\tasync (carriers) => {\n\t\t\t\t\tfor (const [i, m] of messages.entries()) {\n\t\t\t\t\t\tawait boss.publish(\n\t\t\t\t\t\t\ttopicEvent(topic, m.type),\n\t\t\t\t\t\t\twithTraceKey({ type: m.type, payload: m.payload }, carriers[i]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tawait publishTraced(\n\t\t\tmessages,\n\t\t\t(m) => ({ system: 'pgboss', destination: m.type, type: m.type }),\n\t\t\tasync (carriers) => {\n\t\t\t\t// Group jobs by queue name (v11+ requires per-queue insert calls)\n\t\t\t\tconst groups = new Map<string, { data: TMessage['payload'] }[]>();\n\t\t\t\tfor (const [i, m] of messages.entries()) {\n\t\t\t\t\tconst list = groups.get(m.type) ?? [];\n\t\t\t\t\tlist.push({ data: withTraceKey(m.payload, carriers[i]) });\n\t\t\t\t\tgroups.set(m.type, list);\n\t\t\t\t}\n\n\t\t\t\tfor (const [name, jobs] of groups) {\n\t\t\t\t\tawait boss.createQueue(name);\n\t\t\t\t\tawait boss.insert(name, jobs);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t}\n}\n","import { consumeTraced, withoutTraceKey } from '../telemetry';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport { PgBossNotStarted, PgBossSubscriptionNeedsName } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\nimport { topicEvent } from './PgBossPublisher';\n\nexport interface PgBossSubscriberOptions {\n\tbatchSize?: number;\n\tpollingIntervalSeconds?: number;\n\t/**\n\t * Subscribing to a topic. Each subscriber then drains a queue of its own,\n\t * `<topic>/<subscription>`, bound to the events it names — so every\n\t * subscriber sees every message, and replicas of one subscriber share it.\n\t * Without it, messages are drained from the queue named by their type:\n\t * work shared among whoever drains it.\n\t */\n\ttopic?: string;\n\t/** The subscriber's own name on the topic. Required with `topic`. */\n\tsubscription?: string;\n}\n\nexport class PgBossSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossSubscriber from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss&batchSize=5\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<PgBossSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\n\t\tconst options: PgBossSubscriberOptions = {\n\t\t\tbatchSize: params.get('batchSize')\n\t\t\t\t? Number.parseInt(params.get('batchSize')!, 10)\n\t\t\t\t: undefined,\n\t\t\tpollingIntervalSeconds: params.get('pollingIntervalSeconds')\n\t\t\t\t? Number.parseInt(params.get('pollingIntervalSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new PgBossSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\tconst work = {\n\t\t\t...(this.options.batchSize && { batchSize: this.options.batchSize }),\n\t\t\t...(this.options.pollingIntervalSeconds && {\n\t\t\t\tpollingIntervalSeconds: this.options.pollingIntervalSeconds,\n\t\t\t}),\n\t\t};\n\n\t\tconst { topic, subscription } = this.options;\n\t\tif (topic) {\n\t\t\tif (!subscription) throw new PgBossSubscriptionNeedsName(topic);\n\n\t\t\tconst queue = topicEvent(topic, subscription);\n\t\t\tawait boss.createQueue(queue);\n\t\t\tfor (const type of messages) {\n\t\t\t\tawait boss.subscribe(topicEvent(topic, type), queue);\n\t\t\t}\n\t\t\tawait boss.work<{ type: string; payload: unknown }>(\n\t\t\t\tqueue,\n\t\t\t\twork,\n\t\t\t\tasync (jobs) => {\n\t\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t\tconst { data, carrier } = withoutTraceKey(job.data);\n\t\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsystem: 'pgboss',\n\t\t\t\t\t\t\t\tdestination: topic,\n\t\t\t\t\t\t\t\ttype: data.type,\n\t\t\t\t\t\t\t\tmessageId: job.id,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcarrier,\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tlistener({\n\t\t\t\t\t\t\t\t\ttype: data.type,\n\t\t\t\t\t\t\t\t\tpayload: data.payload,\n\t\t\t\t\t\t\t\t} as TMessage),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const messageType of messages) {\n\t\t\tawait boss.createQueue(messageType);\n\t\t\tawait boss.work(messageType, work, async (jobs) => {\n\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t// The trace context is taken out of the data here, so the\n\t\t\t\t\t// handler's payload is exactly what was published.\n\t\t\t\t\tconst { data, carrier } = withoutTraceKey(job.data);\n\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsystem: 'pgboss',\n\t\t\t\t\t\t\tdestination: messageType,\n\t\t\t\t\t\t\ttype: job.name,\n\t\t\t\t\t\t\tmessageId: job.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcarrier,\n\t\t\t\t\t\t() => listener({ type: job.name, payload: data } as TMessage),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n","import type { EventsDriver } from '../registry';\nimport { EventPublisherType } from '../types';\nimport { PgBossConnection } from './PgBossConnection';\nimport { PgBossPublisher } from './PgBossPublisher';\nimport { PgBossSubscriber } from './PgBossSubscriber';\n\n/**\n * `pgboss://` — queues and topics in Postgres. Register it with\n * `registerEventsDriver(pgbossEventsDriver)`; this subpath is the only one\n * that imports `pg-boss`.\n */\nexport const pgbossEventsDriver: EventsDriver = {\n\tscheme: EventPublisherType.PgBoss,\n\tconnect: (url) => PgBossConnection.fromConnectionString(url),\n\tpublisher: (url, options) =>\n\t\tPgBossPublisher.fromConnectionString(url, options),\n\tpublisherFor: (connection, options) =>\n\t\tnew PgBossPublisher(connection as PgBossConnection, options),\n\tsubscriber: (url) => PgBossSubscriber.fromConnectionString(url),\n\tsubscriberFor: (connection, options) =>\n\t\tnew PgBossSubscriber(connection as PgBossConnection, options),\n};\n"],"mappings":";;;;;AAgBA,IAAa,mBAAb,MAAa,iBAA4C;CAKpC;CAJpB,OAAS;CACT;CACA;CAEA,YAAY,QAAwC;EAAhC,KAAA,SAAA;CAAiC;;;;;CAMrD,aAAa,qBACZ,kBAC4B;EAC5B,MAAM,MAAM,IAAI,IAAI,gBAAgB;EACpC,MAAM,SAAS,IAAI;EAInB,MAAM,SAAiC;GACtC,kBAAkB,cAHe,IAAI,WAAW,GAAG,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,KAAK,IAAI,OAAO,IAAI;GAIzG,QAAQ,OAAO,IAAI,QAAQ,KAAK,KAAA;EACjC;EAE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AM,KAAK,UAAU,WAAW,OAAO,IAAI,GAAG,KAAK;GAEpD,MAAM,KAAK,KACV,OACA,MACA,OAAO,SAAS;IACf,KAAK,MAAM,OAAO,MAAM;KACvB,MAAM,EAAE,MAAM,YAAY,gBAAgB,IAAI,IAAI;KAClD,MAAM,cACL;MACC,QAAQ;MACR,aAAa;MACb,MAAM,KAAK;MACX,WAAW,IAAI;KAChB,GACA,eAEC,SAAS;MACR,MAAM,KAAK;MACX,SAAS,KAAK;KACf,CAAa,CACf;IACD;GACD,CACD;GACA;EACD;EAEA,KAAK,MAAM,eAAe,UAAU;GACnC,MAAM,KAAK,YAAY,WAAW;GAClC,MAAM,KAAK,KAAK,aAAa,MAAM,OAAO,SAAS;IAClD,KAAK,MAAM,OAAO,MAAM;KAGvB,MAAM,EAAE,MAAM,YAAY,gBAAgB,IAAI,IAAI;KAClD,MAAM,cACL;MACC,QAAQ;MACR,aAAa;MACb,MAAM,IAAI;MACV,WAAW,IAAI;KAChB,GACA,eACM,SAAS;MAAE,MAAM,IAAI;MAAM,SAAS;KAAK,CAAa,CAC7D;IACD;GACD,CAAC;EACF;CACD;AACD;;;;;;;;ACxHA,MAAa,qBAAmC;CAC/C,QAAA;CACA,UAAU,QAAQ,iBAAiB,qBAAqB,GAAG;CAC3D,YAAY,KAAK,YAChB,gBAAgB,qBAAqB,KAAK,OAAO;CAClD,eAAe,YAAY,YAC1B,IAAI,gBAAgB,YAAgC,OAAO;CAC5D,aAAa,QAAQ,iBAAiB,qBAAqB,GAAG;CAC9D,gBAAgB,YAAY,YAC3B,IAAI,iBAAiB,YAAgC,OAAO;AAC9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["publishTraced","consumeTraced","carrierFromAttributes"],"sources":["../../src/rabbitmq/RabbitMQConnection.ts","../../src/rabbitmq/errors.ts","../../src/rabbitmq/RabbitMQPublisher.ts","../../src/rabbitmq/RabbitMQSubscriber.ts","../../src/rabbitmq/driver.ts"],"sourcesContent":["import amqplib from 'amqplib';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface RabbitMQConnectionConfig {\n\turl: string;\n\texchange?: string;\n\texchangeType?: 'topic' | 'direct' | 'fanout' | 'headers';\n\texchangeOptions?: amqplib.Options.AssertExchange;\n\ttimeout?: number; // Connection timeout in milliseconds (default: 5000)\n}\n\nexport class RabbitMQConnection implements EventConnection {\n\treadonly type = EventPublisherType.RabbitMQ;\n\tprivate connection?: amqplib.ChannelModel;\n\tprivate channel?: amqplib.Channel;\n\tprivate connecting?: Promise<void>;\n\tprivate config: Required<\n\t\tPick<RabbitMQConnectionConfig, 'exchange' | 'exchangeType' | 'timeout'>\n\t> &\n\t\tRabbitMQConnectionConfig;\n\n\tconstructor(config: RabbitMQConnectionConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\texchange: config.exchange || 'geekmidas.events',\n\t\t\texchangeType: config.exchangeType || 'topic',\n\t\t\ttimeout: config.timeout ?? 5000,\n\t\t\texchangeOptions: {\n\t\t\t\tdurable: true,\n\t\t\t\t...config.exchangeOptions,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Create a RabbitMQConnection from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&timeout=5000\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<RabbitMQConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\t// Extract connection URL without query params\n\t\tconst baseUrl = `amqp://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst timeoutParam = params.get('timeout');\n\t\tconst config: RabbitMQConnectionConfig = {\n\t\t\turl: baseUrl,\n\t\t\texchange: params.get('exchange') || 'geekmidas.events',\n\t\t\texchangeType: (params.get('type') as any) || 'topic',\n\t\t\ttimeout: timeoutParam ? Number.parseInt(timeoutParam, 10) : undefined,\n\t\t};\n\n\t\tconst connection = new RabbitMQConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.channel) return;\n\n\t\t// Prevent multiple simultaneous connection attempts\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst connection = await amqplib.connect(this.config.url, {\n\t\t\t\t\ttimeout: this.config.timeout,\n\t\t\t\t});\n\t\t\t\tconst channel = await connection.createChannel();\n\n\t\t\t\t// Assert the exchange exists\n\t\t\t\tawait channel.assertExchange(\n\t\t\t\t\tthis.config.exchange!,\n\t\t\t\t\tthis.config.exchangeType!,\n\t\t\t\t\tthis.config.exchangeOptions,\n\t\t\t\t);\n\n\t\t\t\t// Handle connection errors\n\t\t\t\tconnection.on('error', (_err: Error) => {\n\t\t\t\t\tthis.cleanup();\n\t\t\t\t});\n\n\t\t\t\tconnection.on('close', () => {\n\t\t\t\t\tthis.cleanup();\n\t\t\t\t});\n\n\t\t\t\t// Only set after successful setup\n\t\t\t\tthis.connection = connection;\n\t\t\t\tthis.channel = channel;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.channel?.close();\n\t\t\tawait this.connection?.close();\n\t\t} catch (_error) {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.channel;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.channel = undefined;\n\t\tthis.connection = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying channel for publishing/subscribing\n\t */\n\tget amqpChannel(): amqplib.Channel | undefined {\n\t\treturn this.channel;\n\t}\n\n\t/**\n\t * Get the exchange name for this connection\n\t */\n\tget exchangeName(): string {\n\t\treturn this.config.exchange;\n\t}\n\n\t/**\n\t * Get the exchange type for this connection\n\t */\n\tget exchangeType(): string {\n\t\treturn this.config.exchangeType;\n\t}\n}\n","// Beside the adapter but apart from its connection module, which imports\n// the broker's client: the publisher and subscriber load that lazily, and\n// importing an error class from it would load it eagerly.\n\n/** The connection opened but has no channel to publish or consume on. */\nexport class RabbitMQChannelUnavailable extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'RabbitMQ connected without a channel. Check the broker is reachable and the connection string names a vhost the user can open channels on.',\n\t\t);\n\t\tthis.name = 'RabbitMQChannelUnavailable';\n\t}\n}\n","import type amqplib from 'amqplib';\nimport { publishTraced } from '../telemetry';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport { RabbitMQChannelUnavailable } from './errors';\nimport type { RabbitMQConnection } from './RabbitMQConnection';\n\nexport interface RabbitMQPublisherOptions {\n\tpublishOptions?: amqplib.Options.Publish;\n}\n\nexport class RabbitMQPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: RabbitMQConnection,\n\t\tprivate options: RabbitMQPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create a RabbitMQPublisher from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&timeout=5000\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<RabbitMQPublisher<TMessage>> {\n\t\tconst { RabbitMQConnection } = await import('./RabbitMQConnection');\n\t\tconst connection =\n\t\t\tawait RabbitMQConnection.fromConnectionString(connectionString);\n\t\treturn new RabbitMQPublisher<TMessage>(connection);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst channel = this.connection.amqpChannel;\n\t\tif (!channel) {\n\t\t\tthrow new RabbitMQChannelUnavailable();\n\t\t}\n\n\t\tconst exchange = this.connection.exchangeName;\n\n\t\tawait publishTraced(\n\t\t\tmessages,\n\t\t\t(message) => ({\n\t\t\t\tsystem: 'rabbitmq',\n\t\t\t\tdestination: exchange,\n\t\t\t\ttype: message.type,\n\t\t\t}),\n\t\t\tasync (carriers) => {\n\t\t\t\tfor (const [i, message] of messages.entries()) {\n\t\t\t\t\tconst content = Buffer.from(JSON.stringify(message.payload));\n\t\t\t\t\tconst { headers, ...publishOptions } =\n\t\t\t\t\t\tthis.options.publishOptions ?? {};\n\n\t\t\t\t\t// Use message type as routing key for topic exchanges; the trace\n\t\t\t\t\t// context goes in the message's headers.\n\t\t\t\t\tconst published = channel.publish(exchange, message.type, content, {\n\t\t\t\t\t\tcontentType: 'application/json',\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\ttype: message.type,\n\t\t\t\t\t\tpersistent: true,\n\t\t\t\t\t\t...publishOptions,\n\t\t\t\t\t\t...((headers || carriers[i]) && {\n\t\t\t\t\t\t\theaders: { ...headers, ...carriers[i] },\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\t// Handle backpressure\n\t\t\t\t\tif (!published) {\n\t\t\t\t\t\tawait new Promise((resolve) => channel.once('drain', resolve));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t\t// Connection should be closed by whoever created it\n\t}\n}\n","import type amqplib from 'amqplib';\nimport { carrierFromAttributes, consumeTraced } from '../telemetry';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport { RabbitMQChannelUnavailable } from './errors';\nimport type { RabbitMQConnection } from './RabbitMQConnection';\n\nexport interface RabbitMQSubscriberOptions {\n\tqueueName?: string; // If not provided, a unique queue will be generated\n\tqueueOptions?: amqplib.Options.AssertQueue;\n\tconsumeOptions?: amqplib.Options.Consume;\n\tprefetch?: number; // Number of messages to prefetch (default: 1)\n}\n\nexport class RabbitMQSubscriber<\n\tTMessage extends PublishableMessage<string, any>,\n> implements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: RabbitMQConnection,\n\t\tprivate options: RabbitMQSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a RabbitMQSubscriber from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&queueName=myqueue&prefetch=10\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<RabbitMQSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { RabbitMQConnection } = await import('./RabbitMQConnection');\n\t\tconst connection =\n\t\t\tawait RabbitMQConnection.fromConnectionString(connectionString);\n\n\t\tconst options: RabbitMQSubscriberOptions = {\n\t\t\tqueueName: params.get('queueName') || undefined,\n\t\t\tprefetch: params.get('prefetch')\n\t\t\t\t? Number.parseInt(params.get('prefetch')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new RabbitMQSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst channel = this.connection.amqpChannel;\n\t\tif (!channel) {\n\t\t\tthrow new RabbitMQChannelUnavailable();\n\t\t}\n\n\t\tconst exchange = this.connection.exchangeName;\n\n\t\t// Set prefetch if specified\n\t\tif (this.options.prefetch) {\n\t\t\tawait channel.prefetch(this.options.prefetch);\n\t\t}\n\n\t\t// Assert queue\n\t\tconst queueName = this.options.queueName || '';\n\t\tconst queueOptions: amqplib.Options.AssertQueue = {\n\t\t\tdurable: true,\n\t\t\t...this.options.queueOptions,\n\t\t};\n\n\t\tconst { queue } = await channel.assertQueue(queueName, queueOptions);\n\n\t\t// Bind queue to exchange for each message type\n\t\tfor (const messageType of messages) {\n\t\t\tawait channel.bindQueue(queue, exchange, messageType);\n\t\t}\n\n\t\t// Consume messages\n\t\tawait channel.consume(\n\t\t\tqueue,\n\t\t\tasync (msg) => {\n\t\t\t\tif (!msg) return;\n\n\t\t\t\ttry {\n\t\t\t\t\t// Parse message payload\n\t\t\t\t\tconst content = msg.content.toString();\n\t\t\t\t\tconst payload = JSON.parse(content);\n\n\t\t\t\t\t// Get message type from properties\n\t\t\t\t\tconst messageType = msg.properties.type;\n\n\t\t\t\t\t// Reconstruct full message\n\t\t\t\t\tconst fullMessage: TMessage = {\n\t\t\t\t\t\ttype: messageType,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t} as TMessage;\n\n\t\t\t\t\t// Call listener, as a child of the publisher's span\n\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsystem: 'rabbitmq',\n\t\t\t\t\t\t\tdestination: queue,\n\t\t\t\t\t\t\ttype: messageType,\n\t\t\t\t\t\t\tmessageId: msg.properties.messageId,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcarrierFromAttributes(msg.properties.headers),\n\t\t\t\t\t\t() => listener(fullMessage),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Ack message\n\t\t\t\t\tchannel.ack(msg);\n\t\t\t\t} catch (_error) {\n\t\t\t\t\tchannel.nack(msg, false, true);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.options.consumeOptions,\n\t\t);\n\t}\n}\n","import type { EventsDriver } from '../registry';\nimport { EventPublisherType } from '../types';\nimport { RabbitMQConnection } from './RabbitMQConnection';\nimport { RabbitMQPublisher } from './RabbitMQPublisher';\nimport { RabbitMQSubscriber } from './RabbitMQSubscriber';\n\n/**\n * `rabbitmq://` — an AMQP exchange. Register it with\n * `registerEventsDriver(rabbitmqEventsDriver)`; this subpath is the only one\n * that imports `amqplib`.\n */\nexport const rabbitmqEventsDriver: EventsDriver = {\n\tscheme: EventPublisherType.RabbitMQ,\n\tconnect: (url) => RabbitMQConnection.fromConnectionString(url),\n\tpublisher: (url) => RabbitMQPublisher.fromConnectionString(url),\n\tpublisherFor: (connection) =>\n\t\tnew RabbitMQPublisher(connection as RabbitMQConnection),\n\tsubscriber: (url) => RabbitMQSubscriber.fromConnectionString(url),\n\tsubscriberFor: (connection) =>\n\t\tnew RabbitMQSubscriber(connection as RabbitMQConnection),\n};\n"],"mappings":";;;;;;;AAYA,IAAa,qBAAb,MAAa,mBAA8C;CAC1D,OAAS;CACT;CACA;CACA;CACA;CAKA,YAAY,QAAkC;EAC7C,KAAK,SAAS;GACb,GAAG;GACH,UAAU,OAAO,YAAY;GAC7B,cAAc,OAAO,gBAAgB;GACrC,SAAS,OAAO,WAAW;GAC3B,iBAAiB;IAChB,SAAS;IACT,GAAG,OAAO;GACX;EACD;CACD;;;;;CAMA,aAAa,qBACZ,kBAC8B;EAC9B,MAAM,MAAM,IAAI,IAAI,gBAAgB;EACpC,MAAM,SAAS,IAAI;EAGnB,MAAM,UAAU,UAAU,IAAI,WAAW,GAAG,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,KAAK,IAAI,OAAO,IAAI;EAElG,MAAM,eAAe,OAAO,IAAI,SAAS;EACzC,MAAM,SAAmC;GACxC,KAAK;GACL,UAAU,OAAO,IAAI,UAAU,KAAK;GACpC,cAAe,OAAO,IAAI,MAAM,KAAa;GAC7C,SAAS,eAAe,OAAO,SAAS,cAAc,EAAE,IAAI,KAAA;EAC7D;EAEA,MAAM,aAAa,IAAI,mBAAmB,MAAM;EAChD,MAAM,WAAW,QAAQ;EACzB,OAAO;CACR;CAEA,MAAM,UAAyB;EAC9B,IAAI,KAAK,SAAS;EAGlB,IAAI,KAAK,YAAY;GACpB,MAAM,KAAK;GACX;EACD;EAEA,KAAK,cAAc,YAAY;GAC9B,IAAI;IACH,MAAM,aAAa,MAAM,QAAA,QAAQ,QAAQ,KAAK,OAAO,KAAK,EACzD,SAAS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AAmB,qBAAqB,GAAG;CAC7D,YAAY,QAAQ,kBAAkB,qBAAqB,GAAG;CAC9D,eAAe,eACd,IAAI,kBAAkB,UAAgC;CACvD,aAAa,QAAQ,mBAAmB,qBAAqB,GAAG;CAChE,gBAAgB,eACf,IAAI,mBAAmB,UAAgC;AACzD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/rabbitmq/driver.ts","../../src/rabbitmq/errors.ts","../../src/rabbitmq/RabbitMQConnection.ts","../../src/rabbitmq/RabbitMQPublisher.ts","../../src/rabbitmq/RabbitMQSubscriber.ts"],"mappings":";;;;;;;;qBAWa,sBAAsB;;;;qBCNtB,mCAAmC;EAC/C;;;;UCFgB;EAChB;EACA;EACA;EACA,kBAAkB,QAAQ,QAAQ;EAClC;;qBAGY,8BAA8B;WACjC,OAAI,mBAAA;UACL;UACA;UACA;UACA;EAKR,YAAY,QAAQ;;;;;SAiBP,qBACZ,2BACE,QAAQ;EAoBL,WAAW;EA6CX,SAAS;EAWf;UAIQ;;;;MASJ,eAAe,QAAQ;;;;MAOvB;;;;MAOA;;;;UC1IY;EAChB,iBAAiB,QAAQ,QAAQ;;qBAGrB,kBAAkB,iBAAiB,4CACpC,eAAe;UAGjB;UACA;EAFT,YACS,YAAY,oBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,kBAAkB;EAOjD,QAAQ,UAAU,aAAa;EA+C/B,SAAS;;;;UCxEC;EAChB;EACA,eAAe,QAAQ,QAAQ;EAC/B,iBAAiB,QAAQ,QAAQ;EACjC;;qBAGY,mBACZ,iBAAiB,4CACL,gBAAgB;UAGnB;UACA;EAFT,YACS,YAAY,oBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,mBAAmB;EAkBlD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/rabbitmq/driver.ts","../../src/rabbitmq/errors.ts","../../src/rabbitmq/RabbitMQConnection.ts","../../src/rabbitmq/RabbitMQPublisher.ts","../../src/rabbitmq/RabbitMQSubscriber.ts"],"mappings":";;;;;;;;qBAWa,sBAAsB;;;;qBCNtB,mCAAmC;EAC/C;;;;UCFgB;EAChB;EACA;EACA;EACA,kBAAkB,QAAQ,QAAQ;EAClC;;qBAGY,8BAA8B;WACjC,OAAI,mBAAA;UACL;UACA;UACA;UACA;EAKR,YAAY,QAAQ;;;;;SAiBP,qBACZ,2BACE,QAAQ;EAoBL,WAAW;EA6CX,SAAS;EAWf;UAIQ;;;;MASJ,eAAe,QAAQ;;;;MAOvB;;;;MAOA;;;;UC1IY;EAChB,iBAAiB,QAAQ,QAAQ;;qBAGrB,kBAAkB,iBAAiB,4CACpC,eAAe;UAGjB;UACA;EAFT,YACS,YAAY,oBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,kBAAkB;EAOjD,QAAQ,UAAU,aAAa;EA+C/B,SAAS;;;;UCxEC;EAChB;EACA,eAAe,QAAQ,QAAQ;EAC/B,iBAAiB,QAAQ,QAAQ;EACjC;;qBAGY,mBACZ,iBAAiB,4CACL,gBAAgB;UAGnB;UACA;EAFT,YACS,YAAY,oBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,mBAAmB;EAkBlD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/rabbitmq/RabbitMQConnection.ts","../../src/rabbitmq/errors.ts","../../src/rabbitmq/RabbitMQPublisher.ts","../../src/rabbitmq/RabbitMQSubscriber.ts","../../src/rabbitmq/driver.ts"],"sourcesContent":["import amqplib from 'amqplib';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface RabbitMQConnectionConfig {\n\turl: string;\n\texchange?: string;\n\texchangeType?: 'topic' | 'direct' | 'fanout' | 'headers';\n\texchangeOptions?: amqplib.Options.AssertExchange;\n\ttimeout?: number; // Connection timeout in milliseconds (default: 5000)\n}\n\nexport class RabbitMQConnection implements EventConnection {\n\treadonly type = EventPublisherType.RabbitMQ;\n\tprivate connection?: amqplib.ChannelModel;\n\tprivate channel?: amqplib.Channel;\n\tprivate connecting?: Promise<void>;\n\tprivate config: Required<\n\t\tPick<RabbitMQConnectionConfig, 'exchange' | 'exchangeType' | 'timeout'>\n\t> &\n\t\tRabbitMQConnectionConfig;\n\n\tconstructor(config: RabbitMQConnectionConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\texchange: config.exchange || 'geekmidas.events',\n\t\t\texchangeType: config.exchangeType || 'topic',\n\t\t\ttimeout: config.timeout ?? 5000,\n\t\t\texchangeOptions: {\n\t\t\t\tdurable: true,\n\t\t\t\t...config.exchangeOptions,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Create a RabbitMQConnection from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&timeout=5000\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<RabbitMQConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\t// Extract connection URL without query params\n\t\tconst baseUrl = `amqp://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst timeoutParam = params.get('timeout');\n\t\tconst config: RabbitMQConnectionConfig = {\n\t\t\turl: baseUrl,\n\t\t\texchange: params.get('exchange') || 'geekmidas.events',\n\t\t\texchangeType: (params.get('type') as any) || 'topic',\n\t\t\ttimeout: timeoutParam ? Number.parseInt(timeoutParam, 10) : undefined,\n\t\t};\n\n\t\tconst connection = new RabbitMQConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.channel) return;\n\n\t\t// Prevent multiple simultaneous connection attempts\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst connection = await amqplib.connect(this.config.url, {\n\t\t\t\t\ttimeout: this.config.timeout,\n\t\t\t\t});\n\t\t\t\tconst channel = await connection.createChannel();\n\n\t\t\t\t// Assert the exchange exists\n\t\t\t\tawait channel.assertExchange(\n\t\t\t\t\tthis.config.exchange!,\n\t\t\t\t\tthis.config.exchangeType!,\n\t\t\t\t\tthis.config.exchangeOptions,\n\t\t\t\t);\n\n\t\t\t\t// Handle connection errors\n\t\t\t\tconnection.on('error', (_err: Error) => {\n\t\t\t\t\tthis.cleanup();\n\t\t\t\t});\n\n\t\t\t\tconnection.on('close', () => {\n\t\t\t\t\tthis.cleanup();\n\t\t\t\t});\n\n\t\t\t\t// Only set after successful setup\n\t\t\t\tthis.connection = connection;\n\t\t\t\tthis.channel = channel;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.channel?.close();\n\t\t\tawait this.connection?.close();\n\t\t} catch (_error) {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.channel;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.channel = undefined;\n\t\tthis.connection = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying channel for publishing/subscribing\n\t */\n\tget amqpChannel(): amqplib.Channel | undefined {\n\t\treturn this.channel;\n\t}\n\n\t/**\n\t * Get the exchange name for this connection\n\t */\n\tget exchangeName(): string {\n\t\treturn this.config.exchange;\n\t}\n\n\t/**\n\t * Get the exchange type for this connection\n\t */\n\tget exchangeType(): string {\n\t\treturn this.config.exchangeType;\n\t}\n}\n","// Beside the adapter but apart from its connection module, which imports\n// the broker's client: the publisher and subscriber load that lazily, and\n// importing an error class from it would load it eagerly.\n\n/** The connection opened but has no channel to publish or consume on. */\nexport class RabbitMQChannelUnavailable extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'RabbitMQ connected without a channel. Check the broker is reachable and the connection string names a vhost the user can open channels on.',\n\t\t);\n\t\tthis.name = 'RabbitMQChannelUnavailable';\n\t}\n}\n","import type amqplib from 'amqplib';\nimport { publishTraced } from '../telemetry';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport { RabbitMQChannelUnavailable } from './errors';\nimport type { RabbitMQConnection } from './RabbitMQConnection';\n\nexport interface RabbitMQPublisherOptions {\n\tpublishOptions?: amqplib.Options.Publish;\n}\n\nexport class RabbitMQPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: RabbitMQConnection,\n\t\tprivate options: RabbitMQPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create a RabbitMQPublisher from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&timeout=5000\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<RabbitMQPublisher<TMessage>> {\n\t\tconst { RabbitMQConnection } = await import('./RabbitMQConnection');\n\t\tconst connection =\n\t\t\tawait RabbitMQConnection.fromConnectionString(connectionString);\n\t\treturn new RabbitMQPublisher<TMessage>(connection);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst channel = this.connection.amqpChannel;\n\t\tif (!channel) {\n\t\t\tthrow new RabbitMQChannelUnavailable();\n\t\t}\n\n\t\tconst exchange = this.connection.exchangeName;\n\n\t\tawait publishTraced(\n\t\t\tmessages,\n\t\t\t(message) => ({\n\t\t\t\tsystem: 'rabbitmq',\n\t\t\t\tdestination: exchange,\n\t\t\t\ttype: message.type,\n\t\t\t}),\n\t\t\tasync (carriers) => {\n\t\t\t\tfor (const [i, message] of messages.entries()) {\n\t\t\t\t\tconst content = Buffer.from(JSON.stringify(message.payload));\n\t\t\t\t\tconst { headers, ...publishOptions } =\n\t\t\t\t\t\tthis.options.publishOptions ?? {};\n\n\t\t\t\t\t// Use message type as routing key for topic exchanges; the trace\n\t\t\t\t\t// context goes in the message's headers.\n\t\t\t\t\tconst published = channel.publish(exchange, message.type, content, {\n\t\t\t\t\t\tcontentType: 'application/json',\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\ttype: message.type,\n\t\t\t\t\t\tpersistent: true,\n\t\t\t\t\t\t...publishOptions,\n\t\t\t\t\t\t...((headers || carriers[i]) && {\n\t\t\t\t\t\t\theaders: { ...headers, ...carriers[i] },\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\t// Handle backpressure\n\t\t\t\t\tif (!published) {\n\t\t\t\t\t\tawait new Promise((resolve) => channel.once('drain', resolve));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t\t// Connection should be closed by whoever created it\n\t}\n}\n","import type amqplib from 'amqplib';\nimport { carrierFromAttributes, consumeTraced } from '../telemetry';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport { RabbitMQChannelUnavailable } from './errors';\nimport type { RabbitMQConnection } from './RabbitMQConnection';\n\nexport interface RabbitMQSubscriberOptions {\n\tqueueName?: string; // If not provided, a unique queue will be generated\n\tqueueOptions?: amqplib.Options.AssertQueue;\n\tconsumeOptions?: amqplib.Options.Consume;\n\tprefetch?: number; // Number of messages to prefetch (default: 1)\n}\n\nexport class RabbitMQSubscriber<\n\tTMessage extends PublishableMessage<string, any>,\n> implements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: RabbitMQConnection,\n\t\tprivate options: RabbitMQSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a RabbitMQSubscriber from a connection string\n\t * Format: rabbitmq://user:pass@host:port/vhost?exchange=name&type=topic&queueName=myqueue&prefetch=10\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<RabbitMQSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { RabbitMQConnection } = await import('./RabbitMQConnection');\n\t\tconst connection =\n\t\t\tawait RabbitMQConnection.fromConnectionString(connectionString);\n\n\t\tconst options: RabbitMQSubscriberOptions = {\n\t\t\tqueueName: params.get('queueName') || undefined,\n\t\t\tprefetch: params.get('prefetch')\n\t\t\t\t? Number.parseInt(params.get('prefetch')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new RabbitMQSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst channel = this.connection.amqpChannel;\n\t\tif (!channel) {\n\t\t\tthrow new RabbitMQChannelUnavailable();\n\t\t}\n\n\t\tconst exchange = this.connection.exchangeName;\n\n\t\t// Set prefetch if specified\n\t\tif (this.options.prefetch) {\n\t\t\tawait channel.prefetch(this.options.prefetch);\n\t\t}\n\n\t\t// Assert queue\n\t\tconst queueName = this.options.queueName || '';\n\t\tconst queueOptions: amqplib.Options.AssertQueue = {\n\t\t\tdurable: true,\n\t\t\t...this.options.queueOptions,\n\t\t};\n\n\t\tconst { queue } = await channel.assertQueue(queueName, queueOptions);\n\n\t\t// Bind queue to exchange for each message type\n\t\tfor (const messageType of messages) {\n\t\t\tawait channel.bindQueue(queue, exchange, messageType);\n\t\t}\n\n\t\t// Consume messages\n\t\tawait channel.consume(\n\t\t\tqueue,\n\t\t\tasync (msg) => {\n\t\t\t\tif (!msg) return;\n\n\t\t\t\ttry {\n\t\t\t\t\t// Parse message payload\n\t\t\t\t\tconst content = msg.content.toString();\n\t\t\t\t\tconst payload = JSON.parse(content);\n\n\t\t\t\t\t// Get message type from properties\n\t\t\t\t\tconst messageType = msg.properties.type;\n\n\t\t\t\t\t// Reconstruct full message\n\t\t\t\t\tconst fullMessage: TMessage = {\n\t\t\t\t\t\ttype: messageType,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t} as TMessage;\n\n\t\t\t\t\t// Call listener, as a child of the publisher's span\n\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsystem: 'rabbitmq',\n\t\t\t\t\t\t\tdestination: queue,\n\t\t\t\t\t\t\ttype: messageType,\n\t\t\t\t\t\t\tmessageId: msg.properties.messageId,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcarrierFromAttributes(msg.properties.headers),\n\t\t\t\t\t\t() => listener(fullMessage),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Ack message\n\t\t\t\t\tchannel.ack(msg);\n\t\t\t\t} catch (_error) {\n\t\t\t\t\tchannel.nack(msg, false, true);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.options.consumeOptions,\n\t\t);\n\t}\n}\n","import type { EventsDriver } from '../registry';\nimport { EventPublisherType } from '../types';\nimport { RabbitMQConnection } from './RabbitMQConnection';\nimport { RabbitMQPublisher } from './RabbitMQPublisher';\nimport { RabbitMQSubscriber } from './RabbitMQSubscriber';\n\n/**\n * `rabbitmq://` — an AMQP exchange. Register it with\n * `registerEventsDriver(rabbitmqEventsDriver)`; this subpath is the only one\n * that imports `amqplib`.\n */\nexport const rabbitmqEventsDriver: EventsDriver = {\n\tscheme: EventPublisherType.RabbitMQ,\n\tconnect: (url) => RabbitMQConnection.fromConnectionString(url),\n\tpublisher: (url) => RabbitMQPublisher.fromConnectionString(url),\n\tpublisherFor: (connection) =>\n\t\tnew RabbitMQPublisher(connection as RabbitMQConnection),\n\tsubscriber: (url) => RabbitMQSubscriber.fromConnectionString(url),\n\tsubscriberFor: (connection) =>\n\t\tnew RabbitMQSubscriber(connection as RabbitMQConnection),\n};\n"],"mappings":";;;;;AAYA,IAAa,qBAAb,MAAa,mBAA8C;CAC1D,OAAS;CACT;CACA;CACA;CACA;CAKA,YAAY,QAAkC;EAC7C,KAAK,SAAS;GACb,GAAG;GACH,UAAU,OAAO,YAAY;GAC7B,cAAc,OAAO,gBAAgB;GACrC,SAAS,OAAO,WAAW;GAC3B,iBAAiB;IAChB,SAAS;IACT,GAAG,OAAO;GACX;EACD;CACD;;;;;CAMA,aAAa,qBACZ,kBAC8B;EAC9B,MAAM,MAAM,IAAI,IAAI,gBAAgB;EACpC,MAAM,SAAS,IAAI;EAGnB,MAAM,UAAU,UAAU,IAAI,WAAW,GAAG,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,KAAK,IAAI,OAAO,IAAI;EAElG,MAAM,eAAe,OAAO,IAAI,SAAS;EACzC,MAAM,SAAmC;GACxC,KAAK;GACL,UAAU,OAAO,IAAI,UAAU,KAAK;GACpC,cAAe,OAAO,IAAI,MAAM,KAAa;GAC7C,SAAS,eAAe,OAAO,SAAS,cAAc,EAAE,IAAI,KAAA;EAC7D;EAEA,MAAM,aAAa,IAAI,mBAAmB,MAAM;EAChD,MAAM,WAAW,QAAQ;EACzB,OAAO;CACR;CAEA,MAAM,UAAyB;EAC9B,IAAI,KAAK,SAAS;EAGlB,IAAI,KAAK,YAAY;GACpB,MAAM,KAAK;GACX;EACD;EAEA,KAAK,cAAc,YAAY;GAC9B,IAAI;IACH,MAAM,aAAa,MAAM,QAAQ,QAAQ,KAAK,OAAO,KAAK,EACzD,SAAS,KAAK,OAAO,QACtB,CAAC;IACD,MAAM,UAAU,MAAM,WAAW,cAAc;IAG/C,MAAM,QAAQ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,aAAa,QAAQ,mBAAmB,qBAAqB,GAAG;CAChE,gBAAgB,eACf,IAAI,mBAAmB,UAAgC;AACzD"}
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { InferStandardSchema } from "@geekmidas/schema";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
3
|
-
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
4
|
-
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
5
|
-
/** The Standard properties. */
|
|
6
|
-
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
7
|
-
}
|
|
8
|
-
declare namespace StandardTypedV1 {
|
|
9
|
-
/** The Standard Typed properties interface. */
|
|
10
|
-
interface Props<Input = unknown, Output = Input> {
|
|
11
|
-
/** The version number of the standard. */
|
|
12
|
-
readonly version: 1;
|
|
13
|
-
/** The vendor name of the schema library. */
|
|
14
|
-
readonly vendor: string;
|
|
15
|
-
/** Inferred types associated with the schema. */
|
|
16
|
-
readonly types?: Types<Input, Output> | undefined;
|
|
17
|
-
}
|
|
18
|
-
/** The Standard Typed types interface. */
|
|
19
|
-
interface Types<Input = unknown, Output = Input> {
|
|
20
|
-
/** The input type of the schema. */
|
|
21
|
-
readonly input: Input;
|
|
22
|
-
/** The output type of the schema. */
|
|
23
|
-
readonly output: Output;
|
|
24
|
-
}
|
|
25
|
-
/** Infers the input type of a Standard Typed. */
|
|
26
|
-
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
27
|
-
/** Infers the output type of a Standard Typed. */
|
|
28
|
-
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
29
|
-
}
|
|
30
|
-
/** The Standard Schema interface. */
|
|
31
|
-
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
32
|
-
/** The Standard Schema properties. */
|
|
33
|
-
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
34
|
-
}
|
|
35
|
-
declare namespace StandardSchemaV1 {
|
|
36
|
-
/** The Standard Schema properties interface. */
|
|
37
|
-
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
38
|
-
/** Validates unknown input values. */
|
|
39
|
-
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
40
|
-
}
|
|
41
|
-
/** The result interface of the validate function. */
|
|
42
|
-
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
43
|
-
/** The result interface if validation succeeds. */
|
|
44
|
-
interface SuccessResult<Output> {
|
|
45
|
-
/** The typed output value. */
|
|
46
|
-
readonly value: Output;
|
|
47
|
-
/** A falsy value for `issues` indicates success. */
|
|
48
|
-
readonly issues?: undefined;
|
|
49
|
-
}
|
|
50
|
-
interface Options {
|
|
51
|
-
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
52
|
-
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
53
|
-
}
|
|
54
|
-
/** The result interface if validation fails. */
|
|
55
|
-
interface FailureResult {
|
|
56
|
-
/** The issues of failed validation. */
|
|
57
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
58
|
-
}
|
|
59
|
-
/** The issue interface of the failure output. */
|
|
60
|
-
interface Issue {
|
|
61
|
-
/** The error message of the issue. */
|
|
62
|
-
readonly message: string;
|
|
63
|
-
/** The path of the issue, if any. */
|
|
64
|
-
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
65
|
-
}
|
|
66
|
-
/** The path segment interface of the issue. */
|
|
67
|
-
interface PathSegment {
|
|
68
|
-
/** The key representing a path segment. */
|
|
69
|
-
readonly key: PropertyKey;
|
|
70
|
-
}
|
|
71
|
-
/** The Standard types interface. */
|
|
72
|
-
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
73
|
-
/** Infers the input type of a Standard. */
|
|
74
|
-
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
75
|
-
/** Infers the output type of a Standard. */
|
|
76
|
-
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
77
|
-
}
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/types.d.ts
|
|
80
|
-
/**
|
|
81
|
-
* Represents a publishable event message with a type and payload.
|
|
82
|
-
*
|
|
83
|
-
* @template TType - The event type/name (e.g., 'user.created')
|
|
84
|
-
* @template TPayload - The event payload data
|
|
85
|
-
*/
|
|
86
|
-
type PublishableMessage<TType extends string, TPayload> = {
|
|
87
|
-
type: TType;
|
|
88
|
-
payload: TPayload;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Event publisher/subscriber types
|
|
92
|
-
*/
|
|
93
|
-
declare enum EventPublisherType {
|
|
94
|
-
Basic = "basic",
|
|
95
|
-
EventBridge = "eventbridge",
|
|
96
|
-
SQS = "sqs",
|
|
97
|
-
SNS = "sns",
|
|
98
|
-
Kafka = "kafka",
|
|
99
|
-
RabbitMQ = "rabbitmq",
|
|
100
|
-
PgBoss = "pgboss"
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* A connection string or connection whose transport nothing here implements —
|
|
104
|
-
* a typo'd scheme, or one of the listed-but-unbuilt ones (EventBridge, Kafka).
|
|
105
|
-
*/
|
|
106
|
-
declare class UnsupportedEventTransport extends Error {
|
|
107
|
-
readonly transport: string;
|
|
108
|
-
readonly role: 'publisher' | 'subscriber' | 'connection';
|
|
109
|
-
constructor(transport: string, role: 'publisher' | 'subscriber' | 'connection');
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Base interface for event connections
|
|
113
|
-
* Connections manage the underlying transport (RabbitMQ channel, SQS client, etc.)
|
|
114
|
-
*/
|
|
115
|
-
interface EventConnection {
|
|
116
|
-
readonly type: EventPublisherType;
|
|
117
|
-
connect(): Promise<void>;
|
|
118
|
-
close(): Promise<void>;
|
|
119
|
-
isConnected(): boolean;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Interface for event publishers that handle the actual publishing of events.
|
|
123
|
-
* Implementations can send to EventBridge, SQS, Kafka, or any other event system.
|
|
124
|
-
*
|
|
125
|
-
* @template TMessage - The union type of all publishable messages
|
|
126
|
-
*/
|
|
127
|
-
type EventPublisher<TMessage extends PublishableMessage<string, any>> = {
|
|
128
|
-
publish: (message: TMessage[]) => Promise<void>;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Interface for event subscribers that handle receiving and processing events.
|
|
132
|
-
*
|
|
133
|
-
* @template TMessage - The union type of all publishable messages
|
|
134
|
-
*/
|
|
135
|
-
type EventSubscriber<TMessage extends PublishableMessage<string, any>> = {
|
|
136
|
-
subscribe: (messages: TMessage['type'][], listener: (payload: TMessage) => Promise<void>) => Promise<void>;
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* Utility type to extract the message from EventPublisher
|
|
140
|
-
*/
|
|
141
|
-
type ExtractPublisherMessage<T> = T extends EventPublisher<infer M> ? M : never;
|
|
142
|
-
type MappedEvent<T extends EventPublisher<any> | undefined, OutSchema extends StandardSchemaV1 | undefined = undefined> = {
|
|
143
|
-
type: ExtractPublisherMessage<T>['type'];
|
|
144
|
-
payload: (ctx: InferStandardSchema<OutSchema>) => ExtractPublisherMessage<T>['payload'];
|
|
145
|
-
when?: (ctx: InferStandardSchema<OutSchema>) => boolean;
|
|
146
|
-
};
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/Publisher.d.ts
|
|
149
|
-
/** How a publisher is used, beyond the address it reaches. */
|
|
150
|
-
interface PublisherOptions {
|
|
151
|
-
/**
|
|
152
|
-
* The topic this publisher fans out to. SNS and RabbitMQ name the topic in
|
|
153
|
-
* their address already; pg-boss has one address for every topic and queue,
|
|
154
|
-
* so it is told here that a message goes to every subscriber rather than to
|
|
155
|
-
* one queue.
|
|
156
|
-
*/
|
|
157
|
-
topic?: string;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Publishers for a connection string or a connection, through whichever
|
|
161
|
-
* driver is registered for its scheme — see `registerEventsDriver`.
|
|
162
|
-
*/
|
|
163
|
-
declare class Publisher {
|
|
164
|
-
/**
|
|
165
|
-
* Create a publisher from a connection string
|
|
166
|
-
* This creates both a connection and a publisher
|
|
167
|
-
*
|
|
168
|
-
* @throws {UnregisteredEventsScheme} when the broker's driver is not
|
|
169
|
-
* registered.
|
|
170
|
-
*/
|
|
171
|
-
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionStr: EventPublisherConnectionString, options?: PublisherOptions): Promise<EventPublisher<TMessage>>;
|
|
172
|
-
/**
|
|
173
|
-
* Create a publisher from an existing connection
|
|
174
|
-
* This allows sharing connections between publishers and subscribers
|
|
175
|
-
*/
|
|
176
|
-
static fromConnection<TMessage extends PublishableMessage<string, any>>(connection: EventConnection, options?: PublisherOptions): Promise<EventPublisher<TMessage>>;
|
|
177
|
-
}
|
|
178
|
-
type EventPublisherConnectionString = `${EventPublisherType}://${string}`;
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/registry.d.ts
|
|
181
|
-
type AnyMessage = PublishableMessage<string, any>;
|
|
182
|
-
/** How a subscriber built from a connection is used, beyond its address. */
|
|
183
|
-
interface SubscriberOptions {
|
|
184
|
-
/**
|
|
185
|
-
* The topic subscribed to. pg-boss needs it, with {@link subscription}, to
|
|
186
|
-
* give each subscriber a queue of its own; the other brokers carry the topic
|
|
187
|
-
* in their address and ignore it.
|
|
188
|
-
*/
|
|
189
|
-
topic?: string;
|
|
190
|
-
/** The subscriber's name — its own queue on pg-boss. */
|
|
191
|
-
subscription?: string;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* One broker: the connections, publishers and subscribers for its scheme.
|
|
195
|
-
*
|
|
196
|
-
* A driver owns parsing — the shape of an `sns://` string is SNS's business —
|
|
197
|
-
* and is the only module that imports its broker's client library.
|
|
198
|
-
*/
|
|
199
|
-
interface EventsDriver {
|
|
200
|
-
/**
|
|
201
|
-
* The scheme this driver handles, without the colon — `'pgboss'`, `'sns'`.
|
|
202
|
-
* It is also the `type` of every connection the driver builds, which is how
|
|
203
|
-
* a connection finds its way back here.
|
|
204
|
-
*/
|
|
205
|
-
readonly scheme: `${EventPublisherType}`;
|
|
206
|
-
/** A connection, connected, for a connection string. */
|
|
207
|
-
connect(connectionString: string): Promise<EventConnection>;
|
|
208
|
-
/** A publisher, with a connection of its own, for a connection string. */
|
|
209
|
-
publisher<TMessage extends AnyMessage>(connectionString: string, options: PublisherOptions): Promise<EventPublisher<TMessage>>;
|
|
210
|
-
/** A publisher on a connection this driver built. */
|
|
211
|
-
publisherFor<TMessage extends AnyMessage>(connection: EventConnection, options: PublisherOptions): EventPublisher<TMessage>;
|
|
212
|
-
/** A subscriber, with a connection of its own, for a connection string. */
|
|
213
|
-
subscriber<TMessage extends AnyMessage>(connectionString: string): Promise<EventSubscriber<TMessage>>;
|
|
214
|
-
/** A subscriber on a connection this driver built. */
|
|
215
|
-
subscriberFor<TMessage extends AnyMessage>(connection: EventConnection, options: SubscriberOptions): EventSubscriber<TMessage>;
|
|
216
|
-
}
|
|
217
|
-
/** Make a driver available to `Publisher`, `Subscriber` and friends. Idempotent. */
|
|
218
|
-
declare function registerEventsDriver(driver: EventsDriver): void;
|
|
219
|
-
/** Which schemes are currently registered — the useful half of a failure. */
|
|
220
|
-
declare function registeredEventsSchemes(): string[];
|
|
221
|
-
/**
|
|
222
|
-
* The driver for a scheme — `'pgboss'`, `'pgboss:'`, or a whole connection
|
|
223
|
-
* string, whichever the caller has.
|
|
224
|
-
*
|
|
225
|
-
* @throws {UnregisteredEventsScheme} when the scheme is a broker this package
|
|
226
|
-
* implements but nothing registered its driver.
|
|
227
|
-
* @throws {UnsupportedEventTransport} when no broker here has that scheme.
|
|
228
|
-
*/
|
|
229
|
-
declare function eventsDriverFor(scheme: string, role?: 'publisher' | 'subscriber' | 'connection'): EventsDriver;
|
|
230
|
-
/**
|
|
231
|
-
* A connection string for a broker whose driver nothing registered.
|
|
232
|
-
*
|
|
233
|
-
* The broker exists — this is not a typo'd scheme — but the process was never
|
|
234
|
-
* told about it. Usually a script building its own publisher, or a build that
|
|
235
|
-
* registered the drivers for a different target than the one that composed
|
|
236
|
-
* the connection string.
|
|
237
|
-
*/
|
|
238
|
-
declare class UnregisteredEventsScheme extends Error {
|
|
239
|
-
/** The scheme with no driver, without the colon — `'pgboss'`. */
|
|
240
|
-
readonly scheme: string;
|
|
241
|
-
/** What is registered, so the caller can see what was chosen instead. */
|
|
242
|
-
readonly registered: readonly string[];
|
|
243
|
-
/** The subpath that exports the missing driver. */
|
|
244
|
-
readonly subpath: string;
|
|
245
|
-
/** The driver's export name. */
|
|
246
|
-
readonly driver: string;
|
|
247
|
-
constructor(
|
|
248
|
-
/** The scheme with no driver, without the colon — `'pgboss'`. */
|
|
249
|
-
scheme: string,
|
|
250
|
-
/** What is registered, so the caller can see what was chosen instead. */
|
|
251
|
-
registered: readonly string[]);
|
|
252
|
-
}
|
|
253
|
-
//#endregion
|
|
254
|
-
export { UnsupportedEventTransport as _, registerEventsDriver as a, Publisher as c, EventPublisher as d, EventPublisherType as f, PublishableMessage as g, MappedEvent as h, eventsDriverFor as i, PublisherOptions as l, ExtractPublisherMessage as m, SubscriberOptions as n, registeredEventsSchemes as o, EventSubscriber as p, UnregisteredEventsScheme as r, EventPublisherConnectionString as s, EventsDriver as t, EventConnection as u };
|
|
255
|
-
//# sourceMappingURL=registry-DIx25Q5s.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry-DIx25Q5s.d.cts","names":[],"sources":["../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts","../src/types.ts","../src/Publisher.ts","../src/registry.ts"],"x_google_ignoreList":[0],"mappings":";;;UACU,gBAAgB,iBAAiB,SAAS;;WAEvC,aAAa,gBAAgB,MAAM,OAAO;;k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