@geekmidas/events 1.1.6 → 10.0.0-alpha.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/dist/{PgBossConnection-B71ssr72.cjs → PgBossConnection-23soZ_aM.cjs} +2 -2
- package/dist/{PgBossConnection-B71ssr72.cjs.map → PgBossConnection-23soZ_aM.cjs.map} +1 -1
- package/dist/PgBossConnection-CCXhoNzb.cjs +4 -0
- package/dist/{PgBossConnection-Bj_Wo1lQ.mjs → PgBossConnection-DvNbd4Zk.mjs} +2 -2
- package/dist/{PgBossConnection-Bj_Wo1lQ.mjs.map → PgBossConnection-DvNbd4Zk.mjs.map} +1 -1
- package/dist/PgBossConnection-_gdM40JB.mjs +4 -0
- package/dist/{RabbitMQConnection-DddqvI3I.cjs → RabbitMQConnection-BKEdCUro.cjs} +2 -2
- package/dist/{RabbitMQConnection-DddqvI3I.cjs.map → RabbitMQConnection-BKEdCUro.cjs.map} +1 -1
- package/dist/RabbitMQConnection-CCOqDDnb.cjs +4 -0
- package/dist/RabbitMQConnection-DJEyM-Bu.mjs +4 -0
- package/dist/{RabbitMQConnection-Cg7mp8u-.mjs → RabbitMQConnection-DJgUPc19.mjs} +2 -2
- package/dist/{RabbitMQConnection-Cg7mp8u-.mjs.map → RabbitMQConnection-DJgUPc19.mjs.map} +1 -1
- package/dist/{SNSConnection-DFehUWG1.cjs → SNSConnection-B2K86hpz.cjs} +7 -8
- package/dist/SNSConnection-B2K86hpz.cjs.map +1 -0
- package/dist/SNSConnection-BVo84FeW.mjs +5 -0
- package/dist/SNSConnection-DIHRjrQF.cjs +5 -0
- package/dist/{SNSConnection-CpMKzgx2.mjs → SNSConnection-v9jjF99w.mjs} +7 -8
- package/dist/SNSConnection-v9jjF99w.mjs.map +1 -0
- package/dist/{SQSConnection-BqZZnAZI.mjs → SQSConnection-4tBMkVZE.mjs} +7 -8
- package/dist/SQSConnection-4tBMkVZE.mjs.map +1 -0
- package/dist/SQSConnection-BBLAvF-1.cjs +5 -0
- package/dist/{SQSConnection-yge9cB_f.cjs → SQSConnection-BaC7rGhI.cjs} +7 -8
- package/dist/SQSConnection-BaC7rGhI.cjs.map +1 -0
- package/dist/SQSConnection-DbavOq8_.mjs +5 -0
- package/dist/{SQSSubscriber-CVGhZ8Nr.mjs → SQSSubscriber-BMWZ3s5q.mjs} +1 -1
- package/dist/{SQSSubscriber-CVGhZ8Nr.mjs.map → SQSSubscriber-BMWZ3s5q.mjs.map} +1 -1
- package/dist/{SQSSubscriber-B4sRXVl6.cjs → SQSSubscriber-YXPlg2rm.cjs} +2 -2
- package/dist/{SQSSubscriber-B4sRXVl6.cjs.map → SQSSubscriber-YXPlg2rm.cjs.map} +1 -1
- package/dist/basic/index.cjs +71 -8
- package/dist/basic/index.cjs.map +1 -0
- package/dist/basic/index.d.cts +44 -5
- package/dist/basic/index.d.cts.map +1 -0
- package/dist/basic/index.d.mts +44 -5
- package/dist/basic/index.d.mts.map +1 -0
- package/dist/basic/index.mjs +67 -5
- package/dist/basic/index.mjs.map +1 -0
- package/dist/chunk-B9dir_RE.mjs +11 -0
- package/dist/{chunk-CUT6urMc.cjs → chunk-CsX-DzYB.cjs} +12 -0
- package/dist/index.cjs +189 -6
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +46 -5
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +46 -5
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +188 -5
- package/dist/index.mjs.map +1 -0
- package/dist/pgboss/index.cjs +81 -5
- package/dist/pgboss/index.cjs.map +1 -0
- package/dist/pgboss/index.d.cts +65 -5
- package/dist/pgboss/index.d.cts.map +1 -0
- package/dist/pgboss/index.d.mts +65 -5
- package/dist/pgboss/index.d.mts.map +1 -0
- package/dist/pgboss/index.mjs +81 -5
- package/dist/pgboss/index.mjs.map +1 -0
- package/dist/rabbitmq/index.cjs +95 -5
- package/dist/rabbitmq/index.cjs.map +1 -0
- package/dist/rabbitmq/index.d.cts +83 -5
- package/dist/rabbitmq/index.d.cts.map +1 -0
- package/dist/rabbitmq/index.d.mts +83 -5
- package/dist/rabbitmq/index.d.mts.map +1 -0
- package/dist/rabbitmq/index.mjs +95 -5
- package/dist/rabbitmq/index.mjs.map +1 -0
- package/dist/sns/index.cjs +186 -7
- package/dist/sns/index.cjs.map +1 -0
- package/dist/sns/index.d.cts +109 -5
- package/dist/sns/index.d.cts.map +1 -0
- package/dist/sns/index.d.mts +109 -5
- package/dist/sns/index.d.mts.map +1 -0
- package/dist/sns/index.mjs +179 -7
- package/dist/sns/index.mjs.map +1 -0
- package/dist/sns/snsUrl.cjs +7 -0
- package/dist/sns/snsUrl.d.cts +2 -0
- package/dist/sns/snsUrl.d.mts +2 -0
- package/dist/sns/snsUrl.mjs +3 -0
- package/dist/snsUrl-ASdc0D1v.d.cts +61 -0
- package/dist/snsUrl-ASdc0D1v.d.cts.map +1 -0
- package/dist/snsUrl-CifYhPAa.mjs +79 -0
- package/dist/snsUrl-CifYhPAa.mjs.map +1 -0
- package/dist/snsUrl-FRbRcwF0.d.mts +61 -0
- package/dist/snsUrl-FRbRcwF0.d.mts.map +1 -0
- package/dist/snsUrl-f2gU3CzK.cjs +114 -0
- package/dist/snsUrl-f2gU3CzK.cjs.map +1 -0
- package/dist/sqs/index.cjs +67 -5
- package/dist/sqs/index.cjs.map +1 -0
- package/dist/sqs/index.d.cts +101 -5
- package/dist/sqs/index.d.cts.map +1 -0
- package/dist/sqs/index.d.mts +101 -5
- package/dist/sqs/index.d.mts.map +1 -0
- package/dist/sqs/index.mjs +60 -5
- package/dist/sqs/index.mjs.map +1 -0
- package/dist/sqs/sqsUrl.cjs +7 -0
- package/dist/sqs/sqsUrl.d.cts +2 -0
- package/dist/sqs/sqsUrl.d.mts +2 -0
- package/dist/sqs/sqsUrl.mjs +3 -0
- package/dist/sqsUrl-BV6zS-mi.d.mts +60 -0
- package/dist/sqsUrl-BV6zS-mi.d.mts.map +1 -0
- package/dist/sqsUrl-CbAsBFHI.mjs +80 -0
- package/dist/sqsUrl-CbAsBFHI.mjs.map +1 -0
- package/dist/sqsUrl-CdisN3GU.cjs +115 -0
- package/dist/sqsUrl-CdisN3GU.cjs.map +1 -0
- package/dist/sqsUrl-DZDPHxIk.d.cts +60 -0
- package/dist/sqsUrl-DZDPHxIk.d.cts.map +1 -0
- package/dist/{types-Dh9Jyinx.d.mts → types-BmixGrOD.d.cts} +1 -1
- package/dist/{types-Dh9Jyinx.d.mts.map → types-BmixGrOD.d.cts.map} +1 -1
- package/dist/{types-BrdcSEnd.mjs → types-CYDt-2RQ.mjs} +1 -1
- package/dist/{types-BrdcSEnd.mjs.map → types-CYDt-2RQ.mjs.map} +1 -1
- package/dist/{types-Dj23od3e.d.cts → types-DycjsYms.d.mts} +1 -1
- package/dist/{types-Dj23od3e.d.cts.map → types-DycjsYms.d.mts.map} +1 -1
- package/package.json +26 -3
- package/CHANGELOG.md +0 -88
- package/dist/BasicConnection-CQsJpx2J.d.cts +0 -27
- package/dist/BasicConnection-CQsJpx2J.d.cts.map +0 -1
- package/dist/BasicConnection-CxfNEvlb.cjs +0 -48
- package/dist/BasicConnection-CxfNEvlb.cjs.map +0 -1
- package/dist/BasicConnection-DcRelT64.d.mts +0 -27
- package/dist/BasicConnection-DcRelT64.d.mts.map +0 -1
- package/dist/BasicConnection-hl-Ogz3a.mjs +0 -42
- package/dist/BasicConnection-hl-Ogz3a.mjs.map +0 -1
- package/dist/BasicPublisher-C-hMX2Hy.d.mts +0 -14
- package/dist/BasicPublisher-C-hMX2Hy.d.mts.map +0 -1
- package/dist/BasicPublisher-CGMXg2I2.d.cts +0 -14
- package/dist/BasicPublisher-CGMXg2I2.d.cts.map +0 -1
- package/dist/BasicPublisher-CXAVKxgq.cjs +0 -20
- package/dist/BasicPublisher-CXAVKxgq.cjs.map +0 -1
- package/dist/BasicPublisher-DogbeHAH.mjs +0 -14
- package/dist/BasicPublisher-DogbeHAH.mjs.map +0 -1
- package/dist/BasicSubscriber-BJSZN22M.mjs +0 -16
- package/dist/BasicSubscriber-BJSZN22M.mjs.map +0 -1
- package/dist/BasicSubscriber-HzSJ_MbB.d.mts +0 -14
- package/dist/BasicSubscriber-HzSJ_MbB.d.mts.map +0 -1
- package/dist/BasicSubscriber-mVJRMXhZ.cjs +0 -22
- package/dist/BasicSubscriber-mVJRMXhZ.cjs.map +0 -1
- package/dist/BasicSubscriber-uW3IOyBj.d.cts +0 -14
- package/dist/BasicSubscriber-uW3IOyBj.d.cts.map +0 -1
- package/dist/EventConnection-4niMI6D8.d.mts +0 -13
- package/dist/EventConnection-4niMI6D8.d.mts.map +0 -1
- package/dist/EventConnection-BkA9FSVL.cjs +0 -45
- package/dist/EventConnection-BkA9FSVL.cjs.map +0 -1
- package/dist/EventConnection-Kr32GAzq.mjs +0 -40
- package/dist/EventConnection-Kr32GAzq.mjs.map +0 -1
- package/dist/EventConnection-dP42P87q.d.cts +0 -13
- package/dist/EventConnection-dP42P87q.d.cts.map +0 -1
- package/dist/EventConnection.cjs +0 -5
- package/dist/EventConnection.d.cts +0 -3
- package/dist/EventConnection.d.mts +0 -3
- package/dist/EventConnection.mjs +0 -4
- package/dist/PgBossConnection-DCfLGoHx.d.mts +0 -32
- package/dist/PgBossConnection-DCfLGoHx.d.mts.map +0 -1
- package/dist/PgBossConnection-oto_CAbP.d.cts +0 -32
- package/dist/PgBossConnection-oto_CAbP.d.cts.map +0 -1
- package/dist/PgBossPublisher-Bwo7qSoH.mjs +0 -35
- package/dist/PgBossPublisher-Bwo7qSoH.mjs.map +0 -1
- package/dist/PgBossPublisher-CqjigBVC.d.mts +0 -20
- package/dist/PgBossPublisher-CqjigBVC.d.mts.map +0 -1
- package/dist/PgBossPublisher-FTdYh58W.cjs +0 -41
- package/dist/PgBossPublisher-FTdYh58W.cjs.map +0 -1
- package/dist/PgBossPublisher-JIiB1zpA.d.cts +0 -20
- package/dist/PgBossPublisher-JIiB1zpA.d.cts.map +0 -1
- package/dist/PgBossSubscriber-BUiB1JKf.d.mts +0 -24
- package/dist/PgBossSubscriber-BUiB1JKf.d.mts.map +0 -1
- package/dist/PgBossSubscriber-BubVfuWm.cjs +0 -52
- package/dist/PgBossSubscriber-BubVfuWm.cjs.map +0 -1
- package/dist/PgBossSubscriber-Cozijfdj.d.cts +0 -24
- package/dist/PgBossSubscriber-Cozijfdj.d.cts.map +0 -1
- package/dist/PgBossSubscriber-DopATe80.mjs +0 -46
- package/dist/PgBossSubscriber-DopATe80.mjs.map +0 -1
- package/dist/Publisher-CKloIGh6.cjs +0 -79
- package/dist/Publisher-CKloIGh6.cjs.map +0 -1
- package/dist/Publisher-ChLTrUeP.mjs +0 -74
- package/dist/Publisher-ChLTrUeP.mjs.map +0 -1
- package/dist/Publisher-DDee6xau.d.cts +0 -21
- package/dist/Publisher-DDee6xau.d.cts.map +0 -1
- package/dist/Publisher-VHumMkrP.d.mts +0 -21
- package/dist/Publisher-VHumMkrP.d.mts.map +0 -1
- package/dist/Publisher.cjs +0 -4
- package/dist/Publisher.d.cts +0 -3
- package/dist/Publisher.d.mts +0 -3
- package/dist/Publisher.mjs +0 -4
- package/dist/RabbitMQConnection-DV9t3VYp.d.mts +0 -44
- package/dist/RabbitMQConnection-DV9t3VYp.d.mts.map +0 -1
- package/dist/RabbitMQConnection-jNME_eR7.d.cts +0 -44
- package/dist/RabbitMQConnection-jNME_eR7.d.cts.map +0 -1
- package/dist/RabbitMQPublisher-BfTRUnpy.cjs +0 -45
- package/dist/RabbitMQPublisher-BfTRUnpy.cjs.map +0 -1
- package/dist/RabbitMQPublisher-Cxm1zSkD.mjs +0 -39
- package/dist/RabbitMQPublisher-Cxm1zSkD.mjs.map +0 -1
- package/dist/RabbitMQPublisher-DKmgwqVj.d.mts +0 -25
- package/dist/RabbitMQPublisher-DKmgwqVj.d.mts.map +0 -1
- package/dist/RabbitMQPublisher-d257OHLa.d.cts +0 -25
- package/dist/RabbitMQPublisher-d257OHLa.d.cts.map +0 -1
- package/dist/RabbitMQSubscriber-BF7JGfYm.d.cts +0 -27
- package/dist/RabbitMQSubscriber-BF7JGfYm.d.cts.map +0 -1
- package/dist/RabbitMQSubscriber-CWDdmt1M.cjs +0 -62
- package/dist/RabbitMQSubscriber-CWDdmt1M.cjs.map +0 -1
- package/dist/RabbitMQSubscriber-CdbUy5mB.d.mts +0 -27
- package/dist/RabbitMQSubscriber-CdbUy5mB.d.mts.map +0 -1
- package/dist/RabbitMQSubscriber-fP8G9OlK.mjs +0 -56
- package/dist/RabbitMQSubscriber-fP8G9OlK.mjs.map +0 -1
- package/dist/SNSConnection-CG4iEwA8.d.mts +0 -41
- package/dist/SNSConnection-CG4iEwA8.d.mts.map +0 -1
- package/dist/SNSConnection-CpMKzgx2.mjs.map +0 -1
- package/dist/SNSConnection-DFehUWG1.cjs.map +0 -1
- package/dist/SNSConnection-Dol9FuxA.d.cts +0 -41
- package/dist/SNSConnection-Dol9FuxA.d.cts.map +0 -1
- package/dist/SNSPublisher-BoA8uLnw.cjs +0 -47
- package/dist/SNSPublisher-BoA8uLnw.cjs.map +0 -1
- package/dist/SNSPublisher-D50dPCEh.d.mts +0 -22
- package/dist/SNSPublisher-D50dPCEh.d.mts.map +0 -1
- package/dist/SNSPublisher-DQunY4NM.d.cts +0 -22
- package/dist/SNSPublisher-DQunY4NM.d.cts.map +0 -1
- package/dist/SNSPublisher-Drr4kHn6.mjs +0 -41
- package/dist/SNSPublisher-Drr4kHn6.mjs.map +0 -1
- package/dist/SNSSubscriber-CUgHK4W2.d.mts +0 -55
- package/dist/SNSSubscriber-CUgHK4W2.d.mts.map +0 -1
- package/dist/SNSSubscriber-DIXqA-VV.mjs +0 -139
- package/dist/SNSSubscriber-DIXqA-VV.mjs.map +0 -1
- package/dist/SNSSubscriber-ZGJjhXFQ.d.cts +0 -55
- package/dist/SNSSubscriber-ZGJjhXFQ.d.cts.map +0 -1
- package/dist/SNSSubscriber-ZIdCi6nQ.cjs +0 -145
- package/dist/SNSSubscriber-ZIdCi6nQ.cjs.map +0 -1
- package/dist/SQSConnection-BqZZnAZI.mjs.map +0 -1
- package/dist/SQSConnection-BtEkDha8.d.cts +0 -41
- package/dist/SQSConnection-BtEkDha8.d.cts.map +0 -1
- package/dist/SQSConnection-DVy43GCV.d.mts +0 -41
- package/dist/SQSConnection-DVy43GCV.d.mts.map +0 -1
- package/dist/SQSConnection-yge9cB_f.cjs.map +0 -1
- package/dist/SQSPublisher-DG9o4ME3.mjs +0 -57
- package/dist/SQSPublisher-DG9o4ME3.mjs.map +0 -1
- package/dist/SQSPublisher-Dq5353oZ.cjs +0 -63
- package/dist/SQSPublisher-Dq5353oZ.cjs.map +0 -1
- package/dist/SQSPublisher-kyl5HW3N.d.cts +0 -25
- package/dist/SQSPublisher-kyl5HW3N.d.cts.map +0 -1
- package/dist/SQSPublisher-qDE5Fp-N.d.mts +0 -25
- package/dist/SQSPublisher-qDE5Fp-N.d.mts.map +0 -1
- package/dist/SQSSubscriber-CDvaG4ij.d.cts +0 -44
- package/dist/SQSSubscriber-CDvaG4ij.d.cts.map +0 -1
- package/dist/SQSSubscriber-JfFuAAoP.d.mts +0 -44
- package/dist/SQSSubscriber-JfFuAAoP.d.mts.map +0 -1
- package/dist/Subscriber-CG_QUQZs.d.cts +0 -21
- package/dist/Subscriber-CG_QUQZs.d.cts.map +0 -1
- package/dist/Subscriber-CghW0A02.cjs +0 -88
- package/dist/Subscriber-CghW0A02.cjs.map +0 -1
- package/dist/Subscriber-DiYHmuF0.d.mts +0 -21
- package/dist/Subscriber-DiYHmuF0.d.mts.map +0 -1
- package/dist/Subscriber-bnkFtSvt.mjs +0 -83
- package/dist/Subscriber-bnkFtSvt.mjs.map +0 -1
- package/dist/Subscriber.cjs +0 -4
- package/dist/Subscriber.d.cts +0 -3
- package/dist/Subscriber.d.mts +0 -3
- package/dist/Subscriber.mjs +0 -4
- package/dist/basic/BasicConnection.cjs +0 -4
- package/dist/basic/BasicConnection.d.cts +0 -3
- package/dist/basic/BasicConnection.d.mts +0 -3
- package/dist/basic/BasicConnection.mjs +0 -4
- package/dist/basic/BasicPublisher.cjs +0 -3
- package/dist/basic/BasicPublisher.d.cts +0 -4
- package/dist/basic/BasicPublisher.d.mts +0 -4
- package/dist/basic/BasicPublisher.mjs +0 -3
- package/dist/basic/BasicSubscriber.cjs +0 -3
- package/dist/basic/BasicSubscriber.d.cts +0 -4
- package/dist/basic/BasicSubscriber.d.mts +0 -4
- package/dist/basic/BasicSubscriber.mjs +0 -3
- package/dist/pgboss/PgBossConnection.cjs +0 -4
- package/dist/pgboss/PgBossConnection.d.cts +0 -3
- package/dist/pgboss/PgBossConnection.d.mts +0 -3
- package/dist/pgboss/PgBossConnection.mjs +0 -4
- package/dist/pgboss/PgBossPublisher.cjs +0 -3
- package/dist/pgboss/PgBossPublisher.d.cts +0 -4
- package/dist/pgboss/PgBossPublisher.d.mts +0 -4
- package/dist/pgboss/PgBossPublisher.mjs +0 -3
- package/dist/pgboss/PgBossSubscriber.cjs +0 -3
- package/dist/pgboss/PgBossSubscriber.d.cts +0 -4
- package/dist/pgboss/PgBossSubscriber.d.mts +0 -4
- package/dist/pgboss/PgBossSubscriber.mjs +0 -3
- package/dist/rabbitmq/RabbitMQConnection.cjs +0 -4
- package/dist/rabbitmq/RabbitMQConnection.d.cts +0 -3
- package/dist/rabbitmq/RabbitMQConnection.d.mts +0 -3
- package/dist/rabbitmq/RabbitMQConnection.mjs +0 -4
- package/dist/rabbitmq/RabbitMQPublisher.cjs +0 -3
- package/dist/rabbitmq/RabbitMQPublisher.d.cts +0 -4
- package/dist/rabbitmq/RabbitMQPublisher.d.mts +0 -4
- package/dist/rabbitmq/RabbitMQPublisher.mjs +0 -3
- package/dist/rabbitmq/RabbitMQSubscriber.cjs +0 -3
- package/dist/rabbitmq/RabbitMQSubscriber.d.cts +0 -4
- package/dist/rabbitmq/RabbitMQSubscriber.d.mts +0 -4
- package/dist/rabbitmq/RabbitMQSubscriber.mjs +0 -3
- package/dist/sns/SNSConnection.cjs +0 -4
- package/dist/sns/SNSConnection.d.cts +0 -3
- package/dist/sns/SNSConnection.d.mts +0 -3
- package/dist/sns/SNSConnection.mjs +0 -4
- package/dist/sns/SNSPublisher.cjs +0 -3
- package/dist/sns/SNSPublisher.d.cts +0 -4
- package/dist/sns/SNSPublisher.d.mts +0 -4
- package/dist/sns/SNSPublisher.mjs +0 -3
- package/dist/sns/SNSSubscriber.cjs +0 -6
- package/dist/sns/SNSSubscriber.d.cts +0 -4
- package/dist/sns/SNSSubscriber.d.mts +0 -4
- package/dist/sns/SNSSubscriber.mjs +0 -6
- package/dist/sqs/SQSConnection.cjs +0 -4
- package/dist/sqs/SQSConnection.d.cts +0 -3
- package/dist/sqs/SQSConnection.d.mts +0 -3
- package/dist/sqs/SQSConnection.mjs +0 -4
- package/dist/sqs/SQSPublisher.cjs +0 -3
- package/dist/sqs/SQSPublisher.d.cts +0 -4
- package/dist/sqs/SQSPublisher.d.mts +0 -4
- package/dist/sqs/SQSPublisher.mjs +0 -3
- package/dist/sqs/SQSSubscriber.cjs +0 -3
- package/dist/sqs/SQSSubscriber.d.cts +0 -4
- package/dist/sqs/SQSSubscriber.d.mts +0 -4
- package/dist/sqs/SQSSubscriber.mjs +0 -3
- package/dist/types.cjs +0 -3
- package/dist/types.d.cts +0 -2
- package/dist/types.d.mts +0 -2
- package/dist/types.mjs +0 -3
- package/src/EventConnection.ts +0 -43
- package/src/Publisher.ts +0 -98
- package/src/Subscriber.ts +0 -113
- package/src/__tests__/EventConnection.spec.ts +0 -42
- package/src/__tests__/Publisher.spec.ts +0 -96
- package/src/__tests__/Subscriber.spec.ts +0 -109
- package/src/basic/BasicConnection.ts +0 -47
- package/src/basic/BasicPublisher.ts +0 -15
- package/src/basic/BasicSubscriber.ts +0 -21
- package/src/basic/__tests__/BasicSubscriber.spec.ts +0 -166
- package/src/basic/index.ts +0 -3
- package/src/index.ts +0 -25
- package/src/pgboss/PgBossConnection.ts +0 -91
- package/src/pgboss/PgBossPublisher.ts +0 -49
- package/src/pgboss/PgBossSubscriber.ts +0 -81
- package/src/pgboss/__tests__/pgboss.spec.ts +0 -196
- package/src/pgboss/__tests__/setup.ts +0 -21
- package/src/pgboss/index.ts +0 -5
- package/src/rabbitmq/RabbitMQConnection.ts +0 -148
- package/src/rabbitmq/RabbitMQPublisher.ts +0 -67
- package/src/rabbitmq/RabbitMQSubscriber.ts +0 -111
- package/src/rabbitmq/__tests__/RabbitMQPublisher.spec.ts +0 -378
- package/src/rabbitmq/__tests__/RabbitMQSubscriber.spec.ts +0 -292
- package/src/rabbitmq/index.ts +0 -6
- package/src/sns/SNSConnection.ts +0 -98
- package/src/sns/SNSPublisher.ts +0 -62
- package/src/sns/SNSSubscriber.ts +0 -218
- package/src/sns/__tests__/SNS-SQS-Integration.spec.ts +0 -389
- package/src/sns/__tests__/SNSPublisher.spec.ts +0 -449
- package/src/sns/__tests__/SNSSubscriber.spec.ts +0 -527
- package/src/sns/index.ts +0 -6
- package/src/sqs/SQSConnection.ts +0 -97
- package/src/sqs/SQSPublisher.ts +0 -105
- package/src/sqs/SQSSubscriber.ts +0 -181
- package/src/sqs/__tests__/SQSPublisher.spec.ts +0 -189
- package/src/sqs/index.ts +0 -6
- package/src/types.ts +0 -76
- package/tsconfig.json +0 -9
- package/tsdown.config.ts +0 -10
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { EventSubscriber, PublishableMessage } from "./types-Dh9Jyinx.mjs";
|
|
2
|
-
import { SNSConnection } from "./SNSConnection-CG4iEwA8.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/sns/SNSSubscriber.d.ts
|
|
5
|
-
interface SNSSubscriberOptions {
|
|
6
|
-
queueName?: string;
|
|
7
|
-
createQueue?: boolean;
|
|
8
|
-
deleteQueueOnClose?: boolean;
|
|
9
|
-
waitTimeSeconds?: number;
|
|
10
|
-
maxMessages?: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* SNS Subscriber - receives push-based messages from SNS via SQS queue
|
|
14
|
-
*
|
|
15
|
-
* Architecture:
|
|
16
|
-
* SNS Topic → (push) → SQS Queue → Subscriber
|
|
17
|
-
*
|
|
18
|
-
* This subscriber automatically:
|
|
19
|
-
* 1. Creates an SQS queue (or uses existing one)
|
|
20
|
-
* 2. Subscribes the queue to the SNS topic
|
|
21
|
-
* 3. Receives messages pushed from SNS to the queue
|
|
22
|
-
* 4. Filters messages by topic ARN and message type
|
|
23
|
-
* 5. Processes and acknowledges messages
|
|
24
|
-
*
|
|
25
|
-
* Note: While SQS long-polling is used internally to receive messages,
|
|
26
|
-
* this is an implementation detail of the SNS push delivery mechanism.
|
|
27
|
-
* Messages are pushed from SNS to SQS, and we receive those pushed messages.
|
|
28
|
-
*/
|
|
29
|
-
declare class SNSSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
|
|
30
|
-
private connection;
|
|
31
|
-
private sqsClient;
|
|
32
|
-
private queueUrl?;
|
|
33
|
-
private queueArn?;
|
|
34
|
-
private subscriptionArn?;
|
|
35
|
-
private sqsSubscriber?;
|
|
36
|
-
private options;
|
|
37
|
-
constructor(connection: SNSConnection, options?: SNSSubscriberOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Create an SNSSubscriber from a connection string
|
|
40
|
-
* Format: sns://?topicArn=...&queueName=myqueue®ion=us-east-1
|
|
41
|
-
*/
|
|
42
|
-
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string): Promise<SNSSubscriber<TMessage>>;
|
|
43
|
-
subscribe(messages: TMessage['type'][], listener: (payload: TMessage) => Promise<void>): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Stop receiving messages and clean up resources
|
|
46
|
-
*/
|
|
47
|
-
stop(): Promise<void>;
|
|
48
|
-
private setupQueue;
|
|
49
|
-
private setQueuePolicy;
|
|
50
|
-
private subscribeToTopic;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=SNSSubscriber.d.ts.map
|
|
53
|
-
//#endregion
|
|
54
|
-
export { SNSSubscriber, SNSSubscriberOptions };
|
|
55
|
-
//# sourceMappingURL=SNSSubscriber-CUgHK4W2.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SNSSubscriber-CUgHK4W2.d.mts","names":[],"sources":["../src/sns/SNSSubscriber.ts"],"sourcesContent":[],"mappings":";;;;UAaiB,oBAAA;;EAAA,WAAA,CAAA,EAAA,OAAA;EAyBJ,kBAAa,CAAA,EAAA,OAAA;EAAA,eAAA,CAAA,EAAA,MAAA;EAAA,WAAkB,CAAA,EAAA,MAAA;;;;;;;;;;;;;;AACjB;;;;;cADd,+BAA+B,4CAChC,gBAAgB;;;;;;;;0BAUN,yBACX;;;;;+CAyBQ,4DACW,QAAQ,cAAc;sBAqBxC,wCACU,aAAa,gBAC/B;;;;UA2BW"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { SQSConnection } from "./SQSConnection-BqZZnAZI.mjs";
|
|
2
|
-
import { SQSSubscriber } from "./SQSSubscriber-CVGhZ8Nr.mjs";
|
|
3
|
-
import { SubscribeCommand, UnsubscribeCommand } from "@aws-sdk/client-sns";
|
|
4
|
-
import { CreateQueueCommand, DeleteQueueCommand, GetQueueAttributesCommand, SQSClient, SetQueueAttributesCommand } from "@aws-sdk/client-sqs";
|
|
5
|
-
|
|
6
|
-
//#region src/sns/SNSSubscriber.ts
|
|
7
|
-
/**
|
|
8
|
-
* SNS Subscriber - receives push-based messages from SNS via SQS queue
|
|
9
|
-
*
|
|
10
|
-
* Architecture:
|
|
11
|
-
* SNS Topic → (push) → SQS Queue → Subscriber
|
|
12
|
-
*
|
|
13
|
-
* This subscriber automatically:
|
|
14
|
-
* 1. Creates an SQS queue (or uses existing one)
|
|
15
|
-
* 2. Subscribes the queue to the SNS topic
|
|
16
|
-
* 3. Receives messages pushed from SNS to the queue
|
|
17
|
-
* 4. Filters messages by topic ARN and message type
|
|
18
|
-
* 5. Processes and acknowledges messages
|
|
19
|
-
*
|
|
20
|
-
* Note: While SQS long-polling is used internally to receive messages,
|
|
21
|
-
* this is an implementation detail of the SNS push delivery mechanism.
|
|
22
|
-
* Messages are pushed from SNS to SQS, and we receive those pushed messages.
|
|
23
|
-
*/
|
|
24
|
-
var SNSSubscriber = class SNSSubscriber {
|
|
25
|
-
sqsClient;
|
|
26
|
-
queueUrl;
|
|
27
|
-
queueArn;
|
|
28
|
-
subscriptionArn;
|
|
29
|
-
sqsSubscriber;
|
|
30
|
-
options;
|
|
31
|
-
constructor(connection, options = {}) {
|
|
32
|
-
this.connection = connection;
|
|
33
|
-
this.options = {
|
|
34
|
-
queueName: options.queueName || `sns-sub-${Date.now()}-${Math.random().toString(36).substring(7)}`,
|
|
35
|
-
createQueue: options.createQueue ?? true,
|
|
36
|
-
deleteQueueOnClose: options.deleteQueueOnClose ?? !options.queueName,
|
|
37
|
-
waitTimeSeconds: options.waitTimeSeconds ?? 20,
|
|
38
|
-
maxMessages: options.maxMessages ?? 10
|
|
39
|
-
};
|
|
40
|
-
this.sqsClient = new SQSClient({
|
|
41
|
-
region: this.connection.config.region,
|
|
42
|
-
endpoint: this.connection.config.endpoint,
|
|
43
|
-
credentials: this.connection.config.credentials
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Create an SNSSubscriber from a connection string
|
|
48
|
-
* Format: sns://?topicArn=...&queueName=myqueue®ion=us-east-1
|
|
49
|
-
*/
|
|
50
|
-
static async fromConnectionString(connectionString) {
|
|
51
|
-
const url = new URL(connectionString);
|
|
52
|
-
const params = url.searchParams;
|
|
53
|
-
const { SNSConnection } = await import("./sns/SNSConnection.mjs");
|
|
54
|
-
const connection = await SNSConnection.fromConnectionString(connectionString);
|
|
55
|
-
const options = {
|
|
56
|
-
queueName: params.get("queueName") || void 0,
|
|
57
|
-
createQueue: params.get("createQueue") !== "false",
|
|
58
|
-
deleteQueueOnClose: params.get("deleteQueueOnClose") === "true",
|
|
59
|
-
waitTimeSeconds: params.get("waitTimeSeconds") ? Number.parseInt(params.get("waitTimeSeconds"), 10) : void 0
|
|
60
|
-
};
|
|
61
|
-
return new SNSSubscriber(connection, options);
|
|
62
|
-
}
|
|
63
|
-
async subscribe(messages, listener) {
|
|
64
|
-
await this.setupQueue();
|
|
65
|
-
await this.subscribeToTopic();
|
|
66
|
-
const sqsConnection = new SQSConnection({
|
|
67
|
-
queueUrl: this.queueUrl,
|
|
68
|
-
region: this.connection.config.region,
|
|
69
|
-
endpoint: this.connection.config.endpoint,
|
|
70
|
-
credentials: this.connection.config.credentials
|
|
71
|
-
});
|
|
72
|
-
await sqsConnection.connect();
|
|
73
|
-
this.sqsSubscriber = new SQSSubscriber(sqsConnection, {
|
|
74
|
-
waitTimeSeconds: this.options.waitTimeSeconds,
|
|
75
|
-
maxMessages: this.options.maxMessages,
|
|
76
|
-
expectedTopicArn: this.connection.topicArn
|
|
77
|
-
});
|
|
78
|
-
await this.sqsSubscriber.subscribe(messages, listener);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Stop receiving messages and clean up resources
|
|
82
|
-
*/
|
|
83
|
-
async stop() {
|
|
84
|
-
if (this.sqsSubscriber) this.sqsSubscriber.stop();
|
|
85
|
-
if (this.subscriptionArn) try {
|
|
86
|
-
const command = new UnsubscribeCommand({ SubscriptionArn: this.subscriptionArn });
|
|
87
|
-
await this.connection.snsClient.send(command);
|
|
88
|
-
} catch (_error) {}
|
|
89
|
-
if (this.queueUrl && this.options.deleteQueueOnClose) try {
|
|
90
|
-
const command = new DeleteQueueCommand({ QueueUrl: this.queueUrl });
|
|
91
|
-
await this.sqsClient.send(command);
|
|
92
|
-
} catch (_error) {}
|
|
93
|
-
this.sqsClient.destroy();
|
|
94
|
-
}
|
|
95
|
-
async setupQueue() {
|
|
96
|
-
if (this.options.createQueue) {
|
|
97
|
-
const createCommand = new CreateQueueCommand({ QueueName: this.options.queueName });
|
|
98
|
-
const response = await this.sqsClient.send(createCommand);
|
|
99
|
-
this.queueUrl = response.QueueUrl;
|
|
100
|
-
} else throw new Error("Queue must exist or createQueue option must be true");
|
|
101
|
-
const attrsCommand = new GetQueueAttributesCommand({
|
|
102
|
-
QueueUrl: this.queueUrl,
|
|
103
|
-
AttributeNames: ["QueueArn"]
|
|
104
|
-
});
|
|
105
|
-
const attrsResponse = await this.sqsClient.send(attrsCommand);
|
|
106
|
-
this.queueArn = attrsResponse.Attributes?.QueueArn;
|
|
107
|
-
await this.setQueuePolicy();
|
|
108
|
-
}
|
|
109
|
-
async setQueuePolicy() {
|
|
110
|
-
const policy = {
|
|
111
|
-
Version: "2012-10-17",
|
|
112
|
-
Statement: [{
|
|
113
|
-
Effect: "Allow",
|
|
114
|
-
Principal: "*",
|
|
115
|
-
Action: "SQS:SendMessage",
|
|
116
|
-
Resource: this.queueArn,
|
|
117
|
-
Condition: { ArnEquals: { "aws:SourceArn": this.connection.topicArn } }
|
|
118
|
-
}]
|
|
119
|
-
};
|
|
120
|
-
const command = new SetQueueAttributesCommand({
|
|
121
|
-
QueueUrl: this.queueUrl,
|
|
122
|
-
Attributes: { Policy: JSON.stringify(policy) }
|
|
123
|
-
});
|
|
124
|
-
await this.sqsClient.send(command);
|
|
125
|
-
}
|
|
126
|
-
async subscribeToTopic() {
|
|
127
|
-
const command = new SubscribeCommand({
|
|
128
|
-
TopicArn: this.connection.topicArn,
|
|
129
|
-
Protocol: "sqs",
|
|
130
|
-
Endpoint: this.queueArn
|
|
131
|
-
});
|
|
132
|
-
const response = await this.connection.snsClient.send(command);
|
|
133
|
-
this.subscriptionArn = response.SubscriptionArn;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
//#endregion
|
|
138
|
-
export { SNSSubscriber };
|
|
139
|
-
//# sourceMappingURL=SNSSubscriber-DIXqA-VV.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SNSSubscriber-DIXqA-VV.mjs","names":["connection: SNSConnection","options: SNSSubscriberOptions","connectionString: string","messages: TMessage['type'][]","listener: (payload: TMessage) => Promise<void>"],"sources":["../src/sns/SNSSubscriber.ts"],"sourcesContent":["import { SubscribeCommand, UnsubscribeCommand } from '@aws-sdk/client-sns';\nimport {\n\tCreateQueueCommand,\n\tDeleteQueueCommand,\n\tGetQueueAttributesCommand,\n\tSetQueueAttributesCommand,\n\tSQSClient,\n} from '@aws-sdk/client-sqs';\nimport { SQSConnection } from '../sqs/SQSConnection';\nimport { SQSSubscriber } from '../sqs/SQSSubscriber';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport type { SNSConnection } from './SNSConnection';\n\nexport interface SNSSubscriberOptions {\n\tqueueName?: string; // Optional queue name (defaults to auto-generated)\n\tcreateQueue?: boolean; // Auto-create SQS queue (default: true)\n\tdeleteQueueOnClose?: boolean; // Delete queue when subscriber closes (default: false for named queues, true for auto-generated)\n\twaitTimeSeconds?: number; // SQS long polling (default: 20)\n\tmaxMessages?: number; // Max messages per poll (default: 10)\n}\n\n/**\n * SNS Subscriber - receives push-based messages from SNS via SQS queue\n *\n * Architecture:\n * SNS Topic → (push) → SQS Queue → Subscriber\n *\n * This subscriber automatically:\n * 1. Creates an SQS queue (or uses existing one)\n * 2. Subscribes the queue to the SNS topic\n * 3. Receives messages pushed from SNS to the queue\n * 4. Filters messages by topic ARN and message type\n * 5. Processes and acknowledges messages\n *\n * Note: While SQS long-polling is used internally to receive messages,\n * this is an implementation detail of the SNS push delivery mechanism.\n * Messages are pushed from SNS to SQS, and we receive those pushed messages.\n */\nexport class SNSSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tprivate sqsClient: SQSClient;\n\tprivate queueUrl?: string;\n\tprivate queueArn?: string;\n\tprivate subscriptionArn?: string;\n\tprivate sqsSubscriber?: SQSSubscriber<TMessage>;\n\tprivate options: Required<SNSSubscriberOptions>;\n\n\tconstructor(\n\t\tprivate connection: SNSConnection,\n\t\toptions: SNSSubscriberOptions = {},\n\t) {\n\t\tthis.options = {\n\t\t\tqueueName:\n\t\t\t\toptions.queueName ||\n\t\t\t\t`sns-sub-${Date.now()}-${Math.random().toString(36).substring(7)}`,\n\t\t\tcreateQueue: options.createQueue ?? true,\n\t\t\tdeleteQueueOnClose: options.deleteQueueOnClose ?? !options.queueName, // Delete auto-generated queues\n\t\t\twaitTimeSeconds: options.waitTimeSeconds ?? 20,\n\t\t\tmaxMessages: options.maxMessages ?? 10,\n\t\t};\n\n\t\t// Create SQS client with same config as SNS\n\t\tthis.sqsClient = new SQSClient({\n\t\t\tregion: (this.connection as any).config.region,\n\t\t\tendpoint: (this.connection as any).config.endpoint,\n\t\t\tcredentials: (this.connection as any).config.credentials,\n\t\t});\n\t}\n\n\t/**\n\t * Create an SNSSubscriber from a connection string\n\t * Format: sns://?topicArn=...&queueName=myqueue®ion=us-east-1\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SNSSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { SNSConnection } = await import('./SNSConnection');\n\t\tconst connection =\n\t\t\tawait SNSConnection.fromConnectionString(connectionString);\n\n\t\tconst options: SNSSubscriberOptions = {\n\t\t\tqueueName: params.get('queueName') || undefined,\n\t\t\tcreateQueue: params.get('createQueue') !== 'false',\n\t\t\tdeleteQueueOnClose: params.get('deleteQueueOnClose') === 'true',\n\t\t\twaitTimeSeconds: params.get('waitTimeSeconds')\n\t\t\t\t? Number.parseInt(params.get('waitTimeSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new SNSSubscriber<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\t// Setup SQS queue and SNS subscription\n\t\tawait this.setupQueue();\n\t\tawait this.subscribeToTopic();\n\n\t\t// Create SQS connection for the subscriber\n\t\tconst sqsConnection = new SQSConnection({\n\t\t\tqueueUrl: this.queueUrl!,\n\t\t\tregion: (this.connection as any).config.region,\n\t\t\tendpoint: (this.connection as any).config.endpoint,\n\t\t\tcredentials: (this.connection as any).config.credentials,\n\t\t});\n\t\tawait sqsConnection.connect();\n\n\t\t// Use SQSSubscriber to receive messages, with topic filtering\n\t\tthis.sqsSubscriber = new SQSSubscriber<TMessage>(sqsConnection, {\n\t\t\twaitTimeSeconds: this.options.waitTimeSeconds,\n\t\t\tmaxMessages: this.options.maxMessages,\n\t\t\texpectedTopicArn: this.connection.topicArn,\n\t\t});\n\n\t\tawait this.sqsSubscriber.subscribe(messages, listener);\n\t}\n\n\t/**\n\t * Stop receiving messages and clean up resources\n\t */\n\tasync stop(): Promise<void> {\n\t\t// Stop SQS subscriber\n\t\tif (this.sqsSubscriber) {\n\t\t\tthis.sqsSubscriber.stop();\n\t\t}\n\n\t\t// Unsubscribe from topic\n\t\tif (this.subscriptionArn) {\n\t\t\ttry {\n\t\t\t\tconst command = new UnsubscribeCommand({\n\t\t\t\t\tSubscriptionArn: this.subscriptionArn,\n\t\t\t\t});\n\t\t\t\tawait this.connection.snsClient.send(command);\n\t\t\t} catch (_error) {}\n\t\t}\n\n\t\t// Delete queue if configured\n\t\tif (this.queueUrl && this.options.deleteQueueOnClose) {\n\t\t\ttry {\n\t\t\t\tconst command = new DeleteQueueCommand({\n\t\t\t\t\tQueueUrl: this.queueUrl,\n\t\t\t\t});\n\t\t\t\tawait this.sqsClient.send(command);\n\t\t\t} catch (_error) {}\n\t\t}\n\n\t\tthis.sqsClient.destroy();\n\t}\n\n\tprivate async setupQueue(): Promise<void> {\n\t\tif (this.options.createQueue) {\n\t\t\t// Create queue\n\t\t\tconst createCommand = new CreateQueueCommand({\n\t\t\t\tQueueName: this.options.queueName,\n\t\t\t});\n\t\t\tconst response = await this.sqsClient.send(createCommand);\n\t\t\tthis.queueUrl = response.QueueUrl!;\n\t\t} else {\n\t\t\tthrow new Error('Queue must exist or createQueue option must be true');\n\t\t}\n\n\t\t// Get queue ARN\n\t\tconst attrsCommand = new GetQueueAttributesCommand({\n\t\t\tQueueUrl: this.queueUrl,\n\t\t\tAttributeNames: ['QueueArn'],\n\t\t});\n\t\tconst attrsResponse = await this.sqsClient.send(attrsCommand);\n\t\tthis.queueArn = attrsResponse.Attributes?.QueueArn!;\n\n\t\t// Set queue policy to allow SNS\n\t\tawait this.setQueuePolicy();\n\t}\n\n\tprivate async setQueuePolicy(): Promise<void> {\n\t\tconst policy = {\n\t\t\tVersion: '2012-10-17',\n\t\t\tStatement: [\n\t\t\t\t{\n\t\t\t\t\tEffect: 'Allow',\n\t\t\t\t\tPrincipal: '*',\n\t\t\t\t\tAction: 'SQS:SendMessage',\n\t\t\t\t\tResource: this.queueArn,\n\t\t\t\t\tCondition: {\n\t\t\t\t\t\tArnEquals: {\n\t\t\t\t\t\t\t'aws:SourceArn': this.connection.topicArn,\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};\n\n\t\tconst command = new SetQueueAttributesCommand({\n\t\t\tQueueUrl: this.queueUrl,\n\t\t\tAttributes: {\n\t\t\t\tPolicy: JSON.stringify(policy),\n\t\t\t},\n\t\t});\n\n\t\tawait this.sqsClient.send(command);\n\t}\n\n\tprivate async subscribeToTopic(): Promise<void> {\n\t\tconst command = new SubscribeCommand({\n\t\t\tTopicArn: this.connection.topicArn,\n\t\t\tProtocol: 'sqs',\n\t\t\tEndpoint: this.queueArn,\n\t\t});\n\n\t\tconst response = await this.connection.snsClient.send(command);\n\t\tthis.subscriptionArn = response.SubscriptionArn!;\n\t}\n}\n"],"mappings":"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"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { EventSubscriber, PublishableMessage } from "./types-Dj23od3e.cjs";
|
|
2
|
-
import { SNSConnection } from "./SNSConnection-Dol9FuxA.cjs";
|
|
3
|
-
|
|
4
|
-
//#region src/sns/SNSSubscriber.d.ts
|
|
5
|
-
interface SNSSubscriberOptions {
|
|
6
|
-
queueName?: string;
|
|
7
|
-
createQueue?: boolean;
|
|
8
|
-
deleteQueueOnClose?: boolean;
|
|
9
|
-
waitTimeSeconds?: number;
|
|
10
|
-
maxMessages?: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* SNS Subscriber - receives push-based messages from SNS via SQS queue
|
|
14
|
-
*
|
|
15
|
-
* Architecture:
|
|
16
|
-
* SNS Topic → (push) → SQS Queue → Subscriber
|
|
17
|
-
*
|
|
18
|
-
* This subscriber automatically:
|
|
19
|
-
* 1. Creates an SQS queue (or uses existing one)
|
|
20
|
-
* 2. Subscribes the queue to the SNS topic
|
|
21
|
-
* 3. Receives messages pushed from SNS to the queue
|
|
22
|
-
* 4. Filters messages by topic ARN and message type
|
|
23
|
-
* 5. Processes and acknowledges messages
|
|
24
|
-
*
|
|
25
|
-
* Note: While SQS long-polling is used internally to receive messages,
|
|
26
|
-
* this is an implementation detail of the SNS push delivery mechanism.
|
|
27
|
-
* Messages are pushed from SNS to SQS, and we receive those pushed messages.
|
|
28
|
-
*/
|
|
29
|
-
declare class SNSSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
|
|
30
|
-
private connection;
|
|
31
|
-
private sqsClient;
|
|
32
|
-
private queueUrl?;
|
|
33
|
-
private queueArn?;
|
|
34
|
-
private subscriptionArn?;
|
|
35
|
-
private sqsSubscriber?;
|
|
36
|
-
private options;
|
|
37
|
-
constructor(connection: SNSConnection, options?: SNSSubscriberOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Create an SNSSubscriber from a connection string
|
|
40
|
-
* Format: sns://?topicArn=...&queueName=myqueue®ion=us-east-1
|
|
41
|
-
*/
|
|
42
|
-
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string): Promise<SNSSubscriber<TMessage>>;
|
|
43
|
-
subscribe(messages: TMessage['type'][], listener: (payload: TMessage) => Promise<void>): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Stop receiving messages and clean up resources
|
|
46
|
-
*/
|
|
47
|
-
stop(): Promise<void>;
|
|
48
|
-
private setupQueue;
|
|
49
|
-
private setQueuePolicy;
|
|
50
|
-
private subscribeToTopic;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=SNSSubscriber.d.ts.map
|
|
53
|
-
//#endregion
|
|
54
|
-
export { SNSSubscriber, SNSSubscriberOptions };
|
|
55
|
-
//# sourceMappingURL=SNSSubscriber-ZGJjhXFQ.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SNSSubscriber-ZGJjhXFQ.d.cts","names":[],"sources":["../src/sns/SNSSubscriber.ts"],"sourcesContent":[],"mappings":";;;;UAaiB,oBAAA;;EAAA,WAAA,CAAA,EAAA,OAAA;EAyBJ,kBAAa,CAAA,EAAA,OAAA;EAAA,eAAA,CAAA,EAAA,MAAA;EAAA,WAAkB,CAAA,EAAA,MAAA;;;;;;;;;;;;;;AACjB;;;;;cADd,+BAA+B,4CAChC,gBAAgB;;;;;;;;0BAUN,yBACX;;;;;+CAyBQ,4DACW,QAAQ,cAAc;sBAqBxC,wCACU,aAAa,gBAC/B;;;;UA2BW"}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_SQSConnection = require('./SQSConnection-yge9cB_f.cjs');
|
|
3
|
-
const require_SQSSubscriber = require('./SQSSubscriber-B4sRXVl6.cjs');
|
|
4
|
-
const __aws_sdk_client_sns = require_chunk.__toESM(require("@aws-sdk/client-sns"));
|
|
5
|
-
const __aws_sdk_client_sqs = require_chunk.__toESM(require("@aws-sdk/client-sqs"));
|
|
6
|
-
|
|
7
|
-
//#region src/sns/SNSSubscriber.ts
|
|
8
|
-
/**
|
|
9
|
-
* SNS Subscriber - receives push-based messages from SNS via SQS queue
|
|
10
|
-
*
|
|
11
|
-
* Architecture:
|
|
12
|
-
* SNS Topic → (push) → SQS Queue → Subscriber
|
|
13
|
-
*
|
|
14
|
-
* This subscriber automatically:
|
|
15
|
-
* 1. Creates an SQS queue (or uses existing one)
|
|
16
|
-
* 2. Subscribes the queue to the SNS topic
|
|
17
|
-
* 3. Receives messages pushed from SNS to the queue
|
|
18
|
-
* 4. Filters messages by topic ARN and message type
|
|
19
|
-
* 5. Processes and acknowledges messages
|
|
20
|
-
*
|
|
21
|
-
* Note: While SQS long-polling is used internally to receive messages,
|
|
22
|
-
* this is an implementation detail of the SNS push delivery mechanism.
|
|
23
|
-
* Messages are pushed from SNS to SQS, and we receive those pushed messages.
|
|
24
|
-
*/
|
|
25
|
-
var SNSSubscriber = class SNSSubscriber {
|
|
26
|
-
sqsClient;
|
|
27
|
-
queueUrl;
|
|
28
|
-
queueArn;
|
|
29
|
-
subscriptionArn;
|
|
30
|
-
sqsSubscriber;
|
|
31
|
-
options;
|
|
32
|
-
constructor(connection, options = {}) {
|
|
33
|
-
this.connection = connection;
|
|
34
|
-
this.options = {
|
|
35
|
-
queueName: options.queueName || `sns-sub-${Date.now()}-${Math.random().toString(36).substring(7)}`,
|
|
36
|
-
createQueue: options.createQueue ?? true,
|
|
37
|
-
deleteQueueOnClose: options.deleteQueueOnClose ?? !options.queueName,
|
|
38
|
-
waitTimeSeconds: options.waitTimeSeconds ?? 20,
|
|
39
|
-
maxMessages: options.maxMessages ?? 10
|
|
40
|
-
};
|
|
41
|
-
this.sqsClient = new __aws_sdk_client_sqs.SQSClient({
|
|
42
|
-
region: this.connection.config.region,
|
|
43
|
-
endpoint: this.connection.config.endpoint,
|
|
44
|
-
credentials: this.connection.config.credentials
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Create an SNSSubscriber from a connection string
|
|
49
|
-
* Format: sns://?topicArn=...&queueName=myqueue®ion=us-east-1
|
|
50
|
-
*/
|
|
51
|
-
static async fromConnectionString(connectionString) {
|
|
52
|
-
const url = new URL(connectionString);
|
|
53
|
-
const params = url.searchParams;
|
|
54
|
-
const { SNSConnection } = await Promise.resolve().then(() => require("./sns/SNSConnection.cjs"));
|
|
55
|
-
const connection = await SNSConnection.fromConnectionString(connectionString);
|
|
56
|
-
const options = {
|
|
57
|
-
queueName: params.get("queueName") || void 0,
|
|
58
|
-
createQueue: params.get("createQueue") !== "false",
|
|
59
|
-
deleteQueueOnClose: params.get("deleteQueueOnClose") === "true",
|
|
60
|
-
waitTimeSeconds: params.get("waitTimeSeconds") ? Number.parseInt(params.get("waitTimeSeconds"), 10) : void 0
|
|
61
|
-
};
|
|
62
|
-
return new SNSSubscriber(connection, options);
|
|
63
|
-
}
|
|
64
|
-
async subscribe(messages, listener) {
|
|
65
|
-
await this.setupQueue();
|
|
66
|
-
await this.subscribeToTopic();
|
|
67
|
-
const sqsConnection = new require_SQSConnection.SQSConnection({
|
|
68
|
-
queueUrl: this.queueUrl,
|
|
69
|
-
region: this.connection.config.region,
|
|
70
|
-
endpoint: this.connection.config.endpoint,
|
|
71
|
-
credentials: this.connection.config.credentials
|
|
72
|
-
});
|
|
73
|
-
await sqsConnection.connect();
|
|
74
|
-
this.sqsSubscriber = new require_SQSSubscriber.SQSSubscriber(sqsConnection, {
|
|
75
|
-
waitTimeSeconds: this.options.waitTimeSeconds,
|
|
76
|
-
maxMessages: this.options.maxMessages,
|
|
77
|
-
expectedTopicArn: this.connection.topicArn
|
|
78
|
-
});
|
|
79
|
-
await this.sqsSubscriber.subscribe(messages, listener);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Stop receiving messages and clean up resources
|
|
83
|
-
*/
|
|
84
|
-
async stop() {
|
|
85
|
-
if (this.sqsSubscriber) this.sqsSubscriber.stop();
|
|
86
|
-
if (this.subscriptionArn) try {
|
|
87
|
-
const command = new __aws_sdk_client_sns.UnsubscribeCommand({ SubscriptionArn: this.subscriptionArn });
|
|
88
|
-
await this.connection.snsClient.send(command);
|
|
89
|
-
} catch (_error) {}
|
|
90
|
-
if (this.queueUrl && this.options.deleteQueueOnClose) try {
|
|
91
|
-
const command = new __aws_sdk_client_sqs.DeleteQueueCommand({ QueueUrl: this.queueUrl });
|
|
92
|
-
await this.sqsClient.send(command);
|
|
93
|
-
} catch (_error) {}
|
|
94
|
-
this.sqsClient.destroy();
|
|
95
|
-
}
|
|
96
|
-
async setupQueue() {
|
|
97
|
-
if (this.options.createQueue) {
|
|
98
|
-
const createCommand = new __aws_sdk_client_sqs.CreateQueueCommand({ QueueName: this.options.queueName });
|
|
99
|
-
const response = await this.sqsClient.send(createCommand);
|
|
100
|
-
this.queueUrl = response.QueueUrl;
|
|
101
|
-
} else throw new Error("Queue must exist or createQueue option must be true");
|
|
102
|
-
const attrsCommand = new __aws_sdk_client_sqs.GetQueueAttributesCommand({
|
|
103
|
-
QueueUrl: this.queueUrl,
|
|
104
|
-
AttributeNames: ["QueueArn"]
|
|
105
|
-
});
|
|
106
|
-
const attrsResponse = await this.sqsClient.send(attrsCommand);
|
|
107
|
-
this.queueArn = attrsResponse.Attributes?.QueueArn;
|
|
108
|
-
await this.setQueuePolicy();
|
|
109
|
-
}
|
|
110
|
-
async setQueuePolicy() {
|
|
111
|
-
const policy = {
|
|
112
|
-
Version: "2012-10-17",
|
|
113
|
-
Statement: [{
|
|
114
|
-
Effect: "Allow",
|
|
115
|
-
Principal: "*",
|
|
116
|
-
Action: "SQS:SendMessage",
|
|
117
|
-
Resource: this.queueArn,
|
|
118
|
-
Condition: { ArnEquals: { "aws:SourceArn": this.connection.topicArn } }
|
|
119
|
-
}]
|
|
120
|
-
};
|
|
121
|
-
const command = new __aws_sdk_client_sqs.SetQueueAttributesCommand({
|
|
122
|
-
QueueUrl: this.queueUrl,
|
|
123
|
-
Attributes: { Policy: JSON.stringify(policy) }
|
|
124
|
-
});
|
|
125
|
-
await this.sqsClient.send(command);
|
|
126
|
-
}
|
|
127
|
-
async subscribeToTopic() {
|
|
128
|
-
const command = new __aws_sdk_client_sns.SubscribeCommand({
|
|
129
|
-
TopicArn: this.connection.topicArn,
|
|
130
|
-
Protocol: "sqs",
|
|
131
|
-
Endpoint: this.queueArn
|
|
132
|
-
});
|
|
133
|
-
const response = await this.connection.snsClient.send(command);
|
|
134
|
-
this.subscriptionArn = response.SubscriptionArn;
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
//#endregion
|
|
139
|
-
Object.defineProperty(exports, 'SNSSubscriber', {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
get: function () {
|
|
142
|
-
return SNSSubscriber;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
//# sourceMappingURL=SNSSubscriber-ZIdCi6nQ.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SNSSubscriber-ZIdCi6nQ.cjs","names":["connection: SNSConnection","options: SNSSubscriberOptions","SQSClient","connectionString: string","messages: TMessage['type'][]","listener: (payload: TMessage) => Promise<void>","SQSConnection","SQSSubscriber","UnsubscribeCommand","DeleteQueueCommand","CreateQueueCommand","GetQueueAttributesCommand","SetQueueAttributesCommand","SubscribeCommand"],"sources":["../src/sns/SNSSubscriber.ts"],"sourcesContent":["import { SubscribeCommand, UnsubscribeCommand } from '@aws-sdk/client-sns';\nimport {\n\tCreateQueueCommand,\n\tDeleteQueueCommand,\n\tGetQueueAttributesCommand,\n\tSetQueueAttributesCommand,\n\tSQSClient,\n} from '@aws-sdk/client-sqs';\nimport { SQSConnection } from '../sqs/SQSConnection';\nimport { SQSSubscriber } from '../sqs/SQSSubscriber';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport type { SNSConnection } from './SNSConnection';\n\nexport interface SNSSubscriberOptions {\n\tqueueName?: string; // Optional queue name (defaults to auto-generated)\n\tcreateQueue?: boolean; // Auto-create SQS queue (default: true)\n\tdeleteQueueOnClose?: boolean; // Delete queue when subscriber closes (default: false for named queues, true for auto-generated)\n\twaitTimeSeconds?: number; // SQS long polling (default: 20)\n\tmaxMessages?: number; // Max messages per poll (default: 10)\n}\n\n/**\n * SNS Subscriber - receives push-based messages from SNS via SQS queue\n *\n * Architecture:\n * SNS Topic → (push) → SQS Queue → Subscriber\n *\n * This subscriber automatically:\n * 1. Creates an SQS queue (or uses existing one)\n * 2. Subscribes the queue to the SNS topic\n * 3. Receives messages pushed from SNS to the queue\n * 4. Filters messages by topic ARN and message type\n * 5. Processes and acknowledges messages\n *\n * Note: While SQS long-polling is used internally to receive messages,\n * this is an implementation detail of the SNS push delivery mechanism.\n * Messages are pushed from SNS to SQS, and we receive those pushed messages.\n */\nexport class SNSSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tprivate sqsClient: SQSClient;\n\tprivate queueUrl?: string;\n\tprivate queueArn?: string;\n\tprivate subscriptionArn?: string;\n\tprivate sqsSubscriber?: SQSSubscriber<TMessage>;\n\tprivate options: Required<SNSSubscriberOptions>;\n\n\tconstructor(\n\t\tprivate connection: SNSConnection,\n\t\toptions: SNSSubscriberOptions = {},\n\t) {\n\t\tthis.options = {\n\t\t\tqueueName:\n\t\t\t\toptions.queueName ||\n\t\t\t\t`sns-sub-${Date.now()}-${Math.random().toString(36).substring(7)}`,\n\t\t\tcreateQueue: options.createQueue ?? true,\n\t\t\tdeleteQueueOnClose: options.deleteQueueOnClose ?? !options.queueName, // Delete auto-generated queues\n\t\t\twaitTimeSeconds: options.waitTimeSeconds ?? 20,\n\t\t\tmaxMessages: options.maxMessages ?? 10,\n\t\t};\n\n\t\t// Create SQS client with same config as SNS\n\t\tthis.sqsClient = new SQSClient({\n\t\t\tregion: (this.connection as any).config.region,\n\t\t\tendpoint: (this.connection as any).config.endpoint,\n\t\t\tcredentials: (this.connection as any).config.credentials,\n\t\t});\n\t}\n\n\t/**\n\t * Create an SNSSubscriber from a connection string\n\t * Format: sns://?topicArn=...&queueName=myqueue®ion=us-east-1\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SNSSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { SNSConnection } = await import('./SNSConnection');\n\t\tconst connection =\n\t\t\tawait SNSConnection.fromConnectionString(connectionString);\n\n\t\tconst options: SNSSubscriberOptions = {\n\t\t\tqueueName: params.get('queueName') || undefined,\n\t\t\tcreateQueue: params.get('createQueue') !== 'false',\n\t\t\tdeleteQueueOnClose: params.get('deleteQueueOnClose') === 'true',\n\t\t\twaitTimeSeconds: params.get('waitTimeSeconds')\n\t\t\t\t? Number.parseInt(params.get('waitTimeSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new SNSSubscriber<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\t// Setup SQS queue and SNS subscription\n\t\tawait this.setupQueue();\n\t\tawait this.subscribeToTopic();\n\n\t\t// Create SQS connection for the subscriber\n\t\tconst sqsConnection = new SQSConnection({\n\t\t\tqueueUrl: this.queueUrl!,\n\t\t\tregion: (this.connection as any).config.region,\n\t\t\tendpoint: (this.connection as any).config.endpoint,\n\t\t\tcredentials: (this.connection as any).config.credentials,\n\t\t});\n\t\tawait sqsConnection.connect();\n\n\t\t// Use SQSSubscriber to receive messages, with topic filtering\n\t\tthis.sqsSubscriber = new SQSSubscriber<TMessage>(sqsConnection, {\n\t\t\twaitTimeSeconds: this.options.waitTimeSeconds,\n\t\t\tmaxMessages: this.options.maxMessages,\n\t\t\texpectedTopicArn: this.connection.topicArn,\n\t\t});\n\n\t\tawait this.sqsSubscriber.subscribe(messages, listener);\n\t}\n\n\t/**\n\t * Stop receiving messages and clean up resources\n\t */\n\tasync stop(): Promise<void> {\n\t\t// Stop SQS subscriber\n\t\tif (this.sqsSubscriber) {\n\t\t\tthis.sqsSubscriber.stop();\n\t\t}\n\n\t\t// Unsubscribe from topic\n\t\tif (this.subscriptionArn) {\n\t\t\ttry {\n\t\t\t\tconst command = new UnsubscribeCommand({\n\t\t\t\t\tSubscriptionArn: this.subscriptionArn,\n\t\t\t\t});\n\t\t\t\tawait this.connection.snsClient.send(command);\n\t\t\t} catch (_error) {}\n\t\t}\n\n\t\t// Delete queue if configured\n\t\tif (this.queueUrl && this.options.deleteQueueOnClose) {\n\t\t\ttry {\n\t\t\t\tconst command = new DeleteQueueCommand({\n\t\t\t\t\tQueueUrl: this.queueUrl,\n\t\t\t\t});\n\t\t\t\tawait this.sqsClient.send(command);\n\t\t\t} catch (_error) {}\n\t\t}\n\n\t\tthis.sqsClient.destroy();\n\t}\n\n\tprivate async setupQueue(): Promise<void> {\n\t\tif (this.options.createQueue) {\n\t\t\t// Create queue\n\t\t\tconst createCommand = new CreateQueueCommand({\n\t\t\t\tQueueName: this.options.queueName,\n\t\t\t});\n\t\t\tconst response = await this.sqsClient.send(createCommand);\n\t\t\tthis.queueUrl = response.QueueUrl!;\n\t\t} else {\n\t\t\tthrow new Error('Queue must exist or createQueue option must be true');\n\t\t}\n\n\t\t// Get queue ARN\n\t\tconst attrsCommand = new GetQueueAttributesCommand({\n\t\t\tQueueUrl: this.queueUrl,\n\t\t\tAttributeNames: ['QueueArn'],\n\t\t});\n\t\tconst attrsResponse = await this.sqsClient.send(attrsCommand);\n\t\tthis.queueArn = attrsResponse.Attributes?.QueueArn!;\n\n\t\t// Set queue policy to allow SNS\n\t\tawait this.setQueuePolicy();\n\t}\n\n\tprivate async setQueuePolicy(): Promise<void> {\n\t\tconst policy = {\n\t\t\tVersion: '2012-10-17',\n\t\t\tStatement: [\n\t\t\t\t{\n\t\t\t\t\tEffect: 'Allow',\n\t\t\t\t\tPrincipal: '*',\n\t\t\t\t\tAction: 'SQS:SendMessage',\n\t\t\t\t\tResource: this.queueArn,\n\t\t\t\t\tCondition: {\n\t\t\t\t\t\tArnEquals: {\n\t\t\t\t\t\t\t'aws:SourceArn': this.connection.topicArn,\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};\n\n\t\tconst command = new SetQueueAttributesCommand({\n\t\t\tQueueUrl: this.queueUrl,\n\t\t\tAttributes: {\n\t\t\t\tPolicy: JSON.stringify(policy),\n\t\t\t},\n\t\t});\n\n\t\tawait this.sqsClient.send(command);\n\t}\n\n\tprivate async subscribeToTopic(): Promise<void> {\n\t\tconst command = new SubscribeCommand({\n\t\t\tTopicArn: this.connection.topicArn,\n\t\t\tProtocol: 'sqs',\n\t\t\tEndpoint: this.queueArn,\n\t\t});\n\n\t\tconst response = await this.connection.snsClient.send(command);\n\t\tthis.subscriptionArn = response.SubscriptionArn!;\n\t}\n}\n"],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SQSConnection-BqZZnAZI.mjs","names":["config: SQSConnectionConfig","clientConfig: SQSClientConfig","connectionString: string"],"sources":["../src/sqs/SQSConnection.ts"],"sourcesContent":["import { SQSClient, type SQSClientConfig } from '@aws-sdk/client-sqs';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface SQSConnectionConfig {\n\tqueueUrl: string;\n\tregion?: string;\n\tendpoint?: string; // Custom endpoint (e.g., for LocalStack)\n\tcredentials?: {\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t};\n}\n\nexport class SQSConnection implements EventConnection {\n\treadonly type = EventPublisherType.SQS;\n\tprivate client: SQSClient;\n\tprivate connected = false;\n\n\tconstructor(readonly config: SQSConnectionConfig) {\n\t\tthis.config = config;\n\n\t\tconst clientConfig: SQSClientConfig = {\n\t\t\tregion: config.region,\n\t\t\tendpoint: config.endpoint,\n\t\t\tcredentials: config.credentials,\n\t\t};\n\n\t\tthis.client = new SQSClient(clientConfig);\n\t}\n\n\t/**\n\t * Create an SQSConnection from a connection string\n\t * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName®ion=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<SQSConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst queueUrl = params.get('queueUrl');\n\t\tif (!queueUrl) {\n\t\t\tthrow new Error('queueUrl parameter is required in connection string');\n\t\t}\n\n\t\tconst config: SQSConnectionConfig = {\n\t\t\tqueueUrl,\n\t\t\tregion: params.get('region') || undefined,\n\t\t\tendpoint: params.get('endpoint') || undefined,\n\t\t};\n\n\t\t// Parse credentials if provided\n\t\tconst accessKeyId = params.get('accessKeyId');\n\t\tconst secretAccessKey = params.get('secretAccessKey');\n\t\tif (accessKeyId && secretAccessKey) {\n\t\t\tconfig.credentials = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey,\n\t\t\t\tsessionToken: params.get('sessionToken') || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst connection = new SQSConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\t// SQS doesn't have a traditional connection, but we mark as connected\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.client.destroy();\n\t\tthis.connected = false;\n\t}\n\n\tisConnected(): boolean {\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Get the underlying SQS client\n\t */\n\tget sqsClient(): SQSClient {\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Get the queue URL for this connection\n\t */\n\tget queueUrl(): string {\n\t\treturn this.config.queueUrl;\n\t}\n}\n"],"mappings":";;;;AAeA,IAAa,gBAAb,MAAa,cAAyC;CACrD,AAAS,OAAO,mBAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CAEpB,YAAqBA,QAA6B;EAA7B;AACpB,OAAK,SAAS;EAEd,MAAMC,eAAgC;GACrC,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,aAAa,OAAO;EACpB;AAED,OAAK,SAAS,IAAI,UAAU;CAC5B;;;;;CAMD,aAAa,qBACZC,kBACyB;EACzB,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,WAAW,OAAO,IAAI,WAAW;AACvC,OAAK,SACJ,OAAM,IAAI,MAAM;EAGjB,MAAMF,SAA8B;GACnC;GACA,QAAQ,OAAO,IAAI,SAAS;GAC5B,UAAU,OAAO,IAAI,WAAW;EAChC;EAGD,MAAM,cAAc,OAAO,IAAI,cAAc;EAC7C,MAAM,kBAAkB,OAAO,IAAI,kBAAkB;AACrD,MAAI,eAAe,gBAClB,QAAO,cAAc;GACpB;GACA;GACA,cAAc,OAAO,IAAI,eAAe;EACxC;EAGF,MAAM,aAAa,IAAI,cAAc;AACrC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAE9B,OAAK,YAAY;CACjB;CAED,MAAM,QAAuB;AAC5B,OAAK,OAAO,SAAS;AACrB,OAAK,YAAY;CACjB;CAED,cAAuB;AACtB,SAAO,KAAK;CACZ;;;;CAKD,IAAI,YAAuB;AAC1B,SAAO,KAAK;CACZ;;;;CAKD,IAAI,WAAmB;AACtB,SAAO,KAAK,OAAO;CACnB;AACD"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { EventConnection, EventPublisherType } from "./types-Dj23od3e.cjs";
|
|
2
|
-
import { SQSClient } from "@aws-sdk/client-sqs";
|
|
3
|
-
|
|
4
|
-
//#region src/sqs/SQSConnection.d.ts
|
|
5
|
-
interface SQSConnectionConfig {
|
|
6
|
-
queueUrl: string;
|
|
7
|
-
region?: string;
|
|
8
|
-
endpoint?: string;
|
|
9
|
-
credentials?: {
|
|
10
|
-
accessKeyId: string;
|
|
11
|
-
secretAccessKey: string;
|
|
12
|
-
sessionToken?: string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
declare class SQSConnection implements EventConnection {
|
|
16
|
-
readonly config: SQSConnectionConfig;
|
|
17
|
-
readonly type = EventPublisherType.SQS;
|
|
18
|
-
private client;
|
|
19
|
-
private connected;
|
|
20
|
-
constructor(config: SQSConnectionConfig);
|
|
21
|
-
/**
|
|
22
|
-
* Create an SQSConnection from a connection string
|
|
23
|
-
* Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName®ion=us-east-1&endpoint=http://localhost:4566
|
|
24
|
-
*/
|
|
25
|
-
static fromConnectionString(connectionString: string): Promise<SQSConnection>;
|
|
26
|
-
connect(): Promise<void>;
|
|
27
|
-
close(): Promise<void>;
|
|
28
|
-
isConnected(): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Get the underlying SQS client
|
|
31
|
-
*/
|
|
32
|
-
get sqsClient(): SQSClient;
|
|
33
|
-
/**
|
|
34
|
-
* Get the queue URL for this connection
|
|
35
|
-
*/
|
|
36
|
-
get queueUrl(): string;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=SQSConnection.d.ts.map
|
|
39
|
-
//#endregion
|
|
40
|
-
export { SQSConnection, SQSConnectionConfig };
|
|
41
|
-
//# sourceMappingURL=SQSConnection-BtEkDha8.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SQSConnection-BtEkDha8.d.cts","names":[],"sources":["../src/sqs/SQSConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,mBAAA;EAAA,QAAA,EAAA,MAAA;EAWJ,MAAA,CAAA,EAAA,MAAA;EAAc,QAAA,CAAA,EAAA,MAAA;EAAA,WAKG,CAAA,EAAA;IAJhB,WAAA,EAAA,MAAA;IAIgB,eAAA,EAAA,MAAA;IAkBlB,YAAA,CAAA,EAAA,MAAA;EAAa,CAAA;;AAoCT,cA3DH,aAAA,YAAyB,eA2DtB,CAAA;EAAO,SAYL,MAAA,EAlEY,mBAkEZ;EAAS,SAvEW,IAAA,GACxB,kBAAA,CAAA,GAAA;EADuC,QAAA,MAAA;;sBAKvB;;;;;yDAkB1B,QAAQ;aA+BM;WAKF;;;;;mBAYE"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { EventConnection, EventPublisherType } from "./types-Dh9Jyinx.mjs";
|
|
2
|
-
import { SQSClient } from "@aws-sdk/client-sqs";
|
|
3
|
-
|
|
4
|
-
//#region src/sqs/SQSConnection.d.ts
|
|
5
|
-
interface SQSConnectionConfig {
|
|
6
|
-
queueUrl: string;
|
|
7
|
-
region?: string;
|
|
8
|
-
endpoint?: string;
|
|
9
|
-
credentials?: {
|
|
10
|
-
accessKeyId: string;
|
|
11
|
-
secretAccessKey: string;
|
|
12
|
-
sessionToken?: string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
declare class SQSConnection implements EventConnection {
|
|
16
|
-
readonly config: SQSConnectionConfig;
|
|
17
|
-
readonly type = EventPublisherType.SQS;
|
|
18
|
-
private client;
|
|
19
|
-
private connected;
|
|
20
|
-
constructor(config: SQSConnectionConfig);
|
|
21
|
-
/**
|
|
22
|
-
* Create an SQSConnection from a connection string
|
|
23
|
-
* Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName®ion=us-east-1&endpoint=http://localhost:4566
|
|
24
|
-
*/
|
|
25
|
-
static fromConnectionString(connectionString: string): Promise<SQSConnection>;
|
|
26
|
-
connect(): Promise<void>;
|
|
27
|
-
close(): Promise<void>;
|
|
28
|
-
isConnected(): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Get the underlying SQS client
|
|
31
|
-
*/
|
|
32
|
-
get sqsClient(): SQSClient;
|
|
33
|
-
/**
|
|
34
|
-
* Get the queue URL for this connection
|
|
35
|
-
*/
|
|
36
|
-
get queueUrl(): string;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=SQSConnection.d.ts.map
|
|
39
|
-
//#endregion
|
|
40
|
-
export { SQSConnection, SQSConnectionConfig };
|
|
41
|
-
//# sourceMappingURL=SQSConnection-DVy43GCV.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SQSConnection-DVy43GCV.d.mts","names":[],"sources":["../src/sqs/SQSConnection.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,mBAAA;EAAA,QAAA,EAAA,MAAA;EAWJ,MAAA,CAAA,EAAA,MAAA;EAAc,QAAA,CAAA,EAAA,MAAA;EAAA,WAKG,CAAA,EAAA;IAJhB,WAAA,EAAA,MAAA;IAIgB,eAAA,EAAA,MAAA;IAkBlB,YAAA,CAAA,EAAA,MAAA;EAAa,CAAA;;AAoCT,cA3DH,aAAA,YAAyB,eA2DtB,CAAA;EAAO,SAYL,MAAA,EAlEY,mBAkEZ;EAAS,SAvEW,IAAA,GACxB,kBAAA,CAAA,GAAA;EADuC,QAAA,MAAA;;sBAKvB;;;;;yDAkB1B,QAAQ;aA+BM;WAKF;;;;;mBAYE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SQSConnection-yge9cB_f.cjs","names":["EventPublisherType","config: SQSConnectionConfig","clientConfig: SQSClientConfig","SQSClient","connectionString: string"],"sources":["../src/sqs/SQSConnection.ts"],"sourcesContent":["import { SQSClient, type SQSClientConfig } from '@aws-sdk/client-sqs';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface SQSConnectionConfig {\n\tqueueUrl: string;\n\tregion?: string;\n\tendpoint?: string; // Custom endpoint (e.g., for LocalStack)\n\tcredentials?: {\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t};\n}\n\nexport class SQSConnection implements EventConnection {\n\treadonly type = EventPublisherType.SQS;\n\tprivate client: SQSClient;\n\tprivate connected = false;\n\n\tconstructor(readonly config: SQSConnectionConfig) {\n\t\tthis.config = config;\n\n\t\tconst clientConfig: SQSClientConfig = {\n\t\t\tregion: config.region,\n\t\t\tendpoint: config.endpoint,\n\t\t\tcredentials: config.credentials,\n\t\t};\n\n\t\tthis.client = new SQSClient(clientConfig);\n\t}\n\n\t/**\n\t * Create an SQSConnection from a connection string\n\t * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName®ion=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<SQSConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst queueUrl = params.get('queueUrl');\n\t\tif (!queueUrl) {\n\t\t\tthrow new Error('queueUrl parameter is required in connection string');\n\t\t}\n\n\t\tconst config: SQSConnectionConfig = {\n\t\t\tqueueUrl,\n\t\t\tregion: params.get('region') || undefined,\n\t\t\tendpoint: params.get('endpoint') || undefined,\n\t\t};\n\n\t\t// Parse credentials if provided\n\t\tconst accessKeyId = params.get('accessKeyId');\n\t\tconst secretAccessKey = params.get('secretAccessKey');\n\t\tif (accessKeyId && secretAccessKey) {\n\t\t\tconfig.credentials = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey,\n\t\t\t\tsessionToken: params.get('sessionToken') || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst connection = new SQSConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\t// SQS doesn't have a traditional connection, but we mark as connected\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.client.destroy();\n\t\tthis.connected = false;\n\t}\n\n\tisConnected(): boolean {\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Get the underlying SQS client\n\t */\n\tget sqsClient(): SQSClient {\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Get the queue URL for this connection\n\t */\n\tget queueUrl(): string {\n\t\treturn this.config.queueUrl;\n\t}\n}\n"],"mappings":";;;;;AAeA,IAAa,gBAAb,MAAa,cAAyC;CACrD,AAAS,OAAOA,iCAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CAEpB,YAAqBC,QAA6B;EAA7B;AACpB,OAAK,SAAS;EAEd,MAAMC,eAAgC;GACrC,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,aAAa,OAAO;EACpB;AAED,OAAK,SAAS,IAAIC,+BAAU;CAC5B;;;;;CAMD,aAAa,qBACZC,kBACyB;EACzB,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,WAAW,OAAO,IAAI,WAAW;AACvC,OAAK,SACJ,OAAM,IAAI,MAAM;EAGjB,MAAMH,SAA8B;GACnC;GACA,QAAQ,OAAO,IAAI,SAAS;GAC5B,UAAU,OAAO,IAAI,WAAW;EAChC;EAGD,MAAM,cAAc,OAAO,IAAI,cAAc;EAC7C,MAAM,kBAAkB,OAAO,IAAI,kBAAkB;AACrD,MAAI,eAAe,gBAClB,QAAO,cAAc;GACpB;GACA;GACA,cAAc,OAAO,IAAI,eAAe;EACxC;EAGF,MAAM,aAAa,IAAI,cAAc;AACrC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAE9B,OAAK,YAAY;CACjB;CAED,MAAM,QAAuB;AAC5B,OAAK,OAAO,SAAS;AACrB,OAAK,YAAY;CACjB;CAED,cAAuB;AACtB,SAAO,KAAK;CACZ;;;;CAKD,IAAI,YAAuB;AAC1B,SAAO,KAAK;CACZ;;;;CAKD,IAAI,WAAmB;AACtB,SAAO,KAAK,OAAO;CACnB;AACD"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { SendMessageBatchCommand } from "@aws-sdk/client-sqs";
|
|
2
|
-
import chunk from "lodash.chunk";
|
|
3
|
-
|
|
4
|
-
//#region src/sqs/SQSPublisher.ts
|
|
5
|
-
var SQSPublisher = class SQSPublisher {
|
|
6
|
-
options;
|
|
7
|
-
constructor(connection, options = {}) {
|
|
8
|
-
this.connection = connection;
|
|
9
|
-
this.options = { maxBatchSize: options.maxBatchSize ?? 10 };
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Create an SQSPublisher from a connection string
|
|
13
|
-
* Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName®ion=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10
|
|
14
|
-
*/
|
|
15
|
-
static async fromConnectionString(connectionString) {
|
|
16
|
-
const url = new URL(connectionString);
|
|
17
|
-
const params = url.searchParams;
|
|
18
|
-
const { SQSConnection } = await import("./sqs/SQSConnection.mjs");
|
|
19
|
-
const connection = await SQSConnection.fromConnectionString(connectionString);
|
|
20
|
-
const options = { maxBatchSize: params.get("maxBatchSize") ? Number.parseInt(params.get("maxBatchSize"), 10) : void 0 };
|
|
21
|
-
return new SQSPublisher(connection, options);
|
|
22
|
-
}
|
|
23
|
-
async publish(messages) {
|
|
24
|
-
if (messages.length === 0) return;
|
|
25
|
-
if (!this.connection.isConnected()) await this.connection.connect();
|
|
26
|
-
const batches = chunk(messages, this.options.maxBatchSize);
|
|
27
|
-
await Promise.all(batches.map((batch) => this.sendBatch(batch)));
|
|
28
|
-
}
|
|
29
|
-
async sendBatch(messages) {
|
|
30
|
-
const entries = messages.map((message, index) => ({
|
|
31
|
-
Id: `${index}`,
|
|
32
|
-
MessageBody: JSON.stringify({
|
|
33
|
-
type: message.type,
|
|
34
|
-
payload: message.payload
|
|
35
|
-
}),
|
|
36
|
-
MessageAttributes: { type: {
|
|
37
|
-
DataType: "String",
|
|
38
|
-
StringValue: message.type
|
|
39
|
-
} }
|
|
40
|
-
}));
|
|
41
|
-
const input = {
|
|
42
|
-
QueueUrl: this.connection.queueUrl,
|
|
43
|
-
Entries: entries
|
|
44
|
-
};
|
|
45
|
-
const command = new SendMessageBatchCommand(input);
|
|
46
|
-
const response = await this.connection.sqsClient.send(command);
|
|
47
|
-
if (response.Failed && response.Failed.length > 0) {
|
|
48
|
-
const errors = response.Failed.map((f) => `${f.Id}: ${f.Code} - ${f.Message}`).join(", ");
|
|
49
|
-
throw new Error(`Failed to send ${response.Failed.length} messages: ${errors}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async close() {}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
export { SQSPublisher };
|
|
57
|
-
//# sourceMappingURL=SQSPublisher-DG9o4ME3.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SQSPublisher-DG9o4ME3.mjs","names":["connection: SQSConnection","options: SQSPublisherOptions","connectionString: string","messages: TMessage[]","entries: SendMessageBatchRequestEntry[]","input: SendMessageBatchCommandInput"],"sources":["../src/sqs/SQSPublisher.ts"],"sourcesContent":["import {\n\tSendMessageBatchCommand,\n\ttype SendMessageBatchCommandInput,\n\ttype SendMessageBatchRequestEntry,\n} from '@aws-sdk/client-sqs';\nimport chunk from 'lodash.chunk';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport type { SQSConnection } from './SQSConnection';\n\nexport interface SQSPublisherOptions {\n\tmaxBatchSize?: number; // Default: 10 (SQS limit)\n}\n\nexport class SQSPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\treadonly options: Required<SQSPublisherOptions>;\n\n\tconstructor(\n\t\treadonly connection: SQSConnection,\n\t\toptions: SQSPublisherOptions = {},\n\t) {\n\t\tthis.options = {\n\t\t\tmaxBatchSize: options.maxBatchSize ?? 10, // SQS limit\n\t\t};\n\t}\n\n\t/**\n\t * Create an SQSPublisher from a connection string\n\t * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName®ion=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SQSPublisher<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { SQSConnection } = await import('./SQSConnection');\n\t\tconst connection =\n\t\t\tawait SQSConnection.fromConnectionString(connectionString);\n\n\t\tconst options: SQSPublisherOptions = {\n\t\t\tmaxBatchSize: params.get('maxBatchSize')\n\t\t\t\t? Number.parseInt(params.get('maxBatchSize')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new SQSPublisher<TMessage>(connection, options);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (messages.length === 0) return;\n\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\t// Split messages into batches (SQS limit is 10 messages per batch)\n\t\tconst batches = chunk(messages, this.options.maxBatchSize);\n\n\t\t// Send all batches\n\t\tawait Promise.all(batches.map((batch) => this.sendBatch(batch)));\n\t}\n\n\tprivate async sendBatch(messages: TMessage[]): Promise<void> {\n\t\tconst entries: SendMessageBatchRequestEntry[] = messages.map(\n\t\t\t(message, index) => ({\n\t\t\t\tId: `${index}`,\n\t\t\t\tMessageBody: JSON.stringify({\n\t\t\t\t\ttype: message.type,\n\t\t\t\t\tpayload: message.payload,\n\t\t\t\t}),\n\t\t\t\tMessageAttributes: {\n\t\t\t\t\ttype: {\n\t\t\t\t\t\tDataType: 'String',\n\t\t\t\t\t\tStringValue: message.type,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\n\t\tconst input: SendMessageBatchCommandInput = {\n\t\t\tQueueUrl: this.connection.queueUrl,\n\t\t\tEntries: entries,\n\t\t};\n\n\t\tconst command = new SendMessageBatchCommand(input);\n\t\tconst response = await this.connection.sqsClient.send(command);\n\n\t\t// Check for failures\n\t\tif (response.Failed && response.Failed.length > 0) {\n\t\t\tconst errors = response.Failed.map(\n\t\t\t\t(f) => `${f.Id}: ${f.Code} - ${f.Message}`,\n\t\t\t).join(', ');\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to send ${response.Failed.length} messages: ${errors}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t\t// Connection should be closed by whoever created it\n\t}\n}\n"],"mappings":";;;;AAaA,IAAa,eAAb,MAAa,aAEb;CACC,AAAS;CAET,YACUA,YACTC,UAA+B,CAAE,GAChC;EAFQ;AAGT,OAAK,UAAU,EACd,cAAc,QAAQ,gBAAgB,GACtC;CACD;;;;;CAMD,aAAa,qBAEXC,kBAA2D;EAC5D,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;EACvC,MAAM,aACL,MAAM,cAAc,qBAAqB,iBAAiB;EAE3D,MAAMD,UAA+B,EACpC,cAAc,OAAO,IAAI,eAAe,GACrC,OAAO,SAAS,OAAO,IAAI,eAAe,EAAG,GAAG,UAEnD;AAED,SAAO,IAAI,aAAuB,YAAY;CAC9C;CAED,MAAM,QAAQE,UAAqC;AAClD,MAAI,SAAS,WAAW,EAAG;AAE3B,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAIhC,MAAM,UAAU,MAAM,UAAU,KAAK,QAAQ,aAAa;AAG1D,QAAM,QAAQ,IAAI,QAAQ,IAAI,CAAC,UAAU,KAAK,UAAU,MAAM,CAAC,CAAC;CAChE;CAED,MAAc,UAAUA,UAAqC;EAC5D,MAAMC,UAA0C,SAAS,IACxD,CAAC,SAAS,WAAW;GACpB,KAAK,EAAE,MAAM;GACb,aAAa,KAAK,UAAU;IAC3B,MAAM,QAAQ;IACd,SAAS,QAAQ;GACjB,EAAC;GACF,mBAAmB,EAClB,MAAM;IACL,UAAU;IACV,aAAa,QAAQ;GACrB,EACD;EACD,GACD;EAED,MAAMC,QAAsC;GAC3C,UAAU,KAAK,WAAW;GAC1B,SAAS;EACT;EAED,MAAM,UAAU,IAAI,wBAAwB;EAC5C,MAAM,WAAW,MAAM,KAAK,WAAW,UAAU,KAAK,QAAQ;AAG9D,MAAI,SAAS,UAAU,SAAS,OAAO,SAAS,GAAG;GAClD,MAAM,SAAS,SAAS,OAAO,IAC9B,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,EAAE,QAAQ,EACzC,CAAC,KAAK,KAAK;AACZ,SAAM,IAAI,OACR,iBAAiB,SAAS,OAAO,OAAO,aAAa,OAAO;EAE9D;CACD;CAED,MAAM,QAAuB,CAG5B;AACD"}
|