@geekmidas/events 10.0.0-alpha.2 → 10.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PgBossConnection-CywKoAZU.cjs +2 -0
- package/dist/PgBossConnection-DjoqT84r.mjs +2 -0
- package/dist/RabbitMQConnection-C9eccBL8.cjs +2 -0
- package/dist/RabbitMQConnection-CAp7VqyT.mjs +2 -0
- package/dist/SNSConnection-BWDC1wAF.cjs +2 -0
- package/dist/SNSConnection-ezQvVrDv.mjs +2 -0
- package/dist/{SQSSubscriber-BMWZ3s5q.mjs → SQSSubscriber-BXLE_1L3.mjs} +73 -7
- package/dist/SQSSubscriber-BXLE_1L3.mjs.map +1 -0
- package/dist/{SQSSubscriber-YXPlg2rm.cjs → SQSSubscriber-DtRUaZB3.cjs} +91 -14
- package/dist/SQSSubscriber-DtRUaZB3.cjs.map +1 -0
- package/dist/basic/index.cjs +7 -8
- package/dist/basic/index.cjs.map +1 -1
- package/dist/basic/index.d.cts +4 -10
- package/dist/basic/index.d.cts.map +1 -1
- package/dist/basic/index.d.mts +4 -10
- package/dist/basic/index.d.mts.map +1 -1
- package/dist/basic/index.mjs +5 -6
- package/dist/basic/index.mjs.map +1 -1
- package/dist/index.cjs +39 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +38 -47
- package/dist/index.mjs.map +1 -1
- package/dist/pgboss/index.cjs +98 -21
- package/dist/pgboss/index.cjs.map +1 -1
- package/dist/pgboss/index.d.cts +11 -10
- package/dist/pgboss/index.d.cts.map +1 -1
- package/dist/pgboss/index.d.mts +11 -10
- package/dist/pgboss/index.d.mts.map +1 -1
- package/dist/pgboss/index.mjs +95 -21
- package/dist/pgboss/index.mjs.map +1 -1
- package/dist/rabbitmq/index.cjs +135 -22
- package/dist/rabbitmq/index.cjs.map +1 -1
- package/dist/rabbitmq/index.d.cts +11 -10
- package/dist/rabbitmq/index.d.cts.map +1 -1
- package/dist/rabbitmq/index.d.mts +11 -10
- package/dist/rabbitmq/index.d.mts.map +1 -1
- package/dist/rabbitmq/index.mjs +130 -22
- package/dist/rabbitmq/index.mjs.map +1 -1
- package/dist/{chunk-CsX-DzYB.cjs → rolldown-runtime-C0BPl7ul.cjs} +17 -16
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/sns/index.cjs +106 -34
- package/dist/sns/index.cjs.map +1 -1
- package/dist/sns/index.d.cts +14 -11
- package/dist/sns/index.d.cts.map +1 -1
- package/dist/sns/index.d.mts +14 -11
- package/dist/sns/index.d.mts.map +1 -1
- package/dist/sns/index.mjs +88 -18
- package/dist/sns/index.mjs.map +1 -1
- package/dist/sns/snsUrl.cjs +91 -6
- package/dist/sns/snsUrl.cjs.map +1 -0
- package/dist/sns/snsUrl.d.cts +57 -2
- package/dist/sns/snsUrl.d.cts.map +1 -0
- package/dist/sns/snsUrl.d.mts +57 -2
- package/dist/sns/snsUrl.d.mts.map +1 -0
- package/dist/sns/snsUrl.mjs +81 -2
- package/dist/sns/snsUrl.mjs.map +1 -0
- package/dist/sqs/index.cjs +34 -24
- package/dist/sqs/index.cjs.map +1 -1
- package/dist/sqs/index.d.cts +19 -11
- package/dist/sqs/index.d.cts.map +1 -1
- package/dist/sqs/index.d.mts +19 -11
- package/dist/sqs/index.d.mts.map +1 -1
- package/dist/sqs/index.mjs +22 -15
- package/dist/sqs/index.mjs.map +1 -1
- package/dist/sqs/sqsUrl.cjs +92 -6
- package/dist/sqs/sqsUrl.cjs.map +1 -0
- package/dist/sqs/sqsUrl.d.cts +56 -2
- package/dist/sqs/sqsUrl.d.cts.map +1 -0
- package/dist/sqs/sqsUrl.d.mts +56 -2
- package/dist/sqs/sqsUrl.d.mts.map +1 -0
- package/dist/sqs/sqsUrl.mjs +82 -2
- package/dist/sqs/sqsUrl.mjs.map +1 -0
- package/dist/types-BcZjLxVV.cjs +51 -0
- package/dist/types-BcZjLxVV.cjs.map +1 -0
- package/dist/types-Bk5JM6MP.mjs +40 -0
- package/dist/types-Bk5JM6MP.mjs.map +1 -0
- package/dist/types-gGaoT8qc.d.cts +149 -0
- package/dist/types-gGaoT8qc.d.cts.map +1 -0
- package/dist/types-gGaoT8qc.d.mts +149 -0
- package/dist/types-gGaoT8qc.d.mts.map +1 -0
- package/package.json +12 -12
- package/dist/PgBossConnection-23soZ_aM.cjs +0 -80
- package/dist/PgBossConnection-23soZ_aM.cjs.map +0 -1
- package/dist/PgBossConnection-CCXhoNzb.cjs +0 -4
- package/dist/PgBossConnection-DvNbd4Zk.mjs +0 -74
- package/dist/PgBossConnection-DvNbd4Zk.mjs.map +0 -1
- package/dist/PgBossConnection-_gdM40JB.mjs +0 -4
- package/dist/RabbitMQConnection-BKEdCUro.cjs +0 -113
- package/dist/RabbitMQConnection-BKEdCUro.cjs.map +0 -1
- package/dist/RabbitMQConnection-CCOqDDnb.cjs +0 -4
- package/dist/RabbitMQConnection-DJEyM-Bu.mjs +0 -4
- package/dist/RabbitMQConnection-DJgUPc19.mjs +0 -107
- package/dist/RabbitMQConnection-DJgUPc19.mjs.map +0 -1
- package/dist/SNSConnection-B2K86hpz.cjs +0 -75
- package/dist/SNSConnection-B2K86hpz.cjs.map +0 -1
- package/dist/SNSConnection-BVo84FeW.mjs +0 -5
- package/dist/SNSConnection-DIHRjrQF.cjs +0 -5
- package/dist/SNSConnection-v9jjF99w.mjs +0 -69
- package/dist/SNSConnection-v9jjF99w.mjs.map +0 -1
- package/dist/SQSConnection-4tBMkVZE.mjs +0 -69
- package/dist/SQSConnection-4tBMkVZE.mjs.map +0 -1
- package/dist/SQSConnection-BBLAvF-1.cjs +0 -5
- package/dist/SQSConnection-BaC7rGhI.cjs +0 -75
- package/dist/SQSConnection-BaC7rGhI.cjs.map +0 -1
- package/dist/SQSConnection-DbavOq8_.mjs +0 -5
- package/dist/SQSSubscriber-BMWZ3s5q.mjs.map +0 -1
- package/dist/SQSSubscriber-YXPlg2rm.cjs.map +0 -1
- package/dist/chunk-B9dir_RE.mjs +0 -11
- package/dist/snsUrl-ASdc0D1v.d.cts +0 -61
- package/dist/snsUrl-ASdc0D1v.d.cts.map +0 -1
- package/dist/snsUrl-CifYhPAa.mjs +0 -79
- package/dist/snsUrl-CifYhPAa.mjs.map +0 -1
- package/dist/snsUrl-FRbRcwF0.d.mts +0 -61
- package/dist/snsUrl-FRbRcwF0.d.mts.map +0 -1
- package/dist/snsUrl-f2gU3CzK.cjs +0 -114
- package/dist/snsUrl-f2gU3CzK.cjs.map +0 -1
- package/dist/sqsUrl-BV6zS-mi.d.mts +0 -60
- package/dist/sqsUrl-BV6zS-mi.d.mts.map +0 -1
- package/dist/sqsUrl-CbAsBFHI.mjs +0 -80
- package/dist/sqsUrl-CbAsBFHI.mjs.map +0 -1
- package/dist/sqsUrl-CdisN3GU.cjs +0 -115
- package/dist/sqsUrl-CdisN3GU.cjs.map +0 -1
- package/dist/sqsUrl-DZDPHxIk.d.cts +0 -60
- package/dist/sqsUrl-DZDPHxIk.d.cts.map +0 -1
- package/dist/types-BmixGrOD.d.cts +0 -67
- package/dist/types-BmixGrOD.d.cts.map +0 -1
- package/dist/types-Byv8N9ma.cjs +0 -24
- package/dist/types-Byv8N9ma.cjs.map +0 -1
- package/dist/types-CYDt-2RQ.mjs +0 -18
- package/dist/types-CYDt-2RQ.mjs.map +0 -1
- package/dist/types-DycjsYms.d.mts +0 -67
- package/dist/types-DycjsYms.d.mts.map +0 -1
package/dist/sqs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["
|
|
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®ion=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SQSPublisher<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { SQSConnection } = await import('./SQSConnection');\n\t\tconst connection =\n\t\t\tawait SQSConnection.fromConnectionString(connectionString);\n\n\t\tconst options: SQSPublisherOptions = {\n\t\t\tmaxBatchSize: params.get('maxBatchSize')\n\t\t\t\t? Number.parseInt(params.get('maxBatchSize')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new SQSPublisher<TMessage>(connection, options);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (messages.length === 0) return;\n\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\t// Split messages into batches (SQS limit is 10 messages per batch)\n\t\tconst batches = chunk(messages, this.options.maxBatchSize);\n\n\t\t// Send all batches\n\t\tawait Promise.all(batches.map((batch) => this.sendBatch(batch)));\n\t}\n\n\tprivate async sendBatch(messages: TMessage[]): Promise<void> {\n\t\tconst entries: SendMessageBatchRequestEntry[] = messages.map(\n\t\t\t(message, index) => ({\n\t\t\t\tId: `${index}`,\n\t\t\t\tMessageBody: JSON.stringify({\n\t\t\t\t\ttype: message.type,\n\t\t\t\t\tpayload: message.payload,\n\t\t\t\t}),\n\t\t\t\tMessageAttributes: {\n\t\t\t\t\ttype: {\n\t\t\t\t\t\tDataType: 'String',\n\t\t\t\t\t\tStringValue: message.type,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\n\t\tconst input: SendMessageBatchCommandInput = {\n\t\t\tQueueUrl: this.connection.queueUrl,\n\t\t\tEntries: entries,\n\t\t};\n\n\t\tconst command = new SendMessageBatchCommand(input);\n\t\tconst response = await this.connection.sqsClient.send(command);\n\n\t\t// Check for failures\n\t\tif (response.Failed && response.Failed.length > 0) {\n\t\t\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"}
|
package/dist/sqs/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SqsAddress, sqsUrl_d_exports } from "
|
|
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
|
-
|
|
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 {
|
|
108
|
+
export { type SQSConnectionConfig, type SQSPublisherOptions, type SQSSubscriberOptions, type SqsAddress, sqsUrl_d_exports as sqsUrl };
|
|
101
109
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/sqs/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/sqs/SQSConnection.ts","../../src/sqs/SQSPublisher.ts","../../src/sqs/SQSSubscriber.ts"],"
|
|
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"}
|
package/dist/sqs/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SqsAddress, sqsUrl_d_exports } from "
|
|
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
|
-
|
|
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 {
|
|
108
|
+
export { type SQSConnectionConfig, type SQSPublisherOptions, type SQSSubscriberOptions, type SqsAddress, sqsUrl_d_exports as sqsUrl };
|
|
101
109
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/sqs/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/sqs/SQSConnection.ts","../../src/sqs/SQSPublisher.ts","../../src/sqs/SQSSubscriber.ts"],"
|
|
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"}
|
package/dist/sqs/index.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import {
|
|
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®ion=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10
|
|
18
16
|
*/
|
|
19
17
|
static async fromConnectionString(connectionString) {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
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
|
-
|
|
53
|
-
|
|
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
|
package/dist/sqs/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[
|
|
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®ion=us-east-1&endpoint=http://localhost:4566&maxBatchSize=10\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SQSPublisher<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { SQSConnection } = await import('./SQSConnection');\n\t\tconst connection =\n\t\t\tawait SQSConnection.fromConnectionString(connectionString);\n\n\t\tconst options: SQSPublisherOptions = {\n\t\t\tmaxBatchSize: params.get('maxBatchSize')\n\t\t\t\t? Number.parseInt(params.get('maxBatchSize')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new SQSPublisher<TMessage>(connection, options);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (messages.length === 0) return;\n\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\t// Split messages into batches (SQS limit is 10 messages per batch)\n\t\tconst batches = chunk(messages, this.options.maxBatchSize);\n\n\t\t// Send all batches\n\t\tawait Promise.all(batches.map((batch) => this.sendBatch(batch)));\n\t}\n\n\tprivate async sendBatch(messages: TMessage[]): Promise<void> {\n\t\tconst entries: SendMessageBatchRequestEntry[] = messages.map(\n\t\t\t(message, index) => ({\n\t\t\t\tId: `${index}`,\n\t\t\t\tMessageBody: JSON.stringify({\n\t\t\t\t\ttype: message.type,\n\t\t\t\t\tpayload: message.payload,\n\t\t\t\t}),\n\t\t\t\tMessageAttributes: {\n\t\t\t\t\ttype: {\n\t\t\t\t\t\tDataType: 'String',\n\t\t\t\t\t\tStringValue: message.type,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\n\t\tconst input: SendMessageBatchCommandInput = {\n\t\t\tQueueUrl: this.connection.queueUrl,\n\t\t\tEntries: entries,\n\t\t};\n\n\t\tconst command = new SendMessageBatchCommand(input);\n\t\tconst response = await this.connection.sqsClient.send(command);\n\n\t\t// Check for failures\n\t\tif (response.Failed && response.Failed.length > 0) {\n\t\t\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"}
|
package/dist/sqs/sqsUrl.cjs
CHANGED
|
@@ -1,7 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/sqs/sqsUrl.ts
|
|
3
|
+
var sqsUrl_exports = /* @__PURE__ */ require("../rolldown-runtime-C0BPl7ul.cjs").__exportAll({
|
|
4
|
+
MalformedQueueUrl: () => MalformedQueueUrl,
|
|
5
|
+
MissingQueueUrl: () => MissingQueueUrl,
|
|
6
|
+
UnexpectedQueueScheme: () => UnexpectedQueueScheme,
|
|
7
|
+
build: () => build,
|
|
8
|
+
parse: () => parse
|
|
9
|
+
});
|
|
10
|
+
const SCHEME = "sqs:";
|
|
11
|
+
/**
|
|
12
|
+
* Compose an address into a connection string.
|
|
13
|
+
*
|
|
14
|
+
* Credentials never appear. The AWS SDK resolves them from its own chain — an
|
|
15
|
+
* execution role deployed, environment locally — so the string stays safe to log
|
|
16
|
+
* and identical across environments that differ only in who is calling.
|
|
17
|
+
*/
|
|
18
|
+
function build(address) {
|
|
19
|
+
const { queueUrl, region, endpoint, maxBatchSize } = address;
|
|
20
|
+
if (!queueUrl) throw new MissingQueueUrl("");
|
|
21
|
+
const url = new URL(`${SCHEME}//`);
|
|
22
|
+
url.searchParams.set("queueUrl", queueUrl);
|
|
23
|
+
if (region) url.searchParams.set("region", region);
|
|
24
|
+
if (endpoint) url.searchParams.set("endpoint", endpoint);
|
|
25
|
+
if (maxBatchSize !== void 0) url.searchParams.set("maxBatchSize", String(maxBatchSize));
|
|
26
|
+
return url.toString();
|
|
27
|
+
}
|
|
28
|
+
/** Parse a connection string back into an address. */
|
|
29
|
+
function parse(connectionString) {
|
|
30
|
+
let parsed;
|
|
31
|
+
try {
|
|
32
|
+
parsed = new URL(connectionString);
|
|
33
|
+
} catch {
|
|
34
|
+
throw new MalformedQueueUrl(connectionString);
|
|
35
|
+
}
|
|
36
|
+
if (parsed.protocol !== SCHEME) throw new UnexpectedQueueScheme(connectionString, SCHEME, parsed.protocol);
|
|
37
|
+
const queueUrl = parsed.searchParams.get("queueUrl");
|
|
38
|
+
if (!queueUrl) throw new MissingQueueUrl(connectionString);
|
|
39
|
+
const region = parsed.searchParams.get("region") ?? void 0;
|
|
40
|
+
const endpoint = parsed.searchParams.get("endpoint") ?? void 0;
|
|
41
|
+
const batch = parsed.searchParams.get("maxBatchSize");
|
|
42
|
+
return {
|
|
43
|
+
queueUrl,
|
|
44
|
+
...region ? { region } : {},
|
|
45
|
+
...endpoint ? { endpoint } : {},
|
|
46
|
+
...batch ? { maxBatchSize: Number(batch) } : {}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** The string is not a URL at all. */
|
|
50
|
+
var MalformedQueueUrl = class extends Error {
|
|
51
|
+
url;
|
|
52
|
+
constructor(url) {
|
|
53
|
+
super(`'${url}' is not a valid connection string.`);
|
|
54
|
+
this.url = url;
|
|
55
|
+
this.name = "MalformedQueueUrl";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/** The string is a URL, but not an `sqs://` one. */
|
|
59
|
+
var UnexpectedQueueScheme = class extends Error {
|
|
60
|
+
url;
|
|
61
|
+
expected;
|
|
62
|
+
actual;
|
|
63
|
+
constructor(url, expected, actual) {
|
|
64
|
+
super(`Expected a '${expected}//' connection string and got '${actual}//' in '${url}'.`);
|
|
65
|
+
this.url = url;
|
|
66
|
+
this.expected = expected;
|
|
67
|
+
this.actual = actual;
|
|
68
|
+
this.name = "UnexpectedQueueScheme";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/** An `sqs://` string with no queue names nothing. */
|
|
72
|
+
var MissingQueueUrl = class extends Error {
|
|
73
|
+
url;
|
|
74
|
+
constructor(url) {
|
|
75
|
+
super(url ? `'${url}' names no queue: an sqs:// connection string needs ?queueUrl=.` : "An sqs:// connection string needs a queueUrl.");
|
|
76
|
+
this.url = url;
|
|
77
|
+
this.name = "MissingQueueUrl";
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
exports.MalformedQueueUrl = MalformedQueueUrl;
|
|
82
|
+
exports.MissingQueueUrl = MissingQueueUrl;
|
|
83
|
+
exports.UnexpectedQueueScheme = UnexpectedQueueScheme;
|
|
84
|
+
exports.build = build;
|
|
85
|
+
exports.parse = parse;
|
|
86
|
+
Object.defineProperty(exports, "sqsUrl_exports", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function() {
|
|
89
|
+
return sqsUrl_exports;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
2
92
|
|
|
3
|
-
|
|
4
|
-
exports.MissingQueueUrl = require_sqsUrl.MissingQueueUrl;
|
|
5
|
-
exports.UnexpectedQueueScheme = require_sqsUrl.UnexpectedQueueScheme;
|
|
6
|
-
exports.build = require_sqsUrl.build;
|
|
7
|
-
exports.parse = require_sqsUrl.parse;
|
|
93
|
+
//# sourceMappingURL=sqsUrl.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqsUrl.cjs","names":[],"sources":["../../src/sqs/sqsUrl.ts"],"sourcesContent":["/**\n * The `sqs://` connection-string codec — how a queue is addressed as one string.\n *\n * It lives beside the client rather than in a neutral package because\n * `queueUrl`, `region`, and `endpoint` are SQS's vocabulary. The neutral layer\n * knows only that a queue provides *one* connection string; what that string\n * says is between the component that composes it and the publisher that parses\n * it. The `pgboss://` form sits beside its own client and shares nothing here.\n *\n * Both directions live in this module so they cannot drift: `parse(build(x))`\n * is `x`, and the deploy target composing a string it cannot parse back is the\n * failure this shape rules out.\n */\n\n/** What an SQS connection string addresses. */\nexport interface SqsAddress {\n\tqueueUrl: string;\n\t/** Read off the queue, never inherited: a queue may live in another region. */\n\tregion?: string;\n\t/** Set for SQS-compatible backends such as LocalStack. */\n\tendpoint?: string;\n\t/** Largest batch the publisher may send in one call. */\n\tmaxBatchSize?: number;\n}\n\nconst SCHEME = 'sqs:';\n\n/**\n * Compose an address into a connection string.\n *\n * Credentials never appear. The AWS SDK resolves them from its own chain — an\n * execution role deployed, environment locally — so the string stays safe to log\n * and identical across environments that differ only in who is calling.\n */\nexport function build(address: SqsAddress): string {\n\tconst { queueUrl, region, endpoint, maxBatchSize } = address;\n\tif (!queueUrl) throw new MissingQueueUrl('');\n\n\tconst url = new URL(`${SCHEME}//`);\n\turl.searchParams.set('queueUrl', queueUrl);\n\tif (region) url.searchParams.set('region', region);\n\tif (endpoint) url.searchParams.set('endpoint', endpoint);\n\tif (maxBatchSize !== undefined) {\n\t\turl.searchParams.set('maxBatchSize', String(maxBatchSize));\n\t}\n\n\treturn url.toString();\n}\n\n/** Parse a connection string back into an address. */\nexport function parse(connectionString: string): SqsAddress {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(connectionString);\n\t} catch {\n\t\tthrow new MalformedQueueUrl(connectionString);\n\t}\n\n\tif (parsed.protocol !== SCHEME) {\n\t\tthrow new UnexpectedQueueScheme(connectionString, SCHEME, parsed.protocol);\n\t}\n\n\tconst queueUrl = parsed.searchParams.get('queueUrl');\n\tif (!queueUrl) throw new MissingQueueUrl(connectionString);\n\n\tconst region = parsed.searchParams.get('region') ?? undefined;\n\tconst endpoint = parsed.searchParams.get('endpoint') ?? undefined;\n\tconst batch = parsed.searchParams.get('maxBatchSize');\n\n\treturn {\n\t\tqueueUrl,\n\t\t...(region ? { region } : {}),\n\t\t...(endpoint ? { endpoint } : {}),\n\t\t...(batch ? { maxBatchSize: Number(batch) } : {}),\n\t};\n}\n\n/** The string is not a URL at all. */\nexport class MalformedQueueUrl extends Error {\n\tconstructor(readonly url: string) {\n\t\tsuper(`'${url}' is not a valid connection string.`);\n\t\tthis.name = 'MalformedQueueUrl';\n\t}\n}\n\n/** The string is a URL, but not an `sqs://` one. */\nexport class UnexpectedQueueScheme 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 = 'UnexpectedQueueScheme';\n\t}\n}\n\n/** An `sqs://` string with no queue names nothing. */\nexport class MissingQueueUrl extends Error {\n\tconstructor(readonly url: string) {\n\t\tsuper(\n\t\t\turl\n\t\t\t\t? `'${url}' names no queue: an sqs:// connection string needs ?queueUrl=.`\n\t\t\t\t: 'An sqs:// connection string needs a queueUrl.',\n\t\t);\n\t\tthis.name = 'MissingQueueUrl';\n\t}\n}\n"],"mappings":";;;;;;;;;AAyBA,MAAM,SAAS;;;;;;;;AASf,SAAgB,MAAM,SAA6B;CAClD,MAAM,EAAE,UAAU,QAAQ,UAAU,iBAAiB;CACrD,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,iBAAiB,KAAA,GACpB,IAAI,aAAa,IAAI,gBAAgB,OAAO,YAAY,CAAC;CAG1D,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,QAAQ,OAAO,aAAa,IAAI,cAAc;CAEpD,OAAO;EACN;EACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;EAC/B,GAAI,QAAQ,EAAE,cAAc,OAAO,KAAK,EAAE,IAAI,CAAC;CAChD;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"}
|
package/dist/sqs/sqsUrl.d.cts
CHANGED
|
@@ -1,2 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
export { MalformedQueueUrl, MissingQueueUrl, SqsAddress, UnexpectedQueueScheme, build, parse };
|
|
1
|
+
declare namespace sqsUrl_d_exports {
|
|
2
|
+
export { MalformedQueueUrl, MissingQueueUrl, SqsAddress, UnexpectedQueueScheme, build, parse };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* The `sqs://` connection-string codec — how a queue is addressed as one string.
|
|
6
|
+
*
|
|
7
|
+
* It lives beside the client rather than in a neutral package because
|
|
8
|
+
* `queueUrl`, `region`, and `endpoint` are SQS's vocabulary. The neutral layer
|
|
9
|
+
* knows only that a queue provides *one* connection string; what that string
|
|
10
|
+
* says is between the component that composes it and the publisher that parses
|
|
11
|
+
* it. The `pgboss://` form sits beside its own client and shares nothing here.
|
|
12
|
+
*
|
|
13
|
+
* Both directions live in this module so they cannot drift: `parse(build(x))`
|
|
14
|
+
* is `x`, and the deploy target composing a string it cannot parse back is the
|
|
15
|
+
* failure this shape rules out.
|
|
16
|
+
*/
|
|
17
|
+
/** What an SQS connection string addresses. */
|
|
18
|
+
export interface SqsAddress {
|
|
19
|
+
queueUrl: string;
|
|
20
|
+
/** Read off the queue, never inherited: a queue may live in another region. */
|
|
21
|
+
region?: string;
|
|
22
|
+
/** Set for SQS-compatible backends such as LocalStack. */
|
|
23
|
+
endpoint?: string;
|
|
24
|
+
/** Largest batch the publisher may send in one call. */
|
|
25
|
+
maxBatchSize?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Compose an address into a connection string.
|
|
29
|
+
*
|
|
30
|
+
* Credentials never appear. The AWS SDK resolves them from its own chain — an
|
|
31
|
+
* execution role deployed, environment locally — so the string stays safe to log
|
|
32
|
+
* and identical across environments that differ only in who is calling.
|
|
33
|
+
*/
|
|
34
|
+
export declare function build(address: SqsAddress): string;
|
|
35
|
+
/** Parse a connection string back into an address. */
|
|
36
|
+
export declare function parse(connectionString: string): SqsAddress;
|
|
37
|
+
/** The string is not a URL at all. */
|
|
38
|
+
export declare class MalformedQueueUrl extends Error {
|
|
39
|
+
readonly url: string;
|
|
40
|
+
constructor(url: string);
|
|
41
|
+
}
|
|
42
|
+
/** The string is a URL, but not an `sqs://` one. */
|
|
43
|
+
export declare class UnexpectedQueueScheme extends Error {
|
|
44
|
+
readonly url: string;
|
|
45
|
+
readonly expected: string;
|
|
46
|
+
readonly actual: string;
|
|
47
|
+
constructor(url: string, expected: string, actual: string);
|
|
48
|
+
}
|
|
49
|
+
/** An `sqs://` string with no queue names nothing. */
|
|
50
|
+
export declare class MissingQueueUrl extends Error {
|
|
51
|
+
readonly url: string;
|
|
52
|
+
constructor(url: string);
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { sqsUrl_d_exports as t };
|
|
56
|
+
//# sourceMappingURL=sqsUrl.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqsUrl.d.cts","names":[],"sources":["../../src/sqs/sqsUrl.ts"],"mappings":";;;;;;;;;;;;;;;;;iBAeiB;EAChB;;EAEA;;EAEA;;EAEA;;;;;;;;;wBAYe,MAAM,SAAS;;wBAgBf,MAAM,2BAA2B;;qBA4BpC,0BAA0B;WACjB;EAArB,YAAqB;;;qBAOT,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,aACA,kBACA;;;qBAUE,wBAAwB;WACf;EAArB,YAAqB"}
|
package/dist/sqs/sqsUrl.d.mts
CHANGED
|
@@ -1,2 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
export { MalformedQueueUrl, MissingQueueUrl, SqsAddress, UnexpectedQueueScheme, build, parse };
|
|
1
|
+
declare namespace sqsUrl_d_exports {
|
|
2
|
+
export { MalformedQueueUrl, MissingQueueUrl, SqsAddress, UnexpectedQueueScheme, build, parse };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* The `sqs://` connection-string codec — how a queue is addressed as one string.
|
|
6
|
+
*
|
|
7
|
+
* It lives beside the client rather than in a neutral package because
|
|
8
|
+
* `queueUrl`, `region`, and `endpoint` are SQS's vocabulary. The neutral layer
|
|
9
|
+
* knows only that a queue provides *one* connection string; what that string
|
|
10
|
+
* says is between the component that composes it and the publisher that parses
|
|
11
|
+
* it. The `pgboss://` form sits beside its own client and shares nothing here.
|
|
12
|
+
*
|
|
13
|
+
* Both directions live in this module so they cannot drift: `parse(build(x))`
|
|
14
|
+
* is `x`, and the deploy target composing a string it cannot parse back is the
|
|
15
|
+
* failure this shape rules out.
|
|
16
|
+
*/
|
|
17
|
+
/** What an SQS connection string addresses. */
|
|
18
|
+
export interface SqsAddress {
|
|
19
|
+
queueUrl: string;
|
|
20
|
+
/** Read off the queue, never inherited: a queue may live in another region. */
|
|
21
|
+
region?: string;
|
|
22
|
+
/** Set for SQS-compatible backends such as LocalStack. */
|
|
23
|
+
endpoint?: string;
|
|
24
|
+
/** Largest batch the publisher may send in one call. */
|
|
25
|
+
maxBatchSize?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Compose an address into a connection string.
|
|
29
|
+
*
|
|
30
|
+
* Credentials never appear. The AWS SDK resolves them from its own chain — an
|
|
31
|
+
* execution role deployed, environment locally — so the string stays safe to log
|
|
32
|
+
* and identical across environments that differ only in who is calling.
|
|
33
|
+
*/
|
|
34
|
+
export declare function build(address: SqsAddress): string;
|
|
35
|
+
/** Parse a connection string back into an address. */
|
|
36
|
+
export declare function parse(connectionString: string): SqsAddress;
|
|
37
|
+
/** The string is not a URL at all. */
|
|
38
|
+
export declare class MalformedQueueUrl extends Error {
|
|
39
|
+
readonly url: string;
|
|
40
|
+
constructor(url: string);
|
|
41
|
+
}
|
|
42
|
+
/** The string is a URL, but not an `sqs://` one. */
|
|
43
|
+
export declare class UnexpectedQueueScheme extends Error {
|
|
44
|
+
readonly url: string;
|
|
45
|
+
readonly expected: string;
|
|
46
|
+
readonly actual: string;
|
|
47
|
+
constructor(url: string, expected: string, actual: string);
|
|
48
|
+
}
|
|
49
|
+
/** An `sqs://` string with no queue names nothing. */
|
|
50
|
+
export declare class MissingQueueUrl extends Error {
|
|
51
|
+
readonly url: string;
|
|
52
|
+
constructor(url: string);
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { sqsUrl_d_exports as t };
|
|
56
|
+
//# sourceMappingURL=sqsUrl.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqsUrl.d.mts","names":[],"sources":["../../src/sqs/sqsUrl.ts"],"mappings":";;;;;;;;;;;;;;;;;iBAeiB;EAChB;;EAEA;;EAEA;;EAEA;;;;;;;;;wBAYe,MAAM,SAAS;;wBAgBf,MAAM,2BAA2B;;qBA4BpC,0BAA0B;WACjB;EAArB,YAAqB;;;qBAOT,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,aACA,kBACA;;;qBAUE,wBAAwB;WACf;EAArB,YAAqB"}
|
package/dist/sqs/sqsUrl.mjs
CHANGED
|
@@ -1,3 +1,83 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
//#region src/sqs/sqsUrl.ts
|
|
3
|
+
var sqsUrl_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
MalformedQueueUrl: () => MalformedQueueUrl,
|
|
5
|
+
MissingQueueUrl: () => MissingQueueUrl,
|
|
6
|
+
UnexpectedQueueScheme: () => UnexpectedQueueScheme,
|
|
7
|
+
build: () => build,
|
|
8
|
+
parse: () => parse
|
|
9
|
+
});
|
|
10
|
+
const SCHEME = "sqs:";
|
|
11
|
+
/**
|
|
12
|
+
* Compose an address into a connection string.
|
|
13
|
+
*
|
|
14
|
+
* Credentials never appear. The AWS SDK resolves them from its own chain — an
|
|
15
|
+
* execution role deployed, environment locally — so the string stays safe to log
|
|
16
|
+
* and identical across environments that differ only in who is calling.
|
|
17
|
+
*/
|
|
18
|
+
function build(address) {
|
|
19
|
+
const { queueUrl, region, endpoint, maxBatchSize } = address;
|
|
20
|
+
if (!queueUrl) throw new MissingQueueUrl("");
|
|
21
|
+
const url = new URL(`${SCHEME}//`);
|
|
22
|
+
url.searchParams.set("queueUrl", queueUrl);
|
|
23
|
+
if (region) url.searchParams.set("region", region);
|
|
24
|
+
if (endpoint) url.searchParams.set("endpoint", endpoint);
|
|
25
|
+
if (maxBatchSize !== void 0) url.searchParams.set("maxBatchSize", String(maxBatchSize));
|
|
26
|
+
return url.toString();
|
|
27
|
+
}
|
|
28
|
+
/** Parse a connection string back into an address. */
|
|
29
|
+
function parse(connectionString) {
|
|
30
|
+
let parsed;
|
|
31
|
+
try {
|
|
32
|
+
parsed = new URL(connectionString);
|
|
33
|
+
} catch {
|
|
34
|
+
throw new MalformedQueueUrl(connectionString);
|
|
35
|
+
}
|
|
36
|
+
if (parsed.protocol !== SCHEME) throw new UnexpectedQueueScheme(connectionString, SCHEME, parsed.protocol);
|
|
37
|
+
const queueUrl = parsed.searchParams.get("queueUrl");
|
|
38
|
+
if (!queueUrl) throw new MissingQueueUrl(connectionString);
|
|
39
|
+
const region = parsed.searchParams.get("region") ?? void 0;
|
|
40
|
+
const endpoint = parsed.searchParams.get("endpoint") ?? void 0;
|
|
41
|
+
const batch = parsed.searchParams.get("maxBatchSize");
|
|
42
|
+
return {
|
|
43
|
+
queueUrl,
|
|
44
|
+
...region ? { region } : {},
|
|
45
|
+
...endpoint ? { endpoint } : {},
|
|
46
|
+
...batch ? { maxBatchSize: Number(batch) } : {}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** The string is not a URL at all. */
|
|
50
|
+
var MalformedQueueUrl = class extends Error {
|
|
51
|
+
url;
|
|
52
|
+
constructor(url) {
|
|
53
|
+
super(`'${url}' is not a valid connection string.`);
|
|
54
|
+
this.url = url;
|
|
55
|
+
this.name = "MalformedQueueUrl";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/** The string is a URL, but not an `sqs://` one. */
|
|
59
|
+
var UnexpectedQueueScheme = class extends Error {
|
|
60
|
+
url;
|
|
61
|
+
expected;
|
|
62
|
+
actual;
|
|
63
|
+
constructor(url, expected, actual) {
|
|
64
|
+
super(`Expected a '${expected}//' connection string and got '${actual}//' in '${url}'.`);
|
|
65
|
+
this.url = url;
|
|
66
|
+
this.expected = expected;
|
|
67
|
+
this.actual = actual;
|
|
68
|
+
this.name = "UnexpectedQueueScheme";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/** An `sqs://` string with no queue names nothing. */
|
|
72
|
+
var MissingQueueUrl = class extends Error {
|
|
73
|
+
url;
|
|
74
|
+
constructor(url) {
|
|
75
|
+
super(url ? `'${url}' names no queue: an sqs:// connection string needs ?queueUrl=.` : "An sqs:// connection string needs a queueUrl.");
|
|
76
|
+
this.url = url;
|
|
77
|
+
this.name = "MissingQueueUrl";
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { MalformedQueueUrl, MissingQueueUrl, UnexpectedQueueScheme, build, parse, sqsUrl_exports as t };
|
|
2
82
|
|
|
3
|
-
|
|
83
|
+
//# sourceMappingURL=sqsUrl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqsUrl.mjs","names":[],"sources":["../../src/sqs/sqsUrl.ts"],"sourcesContent":["/**\n * The `sqs://` connection-string codec — how a queue is addressed as one string.\n *\n * It lives beside the client rather than in a neutral package because\n * `queueUrl`, `region`, and `endpoint` are SQS's vocabulary. The neutral layer\n * knows only that a queue provides *one* connection string; what that string\n * says is between the component that composes it and the publisher that parses\n * it. The `pgboss://` form sits beside its own client and shares nothing here.\n *\n * Both directions live in this module so they cannot drift: `parse(build(x))`\n * is `x`, and the deploy target composing a string it cannot parse back is the\n * failure this shape rules out.\n */\n\n/** What an SQS connection string addresses. */\nexport interface SqsAddress {\n\tqueueUrl: string;\n\t/** Read off the queue, never inherited: a queue may live in another region. */\n\tregion?: string;\n\t/** Set for SQS-compatible backends such as LocalStack. */\n\tendpoint?: string;\n\t/** Largest batch the publisher may send in one call. */\n\tmaxBatchSize?: number;\n}\n\nconst SCHEME = 'sqs:';\n\n/**\n * Compose an address into a connection string.\n *\n * Credentials never appear. The AWS SDK resolves them from its own chain — an\n * execution role deployed, environment locally — so the string stays safe to log\n * and identical across environments that differ only in who is calling.\n */\nexport function build(address: SqsAddress): string {\n\tconst { queueUrl, region, endpoint, maxBatchSize } = address;\n\tif (!queueUrl) throw new MissingQueueUrl('');\n\n\tconst url = new URL(`${SCHEME}//`);\n\turl.searchParams.set('queueUrl', queueUrl);\n\tif (region) url.searchParams.set('region', region);\n\tif (endpoint) url.searchParams.set('endpoint', endpoint);\n\tif (maxBatchSize !== undefined) {\n\t\turl.searchParams.set('maxBatchSize', String(maxBatchSize));\n\t}\n\n\treturn url.toString();\n}\n\n/** Parse a connection string back into an address. */\nexport function parse(connectionString: string): SqsAddress {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(connectionString);\n\t} catch {\n\t\tthrow new MalformedQueueUrl(connectionString);\n\t}\n\n\tif (parsed.protocol !== SCHEME) {\n\t\tthrow new UnexpectedQueueScheme(connectionString, SCHEME, parsed.protocol);\n\t}\n\n\tconst queueUrl = parsed.searchParams.get('queueUrl');\n\tif (!queueUrl) throw new MissingQueueUrl(connectionString);\n\n\tconst region = parsed.searchParams.get('region') ?? undefined;\n\tconst endpoint = parsed.searchParams.get('endpoint') ?? undefined;\n\tconst batch = parsed.searchParams.get('maxBatchSize');\n\n\treturn {\n\t\tqueueUrl,\n\t\t...(region ? { region } : {}),\n\t\t...(endpoint ? { endpoint } : {}),\n\t\t...(batch ? { maxBatchSize: Number(batch) } : {}),\n\t};\n}\n\n/** The string is not a URL at all. */\nexport class MalformedQueueUrl extends Error {\n\tconstructor(readonly url: string) {\n\t\tsuper(`'${url}' is not a valid connection string.`);\n\t\tthis.name = 'MalformedQueueUrl';\n\t}\n}\n\n/** The string is a URL, but not an `sqs://` one. */\nexport class UnexpectedQueueScheme 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 = 'UnexpectedQueueScheme';\n\t}\n}\n\n/** An `sqs://` string with no queue names nothing. */\nexport class MissingQueueUrl extends Error {\n\tconstructor(readonly url: string) {\n\t\tsuper(\n\t\t\turl\n\t\t\t\t? `'${url}' names no queue: an sqs:// connection string needs ?queueUrl=.`\n\t\t\t\t: 'An sqs:// connection string needs a queueUrl.',\n\t\t);\n\t\tthis.name = 'MissingQueueUrl';\n\t}\n}\n"],"mappings":";;;;;;;;;AAyBA,MAAM,SAAS;;;;;;;;AASf,SAAgB,MAAM,SAA6B;CAClD,MAAM,EAAE,UAAU,QAAQ,UAAU,iBAAiB;CACrD,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,iBAAiB,KAAA,GACpB,IAAI,aAAa,IAAI,gBAAgB,OAAO,YAAY,CAAC;CAG1D,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,QAAQ,OAAO,aAAa,IAAI,cAAc;CAEpD,OAAO;EACN;EACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;EAC/B,GAAI,QAAQ,EAAE,cAAc,OAAO,KAAK,EAAE,IAAI,CAAC;CAChD;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"}
|