@geekmidas/events 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +473 -0
  2. package/dist/BasicConnection-BNi6_olg.mjs +42 -0
  3. package/dist/BasicConnection-BNi6_olg.mjs.map +1 -0
  4. package/dist/BasicConnection-C4_Y0nIj.d.mts +26 -0
  5. package/dist/BasicConnection-CddnULuT.d.cts +26 -0
  6. package/dist/BasicConnection-CzfMubv_.cjs +48 -0
  7. package/dist/BasicConnection-CzfMubv_.cjs.map +1 -0
  8. package/dist/BasicPublisher-BzfzHIfb.cjs +20 -0
  9. package/dist/BasicPublisher-BzfzHIfb.cjs.map +1 -0
  10. package/dist/BasicPublisher-Cg3SxIVR.mjs +14 -0
  11. package/dist/BasicPublisher-Cg3SxIVR.mjs.map +1 -0
  12. package/dist/BasicPublisher-DCBxaTwC.d.mts +12 -0
  13. package/dist/BasicPublisher-V5hELHG9.d.cts +12 -0
  14. package/dist/BasicSubscriber-BB3aKeph.d.mts +12 -0
  15. package/dist/BasicSubscriber-BEv5N21f.mjs +18 -0
  16. package/dist/BasicSubscriber-BEv5N21f.mjs.map +1 -0
  17. package/dist/BasicSubscriber-DOwgFw5j.d.cts +12 -0
  18. package/dist/BasicSubscriber-DyTKOixe.cjs +24 -0
  19. package/dist/BasicSubscriber-DyTKOixe.cjs.map +1 -0
  20. package/dist/EventConnection-ClLMoIUU.mjs +36 -0
  21. package/dist/EventConnection-ClLMoIUU.mjs.map +1 -0
  22. package/dist/EventConnection-DZhn1Msl.d.cts +13 -0
  23. package/dist/EventConnection-DeXfLGom.d.mts +13 -0
  24. package/dist/EventConnection-F_N81SXu.cjs +41 -0
  25. package/dist/EventConnection-F_N81SXu.cjs.map +1 -0
  26. package/dist/EventConnection.cjs +5 -0
  27. package/dist/EventConnection.d.cts +3 -0
  28. package/dist/EventConnection.d.mts +3 -0
  29. package/dist/EventConnection.mjs +4 -0
  30. package/dist/Publisher-C3m8JFXm.d.mts +19 -0
  31. package/dist/Publisher-DS0aOh8r.mjs +65 -0
  32. package/dist/Publisher-DS0aOh8r.mjs.map +1 -0
  33. package/dist/Publisher-ceu6OxCj.cjs +70 -0
  34. package/dist/Publisher-ceu6OxCj.cjs.map +1 -0
  35. package/dist/Publisher-nXNVjL0e.d.cts +19 -0
  36. package/dist/Publisher.cjs +4 -0
  37. package/dist/Publisher.d.cts +3 -0
  38. package/dist/Publisher.d.mts +3 -0
  39. package/dist/Publisher.mjs +4 -0
  40. package/dist/RabbitMQConnection-7cWp_-_Q.d.cts +43 -0
  41. package/dist/RabbitMQConnection-BN_GybOv.cjs +113 -0
  42. package/dist/RabbitMQConnection-BN_GybOv.cjs.map +1 -0
  43. package/dist/RabbitMQConnection-C2HC7J7K.d.mts +43 -0
  44. package/dist/RabbitMQConnection-eVOVS4Dl.mjs +107 -0
  45. package/dist/RabbitMQConnection-eVOVS4Dl.mjs.map +1 -0
  46. package/dist/RabbitMQPublisher-BZX0edgL.mjs +39 -0
  47. package/dist/RabbitMQPublisher-BZX0edgL.mjs.map +1 -0
  48. package/dist/RabbitMQPublisher-CSCn6gMA.cjs +45 -0
  49. package/dist/RabbitMQPublisher-CSCn6gMA.cjs.map +1 -0
  50. package/dist/RabbitMQPublisher-CpcbgrXj.d.cts +23 -0
  51. package/dist/RabbitMQPublisher-DDZi15Ro.d.mts +23 -0
  52. package/dist/RabbitMQSubscriber-B5I-hBaT.mjs +57 -0
  53. package/dist/RabbitMQSubscriber-B5I-hBaT.mjs.map +1 -0
  54. package/dist/RabbitMQSubscriber-BJ9PTGny.d.cts +25 -0
  55. package/dist/RabbitMQSubscriber-CIvIw8MG.d.mts +25 -0
  56. package/dist/RabbitMQSubscriber-Cj7qLIi6.cjs +63 -0
  57. package/dist/RabbitMQSubscriber-Cj7qLIi6.cjs.map +1 -0
  58. package/dist/SNSConnection-CAImaMM2.d.mts +40 -0
  59. package/dist/SNSConnection-Cqbr7-Ho.d.cts +40 -0
  60. package/dist/SNSConnection-D7wCf9Si.mjs +70 -0
  61. package/dist/SNSConnection-D7wCf9Si.mjs.map +1 -0
  62. package/dist/SNSConnection-DVsC_pbB.cjs +76 -0
  63. package/dist/SNSConnection-DVsC_pbB.cjs.map +1 -0
  64. package/dist/SNSPublisher-BZ6N3JI9.cjs +48 -0
  65. package/dist/SNSPublisher-BZ6N3JI9.cjs.map +1 -0
  66. package/dist/SNSPublisher-BfWjzNiB.mjs +42 -0
  67. package/dist/SNSPublisher-BfWjzNiB.mjs.map +1 -0
  68. package/dist/SNSPublisher-Dkhb4LU-.d.mts +21 -0
  69. package/dist/SNSPublisher-RVZFa7kL.d.cts +21 -0
  70. package/dist/SNSSubscriber-B31JmkAE.d.mts +54 -0
  71. package/dist/SNSSubscriber-C9YJWa7m.mjs +143 -0
  72. package/dist/SNSSubscriber-C9YJWa7m.mjs.map +1 -0
  73. package/dist/SNSSubscriber-UE0ia4XM.cjs +149 -0
  74. package/dist/SNSSubscriber-UE0ia4XM.cjs.map +1 -0
  75. package/dist/SNSSubscriber-k2UwKUxu.d.cts +54 -0
  76. package/dist/SQSConnection-BwNjUPr4.cjs +76 -0
  77. package/dist/SQSConnection-BwNjUPr4.cjs.map +1 -0
  78. package/dist/SQSConnection-C5WFqZW7.d.mts +40 -0
  79. package/dist/SQSConnection-Eleqqre3.mjs +70 -0
  80. package/dist/SQSConnection-Eleqqre3.mjs.map +1 -0
  81. package/dist/SQSConnection-geav2Rsn.d.cts +40 -0
  82. package/dist/SQSPublisher-CdsayOLV.d.mts +23 -0
  83. package/dist/SQSPublisher-DG9o4ME3.mjs +57 -0
  84. package/dist/SQSPublisher-DG9o4ME3.mjs.map +1 -0
  85. package/dist/SQSPublisher-Dq5353oZ.cjs +63 -0
  86. package/dist/SQSPublisher-Dq5353oZ.cjs.map +1 -0
  87. package/dist/SQSPublisher-Utb_FTe5.d.cts +23 -0
  88. package/dist/SQSSubscriber-B6iL1EnX.d.cts +43 -0
  89. package/dist/SQSSubscriber-CD66P7hH.mjs +121 -0
  90. package/dist/SQSSubscriber-CD66P7hH.mjs.map +1 -0
  91. package/dist/SQSSubscriber-DBeE4XAR.d.mts +43 -0
  92. package/dist/SQSSubscriber-DZDNgLE5.cjs +127 -0
  93. package/dist/SQSSubscriber-DZDNgLE5.cjs.map +1 -0
  94. package/dist/Subscriber-Bd9hb_jp.mjs +74 -0
  95. package/dist/Subscriber-Bd9hb_jp.mjs.map +1 -0
  96. package/dist/Subscriber-Cff9EIpv.d.mts +19 -0
  97. package/dist/Subscriber-CpAwcUzb.d.cts +19 -0
  98. package/dist/Subscriber-saVOWuMq.cjs +79 -0
  99. package/dist/Subscriber-saVOWuMq.cjs.map +1 -0
  100. package/dist/Subscriber.cjs +4 -0
  101. package/dist/Subscriber.d.cts +3 -0
  102. package/dist/Subscriber.d.mts +3 -0
  103. package/dist/Subscriber.mjs +4 -0
  104. package/dist/basic/BasicConnection.cjs +4 -0
  105. package/dist/basic/BasicConnection.d.cts +3 -0
  106. package/dist/basic/BasicConnection.d.mts +3 -0
  107. package/dist/basic/BasicConnection.mjs +4 -0
  108. package/dist/basic/BasicPublisher.cjs +3 -0
  109. package/dist/basic/BasicPublisher.d.cts +4 -0
  110. package/dist/basic/BasicPublisher.d.mts +4 -0
  111. package/dist/basic/BasicPublisher.mjs +3 -0
  112. package/dist/basic/BasicSubscriber.cjs +3 -0
  113. package/dist/basic/BasicSubscriber.d.cts +4 -0
  114. package/dist/basic/BasicSubscriber.d.mts +4 -0
  115. package/dist/basic/BasicSubscriber.mjs +3 -0
  116. package/dist/basic/index.cjs +8 -0
  117. package/dist/basic/index.d.cts +5 -0
  118. package/dist/basic/index.d.mts +5 -0
  119. package/dist/basic/index.mjs +6 -0
  120. package/dist/chunk-CUT6urMc.cjs +30 -0
  121. package/dist/index.cjs +9 -0
  122. package/dist/index.d.cts +5 -0
  123. package/dist/index.d.mts +5 -0
  124. package/dist/index.mjs +6 -0
  125. package/dist/rabbitmq/RabbitMQConnection.cjs +4 -0
  126. package/dist/rabbitmq/RabbitMQConnection.d.cts +3 -0
  127. package/dist/rabbitmq/RabbitMQConnection.d.mts +3 -0
  128. package/dist/rabbitmq/RabbitMQConnection.mjs +4 -0
  129. package/dist/rabbitmq/RabbitMQPublisher.cjs +3 -0
  130. package/dist/rabbitmq/RabbitMQPublisher.d.cts +4 -0
  131. package/dist/rabbitmq/RabbitMQPublisher.d.mts +4 -0
  132. package/dist/rabbitmq/RabbitMQPublisher.mjs +3 -0
  133. package/dist/rabbitmq/RabbitMQSubscriber.cjs +3 -0
  134. package/dist/rabbitmq/RabbitMQSubscriber.d.cts +4 -0
  135. package/dist/rabbitmq/RabbitMQSubscriber.d.mts +4 -0
  136. package/dist/rabbitmq/RabbitMQSubscriber.mjs +3 -0
  137. package/dist/rabbitmq/index.cjs +8 -0
  138. package/dist/rabbitmq/index.d.cts +5 -0
  139. package/dist/rabbitmq/index.d.mts +5 -0
  140. package/dist/rabbitmq/index.mjs +6 -0
  141. package/dist/sns/SNSConnection.cjs +4 -0
  142. package/dist/sns/SNSConnection.d.cts +3 -0
  143. package/dist/sns/SNSConnection.d.mts +3 -0
  144. package/dist/sns/SNSConnection.mjs +4 -0
  145. package/dist/sns/SNSPublisher.cjs +3 -0
  146. package/dist/sns/SNSPublisher.d.cts +4 -0
  147. package/dist/sns/SNSPublisher.d.mts +4 -0
  148. package/dist/sns/SNSPublisher.mjs +3 -0
  149. package/dist/sns/SNSSubscriber.cjs +6 -0
  150. package/dist/sns/SNSSubscriber.d.cts +4 -0
  151. package/dist/sns/SNSSubscriber.d.mts +4 -0
  152. package/dist/sns/SNSSubscriber.mjs +6 -0
  153. package/dist/sns/index.cjs +10 -0
  154. package/dist/sns/index.d.cts +5 -0
  155. package/dist/sns/index.d.mts +5 -0
  156. package/dist/sns/index.mjs +8 -0
  157. package/dist/sqs/SQSConnection.cjs +4 -0
  158. package/dist/sqs/SQSConnection.d.cts +3 -0
  159. package/dist/sqs/SQSConnection.d.mts +3 -0
  160. package/dist/sqs/SQSConnection.mjs +4 -0
  161. package/dist/sqs/SQSPublisher.cjs +3 -0
  162. package/dist/sqs/SQSPublisher.d.cts +4 -0
  163. package/dist/sqs/SQSPublisher.d.mts +4 -0
  164. package/dist/sqs/SQSPublisher.mjs +3 -0
  165. package/dist/sqs/SQSSubscriber.cjs +3 -0
  166. package/dist/sqs/SQSSubscriber.d.cts +4 -0
  167. package/dist/sqs/SQSSubscriber.d.mts +4 -0
  168. package/dist/sqs/SQSSubscriber.mjs +3 -0
  169. package/dist/sqs/index.cjs +8 -0
  170. package/dist/sqs/index.d.cts +5 -0
  171. package/dist/sqs/index.d.mts +5 -0
  172. package/dist/sqs/index.mjs +6 -0
  173. package/dist/types-B63qHVOG.mjs +17 -0
  174. package/dist/types-B63qHVOG.mjs.map +1 -0
  175. package/dist/types-CvSMEO5z.cjs +23 -0
  176. package/dist/types-CvSMEO5z.cjs.map +1 -0
  177. package/dist/types-D0g-o6wX.d.mts +65 -0
  178. package/dist/types-DEGUg5BA.d.cts +65 -0
  179. package/dist/types.cjs +3 -0
  180. package/dist/types.d.cts +2 -0
  181. package/dist/types.d.mts +2 -0
  182. package/dist/types.mjs +3 -0
  183. package/package.json +49 -0
  184. package/src/EventConnection.ts +39 -0
  185. package/src/Publisher.ts +87 -0
  186. package/src/Subscriber.ts +102 -0
  187. package/src/__tests__/Subscriber.spec.ts +41 -0
  188. package/src/basic/BasicConnection.ts +47 -0
  189. package/src/basic/BasicPublisher.ts +15 -0
  190. package/src/basic/BasicSubscriber.ts +24 -0
  191. package/src/basic/__tests__/BasicSubscriber.spec.ts +166 -0
  192. package/src/basic/index.ts +3 -0
  193. package/src/index.ts +25 -0
  194. package/src/rabbitmq/RabbitMQConnection.ts +148 -0
  195. package/src/rabbitmq/RabbitMQPublisher.ts +67 -0
  196. package/src/rabbitmq/RabbitMQSubscriber.ts +113 -0
  197. package/src/rabbitmq/__tests__/RabbitMQPublisher.spec.ts +378 -0
  198. package/src/rabbitmq/__tests__/RabbitMQSubscriber.spec.ts +292 -0
  199. package/src/rabbitmq/index.ts +6 -0
  200. package/src/sns/SNSConnection.ts +98 -0
  201. package/src/sns/SNSPublisher.ts +64 -0
  202. package/src/sns/SNSSubscriber.ts +222 -0
  203. package/src/sns/__tests__/SNS-SQS-Integration.spec.ts +389 -0
  204. package/src/sns/index.ts +6 -0
  205. package/src/sqs/SQSConnection.ts +97 -0
  206. package/src/sqs/SQSPublisher.ts +105 -0
  207. package/src/sqs/SQSSubscriber.ts +189 -0
  208. package/src/sqs/__tests__/SQSPublisher.spec.ts +189 -0
  209. package/src/sqs/index.ts +6 -0
  210. package/src/types.ts +76 -0
  211. package/tsdown.config.ts +5 -0
@@ -0,0 +1,149 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const require_SQSConnection = require('./SQSConnection-BwNjUPr4.cjs');
3
+ const require_SQSSubscriber = require('./SQSSubscriber-DZDNgLE5.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&region=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
+ console.error("Error unsubscribing:", error);
91
+ }
92
+ if (this.queueUrl && this.options.deleteQueueOnClose) try {
93
+ const command = new __aws_sdk_client_sqs.DeleteQueueCommand({ QueueUrl: this.queueUrl });
94
+ await this.sqsClient.send(command);
95
+ } catch (error) {
96
+ console.error("Error deleting queue:", error);
97
+ }
98
+ this.sqsClient.destroy();
99
+ }
100
+ async setupQueue() {
101
+ if (this.options.createQueue) {
102
+ const createCommand = new __aws_sdk_client_sqs.CreateQueueCommand({ QueueName: this.options.queueName });
103
+ const response = await this.sqsClient.send(createCommand);
104
+ this.queueUrl = response.QueueUrl;
105
+ } else throw new Error("Queue must exist or createQueue option must be true");
106
+ const attrsCommand = new __aws_sdk_client_sqs.GetQueueAttributesCommand({
107
+ QueueUrl: this.queueUrl,
108
+ AttributeNames: ["QueueArn"]
109
+ });
110
+ const attrsResponse = await this.sqsClient.send(attrsCommand);
111
+ this.queueArn = attrsResponse.Attributes?.QueueArn;
112
+ await this.setQueuePolicy();
113
+ }
114
+ async setQueuePolicy() {
115
+ const policy = {
116
+ Version: "2012-10-17",
117
+ Statement: [{
118
+ Effect: "Allow",
119
+ Principal: "*",
120
+ Action: "SQS:SendMessage",
121
+ Resource: this.queueArn,
122
+ Condition: { ArnEquals: { "aws:SourceArn": this.connection.topicArn } }
123
+ }]
124
+ };
125
+ const command = new __aws_sdk_client_sqs.SetQueueAttributesCommand({
126
+ QueueUrl: this.queueUrl,
127
+ Attributes: { Policy: JSON.stringify(policy) }
128
+ });
129
+ await this.sqsClient.send(command);
130
+ }
131
+ async subscribeToTopic() {
132
+ const command = new __aws_sdk_client_sns.SubscribeCommand({
133
+ TopicArn: this.connection.topicArn,
134
+ Protocol: "sqs",
135
+ Endpoint: this.queueArn
136
+ });
137
+ const response = await this.connection.snsClient.send(command);
138
+ this.subscriptionArn = response.SubscriptionArn;
139
+ }
140
+ };
141
+
142
+ //#endregion
143
+ Object.defineProperty(exports, 'SNSSubscriber', {
144
+ enumerable: true,
145
+ get: function () {
146
+ return SNSSubscriber;
147
+ }
148
+ });
149
+ //# sourceMappingURL=SNSSubscriber-UE0ia4XM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SNSSubscriber-UE0ia4XM.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 CreateQueueCommand,\n DeleteQueueCommand,\n GetQueueAttributesCommand,\n SQSClient,\n SetQueueAttributesCommand,\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 queueName?: string; // Optional queue name (defaults to auto-generated)\n createQueue?: boolean; // Auto-create SQS queue (default: true)\n deleteQueueOnClose?: boolean; // Delete queue when subscriber closes (default: false for named queues, true for auto-generated)\n waitTimeSeconds?: number; // SQS long polling (default: 20)\n maxMessages?: 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 implements EventSubscriber<TMessage>\n{\n private sqsClient: SQSClient;\n private queueUrl?: string;\n private queueArn?: string;\n private subscriptionArn?: string;\n private sqsSubscriber?: SQSSubscriber<TMessage>;\n private options: Required<SNSSubscriberOptions>;\n\n constructor(\n private connection: SNSConnection,\n options: SNSSubscriberOptions = {},\n ) {\n this.options = {\n queueName:\n options.queueName ||\n `sns-sub-${Date.now()}-${Math.random().toString(36).substring(7)}`,\n createQueue: options.createQueue ?? true,\n deleteQueueOnClose: options.deleteQueueOnClose ?? !options.queueName, // Delete auto-generated queues\n waitTimeSeconds: options.waitTimeSeconds ?? 20,\n maxMessages: options.maxMessages ?? 10,\n };\n\n // Create SQS client with same config as SNS\n this.sqsClient = new SQSClient({\n region: (this.connection as any).config.region,\n endpoint: (this.connection as any).config.endpoint,\n credentials: (this.connection as any).config.credentials,\n });\n }\n\n /**\n * Create an SNSSubscriber from a connection string\n * Format: sns://?topicArn=...&queueName=myqueue&region=us-east-1\n */\n static async fromConnectionString<\n TMessage extends PublishableMessage<string, any>,\n >(connectionString: string): Promise<SNSSubscriber<TMessage>> {\n const url = new URL(connectionString);\n const params = url.searchParams;\n\n const { SNSConnection } = await import('./SNSConnection');\n const connection =\n await SNSConnection.fromConnectionString(connectionString);\n\n const options: SNSSubscriberOptions = {\n queueName: params.get('queueName') || undefined,\n createQueue: params.get('createQueue') !== 'false',\n deleteQueueOnClose: params.get('deleteQueueOnClose') === 'true',\n waitTimeSeconds: params.get('waitTimeSeconds')\n ? Number.parseInt(params.get('waitTimeSeconds')!, 10)\n : undefined,\n };\n\n return new SNSSubscriber<TMessage>(connection, options);\n }\n\n async subscribe(\n messages: TMessage['type'][],\n listener: (payload: TMessage) => Promise<void>,\n ): Promise<void> {\n // Setup SQS queue and SNS subscription\n await this.setupQueue();\n await this.subscribeToTopic();\n\n // Create SQS connection for the subscriber\n const sqsConnection = new SQSConnection({\n queueUrl: this.queueUrl!,\n region: (this.connection as any).config.region,\n endpoint: (this.connection as any).config.endpoint,\n credentials: (this.connection as any).config.credentials,\n });\n await sqsConnection.connect();\n\n // Use SQSSubscriber to receive messages, with topic filtering\n this.sqsSubscriber = new SQSSubscriber<TMessage>(sqsConnection, {\n waitTimeSeconds: this.options.waitTimeSeconds,\n maxMessages: this.options.maxMessages,\n expectedTopicArn: this.connection.topicArn,\n });\n\n await this.sqsSubscriber.subscribe(messages, listener);\n }\n\n /**\n * Stop receiving messages and clean up resources\n */\n async stop(): Promise<void> {\n // Stop SQS subscriber\n if (this.sqsSubscriber) {\n this.sqsSubscriber.stop();\n }\n\n // Unsubscribe from topic\n if (this.subscriptionArn) {\n try {\n const command = new UnsubscribeCommand({\n SubscriptionArn: this.subscriptionArn,\n });\n await this.connection.snsClient.send(command);\n } catch (error) {\n console.error('Error unsubscribing:', error);\n }\n }\n\n // Delete queue if configured\n if (this.queueUrl && this.options.deleteQueueOnClose) {\n try {\n const command = new DeleteQueueCommand({\n QueueUrl: this.queueUrl,\n });\n await this.sqsClient.send(command);\n } catch (error) {\n console.error('Error deleting queue:', error);\n }\n }\n\n this.sqsClient.destroy();\n }\n\n private async setupQueue(): Promise<void> {\n if (this.options.createQueue) {\n // Create queue\n const createCommand = new CreateQueueCommand({\n QueueName: this.options.queueName,\n });\n const response = await this.sqsClient.send(createCommand);\n this.queueUrl = response.QueueUrl!;\n } else {\n throw new Error('Queue must exist or createQueue option must be true');\n }\n\n // Get queue ARN\n const attrsCommand = new GetQueueAttributesCommand({\n QueueUrl: this.queueUrl,\n AttributeNames: ['QueueArn'],\n });\n const attrsResponse = await this.sqsClient.send(attrsCommand);\n this.queueArn = attrsResponse.Attributes?.QueueArn!;\n\n // Set queue policy to allow SNS\n await this.setQueuePolicy();\n }\n\n private async setQueuePolicy(): Promise<void> {\n const policy = {\n Version: '2012-10-17',\n Statement: [\n {\n Effect: 'Allow',\n Principal: '*',\n Action: 'SQS:SendMessage',\n Resource: this.queueArn,\n Condition: {\n ArnEquals: {\n 'aws:SourceArn': this.connection.topicArn,\n },\n },\n },\n ],\n };\n\n const command = new SetQueueAttributesCommand({\n QueueUrl: this.queueUrl,\n Attributes: {\n Policy: JSON.stringify(policy),\n },\n });\n\n await this.sqsClient.send(command);\n }\n\n private async subscribeToTopic(): Promise<void> {\n const command = new SubscribeCommand({\n TopicArn: this.connection.topicArn,\n Protocol: 'sqs',\n Endpoint: this.queueArn,\n });\n\n const response = await this.connection.snsClient.send(command);\n this.subscriptionArn = response.SubscriptionArn!;\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,54 @@
1
+ import { EventSubscriber, PublishableMessage } from "./types-DEGUg5BA.cjs";
2
+ import { SNSConnection } from "./SNSConnection-Cqbr7-Ho.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&region=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
+ //#endregion
53
+ export { SNSSubscriber, SNSSubscriberOptions };
54
+ //# sourceMappingURL=SNSSubscriber-k2UwKUxu.d.cts.map
@@ -0,0 +1,76 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const require_types = require('./types-CvSMEO5z.cjs');
3
+ const __aws_sdk_client_sqs = require_chunk.__toESM(require("@aws-sdk/client-sqs"));
4
+
5
+ //#region src/sqs/SQSConnection.ts
6
+ var SQSConnection = class SQSConnection {
7
+ type = require_types.EventPublisherType.SQS;
8
+ client;
9
+ connected = false;
10
+ constructor(config) {
11
+ this.config = config;
12
+ this.config = config;
13
+ const clientConfig = {
14
+ region: config.region,
15
+ endpoint: config.endpoint,
16
+ credentials: config.credentials
17
+ };
18
+ this.client = new __aws_sdk_client_sqs.SQSClient(clientConfig);
19
+ }
20
+ /**
21
+ * Create an SQSConnection from a connection string
22
+ * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566
23
+ */
24
+ static async fromConnectionString(connectionString) {
25
+ const url = new URL(connectionString);
26
+ const params = url.searchParams;
27
+ const queueUrl = params.get("queueUrl");
28
+ if (!queueUrl) throw new Error("queueUrl parameter is required in connection string");
29
+ const config = {
30
+ queueUrl,
31
+ region: params.get("region") || void 0,
32
+ endpoint: params.get("endpoint") || void 0
33
+ };
34
+ const accessKeyId = params.get("accessKeyId");
35
+ const secretAccessKey = params.get("secretAccessKey");
36
+ if (accessKeyId && secretAccessKey) config.credentials = {
37
+ accessKeyId,
38
+ secretAccessKey,
39
+ sessionToken: params.get("sessionToken") || void 0
40
+ };
41
+ const connection = new SQSConnection(config);
42
+ await connection.connect();
43
+ return connection;
44
+ }
45
+ async connect() {
46
+ this.connected = true;
47
+ }
48
+ async close() {
49
+ this.client.destroy();
50
+ this.connected = false;
51
+ }
52
+ isConnected() {
53
+ return this.connected;
54
+ }
55
+ /**
56
+ * Get the underlying SQS client
57
+ */
58
+ get sqsClient() {
59
+ return this.client;
60
+ }
61
+ /**
62
+ * Get the queue URL for this connection
63
+ */
64
+ get queueUrl() {
65
+ return this.config.queueUrl;
66
+ }
67
+ };
68
+
69
+ //#endregion
70
+ Object.defineProperty(exports, 'SQSConnection', {
71
+ enumerable: true,
72
+ get: function () {
73
+ return SQSConnection;
74
+ }
75
+ });
76
+ //# sourceMappingURL=SQSConnection-BwNjUPr4.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SQSConnection-BwNjUPr4.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 queueUrl: string;\n region?: string;\n endpoint?: string; // Custom endpoint (e.g., for LocalStack)\n credentials?: {\n accessKeyId: string;\n secretAccessKey: string;\n sessionToken?: string;\n };\n}\n\nexport class SQSConnection implements EventConnection {\n readonly type = EventPublisherType.SQS;\n private client: SQSClient;\n private connected = false;\n\n constructor(readonly config: SQSConnectionConfig) {\n this.config = config;\n\n const clientConfig: SQSClientConfig = {\n region: config.region,\n endpoint: config.endpoint,\n credentials: config.credentials,\n };\n\n this.client = new SQSClient(clientConfig);\n }\n\n /**\n * Create an SQSConnection from a connection string\n * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566\n */\n static async fromConnectionString(\n connectionString: string,\n ): Promise<SQSConnection> {\n const url = new URL(connectionString);\n const params = url.searchParams;\n\n const queueUrl = params.get('queueUrl');\n if (!queueUrl) {\n throw new Error('queueUrl parameter is required in connection string');\n }\n\n const config: SQSConnectionConfig = {\n queueUrl,\n region: params.get('region') || undefined,\n endpoint: params.get('endpoint') || undefined,\n };\n\n // Parse credentials if provided\n const accessKeyId = params.get('accessKeyId');\n const secretAccessKey = params.get('secretAccessKey');\n if (accessKeyId && secretAccessKey) {\n config.credentials = {\n accessKeyId,\n secretAccessKey,\n sessionToken: params.get('sessionToken') || undefined,\n };\n }\n\n const connection = new SQSConnection(config);\n await connection.connect();\n return connection;\n }\n\n async connect(): Promise<void> {\n // SQS doesn't have a traditional connection, but we mark as connected\n this.connected = true;\n }\n\n async close(): Promise<void> {\n this.client.destroy();\n this.connected = false;\n }\n\n isConnected(): boolean {\n return this.connected;\n }\n\n /**\n * Get the underlying SQS client\n */\n get sqsClient(): SQSClient {\n return this.client;\n }\n\n /**\n * Get the queue URL for this connection\n */\n get queueUrl(): string {\n return this.config.queueUrl;\n }\n}\n"],"mappings":";;;;;AAeA,IAAa,gBAAb,MAAa,cAAyC;CACpD,AAAS,OAAOA,iCAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CAEpB,YAAqBC,QAA6B;EAA7B;AACnB,OAAK,SAAS;EAEd,MAAMC,eAAgC;GACpC,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,aAAa,OAAO;EACrB;AAED,OAAK,SAAS,IAAIC,+BAAU;CAC7B;;;;;CAMD,aAAa,qBACXC,kBACwB;EACxB,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,WAAW,OAAO,IAAI,WAAW;AACvC,OAAK,SACH,OAAM,IAAI,MAAM;EAGlB,MAAMH,SAA8B;GAClC;GACA,QAAQ,OAAO,IAAI,SAAS;GAC5B,UAAU,OAAO,IAAI,WAAW;EACjC;EAGD,MAAM,cAAc,OAAO,IAAI,cAAc;EAC7C,MAAM,kBAAkB,OAAO,IAAI,kBAAkB;AACrD,MAAI,eAAe,gBACjB,QAAO,cAAc;GACnB;GACA;GACA,cAAc,OAAO,IAAI,eAAe;EACzC;EAGH,MAAM,aAAa,IAAI,cAAc;AACrC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACR;CAED,MAAM,UAAyB;AAE7B,OAAK,YAAY;CAClB;CAED,MAAM,QAAuB;AAC3B,OAAK,OAAO,SAAS;AACrB,OAAK,YAAY;CAClB;CAED,cAAuB;AACrB,SAAO,KAAK;CACb;;;;CAKD,IAAI,YAAuB;AACzB,SAAO,KAAK;CACb;;;;CAKD,IAAI,WAAmB;AACrB,SAAO,KAAK,OAAO;CACpB;AACF"}
@@ -0,0 +1,40 @@
1
+ import { EventConnection, EventPublisherType } from "./types-D0g-o6wX.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&region=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
+ //#endregion
39
+ export { SQSConnection, SQSConnectionConfig };
40
+ //# sourceMappingURL=SQSConnection-C5WFqZW7.d.mts.map
@@ -0,0 +1,70 @@
1
+ import { EventPublisherType } from "./types-B63qHVOG.mjs";
2
+ import { SQSClient } from "@aws-sdk/client-sqs";
3
+
4
+ //#region src/sqs/SQSConnection.ts
5
+ var SQSConnection = class SQSConnection {
6
+ type = EventPublisherType.SQS;
7
+ client;
8
+ connected = false;
9
+ constructor(config) {
10
+ this.config = config;
11
+ this.config = config;
12
+ const clientConfig = {
13
+ region: config.region,
14
+ endpoint: config.endpoint,
15
+ credentials: config.credentials
16
+ };
17
+ this.client = new SQSClient(clientConfig);
18
+ }
19
+ /**
20
+ * Create an SQSConnection from a connection string
21
+ * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566
22
+ */
23
+ static async fromConnectionString(connectionString) {
24
+ const url = new URL(connectionString);
25
+ const params = url.searchParams;
26
+ const queueUrl = params.get("queueUrl");
27
+ if (!queueUrl) throw new Error("queueUrl parameter is required in connection string");
28
+ const config = {
29
+ queueUrl,
30
+ region: params.get("region") || void 0,
31
+ endpoint: params.get("endpoint") || void 0
32
+ };
33
+ const accessKeyId = params.get("accessKeyId");
34
+ const secretAccessKey = params.get("secretAccessKey");
35
+ if (accessKeyId && secretAccessKey) config.credentials = {
36
+ accessKeyId,
37
+ secretAccessKey,
38
+ sessionToken: params.get("sessionToken") || void 0
39
+ };
40
+ const connection = new SQSConnection(config);
41
+ await connection.connect();
42
+ return connection;
43
+ }
44
+ async connect() {
45
+ this.connected = true;
46
+ }
47
+ async close() {
48
+ this.client.destroy();
49
+ this.connected = false;
50
+ }
51
+ isConnected() {
52
+ return this.connected;
53
+ }
54
+ /**
55
+ * Get the underlying SQS client
56
+ */
57
+ get sqsClient() {
58
+ return this.client;
59
+ }
60
+ /**
61
+ * Get the queue URL for this connection
62
+ */
63
+ get queueUrl() {
64
+ return this.config.queueUrl;
65
+ }
66
+ };
67
+
68
+ //#endregion
69
+ export { SQSConnection };
70
+ //# sourceMappingURL=SQSConnection-Eleqqre3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SQSConnection-Eleqqre3.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 queueUrl: string;\n region?: string;\n endpoint?: string; // Custom endpoint (e.g., for LocalStack)\n credentials?: {\n accessKeyId: string;\n secretAccessKey: string;\n sessionToken?: string;\n };\n}\n\nexport class SQSConnection implements EventConnection {\n readonly type = EventPublisherType.SQS;\n private client: SQSClient;\n private connected = false;\n\n constructor(readonly config: SQSConnectionConfig) {\n this.config = config;\n\n const clientConfig: SQSClientConfig = {\n region: config.region,\n endpoint: config.endpoint,\n credentials: config.credentials,\n };\n\n this.client = new SQSClient(clientConfig);\n }\n\n /**\n * Create an SQSConnection from a connection string\n * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566\n */\n static async fromConnectionString(\n connectionString: string,\n ): Promise<SQSConnection> {\n const url = new URL(connectionString);\n const params = url.searchParams;\n\n const queueUrl = params.get('queueUrl');\n if (!queueUrl) {\n throw new Error('queueUrl parameter is required in connection string');\n }\n\n const config: SQSConnectionConfig = {\n queueUrl,\n region: params.get('region') || undefined,\n endpoint: params.get('endpoint') || undefined,\n };\n\n // Parse credentials if provided\n const accessKeyId = params.get('accessKeyId');\n const secretAccessKey = params.get('secretAccessKey');\n if (accessKeyId && secretAccessKey) {\n config.credentials = {\n accessKeyId,\n secretAccessKey,\n sessionToken: params.get('sessionToken') || undefined,\n };\n }\n\n const connection = new SQSConnection(config);\n await connection.connect();\n return connection;\n }\n\n async connect(): Promise<void> {\n // SQS doesn't have a traditional connection, but we mark as connected\n this.connected = true;\n }\n\n async close(): Promise<void> {\n this.client.destroy();\n this.connected = false;\n }\n\n isConnected(): boolean {\n return this.connected;\n }\n\n /**\n * Get the underlying SQS client\n */\n get sqsClient(): SQSClient {\n return this.client;\n }\n\n /**\n * Get the queue URL for this connection\n */\n get queueUrl(): string {\n return this.config.queueUrl;\n }\n}\n"],"mappings":";;;;AAeA,IAAa,gBAAb,MAAa,cAAyC;CACpD,AAAS,OAAO,mBAAmB;CACnC,AAAQ;CACR,AAAQ,YAAY;CAEpB,YAAqBA,QAA6B;EAA7B;AACnB,OAAK,SAAS;EAEd,MAAMC,eAAgC;GACpC,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,aAAa,OAAO;EACrB;AAED,OAAK,SAAS,IAAI,UAAU;CAC7B;;;;;CAMD,aAAa,qBACXC,kBACwB;EACxB,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,WAAW,OAAO,IAAI,WAAW;AACvC,OAAK,SACH,OAAM,IAAI,MAAM;EAGlB,MAAMF,SAA8B;GAClC;GACA,QAAQ,OAAO,IAAI,SAAS;GAC5B,UAAU,OAAO,IAAI,WAAW;EACjC;EAGD,MAAM,cAAc,OAAO,IAAI,cAAc;EAC7C,MAAM,kBAAkB,OAAO,IAAI,kBAAkB;AACrD,MAAI,eAAe,gBACjB,QAAO,cAAc;GACnB;GACA;GACA,cAAc,OAAO,IAAI,eAAe;EACzC;EAGH,MAAM,aAAa,IAAI,cAAc;AACrC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACR;CAED,MAAM,UAAyB;AAE7B,OAAK,YAAY;CAClB;CAED,MAAM,QAAuB;AAC3B,OAAK,OAAO,SAAS;AACrB,OAAK,YAAY;CAClB;CAED,cAAuB;AACrB,SAAO,KAAK;CACb;;;;CAKD,IAAI,YAAuB;AACzB,SAAO,KAAK;CACb;;;;CAKD,IAAI,WAAmB;AACrB,SAAO,KAAK,OAAO;CACpB;AACF"}
@@ -0,0 +1,40 @@
1
+ import { EventConnection, EventPublisherType } from "./types-DEGUg5BA.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&region=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
+ //#endregion
39
+ export { SQSConnection, SQSConnectionConfig };
40
+ //# sourceMappingURL=SQSConnection-geav2Rsn.d.cts.map
@@ -0,0 +1,23 @@
1
+ import { EventPublisher, PublishableMessage } from "./types-D0g-o6wX.mjs";
2
+ import { SQSConnection } from "./SQSConnection-C5WFqZW7.mjs";
3
+
4
+ //#region src/sqs/SQSPublisher.d.ts
5
+ interface SQSPublisherOptions {
6
+ maxBatchSize?: number;
7
+ }
8
+ declare class SQSPublisher<TMessage extends PublishableMessage<string, any>> implements EventPublisher<TMessage> {
9
+ readonly connection: SQSConnection;
10
+ readonly options: Required<SQSPublisherOptions>;
11
+ constructor(connection: SQSConnection, options?: SQSPublisherOptions);
12
+ /**
13
+ * Create an SQSPublisher from a connection string
14
+ * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10
15
+ */
16
+ static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string): Promise<SQSPublisher<TMessage>>;
17
+ publish(messages: TMessage[]): Promise<void>;
18
+ private sendBatch;
19
+ close(): Promise<void>;
20
+ }
21
+ //#endregion
22
+ export { SQSPublisher, SQSPublisherOptions };
23
+ //# sourceMappingURL=SQSPublisher-CdsayOLV.d.mts.map
@@ -0,0 +1,57 @@
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&region=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
@@ -0,0 +1 @@
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 SendMessageBatchCommand,\n type SendMessageBatchCommandInput,\n type 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 maxBatchSize?: number; // Default: 10 (SQS limit)\n}\n\nexport class SQSPublisher<TMessage extends PublishableMessage<string, any>>\n implements EventPublisher<TMessage>\n{\n readonly options: Required<SQSPublisherOptions>;\n\n constructor(\n readonly connection: SQSConnection,\n options: SQSPublisherOptions = {},\n ) {\n this.options = {\n maxBatchSize: options.maxBatchSize ?? 10, // SQS limit\n };\n }\n\n /**\n * Create an SQSPublisher from a connection string\n * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10\n */\n static async fromConnectionString<\n TMessage extends PublishableMessage<string, any>,\n >(connectionString: string): Promise<SQSPublisher<TMessage>> {\n const url = new URL(connectionString);\n const params = url.searchParams;\n\n const { SQSConnection } = await import('./SQSConnection');\n const connection =\n await SQSConnection.fromConnectionString(connectionString);\n\n const options: SQSPublisherOptions = {\n maxBatchSize: params.get('maxBatchSize')\n ? Number.parseInt(params.get('maxBatchSize')!, 10)\n : undefined,\n };\n\n return new SQSPublisher<TMessage>(connection, options);\n }\n\n async publish(messages: TMessage[]): Promise<void> {\n if (messages.length === 0) return;\n\n if (!this.connection.isConnected()) {\n await this.connection.connect();\n }\n\n // Split messages into batches (SQS limit is 10 messages per batch)\n const batches = chunk(messages, this.options.maxBatchSize);\n\n // Send all batches\n await Promise.all(batches.map((batch) => this.sendBatch(batch)));\n }\n\n private async sendBatch(messages: TMessage[]): Promise<void> {\n const entries: SendMessageBatchRequestEntry[] = messages.map(\n (message, index) => ({\n Id: `${index}`,\n MessageBody: JSON.stringify({\n type: message.type,\n payload: message.payload,\n }),\n MessageAttributes: {\n type: {\n DataType: 'String',\n StringValue: message.type,\n },\n },\n }),\n );\n\n const input: SendMessageBatchCommandInput = {\n QueueUrl: this.connection.queueUrl,\n Entries: entries,\n };\n\n const command = new SendMessageBatchCommand(input);\n const response = await this.connection.sqsClient.send(command);\n\n // Check for failures\n if (response.Failed && response.Failed.length > 0) {\n const errors = response.Failed.map(\n (f) => `${f.Id}: ${f.Code} - ${f.Message}`,\n ).join(', ');\n throw new Error(\n `Failed to send ${response.Failed.length} messages: ${errors}`,\n );\n }\n }\n\n async close(): Promise<void> {\n // Publisher doesn't own the connection\n // Connection should be closed by whoever created it\n }\n}\n"],"mappings":";;;;AAaA,IAAa,eAAb,MAAa,aAEb;CACE,AAAS;CAET,YACWA,YACTC,UAA+B,CAAE,GACjC;EAFS;AAGT,OAAK,UAAU,EACb,cAAc,QAAQ,gBAAgB,GACvC;CACF;;;;;CAMD,aAAa,qBAEXC,kBAA2D;EAC3D,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;EACvC,MAAM,aACJ,MAAM,cAAc,qBAAqB,iBAAiB;EAE5D,MAAMD,UAA+B,EACnC,cAAc,OAAO,IAAI,eAAe,GACpC,OAAO,SAAS,OAAO,IAAI,eAAe,EAAG,GAAG,UAErD;AAED,SAAO,IAAI,aAAuB,YAAY;CAC/C;CAED,MAAM,QAAQE,UAAqC;AACjD,MAAI,SAAS,WAAW,EAAG;AAE3B,OAAK,KAAK,WAAW,aAAa,CAChC,OAAM,KAAK,WAAW,SAAS;EAIjC,MAAM,UAAU,MAAM,UAAU,KAAK,QAAQ,aAAa;AAG1D,QAAM,QAAQ,IAAI,QAAQ,IAAI,CAAC,UAAU,KAAK,UAAU,MAAM,CAAC,CAAC;CACjE;CAED,MAAc,UAAUA,UAAqC;EAC3D,MAAMC,UAA0C,SAAS,IACvD,CAAC,SAAS,WAAW;GACnB,KAAK,EAAE,MAAM;GACb,aAAa,KAAK,UAAU;IAC1B,MAAM,QAAQ;IACd,SAAS,QAAQ;GAClB,EAAC;GACF,mBAAmB,EACjB,MAAM;IACJ,UAAU;IACV,aAAa,QAAQ;GACtB,EACF;EACF,GACF;EAED,MAAMC,QAAsC;GAC1C,UAAU,KAAK,WAAW;GAC1B,SAAS;EACV;EAED,MAAM,UAAU,IAAI,wBAAwB;EAC5C,MAAM,WAAW,MAAM,KAAK,WAAW,UAAU,KAAK,QAAQ;AAG9D,MAAI,SAAS,UAAU,SAAS,OAAO,SAAS,GAAG;GACjD,MAAM,SAAS,SAAS,OAAO,IAC7B,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,EAAE,QAAQ,EAC1C,CAAC,KAAK,KAAK;AACZ,SAAM,IAAI,OACP,iBAAiB,SAAS,OAAO,OAAO,aAAa,OAAO;EAEhE;CACF;CAED,MAAM,QAAuB,CAG5B;AACF"}
@@ -0,0 +1,63 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const __aws_sdk_client_sqs = require_chunk.__toESM(require("@aws-sdk/client-sqs"));
3
+ const lodash_chunk = require_chunk.__toESM(require("lodash.chunk"));
4
+
5
+ //#region src/sqs/SQSPublisher.ts
6
+ var SQSPublisher = class SQSPublisher {
7
+ options;
8
+ constructor(connection, options = {}) {
9
+ this.connection = connection;
10
+ this.options = { maxBatchSize: options.maxBatchSize ?? 10 };
11
+ }
12
+ /**
13
+ * Create an SQSPublisher from a connection string
14
+ * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10
15
+ */
16
+ static async fromConnectionString(connectionString) {
17
+ const url = new URL(connectionString);
18
+ const params = url.searchParams;
19
+ const { SQSConnection } = await Promise.resolve().then(() => require("./sqs/SQSConnection.cjs"));
20
+ const connection = await SQSConnection.fromConnectionString(connectionString);
21
+ const options = { maxBatchSize: params.get("maxBatchSize") ? Number.parseInt(params.get("maxBatchSize"), 10) : void 0 };
22
+ return new SQSPublisher(connection, options);
23
+ }
24
+ async publish(messages) {
25
+ if (messages.length === 0) return;
26
+ if (!this.connection.isConnected()) await this.connection.connect();
27
+ const batches = (0, lodash_chunk.default)(messages, this.options.maxBatchSize);
28
+ await Promise.all(batches.map((batch) => this.sendBatch(batch)));
29
+ }
30
+ async sendBatch(messages) {
31
+ const entries = messages.map((message, index) => ({
32
+ Id: `${index}`,
33
+ MessageBody: JSON.stringify({
34
+ type: message.type,
35
+ payload: message.payload
36
+ }),
37
+ MessageAttributes: { type: {
38
+ DataType: "String",
39
+ StringValue: message.type
40
+ } }
41
+ }));
42
+ const input = {
43
+ QueueUrl: this.connection.queueUrl,
44
+ Entries: entries
45
+ };
46
+ const command = new __aws_sdk_client_sqs.SendMessageBatchCommand(input);
47
+ const response = await this.connection.sqsClient.send(command);
48
+ if (response.Failed && response.Failed.length > 0) {
49
+ const errors = response.Failed.map((f) => `${f.Id}: ${f.Code} - ${f.Message}`).join(", ");
50
+ throw new Error(`Failed to send ${response.Failed.length} messages: ${errors}`);
51
+ }
52
+ }
53
+ async close() {}
54
+ };
55
+
56
+ //#endregion
57
+ Object.defineProperty(exports, 'SQSPublisher', {
58
+ enumerable: true,
59
+ get: function () {
60
+ return SQSPublisher;
61
+ }
62
+ });
63
+ //# sourceMappingURL=SQSPublisher-Dq5353oZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SQSPublisher-Dq5353oZ.cjs","names":["connection: SQSConnection","options: SQSPublisherOptions","connectionString: string","messages: TMessage[]","entries: SendMessageBatchRequestEntry[]","input: SendMessageBatchCommandInput","SendMessageBatchCommand"],"sources":["../src/sqs/SQSPublisher.ts"],"sourcesContent":["import {\n SendMessageBatchCommand,\n type SendMessageBatchCommandInput,\n type 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 maxBatchSize?: number; // Default: 10 (SQS limit)\n}\n\nexport class SQSPublisher<TMessage extends PublishableMessage<string, any>>\n implements EventPublisher<TMessage>\n{\n readonly options: Required<SQSPublisherOptions>;\n\n constructor(\n readonly connection: SQSConnection,\n options: SQSPublisherOptions = {},\n ) {\n this.options = {\n maxBatchSize: options.maxBatchSize ?? 10, // SQS limit\n };\n }\n\n /**\n * Create an SQSPublisher from a connection string\n * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10\n */\n static async fromConnectionString<\n TMessage extends PublishableMessage<string, any>,\n >(connectionString: string): Promise<SQSPublisher<TMessage>> {\n const url = new URL(connectionString);\n const params = url.searchParams;\n\n const { SQSConnection } = await import('./SQSConnection');\n const connection =\n await SQSConnection.fromConnectionString(connectionString);\n\n const options: SQSPublisherOptions = {\n maxBatchSize: params.get('maxBatchSize')\n ? Number.parseInt(params.get('maxBatchSize')!, 10)\n : undefined,\n };\n\n return new SQSPublisher<TMessage>(connection, options);\n }\n\n async publish(messages: TMessage[]): Promise<void> {\n if (messages.length === 0) return;\n\n if (!this.connection.isConnected()) {\n await this.connection.connect();\n }\n\n // Split messages into batches (SQS limit is 10 messages per batch)\n const batches = chunk(messages, this.options.maxBatchSize);\n\n // Send all batches\n await Promise.all(batches.map((batch) => this.sendBatch(batch)));\n }\n\n private async sendBatch(messages: TMessage[]): Promise<void> {\n const entries: SendMessageBatchRequestEntry[] = messages.map(\n (message, index) => ({\n Id: `${index}`,\n MessageBody: JSON.stringify({\n type: message.type,\n payload: message.payload,\n }),\n MessageAttributes: {\n type: {\n DataType: 'String',\n StringValue: message.type,\n },\n },\n }),\n );\n\n const input: SendMessageBatchCommandInput = {\n QueueUrl: this.connection.queueUrl,\n Entries: entries,\n };\n\n const command = new SendMessageBatchCommand(input);\n const response = await this.connection.sqsClient.send(command);\n\n // Check for failures\n if (response.Failed && response.Failed.length > 0) {\n const errors = response.Failed.map(\n (f) => `${f.Id}: ${f.Code} - ${f.Message}`,\n ).join(', ');\n throw new Error(\n `Failed to send ${response.Failed.length} messages: ${errors}`,\n );\n }\n }\n\n async close(): Promise<void> {\n // Publisher doesn't own the connection\n // Connection should be closed by whoever created it\n }\n}\n"],"mappings":";;;;;AAaA,IAAa,eAAb,MAAa,aAEb;CACE,AAAS;CAET,YACWA,YACTC,UAA+B,CAAE,GACjC;EAFS;AAGT,OAAK,UAAU,EACb,cAAc,QAAQ,gBAAgB,GACvC;CACF;;;;;CAMD,aAAa,qBAEXC,kBAA2D;EAC3D,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,EAAE,eAAe,GAAG,2CAAM;EAChC,MAAM,aACJ,MAAM,cAAc,qBAAqB,iBAAiB;EAE5D,MAAMD,UAA+B,EACnC,cAAc,OAAO,IAAI,eAAe,GACpC,OAAO,SAAS,OAAO,IAAI,eAAe,EAAG,GAAG,UAErD;AAED,SAAO,IAAI,aAAuB,YAAY;CAC/C;CAED,MAAM,QAAQE,UAAqC;AACjD,MAAI,SAAS,WAAW,EAAG;AAE3B,OAAK,KAAK,WAAW,aAAa,CAChC,OAAM,KAAK,WAAW,SAAS;EAIjC,MAAM,UAAU,0BAAM,UAAU,KAAK,QAAQ,aAAa;AAG1D,QAAM,QAAQ,IAAI,QAAQ,IAAI,CAAC,UAAU,KAAK,UAAU,MAAM,CAAC,CAAC;CACjE;CAED,MAAc,UAAUA,UAAqC;EAC3D,MAAMC,UAA0C,SAAS,IACvD,CAAC,SAAS,WAAW;GACnB,KAAK,EAAE,MAAM;GACb,aAAa,KAAK,UAAU;IAC1B,MAAM,QAAQ;IACd,SAAS,QAAQ;GAClB,EAAC;GACF,mBAAmB,EACjB,MAAM;IACJ,UAAU;IACV,aAAa,QAAQ;GACtB,EACF;EACF,GACF;EAED,MAAMC,QAAsC;GAC1C,UAAU,KAAK,WAAW;GAC1B,SAAS;EACV;EAED,MAAM,UAAU,IAAIC,6CAAwB;EAC5C,MAAM,WAAW,MAAM,KAAK,WAAW,UAAU,KAAK,QAAQ;AAG9D,MAAI,SAAS,UAAU,SAAS,OAAO,SAAS,GAAG;GACjD,MAAM,SAAS,SAAS,OAAO,IAC7B,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,EAAE,QAAQ,EAC1C,CAAC,KAAK,KAAK;AACZ,SAAM,IAAI,OACP,iBAAiB,SAAS,OAAO,OAAO,aAAa,OAAO;EAEhE;CACF;CAED,MAAM,QAAuB,CAG5B;AACF"}