@geekmidas/events 10.0.0-alpha.4 → 10.0.0-alpha.40

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 (136) hide show
  1. package/dist/PgBossConnection-CywKoAZU.cjs +2 -0
  2. package/dist/PgBossConnection-DjoqT84r.mjs +2 -0
  3. package/dist/RabbitMQConnection-C9eccBL8.cjs +2 -0
  4. package/dist/RabbitMQConnection-CAp7VqyT.mjs +2 -0
  5. package/dist/SNSConnection-BWDC1wAF.cjs +2 -0
  6. package/dist/SNSConnection-ezQvVrDv.mjs +2 -0
  7. package/dist/{SQSSubscriber-BMWZ3s5q.mjs → SQSSubscriber-BXLE_1L3.mjs} +73 -7
  8. package/dist/SQSSubscriber-BXLE_1L3.mjs.map +1 -0
  9. package/dist/{SQSSubscriber-YXPlg2rm.cjs → SQSSubscriber-DtRUaZB3.cjs} +91 -14
  10. package/dist/SQSSubscriber-DtRUaZB3.cjs.map +1 -0
  11. package/dist/basic/index.cjs +7 -8
  12. package/dist/basic/index.cjs.map +1 -1
  13. package/dist/basic/index.d.cts +4 -10
  14. package/dist/basic/index.d.cts.map +1 -1
  15. package/dist/basic/index.d.mts +4 -10
  16. package/dist/basic/index.d.mts.map +1 -1
  17. package/dist/basic/index.mjs +5 -6
  18. package/dist/basic/index.mjs.map +1 -1
  19. package/dist/index.cjs +43 -50
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +26 -11
  22. package/dist/index.d.cts.map +1 -1
  23. package/dist/index.d.mts +26 -11
  24. package/dist/index.d.mts.map +1 -1
  25. package/dist/index.mjs +42 -51
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/pgboss/index.cjs +145 -28
  28. package/dist/pgboss/index.cjs.map +1 -1
  29. package/dist/pgboss/index.d.cts +39 -12
  30. package/dist/pgboss/index.d.cts.map +1 -1
  31. package/dist/pgboss/index.d.mts +39 -12
  32. package/dist/pgboss/index.d.mts.map +1 -1
  33. package/dist/pgboss/index.mjs +140 -28
  34. package/dist/pgboss/index.mjs.map +1 -1
  35. package/dist/rabbitmq/index.cjs +135 -22
  36. package/dist/rabbitmq/index.cjs.map +1 -1
  37. package/dist/rabbitmq/index.d.cts +11 -10
  38. package/dist/rabbitmq/index.d.cts.map +1 -1
  39. package/dist/rabbitmq/index.d.mts +11 -10
  40. package/dist/rabbitmq/index.d.mts.map +1 -1
  41. package/dist/rabbitmq/index.mjs +130 -22
  42. package/dist/rabbitmq/index.mjs.map +1 -1
  43. package/dist/{chunk-CsX-DzYB.cjs → rolldown-runtime-C0BPl7ul.cjs} +17 -16
  44. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  45. package/dist/sns/index.cjs +371 -34
  46. package/dist/sns/index.cjs.map +1 -1
  47. package/dist/sns/index.d.cts +167 -11
  48. package/dist/sns/index.d.cts.map +1 -1
  49. package/dist/sns/index.d.mts +167 -11
  50. package/dist/sns/index.d.mts.map +1 -1
  51. package/dist/sns/index.mjs +340 -18
  52. package/dist/sns/index.mjs.map +1 -1
  53. package/dist/sns/snsUrl.cjs +91 -6
  54. package/dist/sns/snsUrl.cjs.map +1 -0
  55. package/dist/sns/snsUrl.d.cts +57 -2
  56. package/dist/sns/snsUrl.d.cts.map +1 -0
  57. package/dist/sns/snsUrl.d.mts +57 -2
  58. package/dist/sns/snsUrl.d.mts.map +1 -0
  59. package/dist/sns/snsUrl.mjs +81 -2
  60. package/dist/sns/snsUrl.mjs.map +1 -0
  61. package/dist/sqs/index.cjs +34 -24
  62. package/dist/sqs/index.cjs.map +1 -1
  63. package/dist/sqs/index.d.cts +19 -11
  64. package/dist/sqs/index.d.cts.map +1 -1
  65. package/dist/sqs/index.d.mts +19 -11
  66. package/dist/sqs/index.d.mts.map +1 -1
  67. package/dist/sqs/index.mjs +22 -15
  68. package/dist/sqs/index.mjs.map +1 -1
  69. package/dist/sqs/sqsUrl.cjs +92 -6
  70. package/dist/sqs/sqsUrl.cjs.map +1 -0
  71. package/dist/sqs/sqsUrl.d.cts +56 -2
  72. package/dist/sqs/sqsUrl.d.cts.map +1 -0
  73. package/dist/sqs/sqsUrl.d.mts +56 -2
  74. package/dist/sqs/sqsUrl.d.mts.map +1 -0
  75. package/dist/sqs/sqsUrl.mjs +82 -2
  76. package/dist/sqs/sqsUrl.mjs.map +1 -0
  77. package/dist/types-BcZjLxVV.cjs +51 -0
  78. package/dist/types-BcZjLxVV.cjs.map +1 -0
  79. package/dist/types-Bk5JM6MP.mjs +40 -0
  80. package/dist/types-Bk5JM6MP.mjs.map +1 -0
  81. package/dist/types-gGaoT8qc.d.cts +149 -0
  82. package/dist/types-gGaoT8qc.d.cts.map +1 -0
  83. package/dist/types-gGaoT8qc.d.mts +149 -0
  84. package/dist/types-gGaoT8qc.d.mts.map +1 -0
  85. package/package.json +3 -3
  86. package/dist/PgBossConnection-C3qYNfm5.cjs +0 -80
  87. package/dist/PgBossConnection-C3qYNfm5.cjs.map +0 -1
  88. package/dist/PgBossConnection-Cvgv2l1G.mjs +0 -74
  89. package/dist/PgBossConnection-Cvgv2l1G.mjs.map +0 -1
  90. package/dist/PgBossConnection-DCUxQLZz.cjs +0 -4
  91. package/dist/PgBossConnection-DbO0ypJf.mjs +0 -4
  92. package/dist/RabbitMQConnection-8PbOD8hM.cjs +0 -4
  93. package/dist/RabbitMQConnection-Bpx3Lgij.mjs +0 -4
  94. package/dist/RabbitMQConnection-DGAk4aUb.cjs +0 -113
  95. package/dist/RabbitMQConnection-DGAk4aUb.cjs.map +0 -1
  96. package/dist/RabbitMQConnection-aE0dtb63.mjs +0 -107
  97. package/dist/RabbitMQConnection-aE0dtb63.mjs.map +0 -1
  98. package/dist/SNSConnection-B2K86hpz.cjs +0 -75
  99. package/dist/SNSConnection-B2K86hpz.cjs.map +0 -1
  100. package/dist/SNSConnection-BVo84FeW.mjs +0 -5
  101. package/dist/SNSConnection-DIHRjrQF.cjs +0 -5
  102. package/dist/SNSConnection-v9jjF99w.mjs +0 -69
  103. package/dist/SNSConnection-v9jjF99w.mjs.map +0 -1
  104. package/dist/SQSConnection-4tBMkVZE.mjs +0 -69
  105. package/dist/SQSConnection-4tBMkVZE.mjs.map +0 -1
  106. package/dist/SQSConnection-BBLAvF-1.cjs +0 -5
  107. package/dist/SQSConnection-BaC7rGhI.cjs +0 -75
  108. package/dist/SQSConnection-BaC7rGhI.cjs.map +0 -1
  109. package/dist/SQSConnection-DbavOq8_.mjs +0 -5
  110. package/dist/SQSSubscriber-BMWZ3s5q.mjs.map +0 -1
  111. package/dist/SQSSubscriber-YXPlg2rm.cjs.map +0 -1
  112. package/dist/chunk-B9dir_RE.mjs +0 -11
  113. package/dist/snsUrl-ASdc0D1v.d.cts +0 -61
  114. package/dist/snsUrl-ASdc0D1v.d.cts.map +0 -1
  115. package/dist/snsUrl-CifYhPAa.mjs +0 -79
  116. package/dist/snsUrl-CifYhPAa.mjs.map +0 -1
  117. package/dist/snsUrl-FRbRcwF0.d.mts +0 -61
  118. package/dist/snsUrl-FRbRcwF0.d.mts.map +0 -1
  119. package/dist/snsUrl-f2gU3CzK.cjs +0 -114
  120. package/dist/snsUrl-f2gU3CzK.cjs.map +0 -1
  121. package/dist/sqsUrl-BV6zS-mi.d.mts +0 -60
  122. package/dist/sqsUrl-BV6zS-mi.d.mts.map +0 -1
  123. package/dist/sqsUrl-CbAsBFHI.mjs +0 -80
  124. package/dist/sqsUrl-CbAsBFHI.mjs.map +0 -1
  125. package/dist/sqsUrl-CdisN3GU.cjs +0 -115
  126. package/dist/sqsUrl-CdisN3GU.cjs.map +0 -1
  127. package/dist/sqsUrl-DZDPHxIk.d.cts +0 -60
  128. package/dist/sqsUrl-DZDPHxIk.d.cts.map +0 -1
  129. package/dist/types-BmixGrOD.d.cts +0 -67
  130. package/dist/types-BmixGrOD.d.cts.map +0 -1
  131. package/dist/types-Byv8N9ma.cjs +0 -24
  132. package/dist/types-Byv8N9ma.cjs.map +0 -1
  133. package/dist/types-CYDt-2RQ.mjs +0 -18
  134. package/dist/types-CYDt-2RQ.mjs.map +0 -1
  135. package/dist/types-DycjsYms.d.mts +0 -67
  136. package/dist/types-DycjsYms.d.mts.map +0 -1
@@ -1,2 +1,57 @@
1
- import { MalformedTopicUrl, MissingTopicArn, SnsAddress, UnexpectedTopicScheme, build, parse } from "../snsUrl-ASdc0D1v.cjs";
2
- export { MalformedTopicUrl, MissingTopicArn, SnsAddress, UnexpectedTopicScheme, build, parse };
1
+ declare namespace snsUrl_d_exports {
2
+ export { MalformedTopicUrl, MissingTopicArn, SnsAddress, UnexpectedTopicScheme, build, parse };
3
+ }
4
+ /**
5
+ * The `sns://` connection-string codec — how a topic is addressed as one string.
6
+ *
7
+ * The twin of `sqsUrl`, and separate from it for the same reason `gs://` would
8
+ * be separate from `s3://`: a topic ARN and a queue URL are different
9
+ * vocabularies, and a shared codec would have to contain both. What they share
10
+ * is only the rule that a construct provides one string.
11
+ *
12
+ * Both directions live here so they cannot drift: `parse(build(x))` is `x`.
13
+ */
14
+ /** What an SNS connection string addresses. */
15
+ export interface SnsAddress {
16
+ topicArn: string;
17
+ /** Read off the topic, never inherited: a topic may live in another region. */
18
+ region?: string;
19
+ /** Set for SNS-compatible backends such as LocalStack. */
20
+ endpoint?: string;
21
+ /**
22
+ * The queue a subscriber drains.
23
+ *
24
+ * Present only on the subscriber's string: fan-out delivers to a queue per
25
+ * subscriber, so the publisher's string names the topic and nothing else.
26
+ */
27
+ queueName?: string;
28
+ }
29
+ /**
30
+ * Compose an address into a connection string.
31
+ *
32
+ * Credentials never appear, for the same reason they never appear in an
33
+ * `s3://` URL: the SDK resolves them from its own chain.
34
+ */
35
+ export declare function build(address: SnsAddress): string;
36
+ /** Parse a connection string back into an address. */
37
+ export declare function parse(connectionString: string): SnsAddress;
38
+ /** The string is not a URL at all. */
39
+ export declare class MalformedTopicUrl extends Error {
40
+ readonly url: string;
41
+ constructor(url: string);
42
+ }
43
+ /** The string is a URL, but not an `sns://` one. */
44
+ export declare class UnexpectedTopicScheme extends Error {
45
+ readonly url: string;
46
+ readonly expected: string;
47
+ readonly actual: string;
48
+ constructor(url: string, expected: string, actual: string);
49
+ }
50
+ /** An `sns://` string with no topic names nothing. */
51
+ export declare class MissingTopicArn extends Error {
52
+ readonly url: string;
53
+ constructor(url: string);
54
+ }
55
+ //#endregion
56
+ export { snsUrl_d_exports as t };
57
+ //# sourceMappingURL=snsUrl.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snsUrl.d.cts","names":[],"sources":["../../src/sns/snsUrl.ts"],"mappings":";;;;;;;;;;;;;;iBAYiB;EAChB;;EAEA;;EAEA;;;;;;;EAOA;;;;;;;;wBAWe,MAAM,SAAS;;wBAcf,MAAM,2BAA2B;;qBA4BpC,0BAA0B;WACjB;EAArB,YAAqB;;;qBAOT,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,aACA,kBACA;;;qBAUE,wBAAwB;WACf;EAArB,YAAqB"}
@@ -1,2 +1,57 @@
1
- import { MalformedTopicUrl, MissingTopicArn, SnsAddress, UnexpectedTopicScheme, build, parse } from "../snsUrl-FRbRcwF0.mjs";
2
- export { MalformedTopicUrl, MissingTopicArn, SnsAddress, UnexpectedTopicScheme, build, parse };
1
+ declare namespace snsUrl_d_exports {
2
+ export { MalformedTopicUrl, MissingTopicArn, SnsAddress, UnexpectedTopicScheme, build, parse };
3
+ }
4
+ /**
5
+ * The `sns://` connection-string codec — how a topic is addressed as one string.
6
+ *
7
+ * The twin of `sqsUrl`, and separate from it for the same reason `gs://` would
8
+ * be separate from `s3://`: a topic ARN and a queue URL are different
9
+ * vocabularies, and a shared codec would have to contain both. What they share
10
+ * is only the rule that a construct provides one string.
11
+ *
12
+ * Both directions live here so they cannot drift: `parse(build(x))` is `x`.
13
+ */
14
+ /** What an SNS connection string addresses. */
15
+ export interface SnsAddress {
16
+ topicArn: string;
17
+ /** Read off the topic, never inherited: a topic may live in another region. */
18
+ region?: string;
19
+ /** Set for SNS-compatible backends such as LocalStack. */
20
+ endpoint?: string;
21
+ /**
22
+ * The queue a subscriber drains.
23
+ *
24
+ * Present only on the subscriber's string: fan-out delivers to a queue per
25
+ * subscriber, so the publisher's string names the topic and nothing else.
26
+ */
27
+ queueName?: string;
28
+ }
29
+ /**
30
+ * Compose an address into a connection string.
31
+ *
32
+ * Credentials never appear, for the same reason they never appear in an
33
+ * `s3://` URL: the SDK resolves them from its own chain.
34
+ */
35
+ export declare function build(address: SnsAddress): string;
36
+ /** Parse a connection string back into an address. */
37
+ export declare function parse(connectionString: string): SnsAddress;
38
+ /** The string is not a URL at all. */
39
+ export declare class MalformedTopicUrl extends Error {
40
+ readonly url: string;
41
+ constructor(url: string);
42
+ }
43
+ /** The string is a URL, but not an `sns://` one. */
44
+ export declare class UnexpectedTopicScheme extends Error {
45
+ readonly url: string;
46
+ readonly expected: string;
47
+ readonly actual: string;
48
+ constructor(url: string, expected: string, actual: string);
49
+ }
50
+ /** An `sns://` string with no topic names nothing. */
51
+ export declare class MissingTopicArn extends Error {
52
+ readonly url: string;
53
+ constructor(url: string);
54
+ }
55
+ //#endregion
56
+ export { snsUrl_d_exports as t };
57
+ //# sourceMappingURL=snsUrl.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snsUrl.d.mts","names":[],"sources":["../../src/sns/snsUrl.ts"],"mappings":";;;;;;;;;;;;;;iBAYiB;EAChB;;EAEA;;EAEA;;;;;;;EAOA;;;;;;;;wBAWe,MAAM,SAAS;;wBAcf,MAAM,2BAA2B;;qBA4BpC,0BAA0B;WACjB;EAArB,YAAqB;;;qBAOT,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,aACA,kBACA;;;qBAUE,wBAAwB;WACf;EAArB,YAAqB"}
@@ -1,3 +1,82 @@
1
- import { MalformedTopicUrl, MissingTopicArn, UnexpectedTopicScheme, build, parse } from "../snsUrl-CifYhPAa.mjs";
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ //#region src/sns/snsUrl.ts
3
+ var snsUrl_exports = /* @__PURE__ */ __exportAll({
4
+ MalformedTopicUrl: () => MalformedTopicUrl,
5
+ MissingTopicArn: () => MissingTopicArn,
6
+ UnexpectedTopicScheme: () => UnexpectedTopicScheme,
7
+ build: () => build,
8
+ parse: () => parse
9
+ });
10
+ const SCHEME = "sns:";
11
+ /**
12
+ * Compose an address into a connection string.
13
+ *
14
+ * Credentials never appear, for the same reason they never appear in an
15
+ * `s3://` URL: the SDK resolves them from its own chain.
16
+ */
17
+ function build(address) {
18
+ const { topicArn, region, endpoint, queueName } = address;
19
+ if (!topicArn) throw new MissingTopicArn("");
20
+ const url = new URL(`${SCHEME}//`);
21
+ url.searchParams.set("topicArn", topicArn);
22
+ if (region) url.searchParams.set("region", region);
23
+ if (endpoint) url.searchParams.set("endpoint", endpoint);
24
+ if (queueName) url.searchParams.set("queueName", queueName);
25
+ return url.toString();
26
+ }
27
+ /** Parse a connection string back into an address. */
28
+ function parse(connectionString) {
29
+ let parsed;
30
+ try {
31
+ parsed = new URL(connectionString);
32
+ } catch {
33
+ throw new MalformedTopicUrl(connectionString);
34
+ }
35
+ if (parsed.protocol !== SCHEME) throw new UnexpectedTopicScheme(connectionString, SCHEME, parsed.protocol);
36
+ const topicArn = parsed.searchParams.get("topicArn");
37
+ if (!topicArn) throw new MissingTopicArn(connectionString);
38
+ const region = parsed.searchParams.get("region") ?? void 0;
39
+ const endpoint = parsed.searchParams.get("endpoint") ?? void 0;
40
+ const queueName = parsed.searchParams.get("queueName") ?? void 0;
41
+ return {
42
+ topicArn,
43
+ ...region ? { region } : {},
44
+ ...endpoint ? { endpoint } : {},
45
+ ...queueName ? { queueName } : {}
46
+ };
47
+ }
48
+ /** The string is not a URL at all. */
49
+ var MalformedTopicUrl = class extends Error {
50
+ url;
51
+ constructor(url) {
52
+ super(`'${url}' is not a valid connection string.`);
53
+ this.url = url;
54
+ this.name = "MalformedTopicUrl";
55
+ }
56
+ };
57
+ /** The string is a URL, but not an `sns://` one. */
58
+ var UnexpectedTopicScheme = class extends Error {
59
+ url;
60
+ expected;
61
+ actual;
62
+ constructor(url, expected, actual) {
63
+ super(`Expected a '${expected}//' connection string and got '${actual}//' in '${url}'.`);
64
+ this.url = url;
65
+ this.expected = expected;
66
+ this.actual = actual;
67
+ this.name = "UnexpectedTopicScheme";
68
+ }
69
+ };
70
+ /** An `sns://` string with no topic names nothing. */
71
+ var MissingTopicArn = class extends Error {
72
+ url;
73
+ constructor(url) {
74
+ super(url ? `'${url}' names no topic: an sns:// connection string needs ?topicArn=.` : "An sns:// connection string needs a topicArn.");
75
+ this.url = url;
76
+ this.name = "MissingTopicArn";
77
+ }
78
+ };
79
+ //#endregion
80
+ export { MalformedTopicUrl, MissingTopicArn, UnexpectedTopicScheme, build, parse, snsUrl_exports as t };
2
81
 
3
- export { MalformedTopicUrl, MissingTopicArn, UnexpectedTopicScheme, build, parse };
82
+ //# sourceMappingURL=snsUrl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snsUrl.mjs","names":[],"sources":["../../src/sns/snsUrl.ts"],"sourcesContent":["/**\n * The `sns://` connection-string codec — how a topic is addressed as one string.\n *\n * The twin of `sqsUrl`, and separate from it for the same reason `gs://` would\n * be separate from `s3://`: a topic ARN and a queue URL are different\n * vocabularies, and a shared codec would have to contain both. What they share\n * is only the rule that a construct provides one string.\n *\n * Both directions live here so they cannot drift: `parse(build(x))` is `x`.\n */\n\n/** What an SNS connection string addresses. */\nexport interface SnsAddress {\n\ttopicArn: string;\n\t/** Read off the topic, never inherited: a topic may live in another region. */\n\tregion?: string;\n\t/** Set for SNS-compatible backends such as LocalStack. */\n\tendpoint?: string;\n\t/**\n\t * The queue a subscriber drains.\n\t *\n\t * Present only on the subscriber's string: fan-out delivers to a queue per\n\t * subscriber, so the publisher's string names the topic and nothing else.\n\t */\n\tqueueName?: string;\n}\n\nconst SCHEME = 'sns:';\n\n/**\n * Compose an address into a connection string.\n *\n * Credentials never appear, for the same reason they never appear in an\n * `s3://` URL: the SDK resolves them from its own chain.\n */\nexport function build(address: SnsAddress): string {\n\tconst { topicArn, region, endpoint, queueName } = address;\n\tif (!topicArn) throw new MissingTopicArn('');\n\n\tconst url = new URL(`${SCHEME}//`);\n\turl.searchParams.set('topicArn', topicArn);\n\tif (region) url.searchParams.set('region', region);\n\tif (endpoint) url.searchParams.set('endpoint', endpoint);\n\tif (queueName) url.searchParams.set('queueName', queueName);\n\n\treturn url.toString();\n}\n\n/** Parse a connection string back into an address. */\nexport function parse(connectionString: string): SnsAddress {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(connectionString);\n\t} catch {\n\t\tthrow new MalformedTopicUrl(connectionString);\n\t}\n\n\tif (parsed.protocol !== SCHEME) {\n\t\tthrow new UnexpectedTopicScheme(connectionString, SCHEME, parsed.protocol);\n\t}\n\n\tconst topicArn = parsed.searchParams.get('topicArn');\n\tif (!topicArn) throw new MissingTopicArn(connectionString);\n\n\tconst region = parsed.searchParams.get('region') ?? undefined;\n\tconst endpoint = parsed.searchParams.get('endpoint') ?? undefined;\n\tconst queueName = parsed.searchParams.get('queueName') ?? undefined;\n\n\treturn {\n\t\ttopicArn,\n\t\t...(region ? { region } : {}),\n\t\t...(endpoint ? { endpoint } : {}),\n\t\t...(queueName ? { queueName } : {}),\n\t};\n}\n\n/** The string is not a URL at all. */\nexport class MalformedTopicUrl extends Error {\n\tconstructor(readonly url: string) {\n\t\tsuper(`'${url}' is not a valid connection string.`);\n\t\tthis.name = 'MalformedTopicUrl';\n\t}\n}\n\n/** The string is a URL, but not an `sns://` one. */\nexport class UnexpectedTopicScheme extends Error {\n\tconstructor(\n\t\treadonly url: string,\n\t\treadonly expected: string,\n\t\treadonly actual: string,\n\t) {\n\t\tsuper(\n\t\t\t`Expected a '${expected}//' connection string and got '${actual}//' in '${url}'.`,\n\t\t);\n\t\tthis.name = 'UnexpectedTopicScheme';\n\t}\n}\n\n/** An `sns://` string with no topic names nothing. */\nexport class MissingTopicArn extends Error {\n\tconstructor(readonly url: string) {\n\t\tsuper(\n\t\t\turl\n\t\t\t\t? `'${url}' names no topic: an sns:// connection string needs ?topicArn=.`\n\t\t\t\t: 'An sns:// connection string needs a topicArn.',\n\t\t);\n\t\tthis.name = 'MissingTopicArn';\n\t}\n}\n"],"mappings":";;;;;;;;;AA2BA,MAAM,SAAS;;;;;;;AAQf,SAAgB,MAAM,SAA6B;CAClD,MAAM,EAAE,UAAU,QAAQ,UAAU,cAAc;CAClD,IAAI,CAAC,UAAU,MAAM,IAAI,gBAAgB,EAAE;CAE3C,MAAM,MAAM,IAAI,IAAI,GAAG,OAAO,GAAG;CACjC,IAAI,aAAa,IAAI,YAAY,QAAQ;CACzC,IAAI,QAAQ,IAAI,aAAa,IAAI,UAAU,MAAM;CACjD,IAAI,UAAU,IAAI,aAAa,IAAI,YAAY,QAAQ;CACvD,IAAI,WAAW,IAAI,aAAa,IAAI,aAAa,SAAS;CAE1D,OAAO,IAAI,SAAS;AACrB;;AAGA,SAAgB,MAAM,kBAAsC;CAC3D,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,gBAAgB;CAClC,QAAQ;EACP,MAAM,IAAI,kBAAkB,gBAAgB;CAC7C;CAEA,IAAI,OAAO,aAAa,QACvB,MAAM,IAAI,sBAAsB,kBAAkB,QAAQ,OAAO,QAAQ;CAG1E,MAAM,WAAW,OAAO,aAAa,IAAI,UAAU;CACnD,IAAI,CAAC,UAAU,MAAM,IAAI,gBAAgB,gBAAgB;CAEzD,MAAM,SAAS,OAAO,aAAa,IAAI,QAAQ,KAAK,KAAA;CACpD,MAAM,WAAW,OAAO,aAAa,IAAI,UAAU,KAAK,KAAA;CACxD,MAAM,YAAY,OAAO,aAAa,IAAI,WAAW,KAAK,KAAA;CAE1D,OAAO;EACN;EACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;EAC/B,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;CAClC;AACD;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CACvB;CAArB,YAAY,KAAsB;EACjC,MAAM,IAAI,IAAI,oCAAoC;EAD9B,KAAA,MAAA;EAEpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,wBAAb,cAA2C,MAAM;CAEtC;CACA;CACA;CAHV,YACC,KACA,UACA,QACC;EACD,MACC,eAAe,SAAS,iCAAiC,OAAO,UAAU,IAAI,GAC/E;EANS,KAAA,MAAA;EACA,KAAA,WAAA;EACA,KAAA,SAAA;EAKT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CACrB;CAArB,YAAY,KAAsB;EACjC,MACC,MACG,IAAI,IAAI,mEACR,+CACJ;EALoB,KAAA,MAAA;EAMpB,KAAK,OAAO;CACb;AACD"}
@@ -1,13 +1,13 @@
1
- const require_chunk = require('../chunk-CsX-DzYB.cjs');
2
- require('../types-Byv8N9ma.cjs');
3
- const require_sqsUrl = require('../sqsUrl-CdisN3GU.cjs');
4
- const require_SQSConnection = require('../SQSConnection-BaC7rGhI.cjs');
5
- const require_SQSSubscriber = require('../SQSSubscriber-YXPlg2rm.cjs');
6
- const __aws_sdk_client_sqs = require_chunk.__toESM(require("@aws-sdk/client-sqs"));
7
- const lodash_chunk = require_chunk.__toESM(require("lodash.chunk"));
8
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rolldown_runtime = require("../rolldown-runtime-C0BPl7ul.cjs");
3
+ const require_sqs_sqsUrl = require("./sqsUrl.cjs");
4
+ const require_SQSSubscriber = require("../SQSSubscriber-DtRUaZB3.cjs");
5
+ let _aws_sdk_client_sqs = require("@aws-sdk/client-sqs");
6
+ let lodash_chunk = require("lodash.chunk");
7
+ lodash_chunk = require_rolldown_runtime.__toESM(lodash_chunk, 1);
9
8
  //#region src/sqs/SQSPublisher.ts
10
9
  var SQSPublisher = class SQSPublisher {
10
+ connection;
11
11
  options;
12
12
  constructor(connection, options = {}) {
13
13
  this.connection = connection;
@@ -18,10 +18,9 @@ var SQSPublisher = class SQSPublisher {
18
18
  * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10
19
19
  */
20
20
  static async fromConnectionString(connectionString) {
21
- const url = new URL(connectionString);
22
- const params = url.searchParams;
23
- const { SQSConnection: SQSConnection$1 } = await Promise.resolve().then(() => require("../SQSConnection-BBLAvF-1.cjs"));
24
- const connection = await SQSConnection$1.fromConnectionString(connectionString);
21
+ const params = new URL(connectionString).searchParams;
22
+ const { SQSConnection } = await Promise.resolve().then(() => require("../SQSSubscriber-DtRUaZB3.cjs")).then((n) => n.SQSConnection_exports);
23
+ const connection = await SQSConnection.fromConnectionString(connectionString);
25
24
  const options = { maxBatchSize: params.get("maxBatchSize") ? Number.parseInt(params.get("maxBatchSize"), 10) : void 0 };
26
25
  return new SQSPublisher(connection, options);
27
26
  }
@@ -47,24 +46,35 @@ var SQSPublisher = class SQSPublisher {
47
46
  QueueUrl: this.connection.queueUrl,
48
47
  Entries: entries
49
48
  };
50
- const command = new __aws_sdk_client_sqs.SendMessageBatchCommand(input);
49
+ const command = new _aws_sdk_client_sqs.SendMessageBatchCommand(input);
51
50
  const response = await this.connection.sqsClient.send(command);
52
- if (response.Failed && response.Failed.length > 0) {
53
- const errors = response.Failed.map((f) => `${f.Id}: ${f.Code} - ${f.Message}`).join(", ");
54
- throw new Error(`Failed to send ${response.Failed.length} messages: ${errors}`);
55
- }
51
+ if (response.Failed && response.Failed.length > 0) throw new SqsBatchPartlyFailed(response.Failed.map((f) => ({
52
+ id: f.Id,
53
+ code: f.Code,
54
+ message: f.Message
55
+ })));
56
56
  }
57
57
  async close() {}
58
58
  };
59
-
59
+ /** SQS accepted the batch but refused some of its messages; the rest were sent. */
60
+ var SqsBatchPartlyFailed = class extends Error {
61
+ failed;
62
+ constructor(failed) {
63
+ super(`Failed to send ${failed.length} messages: ${failed.map((f) => `${f.id}: ${f.code} - ${f.message}`).join(", ")}. The others in the batch were sent; retry only these.`);
64
+ this.failed = failed;
65
+ this.name = "SqsBatchPartlyFailed";
66
+ }
67
+ };
60
68
  //#endregion
61
- exports.SQSConnection = require_SQSConnection.SQSConnection;
69
+ exports.SQSConnection = require_SQSSubscriber.SQSConnection;
62
70
  exports.SQSPublisher = SQSPublisher;
63
71
  exports.SQSSubscriber = require_SQSSubscriber.SQSSubscriber;
64
- Object.defineProperty(exports, 'sqsUrl', {
65
- enumerable: true,
66
- get: function () {
67
- return require_sqsUrl.sqsUrl_exports;
68
- }
72
+ exports.SqsBatchPartlyFailed = SqsBatchPartlyFailed;
73
+ Object.defineProperty(exports, "sqsUrl", {
74
+ enumerable: true,
75
+ get: function() {
76
+ return require_sqs_sqsUrl.sqsUrl_exports;
77
+ }
69
78
  });
79
+
70
80
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["connection: SQSConnection","options: SQSPublisherOptions","connectionString: string","messages: TMessage[]","entries: SendMessageBatchRequestEntry[]","input: SendMessageBatchCommandInput","SendMessageBatchCommand"],"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&region=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,gCAAe,GAAG,2CAAM;EAChC,MAAM,aACL,MAAM,gBAAc,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,0BAAM,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,IAAIC,6CAAwB;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"}
1
+ {"version":3,"file":"index.cjs","names":["chunk","SendMessageBatchCommand"],"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&region=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\tthrow new SqsBatchPartlyFailed(\n\t\t\t\tresponse.Failed.map((f) => ({\n\t\t\t\t\tid: f.Id,\n\t\t\t\t\tcode: f.Code,\n\t\t\t\t\tmessage: f.Message,\n\t\t\t\t})),\n\t\t\t);\n\t\t}\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t\t// Connection should be closed by whoever created it\n\t}\n}\n\n/** SQS accepted the batch but refused some of its messages; the rest were sent. */\nexport class SqsBatchPartlyFailed extends Error {\n\tconstructor(\n\t\treadonly failed: readonly {\n\t\t\tid?: string;\n\t\t\tcode?: string;\n\t\t\tmessage?: string;\n\t\t}[],\n\t) {\n\t\tsuper(\n\t\t\t`Failed to send ${failed.length} messages: ${failed.map((f) => `${f.id}: ${f.code} - ${f.message}`).join(', ')}. The others in the batch were sent; retry only these.`,\n\t\t);\n\t\tthis.name = 'SqsBatchPartlyFailed';\n\t}\n}\n"],"mappings":";;;;;;;;AAaA,IAAa,eAAb,MAAa,aAEb;CAIW;CAHV;CAEA,YACC,YACA,UAA+B,CAAC,GAC/B;EAFQ,KAAA,aAAA;EAGT,KAAK,UAAU,EACd,cAAc,QAAQ,gBAAgB,GACvC;CACD;;;;;CAMA,aAAa,qBAEX,kBAA2D;EAE5D,MAAM,SAAS,IADC,IAAI,gBACH,CAAC,CAAC;EAEnB,MAAM,EAAE,kBAAkB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,+BAAA,CAAA,CAAA,CAAA,MAAA,MAAA,EAAA,qBAAA;EAChC,MAAM,aACL,MAAM,cAAc,qBAAqB,gBAAgB;EAE1D,MAAM,UAA+B,EACpC,cAAc,OAAO,IAAI,cAAc,IACpC,OAAO,SAAS,OAAO,IAAI,cAAc,GAAI,EAAE,IAC/C,KAAA,EACJ;EAEA,OAAO,IAAI,aAAuB,YAAY,OAAO;CACtD;CAEA,MAAM,QAAQ,UAAqC;EAClD,IAAI,SAAS,WAAW,GAAG;EAE3B,IAAI,CAAC,KAAK,WAAW,YAAY,GAChC,MAAM,KAAK,WAAW,QAAQ;EAI/B,MAAM,WAAA,GAAUA,aAAAA,QAAAA,CAAM,UAAU,KAAK,QAAQ,YAAY;EAGzD,MAAM,QAAQ,IAAI,QAAQ,KAAK,UAAU,KAAK,UAAU,KAAK,CAAC,CAAC;CAChE;CAEA,MAAc,UAAU,UAAqC;EAC5D,MAAM,UAA0C,SAAS,KACvD,SAAS,WAAW;GACpB,IAAI,GAAG;GACP,aAAa,KAAK,UAAU;IAC3B,MAAM,QAAQ;IACd,SAAS,QAAQ;GAClB,CAAC;GACD,mBAAmB,EAClB,MAAM;IACL,UAAU;IACV,aAAa,QAAQ;GACtB,EACD;EACD,EACD;EAEA,MAAM,QAAsC;GAC3C,UAAU,KAAK,WAAW;GAC1B,SAAS;EACV;EAEA,MAAM,UAAU,IAAIC,oBAAAA,wBAAwB,KAAK;EACjD,MAAM,WAAW,MAAM,KAAK,WAAW,UAAU,KAAK,OAAO;EAG7D,IAAI,SAAS,UAAU,SAAS,OAAO,SAAS,GAC/C,MAAM,IAAI,qBACT,SAAS,OAAO,KAAK,OAAO;GAC3B,IAAI,EAAE;GACN,MAAM,EAAE;GACR,SAAS,EAAE;EACZ,EAAE,CACH;CAEF;CAEA,MAAM,QAAuB,CAG7B;AACD;;AAGA,IAAa,uBAAb,cAA0C,MAAM;CAErC;CADV,YACC,QAKC;EACD,MACC,kBAAkB,OAAO,OAAO,aAAa,OAAO,KAAK,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,EAAE,SAAS,CAAC,CAAC,KAAK,IAAI,EAAE,uDAChH;EARS,KAAA,SAAA;EAST,KAAK,OAAO;CACb;AACD"}
@@ -1,7 +1,6 @@
1
- import { EventConnection, EventPublisher, EventPublisherType, EventSubscriber, PublishableMessage } from "../types-BmixGrOD.cjs";
2
- import { SqsAddress, sqsUrl_d_exports } from "../sqsUrl-DZDPHxIk.cjs";
1
+ import { i as EventSubscriber, n as EventPublisher, r as EventPublisherType, s as PublishableMessage, t as EventConnection } from "../types-gGaoT8qc.cjs";
2
+ import { SqsAddress, t as sqsUrl_d_exports } from "./sqsUrl.cjs";
3
3
  import { SQSClient } from "@aws-sdk/client-sqs";
4
-
5
4
  //#region src/sqs/SQSConnection.d.ts
6
5
  interface SQSConnectionConfig {
7
6
  queueUrl: string;
@@ -13,7 +12,7 @@ interface SQSConnectionConfig {
13
12
  sessionToken?: string;
14
13
  };
15
14
  }
16
- declare class SQSConnection implements EventConnection {
15
+ export declare class SQSConnection implements EventConnection {
17
16
  readonly config: SQSConnectionConfig;
18
17
  readonly type = EventPublisherType.SQS;
19
18
  private client;
@@ -36,13 +35,12 @@ declare class SQSConnection implements EventConnection {
36
35
  */
37
36
  get queueUrl(): string;
38
37
  }
39
- //# sourceMappingURL=SQSConnection.d.ts.map
40
38
  //#endregion
41
39
  //#region src/sqs/SQSPublisher.d.ts
42
40
  interface SQSPublisherOptions {
43
41
  maxBatchSize?: number;
44
42
  }
45
- declare class SQSPublisher<TMessage extends PublishableMessage<string, any>> implements EventPublisher<TMessage> {
43
+ export declare class SQSPublisher<TMessage extends PublishableMessage<string, any>> implements EventPublisher<TMessage> {
46
44
  readonly connection: SQSConnection;
47
45
  readonly options: Required<SQSPublisherOptions>;
48
46
  constructor(connection: SQSConnection, options?: SQSPublisherOptions);
@@ -55,7 +53,19 @@ declare class SQSPublisher<TMessage extends PublishableMessage<string, any>> imp
55
53
  private sendBatch;
56
54
  close(): Promise<void>;
57
55
  }
58
- //# sourceMappingURL=SQSPublisher.d.ts.map
56
+ /** SQS accepted the batch but refused some of its messages; the rest were sent. */
57
+ export declare class SqsBatchPartlyFailed extends Error {
58
+ readonly failed: readonly {
59
+ id?: string;
60
+ code?: string;
61
+ message?: string;
62
+ }[];
63
+ constructor(failed: readonly {
64
+ id?: string;
65
+ code?: string;
66
+ message?: string;
67
+ }[]);
68
+ }
59
69
  //#endregion
60
70
  //#region src/sqs/SQSSubscriber.d.ts
61
71
  interface SQSSubscriberOptions {
@@ -76,7 +86,7 @@ interface SQSSubscriberOptions {
76
86
  * - Filters by message type
77
87
  * - Processes the actual message payload
78
88
  */
79
- declare class SQSSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
89
+ export declare class SQSSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
80
90
  private connection;
81
91
  private polling;
82
92
  private messageTypes;
@@ -94,8 +104,6 @@ declare class SQSSubscriber<TMessage extends PublishableMessage<string, any>> im
94
104
  private deleteMessage;
95
105
  private sleep;
96
106
  }
97
- //# sourceMappingURL=SQSSubscriber.d.ts.map
98
-
99
107
  //#endregion
100
- export { SQSConnection, SQSConnectionConfig, SQSPublisher, SQSPublisherOptions, SQSSubscriber, SQSSubscriberOptions, SqsAddress, sqsUrl_d_exports as sqsUrl };
108
+ export { type SQSConnectionConfig, type SQSPublisherOptions, type SQSSubscriberOptions, type SqsAddress, sqsUrl_d_exports as sqsUrl };
101
109
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/sqs/SQSConnection.ts","../../src/sqs/SQSPublisher.ts","../../src/sqs/SQSSubscriber.ts"],"sourcesContent":[],"mappings":";;;;;UAKiB,mBAAA;;EAAA,MAAA,CAAA,EAAA,MAAA;EAWJ,QAAA,CAAA,EAAA,MAAc;EAAA,WAAA,CAAA,EAAA;IAKG,WAAA,EAAA,MAAA;IAJhB,eAAA,EAAA,MAAA;IAIgB,YAAA,CAAA,EAAA,MAAA;EAAmB,CAAA;;AAgD/B,cArDL,aAAA,YAAyB,eAqDpB,CAAA;EAAO,SAKT,MAAA,EArDc,mBAqDd;EAAO,SAYL,IAAA,GArEJ,kBAAA,CAAA,GAAA;EAqEa,QAtEW,MAAA;EAAe,QAAA,SAAA;sBAKvB;;;ACZ9B;AAIA;EAAyB,OAAA,oBAAA,CAAA,gBAAA,EAAA,MAAA,CAAA,ED0BrB,OC1BqB,CD0Bb,aC1Ba,CAAA;EAAA,OAAkB,CAAA,CAAA,EDwDzB,OCxDyB,CAAA,IAAA,CAAA;EAAkB,KAClC,CAAA,CAAA,ED4DX,OC5DW,CAAA,IAAA,CAAA;EAAQ,WAKZ,CAAA,CAAA,EAAA,OAAA;EAAa;;;EAAA,IACzB,SAAA,CAAA,CAAA,EDkEO,SClEP;EAAwB;;;EAae,IAApB,QAAA,CAAA,CAAA,EAAA,MAAA;;;;;UAxBb,mBAAA;;;ADJA,cCQJ,YDRuB,CAAA,iBCQO,kBDRP,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,YCSxB,cDTwB,CCST,QDTS,CAAA,CAAA;EAWvB,SAAA,UAAc,ECGJ,aDHI;EAAA,SAAA,OAAA,ECAR,QDAQ,CCAC,mBDAD,CAAA;EAAA,WAKG,CAAA,UAAA,ECFP,aDEO,EAAA,OAAA,CAAA,ECDnB,mBDCmB;EAAmB;;;;EAkBtC,OA8BO,oBAAA,CAAA,iBCrCC,kBDqCD,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,gBAAA,EAAA,MAAA,CAAA,ECpCY,ODoCZ,CCpCoB,YDoCpB,CCpCiC,QDoCjC,CAAA,CAAA;EAAO,OAKT,CAAA,QAAA,ECxBS,QDwBT,EAAA,CAAA,ECxBsB,ODwBtB,CAAA,IAAA,CAAA;EAAO,QAYL,SAAA;EAAS,KAtEW,CAAA,CAAA,ECoFtB,ODpFsB,CAAA,IAAA,CAAA;AAAe;;;;UERpC,oBAAA;;;EFHA,gBAAA,CAAA,EAAA,MAAmB;AAWpC;;;;;;;;;;;AAAqD;;;cEWxC,+BAA+B,4CAChC,gBAAgB;EDnBX,QAAA,UAAA;EAIJ,QAAA,OAAY;EAAA,QAAA,YAAA;EAAA,QAAkB,QAAA;EAAkB,QAClC,OAAA;EAAQ,WAKZ,CAAA,UAAA,ECiBD,aDjBC,EAAA,OAAA,CAAA,ECkBZ,oBDlBY;EAAa,SAHR,CAAA,QAAA,EC+BhB,QD/BgB,CAAA,MAAA,CAAA,EAAA,EAAA,QAAA,EAAA,CAAA,OAAA,ECgCN,QDhCM,EAAA,GCgCO,ODhCP,CAAA,IAAA,CAAA,CAAA,ECiCxB,ODjCwB,CAAA,IAAA,CAAA;EAAmB,IAA5B,CAAA,CAAA,EAAA,IAAA;EAAQ,QAGJ,IAAA;EAAa,QACzB,eAAA;EAAwB;;;EAae,QAApB,YAAA;EAAO,QAiBZ,aAAA;EAAQ,QAAK,KAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/sqs/SQSConnection.ts","../../src/sqs/SQSPublisher.ts","../../src/sqs/SQSSubscriber.ts"],"mappings":";;;;UAKiB;EAChB;EACA;EACA;EACA;IACC;IACA;IACA;;;qBAIW,yBAAyB;WAKhB,QAAQ;WAJpB,OAAI,mBAAA;UACL;UACA;EAER,YAAqB,QAAQ;;;;;SAgBhB,qBACZ,2BACE,QAAQ;EA8BL,WAAW;EAKX,SAAS;EAKf;;;;MAOI,aAAa;;;;MAOb;;;;UCpFY;EAChB;;qBAGY,aAAa,iBAAiB,4CAC/B,eAAe;WAKhB,YAAY;WAHb,SAAS,SAAS;EAE3B,YACU,YAAY,eACrB,UAAS;;;;;SAWG,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,aAAa;EAiB5C,QAAQ,UAAU,aAAa;UAcvB;EAqCR,SAAS;;;qBAOH,6BAA6B;WAE/B;IACR;IACA;IACA;;EAJF,YACU;IACR;IACA;IACA;;;;;UCzGc;EAChB;EACA;EACA;;;;;;;;;;;;;;;qBAgBY,cAAc,iBAAiB,4CAChC,gBAAgB;UAQlB;UAND;UACA;UACA;UACA;EAER,YACS,YAAY,eACpB,UAAS;EASJ,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B;EAYH;UAIc;UAqBA;;;;UAiDN;UAgCM;UAUN"}
@@ -1,7 +1,6 @@
1
- import { EventConnection, EventPublisher, EventPublisherType, EventSubscriber, PublishableMessage } from "../types-DycjsYms.mjs";
2
- import { SqsAddress, sqsUrl_d_exports } from "../sqsUrl-BV6zS-mi.mjs";
1
+ import { i as EventSubscriber, n as EventPublisher, r as EventPublisherType, s as PublishableMessage, t as EventConnection } from "../types-gGaoT8qc.mjs";
2
+ import { SqsAddress, t as sqsUrl_d_exports } from "./sqsUrl.mjs";
3
3
  import { SQSClient } from "@aws-sdk/client-sqs";
4
-
5
4
  //#region src/sqs/SQSConnection.d.ts
6
5
  interface SQSConnectionConfig {
7
6
  queueUrl: string;
@@ -13,7 +12,7 @@ interface SQSConnectionConfig {
13
12
  sessionToken?: string;
14
13
  };
15
14
  }
16
- declare class SQSConnection implements EventConnection {
15
+ export declare class SQSConnection implements EventConnection {
17
16
  readonly config: SQSConnectionConfig;
18
17
  readonly type = EventPublisherType.SQS;
19
18
  private client;
@@ -36,13 +35,12 @@ declare class SQSConnection implements EventConnection {
36
35
  */
37
36
  get queueUrl(): string;
38
37
  }
39
- //# sourceMappingURL=SQSConnection.d.ts.map
40
38
  //#endregion
41
39
  //#region src/sqs/SQSPublisher.d.ts
42
40
  interface SQSPublisherOptions {
43
41
  maxBatchSize?: number;
44
42
  }
45
- declare class SQSPublisher<TMessage extends PublishableMessage<string, any>> implements EventPublisher<TMessage> {
43
+ export declare class SQSPublisher<TMessage extends PublishableMessage<string, any>> implements EventPublisher<TMessage> {
46
44
  readonly connection: SQSConnection;
47
45
  readonly options: Required<SQSPublisherOptions>;
48
46
  constructor(connection: SQSConnection, options?: SQSPublisherOptions);
@@ -55,7 +53,19 @@ declare class SQSPublisher<TMessage extends PublishableMessage<string, any>> imp
55
53
  private sendBatch;
56
54
  close(): Promise<void>;
57
55
  }
58
- //# sourceMappingURL=SQSPublisher.d.ts.map
56
+ /** SQS accepted the batch but refused some of its messages; the rest were sent. */
57
+ export declare class SqsBatchPartlyFailed extends Error {
58
+ readonly failed: readonly {
59
+ id?: string;
60
+ code?: string;
61
+ message?: string;
62
+ }[];
63
+ constructor(failed: readonly {
64
+ id?: string;
65
+ code?: string;
66
+ message?: string;
67
+ }[]);
68
+ }
59
69
  //#endregion
60
70
  //#region src/sqs/SQSSubscriber.d.ts
61
71
  interface SQSSubscriberOptions {
@@ -76,7 +86,7 @@ interface SQSSubscriberOptions {
76
86
  * - Filters by message type
77
87
  * - Processes the actual message payload
78
88
  */
79
- declare class SQSSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
89
+ export declare class SQSSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
80
90
  private connection;
81
91
  private polling;
82
92
  private messageTypes;
@@ -94,8 +104,6 @@ declare class SQSSubscriber<TMessage extends PublishableMessage<string, any>> im
94
104
  private deleteMessage;
95
105
  private sleep;
96
106
  }
97
- //# sourceMappingURL=SQSSubscriber.d.ts.map
98
-
99
107
  //#endregion
100
- export { SQSConnection, SQSConnectionConfig, SQSPublisher, SQSPublisherOptions, SQSSubscriber, SQSSubscriberOptions, SqsAddress, sqsUrl_d_exports as sqsUrl };
108
+ export { type SQSConnectionConfig, type SQSPublisherOptions, type SQSSubscriberOptions, type SqsAddress, sqsUrl_d_exports as sqsUrl };
101
109
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/sqs/SQSConnection.ts","../../src/sqs/SQSPublisher.ts","../../src/sqs/SQSSubscriber.ts"],"sourcesContent":[],"mappings":";;;;;UAKiB,mBAAA;;EAAA,MAAA,CAAA,EAAA,MAAA;EAWJ,QAAA,CAAA,EAAA,MAAc;EAAA,WAAA,CAAA,EAAA;IAKG,WAAA,EAAA,MAAA;IAJhB,eAAA,EAAA,MAAA;IAIgB,YAAA,CAAA,EAAA,MAAA;EAAmB,CAAA;;AAgD/B,cArDL,aAAA,YAAyB,eAqDpB,CAAA;EAAO,SAKT,MAAA,EArDc,mBAqDd;EAAO,SAYL,IAAA,GArEJ,kBAAA,CAAA,GAAA;EAqEa,QAtEW,MAAA;EAAe,QAAA,SAAA;sBAKvB;;;ACZ9B;AAIA;EAAyB,OAAA,oBAAA,CAAA,gBAAA,EAAA,MAAA,CAAA,ED0BrB,OC1BqB,CD0Bb,aC1Ba,CAAA;EAAA,OAAkB,CAAA,CAAA,EDwDzB,OCxDyB,CAAA,IAAA,CAAA;EAAkB,KAClC,CAAA,CAAA,ED4DX,OC5DW,CAAA,IAAA,CAAA;EAAQ,WAKZ,CAAA,CAAA,EAAA,OAAA;EAAa;;;EAAA,IACzB,SAAA,CAAA,CAAA,EDkEO,SClEP;EAAwB;;;EAae,IAApB,QAAA,CAAA,CAAA,EAAA,MAAA;;;;;UAxBb,mBAAA;;;ADJA,cCQJ,YDRuB,CAAA,iBCQO,kBDRP,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,YCSxB,cDTwB,CCST,QDTS,CAAA,CAAA;EAWvB,SAAA,UAAc,ECGJ,aDHI;EAAA,SAAA,OAAA,ECAR,QDAQ,CCAC,mBDAD,CAAA;EAAA,WAKG,CAAA,UAAA,ECFP,aDEO,EAAA,OAAA,CAAA,ECDnB,mBDCmB;EAAmB;;;;EAkBtC,OA8BO,oBAAA,CAAA,iBCrCC,kBDqCD,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,gBAAA,EAAA,MAAA,CAAA,ECpCY,ODoCZ,CCpCoB,YDoCpB,CCpCiC,QDoCjC,CAAA,CAAA;EAAO,OAKT,CAAA,QAAA,ECxBS,QDwBT,EAAA,CAAA,ECxBsB,ODwBtB,CAAA,IAAA,CAAA;EAAO,QAYL,SAAA;EAAS,KAtEW,CAAA,CAAA,ECoFtB,ODpFsB,CAAA,IAAA,CAAA;AAAe;;;;UERpC,oBAAA;;;EFHA,gBAAA,CAAA,EAAA,MAAmB;AAWpC;;;;;;;;;;;AAAqD;;;cEWxC,+BAA+B,4CAChC,gBAAgB;EDnBX,QAAA,UAAA;EAIJ,QAAA,OAAY;EAAA,QAAA,YAAA;EAAA,QAAkB,QAAA;EAAkB,QAClC,OAAA;EAAQ,WAKZ,CAAA,UAAA,ECiBD,aDjBC,EAAA,OAAA,CAAA,ECkBZ,oBDlBY;EAAa,SAHR,CAAA,QAAA,EC+BhB,QD/BgB,CAAA,MAAA,CAAA,EAAA,EAAA,QAAA,EAAA,CAAA,OAAA,ECgCN,QDhCM,EAAA,GCgCO,ODhCP,CAAA,IAAA,CAAA,CAAA,ECiCxB,ODjCwB,CAAA,IAAA,CAAA;EAAmB,IAA5B,CAAA,CAAA,EAAA,IAAA;EAAQ,QAGJ,IAAA;EAAa,QACzB,eAAA;EAAwB;;;EAae,QAApB,YAAA;EAAO,QAiBZ,aAAA;EAAQ,QAAK,KAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/sqs/SQSConnection.ts","../../src/sqs/SQSPublisher.ts","../../src/sqs/SQSSubscriber.ts"],"mappings":";;;;UAKiB;EAChB;EACA;EACA;EACA;IACC;IACA;IACA;;;qBAIW,yBAAyB;WAKhB,QAAQ;WAJpB,OAAI,mBAAA;UACL;UACA;EAER,YAAqB,QAAQ;;;;;SAgBhB,qBACZ,2BACE,QAAQ;EA8BL,WAAW;EAKX,SAAS;EAKf;;;;MAOI,aAAa;;;;MAOb;;;;UCpFY;EAChB;;qBAGY,aAAa,iBAAiB,4CAC/B,eAAe;WAKhB,YAAY;WAHb,SAAS,SAAS;EAE3B,YACU,YAAY,eACrB,UAAS;;;;;SAWG,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,aAAa;EAiB5C,QAAQ,UAAU,aAAa;UAcvB;EAqCR,SAAS;;;qBAOH,6BAA6B;WAE/B;IACR;IACA;IACA;;EAJF,YACU;IACR;IACA;IACA;;;;;UCzGc;EAChB;EACA;EACA;;;;;;;;;;;;;;;qBAgBY,cAAc,iBAAiB,4CAChC,gBAAgB;UAQlB;UAND;UACA;UACA;UACA;EAER,YACS,YAAY,eACpB,UAAS;EASJ,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B;EAYH;UAIc;UAqBA;;;;UAiDN;UAgCM;UAUN"}
@@ -1,12 +1,10 @@
1
- import "../types-CYDt-2RQ.mjs";
2
- import { sqsUrl_exports } from "../sqsUrl-CbAsBFHI.mjs";
3
- import { SQSConnection } from "../SQSConnection-4tBMkVZE.mjs";
4
- import { SQSSubscriber } from "../SQSSubscriber-BMWZ3s5q.mjs";
1
+ import { t as sqsUrl_exports } from "./sqsUrl.mjs";
2
+ import { n as SQSConnection, t as SQSSubscriber } from "../SQSSubscriber-BXLE_1L3.mjs";
5
3
  import { SendMessageBatchCommand } from "@aws-sdk/client-sqs";
6
4
  import chunk from "lodash.chunk";
7
-
8
5
  //#region src/sqs/SQSPublisher.ts
9
6
  var SQSPublisher = class SQSPublisher {
7
+ connection;
10
8
  options;
11
9
  constructor(connection, options = {}) {
12
10
  this.connection = connection;
@@ -17,10 +15,9 @@ var SQSPublisher = class SQSPublisher {
17
15
  * Format: sqs://?queueUrl=https://sqs.region.amazonaws.com/accountId/queueName&region=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10
18
16
  */
19
17
  static async fromConnectionString(connectionString) {
20
- const url = new URL(connectionString);
21
- const params = url.searchParams;
22
- const { SQSConnection: SQSConnection$1 } = await import("../SQSConnection-DbavOq8_.mjs");
23
- const connection = await SQSConnection$1.fromConnectionString(connectionString);
18
+ const params = new URL(connectionString).searchParams;
19
+ const { SQSConnection } = await import("../SQSSubscriber-BXLE_1L3.mjs").then((n) => n.r);
20
+ const connection = await SQSConnection.fromConnectionString(connectionString);
24
21
  const options = { maxBatchSize: params.get("maxBatchSize") ? Number.parseInt(params.get("maxBatchSize"), 10) : void 0 };
25
22
  return new SQSPublisher(connection, options);
26
23
  }
@@ -48,14 +45,24 @@ var SQSPublisher = class SQSPublisher {
48
45
  };
49
46
  const command = new SendMessageBatchCommand(input);
50
47
  const response = await this.connection.sqsClient.send(command);
51
- if (response.Failed && response.Failed.length > 0) {
52
- const errors = response.Failed.map((f) => `${f.Id}: ${f.Code} - ${f.Message}`).join(", ");
53
- throw new Error(`Failed to send ${response.Failed.length} messages: ${errors}`);
54
- }
48
+ if (response.Failed && response.Failed.length > 0) throw new SqsBatchPartlyFailed(response.Failed.map((f) => ({
49
+ id: f.Id,
50
+ code: f.Code,
51
+ message: f.Message
52
+ })));
55
53
  }
56
54
  async close() {}
57
55
  };
58
-
56
+ /** SQS accepted the batch but refused some of its messages; the rest were sent. */
57
+ var SqsBatchPartlyFailed = class extends Error {
58
+ failed;
59
+ constructor(failed) {
60
+ super(`Failed to send ${failed.length} messages: ${failed.map((f) => `${f.id}: ${f.code} - ${f.message}`).join(", ")}. The others in the batch were sent; retry only these.`);
61
+ this.failed = failed;
62
+ this.name = "SqsBatchPartlyFailed";
63
+ }
64
+ };
59
65
  //#endregion
60
- export { SQSConnection, SQSPublisher, SQSSubscriber, sqsUrl_exports as sqsUrl };
66
+ export { SQSConnection, SQSPublisher, SQSSubscriber, SqsBatchPartlyFailed, sqsUrl_exports as sqsUrl };
67
+
61
68
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.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&region=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,gCAAe,GAAG,MAAM,OAAO;EACvC,MAAM,aACL,MAAM,gBAAc,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"}
1
+ {"version":3,"file":"index.mjs","names":[],"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&region=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\tthrow new SqsBatchPartlyFailed(\n\t\t\t\tresponse.Failed.map((f) => ({\n\t\t\t\t\tid: f.Id,\n\t\t\t\t\tcode: f.Code,\n\t\t\t\t\tmessage: f.Message,\n\t\t\t\t})),\n\t\t\t);\n\t\t}\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t\t// Connection should be closed by whoever created it\n\t}\n}\n\n/** SQS accepted the batch but refused some of its messages; the rest were sent. */\nexport class SqsBatchPartlyFailed extends Error {\n\tconstructor(\n\t\treadonly failed: readonly {\n\t\t\tid?: string;\n\t\t\tcode?: string;\n\t\t\tmessage?: string;\n\t\t}[],\n\t) {\n\t\tsuper(\n\t\t\t`Failed to send ${failed.length} messages: ${failed.map((f) => `${f.id}: ${f.code} - ${f.message}`).join(', ')}. The others in the batch were sent; retry only these.`,\n\t\t);\n\t\tthis.name = 'SqsBatchPartlyFailed';\n\t}\n}\n"],"mappings":";;;;;AAaA,IAAa,eAAb,MAAa,aAEb;CAIW;CAHV;CAEA,YACC,YACA,UAA+B,CAAC,GAC/B;EAFQ,KAAA,aAAA;EAGT,KAAK,UAAU,EACd,cAAc,QAAQ,gBAAgB,GACvC;CACD;;;;;CAMA,aAAa,qBAEX,kBAA2D;EAE5D,MAAM,SAAS,IADC,IAAI,gBACH,CAAC,CAAC;EAEnB,MAAM,EAAE,kBAAkB,MAAM,OAAO,gCAAkB,CAAA,MAAA,MAAA,EAAA,CAAA;EACzD,MAAM,aACL,MAAM,cAAc,qBAAqB,gBAAgB;EAE1D,MAAM,UAA+B,EACpC,cAAc,OAAO,IAAI,cAAc,IACpC,OAAO,SAAS,OAAO,IAAI,cAAc,GAAI,EAAE,IAC/C,KAAA,EACJ;EAEA,OAAO,IAAI,aAAuB,YAAY,OAAO;CACtD;CAEA,MAAM,QAAQ,UAAqC;EAClD,IAAI,SAAS,WAAW,GAAG;EAE3B,IAAI,CAAC,KAAK,WAAW,YAAY,GAChC,MAAM,KAAK,WAAW,QAAQ;EAI/B,MAAM,UAAU,MAAM,UAAU,KAAK,QAAQ,YAAY;EAGzD,MAAM,QAAQ,IAAI,QAAQ,KAAK,UAAU,KAAK,UAAU,KAAK,CAAC,CAAC;CAChE;CAEA,MAAc,UAAU,UAAqC;EAC5D,MAAM,UAA0C,SAAS,KACvD,SAAS,WAAW;GACpB,IAAI,GAAG;GACP,aAAa,KAAK,UAAU;IAC3B,MAAM,QAAQ;IACd,SAAS,QAAQ;GAClB,CAAC;GACD,mBAAmB,EAClB,MAAM;IACL,UAAU;IACV,aAAa,QAAQ;GACtB,EACD;EACD,EACD;EAEA,MAAM,QAAsC;GAC3C,UAAU,KAAK,WAAW;GAC1B,SAAS;EACV;EAEA,MAAM,UAAU,IAAI,wBAAwB,KAAK;EACjD,MAAM,WAAW,MAAM,KAAK,WAAW,UAAU,KAAK,OAAO;EAG7D,IAAI,SAAS,UAAU,SAAS,OAAO,SAAS,GAC/C,MAAM,IAAI,qBACT,SAAS,OAAO,KAAK,OAAO;GAC3B,IAAI,EAAE;GACN,MAAM,EAAE;GACR,SAAS,EAAE;EACZ,EAAE,CACH;CAEF;CAEA,MAAM,QAAuB,CAG7B;AACD;;AAGA,IAAa,uBAAb,cAA0C,MAAM;CAErC;CADV,YACC,QAKC;EACD,MACC,kBAAkB,OAAO,OAAO,aAAa,OAAO,KAAK,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,EAAE,SAAS,CAAC,CAAC,KAAK,IAAI,EAAE,uDAChH;EARS,KAAA,SAAA;EAST,KAAK,OAAO;CACb;AACD"}