@geekmidas/events 10.0.0-alpha.9 → 10.0.0-alpha.91
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/README.md +46 -1
- package/dist/SQSSubscriber-BEJBfNTe.mjs +264 -0
- package/dist/SQSSubscriber-BEJBfNTe.mjs.map +1 -0
- package/dist/SQSSubscriber-COTqWvOk.cjs +288 -0
- package/dist/SQSSubscriber-COTqWvOk.cjs.map +1 -0
- package/dist/basic/index.cjs +41 -11
- package/dist/basic/index.cjs.map +1 -1
- package/dist/basic/index.d.cts +11 -10
- package/dist/basic/index.d.cts.map +1 -1
- package/dist/basic/index.d.mts +11 -10
- package/dist/basic/index.d.mts.map +1 -1
- package/dist/basic/index.mjs +39 -10
- package/dist/basic/index.mjs.map +1 -1
- package/dist/index.cjs +47 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -26
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +82 -26
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +34 -151
- package/dist/index.mjs.map +1 -1
- package/dist/pgboss/index.cjs +198 -34
- package/dist/pgboss/index.cjs.map +1 -1
- package/dist/pgboss/index.d.cts +54 -12
- package/dist/pgboss/index.d.cts.map +1 -1
- package/dist/pgboss/index.d.mts +54 -12
- package/dist/pgboss/index.d.mts.map +1 -1
- package/dist/pgboss/index.mjs +193 -34
- package/dist/pgboss/index.mjs.map +1 -1
- package/dist/rabbitmq/index.cjs +173 -27
- package/dist/rabbitmq/index.cjs.map +1 -1
- package/dist/rabbitmq/index.d.cts +19 -10
- package/dist/rabbitmq/index.d.cts.map +1 -1
- package/dist/rabbitmq/index.d.mts +19 -10
- package/dist/rabbitmq/index.d.mts.map +1 -1
- package/dist/rabbitmq/index.mjs +169 -27
- package/dist/rabbitmq/index.mjs.map +1 -1
- package/dist/registry-DIx25Q5s.d.cts +255 -0
- package/dist/registry-DIx25Q5s.d.cts.map +1 -0
- package/dist/registry-DIx25Q5s.d.mts +255 -0
- package/dist/registry-DIx25Q5s.d.mts.map +1 -0
- package/dist/registry-DXLY1Xf6.mjs +99 -0
- package/dist/registry-DXLY1Xf6.mjs.map +1 -0
- package/dist/registry-DlT36229.cjs +122 -0
- package/dist/registry-DlT36229.cjs.map +1 -0
- 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 +403 -40
- package/dist/sns/index.cjs.map +1 -1
- package/dist/sns/index.d.cts +175 -11
- package/dist/sns/index.d.cts.map +1 -1
- package/dist/sns/index.d.mts +175 -11
- package/dist/sns/index.d.mts.map +1 -1
- package/dist/sns/index.mjs +372 -24
- 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 +31 -65
- package/dist/sqs/index.cjs.map +1 -1
- package/dist/sqs/index.d.cts +28 -11
- package/dist/sqs/index.d.cts.map +1 -1
- package/dist/sqs/index.d.mts +28 -11
- package/dist/sqs/index.d.mts.map +1 -1
- package/dist/sqs/index.mjs +22 -58
- 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/telemetry-DG3l807O.cjs +309 -0
- package/dist/telemetry-DG3l807O.cjs.map +1 -0
- package/dist/telemetry-DjjgJMul.mjs +244 -0
- package/dist/telemetry-DjjgJMul.mjs.map +1 -0
- package/package.json +8 -3
- 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 +0 -114
- package/dist/SQSSubscriber-BMWZ3s5q.mjs.map +0 -1
- package/dist/SQSSubscriber-YXPlg2rm.cjs +0 -120
- 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/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["connectionStr: string","EventPublisherType","connectionStr: EventPublisherConnectionString","EventPublisherType","connection: EventConnection","connectionStr: EventSubscriberConnectionString","EventPublisherType","url","connection: EventConnection"],"sources":["../src/EventConnection.ts","../src/Publisher.ts","../src/Subscriber.ts"],"sourcesContent":["import type { EventConnection } from './types';\nimport { EventPublisherType } from './types';\n\nexport class EventConnectionFactory {\n\t/**\n\t * Create an EventConnection from a connection string\n\t * Dynamically imports the appropriate connection implementation\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionStr: string,\n\t): Promise<EventConnection> {\n\t\tconst url = new URL(connectionStr);\n\t\tconst protocol = url.protocol.replace(':', '') as EventPublisherType;\n\n\t\tswitch (protocol) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicConnection } = await import('./basic');\n\t\t\t\treturn BasicConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQConnection } = await import('./rabbitmq');\n\t\t\t\treturn RabbitMQConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\treturn SQSConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSConnection } = await import('./sns');\n\t\t\t\treturn SNSConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossConnection } = await import('./pgboss');\n\t\t\t\treturn PgBossConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported connection type: ${protocol}`);\n\t\t}\n\t}\n}\n\nexport type { EventConnection } from './types';\nexport { EventPublisherType } from './types';\n","import type {\n\tEventConnection,\n\tEventPublisher,\n\tPublishableMessage,\n} from './types';\nimport { EventPublisherType } from './types';\n\nexport class Publisher {\n\t/**\n\t * Create a publisher from a connection string\n\t * This creates both a connection and a publisher\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventPublisherConnectionString,\n\t): Promise<EventPublisher<TMessage>> {\n\t\tconst url = new URL(connectionStr);\n\t\tswitch (url.protocol.replace(':', '')) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicConnection, BasicPublisher } = await import('./basic');\n\t\t\t\tconst connection =\n\t\t\t\t\tawait BasicConnection.fromConnectionString(connectionStr);\n\t\t\t\treturn new BasicPublisher<TMessage>(connection);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQPublisher } = await import('./rabbitmq');\n\t\t\t\treturn RabbitMQPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSPublisher } = await import('./sqs');\n\t\t\t\treturn SQSPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSPublisher } = await import('./sns');\n\t\t\t\treturn SNSPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossPublisher } = await import('./pgboss');\n\t\t\t\treturn PgBossPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\t// Future implementations for EventBridge, Kafka, etc.\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported event publisher type: ${url.protocol}`);\n\t\t}\n\t}\n\n\t/**\n\t * Create a publisher from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t): Promise<EventPublisher<TMessage>> {\n\t\tswitch (connection.type) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicPublisher } = await import('./basic');\n\t\t\t\tconst { BasicConnection } = await import('./basic');\n\t\t\t\treturn new BasicPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof BasicConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQPublisher } = await import('./rabbitmq');\n\t\t\t\tconst { RabbitMQConnection } = await import('./rabbitmq');\n\t\t\t\treturn new RabbitMQPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof RabbitMQConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSPublisher } = await import('./sqs');\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\treturn new SQSPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SQSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSPublisher } = await import('./sns');\n\t\t\t\tconst { SNSConnection } = await import('./sns');\n\t\t\t\treturn new SNSPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SNSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossPublisher } = await import('./pgboss');\n\t\t\t\tconst { PgBossConnection } = await import('./pgboss');\n\t\t\t\treturn new PgBossPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof PgBossConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported connection type: ${connection.type}`);\n\t\t}\n\t}\n}\n\nexport type EventPublisherConnectionString =\n\t`${EventPublisherType}://${string}`;\n","import type {\n\tEventConnection,\n\tEventSubscriber,\n\tPublishableMessage,\n} from './types';\nimport { EventPublisherType } from './types';\n\nexport class Subscriber {\n\t/**\n\t * Create a subscriber from a connection string\n\t * This creates both a connection and a subscriber\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventSubscriberConnectionString,\n\t): Promise<EventSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionStr);\n\t\tswitch (url.protocol.replace(':', '')) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicConnection, BasicSubscriber } = await import('./basic');\n\t\t\t\tconst connection =\n\t\t\t\t\tawait BasicConnection.fromConnectionString(connectionStr);\n\t\t\t\treturn new BasicSubscriber<TMessage>(connection);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQSubscriber } = await import('./rabbitmq');\n\t\t\t\treturn RabbitMQSubscriber.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSSubscriber } = await import('./sns');\n\t\t\t\treturn SNSSubscriber.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst url = new URL(connectionStr);\n\t\t\t\tconst topicArn = url.searchParams.get('topicArn');\n\n\t\t\t\t// If topicArn is present, use managed SNS→SQS subscription\n\t\t\t\tif (topicArn) {\n\t\t\t\t\tconst { SNSSubscriber } = await import('./sns');\n\t\t\t\t\t// Convert SQS connection string to SNS connection string\n\t\t\t\t\tconst snsConnectionStr = connectionStr.replace('sqs://', 'sns://');\n\t\t\t\t\treturn SNSSubscriber.fromConnectionString<TMessage>(snsConnectionStr);\n\t\t\t\t}\n\n\t\t\t\t// Direct SQS subscriber\n\t\t\t\tconst { SQSSubscriber } = await import('./sqs');\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\tconst connection =\n\t\t\t\t\tawait SQSConnection.fromConnectionString(connectionStr);\n\t\t\t\treturn new SQSSubscriber<TMessage>(connection);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossSubscriber } = await import('./pgboss');\n\t\t\t\treturn PgBossSubscriber.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\t// Future implementations for EventBridge, Kafka, etc.\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported event subscriber type: ${url.protocol}`);\n\t\t}\n\t}\n\n\t/**\n\t * Create a subscriber from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t): Promise<EventSubscriber<TMessage>> {\n\t\tswitch (connection.type) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicSubscriber } = await import('./basic');\n\t\t\t\tconst { BasicConnection } = await import('./basic');\n\t\t\t\treturn new BasicSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof BasicConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQSubscriber } = await import('./rabbitmq');\n\t\t\t\tconst { RabbitMQConnection } = await import('./rabbitmq');\n\t\t\t\treturn new RabbitMQSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof RabbitMQConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSSubscriber } = await import('./sns');\n\t\t\t\tconst { SNSConnection } = await import('./sns');\n\t\t\t\treturn new SNSSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SNSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSSubscriber } = await import('./sqs');\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\treturn new SQSSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SQSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossSubscriber } = await import('./pgboss');\n\t\t\t\tconst { PgBossConnection } = await import('./pgboss');\n\t\t\t\treturn new PgBossSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof PgBossConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported connection type: ${connection.type}`);\n\t\t}\n\t}\n}\n\nexport type EventSubscriberConnectionString =\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AAM,EAAE,oBAAoB,GAAG,2CAAM;AACrC,WAAO,IAAI,mBACV;GAED;GACD,KAAKA,iCAAmB,KAAK;IAC5B,MAAM,EAAE,eAAe,GAAG,2CAAM;IAChC,MAAM,EAAE,eAAe,GAAG,2CAAM;AAChC,WAAO,IAAI,cACV;GAED;GACD,KAAKA,iCAAmB,KAAK;IAC5B,MAAM,EAAE,eAAe,GAAG,2CAAM;IAChC,MAAM,EAAE,eAAe,GAAG,2CAAM;AAChC,WAAO,IAAI,cACV;GAED;GACD,KAAKA,iCAAmB,QAAQ;IAC/B,MAAM,EAAE,kBAAkB,GAAG,2CAAM;IACnC,MAAM,EAAE,kBAAkB,GAAG,2CAAM;AACnC,WAAO,IAAI,iBACV;GAED;GACD,QACC,OAAM,IAAI,OAAO,+BAA+B,WAAW,KAAK;EACjE;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["eventsDriverFor","eventsDriverFor","eventsDriverFor"],"sources":["../src/EventConnection.ts","../src/Publisher.ts","../src/Subscriber.ts"],"sourcesContent":["import { eventsDriverFor } from './registry';\nimport type { EventConnection } from './types';\n\nexport class EventConnectionFactory {\n\t/**\n\t * Create an EventConnection from a connection string, through whichever\n\t * driver is registered for its scheme — see `registerEventsDriver`.\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionStr: string,\n\t): Promise<EventConnection> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'connection').connect(connectionStr);\n\t}\n}\n\nexport type { EventConnection } from './types';\nexport { EventPublisherType } from './types';\n","import { eventsDriverFor } from './registry';\nimport type {\n\tEventConnection,\n\tEventPublisher,\n\tEventPublisherType,\n\tPublishableMessage,\n} from './types';\n\n/** How a publisher is used, beyond the address it reaches. */\nexport interface PublisherOptions {\n\t/**\n\t * The topic this publisher fans out to. SNS and RabbitMQ name the topic in\n\t * their address already; pg-boss has one address for every topic and queue,\n\t * so it is told here that a message goes to every subscriber rather than to\n\t * one queue.\n\t */\n\ttopic?: string;\n}\n\n/**\n * Publishers for a connection string or a connection, through whichever\n * driver is registered for its scheme — see `registerEventsDriver`.\n */\nexport class Publisher {\n\t/**\n\t * Create a publisher from a connection string\n\t * This creates both a connection and a publisher\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventPublisherConnectionString,\n\t\toptions: PublisherOptions = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'publisher').publisher<TMessage>(\n\t\t\tconnectionStr,\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * Create a publisher from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t\toptions: PublisherOptions = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\treturn eventsDriverFor(connection.type, 'publisher').publisherFor<TMessage>(\n\t\t\tconnection,\n\t\t\toptions,\n\t\t);\n\t}\n}\n\nexport type EventPublisherConnectionString =\n\t`${EventPublisherType}://${string}`;\n","import { eventsDriverFor, type SubscriberOptions } from './registry';\nimport type {\n\tEventConnection,\n\tEventPublisherType,\n\tEventSubscriber,\n\tPublishableMessage,\n} from './types';\n\n/**\n * Subscribers for a connection string or a connection, through whichever\n * driver is registered for its scheme — see `registerEventsDriver`.\n */\nexport class Subscriber {\n\t/**\n\t * Create a subscriber from a connection string\n\t * This creates both a connection and a subscriber\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventSubscriberConnectionString,\n\t): Promise<EventSubscriber<TMessage>> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'subscriber').subscriber<TMessage>(\n\t\t\tconnectionStr,\n\t\t);\n\t}\n\n\t/**\n\t * Create a subscriber from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t\t/**\n\t\t * Subscribing to a topic as a named subscriber. pg-boss needs both to\n\t\t * give each subscriber its own queue; the other transports carry the\n\t\t * topic in their address and ignore it.\n\t\t */\n\t\toptions: SubscriberOptions = {},\n\t): Promise<EventSubscriber<TMessage>> {\n\t\treturn eventsDriverFor(\n\t\t\tconnection.type,\n\t\t\t'subscriber',\n\t\t).subscriberFor<TMessage>(connection, options);\n\t}\n}\n\nexport type EventSubscriberConnectionString =\n\t`${EventPublisherType}://${string}`;\n"],"mappings":";;;;AAGA,IAAa,yBAAb,MAAoC;;;;;;;;CAQnC,aAAa,qBACZ,eAC2B;EAC3B,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAOA,iBAAAA,gBAAgB,QAAQ,YAAY,CAAC,CAAC,QAAQ,aAAa;CACnE;AACD;;;;;;;ACMA,IAAa,YAAb,MAAuB;;;;;;;;CAQtB,aAAa,qBAGZ,eACA,UAA4B,CAAC,GACO;EACpC,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAOC,iBAAAA,gBAAgB,QAAQ,WAAW,CAAC,CAAC,UAC3C,eACA,OACD;CACD;;;;;CAMA,aAAa,eACZ,YACA,UAA4B,CAAC,GACO;EACpC,OAAOA,iBAAAA,gBAAgB,WAAW,MAAM,WAAW,CAAC,CAAC,aACpD,YACA,OACD;CACD;AACD;;;;;;;AC7CA,IAAa,aAAb,MAAwB;;;;;;;;CAQvB,aAAa,qBAGZ,eACqC;EACrC,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAOC,iBAAAA,gBAAgB,QAAQ,YAAY,CAAC,CAAC,WAC5C,aACD;CACD;;;;;CAMA,aAAa,eACZ,YAMA,UAA6B,CAAC,GACO;EACrC,OAAOA,iBAAAA,gBACN,WAAW,MACX,YACD,CAAC,CAAC,cAAwB,YAAY,OAAO;CAC9C;AACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,46 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { _ as UnsupportedEventTransport, a as registerEventsDriver, c as Publisher, d as EventPublisher, f as EventPublisherType, g as PublishableMessage, h as MappedEvent, i as eventsDriverFor, l as PublisherOptions, m as ExtractPublisherMessage, n as SubscriberOptions, o as registeredEventsSchemes, p as EventSubscriber, r as UnregisteredEventsScheme, s as EventPublisherConnectionString, t as EventsDriver, u as EventConnection } from "./registry-DIx25Q5s.cjs";
|
|
2
|
+
import { Context } from "@opentelemetry/api";
|
|
3
3
|
//#region src/EventConnection.d.ts
|
|
4
|
-
declare class EventConnectionFactory {
|
|
4
|
+
export declare class EventConnectionFactory {
|
|
5
5
|
/**
|
|
6
|
-
* Create an EventConnection from a connection string
|
|
7
|
-
*
|
|
6
|
+
* Create an EventConnection from a connection string, through whichever
|
|
7
|
+
* driver is registered for its scheme — see `registerEventsDriver`.
|
|
8
|
+
*
|
|
9
|
+
* @throws {UnregisteredEventsScheme} when the broker's driver is not
|
|
10
|
+
* registered.
|
|
8
11
|
*/
|
|
9
12
|
static fromConnectionString(connectionStr: string): Promise<EventConnection>;
|
|
10
13
|
}
|
|
11
14
|
//#endregion
|
|
12
|
-
//#region src/Publisher.d.ts
|
|
13
|
-
declare class Publisher {
|
|
14
|
-
/**
|
|
15
|
-
* Create a publisher from a connection string
|
|
16
|
-
* This creates both a connection and a publisher
|
|
17
|
-
*/
|
|
18
|
-
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionStr: EventPublisherConnectionString): Promise<EventPublisher<TMessage>>;
|
|
19
|
-
/**
|
|
20
|
-
* Create a publisher from an existing connection
|
|
21
|
-
* This allows sharing connections between publishers and subscribers
|
|
22
|
-
*/
|
|
23
|
-
static fromConnection<TMessage extends PublishableMessage<string, any>>(connection: EventConnection): Promise<EventPublisher<TMessage>>;
|
|
24
|
-
}
|
|
25
|
-
type EventPublisherConnectionString = `${EventPublisherType}://${string}`;
|
|
26
|
-
//# sourceMappingURL=Publisher.d.ts.map
|
|
27
|
-
//#endregion
|
|
28
15
|
//#region src/Subscriber.d.ts
|
|
29
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Subscribers for a connection string or a connection, through whichever
|
|
18
|
+
* driver is registered for its scheme — see `registerEventsDriver`.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Subscriber {
|
|
30
21
|
/**
|
|
31
22
|
* Create a subscriber from a connection string
|
|
32
23
|
* This creates both a connection and a subscriber
|
|
24
|
+
*
|
|
25
|
+
* @throws {UnregisteredEventsScheme} when the broker's driver is not
|
|
26
|
+
* registered.
|
|
33
27
|
*/
|
|
34
28
|
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionStr: EventSubscriberConnectionString): Promise<EventSubscriber<TMessage>>;
|
|
35
29
|
/**
|
|
36
30
|
* Create a subscriber from an existing connection
|
|
37
31
|
* This allows sharing connections between publishers and subscribers
|
|
38
32
|
*/
|
|
39
|
-
static fromConnection<TMessage extends PublishableMessage<string, any>>(connection: EventConnection
|
|
33
|
+
static fromConnection<TMessage extends PublishableMessage<string, any>>(connection: EventConnection,
|
|
34
|
+
/**
|
|
35
|
+
* Subscribing to a topic as a named subscriber. pg-boss needs both to
|
|
36
|
+
* give each subscriber its own queue; the other transports carry the
|
|
37
|
+
* topic in their address and ignore it.
|
|
38
|
+
*/
|
|
39
|
+
options?: SubscriberOptions): Promise<EventSubscriber<TMessage>>;
|
|
40
40
|
}
|
|
41
41
|
type EventSubscriberConnectionString = `${EventPublisherType}://${string}`;
|
|
42
|
-
//# sourceMappingURL=Subscriber.d.ts.map
|
|
43
|
-
|
|
44
42
|
//#endregion
|
|
45
|
-
|
|
43
|
+
//#region src/telemetry.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* The key a trace context travels under where a broker has no header field of
|
|
46
|
+
* its own — a pg-boss job's data. Reserved: it is removed before a handler sees
|
|
47
|
+
* the payload, and a payload of the application's own should not use it.
|
|
48
|
+
*/
|
|
49
|
+
export declare const TRACE_CONTEXT_KEY = "__gkmTrace";
|
|
50
|
+
/** A propagated trace context: `traceparent`, and `tracestate` when set. */
|
|
51
|
+
type TraceCarrier = Record<string, string>;
|
|
52
|
+
/** What a message is, as its spans describe it. */
|
|
53
|
+
interface MessagingTarget {
|
|
54
|
+
/** `messaging.system`: `pgboss`, `aws_sqs`, `aws_sns`, `rabbitmq`, `basic`. */
|
|
55
|
+
system: string;
|
|
56
|
+
/** The queue or topic — `messaging.destination.name`. */
|
|
57
|
+
destination: string;
|
|
58
|
+
/** The event's type, when the message has one. */
|
|
59
|
+
type?: string;
|
|
60
|
+
/** The broker's id for the message, when it has one. */
|
|
61
|
+
messageId?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Publish `items`, each with a PRODUCER span of its own, through `send` —
|
|
65
|
+
* which receives the carrier to attach to each item, in order.
|
|
66
|
+
*/
|
|
67
|
+
export declare function publishTraced<T, R>(items: readonly T[], describe: (item: T) => MessagingTarget, send: (carriers: (TraceCarrier | undefined)[]) => Promise<R>): Promise<R>;
|
|
68
|
+
/**
|
|
69
|
+
* The context a carrier holds, or undefined when it holds none — no carrier, a
|
|
70
|
+
* malformed `traceparent`, or a propagator that throws.
|
|
71
|
+
*/
|
|
72
|
+
export declare function extractTraceContext(carrier: TraceCarrier | undefined): Context | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Run `fn` inside a CONSUMER span for one message: a child of the context the
|
|
75
|
+
* message carried, or a new trace when it carried none. The active context of
|
|
76
|
+
* the poller that received it is never the parent — a job is not part of
|
|
77
|
+
* whatever happened to start the poll loop.
|
|
78
|
+
*/
|
|
79
|
+
export declare function consumeTraced<R>(target: MessagingTarget, carrier: TraceCarrier | undefined, fn: () => Promise<R>): Promise<R>;
|
|
80
|
+
/**
|
|
81
|
+
* One CONSUMER span for a batch that arrived together — a Lambda's records.
|
|
82
|
+
* One message with a context is its child; several start a trace of their own
|
|
83
|
+
* that links to each message's producer, since a span has one parent.
|
|
84
|
+
*/
|
|
85
|
+
export declare function consumeBatchTraced<R>(target: MessagingTarget, carriers: readonly (TraceCarrier | undefined)[], fn: () => Promise<R>): Promise<R>;
|
|
86
|
+
/**
|
|
87
|
+
* A carrier from broker message attributes, in any of the shapes they arrive
|
|
88
|
+
* in: SQS's `{ StringValue }`, a Lambda SQS record's `{ stringValue }`, an SNS
|
|
89
|
+
* envelope's `{ Value }`, or plain strings (RabbitMQ headers).
|
|
90
|
+
*/
|
|
91
|
+
export declare function carrierFromAttributes(attributes: Record<string, unknown> | undefined | null): TraceCarrier | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* `data` without {@link TRACE_CONTEXT_KEY}, and the carrier that was under it.
|
|
94
|
+
* What a handler sees never has the key.
|
|
95
|
+
*/
|
|
96
|
+
export declare function withoutTraceKey<T>(data: T): {
|
|
97
|
+
data: T;
|
|
98
|
+
carrier: TraceCarrier | undefined;
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { type EventConnection, type EventPublisher, type EventPublisherConnectionString, EventPublisherType, type EventSubscriber, type EventSubscriberConnectionString, type EventsDriver, type ExtractPublisherMessage, type MappedEvent, type MessagingTarget, type PublishableMessage, Publisher, type PublisherOptions, type SubscriberOptions, type TraceCarrier, UnregisteredEventsScheme, UnsupportedEventTransport, eventsDriverFor, registerEventsDriver, registeredEventsSchemes };
|
|
46
102
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/EventConnection.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/EventConnection.ts","../src/Subscriber.ts","../src/telemetry.ts"],"mappings":";;;qBAGa;;;;;;;;SAQC,qBACZ,wBACE,QAAQ;;;;;;;;qBCDC;;;;;;;;SAQC,qBACZ,iBAAiB,iCAEjB,eAAe,kCACb,QAAQ,gBAAgB;;;;;SAWd,eAAe,iBAAiB,iCAC5C,YAAY,iBAMZ;;;;;;EAAA,UAAS,oBACP,QAAQ,gBAAgB;;KAQhB,qCACR;;;;;;;;qBCjBS;;KAGD,eAAe;;UAGV;;EAEhB;;EAEA;;EAEA;;EAEA;;;;;;wBA+DqB,cAAc,GAAG,GACtC,gBAAgB,KAChB,WAAW,MAAM,MAAM,iBACvB,OAAO,WAAW,gCAAgC,QAAQ,KACxD,QAAQ;;;;;wBAiBK,oBACf,SAAS,2BACP;;;;;;;wBAgBa,cAAc,GAC7B,QAAQ,iBACR,SAAS,0BACT,UAAU,QAAQ,KAChB,QAAQ;;;;;;wBAUK,mBAAmB,GAClC,QAAQ,iBACR,oBAAoB,6BACpB,UAAU,QAAQ,KAChB,QAAQ;;;;;;wBAwDK,sBACf,YAAY,6CACV;;;;;wBA+Da,gBAAgB,GAAG,MAAM;EACxC,MAAM;EACN,SAAS"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,46 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { _ as UnsupportedEventTransport, a as registerEventsDriver, c as Publisher, d as EventPublisher, f as EventPublisherType, g as PublishableMessage, h as MappedEvent, i as eventsDriverFor, l as PublisherOptions, m as ExtractPublisherMessage, n as SubscriberOptions, o as registeredEventsSchemes, p as EventSubscriber, r as UnregisteredEventsScheme, s as EventPublisherConnectionString, t as EventsDriver, u as EventConnection } from "./registry-DIx25Q5s.mjs";
|
|
2
|
+
import { Context } from "@opentelemetry/api";
|
|
3
3
|
//#region src/EventConnection.d.ts
|
|
4
|
-
declare class EventConnectionFactory {
|
|
4
|
+
export declare class EventConnectionFactory {
|
|
5
5
|
/**
|
|
6
|
-
* Create an EventConnection from a connection string
|
|
7
|
-
*
|
|
6
|
+
* Create an EventConnection from a connection string, through whichever
|
|
7
|
+
* driver is registered for its scheme — see `registerEventsDriver`.
|
|
8
|
+
*
|
|
9
|
+
* @throws {UnregisteredEventsScheme} when the broker's driver is not
|
|
10
|
+
* registered.
|
|
8
11
|
*/
|
|
9
12
|
static fromConnectionString(connectionStr: string): Promise<EventConnection>;
|
|
10
13
|
}
|
|
11
14
|
//#endregion
|
|
12
|
-
//#region src/Publisher.d.ts
|
|
13
|
-
declare class Publisher {
|
|
14
|
-
/**
|
|
15
|
-
* Create a publisher from a connection string
|
|
16
|
-
* This creates both a connection and a publisher
|
|
17
|
-
*/
|
|
18
|
-
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionStr: EventPublisherConnectionString): Promise<EventPublisher<TMessage>>;
|
|
19
|
-
/**
|
|
20
|
-
* Create a publisher from an existing connection
|
|
21
|
-
* This allows sharing connections between publishers and subscribers
|
|
22
|
-
*/
|
|
23
|
-
static fromConnection<TMessage extends PublishableMessage<string, any>>(connection: EventConnection): Promise<EventPublisher<TMessage>>;
|
|
24
|
-
}
|
|
25
|
-
type EventPublisherConnectionString = `${EventPublisherType}://${string}`;
|
|
26
|
-
//# sourceMappingURL=Publisher.d.ts.map
|
|
27
|
-
//#endregion
|
|
28
15
|
//#region src/Subscriber.d.ts
|
|
29
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Subscribers for a connection string or a connection, through whichever
|
|
18
|
+
* driver is registered for its scheme — see `registerEventsDriver`.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Subscriber {
|
|
30
21
|
/**
|
|
31
22
|
* Create a subscriber from a connection string
|
|
32
23
|
* This creates both a connection and a subscriber
|
|
24
|
+
*
|
|
25
|
+
* @throws {UnregisteredEventsScheme} when the broker's driver is not
|
|
26
|
+
* registered.
|
|
33
27
|
*/
|
|
34
28
|
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionStr: EventSubscriberConnectionString): Promise<EventSubscriber<TMessage>>;
|
|
35
29
|
/**
|
|
36
30
|
* Create a subscriber from an existing connection
|
|
37
31
|
* This allows sharing connections between publishers and subscribers
|
|
38
32
|
*/
|
|
39
|
-
static fromConnection<TMessage extends PublishableMessage<string, any>>(connection: EventConnection
|
|
33
|
+
static fromConnection<TMessage extends PublishableMessage<string, any>>(connection: EventConnection,
|
|
34
|
+
/**
|
|
35
|
+
* Subscribing to a topic as a named subscriber. pg-boss needs both to
|
|
36
|
+
* give each subscriber its own queue; the other transports carry the
|
|
37
|
+
* topic in their address and ignore it.
|
|
38
|
+
*/
|
|
39
|
+
options?: SubscriberOptions): Promise<EventSubscriber<TMessage>>;
|
|
40
40
|
}
|
|
41
41
|
type EventSubscriberConnectionString = `${EventPublisherType}://${string}`;
|
|
42
|
-
//# sourceMappingURL=Subscriber.d.ts.map
|
|
43
|
-
|
|
44
42
|
//#endregion
|
|
45
|
-
|
|
43
|
+
//#region src/telemetry.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* The key a trace context travels under where a broker has no header field of
|
|
46
|
+
* its own — a pg-boss job's data. Reserved: it is removed before a handler sees
|
|
47
|
+
* the payload, and a payload of the application's own should not use it.
|
|
48
|
+
*/
|
|
49
|
+
export declare const TRACE_CONTEXT_KEY = "__gkmTrace";
|
|
50
|
+
/** A propagated trace context: `traceparent`, and `tracestate` when set. */
|
|
51
|
+
type TraceCarrier = Record<string, string>;
|
|
52
|
+
/** What a message is, as its spans describe it. */
|
|
53
|
+
interface MessagingTarget {
|
|
54
|
+
/** `messaging.system`: `pgboss`, `aws_sqs`, `aws_sns`, `rabbitmq`, `basic`. */
|
|
55
|
+
system: string;
|
|
56
|
+
/** The queue or topic — `messaging.destination.name`. */
|
|
57
|
+
destination: string;
|
|
58
|
+
/** The event's type, when the message has one. */
|
|
59
|
+
type?: string;
|
|
60
|
+
/** The broker's id for the message, when it has one. */
|
|
61
|
+
messageId?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Publish `items`, each with a PRODUCER span of its own, through `send` —
|
|
65
|
+
* which receives the carrier to attach to each item, in order.
|
|
66
|
+
*/
|
|
67
|
+
export declare function publishTraced<T, R>(items: readonly T[], describe: (item: T) => MessagingTarget, send: (carriers: (TraceCarrier | undefined)[]) => Promise<R>): Promise<R>;
|
|
68
|
+
/**
|
|
69
|
+
* The context a carrier holds, or undefined when it holds none — no carrier, a
|
|
70
|
+
* malformed `traceparent`, or a propagator that throws.
|
|
71
|
+
*/
|
|
72
|
+
export declare function extractTraceContext(carrier: TraceCarrier | undefined): Context | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Run `fn` inside a CONSUMER span for one message: a child of the context the
|
|
75
|
+
* message carried, or a new trace when it carried none. The active context of
|
|
76
|
+
* the poller that received it is never the parent — a job is not part of
|
|
77
|
+
* whatever happened to start the poll loop.
|
|
78
|
+
*/
|
|
79
|
+
export declare function consumeTraced<R>(target: MessagingTarget, carrier: TraceCarrier | undefined, fn: () => Promise<R>): Promise<R>;
|
|
80
|
+
/**
|
|
81
|
+
* One CONSUMER span for a batch that arrived together — a Lambda's records.
|
|
82
|
+
* One message with a context is its child; several start a trace of their own
|
|
83
|
+
* that links to each message's producer, since a span has one parent.
|
|
84
|
+
*/
|
|
85
|
+
export declare function consumeBatchTraced<R>(target: MessagingTarget, carriers: readonly (TraceCarrier | undefined)[], fn: () => Promise<R>): Promise<R>;
|
|
86
|
+
/**
|
|
87
|
+
* A carrier from broker message attributes, in any of the shapes they arrive
|
|
88
|
+
* in: SQS's `{ StringValue }`, a Lambda SQS record's `{ stringValue }`, an SNS
|
|
89
|
+
* envelope's `{ Value }`, or plain strings (RabbitMQ headers).
|
|
90
|
+
*/
|
|
91
|
+
export declare function carrierFromAttributes(attributes: Record<string, unknown> | undefined | null): TraceCarrier | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* `data` without {@link TRACE_CONTEXT_KEY}, and the carrier that was under it.
|
|
94
|
+
* What a handler sees never has the key.
|
|
95
|
+
*/
|
|
96
|
+
export declare function withoutTraceKey<T>(data: T): {
|
|
97
|
+
data: T;
|
|
98
|
+
carrier: TraceCarrier | undefined;
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { type EventConnection, type EventPublisher, type EventPublisherConnectionString, EventPublisherType, type EventSubscriber, type EventSubscriberConnectionString, type EventsDriver, type ExtractPublisherMessage, type MappedEvent, type MessagingTarget, type PublishableMessage, Publisher, type PublisherOptions, type SubscriberOptions, type TraceCarrier, UnregisteredEventsScheme, UnsupportedEventTransport, eventsDriverFor, registerEventsDriver, registeredEventsSchemes };
|
|
46
102
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/EventConnection.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/EventConnection.ts","../src/Subscriber.ts","../src/telemetry.ts"],"mappings":";;;qBAGa;;;;;;;;SAQC,qBACZ,wBACE,QAAQ;;;;;;;;qBCDC;;;;;;;;SAQC,qBACZ,iBAAiB,iCAEjB,eAAe,kCACb,QAAQ,gBAAgB;;;;;SAWd,eAAe,iBAAiB,iCAC5C,YAAY,iBAMZ;;;;;;EAAA,UAAS,oBACP,QAAQ,gBAAgB;;KAQhB,qCACR;;;;;;;;qBCjBS;;KAGD,eAAe;;UAGV;;EAEhB;;EAEA;;EAEA;;EAEA;;;;;;wBA+DqB,cAAc,GAAG,GACtC,gBAAgB,KAChB,WAAW,MAAM,MAAM,iBACvB,OAAO,WAAW,gCAAgC,QAAQ,KACxD,QAAQ;;;;;wBAiBK,oBACf,SAAS,2BACP;;;;;;;wBAgBa,cAAc,GAC7B,QAAQ,iBACR,SAAS,0BACT,UAAU,QAAQ,KAChB,QAAQ;;;;;;wBAUK,mBAAmB,GAClC,QAAQ,iBACR,oBAAoB,6BACpB,UAAU,QAAQ,KAChB,QAAQ;;;;;;wBAwDK,sBACf,YAAY,6CACV;;;;;wBA+Da,gBAAgB,GAAG,MAAM;EACxC,MAAM;EACN,SAAS"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,189 +1,72 @@
|
|
|
1
|
-
import { EventPublisherType } from "./
|
|
2
|
-
|
|
1
|
+
import { a as consumeTraced, d as UnsupportedEventTransport, i as consumeBatchTraced, l as withoutTraceKey, o as extractTraceContext, r as carrierFromAttributes, s as publishTraced, t as TRACE_CONTEXT_KEY, u as EventPublisherType } from "./telemetry-DjjgJMul.mjs";
|
|
2
|
+
import { i as registeredEventsSchemes, n as eventsDriverFor, r as registerEventsDriver, t as UnregisteredEventsScheme } from "./registry-DXLY1Xf6.mjs";
|
|
3
3
|
//#region src/EventConnection.ts
|
|
4
4
|
var EventConnectionFactory = class {
|
|
5
5
|
/**
|
|
6
|
-
* Create an EventConnection from a connection string
|
|
7
|
-
*
|
|
6
|
+
* Create an EventConnection from a connection string, through whichever
|
|
7
|
+
* driver is registered for its scheme — see `registerEventsDriver`.
|
|
8
|
+
*
|
|
9
|
+
* @throws {UnregisteredEventsScheme} when the broker's driver is not
|
|
10
|
+
* registered.
|
|
8
11
|
*/
|
|
9
12
|
static async fromConnectionString(connectionStr) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
switch (protocol) {
|
|
13
|
-
case EventPublisherType.Basic: {
|
|
14
|
-
const { BasicConnection } = await import("./basic/index.mjs");
|
|
15
|
-
return BasicConnection.fromConnectionString(connectionStr);
|
|
16
|
-
}
|
|
17
|
-
case EventPublisherType.RabbitMQ: {
|
|
18
|
-
const { RabbitMQConnection } = await import("./rabbitmq/index.mjs");
|
|
19
|
-
return RabbitMQConnection.fromConnectionString(connectionStr);
|
|
20
|
-
}
|
|
21
|
-
case EventPublisherType.SQS: {
|
|
22
|
-
const { SQSConnection } = await import("./sqs/index.mjs");
|
|
23
|
-
return SQSConnection.fromConnectionString(connectionStr);
|
|
24
|
-
}
|
|
25
|
-
case EventPublisherType.SNS: {
|
|
26
|
-
const { SNSConnection } = await import("./sns/index.mjs");
|
|
27
|
-
return SNSConnection.fromConnectionString(connectionStr);
|
|
28
|
-
}
|
|
29
|
-
case EventPublisherType.PgBoss: {
|
|
30
|
-
const { PgBossConnection } = await import("./pgboss/index.mjs");
|
|
31
|
-
return PgBossConnection.fromConnectionString(connectionStr);
|
|
32
|
-
}
|
|
33
|
-
default: throw new Error(`Unsupported connection type: ${protocol}`);
|
|
34
|
-
}
|
|
13
|
+
const scheme = new URL(connectionStr).protocol;
|
|
14
|
+
return eventsDriverFor(scheme, "connection").connect(connectionStr);
|
|
35
15
|
}
|
|
36
16
|
};
|
|
37
|
-
|
|
38
17
|
//#endregion
|
|
39
18
|
//#region src/Publisher.ts
|
|
19
|
+
/**
|
|
20
|
+
* Publishers for a connection string or a connection, through whichever
|
|
21
|
+
* driver is registered for its scheme — see `registerEventsDriver`.
|
|
22
|
+
*/
|
|
40
23
|
var Publisher = class {
|
|
41
24
|
/**
|
|
42
25
|
* Create a publisher from a connection string
|
|
43
26
|
* This creates both a connection and a publisher
|
|
27
|
+
*
|
|
28
|
+
* @throws {UnregisteredEventsScheme} when the broker's driver is not
|
|
29
|
+
* registered.
|
|
44
30
|
*/
|
|
45
|
-
static async fromConnectionString(connectionStr) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
case EventPublisherType.Basic: {
|
|
49
|
-
const { BasicConnection, BasicPublisher } = await import("./basic/index.mjs");
|
|
50
|
-
const connection = await BasicConnection.fromConnectionString(connectionStr);
|
|
51
|
-
return new BasicPublisher(connection);
|
|
52
|
-
}
|
|
53
|
-
case EventPublisherType.RabbitMQ: {
|
|
54
|
-
const { RabbitMQPublisher } = await import("./rabbitmq/index.mjs");
|
|
55
|
-
return RabbitMQPublisher.fromConnectionString(connectionStr);
|
|
56
|
-
}
|
|
57
|
-
case EventPublisherType.SQS: {
|
|
58
|
-
const { SQSPublisher } = await import("./sqs/index.mjs");
|
|
59
|
-
return SQSPublisher.fromConnectionString(connectionStr);
|
|
60
|
-
}
|
|
61
|
-
case EventPublisherType.SNS: {
|
|
62
|
-
const { SNSPublisher } = await import("./sns/index.mjs");
|
|
63
|
-
return SNSPublisher.fromConnectionString(connectionStr);
|
|
64
|
-
}
|
|
65
|
-
case EventPublisherType.PgBoss: {
|
|
66
|
-
const { PgBossPublisher } = await import("./pgboss/index.mjs");
|
|
67
|
-
return PgBossPublisher.fromConnectionString(connectionStr);
|
|
68
|
-
}
|
|
69
|
-
default: throw new Error(`Unsupported event publisher type: ${url.protocol}`);
|
|
70
|
-
}
|
|
31
|
+
static async fromConnectionString(connectionStr, options = {}) {
|
|
32
|
+
const scheme = new URL(connectionStr).protocol;
|
|
33
|
+
return eventsDriverFor(scheme, "publisher").publisher(connectionStr, options);
|
|
71
34
|
}
|
|
72
35
|
/**
|
|
73
36
|
* Create a publisher from an existing connection
|
|
74
37
|
* This allows sharing connections between publishers and subscribers
|
|
75
38
|
*/
|
|
76
|
-
static async fromConnection(connection) {
|
|
77
|
-
|
|
78
|
-
case EventPublisherType.Basic: {
|
|
79
|
-
const { BasicPublisher } = await import("./basic/index.mjs");
|
|
80
|
-
const { BasicConnection } = await import("./basic/index.mjs");
|
|
81
|
-
return new BasicPublisher(connection);
|
|
82
|
-
}
|
|
83
|
-
case EventPublisherType.RabbitMQ: {
|
|
84
|
-
const { RabbitMQPublisher } = await import("./rabbitmq/index.mjs");
|
|
85
|
-
const { RabbitMQConnection } = await import("./rabbitmq/index.mjs");
|
|
86
|
-
return new RabbitMQPublisher(connection);
|
|
87
|
-
}
|
|
88
|
-
case EventPublisherType.SQS: {
|
|
89
|
-
const { SQSPublisher } = await import("./sqs/index.mjs");
|
|
90
|
-
const { SQSConnection } = await import("./sqs/index.mjs");
|
|
91
|
-
return new SQSPublisher(connection);
|
|
92
|
-
}
|
|
93
|
-
case EventPublisherType.SNS: {
|
|
94
|
-
const { SNSPublisher } = await import("./sns/index.mjs");
|
|
95
|
-
const { SNSConnection } = await import("./sns/index.mjs");
|
|
96
|
-
return new SNSPublisher(connection);
|
|
97
|
-
}
|
|
98
|
-
case EventPublisherType.PgBoss: {
|
|
99
|
-
const { PgBossPublisher } = await import("./pgboss/index.mjs");
|
|
100
|
-
const { PgBossConnection } = await import("./pgboss/index.mjs");
|
|
101
|
-
return new PgBossPublisher(connection);
|
|
102
|
-
}
|
|
103
|
-
default: throw new Error(`Unsupported connection type: ${connection.type}`);
|
|
104
|
-
}
|
|
39
|
+
static async fromConnection(connection, options = {}) {
|
|
40
|
+
return eventsDriverFor(connection.type, "publisher").publisherFor(connection, options);
|
|
105
41
|
}
|
|
106
42
|
};
|
|
107
|
-
|
|
108
43
|
//#endregion
|
|
109
44
|
//#region src/Subscriber.ts
|
|
45
|
+
/**
|
|
46
|
+
* Subscribers for a connection string or a connection, through whichever
|
|
47
|
+
* driver is registered for its scheme — see `registerEventsDriver`.
|
|
48
|
+
*/
|
|
110
49
|
var Subscriber = class {
|
|
111
50
|
/**
|
|
112
51
|
* Create a subscriber from a connection string
|
|
113
52
|
* This creates both a connection and a subscriber
|
|
53
|
+
*
|
|
54
|
+
* @throws {UnregisteredEventsScheme} when the broker's driver is not
|
|
55
|
+
* registered.
|
|
114
56
|
*/
|
|
115
57
|
static async fromConnectionString(connectionStr) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
case EventPublisherType.Basic: {
|
|
119
|
-
const { BasicConnection, BasicSubscriber } = await import("./basic/index.mjs");
|
|
120
|
-
const connection = await BasicConnection.fromConnectionString(connectionStr);
|
|
121
|
-
return new BasicSubscriber(connection);
|
|
122
|
-
}
|
|
123
|
-
case EventPublisherType.RabbitMQ: {
|
|
124
|
-
const { RabbitMQSubscriber } = await import("./rabbitmq/index.mjs");
|
|
125
|
-
return RabbitMQSubscriber.fromConnectionString(connectionStr);
|
|
126
|
-
}
|
|
127
|
-
case EventPublisherType.SNS: {
|
|
128
|
-
const { SNSSubscriber } = await import("./sns/index.mjs");
|
|
129
|
-
return SNSSubscriber.fromConnectionString(connectionStr);
|
|
130
|
-
}
|
|
131
|
-
case EventPublisherType.SQS: {
|
|
132
|
-
const url$1 = new URL(connectionStr);
|
|
133
|
-
const topicArn = url$1.searchParams.get("topicArn");
|
|
134
|
-
if (topicArn) {
|
|
135
|
-
const { SNSSubscriber } = await import("./sns/index.mjs");
|
|
136
|
-
const snsConnectionStr = connectionStr.replace("sqs://", "sns://");
|
|
137
|
-
return SNSSubscriber.fromConnectionString(snsConnectionStr);
|
|
138
|
-
}
|
|
139
|
-
const { SQSSubscriber } = await import("./sqs/index.mjs");
|
|
140
|
-
const { SQSConnection } = await import("./sqs/index.mjs");
|
|
141
|
-
const connection = await SQSConnection.fromConnectionString(connectionStr);
|
|
142
|
-
return new SQSSubscriber(connection);
|
|
143
|
-
}
|
|
144
|
-
case EventPublisherType.PgBoss: {
|
|
145
|
-
const { PgBossSubscriber } = await import("./pgboss/index.mjs");
|
|
146
|
-
return PgBossSubscriber.fromConnectionString(connectionStr);
|
|
147
|
-
}
|
|
148
|
-
default: throw new Error(`Unsupported event subscriber type: ${url.protocol}`);
|
|
149
|
-
}
|
|
58
|
+
const scheme = new URL(connectionStr).protocol;
|
|
59
|
+
return eventsDriverFor(scheme, "subscriber").subscriber(connectionStr);
|
|
150
60
|
}
|
|
151
61
|
/**
|
|
152
62
|
* Create a subscriber from an existing connection
|
|
153
63
|
* This allows sharing connections between publishers and subscribers
|
|
154
64
|
*/
|
|
155
|
-
static async fromConnection(connection) {
|
|
156
|
-
|
|
157
|
-
case EventPublisherType.Basic: {
|
|
158
|
-
const { BasicSubscriber } = await import("./basic/index.mjs");
|
|
159
|
-
const { BasicConnection } = await import("./basic/index.mjs");
|
|
160
|
-
return new BasicSubscriber(connection);
|
|
161
|
-
}
|
|
162
|
-
case EventPublisherType.RabbitMQ: {
|
|
163
|
-
const { RabbitMQSubscriber } = await import("./rabbitmq/index.mjs");
|
|
164
|
-
const { RabbitMQConnection } = await import("./rabbitmq/index.mjs");
|
|
165
|
-
return new RabbitMQSubscriber(connection);
|
|
166
|
-
}
|
|
167
|
-
case EventPublisherType.SNS: {
|
|
168
|
-
const { SNSSubscriber } = await import("./sns/index.mjs");
|
|
169
|
-
const { SNSConnection } = await import("./sns/index.mjs");
|
|
170
|
-
return new SNSSubscriber(connection);
|
|
171
|
-
}
|
|
172
|
-
case EventPublisherType.SQS: {
|
|
173
|
-
const { SQSSubscriber } = await import("./sqs/index.mjs");
|
|
174
|
-
const { SQSConnection } = await import("./sqs/index.mjs");
|
|
175
|
-
return new SQSSubscriber(connection);
|
|
176
|
-
}
|
|
177
|
-
case EventPublisherType.PgBoss: {
|
|
178
|
-
const { PgBossSubscriber } = await import("./pgboss/index.mjs");
|
|
179
|
-
const { PgBossConnection } = await import("./pgboss/index.mjs");
|
|
180
|
-
return new PgBossSubscriber(connection);
|
|
181
|
-
}
|
|
182
|
-
default: throw new Error(`Unsupported connection type: ${connection.type}`);
|
|
183
|
-
}
|
|
65
|
+
static async fromConnection(connection, options = {}) {
|
|
66
|
+
return eventsDriverFor(connection.type, "subscriber").subscriberFor(connection, options);
|
|
184
67
|
}
|
|
185
68
|
};
|
|
186
|
-
|
|
187
69
|
//#endregion
|
|
188
|
-
export { EventConnectionFactory, EventPublisherType, Publisher, Subscriber };
|
|
70
|
+
export { EventConnectionFactory, EventPublisherType, Publisher, Subscriber, TRACE_CONTEXT_KEY, UnregisteredEventsScheme, UnsupportedEventTransport, carrierFromAttributes, consumeBatchTraced, consumeTraced, eventsDriverFor, extractTraceContext, publishTraced, registerEventsDriver, registeredEventsSchemes, withoutTraceKey };
|
|
71
|
+
|
|
189
72
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["connectionStr: string","connectionStr: EventPublisherConnectionString","connection: EventConnection","connectionStr: EventSubscriberConnectionString","url","connection: EventConnection"],"sources":["../src/EventConnection.ts","../src/Publisher.ts","../src/Subscriber.ts"],"sourcesContent":["import type { EventConnection } from './types';\nimport { EventPublisherType } from './types';\n\nexport class EventConnectionFactory {\n\t/**\n\t * Create an EventConnection from a connection string\n\t * Dynamically imports the appropriate connection implementation\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionStr: string,\n\t): Promise<EventConnection> {\n\t\tconst url = new URL(connectionStr);\n\t\tconst protocol = url.protocol.replace(':', '') as EventPublisherType;\n\n\t\tswitch (protocol) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicConnection } = await import('./basic');\n\t\t\t\treturn BasicConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQConnection } = await import('./rabbitmq');\n\t\t\t\treturn RabbitMQConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\treturn SQSConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSConnection } = await import('./sns');\n\t\t\t\treturn SNSConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossConnection } = await import('./pgboss');\n\t\t\t\treturn PgBossConnection.fromConnectionString(connectionStr);\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported connection type: ${protocol}`);\n\t\t}\n\t}\n}\n\nexport type { EventConnection } from './types';\nexport { EventPublisherType } from './types';\n","import type {\n\tEventConnection,\n\tEventPublisher,\n\tPublishableMessage,\n} from './types';\nimport { EventPublisherType } from './types';\n\nexport class Publisher {\n\t/**\n\t * Create a publisher from a connection string\n\t * This creates both a connection and a publisher\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventPublisherConnectionString,\n\t): Promise<EventPublisher<TMessage>> {\n\t\tconst url = new URL(connectionStr);\n\t\tswitch (url.protocol.replace(':', '')) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicConnection, BasicPublisher } = await import('./basic');\n\t\t\t\tconst connection =\n\t\t\t\t\tawait BasicConnection.fromConnectionString(connectionStr);\n\t\t\t\treturn new BasicPublisher<TMessage>(connection);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQPublisher } = await import('./rabbitmq');\n\t\t\t\treturn RabbitMQPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSPublisher } = await import('./sqs');\n\t\t\t\treturn SQSPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSPublisher } = await import('./sns');\n\t\t\t\treturn SNSPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossPublisher } = await import('./pgboss');\n\t\t\t\treturn PgBossPublisher.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\t// Future implementations for EventBridge, Kafka, etc.\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported event publisher type: ${url.protocol}`);\n\t\t}\n\t}\n\n\t/**\n\t * Create a publisher from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t): Promise<EventPublisher<TMessage>> {\n\t\tswitch (connection.type) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicPublisher } = await import('./basic');\n\t\t\t\tconst { BasicConnection } = await import('./basic');\n\t\t\t\treturn new BasicPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof BasicConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQPublisher } = await import('./rabbitmq');\n\t\t\t\tconst { RabbitMQConnection } = await import('./rabbitmq');\n\t\t\t\treturn new RabbitMQPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof RabbitMQConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSPublisher } = await import('./sqs');\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\treturn new SQSPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SQSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSPublisher } = await import('./sns');\n\t\t\t\tconst { SNSConnection } = await import('./sns');\n\t\t\t\treturn new SNSPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SNSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossPublisher } = await import('./pgboss');\n\t\t\t\tconst { PgBossConnection } = await import('./pgboss');\n\t\t\t\treturn new PgBossPublisher<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof PgBossConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported connection type: ${connection.type}`);\n\t\t}\n\t}\n}\n\nexport type EventPublisherConnectionString =\n\t`${EventPublisherType}://${string}`;\n","import type {\n\tEventConnection,\n\tEventSubscriber,\n\tPublishableMessage,\n} from './types';\nimport { EventPublisherType } from './types';\n\nexport class Subscriber {\n\t/**\n\t * Create a subscriber from a connection string\n\t * This creates both a connection and a subscriber\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventSubscriberConnectionString,\n\t): Promise<EventSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionStr);\n\t\tswitch (url.protocol.replace(':', '')) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicConnection, BasicSubscriber } = await import('./basic');\n\t\t\t\tconst connection =\n\t\t\t\t\tawait BasicConnection.fromConnectionString(connectionStr);\n\t\t\t\treturn new BasicSubscriber<TMessage>(connection);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQSubscriber } = await import('./rabbitmq');\n\t\t\t\treturn RabbitMQSubscriber.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSSubscriber } = await import('./sns');\n\t\t\t\treturn SNSSubscriber.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst url = new URL(connectionStr);\n\t\t\t\tconst topicArn = url.searchParams.get('topicArn');\n\n\t\t\t\t// If topicArn is present, use managed SNS→SQS subscription\n\t\t\t\tif (topicArn) {\n\t\t\t\t\tconst { SNSSubscriber } = await import('./sns');\n\t\t\t\t\t// Convert SQS connection string to SNS connection string\n\t\t\t\t\tconst snsConnectionStr = connectionStr.replace('sqs://', 'sns://');\n\t\t\t\t\treturn SNSSubscriber.fromConnectionString<TMessage>(snsConnectionStr);\n\t\t\t\t}\n\n\t\t\t\t// Direct SQS subscriber\n\t\t\t\tconst { SQSSubscriber } = await import('./sqs');\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\tconst connection =\n\t\t\t\t\tawait SQSConnection.fromConnectionString(connectionStr);\n\t\t\t\treturn new SQSSubscriber<TMessage>(connection);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossSubscriber } = await import('./pgboss');\n\t\t\t\treturn PgBossSubscriber.fromConnectionString<TMessage>(connectionStr);\n\t\t\t}\n\t\t\t// Future implementations for EventBridge, Kafka, etc.\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported event subscriber type: ${url.protocol}`);\n\t\t}\n\t}\n\n\t/**\n\t * Create a subscriber from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t): Promise<EventSubscriber<TMessage>> {\n\t\tswitch (connection.type) {\n\t\t\tcase EventPublisherType.Basic: {\n\t\t\t\tconst { BasicSubscriber } = await import('./basic');\n\t\t\t\tconst { BasicConnection } = await import('./basic');\n\t\t\t\treturn new BasicSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof BasicConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.RabbitMQ: {\n\t\t\t\tconst { RabbitMQSubscriber } = await import('./rabbitmq');\n\t\t\t\tconst { RabbitMQConnection } = await import('./rabbitmq');\n\t\t\t\treturn new RabbitMQSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof RabbitMQConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SNS: {\n\t\t\t\tconst { SNSSubscriber } = await import('./sns');\n\t\t\t\tconst { SNSConnection } = await import('./sns');\n\t\t\t\treturn new SNSSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SNSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.SQS: {\n\t\t\t\tconst { SQSSubscriber } = await import('./sqs');\n\t\t\t\tconst { SQSConnection } = await import('./sqs');\n\t\t\t\treturn new SQSSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof SQSConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase EventPublisherType.PgBoss: {\n\t\t\t\tconst { PgBossSubscriber } = await import('./pgboss');\n\t\t\t\tconst { PgBossConnection } = await import('./pgboss');\n\t\t\t\treturn new PgBossSubscriber<TMessage>(\n\t\t\t\t\tconnection as InstanceType<typeof PgBossConnection>,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported connection type: ${connection.type}`);\n\t\t}\n\t}\n}\n\nexport type EventSubscriberConnectionString =\n\t`${EventPublisherType}://${string}`;\n"],"mappings":";;;AAGA,IAAa,yBAAb,MAAoC;;;;;CAKnC,aAAa,qBACZA,eAC2B;EAC3B,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,WAAW,IAAI,SAAS,QAAQ,KAAK,GAAG;AAE9C,UAAQ,UAAR;GACC,KAAK,mBAAmB,OAAO;IAC9B,MAAM,EAAE,iBAAiB,GAAG,MAAM,OAAO;AACzC,WAAO,gBAAgB,qBAAqB,cAAc;GAC1D;GACD,KAAK,mBAAmB,UAAU;IACjC,MAAM,EAAE,oBAAoB,GAAG,MAAM,OAAO;AAC5C,WAAO,mBAAmB,qBAAqB,cAAc;GAC7D;GACD,KAAK,mBAAmB,KAAK;IAC5B,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;AACvC,WAAO,cAAc,qBAAqB,cAAc;GACxD;GACD,KAAK,mBAAmB,KAAK;IAC5B,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;AACvC,WAAO,cAAc,qBAAqB,cAAc;GACxD;GACD,KAAK,mBAAmB,QAAQ;IAC/B,MAAM,EAAE,kBAAkB,GAAG,MAAM,OAAO;AAC1C,WAAO,iBAAiB,qBAAqB,cAAc;GAC3D;GACD,QACC,OAAM,IAAI,OAAO,+BAA+B,SAAS;EAC1D;CACD;AACD;;;;AChCD,IAAa,YAAb,MAAuB;;;;;CAKtB,aAAa,qBAGZC,eACoC;EACpC,MAAM,MAAM,IAAI,IAAI;AACpB,UAAQ,IAAI,SAAS,QAAQ,KAAK,GAAG,EAArC;GACC,KAAK,mBAAmB,OAAO;IAC9B,MAAM,EAAE,iBAAiB,gBAAgB,GAAG,MAAM,OAAO;IACzD,MAAM,aACL,MAAM,gBAAgB,qBAAqB,cAAc;AAC1D,WAAO,IAAI,eAAyB;GACpC;GACD,KAAK,mBAAmB,UAAU;IACjC,MAAM,EAAE,m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AO;IAC9B,MAAM,EAAE,iBAAiB,GAAG,MAAM,OAAO;IACzC,MAAM,EAAE,iBAAiB,GAAG,MAAM,OAAO;AACzC,WAAO,IAAI,gBACV;GAED;GACD,KAAK,mBAAmB,UAAU;IACjC,MAAM,EAAE,oBAAoB,GAAG,MAAM,OAAO;IAC5C,MAAM,EAAE,oBAAoB,GAAG,MAAM,OAAO;AAC5C,WAAO,IAAI,mBACV;GAED;GACD,KAAK,mBAAmB,KAAK;IAC5B,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;IACvC,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;AACvC,WAAO,IAAI,cACV;GAED;GACD,KAAK,mBAAmB,KAAK;IAC5B,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;IACvC,MAAM,EAAE,eAAe,GAAG,MAAM,OAAO;AACvC,WAAO,IAAI,cACV;GAED;GACD,KAAK,mBAAmB,QAAQ;IAC/B,MAAM,EAAE,kBAAkB,GAAG,MAAM,OAAO;IAC1C,MAAM,EAAE,kBAAkB,GAAG,MAAM,OAAO;AAC1C,WAAO,IAAI,iBACV;GAED;GACD,QACC,OAAM,IAAI,OAAO,+BAA+B,WAAW,KAAK;EACjE;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/EventConnection.ts","../src/Publisher.ts","../src/Subscriber.ts"],"sourcesContent":["import { eventsDriverFor } from './registry';\nimport type { EventConnection } from './types';\n\nexport class EventConnectionFactory {\n\t/**\n\t * Create an EventConnection from a connection string, through whichever\n\t * driver is registered for its scheme — see `registerEventsDriver`.\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionStr: string,\n\t): Promise<EventConnection> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'connection').connect(connectionStr);\n\t}\n}\n\nexport type { EventConnection } from './types';\nexport { EventPublisherType } from './types';\n","import { eventsDriverFor } from './registry';\nimport type {\n\tEventConnection,\n\tEventPublisher,\n\tEventPublisherType,\n\tPublishableMessage,\n} from './types';\n\n/** How a publisher is used, beyond the address it reaches. */\nexport interface PublisherOptions {\n\t/**\n\t * The topic this publisher fans out to. SNS and RabbitMQ name the topic in\n\t * their address already; pg-boss has one address for every topic and queue,\n\t * so it is told here that a message goes to every subscriber rather than to\n\t * one queue.\n\t */\n\ttopic?: string;\n}\n\n/**\n * Publishers for a connection string or a connection, through whichever\n * driver is registered for its scheme — see `registerEventsDriver`.\n */\nexport class Publisher {\n\t/**\n\t * Create a publisher from a connection string\n\t * This creates both a connection and a publisher\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventPublisherConnectionString,\n\t\toptions: PublisherOptions = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'publisher').publisher<TMessage>(\n\t\t\tconnectionStr,\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * Create a publisher from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t\toptions: PublisherOptions = {},\n\t): Promise<EventPublisher<TMessage>> {\n\t\treturn eventsDriverFor(connection.type, 'publisher').publisherFor<TMessage>(\n\t\t\tconnection,\n\t\t\toptions,\n\t\t);\n\t}\n}\n\nexport type EventPublisherConnectionString =\n\t`${EventPublisherType}://${string}`;\n","import { eventsDriverFor, type SubscriberOptions } from './registry';\nimport type {\n\tEventConnection,\n\tEventPublisherType,\n\tEventSubscriber,\n\tPublishableMessage,\n} from './types';\n\n/**\n * Subscribers for a connection string or a connection, through whichever\n * driver is registered for its scheme — see `registerEventsDriver`.\n */\nexport class Subscriber {\n\t/**\n\t * Create a subscriber from a connection string\n\t * This creates both a connection and a subscriber\n\t *\n\t * @throws {UnregisteredEventsScheme} when the broker's driver is not\n\t * registered.\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionStr: EventSubscriberConnectionString,\n\t): Promise<EventSubscriber<TMessage>> {\n\t\tconst scheme = new URL(connectionStr).protocol;\n\t\treturn eventsDriverFor(scheme, 'subscriber').subscriber<TMessage>(\n\t\t\tconnectionStr,\n\t\t);\n\t}\n\n\t/**\n\t * Create a subscriber from an existing connection\n\t * This allows sharing connections between publishers and subscribers\n\t */\n\tstatic async fromConnection<TMessage extends PublishableMessage<string, any>>(\n\t\tconnection: EventConnection,\n\t\t/**\n\t\t * Subscribing to a topic as a named subscriber. pg-boss needs both to\n\t\t * give each subscriber its own queue; the other transports carry the\n\t\t * topic in their address and ignore it.\n\t\t */\n\t\toptions: SubscriberOptions = {},\n\t): Promise<EventSubscriber<TMessage>> {\n\t\treturn eventsDriverFor(\n\t\t\tconnection.type,\n\t\t\t'subscriber',\n\t\t).subscriberFor<TMessage>(connection, options);\n\t}\n}\n\nexport type EventSubscriberConnectionString =\n\t`${EventPublisherType}://${string}`;\n"],"mappings":";;;AAGA,IAAa,yBAAb,MAAoC;;;;;;;;CAQnC,aAAa,qBACZ,eAC2B;EAC3B,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAO,gBAAgB,QAAQ,YAAY,CAAC,CAAC,QAAQ,aAAa;CACnE;AACD;;;;;;;ACMA,IAAa,YAAb,MAAuB;;;;;;;;CAQtB,aAAa,qBAGZ,eACA,UAA4B,CAAC,GACO;EACpC,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAO,gBAAgB,QAAQ,WAAW,CAAC,CAAC,UAC3C,eACA,OACD;CACD;;;;;CAMA,aAAa,eACZ,YACA,UAA4B,CAAC,GACO;EACpC,OAAO,gBAAgB,WAAW,MAAM,WAAW,CAAC,CAAC,aACpD,YACA,OACD;CACD;AACD;;;;;;;AC7CA,IAAa,aAAb,MAAwB;;;;;;;;CAQvB,aAAa,qBAGZ,eACqC;EACrC,MAAM,SAAS,IAAI,IAAI,aAAa,CAAC,CAAC;EACtC,OAAO,gBAAgB,QAAQ,YAAY,CAAC,CAAC,WAC5C,aACD;CACD;;;;;CAMA,aAAa,eACZ,YAMA,UAA6B,CAAC,GACO;EACrC,OAAO,gBACN,WAAW,MACX,YACD,CAAC,CAAC,cAAwB,YAAY,OAAO;CAC9C;AACD"}
|