@geekmidas/events 10.0.0-alpha.13 → 10.0.0-alpha.14

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 (61) hide show
  1. package/dist/{SQSSubscriber-cpo624qU.mjs → SQSSubscriber-BXLE_1L3.mjs} +2 -2
  2. package/dist/{SQSSubscriber-cpo624qU.mjs.map → SQSSubscriber-BXLE_1L3.mjs.map} +1 -1
  3. package/dist/{SQSSubscriber-DLPZCzFE.cjs → SQSSubscriber-DtRUaZB3.cjs} +2 -2
  4. package/dist/{SQSSubscriber-DLPZCzFE.cjs.map → SQSSubscriber-DtRUaZB3.cjs.map} +1 -1
  5. package/dist/basic/index.cjs +1 -1
  6. package/dist/basic/index.d.cts +1 -1
  7. package/dist/basic/index.d.mts +1 -1
  8. package/dist/basic/index.mjs +1 -1
  9. package/dist/index.cjs +7 -6
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +2 -2
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +2 -2
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +7 -7
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/pgboss/index.cjs +13 -3
  18. package/dist/pgboss/index.cjs.map +1 -1
  19. package/dist/pgboss/index.d.cts +7 -1
  20. package/dist/pgboss/index.d.cts.map +1 -1
  21. package/dist/pgboss/index.d.mts +7 -1
  22. package/dist/pgboss/index.d.mts.map +1 -1
  23. package/dist/pgboss/index.mjs +13 -4
  24. package/dist/pgboss/index.mjs.map +1 -1
  25. package/dist/rabbitmq/index.cjs +13 -3
  26. package/dist/rabbitmq/index.cjs.map +1 -1
  27. package/dist/rabbitmq/index.d.cts +7 -1
  28. package/dist/rabbitmq/index.d.cts.map +1 -1
  29. package/dist/rabbitmq/index.d.mts +7 -1
  30. package/dist/rabbitmq/index.d.mts.map +1 -1
  31. package/dist/rabbitmq/index.mjs +13 -4
  32. package/dist/rabbitmq/index.mjs.map +1 -1
  33. package/dist/sns/index.cjs +16 -3
  34. package/dist/sns/index.cjs.map +1 -1
  35. package/dist/sns/index.d.cts +9 -1
  36. package/dist/sns/index.d.cts.map +1 -1
  37. package/dist/sns/index.d.mts +9 -1
  38. package/dist/sns/index.d.mts.map +1 -1
  39. package/dist/sns/index.mjs +16 -4
  40. package/dist/sns/index.mjs.map +1 -1
  41. package/dist/sqs/index.cjs +17 -6
  42. package/dist/sqs/index.cjs.map +1 -1
  43. package/dist/sqs/index.d.cts +14 -1
  44. package/dist/sqs/index.d.cts.map +1 -1
  45. package/dist/sqs/index.d.mts +14 -1
  46. package/dist/sqs/index.d.mts.map +1 -1
  47. package/dist/sqs/index.mjs +17 -7
  48. package/dist/sqs/index.mjs.map +1 -1
  49. package/dist/types-BcZjLxVV.cjs +51 -0
  50. package/dist/types-BcZjLxVV.cjs.map +1 -0
  51. package/dist/types-Bk5JM6MP.mjs +40 -0
  52. package/dist/types-Bk5JM6MP.mjs.map +1 -0
  53. package/dist/{types-lnM-qoe_.d.cts → types-gGaoT8qc.d.cts} +11 -2
  54. package/dist/{types-lnM-qoe_.d.cts.map → types-gGaoT8qc.d.cts.map} +1 -1
  55. package/dist/{types-lnM-qoe_.d.mts → types-gGaoT8qc.d.mts} +11 -2
  56. package/dist/{types-lnM-qoe_.d.mts.map → types-gGaoT8qc.d.mts.map} +1 -1
  57. package/package.json +3 -3
  58. package/dist/types-C15FC0qp.mjs +0 -18
  59. package/dist/types-C15FC0qp.mjs.map +0 -1
  60. package/dist/types-DXNwyRyg.cjs +0 -23
  61. package/dist/types-DXNwyRyg.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["snsUrl.parse"],"sources":["../../src/sns/SNSConnection.ts","../../src/sns/SNSPublisher.ts","../../src/sns/SNSSubscriber.ts"],"sourcesContent":["import { SNSClient, type SNSClientConfig } from '@aws-sdk/client-sns';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\nimport * as snsUrl from './snsUrl';\n\nexport interface SNSConnectionConfig {\n\ttopicArn: string;\n\tregion?: string;\n\tendpoint?: string; // Custom endpoint (e.g., for LocalStack)\n\tcredentials?: {\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t};\n}\n\nexport class SNSConnection implements EventConnection {\n\treadonly type = EventPublisherType.SNS;\n\tprivate client: SNSClient;\n\tprivate connected = false;\n\tprivate config: SNSConnectionConfig;\n\n\tconstructor(config: SNSConnectionConfig) {\n\t\tthis.config = config;\n\n\t\tconst clientConfig: SNSClientConfig = {\n\t\t\tregion: config.region,\n\t\t\tendpoint: config.endpoint,\n\t\t\tcredentials: config.credentials,\n\t\t};\n\n\t\tthis.client = new SNSClient(clientConfig);\n\t}\n\n\t/**\n\t * Create an SNSConnection from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic&region=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<SNSConnection> {\n\t\t// Through the codec, not a second hand-rolled parse: the deploy target\n\t\t// composes these with `snsUrl.build`, and a string it cannot read back is\n\t\t// exactly the drift one shared module rules out.\n\t\tconst { topicArn, region, endpoint } = snsUrl.parse(connectionString);\n\t\tconst params = new URL(connectionString).searchParams;\n\n\t\tconst config: SNSConnectionConfig = {\n\t\t\ttopicArn,\n\t\t\tregion,\n\t\t\tendpoint,\n\t\t};\n\n\t\t// Credentials are not part of the address — see `snsUrl` — but a caller\n\t\t// may still pin them here, so they are read beside it rather than in it.\n\t\tconst accessKeyId = params.get('accessKeyId');\n\t\tconst secretAccessKey = params.get('secretAccessKey');\n\t\tif (accessKeyId && secretAccessKey) {\n\t\t\tconfig.credentials = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey,\n\t\t\t\tsessionToken: params.get('sessionToken') || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst connection = new SNSConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\t// SNS doesn't have a traditional connection, but we mark as connected\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.client.destroy();\n\t\tthis.connected = false;\n\t}\n\n\tisConnected(): boolean {\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Get the underlying SNS client\n\t */\n\tget snsClient(): SNSClient {\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Get the topic ARN for this connection\n\t */\n\tget topicArn(): string {\n\t\treturn this.config.topicArn;\n\t}\n}\n","import { PublishCommand } from '@aws-sdk/client-sns';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport type { SNSConnection } from './SNSConnection';\n\nexport type SNSPublisherOptions = {};\n\nexport class SNSPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: SNSConnection,\n\t\t_options: SNSPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create an SNSPublisher from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic&region=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SNSPublisher<TMessage>> {\n\t\tconst { SNSConnection } = await import('./SNSConnection');\n\t\tconst connection =\n\t\t\tawait SNSConnection.fromConnectionString(connectionString);\n\n\t\treturn new SNSPublisher<TMessage>(connection);\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// Publish all messages\n\t\tawait Promise.all(messages.map((message) => this.publishMessage(message)));\n\t}\n\n\tprivate async publishMessage(message: TMessage): Promise<void> {\n\t\tconst command = new PublishCommand({\n\t\t\tTopicArn: this.connection.topicArn,\n\t\t\tMessage: JSON.stringify({\n\t\t\t\ttype: message.type,\n\t\t\t\tpayload: message.payload,\n\t\t\t}),\n\t\t\tMessageAttributes: {\n\t\t\t\ttype: {\n\t\t\t\t\tDataType: 'String',\n\t\t\t\t\tStringValue: message.type,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tawait this.connection.snsClient.send(command);\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t\t// Connection should be closed by whoever created it\n\t}\n}\n","import { SubscribeCommand, UnsubscribeCommand } from '@aws-sdk/client-sns';\nimport {\n\tCreateQueueCommand,\n\tDeleteQueueCommand,\n\tGetQueueAttributesCommand,\n\tSetQueueAttributesCommand,\n\tSQSClient,\n} from '@aws-sdk/client-sqs';\nimport { SQSConnection } from '../sqs/SQSConnection';\nimport { SQSSubscriber } from '../sqs/SQSSubscriber';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport type { SNSConnection } from './SNSConnection';\n\nexport interface SNSSubscriberOptions {\n\tqueueName?: string; // Optional queue name (defaults to auto-generated)\n\tcreateQueue?: boolean; // Auto-create SQS queue (default: true)\n\tdeleteQueueOnClose?: boolean; // Delete queue when subscriber closes (default: false for named queues, true for auto-generated)\n\twaitTimeSeconds?: number; // SQS long polling (default: 20)\n\tmaxMessages?: number; // Max messages per poll (default: 10)\n}\n\n/**\n * SNS Subscriber - receives push-based messages from SNS via SQS queue\n *\n * Architecture:\n * SNS Topic → (push) → SQS Queue → Subscriber\n *\n * This subscriber automatically:\n * 1. Creates an SQS queue (or uses existing one)\n * 2. Subscribes the queue to the SNS topic\n * 3. Receives messages pushed from SNS to the queue\n * 4. Filters messages by topic ARN and message type\n * 5. Processes and acknowledges messages\n *\n * Note: While SQS long-polling is used internally to receive messages,\n * this is an implementation detail of the SNS push delivery mechanism.\n * Messages are pushed from SNS to SQS, and we receive those pushed messages.\n */\nexport class SNSSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tprivate sqsClient: SQSClient;\n\tprivate queueUrl?: string;\n\tprivate queueArn?: string;\n\tprivate subscriptionArn?: string;\n\tprivate sqsSubscriber?: SQSSubscriber<TMessage>;\n\tprivate options: Required<SNSSubscriberOptions>;\n\n\tconstructor(\n\t\tprivate connection: SNSConnection,\n\t\toptions: SNSSubscriberOptions = {},\n\t) {\n\t\tthis.options = {\n\t\t\tqueueName:\n\t\t\t\toptions.queueName ||\n\t\t\t\t`sns-sub-${Date.now()}-${Math.random().toString(36).substring(7)}`,\n\t\t\tcreateQueue: options.createQueue ?? true,\n\t\t\tdeleteQueueOnClose: options.deleteQueueOnClose ?? !options.queueName, // Delete auto-generated queues\n\t\t\twaitTimeSeconds: options.waitTimeSeconds ?? 20,\n\t\t\tmaxMessages: options.maxMessages ?? 10,\n\t\t};\n\n\t\t// Create SQS client with same config as SNS\n\t\tthis.sqsClient = new SQSClient({\n\t\t\tregion: (this.connection as any).config.region,\n\t\t\tendpoint: (this.connection as any).config.endpoint,\n\t\t\tcredentials: (this.connection as any).config.credentials,\n\t\t});\n\t}\n\n\t/**\n\t * Create an SNSSubscriber from a connection string\n\t * Format: sns://?topicArn=...&queueName=myqueue&region=us-east-1\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SNSSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { SNSConnection } = await import('./SNSConnection');\n\t\tconst connection =\n\t\t\tawait SNSConnection.fromConnectionString(connectionString);\n\n\t\tconst options: SNSSubscriberOptions = {\n\t\t\tqueueName: params.get('queueName') || undefined,\n\t\t\tcreateQueue: params.get('createQueue') !== 'false',\n\t\t\tdeleteQueueOnClose: params.get('deleteQueueOnClose') === 'true',\n\t\t\twaitTimeSeconds: params.get('waitTimeSeconds')\n\t\t\t\t? Number.parseInt(params.get('waitTimeSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new SNSSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\t// Setup SQS queue and SNS subscription\n\t\tawait this.setupQueue();\n\t\tawait this.subscribeToTopic();\n\n\t\t// Create SQS connection for the subscriber\n\t\tconst sqsConnection = new SQSConnection({\n\t\t\tqueueUrl: this.queueUrl!,\n\t\t\tregion: (this.connection as any).config.region,\n\t\t\tendpoint: (this.connection as any).config.endpoint,\n\t\t\tcredentials: (this.connection as any).config.credentials,\n\t\t});\n\t\tawait sqsConnection.connect();\n\n\t\t// Use SQSSubscriber to receive messages, with topic filtering\n\t\tthis.sqsSubscriber = new SQSSubscriber<TMessage>(sqsConnection, {\n\t\t\twaitTimeSeconds: this.options.waitTimeSeconds,\n\t\t\tmaxMessages: this.options.maxMessages,\n\t\t\texpectedTopicArn: this.connection.topicArn,\n\t\t});\n\n\t\tawait this.sqsSubscriber.subscribe(messages, listener);\n\t}\n\n\t/**\n\t * Stop receiving messages and clean up resources\n\t */\n\tasync stop(): Promise<void> {\n\t\t// Stop SQS subscriber\n\t\tif (this.sqsSubscriber) {\n\t\t\tthis.sqsSubscriber.stop();\n\t\t}\n\n\t\t// Unsubscribe from topic\n\t\tif (this.subscriptionArn) {\n\t\t\ttry {\n\t\t\t\tconst command = new UnsubscribeCommand({\n\t\t\t\t\tSubscriptionArn: this.subscriptionArn,\n\t\t\t\t});\n\t\t\t\tawait this.connection.snsClient.send(command);\n\t\t\t} catch (_error) {}\n\t\t}\n\n\t\t// Delete queue if configured\n\t\tif (this.queueUrl && this.options.deleteQueueOnClose) {\n\t\t\ttry {\n\t\t\t\tconst command = new DeleteQueueCommand({\n\t\t\t\t\tQueueUrl: this.queueUrl,\n\t\t\t\t});\n\t\t\t\tawait this.sqsClient.send(command);\n\t\t\t} catch (_error) {}\n\t\t}\n\n\t\tthis.sqsClient.destroy();\n\t}\n\n\tprivate async setupQueue(): Promise<void> {\n\t\tif (this.options.createQueue) {\n\t\t\t// Create queue\n\t\t\tconst createCommand = new CreateQueueCommand({\n\t\t\t\tQueueName: this.options.queueName,\n\t\t\t});\n\t\t\tconst response = await this.sqsClient.send(createCommand);\n\t\t\tthis.queueUrl = response.QueueUrl!;\n\t\t} else {\n\t\t\tthrow new Error('Queue must exist or createQueue option must be true');\n\t\t}\n\n\t\t// Get queue ARN\n\t\tconst attrsCommand = new GetQueueAttributesCommand({\n\t\t\tQueueUrl: this.queueUrl,\n\t\t\tAttributeNames: ['QueueArn'],\n\t\t});\n\t\tconst attrsResponse = await this.sqsClient.send(attrsCommand);\n\t\tthis.queueArn = attrsResponse.Attributes?.QueueArn!;\n\n\t\t// Set queue policy to allow SNS\n\t\tawait this.setQueuePolicy();\n\t}\n\n\tprivate async setQueuePolicy(): Promise<void> {\n\t\tconst policy = {\n\t\t\tVersion: '2012-10-17',\n\t\t\tStatement: [\n\t\t\t\t{\n\t\t\t\t\tEffect: 'Allow',\n\t\t\t\t\tPrincipal: '*',\n\t\t\t\t\tAction: 'SQS:SendMessage',\n\t\t\t\t\tResource: this.queueArn,\n\t\t\t\t\tCondition: {\n\t\t\t\t\t\tArnEquals: {\n\t\t\t\t\t\t\t'aws:SourceArn': this.connection.topicArn,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tconst command = new SetQueueAttributesCommand({\n\t\t\tQueueUrl: this.queueUrl,\n\t\t\tAttributes: {\n\t\t\t\tPolicy: JSON.stringify(policy),\n\t\t\t},\n\t\t});\n\n\t\tawait this.sqsClient.send(command);\n\t}\n\n\tprivate async subscribeToTopic(): Promise<void> {\n\t\tconst command = new SubscribeCommand({\n\t\t\tTopicArn: this.connection.topicArn,\n\t\t\tProtocol: 'sqs',\n\t\t\tEndpoint: this.queueArn,\n\t\t});\n\n\t\tconst response = await this.connection.snsClient.send(command);\n\t\tthis.subscriptionArn = response.SubscriptionArn!;\n\t}\n}\n"],"mappings":";;;;;;AAgBA,IAAa,gBAAb,MAAa,cA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U,KAAK,aAAa;GACxD,KAAK,WAAW,SAAS;EAC1B,OACC,MAAM,IAAI,MAAM,qDAAqD;EAItE,MAAM,eAAe,IAAI,0BAA0B;GAClD,UAAU,KAAK;GACf,gBAAgB,CAAC,UAAU;EAC5B,CAAC;EACD,MAAM,gBAAgB,MAAM,KAAK,UAAU,KAAK,YAAY;EAC5D,KAAK,WAAW,cAAc,YAAY;EAG1C,MAAM,KAAK,eAAe;CAC3B;CAEA,MAAc,iBAAgC;EAC7C,MAAM,SAAS;GACd,SAAS;GACT,WAAW,CACV;IACC,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,UAAU,KAAK;IACf,WAAW,EACV,WAAW,EACV,iBAAiB,KAAK,WAAW,SAClC,EACD;GACD,CACD;EACD;EAEA,MAAM,UAAU,IAAI,0BAA0B;GAC7C,UAAU,KAAK;GACf,YAAY,EACX,QAAQ,KAAK,UAAU,MAAM,EAC9B;EACD,CAAC;EAED,MAAM,KAAK,UAAU,KAAK,OAAO;CAClC;CAEA,MAAc,mBAAkC;EAC/C,MAAM,UAAU,IAAI,iBAAiB;GACpC,UAAU,KAAK,WAAW;GAC1B,UAAU;GACV,UAAU,KAAK;EAChB,CAAC;EAED,MAAM,WAAW,MAAM,KAAK,WAAW,UAAU,KAAK,OAAO;EAC7D,KAAK,kBAAkB,SAAS;CACjC;AACD"}
1
+ {"version":3,"file":"index.mjs","names":["snsUrl.parse"],"sources":["../../src/sns/SNSConnection.ts","../../src/sns/SNSPublisher.ts","../../src/sns/SNSSubscriber.ts"],"sourcesContent":["import { SNSClient, type SNSClientConfig } from '@aws-sdk/client-sns';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\nimport * as snsUrl from './snsUrl';\n\nexport interface SNSConnectionConfig {\n\ttopicArn: string;\n\tregion?: string;\n\tendpoint?: string; // Custom endpoint (e.g., for LocalStack)\n\tcredentials?: {\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t};\n}\n\nexport class SNSConnection implements EventConnection {\n\treadonly type = EventPublisherType.SNS;\n\tprivate client: SNSClient;\n\tprivate connected = false;\n\tprivate config: SNSConnectionConfig;\n\n\tconstructor(config: SNSConnectionConfig) {\n\t\tthis.config = config;\n\n\t\tconst clientConfig: SNSClientConfig = {\n\t\t\tregion: config.region,\n\t\t\tendpoint: config.endpoint,\n\t\t\tcredentials: config.credentials,\n\t\t};\n\n\t\tthis.client = new SNSClient(clientConfig);\n\t}\n\n\t/**\n\t * Create an SNSConnection from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic&region=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<SNSConnection> {\n\t\t// Through the codec, not a second hand-rolled parse: the deploy target\n\t\t// composes these with `snsUrl.build`, and a string it cannot read back is\n\t\t// exactly the drift one shared module rules out.\n\t\tconst { topicArn, region, endpoint } = snsUrl.parse(connectionString);\n\t\tconst params = new URL(connectionString).searchParams;\n\n\t\tconst config: SNSConnectionConfig = {\n\t\t\ttopicArn,\n\t\t\tregion,\n\t\t\tendpoint,\n\t\t};\n\n\t\t// Credentials are not part of the address — see `snsUrl` — but a caller\n\t\t// may still pin them here, so they are read beside it rather than in it.\n\t\tconst accessKeyId = params.get('accessKeyId');\n\t\tconst secretAccessKey = params.get('secretAccessKey');\n\t\tif (accessKeyId && secretAccessKey) {\n\t\t\tconfig.credentials = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey,\n\t\t\t\tsessionToken: params.get('sessionToken') || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst connection = new SNSConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\t// SNS doesn't have a traditional connection, but we mark as connected\n\t\tthis.connected = true;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.client.destroy();\n\t\tthis.connected = false;\n\t}\n\n\tisConnected(): boolean {\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Get the underlying SNS client\n\t */\n\tget snsClient(): SNSClient {\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Get the topic ARN for this connection\n\t */\n\tget topicArn(): string {\n\t\treturn this.config.topicArn;\n\t}\n}\n","import { PublishCommand } from '@aws-sdk/client-sns';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport type { SNSConnection } from './SNSConnection';\n\nexport type SNSPublisherOptions = {};\n\nexport class SNSPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: SNSConnection,\n\t\t_options: SNSPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create an SNSPublisher from a connection string\n\t * Format: sns://?topicArn=arn:aws:sns:region:account:topic&region=us-east-1&endpoint=http://localhost:4566\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SNSPublisher<TMessage>> {\n\t\tconst { SNSConnection } = await import('./SNSConnection');\n\t\tconst connection =\n\t\t\tawait SNSConnection.fromConnectionString(connectionString);\n\n\t\treturn new SNSPublisher<TMessage>(connection);\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// Publish all messages\n\t\tawait Promise.all(messages.map((message) => this.publishMessage(message)));\n\t}\n\n\tprivate async publishMessage(message: TMessage): Promise<void> {\n\t\tconst command = new PublishCommand({\n\t\t\tTopicArn: this.connection.topicArn,\n\t\t\tMessage: JSON.stringify({\n\t\t\t\ttype: message.type,\n\t\t\t\tpayload: message.payload,\n\t\t\t}),\n\t\t\tMessageAttributes: {\n\t\t\t\ttype: {\n\t\t\t\t\tDataType: 'String',\n\t\t\t\t\tStringValue: message.type,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tawait this.connection.snsClient.send(command);\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t\t// Connection should be closed by whoever created it\n\t}\n}\n","import { SubscribeCommand, UnsubscribeCommand } from '@aws-sdk/client-sns';\nimport {\n\tCreateQueueCommand,\n\tDeleteQueueCommand,\n\tGetQueueAttributesCommand,\n\tSetQueueAttributesCommand,\n\tSQSClient,\n} from '@aws-sdk/client-sqs';\nimport { SQSConnection } from '../sqs/SQSConnection';\nimport { SQSSubscriber } from '../sqs/SQSSubscriber';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport type { SNSConnection } from './SNSConnection';\n\nexport interface SNSSubscriberOptions {\n\tqueueName?: string; // Optional queue name (defaults to auto-generated)\n\tcreateQueue?: boolean; // Auto-create SQS queue (default: true)\n\tdeleteQueueOnClose?: boolean; // Delete queue when subscriber closes (default: false for named queues, true for auto-generated)\n\twaitTimeSeconds?: number; // SQS long polling (default: 20)\n\tmaxMessages?: number; // Max messages per poll (default: 10)\n}\n\n/**\n * SNS Subscriber - receives push-based messages from SNS via SQS queue\n *\n * Architecture:\n * SNS Topic → (push) → SQS Queue → Subscriber\n *\n * This subscriber automatically:\n * 1. Creates an SQS queue (or uses existing one)\n * 2. Subscribes the queue to the SNS topic\n * 3. Receives messages pushed from SNS to the queue\n * 4. Filters messages by topic ARN and message type\n * 5. Processes and acknowledges messages\n *\n * Note: While SQS long-polling is used internally to receive messages,\n * this is an implementation detail of the SNS push delivery mechanism.\n * Messages are pushed from SNS to SQS, and we receive those pushed messages.\n */\nexport class SNSSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tprivate sqsClient: SQSClient;\n\tprivate queueUrl?: string;\n\tprivate queueArn?: string;\n\tprivate subscriptionArn?: string;\n\tprivate sqsSubscriber?: SQSSubscriber<TMessage>;\n\tprivate options: Required<SNSSubscriberOptions>;\n\n\tconstructor(\n\t\tprivate connection: SNSConnection,\n\t\toptions: SNSSubscriberOptions = {},\n\t) {\n\t\tthis.options = {\n\t\t\tqueueName:\n\t\t\t\toptions.queueName ||\n\t\t\t\t`sns-sub-${Date.now()}-${Math.random().toString(36).substring(7)}`,\n\t\t\tcreateQueue: options.createQueue ?? true,\n\t\t\tdeleteQueueOnClose: options.deleteQueueOnClose ?? !options.queueName, // Delete auto-generated queues\n\t\t\twaitTimeSeconds: options.waitTimeSeconds ?? 20,\n\t\t\tmaxMessages: options.maxMessages ?? 10,\n\t\t};\n\n\t\t// Create SQS client with same config as SNS\n\t\tthis.sqsClient = new SQSClient({\n\t\t\tregion: (this.connection as any).config.region,\n\t\t\tendpoint: (this.connection as any).config.endpoint,\n\t\t\tcredentials: (this.connection as any).config.credentials,\n\t\t});\n\t}\n\n\t/**\n\t * Create an SNSSubscriber from a connection string\n\t * Format: sns://?topicArn=...&queueName=myqueue&region=us-east-1\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<SNSSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { SNSConnection } = await import('./SNSConnection');\n\t\tconst connection =\n\t\t\tawait SNSConnection.fromConnectionString(connectionString);\n\n\t\tconst options: SNSSubscriberOptions = {\n\t\t\tqueueName: params.get('queueName') || undefined,\n\t\t\tcreateQueue: params.get('createQueue') !== 'false',\n\t\t\tdeleteQueueOnClose: params.get('deleteQueueOnClose') === 'true',\n\t\t\twaitTimeSeconds: params.get('waitTimeSeconds')\n\t\t\t\t? Number.parseInt(params.get('waitTimeSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new SNSSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\t// Setup SQS queue and SNS subscription\n\t\tawait this.setupQueue();\n\t\tawait this.subscribeToTopic();\n\n\t\t// Create SQS connection for the subscriber\n\t\tconst sqsConnection = new SQSConnection({\n\t\t\tqueueUrl: this.queueUrl!,\n\t\t\tregion: (this.connection as any).config.region,\n\t\t\tendpoint: (this.connection as any).config.endpoint,\n\t\t\tcredentials: (this.connection as any).config.credentials,\n\t\t});\n\t\tawait sqsConnection.connect();\n\n\t\t// Use SQSSubscriber to receive messages, with topic filtering\n\t\tthis.sqsSubscriber = new SQSSubscriber<TMessage>(sqsConnection, {\n\t\t\twaitTimeSeconds: this.options.waitTimeSeconds,\n\t\t\tmaxMessages: this.options.maxMessages,\n\t\t\texpectedTopicArn: this.connection.topicArn,\n\t\t});\n\n\t\tawait this.sqsSubscriber.subscribe(messages, listener);\n\t}\n\n\t/**\n\t * Stop receiving messages and clean up resources\n\t */\n\tasync stop(): Promise<void> {\n\t\t// Stop SQS subscriber\n\t\tif (this.sqsSubscriber) {\n\t\t\tthis.sqsSubscriber.stop();\n\t\t}\n\n\t\t// Unsubscribe from topic\n\t\tif (this.subscriptionArn) {\n\t\t\ttry {\n\t\t\t\tconst command = new UnsubscribeCommand({\n\t\t\t\t\tSubscriptionArn: this.subscriptionArn,\n\t\t\t\t});\n\t\t\t\tawait this.connection.snsClient.send(command);\n\t\t\t} catch (_error) {}\n\t\t}\n\n\t\t// Delete queue if configured\n\t\tif (this.queueUrl && this.options.deleteQueueOnClose) {\n\t\t\ttry {\n\t\t\t\tconst command = new DeleteQueueCommand({\n\t\t\t\t\tQueueUrl: this.queueUrl,\n\t\t\t\t});\n\t\t\t\tawait this.sqsClient.send(command);\n\t\t\t} catch (_error) {}\n\t\t}\n\n\t\tthis.sqsClient.destroy();\n\t}\n\n\tprivate async setupQueue(): Promise<void> {\n\t\tif (this.options.createQueue) {\n\t\t\t// Create queue\n\t\t\tconst createCommand = new CreateQueueCommand({\n\t\t\t\tQueueName: this.options.queueName,\n\t\t\t});\n\t\t\tconst response = await this.sqsClient.send(createCommand);\n\t\t\tthis.queueUrl = response.QueueUrl!;\n\t\t} else {\n\t\t\tthrow new SnsQueueMissing(this.options.queueName);\n\t\t}\n\n\t\t// Get queue ARN\n\t\tconst attrsCommand = new GetQueueAttributesCommand({\n\t\t\tQueueUrl: this.queueUrl,\n\t\t\tAttributeNames: ['QueueArn'],\n\t\t});\n\t\tconst attrsResponse = await this.sqsClient.send(attrsCommand);\n\t\tthis.queueArn = attrsResponse.Attributes?.QueueArn!;\n\n\t\t// Set queue policy to allow SNS\n\t\tawait this.setQueuePolicy();\n\t}\n\n\tprivate async setQueuePolicy(): Promise<void> {\n\t\tconst policy = {\n\t\t\tVersion: '2012-10-17',\n\t\t\tStatement: [\n\t\t\t\t{\n\t\t\t\t\tEffect: 'Allow',\n\t\t\t\t\tPrincipal: '*',\n\t\t\t\t\tAction: 'SQS:SendMessage',\n\t\t\t\t\tResource: this.queueArn,\n\t\t\t\t\tCondition: {\n\t\t\t\t\t\tArnEquals: {\n\t\t\t\t\t\t\t'aws:SourceArn': this.connection.topicArn,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tconst command = new SetQueueAttributesCommand({\n\t\t\tQueueUrl: this.queueUrl,\n\t\t\tAttributes: {\n\t\t\t\tPolicy: JSON.stringify(policy),\n\t\t\t},\n\t\t});\n\n\t\tawait this.sqsClient.send(command);\n\t}\n\n\tprivate async subscribeToTopic(): Promise<void> {\n\t\tconst command = new SubscribeCommand({\n\t\t\tTopicArn: this.connection.topicArn,\n\t\t\tProtocol: 'sqs',\n\t\t\tEndpoint: this.queueArn,\n\t\t});\n\n\t\tconst response = await this.connection.snsClient.send(command);\n\t\tthis.subscriptionArn = response.SubscriptionArn!;\n\t}\n}\n\n/**\n * A subscriber asked to use a queue it may not create. The SQS queue behind an\n * SNS subscription has to exist first, or `createQueue` has to allow it.\n */\nexport class SnsQueueMissing extends Error {\n\tconstructor(readonly queueName: string | undefined) {\n\t\tsuper(\n\t\t\t`The SNS subscriber's queue${queueName ? ` \"${queueName}\"` : ''} is not created here: pass createQueue: true, or create the queue first.`,\n\t\t);\n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I,mBAAmB,EAC5C,WAAW,KAAK,QAAQ,UACzB,CAAC;GACD,MAAM,WAAW,MAAM,KAAK,UAAU,KAAK,aAAa;GACxD,KAAK,WAAW,SAAS;EAC1B,OACC,MAAM,IAAI,gBAAgB,KAAK,QAAQ,SAAS;EAIjD,MAAM,eAAe,IAAI,0BAA0B;GAClD,UAAU,KAAK;GACf,gBAAgB,CAAC,UAAU;EAC5B,CAAC;EACD,MAAM,gBAAgB,MAAM,KAAK,UAAU,KAAK,YAAY;EAC5D,KAAK,WAAW,cAAc,YAAY;EAG1C,MAAM,KAAK,eAAe;CAC3B;CAEA,MAAc,iBAAgC;EAC7C,MAAM,SAAS;GACd,SAAS;GACT,WAAW,CACV;IACC,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,UAAU,KAAK;IACf,WAAW,EACV,WAAW,EACV,iBAAiB,KAAK,WAAW,SAClC,EACD;GACD,CACD;EACD;EAEA,MAAM,UAAU,IAAI,0BAA0B;GAC7C,UAAU,KAAK;GACf,YAAY,EACX,QAAQ,KAAK,UAAU,MAAM,EAC9B;EACD,CAAC;EAED,MAAM,KAAK,UAAU,KAAK,OAAO;CAClC;CAEA,MAAc,mBAAkC;EAC/C,MAAM,UAAU,IAAI,iBAAiB;GACpC,UAAU,KAAK,WAAW;GAC1B,UAAU;GACV,UAAU,KAAK;EAChB,CAAC;EAED,MAAM,WAAW,MAAM,KAAK,WAAW,UAAU,KAAK,OAAO;EAC7D,KAAK,kBAAkB,SAAS;CACjC;AACD;;;;;AAMA,IAAa,kBAAb,cAAqC,MAAM;CACrB;CAArB,YAAY,WAAwC;EACnD,MACC,6BAA6B,YAAY,KAAK,UAAU,KAAK,GAAG,yEACjE;EAHoB,KAAA,YAAA;EAIpB,KAAK,OAAO;CACb;AACD"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("../rolldown-runtime-C0BPl7ul.cjs");
3
3
  const require_sqs_sqsUrl = require("./sqsUrl.cjs");
4
- const require_SQSSubscriber = require("../SQSSubscriber-DLPZCzFE.cjs");
4
+ const require_SQSSubscriber = require("../SQSSubscriber-DtRUaZB3.cjs");
5
5
  let _aws_sdk_client_sqs = require("@aws-sdk/client-sqs");
6
6
  let lodash_chunk = require("lodash.chunk");
7
7
  lodash_chunk = require_rolldown_runtime.__toESM(lodash_chunk, 1);
@@ -19,7 +19,7 @@ var SQSPublisher = class SQSPublisher {
19
19
  */
20
20
  static async fromConnectionString(connectionString) {
21
21
  const params = new URL(connectionString).searchParams;
22
- const { SQSConnection } = await Promise.resolve().then(() => require("../SQSSubscriber-DLPZCzFE.cjs")).then((n) => n.SQSConnection_exports);
22
+ const { SQSConnection } = await Promise.resolve().then(() => require("../SQSSubscriber-DtRUaZB3.cjs")).then((n) => n.SQSConnection_exports);
23
23
  const connection = await SQSConnection.fromConnectionString(connectionString);
24
24
  const options = { maxBatchSize: params.get("maxBatchSize") ? Number.parseInt(params.get("maxBatchSize"), 10) : void 0 };
25
25
  return new SQSPublisher(connection, options);
@@ -48,17 +48,28 @@ var SQSPublisher = class SQSPublisher {
48
48
  };
49
49
  const command = new _aws_sdk_client_sqs.SendMessageBatchCommand(input);
50
50
  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
- }
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
+ })));
55
56
  }
56
57
  async close() {}
57
58
  };
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
+ };
58
68
  //#endregion
59
69
  exports.SQSConnection = require_SQSSubscriber.SQSConnection;
60
70
  exports.SQSPublisher = SQSPublisher;
61
71
  exports.SQSSubscriber = require_SQSSubscriber.SQSSubscriber;
72
+ exports.SqsBatchPartlyFailed = SqsBatchPartlyFailed;
62
73
  Object.defineProperty(exports, "sqsUrl", {
63
74
  enumerable: true,
64
75
  get: function() {
@@ -1 +1 @@
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\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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,MAAM,WAAW,MAAM,KAAK,WAAW,UAAU,KAAK,OAAO;EAG7D,IAAI,SAAS,UAAU,SAAS,OAAO,SAAS,GAAG;GAClD,MAAM,SAAS,SAAS,OAAO,KAC7B,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,EAAE,SAClC,CAAC,CAAC,KAAK,IAAI;GACX,MAAM,IAAI,MACT,kBAAkB,SAAS,OAAO,OAAO,aAAa,QACvD;EACD;CACD;CAEA,MAAM,QAAuB,CAG7B;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,4 +1,4 @@
1
- import { i as EventSubscriber, n as EventPublisher, r as EventPublisherType, s as PublishableMessage, t as EventConnection } from "../types-lnM-qoe_.cjs";
1
+ import { i as EventSubscriber, n as EventPublisher, r as EventPublisherType, s as PublishableMessage, t as EventConnection } from "../types-gGaoT8qc.cjs";
2
2
  import { SqsAddress, t as sqsUrl_d_exports } from "./sqsUrl.cjs";
3
3
  import { SQSClient } from "@aws-sdk/client-sqs";
4
4
  //#region src/sqs/SQSConnection.d.ts
@@ -53,6 +53,19 @@ export declare class SQSPublisher<TMessage extends PublishableMessage<string, an
53
53
  private sendBatch;
54
54
  close(): Promise<void>;
55
55
  }
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
+ }
56
69
  //#endregion
57
70
  //#region src/sqs/SQSSubscriber.d.ts
58
71
  interface SQSSubscriberOptions {
@@ -1 +1 @@
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;EAEa,YAAA,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;EAGjB,YAAA,YAAY,eACrB,UAAS;;;;;SAWG,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,aAAa;EAiB5C,QAAQ,UAAU,aAAa;UAcvB;EAoCR,SAAS;;;;UC5FC;EAChB;EACA;EACA;;;;;;;;;;;;;;;qBAgBY,cAAc,iBAAiB,4CAChC,gBAAgB;UAQlB;UAND;UACA;UACA;UACA;EAGC,YAAA,YAAY,eACpB,UAAS;EASJ,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B;EAYH;UAIc;UAqBA;;;;UAiDN;UAgCM;UAUN"}
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;EAEa,YAAA,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;EAGjB,YAAA,YAAY,eACrB,UAAS;;;;;SAWG,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,aAAa;EAiB5C,QAAQ,UAAU,aAAa;UAcvB;EAqCR,SAAS;;;qBAOH,6BAA6B;WAE/B;IACR;IACA;IACA;;EAHQ,YAAA;IACR;IACA;IACA;;;;;UCzGc;EAChB;EACA;EACA;;;;;;;;;;;;;;;qBAgBY,cAAc,iBAAiB,4CAChC,gBAAgB;UAQlB;UAND;UACA;UACA;UACA;EAGC,YAAA,YAAY,eACpB,UAAS;EASJ,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B;EAYH;UAIc;UAqBA;;;;UAiDN;UAgCM;UAUN"}
@@ -1,4 +1,4 @@
1
- import { i as EventSubscriber, n as EventPublisher, r as EventPublisherType, s as PublishableMessage, t as EventConnection } from "../types-lnM-qoe_.mjs";
1
+ import { i as EventSubscriber, n as EventPublisher, r as EventPublisherType, s as PublishableMessage, t as EventConnection } from "../types-gGaoT8qc.mjs";
2
2
  import { SqsAddress, t as sqsUrl_d_exports } from "./sqsUrl.mjs";
3
3
  import { SQSClient } from "@aws-sdk/client-sqs";
4
4
  //#region src/sqs/SQSConnection.d.ts
@@ -53,6 +53,19 @@ export declare class SQSPublisher<TMessage extends PublishableMessage<string, an
53
53
  private sendBatch;
54
54
  close(): Promise<void>;
55
55
  }
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
+ }
56
69
  //#endregion
57
70
  //#region src/sqs/SQSSubscriber.d.ts
58
71
  interface SQSSubscriberOptions {
@@ -1 +1 @@
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;EAEa,YAAA,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;EAGjB,YAAA,YAAY,eACrB,UAAS;;;;;SAWG,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,aAAa;EAiB5C,QAAQ,UAAU,aAAa;UAcvB;EAoCR,SAAS;;;;UC5FC;EAChB;EACA;EACA;;;;;;;;;;;;;;;qBAgBY,cAAc,iBAAiB,4CAChC,gBAAgB;UAQlB;UAND;UACA;UACA;UACA;EAGC,YAAA,YAAY,eACpB,UAAS;EASJ,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B;EAYH;UAIc;UAqBA;;;;UAiDN;UAgCM;UAUN"}
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;EAEa,YAAA,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;EAGjB,YAAA,YAAY,eACrB,UAAS;;;;;SAWG,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,aAAa;EAiB5C,QAAQ,UAAU,aAAa;UAcvB;EAqCR,SAAS;;;qBAOH,6BAA6B;WAE/B;IACR;IACA;IACA;;EAHQ,YAAA;IACR;IACA;IACA;;;;;UCzGc;EAChB;EACA;EACA;;;;;;;;;;;;;;;qBAgBY,cAAc,iBAAiB,4CAChC,gBAAgB;UAQlB;UAND;UACA;UACA;UACA;EAGC,YAAA,YAAY,eACpB,UAAS;EASJ,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B;EAYH;UAIc;UAqBA;;;;UAiDN;UAgCM;UAUN"}
@@ -1,5 +1,5 @@
1
1
  import { t as sqsUrl_exports } from "./sqsUrl.mjs";
2
- import { n as SQSConnection, t as SQSSubscriber } from "../SQSSubscriber-cpo624qU.mjs";
2
+ import { n as SQSConnection, t as SQSSubscriber } from "../SQSSubscriber-BXLE_1L3.mjs";
3
3
  import { SendMessageBatchCommand } from "@aws-sdk/client-sqs";
4
4
  import chunk from "lodash.chunk";
5
5
  //#region src/sqs/SQSPublisher.ts
@@ -16,7 +16,7 @@ var SQSPublisher = class SQSPublisher {
16
16
  */
17
17
  static async fromConnectionString(connectionString) {
18
18
  const params = new URL(connectionString).searchParams;
19
- const { SQSConnection } = await import("../SQSSubscriber-cpo624qU.mjs").then((n) => n.r);
19
+ const { SQSConnection } = await import("../SQSSubscriber-BXLE_1L3.mjs").then((n) => n.r);
20
20
  const connection = await SQSConnection.fromConnectionString(connectionString);
21
21
  const options = { maxBatchSize: params.get("maxBatchSize") ? Number.parseInt(params.get("maxBatchSize"), 10) : void 0 };
22
22
  return new SQSPublisher(connection, options);
@@ -45,14 +45,24 @@ var SQSPublisher = class SQSPublisher {
45
45
  };
46
46
  const command = new SendMessageBatchCommand(input);
47
47
  const response = await this.connection.sqsClient.send(command);
48
- if (response.Failed && response.Failed.length > 0) {
49
- const errors = response.Failed.map((f) => `${f.Id}: ${f.Code} - ${f.Message}`).join(", ");
50
- throw new Error(`Failed to send ${response.Failed.length} messages: ${errors}`);
51
- }
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
+ })));
52
53
  }
53
54
  async close() {}
54
55
  };
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
+ };
55
65
  //#endregion
56
- export { SQSConnection, SQSPublisher, SQSSubscriber, sqsUrl_exports as sqsUrl };
66
+ export { SQSConnection, SQSPublisher, SQSSubscriber, SqsBatchPartlyFailed, sqsUrl_exports as sqsUrl };
57
67
 
58
68
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
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\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;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,GAAG;GAClD,MAAM,SAAS,SAAS,OAAO,KAC7B,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,EAAE,SAClC,CAAC,CAAC,KAAK,IAAI;GACX,MAAM,IAAI,MACT,kBAAkB,SAAS,OAAO,OAAO,aAAa,QACvD;EACD;CACD;CAEA,MAAM,QAAuB,CAG7B;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"}
@@ -0,0 +1,51 @@
1
+ //#region src/types.ts
2
+ /**
3
+ * Event publisher/subscriber types
4
+ */
5
+ let EventPublisherType = /* @__PURE__ */ function(EventPublisherType) {
6
+ EventPublisherType["Basic"] = "basic";
7
+ EventPublisherType["EventBridge"] = "eventbridge";
8
+ EventPublisherType["SQS"] = "sqs";
9
+ EventPublisherType["SNS"] = "sns";
10
+ EventPublisherType["Kafka"] = "kafka";
11
+ EventPublisherType["RabbitMQ"] = "rabbitmq";
12
+ EventPublisherType["PgBoss"] = "pgboss";
13
+ return EventPublisherType;
14
+ }({});
15
+ /** The transports a publisher, subscriber or connection can be built for. */
16
+ const SUPPORTED = [
17
+ "basic",
18
+ "sqs",
19
+ "sns",
20
+ "rabbitmq",
21
+ "pgboss"
22
+ ];
23
+ /**
24
+ * A connection string or connection whose transport nothing here implements —
25
+ * a typo'd scheme, or one of the listed-but-unbuilt ones (EventBridge, Kafka).
26
+ */
27
+ var UnsupportedEventTransport = class extends Error {
28
+ transport;
29
+ role;
30
+ constructor(transport, role) {
31
+ super(`No event ${role} for "${transport}". Use one of: ${SUPPORTED.join(", ")} — e.g. pgboss://… or sns://….`);
32
+ this.transport = transport;
33
+ this.role = role;
34
+ this.name = "UnsupportedEventTransport";
35
+ }
36
+ };
37
+ //#endregion
38
+ Object.defineProperty(exports, "EventPublisherType", {
39
+ enumerable: true,
40
+ get: function() {
41
+ return EventPublisherType;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "UnsupportedEventTransport", {
45
+ enumerable: true,
46
+ get: function() {
47
+ return UnsupportedEventTransport;
48
+ }
49
+ });
50
+
51
+ //# sourceMappingURL=types-BcZjLxVV.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BcZjLxVV.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { InferStandardSchema } from '@geekmidas/schema';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\n/**\n * Represents a publishable event message with a type and payload.\n *\n * @template TType - The event type/name (e.g., 'user.created')\n * @template TPayload - The event payload data\n */\nexport type PublishableMessage<TType extends string, TPayload> = {\n\ttype: TType;\n\tpayload: TPayload;\n};\n\n/**\n * Event publisher/subscriber types\n */\nexport enum EventPublisherType {\n\tBasic = 'basic',\n\tEventBridge = 'eventbridge',\n\tSQS = 'sqs',\n\tSNS = 'sns',\n\tKafka = 'kafka',\n\tRabbitMQ = 'rabbitmq',\n\tPgBoss = 'pgboss',\n}\n\n/** The transports a publisher, subscriber or connection can be built for. */\nconst SUPPORTED: readonly string[] = [\n\tEventPublisherType.Basic,\n\tEventPublisherType.SQS,\n\tEventPublisherType.SNS,\n\tEventPublisherType.RabbitMQ,\n\tEventPublisherType.PgBoss,\n];\n\n/**\n * A connection string or connection whose transport nothing here implements —\n * a typo'd scheme, or one of the listed-but-unbuilt ones (EventBridge, Kafka).\n */\nexport class UnsupportedEventTransport extends Error {\n\tconstructor(\n\t\treadonly transport: string,\n\t\treadonly role: 'publisher' | 'subscriber' | 'connection',\n\t) {\n\t\tsuper(\n\t\t\t`No event ${role} for \"${transport}\". Use one of: ${SUPPORTED.join(', ')} — e.g. pgboss://… or sns://….`,\n\t\t);\n\t\tthis.name = 'UnsupportedEventTransport';\n\t}\n}\n\n/**\n * Base interface for event connections\n * Connections manage the underlying transport (RabbitMQ channel, SQS client, etc.)\n */\nexport interface EventConnection {\n\treadonly type: EventPublisherType;\n\tconnect(): Promise<void>;\n\tclose(): Promise<void>;\n\tisConnected(): boolean;\n}\n\n/**\n * Interface for event publishers that handle the actual publishing of events.\n * Implementations can send to EventBridge, SQS, Kafka, or any other event system.\n *\n * @template TMessage - The union type of all publishable messages\n */\nexport type EventPublisher<TMessage extends PublishableMessage<string, any>> = {\n\tpublish: (message: TMessage[]) => Promise<void>;\n};\n\n/**\n * Interface for event subscribers that handle receiving and processing events.\n *\n * @template TMessage - The union type of all publishable messages\n */\nexport type EventSubscriber<TMessage extends PublishableMessage<string, any>> =\n\t{\n\t\tsubscribe: (\n\t\t\tmessages: TMessage['type'][],\n\t\t\tlistener: (payload: TMessage) => Promise<void>,\n\t\t) => Promise<void>;\n\t};\n/**\n * Utility type to extract the message from EventPublisher\n */\nexport type ExtractPublisherMessage<T> =\n\tT extends EventPublisher<infer M> ? M : never;\n\nexport type MappedEvent<\n\tT extends EventPublisher<any> | undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n> = {\n\ttype: ExtractPublisherMessage<T>['type'];\n\tpayload: (\n\t\tctx: InferStandardSchema<OutSchema>,\n\t) => ExtractPublisherMessage<T>['payload'];\n\twhen?: (ctx: InferStandardSchema<OutSchema>) => boolean;\n};\n"],"mappings":";;;;AAiBA,IAAY,qBAAL,yBAAA,oBAAA;CACN,mBAAA,WAAA;CACA,mBAAA,iBAAA;CACA,mBAAA,SAAA;CACA,mBAAA,SAAA;CACA,mBAAA,WAAA;CACA,mBAAA,cAAA;CACA,mBAAA,YAAA;;AACD,EAAA,CAAA,CAAA;;AAGA,MAAM,YAA+B;;;;;;AAMrC;;;;;AAMA,IAAa,4BAAb,cAA+C,MAAM;CAE1C;CACA;CAFV,YACC,WACA,MACC;EACD,MACC,YAAY,KAAK,QAAQ,UAAU,iBAAiB,UAAU,KAAK,IAAI,EAAE,+BAC1E;EALS,KAAA,YAAA;EACA,KAAA,OAAA;EAKT,KAAK,OAAO;CACb;AACD"}
@@ -0,0 +1,40 @@
1
+ //#region src/types.ts
2
+ /**
3
+ * Event publisher/subscriber types
4
+ */
5
+ let EventPublisherType = /* @__PURE__ */ function(EventPublisherType) {
6
+ EventPublisherType["Basic"] = "basic";
7
+ EventPublisherType["EventBridge"] = "eventbridge";
8
+ EventPublisherType["SQS"] = "sqs";
9
+ EventPublisherType["SNS"] = "sns";
10
+ EventPublisherType["Kafka"] = "kafka";
11
+ EventPublisherType["RabbitMQ"] = "rabbitmq";
12
+ EventPublisherType["PgBoss"] = "pgboss";
13
+ return EventPublisherType;
14
+ }({});
15
+ /** The transports a publisher, subscriber or connection can be built for. */
16
+ const SUPPORTED = [
17
+ "basic",
18
+ "sqs",
19
+ "sns",
20
+ "rabbitmq",
21
+ "pgboss"
22
+ ];
23
+ /**
24
+ * A connection string or connection whose transport nothing here implements —
25
+ * a typo'd scheme, or one of the listed-but-unbuilt ones (EventBridge, Kafka).
26
+ */
27
+ var UnsupportedEventTransport = class extends Error {
28
+ transport;
29
+ role;
30
+ constructor(transport, role) {
31
+ super(`No event ${role} for "${transport}". Use one of: ${SUPPORTED.join(", ")} — e.g. pgboss://… or sns://….`);
32
+ this.transport = transport;
33
+ this.role = role;
34
+ this.name = "UnsupportedEventTransport";
35
+ }
36
+ };
37
+ //#endregion
38
+ export { UnsupportedEventTransport as n, EventPublisherType as t };
39
+
40
+ //# sourceMappingURL=types-Bk5JM6MP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-Bk5JM6MP.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { InferStandardSchema } from '@geekmidas/schema';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\n/**\n * Represents a publishable event message with a type and payload.\n *\n * @template TType - The event type/name (e.g., 'user.created')\n * @template TPayload - The event payload data\n */\nexport type PublishableMessage<TType extends string, TPayload> = {\n\ttype: TType;\n\tpayload: TPayload;\n};\n\n/**\n * Event publisher/subscriber types\n */\nexport enum EventPublisherType {\n\tBasic = 'basic',\n\tEventBridge = 'eventbridge',\n\tSQS = 'sqs',\n\tSNS = 'sns',\n\tKafka = 'kafka',\n\tRabbitMQ = 'rabbitmq',\n\tPgBoss = 'pgboss',\n}\n\n/** The transports a publisher, subscriber or connection can be built for. */\nconst SUPPORTED: readonly string[] = [\n\tEventPublisherType.Basic,\n\tEventPublisherType.SQS,\n\tEventPublisherType.SNS,\n\tEventPublisherType.RabbitMQ,\n\tEventPublisherType.PgBoss,\n];\n\n/**\n * A connection string or connection whose transport nothing here implements —\n * a typo'd scheme, or one of the listed-but-unbuilt ones (EventBridge, Kafka).\n */\nexport class UnsupportedEventTransport extends Error {\n\tconstructor(\n\t\treadonly transport: string,\n\t\treadonly role: 'publisher' | 'subscriber' | 'connection',\n\t) {\n\t\tsuper(\n\t\t\t`No event ${role} for \"${transport}\". Use one of: ${SUPPORTED.join(', ')} — e.g. pgboss://… or sns://….`,\n\t\t);\n\t\tthis.name = 'UnsupportedEventTransport';\n\t}\n}\n\n/**\n * Base interface for event connections\n * Connections manage the underlying transport (RabbitMQ channel, SQS client, etc.)\n */\nexport interface EventConnection {\n\treadonly type: EventPublisherType;\n\tconnect(): Promise<void>;\n\tclose(): Promise<void>;\n\tisConnected(): boolean;\n}\n\n/**\n * Interface for event publishers that handle the actual publishing of events.\n * Implementations can send to EventBridge, SQS, Kafka, or any other event system.\n *\n * @template TMessage - The union type of all publishable messages\n */\nexport type EventPublisher<TMessage extends PublishableMessage<string, any>> = {\n\tpublish: (message: TMessage[]) => Promise<void>;\n};\n\n/**\n * Interface for event subscribers that handle receiving and processing events.\n *\n * @template TMessage - The union type of all publishable messages\n */\nexport type EventSubscriber<TMessage extends PublishableMessage<string, any>> =\n\t{\n\t\tsubscribe: (\n\t\t\tmessages: TMessage['type'][],\n\t\t\tlistener: (payload: TMessage) => Promise<void>,\n\t\t) => Promise<void>;\n\t};\n/**\n * Utility type to extract the message from EventPublisher\n */\nexport type ExtractPublisherMessage<T> =\n\tT extends EventPublisher<infer M> ? M : never;\n\nexport type MappedEvent<\n\tT extends EventPublisher<any> | undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n> = {\n\ttype: ExtractPublisherMessage<T>['type'];\n\tpayload: (\n\t\tctx: InferStandardSchema<OutSchema>,\n\t) => ExtractPublisherMessage<T>['payload'];\n\twhen?: (ctx: InferStandardSchema<OutSchema>) => boolean;\n};\n"],"mappings":";;;;AAiBA,IAAY,qBAAL,yBAAA,oBAAA;CACN,mBAAA,WAAA;CACA,mBAAA,iBAAA;CACA,mBAAA,SAAA;CACA,mBAAA,SAAA;CACA,mBAAA,WAAA;CACA,mBAAA,cAAA;CACA,mBAAA,YAAA;;AACD,EAAA,CAAA,CAAA;;AAGA,MAAM,YAA+B;;;;;;AAMrC;;;;;AAMA,IAAa,4BAAb,cAA+C,MAAM;CAE1C;CACA;CAFV,YACC,WACA,MACC;EACD,MACC,YAAY,KAAK,QAAQ,UAAU,iBAAiB,UAAU,KAAK,IAAI,EAAE,+BAC1E;EALS,KAAA,YAAA;EACA,KAAA,OAAA;EAKT,KAAK,OAAO;CACb;AACD"}
@@ -99,6 +99,15 @@ declare enum EventPublisherType {
99
99
  RabbitMQ = "rabbitmq",
100
100
  PgBoss = "pgboss"
101
101
  }
102
+ /**
103
+ * A connection string or connection whose transport nothing here implements —
104
+ * a typo'd scheme, or one of the listed-but-unbuilt ones (EventBridge, Kafka).
105
+ */
106
+ declare class UnsupportedEventTransport extends Error {
107
+ readonly transport: string;
108
+ readonly role: 'publisher' | 'subscriber' | 'connection';
109
+ constructor(transport: string, role: 'publisher' | 'subscriber' | 'connection');
110
+ }
102
111
  /**
103
112
  * Base interface for event connections
104
113
  * Connections manage the underlying transport (RabbitMQ channel, SQS client, etc.)
@@ -136,5 +145,5 @@ type MappedEvent<T extends EventPublisher<any> | undefined, OutSchema extends St
136
145
  when?: (ctx: InferStandardSchema<OutSchema>) => boolean;
137
146
  };
138
147
  //#endregion
139
- export { ExtractPublisherMessage as a, EventSubscriber as i, EventPublisher as n, MappedEvent as o, EventPublisherType as r, PublishableMessage as s, EventConnection as t };
140
- //# sourceMappingURL=types-lnM-qoe_.d.cts.map
148
+ export { ExtractPublisherMessage as a, UnsupportedEventTransport as c, EventSubscriber as i, EventPublisher as n, MappedEvent as o, EventPublisherType as r, PublishableMessage as s, EventConnection as t };
149
+ //# sourceMappingURL=types-gGaoT8qc.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-lnM-qoe_.d.cts","names":[],"sources":["../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts","../src/types.ts"],"x_google_ignoreList":[0],"mappings":";;;UACU,gBAAgB,iBAAiB,SAAS;;WAEvC,aAAa,gBAAgB,MAAM,OAAO;;kBAErC;;YAEJ,MAAM,iBAAiB,SAAS;;aAE7B;;aAEA;;aAEA,QAAQ,MAAM,OAAO;;;YAGxB,MAAM,iBAAiB,SAAS;;aAE7B,OAAO;;aAEP,QAAQ;;;OAGhB,WAAW,eAAe,mBAAmB,YAAY;;OAEzD,YAAY,eAAe,mBAAmB,YAAY;;;UAGzD,iBAAiB,iBAAiB,SAAS;;WAExC,aAAa,iBAAiB,MAAM,OAAO;;kBAEtC;;YAEJ,MAAM,iBAAiB,SAAS,eAAe,gBAAgB,MAAM,OAAO;;aAEzE,WAAW,gBAAgB,UAAU,iBAAiB,wBAAwB,OAAO,UAAU,QAAQ,OAAO;;;OAGtH,OAAO,UAAU,cAAc,UAAU;;YAEpC,cAAc;;aAEX,OAAO;;aAEP;;YAEH;;aAEG,iBAAiB;;;YAGpB;;aAEG,QAAQ,cAAc;;;YAGzB;;aAEG;;aAEA,OAAO,cAAc,cAAc;;;YAGtC;;aAEG,KAAK;;;YAGR,MAAM,iBAAiB,SAAS,eAAe,gBAAgB,MAAM,OAAO;;OAGjF,WAAW,eAAe,mBAAmB,gBAAgB,WAAW;;OAExE,YAAY,eAAe,mBAAmB,gBAAgB,YAAY;;;;;;;;;;KCjEvE,mBAAmB,sBAAsB;EACpD,MAAM;EACN,SAAS;;;;;aAME;EACX;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;UAOgB;WACP,MAAM;EACf,WAAW;EACX,SAAS;EACT;;;;;;;;KASW,eAAe,iBAAiB;EAC3C,UAAU,SAAS,eAAe;;;;;;;KAQvB,gBAAgB,iBAAiB;EAE3C,YACC,UAAU,oBACV,WAAW,SAAS,aAAa,kBAC7B;;;;;KAKK,wBAAwB,KACnC,UAAU,qBAAqB,KAAK;KAEzB,YACX,UAAU,iCACV,kBAAkB;EAElB,MAAM,wBAAwB;EAC9B,UACC,KAAK,oBAAoB,eACrB,wBAAwB;EAC7B,QAAQ,KAAK,oBAAoB"}
1
+ {"version":3,"file":"types-gGaoT8qc.d.cts","names":[],"sources":["../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts","../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UAAU,iCACV,kBAAkB;EAElB,MAAM,wBAAwB;EAC9B,UACC,KAAK,oBAAoB,eACrB,wBAAwB;EAC7B,QAAQ,KAAK,oBAAoB"}
@@ -99,6 +99,15 @@ declare enum EventPublisherType {
99
99
  RabbitMQ = "rabbitmq",
100
100
  PgBoss = "pgboss"
101
101
  }
102
+ /**
103
+ * A connection string or connection whose transport nothing here implements —
104
+ * a typo'd scheme, or one of the listed-but-unbuilt ones (EventBridge, Kafka).
105
+ */
106
+ declare class UnsupportedEventTransport extends Error {
107
+ readonly transport: string;
108
+ readonly role: 'publisher' | 'subscriber' | 'connection';
109
+ constructor(transport: string, role: 'publisher' | 'subscriber' | 'connection');
110
+ }
102
111
  /**
103
112
  * Base interface for event connections
104
113
  * Connections manage the underlying transport (RabbitMQ channel, SQS client, etc.)
@@ -136,5 +145,5 @@ type MappedEvent<T extends EventPublisher<any> | undefined, OutSchema extends St
136
145
  when?: (ctx: InferStandardSchema<OutSchema>) => boolean;
137
146
  };
138
147
  //#endregion
139
- export { ExtractPublisherMessage as a, EventSubscriber as i, EventPublisher as n, MappedEvent as o, EventPublisherType as r, PublishableMessage as s, EventConnection as t };
140
- //# sourceMappingURL=types-lnM-qoe_.d.mts.map
148
+ export { ExtractPublisherMessage as a, UnsupportedEventTransport as c, EventSubscriber as i, EventPublisher as n, MappedEvent as o, EventPublisherType as r, PublishableMessage as s, EventConnection as t };
149
+ //# sourceMappingURL=types-gGaoT8qc.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-lnM-qoe_.d.mts","names":[],"sources":["../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts","../src/types.ts"],"x_google_ignoreList":[0],"mappings":";;;UACU,gBAAgB,iBAAiB,SAAS;;WAEvC,aAAa,gBAAgB,MAAM,OAAO;;kBAErC;;YAEJ,MAAM,iBAAiB,SAAS;;aAE7B;;aAEA;;aAEA,QAAQ,MAAM,OAAO;;;YAGxB,MAAM,iBAAiB,SAAS;;aAE7B,OAAO;;aAEP,QAAQ;;;OAGhB,WAAW,eAAe,mBAAmB,YAAY;;OAEzD,YAAY,eAAe,mBAAmB,YAAY;;;UAGzD,iBAAiB,iBAAiB,SAAS;;WAExC,aAAa,iBAAiB,MAAM,OAAO;;kBAEtC;;YAEJ,MAAM,iBAAiB,SAAS,eAAe,gBAAgB,MAAM,OAAO;;aAEzE,WAAW,gBAAgB,UAAU,iBAAiB,wBAAwB,OAAO,UAAU,QAAQ,OAAO;;;OAGtH,OAAO,UAAU,cAAc,UAAU;;YAEpC,cAAc;;aAEX,OAAO;;aAEP;;YAEH;;aAEG,iBAAiB;;;YAGpB;;aAEG,QAAQ,cAAc;;;YAGzB;;aAEG;;aAEA,OAAO,cAAc,cAAc;;;YAGtC;;aAEG,KAAK;;;YAGR,MAAM,iBAAiB,SAAS,eAAe,gBAAgB,MAAM,OAAO;;OAGjF,WAAW,eAAe,mBAAmB,gBAAgB,WAAW;;OAExE,YAAY,eAAe,mBAAmB,gBAAgB,YAAY;;;;;;;;;;KCjEvE,mBAAmB,sBAAsB;EACpD,MAAM;EACN,SAAS;;;;;aAME;EACX;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;UAOgB;WACP,MAAM;EACf,WAAW;EACX,SAAS;EACT;;;;;;;;KASW,eAAe,iBAAiB;EAC3C,UAAU,SAAS,eAAe;;;;;;;KAQvB,gBAAgB,iBAAiB;EAE3C,YACC,UAAU,oBACV,WAAW,SAAS,aAAa,kBAC7B;;;;;KAKK,wBAAwB,KACnC,UAAU,qBAAqB,KAAK;KAEzB,YACX,UAAU,iCACV,kBAAkB;EAElB,MAAM,wBAAwB;EAC9B,UACC,KAAK,oBAAoB,eACrB,wBAAwB;EAC7B,QAAQ,KAAK,oBAAoB"}
1
+ {"version":3,"file":"types-gGaoT8qc.d.mts","names":[],"sources":["../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts","../src/types.ts"],"x_google_ign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B;EAElB,MAAM,wBAAwB;EAC9B,UACC,KAAK,oBAAoB,eACrB,wBAAwB;EAC7B,QAAQ,KAAK,oBAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/events",
3
- "version": "10.0.0-alpha.13",
3
+ "version": "10.0.0-alpha.14",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -103,7 +103,7 @@
103
103
  "@aws-sdk/client-sqs": ">=3.1136.0",
104
104
  "@aws-sdk/client-sns": ">=3.1136.0",
105
105
  "pg-boss": ">=12.33.3",
106
- "@geekmidas/schema": "^10.0.0-alpha.13"
106
+ "@geekmidas/schema": "^10.0.0-alpha.14"
107
107
  },
108
108
  "peerDependenciesMeta": {
109
109
  "@geekmidas/schema": {
@@ -128,6 +128,6 @@
128
128
  "@types/pg": "~8.23.1",
129
129
  "pg": "~8.23.0",
130
130
  "pg-boss": "~12.33.3",
131
- "@geekmidas/schema": "^10.0.0-alpha.13"
131
+ "@geekmidas/schema": "^10.0.0-alpha.14"
132
132
  }
133
133
  }
@@ -1,18 +0,0 @@
1
- //#region src/types.ts
2
- /**
3
- * Event publisher/subscriber types
4
- */
5
- let EventPublisherType = /* @__PURE__ */ function(EventPublisherType) {
6
- EventPublisherType["Basic"] = "basic";
7
- EventPublisherType["EventBridge"] = "eventbridge";
8
- EventPublisherType["SQS"] = "sqs";
9
- EventPublisherType["SNS"] = "sns";
10
- EventPublisherType["Kafka"] = "kafka";
11
- EventPublisherType["RabbitMQ"] = "rabbitmq";
12
- EventPublisherType["PgBoss"] = "pgboss";
13
- return EventPublisherType;
14
- }({});
15
- //#endregion
16
- export { EventPublisherType as t };
17
-
18
- //# sourceMappingURL=types-C15FC0qp.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-C15FC0qp.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { InferStandardSchema } from '@geekmidas/schema';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\n/**\n * Represents a publishable event message with a type and payload.\n *\n * @template TType - The event type/name (e.g., 'user.created')\n * @template TPayload - The event payload data\n */\nexport type PublishableMessage<TType extends string, TPayload> = {\n\ttype: TType;\n\tpayload: TPayload;\n};\n\n/**\n * Event publisher/subscriber types\n */\nexport enum EventPublisherType {\n\tBasic = 'basic',\n\tEventBridge = 'eventbridge',\n\tSQS = 'sqs',\n\tSNS = 'sns',\n\tKafka = 'kafka',\n\tRabbitMQ = 'rabbitmq',\n\tPgBoss = 'pgboss',\n}\n\n/**\n * Base interface for event connections\n * Connections manage the underlying transport (RabbitMQ channel, SQS client, etc.)\n */\nexport interface EventConnection {\n\treadonly type: EventPublisherType;\n\tconnect(): Promise<void>;\n\tclose(): Promise<void>;\n\tisConnected(): boolean;\n}\n\n/**\n * Interface for event publishers that handle the actual publishing of events.\n * Implementations can send to EventBridge, SQS, Kafka, or any other event system.\n *\n * @template TMessage - The union type of all publishable messages\n */\nexport type EventPublisher<TMessage extends PublishableMessage<string, any>> = {\n\tpublish: (message: TMessage[]) => Promise<void>;\n};\n\n/**\n * Interface for event subscribers that handle receiving and processing events.\n *\n * @template TMessage - The union type of all publishable messages\n */\nexport type EventSubscriber<TMessage extends PublishableMessage<string, any>> =\n\t{\n\t\tsubscribe: (\n\t\t\tmessages: TMessage['type'][],\n\t\t\tlistener: (payload: TMessage) => Promise<void>,\n\t\t) => Promise<void>;\n\t};\n/**\n * Utility type to extract the message from EventPublisher\n */\nexport type ExtractPublisherMessage<T> =\n\tT extends EventPublisher<infer M> ? M : never;\n\nexport type MappedEvent<\n\tT extends EventPublisher<any> | undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n> = {\n\ttype: ExtractPublisherMessage<T>['type'];\n\tpayload: (\n\t\tctx: InferStandardSchema<OutSchema>,\n\t) => ExtractPublisherMessage<T>['payload'];\n\twhen?: (ctx: InferStandardSchema<OutSchema>) => boolean;\n};\n"],"mappings":";;;;AAiBA,IAAY,qBAAL,yBAAA,oBAAA;CACN,mBAAA,WAAA;CACA,mBAAA,iBAAA;CACA,mBAAA,SAAA;CACA,mBAAA,SAAA;CACA,mBAAA,WAAA;CACA,mBAAA,cAAA;CACA,mBAAA,YAAA;;AACD,EAAA,CAAA,CAAA"}
@@ -1,23 +0,0 @@
1
- //#region src/types.ts
2
- /**
3
- * Event publisher/subscriber types
4
- */
5
- let EventPublisherType = /* @__PURE__ */ function(EventPublisherType) {
6
- EventPublisherType["Basic"] = "basic";
7
- EventPublisherType["EventBridge"] = "eventbridge";
8
- EventPublisherType["SQS"] = "sqs";
9
- EventPublisherType["SNS"] = "sns";
10
- EventPublisherType["Kafka"] = "kafka";
11
- EventPublisherType["RabbitMQ"] = "rabbitmq";
12
- EventPublisherType["PgBoss"] = "pgboss";
13
- return EventPublisherType;
14
- }({});
15
- //#endregion
16
- Object.defineProperty(exports, "EventPublisherType", {
17
- enumerable: true,
18
- get: function() {
19
- return EventPublisherType;
20
- }
21
- });
22
-
23
- //# sourceMappingURL=types-DXNwyRyg.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-DXNwyRyg.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { InferStandardSchema } from '@geekmidas/schema';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\n/**\n * Represents a publishable event message with a type and payload.\n *\n * @template TType - The event type/name (e.g., 'user.created')\n * @template TPayload - The event payload data\n */\nexport type PublishableMessage<TType extends string, TPayload> = {\n\ttype: TType;\n\tpayload: TPayload;\n};\n\n/**\n * Event publisher/subscriber types\n */\nexport enum EventPublisherType {\n\tBasic = 'basic',\n\tEventBridge = 'eventbridge',\n\tSQS = 'sqs',\n\tSNS = 'sns',\n\tKafka = 'kafka',\n\tRabbitMQ = 'rabbitmq',\n\tPgBoss = 'pgboss',\n}\n\n/**\n * Base interface for event connections\n * Connections manage the underlying transport (RabbitMQ channel, SQS client, etc.)\n */\nexport interface EventConnection {\n\treadonly type: EventPublisherType;\n\tconnect(): Promise<void>;\n\tclose(): Promise<void>;\n\tisConnected(): boolean;\n}\n\n/**\n * Interface for event publishers that handle the actual publishing of events.\n * Implementations can send to EventBridge, SQS, Kafka, or any other event system.\n *\n * @template TMessage - The union type of all publishable messages\n */\nexport type EventPublisher<TMessage extends PublishableMessage<string, any>> = {\n\tpublish: (message: TMessage[]) => Promise<void>;\n};\n\n/**\n * Interface for event subscribers that handle receiving and processing events.\n *\n * @template TMessage - The union type of all publishable messages\n */\nexport type EventSubscriber<TMessage extends PublishableMessage<string, any>> =\n\t{\n\t\tsubscribe: (\n\t\t\tmessages: TMessage['type'][],\n\t\t\tlistener: (payload: TMessage) => Promise<void>,\n\t\t) => Promise<void>;\n\t};\n/**\n * Utility type to extract the message from EventPublisher\n */\nexport type ExtractPublisherMessage<T> =\n\tT extends EventPublisher<infer M> ? M : never;\n\nexport type MappedEvent<\n\tT extends EventPublisher<any> | undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n> = {\n\ttype: ExtractPublisherMessage<T>['type'];\n\tpayload: (\n\t\tctx: InferStandardSchema<OutSchema>,\n\t) => ExtractPublisherMessage<T>['payload'];\n\twhen?: (ctx: InferStandardSchema<OutSchema>) => boolean;\n};\n"],"mappings":";;;;AAiBA,IAAY,qBAAL,yBAAA,oBAAA;CACN,mBAAA,WAAA;CACA,mBAAA,iBAAA;CACA,mBAAA,SAAA;CACA,mBAAA,SAAA;CACA,mBAAA,WAAA;CACA,mBAAA,cAAA;CACA,mBAAA,YAAA;;AACD,EAAA,CAAA,CAAA"}