@geekmidas/events 10.0.0-alpha.2 → 10.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PgBossConnection-CywKoAZU.cjs +2 -0
- package/dist/PgBossConnection-DjoqT84r.mjs +2 -0
- package/dist/RabbitMQConnection-C9eccBL8.cjs +2 -0
- package/dist/RabbitMQConnection-CAp7VqyT.mjs +2 -0
- package/dist/SNSConnection-BWDC1wAF.cjs +2 -0
- package/dist/SNSConnection-ezQvVrDv.mjs +2 -0
- package/dist/{SQSSubscriber-BMWZ3s5q.mjs → SQSSubscriber-BXLE_1L3.mjs} +73 -7
- package/dist/SQSSubscriber-BXLE_1L3.mjs.map +1 -0
- package/dist/{SQSSubscriber-YXPlg2rm.cjs → SQSSubscriber-DtRUaZB3.cjs} +91 -14
- package/dist/SQSSubscriber-DtRUaZB3.cjs.map +1 -0
- package/dist/basic/index.cjs +7 -8
- package/dist/basic/index.cjs.map +1 -1
- package/dist/basic/index.d.cts +4 -10
- package/dist/basic/index.d.cts.map +1 -1
- package/dist/basic/index.d.mts +4 -10
- package/dist/basic/index.d.mts.map +1 -1
- package/dist/basic/index.mjs +5 -6
- package/dist/basic/index.mjs.map +1 -1
- package/dist/index.cjs +39 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +38 -47
- package/dist/index.mjs.map +1 -1
- package/dist/pgboss/index.cjs +98 -21
- package/dist/pgboss/index.cjs.map +1 -1
- package/dist/pgboss/index.d.cts +11 -10
- package/dist/pgboss/index.d.cts.map +1 -1
- package/dist/pgboss/index.d.mts +11 -10
- package/dist/pgboss/index.d.mts.map +1 -1
- package/dist/pgboss/index.mjs +95 -21
- package/dist/pgboss/index.mjs.map +1 -1
- package/dist/rabbitmq/index.cjs +135 -22
- package/dist/rabbitmq/index.cjs.map +1 -1
- package/dist/rabbitmq/index.d.cts +11 -10
- package/dist/rabbitmq/index.d.cts.map +1 -1
- package/dist/rabbitmq/index.d.mts +11 -10
- package/dist/rabbitmq/index.d.mts.map +1 -1
- package/dist/rabbitmq/index.mjs +130 -22
- package/dist/rabbitmq/index.mjs.map +1 -1
- package/dist/{chunk-CsX-DzYB.cjs → rolldown-runtime-C0BPl7ul.cjs} +17 -16
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/sns/index.cjs +106 -34
- package/dist/sns/index.cjs.map +1 -1
- package/dist/sns/index.d.cts +14 -11
- package/dist/sns/index.d.cts.map +1 -1
- package/dist/sns/index.d.mts +14 -11
- package/dist/sns/index.d.mts.map +1 -1
- package/dist/sns/index.mjs +88 -18
- package/dist/sns/index.mjs.map +1 -1
- package/dist/sns/snsUrl.cjs +91 -6
- package/dist/sns/snsUrl.cjs.map +1 -0
- package/dist/sns/snsUrl.d.cts +57 -2
- package/dist/sns/snsUrl.d.cts.map +1 -0
- package/dist/sns/snsUrl.d.mts +57 -2
- package/dist/sns/snsUrl.d.mts.map +1 -0
- package/dist/sns/snsUrl.mjs +81 -2
- package/dist/sns/snsUrl.mjs.map +1 -0
- package/dist/sqs/index.cjs +34 -24
- package/dist/sqs/index.cjs.map +1 -1
- package/dist/sqs/index.d.cts +19 -11
- package/dist/sqs/index.d.cts.map +1 -1
- package/dist/sqs/index.d.mts +19 -11
- package/dist/sqs/index.d.mts.map +1 -1
- package/dist/sqs/index.mjs +22 -15
- package/dist/sqs/index.mjs.map +1 -1
- package/dist/sqs/sqsUrl.cjs +92 -6
- package/dist/sqs/sqsUrl.cjs.map +1 -0
- package/dist/sqs/sqsUrl.d.cts +56 -2
- package/dist/sqs/sqsUrl.d.cts.map +1 -0
- package/dist/sqs/sqsUrl.d.mts +56 -2
- package/dist/sqs/sqsUrl.d.mts.map +1 -0
- package/dist/sqs/sqsUrl.mjs +82 -2
- package/dist/sqs/sqsUrl.mjs.map +1 -0
- package/dist/types-BcZjLxVV.cjs +51 -0
- package/dist/types-BcZjLxVV.cjs.map +1 -0
- package/dist/types-Bk5JM6MP.mjs +40 -0
- package/dist/types-Bk5JM6MP.mjs.map +1 -0
- package/dist/types-gGaoT8qc.d.cts +149 -0
- package/dist/types-gGaoT8qc.d.cts.map +1 -0
- package/dist/types-gGaoT8qc.d.mts +149 -0
- package/dist/types-gGaoT8qc.d.mts.map +1 -0
- package/package.json +12 -12
- package/dist/PgBossConnection-23soZ_aM.cjs +0 -80
- package/dist/PgBossConnection-23soZ_aM.cjs.map +0 -1
- package/dist/PgBossConnection-CCXhoNzb.cjs +0 -4
- package/dist/PgBossConnection-DvNbd4Zk.mjs +0 -74
- package/dist/PgBossConnection-DvNbd4Zk.mjs.map +0 -1
- package/dist/PgBossConnection-_gdM40JB.mjs +0 -4
- package/dist/RabbitMQConnection-BKEdCUro.cjs +0 -113
- package/dist/RabbitMQConnection-BKEdCUro.cjs.map +0 -1
- package/dist/RabbitMQConnection-CCOqDDnb.cjs +0 -4
- package/dist/RabbitMQConnection-DJEyM-Bu.mjs +0 -4
- package/dist/RabbitMQConnection-DJgUPc19.mjs +0 -107
- package/dist/RabbitMQConnection-DJgUPc19.mjs.map +0 -1
- package/dist/SNSConnection-B2K86hpz.cjs +0 -75
- package/dist/SNSConnection-B2K86hpz.cjs.map +0 -1
- package/dist/SNSConnection-BVo84FeW.mjs +0 -5
- package/dist/SNSConnection-DIHRjrQF.cjs +0 -5
- package/dist/SNSConnection-v9jjF99w.mjs +0 -69
- package/dist/SNSConnection-v9jjF99w.mjs.map +0 -1
- package/dist/SQSConnection-4tBMkVZE.mjs +0 -69
- package/dist/SQSConnection-4tBMkVZE.mjs.map +0 -1
- package/dist/SQSConnection-BBLAvF-1.cjs +0 -5
- package/dist/SQSConnection-BaC7rGhI.cjs +0 -75
- package/dist/SQSConnection-BaC7rGhI.cjs.map +0 -1
- package/dist/SQSConnection-DbavOq8_.mjs +0 -5
- package/dist/SQSSubscriber-BMWZ3s5q.mjs.map +0 -1
- package/dist/SQSSubscriber-YXPlg2rm.cjs.map +0 -1
- package/dist/chunk-B9dir_RE.mjs +0 -11
- package/dist/snsUrl-ASdc0D1v.d.cts +0 -61
- package/dist/snsUrl-ASdc0D1v.d.cts.map +0 -1
- package/dist/snsUrl-CifYhPAa.mjs +0 -79
- package/dist/snsUrl-CifYhPAa.mjs.map +0 -1
- package/dist/snsUrl-FRbRcwF0.d.mts +0 -61
- package/dist/snsUrl-FRbRcwF0.d.mts.map +0 -1
- package/dist/snsUrl-f2gU3CzK.cjs +0 -114
- package/dist/snsUrl-f2gU3CzK.cjs.map +0 -1
- package/dist/sqsUrl-BV6zS-mi.d.mts +0 -60
- package/dist/sqsUrl-BV6zS-mi.d.mts.map +0 -1
- package/dist/sqsUrl-CbAsBFHI.mjs +0 -80
- package/dist/sqsUrl-CbAsBFHI.mjs.map +0 -1
- package/dist/sqsUrl-CdisN3GU.cjs +0 -115
- package/dist/sqsUrl-CdisN3GU.cjs.map +0 -1
- package/dist/sqsUrl-DZDPHxIk.d.cts +0 -60
- package/dist/sqsUrl-DZDPHxIk.d.cts.map +0 -1
- package/dist/types-BmixGrOD.d.cts +0 -67
- package/dist/types-BmixGrOD.d.cts.map +0 -1
- package/dist/types-Byv8N9ma.cjs +0 -24
- package/dist/types-Byv8N9ma.cjs.map +0 -1
- package/dist/types-CYDt-2RQ.mjs +0 -18
- package/dist/types-CYDt-2RQ.mjs.map +0 -1
- package/dist/types-DycjsYms.d.mts +0 -67
- package/dist/types-DycjsYms.d.mts.map +0 -1
|
@@ -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"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { InferStandardSchema } from "@geekmidas/schema";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
3
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
4
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
5
|
+
/** The Standard properties. */
|
|
6
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
7
|
+
}
|
|
8
|
+
declare namespace StandardTypedV1 {
|
|
9
|
+
/** The Standard Typed properties interface. */
|
|
10
|
+
interface Props<Input = unknown, Output = Input> {
|
|
11
|
+
/** The version number of the standard. */
|
|
12
|
+
readonly version: 1;
|
|
13
|
+
/** The vendor name of the schema library. */
|
|
14
|
+
readonly vendor: string;
|
|
15
|
+
/** Inferred types associated with the schema. */
|
|
16
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** The Standard Typed types interface. */
|
|
19
|
+
interface Types<Input = unknown, Output = Input> {
|
|
20
|
+
/** The input type of the schema. */
|
|
21
|
+
readonly input: Input;
|
|
22
|
+
/** The output type of the schema. */
|
|
23
|
+
readonly output: Output;
|
|
24
|
+
}
|
|
25
|
+
/** Infers the input type of a Standard Typed. */
|
|
26
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
27
|
+
/** Infers the output type of a Standard Typed. */
|
|
28
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
29
|
+
}
|
|
30
|
+
/** The Standard Schema interface. */
|
|
31
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
32
|
+
/** The Standard Schema properties. */
|
|
33
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
34
|
+
}
|
|
35
|
+
declare namespace StandardSchemaV1 {
|
|
36
|
+
/** The Standard Schema properties interface. */
|
|
37
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
38
|
+
/** Validates unknown input values. */
|
|
39
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
40
|
+
}
|
|
41
|
+
/** The result interface of the validate function. */
|
|
42
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
43
|
+
/** The result interface if validation succeeds. */
|
|
44
|
+
interface SuccessResult<Output> {
|
|
45
|
+
/** The typed output value. */
|
|
46
|
+
readonly value: Output;
|
|
47
|
+
/** A falsy value for `issues` indicates success. */
|
|
48
|
+
readonly issues?: undefined;
|
|
49
|
+
}
|
|
50
|
+
interface Options {
|
|
51
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
52
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
53
|
+
}
|
|
54
|
+
/** The result interface if validation fails. */
|
|
55
|
+
interface FailureResult {
|
|
56
|
+
/** The issues of failed validation. */
|
|
57
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
58
|
+
}
|
|
59
|
+
/** The issue interface of the failure output. */
|
|
60
|
+
interface Issue {
|
|
61
|
+
/** The error message of the issue. */
|
|
62
|
+
readonly message: string;
|
|
63
|
+
/** The path of the issue, if any. */
|
|
64
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
65
|
+
}
|
|
66
|
+
/** The path segment interface of the issue. */
|
|
67
|
+
interface PathSegment {
|
|
68
|
+
/** The key representing a path segment. */
|
|
69
|
+
readonly key: PropertyKey;
|
|
70
|
+
}
|
|
71
|
+
/** The Standard types interface. */
|
|
72
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
73
|
+
/** Infers the input type of a Standard. */
|
|
74
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
75
|
+
/** Infers the output type of a Standard. */
|
|
76
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/types.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* Represents a publishable event message with a type and payload.
|
|
82
|
+
*
|
|
83
|
+
* @template TType - The event type/name (e.g., 'user.created')
|
|
84
|
+
* @template TPayload - The event payload data
|
|
85
|
+
*/
|
|
86
|
+
type PublishableMessage<TType extends string, TPayload> = {
|
|
87
|
+
type: TType;
|
|
88
|
+
payload: TPayload;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Event publisher/subscriber types
|
|
92
|
+
*/
|
|
93
|
+
declare enum EventPublisherType {
|
|
94
|
+
Basic = "basic",
|
|
95
|
+
EventBridge = "eventbridge",
|
|
96
|
+
SQS = "sqs",
|
|
97
|
+
SNS = "sns",
|
|
98
|
+
Kafka = "kafka",
|
|
99
|
+
RabbitMQ = "rabbitmq",
|
|
100
|
+
PgBoss = "pgboss"
|
|
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
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Base interface for event connections
|
|
113
|
+
* Connections manage the underlying transport (RabbitMQ channel, SQS client, etc.)
|
|
114
|
+
*/
|
|
115
|
+
interface EventConnection {
|
|
116
|
+
readonly type: EventPublisherType;
|
|
117
|
+
connect(): Promise<void>;
|
|
118
|
+
close(): Promise<void>;
|
|
119
|
+
isConnected(): boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Interface for event publishers that handle the actual publishing of events.
|
|
123
|
+
* Implementations can send to EventBridge, SQS, Kafka, or any other event system.
|
|
124
|
+
*
|
|
125
|
+
* @template TMessage - The union type of all publishable messages
|
|
126
|
+
*/
|
|
127
|
+
type EventPublisher<TMessage extends PublishableMessage<string, any>> = {
|
|
128
|
+
publish: (message: TMessage[]) => Promise<void>;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Interface for event subscribers that handle receiving and processing events.
|
|
132
|
+
*
|
|
133
|
+
* @template TMessage - The union type of all publishable messages
|
|
134
|
+
*/
|
|
135
|
+
type EventSubscriber<TMessage extends PublishableMessage<string, any>> = {
|
|
136
|
+
subscribe: (messages: TMessage['type'][], listener: (payload: TMessage) => Promise<void>) => Promise<void>;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Utility type to extract the message from EventPublisher
|
|
140
|
+
*/
|
|
141
|
+
type ExtractPublisherMessage<T> = T extends EventPublisher<infer M> ? M : never;
|
|
142
|
+
type MappedEvent<T extends EventPublisher<any> | undefined, OutSchema extends StandardSchemaV1 | undefined = undefined> = {
|
|
143
|
+
type: ExtractPublisherMessage<T>['type'];
|
|
144
|
+
payload: (ctx: InferStandardSchema<OutSchema>) => ExtractPublisherMessage<T>['payload'];
|
|
145
|
+
when?: (ctx: InferStandardSchema<OutSchema>) => boolean;
|
|
146
|
+
};
|
|
147
|
+
//#endregion
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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","../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;;;;;;cAgBY,kCAAkC;WAEpC;WACA;EAFV,YACU,mBACA;;;;;;UAaM;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"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { InferStandardSchema } from "@geekmidas/schema";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
3
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
4
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
5
|
+
/** The Standard properties. */
|
|
6
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
7
|
+
}
|
|
8
|
+
declare namespace StandardTypedV1 {
|
|
9
|
+
/** The Standard Typed properties interface. */
|
|
10
|
+
interface Props<Input = unknown, Output = Input> {
|
|
11
|
+
/** The version number of the standard. */
|
|
12
|
+
readonly version: 1;
|
|
13
|
+
/** The vendor name of the schema library. */
|
|
14
|
+
readonly vendor: string;
|
|
15
|
+
/** Inferred types associated with the schema. */
|
|
16
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** The Standard Typed types interface. */
|
|
19
|
+
interface Types<Input = unknown, Output = Input> {
|
|
20
|
+
/** The input type of the schema. */
|
|
21
|
+
readonly input: Input;
|
|
22
|
+
/** The output type of the schema. */
|
|
23
|
+
readonly output: Output;
|
|
24
|
+
}
|
|
25
|
+
/** Infers the input type of a Standard Typed. */
|
|
26
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
27
|
+
/** Infers the output type of a Standard Typed. */
|
|
28
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
29
|
+
}
|
|
30
|
+
/** The Standard Schema interface. */
|
|
31
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
32
|
+
/** The Standard Schema properties. */
|
|
33
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
34
|
+
}
|
|
35
|
+
declare namespace StandardSchemaV1 {
|
|
36
|
+
/** The Standard Schema properties interface. */
|
|
37
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
38
|
+
/** Validates unknown input values. */
|
|
39
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
40
|
+
}
|
|
41
|
+
/** The result interface of the validate function. */
|
|
42
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
43
|
+
/** The result interface if validation succeeds. */
|
|
44
|
+
interface SuccessResult<Output> {
|
|
45
|
+
/** The typed output value. */
|
|
46
|
+
readonly value: Output;
|
|
47
|
+
/** A falsy value for `issues` indicates success. */
|
|
48
|
+
readonly issues?: undefined;
|
|
49
|
+
}
|
|
50
|
+
interface Options {
|
|
51
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
52
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
53
|
+
}
|
|
54
|
+
/** The result interface if validation fails. */
|
|
55
|
+
interface FailureResult {
|
|
56
|
+
/** The issues of failed validation. */
|
|
57
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
58
|
+
}
|
|
59
|
+
/** The issue interface of the failure output. */
|
|
60
|
+
interface Issue {
|
|
61
|
+
/** The error message of the issue. */
|
|
62
|
+
readonly message: string;
|
|
63
|
+
/** The path of the issue, if any. */
|
|
64
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
65
|
+
}
|
|
66
|
+
/** The path segment interface of the issue. */
|
|
67
|
+
interface PathSegment {
|
|
68
|
+
/** The key representing a path segment. */
|
|
69
|
+
readonly key: PropertyKey;
|
|
70
|
+
}
|
|
71
|
+
/** The Standard types interface. */
|
|
72
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
73
|
+
/** Infers the input type of a Standard. */
|
|
74
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
75
|
+
/** Infers the output type of a Standard. */
|
|
76
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/types.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* Represents a publishable event message with a type and payload.
|
|
82
|
+
*
|
|
83
|
+
* @template TType - The event type/name (e.g., 'user.created')
|
|
84
|
+
* @template TPayload - The event payload data
|
|
85
|
+
*/
|
|
86
|
+
type PublishableMessage<TType extends string, TPayload> = {
|
|
87
|
+
type: TType;
|
|
88
|
+
payload: TPayload;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Event publisher/subscriber types
|
|
92
|
+
*/
|
|
93
|
+
declare enum EventPublisherType {
|
|
94
|
+
Basic = "basic",
|
|
95
|
+
EventBridge = "eventbridge",
|
|
96
|
+
SQS = "sqs",
|
|
97
|
+
SNS = "sns",
|
|
98
|
+
Kafka = "kafka",
|
|
99
|
+
RabbitMQ = "rabbitmq",
|
|
100
|
+
PgBoss = "pgboss"
|
|
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
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Base interface for event connections
|
|
113
|
+
* Connections manage the underlying transport (RabbitMQ channel, SQS client, etc.)
|
|
114
|
+
*/
|
|
115
|
+
interface EventConnection {
|
|
116
|
+
readonly type: EventPublisherType;
|
|
117
|
+
connect(): Promise<void>;
|
|
118
|
+
close(): Promise<void>;
|
|
119
|
+
isConnected(): boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Interface for event publishers that handle the actual publishing of events.
|
|
123
|
+
* Implementations can send to EventBridge, SQS, Kafka, or any other event system.
|
|
124
|
+
*
|
|
125
|
+
* @template TMessage - The union type of all publishable messages
|
|
126
|
+
*/
|
|
127
|
+
type EventPublisher<TMessage extends PublishableMessage<string, any>> = {
|
|
128
|
+
publish: (message: TMessage[]) => Promise<void>;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Interface for event subscribers that handle receiving and processing events.
|
|
132
|
+
*
|
|
133
|
+
* @template TMessage - The union type of all publishable messages
|
|
134
|
+
*/
|
|
135
|
+
type EventSubscriber<TMessage extends PublishableMessage<string, any>> = {
|
|
136
|
+
subscribe: (messages: TMessage['type'][], listener: (payload: TMessage) => Promise<void>) => Promise<void>;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Utility type to extract the message from EventPublisher
|
|
140
|
+
*/
|
|
141
|
+
type ExtractPublisherMessage<T> = T extends EventPublisher<infer M> ? M : never;
|
|
142
|
+
type MappedEvent<T extends EventPublisher<any> | undefined, OutSchema extends StandardSchemaV1 | undefined = undefined> = {
|
|
143
|
+
type: ExtractPublisherMessage<T>['type'];
|
|
144
|
+
payload: (ctx: InferStandardSchema<OutSchema>) => ExtractPublisherMessage<T>['payload'];
|
|
145
|
+
when?: (ctx: InferStandardSchema<OutSchema>) => boolean;
|
|
146
|
+
};
|
|
147
|
+
//#endregion
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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_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;;;;;;cAgBY,kCAAkC;WAEpC;WACA;EAFV,YACU,mBACA;;;;;;UAaM;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/events",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
3
|
+
"version": "10.0.0-alpha.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -99,11 +99,11 @@
|
|
|
99
99
|
"lodash.chunk": "~4.2.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
|
-
"amqplib": "
|
|
103
|
-
"@aws-sdk/client-sqs": "
|
|
104
|
-
"@aws-sdk/client-sns": "
|
|
105
|
-
"pg-boss": ">=12.
|
|
106
|
-
"@geekmidas/schema": "^10.0.0-alpha.
|
|
102
|
+
"amqplib": ">=2.0.1",
|
|
103
|
+
"@aws-sdk/client-sqs": ">=3.1136.0",
|
|
104
|
+
"@aws-sdk/client-sns": ">=3.1136.0",
|
|
105
|
+
"pg-boss": ">=12.33.3",
|
|
106
|
+
"@geekmidas/schema": "^10.0.0-alpha.21"
|
|
107
107
|
},
|
|
108
108
|
"peerDependenciesMeta": {
|
|
109
109
|
"@geekmidas/schema": {
|
|
@@ -123,11 +123,11 @@
|
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
|
-
"@types/amqplib": "~0.10.
|
|
127
|
-
"@types/lodash.chunk": "~4.2.
|
|
128
|
-
"@types/pg": "~8.
|
|
129
|
-
"pg": "~8.
|
|
130
|
-
"pg-boss": "~12.
|
|
131
|
-
"@geekmidas/schema": "^10.0.0-alpha.
|
|
126
|
+
"@types/amqplib": "~0.10.8",
|
|
127
|
+
"@types/lodash.chunk": "~4.2.9",
|
|
128
|
+
"@types/pg": "~8.23.1",
|
|
129
|
+
"pg": "~8.23.0",
|
|
130
|
+
"pg-boss": "~12.33.3",
|
|
131
|
+
"@geekmidas/schema": "^10.0.0-alpha.21"
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CsX-DzYB.cjs');
|
|
2
|
-
const require_types = require('./types-Byv8N9ma.cjs');
|
|
3
|
-
const pg_boss = require_chunk.__toESM(require("pg-boss"));
|
|
4
|
-
|
|
5
|
-
//#region src/pgboss/PgBossConnection.ts
|
|
6
|
-
var PgBossConnection = class PgBossConnection {
|
|
7
|
-
type = require_types.EventPublisherType.PgBoss;
|
|
8
|
-
boss;
|
|
9
|
-
connecting;
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.config = config;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Create a PgBossConnection from a connection string.
|
|
15
|
-
* Format: pgboss://user:pass@host:5432/database?schema=pgboss
|
|
16
|
-
*/
|
|
17
|
-
static async fromConnectionString(connectionString) {
|
|
18
|
-
const url = new URL(connectionString);
|
|
19
|
-
const params = url.searchParams;
|
|
20
|
-
const postgresUrl = `postgres://${url.username ? `${url.username}:${url.password}@` : ""}${url.host}${url.pathname}`;
|
|
21
|
-
const config = {
|
|
22
|
-
connectionString: postgresUrl,
|
|
23
|
-
schema: params.get("schema") || void 0
|
|
24
|
-
};
|
|
25
|
-
const connection = new PgBossConnection(config);
|
|
26
|
-
await connection.connect();
|
|
27
|
-
return connection;
|
|
28
|
-
}
|
|
29
|
-
async connect() {
|
|
30
|
-
if (this.boss) return;
|
|
31
|
-
if (this.connecting) {
|
|
32
|
-
await this.connecting;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.connecting = (async () => {
|
|
36
|
-
try {
|
|
37
|
-
const boss = new pg_boss.PgBoss({
|
|
38
|
-
connectionString: this.config.connectionString,
|
|
39
|
-
...this.config.schema && { schema: this.config.schema }
|
|
40
|
-
});
|
|
41
|
-
await boss.start();
|
|
42
|
-
this.boss = boss;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
this.cleanup();
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
})();
|
|
48
|
-
await this.connecting;
|
|
49
|
-
this.connecting = void 0;
|
|
50
|
-
}
|
|
51
|
-
async close() {
|
|
52
|
-
try {
|
|
53
|
-
await this.boss?.stop({ graceful: true });
|
|
54
|
-
} catch {} finally {
|
|
55
|
-
this.cleanup();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
isConnected() {
|
|
59
|
-
return !!this.boss;
|
|
60
|
-
}
|
|
61
|
-
cleanup() {
|
|
62
|
-
this.boss = void 0;
|
|
63
|
-
this.connecting = void 0;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get the underlying pg-boss instance for publishing/subscribing
|
|
67
|
-
*/
|
|
68
|
-
get instance() {
|
|
69
|
-
return this.boss;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
//#endregion
|
|
74
|
-
Object.defineProperty(exports, 'PgBossConnection', {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function () {
|
|
77
|
-
return PgBossConnection;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
//# sourceMappingURL=PgBossConnection-23soZ_aM.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PgBossConnection-23soZ_aM.cjs","names":["EventPublisherType","config: PgBossConnectionConfig","connectionString: string","PgBoss"],"sources":["../src/pgboss/PgBossConnection.ts"],"sourcesContent":["import { PgBoss } from 'pg-boss';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface PgBossConnectionConfig {\n\tconnectionString: string;\n\tschema?: string;\n}\n\nexport class PgBossConnection implements EventConnection {\n\treadonly type = EventPublisherType.PgBoss;\n\tprivate boss?: PgBoss;\n\tprivate connecting?: Promise<void>;\n\n\tconstructor(private config: PgBossConnectionConfig) {}\n\n\t/**\n\t * Create a PgBossConnection from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<PgBossConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst postgresUrl = `postgres://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst config: PgBossConnectionConfig = {\n\t\t\tconnectionString: postgresUrl,\n\t\t\tschema: params.get('schema') || undefined,\n\t\t};\n\n\t\tconst connection = new PgBossConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.boss) return;\n\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst boss = new PgBoss({\n\t\t\t\t\tconnectionString: this.config.connectionString,\n\t\t\t\t\t...(this.config.schema && { schema: this.config.schema }),\n\t\t\t\t});\n\n\t\t\t\tawait boss.start();\n\t\t\t\tthis.boss = boss;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.boss?.stop({ graceful: true });\n\t\t} catch {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.boss;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.boss = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying pg-boss instance for publishing/subscribing\n\t */\n\tget instance(): PgBoss | undefined {\n\t\treturn this.boss;\n\t}\n}\n"],"mappings":";;;;;AASA,IAAa,mBAAb,MAAa,iBAA4C;CACxD,AAAS,OAAOA,iCAAmB;CACnC,AAAQ;CACR,AAAQ;CAER,YAAoBC,QAAgC;EAAhC;CAAkC;;;;;CAMtD,aAAa,qBACZC,kBAC4B;EAC5B,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,eAAe,aAAa,IAAI,YAAY,EAAE,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,GAAG,EAAE,IAAI,KAAK,EAAE,IAAI,SAAS;EAEnH,MAAMD,SAAiC;GACtC,kBAAkB;GAClB,QAAQ,OAAO,IAAI,SAAS;EAC5B;EAED,MAAM,aAAa,IAAI,iBAAiB;AACxC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAC9B,MAAI,KAAK,KAAM;AAEf,MAAI,KAAK,YAAY;AACpB,SAAM,KAAK;AACX;EACA;AAED,OAAK,aAAa,CAAC,YAAY;AAC9B,OAAI;IACH,MAAM,OAAO,IAAIE,eAAO;KACvB,kBAAkB,KAAK,OAAO;KAC9B,GAAI,KAAK,OAAO,UAAU,EAAE,QAAQ,KAAK,OAAO,OAAQ;IACxD;AAED,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;GACZ,SAAQ,OAAO;AACf,SAAK,SAAS;AACd,UAAM;GACN;EACD,IAAG;AAEJ,QAAM,KAAK;AACX,OAAK;CACL;CAED,MAAM,QAAuB;AAC5B,MAAI;AACH,SAAM,KAAK,MAAM,KAAK,EAAE,UAAU,KAAM,EAAC;EACzC,QAAO,CAEP,UAAS;AACT,QAAK,SAAS;EACd;CACD;CAED,cAAuB;AACtB,WAAS,KAAK;CACd;CAED,AAAQ,UAAgB;AACvB,OAAK;AACL,OAAK;CACL;;;;CAKD,IAAI,WAA+B;AAClC,SAAO,KAAK;CACZ;AACD"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { EventPublisherType } from "./types-CYDt-2RQ.mjs";
|
|
2
|
-
import { PgBoss } from "pg-boss";
|
|
3
|
-
|
|
4
|
-
//#region src/pgboss/PgBossConnection.ts
|
|
5
|
-
var PgBossConnection = class PgBossConnection {
|
|
6
|
-
type = EventPublisherType.PgBoss;
|
|
7
|
-
boss;
|
|
8
|
-
connecting;
|
|
9
|
-
constructor(config) {
|
|
10
|
-
this.config = config;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Create a PgBossConnection from a connection string.
|
|
14
|
-
* Format: pgboss://user:pass@host:5432/database?schema=pgboss
|
|
15
|
-
*/
|
|
16
|
-
static async fromConnectionString(connectionString) {
|
|
17
|
-
const url = new URL(connectionString);
|
|
18
|
-
const params = url.searchParams;
|
|
19
|
-
const postgresUrl = `postgres://${url.username ? `${url.username}:${url.password}@` : ""}${url.host}${url.pathname}`;
|
|
20
|
-
const config = {
|
|
21
|
-
connectionString: postgresUrl,
|
|
22
|
-
schema: params.get("schema") || void 0
|
|
23
|
-
};
|
|
24
|
-
const connection = new PgBossConnection(config);
|
|
25
|
-
await connection.connect();
|
|
26
|
-
return connection;
|
|
27
|
-
}
|
|
28
|
-
async connect() {
|
|
29
|
-
if (this.boss) return;
|
|
30
|
-
if (this.connecting) {
|
|
31
|
-
await this.connecting;
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
this.connecting = (async () => {
|
|
35
|
-
try {
|
|
36
|
-
const boss = new PgBoss({
|
|
37
|
-
connectionString: this.config.connectionString,
|
|
38
|
-
...this.config.schema && { schema: this.config.schema }
|
|
39
|
-
});
|
|
40
|
-
await boss.start();
|
|
41
|
-
this.boss = boss;
|
|
42
|
-
} catch (error) {
|
|
43
|
-
this.cleanup();
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
})();
|
|
47
|
-
await this.connecting;
|
|
48
|
-
this.connecting = void 0;
|
|
49
|
-
}
|
|
50
|
-
async close() {
|
|
51
|
-
try {
|
|
52
|
-
await this.boss?.stop({ graceful: true });
|
|
53
|
-
} catch {} finally {
|
|
54
|
-
this.cleanup();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
isConnected() {
|
|
58
|
-
return !!this.boss;
|
|
59
|
-
}
|
|
60
|
-
cleanup() {
|
|
61
|
-
this.boss = void 0;
|
|
62
|
-
this.connecting = void 0;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Get the underlying pg-boss instance for publishing/subscribing
|
|
66
|
-
*/
|
|
67
|
-
get instance() {
|
|
68
|
-
return this.boss;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
export { PgBossConnection };
|
|
74
|
-
//# sourceMappingURL=PgBossConnection-DvNbd4Zk.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PgBossConnection-DvNbd4Zk.mjs","names":["config: PgBossConnectionConfig","connectionString: string"],"sources":["../src/pgboss/PgBossConnection.ts"],"sourcesContent":["import { PgBoss } from 'pg-boss';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface PgBossConnectionConfig {\n\tconnectionString: string;\n\tschema?: string;\n}\n\nexport class PgBossConnection implements EventConnection {\n\treadonly type = EventPublisherType.PgBoss;\n\tprivate boss?: PgBoss;\n\tprivate connecting?: Promise<void>;\n\n\tconstructor(private config: PgBossConnectionConfig) {}\n\n\t/**\n\t * Create a PgBossConnection from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<PgBossConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst postgresUrl = `postgres://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst config: PgBossConnectionConfig = {\n\t\t\tconnectionString: postgresUrl,\n\t\t\tschema: params.get('schema') || undefined,\n\t\t};\n\n\t\tconst connection = new PgBossConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.boss) return;\n\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst boss = new PgBoss({\n\t\t\t\t\tconnectionString: this.config.connectionString,\n\t\t\t\t\t...(this.config.schema && { schema: this.config.schema }),\n\t\t\t\t});\n\n\t\t\t\tawait boss.start();\n\t\t\t\tthis.boss = boss;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.boss?.stop({ graceful: true });\n\t\t} catch {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.boss;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.boss = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying pg-boss instance for publishing/subscribing\n\t */\n\tget instance(): PgBoss | undefined {\n\t\treturn this.boss;\n\t}\n}\n"],"mappings":";;;;AASA,IAAa,mBAAb,MAAa,iBAA4C;CACxD,AAAS,OAAO,mBAAmB;CACnC,AAAQ;CACR,AAAQ;CAER,YAAoBA,QAAgC;EAAhC;CAAkC;;;;;CAMtD,aAAa,qBACZC,kBAC4B;EAC5B,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,eAAe,aAAa,IAAI,YAAY,EAAE,IAAI,SAAS,GAAG,IAAI,SAAS,KAAK,GAAG,EAAE,IAAI,KAAK,EAAE,IAAI,SAAS;EAEnH,MAAMD,SAAiC;GACtC,kBAAkB;GAClB,QAAQ,OAAO,IAAI,SAAS;EAC5B;EAED,MAAM,aAAa,IAAI,iBAAiB;AACxC,QAAM,WAAW,SAAS;AAC1B,SAAO;CACP;CAED,MAAM,UAAyB;AAC9B,MAAI,KAAK,KAAM;AAEf,MAAI,KAAK,YAAY;AACpB,SAAM,KAAK;AACX;EACA;AAED,OAAK,aAAa,CAAC,YAAY;AAC9B,OAAI;IACH,MAAM,OAAO,IAAI,OAAO;KACvB,kBAAkB,KAAK,OAAO;KAC9B,GAAI,KAAK,OAAO,UAAU,EAAE,QAAQ,KAAK,OAAO,OAAQ;IACxD;AAED,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;GACZ,SAAQ,OAAO;AACf,SAAK,SAAS;AACd,UAAM;GACN;EACD,IAAG;AAEJ,QAAM,KAAK;AACX,OAAK;CACL;CAED,MAAM,QAAuB;AAC5B,MAAI;AACH,SAAM,KAAK,MAAM,KAAK,EAAE,UAAU,KAAM,EAAC;EACzC,QAAO,CAEP,UAAS;AACT,QAAK,SAAS;EACd;CACD;CAED,cAAuB;AACtB,WAAS,KAAK;CACd;CAED,AAAQ,UAAgB;AACvB,OAAK;AACL,OAAK;CACL;;;;CAKD,IAAI,WAA+B;AAClC,SAAO,KAAK;CACZ;AACD"}
|