@geekmidas/constructs 10.0.0-alpha.37 → 10.0.0-alpha.39
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 +156 -155
- package/dist/{Construct-Detz65RA.mjs → Construct-BO1X-kt9.mjs} +3 -6
- package/dist/Construct-BO1X-kt9.mjs.map +1 -0
- package/dist/Construct-BQALFCh2.d.cts +230 -0
- package/dist/Construct-BQALFCh2.d.cts.map +1 -0
- package/dist/{Construct-yG9Sw-5p.cjs → Construct-DmvXceVY.cjs} +3 -6
- package/dist/Construct-DmvXceVY.cjs.map +1 -0
- package/dist/Construct-QXnl3VqT.d.mts +230 -0
- package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
- package/dist/{Cron-CA2oa2nC.d.cts → Cron-CMEGfRs8.d.cts} +7 -5
- package/dist/Cron-CMEGfRs8.d.cts.map +1 -0
- package/dist/{Cron-B_iuyNxr.d.mts → Cron-D6X4-xjB.d.mts} +7 -5
- package/dist/Cron-D6X4-xjB.d.mts.map +1 -0
- package/dist/{CronBuilder-B_KqaodP.d.cts → CronBuilder-CEK7aOqD.d.cts} +21 -16
- package/dist/CronBuilder-CEK7aOqD.d.cts.map +1 -0
- package/dist/{CronBuilder-BbnT7tqo.cjs → CronBuilder-DB35T5dL.cjs} +13 -11
- package/dist/CronBuilder-DB35T5dL.cjs.map +1 -0
- package/dist/{CronBuilder-BRkzUOAs.mjs → CronBuilder-Dv0IlZs0.mjs} +14 -12
- package/dist/CronBuilder-Dv0IlZs0.mjs.map +1 -0
- package/dist/{CronBuilder-BIKCLWu7.d.mts → CronBuilder-O_gvButp.d.mts} +21 -16
- package/dist/CronBuilder-O_gvButp.d.mts.map +1 -0
- package/dist/{Endpoint-DO332Dnm.mjs → Endpoint-CQAeh1Rh.mjs} +5 -5
- package/dist/Endpoint-CQAeh1Rh.mjs.map +1 -0
- package/dist/{Endpoint-QKuFg5gs.cjs → Endpoint-D1L9qu5C.cjs} +5 -5
- package/dist/Endpoint-D1L9qu5C.cjs.map +1 -0
- package/dist/{Endpoint-1-XYQSx0.d.cts → Endpoint-Dp5AKIXl.d.cts} +10 -13
- package/dist/Endpoint-Dp5AKIXl.d.cts.map +1 -0
- package/dist/{Endpoint-GFIxYb9L.d.mts → Endpoint-DtI7heFm.d.mts} +10 -13
- package/dist/Endpoint-DtI7heFm.d.mts.map +1 -0
- package/dist/{EndpointFactory-B9HAjDAP.mjs → EndpointFactory-BBdNeaGJ.mjs} +23 -52
- package/dist/EndpointFactory-BBdNeaGJ.mjs.map +1 -0
- package/dist/{EndpointFactory-BmO0WnXE.cjs → EndpointFactory-BZOCOaK6.cjs} +22 -51
- package/dist/EndpointFactory-BZOCOaK6.cjs.map +1 -0
- package/dist/{EndpointFactory-BCZdh_u3.d.mts → EndpointFactory-CgMDvERK.d.mts} +58 -48
- package/dist/EndpointFactory-CgMDvERK.d.mts.map +1 -0
- package/dist/{EndpointFactory-BnK_YkW1.d.cts → EndpointFactory-FeFRmlDZ.d.cts} +58 -48
- package/dist/EndpointFactory-FeFRmlDZ.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-CiqAZ5Mt.mjs → HonoEndpointAdaptor-Aui-x9Lg.mjs} +4 -3
- package/dist/HonoEndpointAdaptor-Aui-x9Lg.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-DoEQdC3r.cjs → HonoEndpointAdaptor-Cq99r9H7.cjs} +5 -4
- package/dist/HonoEndpointAdaptor-Cq99r9H7.cjs.map +1 -0
- package/dist/{Queue-DpKTLl6E.mjs → Queue-C1uDgjxt.mjs} +29 -48
- package/dist/Queue-C1uDgjxt.mjs.map +1 -0
- package/dist/{Queue-B7yRXQmL.cjs → Queue-Ckmudcm8.cjs} +29 -48
- package/dist/Queue-Ckmudcm8.cjs.map +1 -0
- package/dist/{Queue-Bhzi2WQC.d.cts → Queue-CpQIGB_2.d.cts} +22 -33
- package/dist/Queue-CpQIGB_2.d.cts.map +1 -0
- package/dist/{Queue-BoUA-e83.d.mts → Queue-YmvN2vEP.d.mts} +21 -32
- package/dist/Queue-YmvN2vEP.d.mts.map +1 -0
- package/dist/QueueBuilder-CJNcv4dy.cjs +112 -0
- package/dist/QueueBuilder-CJNcv4dy.cjs.map +1 -0
- package/dist/QueueBuilder-CM0WUxfw.d.mts +62 -0
- package/dist/QueueBuilder-CM0WUxfw.d.mts.map +1 -0
- package/dist/QueueBuilder-XEnnOWGe.d.cts +62 -0
- package/dist/QueueBuilder-XEnnOWGe.d.cts.map +1 -0
- package/dist/QueueBuilder-XuPKZwKH.mjs +95 -0
- package/dist/QueueBuilder-XuPKZwKH.mjs.map +1 -0
- package/dist/{Subscriber-DQCaiOXF.d.cts → Subscriber-B91YSkZt.d.cts} +12 -13
- package/dist/Subscriber-B91YSkZt.d.cts.map +1 -0
- package/dist/{Subscriber-CIO3pwji.d.mts → Subscriber-BjHYe5hK.d.mts} +11 -12
- package/dist/Subscriber-BjHYe5hK.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-CjDGSTZc.d.cts → SubscriberBuilder-BSpQX1JT.d.cts} +19 -23
- package/dist/SubscriberBuilder-BSpQX1JT.d.cts.map +1 -0
- package/dist/{SubscriberBuilder-C2FRfd26.d.mts → SubscriberBuilder-BhMphk4z.d.mts} +18 -22
- package/dist/SubscriberBuilder-BhMphk4z.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-C2bCOuPT.cjs → SubscriberBuilder-Duk028pD.cjs} +11 -19
- package/dist/SubscriberBuilder-Duk028pD.cjs.map +1 -0
- package/dist/{SubscriberBuilder-B4YRTBng.mjs → SubscriberBuilder-DzQUWE08.mjs} +11 -19
- package/dist/SubscriberBuilder-DzQUWE08.mjs.map +1 -0
- package/dist/{Topic-D5rlM9wS.cjs → Topic-BBVXC3H4.cjs} +46 -51
- package/dist/Topic-BBVXC3H4.cjs.map +1 -0
- package/dist/Topic-DOw051ch.mjs +98 -0
- package/dist/Topic-DOw051ch.mjs.map +1 -0
- package/dist/adaptors/aws.cjs +5 -5
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +26 -26
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +25 -25
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +5 -5
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +1 -1
- package/dist/adaptors/hono.d.cts +4 -5
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +4 -5
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +1 -1
- package/dist/adaptors/testing.cjs +59 -23
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +40 -28
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +40 -28
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +59 -23
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/{auth-c6nWnvD8.d.cts → auth-CMwml9QN.d.mts} +4 -4
- package/dist/{auth-c6nWnvD8.d.cts.map → auth-CMwml9QN.d.mts.map} +1 -1
- package/dist/{auth-pS_U1H_X.d.mts → auth-rVRDjIw_.d.cts} +4 -4
- package/dist/{auth-pS_U1H_X.d.mts.map → auth-rVRDjIw_.d.cts.map} +1 -1
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.mts +1 -1
- package/dist/{cache-B2s0b-ss.d.mts → cache-C9a_hVCc.d.cts} +3 -3
- package/dist/{cache-B2s0b-ss.d.mts.map → cache-C9a_hVCc.d.cts.map} +1 -1
- package/dist/{cache-CYe2Kzjc.d.cts → cache-CeTMI8LR.d.mts} +3 -3
- package/dist/{cache-CYe2Kzjc.d.cts.map → cache-CeTMI8LR.d.mts.map} +1 -1
- package/dist/cache.d.cts +1 -1
- package/dist/cache.d.mts +1 -1
- package/dist/{construct-interface-D2gesxos.d.mts → construct-interface-_3zgxzXl.d.mts} +11 -20
- package/dist/{construct-interface-D2gesxos.d.mts.map → construct-interface-_3zgxzXl.d.mts.map} +1 -1
- package/dist/{construct-interface-DPusCUSQ.d.cts → construct-interface-_xi4BPN8.d.cts} +11 -20
- package/dist/{construct-interface-DPusCUSQ.d.cts.map → construct-interface-_xi4BPN8.d.cts.map} +1 -1
- package/dist/construct-interface.cjs +4 -33
- package/dist/construct-interface.cjs.map +1 -1
- package/dist/construct-interface.d.cts +2 -2
- package/dist/construct-interface.d.mts +2 -2
- package/dist/construct-interface.mjs +5 -32
- package/dist/construct-interface.mjs.map +1 -1
- package/dist/credential.cjs +22 -9
- package/dist/credential.cjs.map +1 -1
- package/dist/credential.d.cts +12 -2
- package/dist/credential.d.cts.map +1 -1
- package/dist/credential.d.mts +12 -2
- package/dist/credential.d.mts.map +1 -1
- package/dist/credential.mjs +22 -10
- package/dist/credential.mjs.map +1 -1
- package/dist/crons/index.cjs +1 -1
- package/dist/crons/index.d.cts +2 -2
- package/dist/crons/index.d.mts +2 -2
- package/dist/crons/index.mjs +1 -1
- package/dist/database/kysely.d.cts +1 -1
- package/dist/database/kysely.d.mts +1 -1
- package/dist/email.d.cts +1 -1
- package/dist/email.d.mts +1 -1
- package/dist/endpoints/index.cjs +5 -4
- package/dist/endpoints/index.d.cts +4 -13
- package/dist/endpoints/index.d.cts.map +1 -1
- package/dist/endpoints/index.d.mts +4 -13
- package/dist/endpoints/index.d.mts.map +1 -1
- package/dist/endpoints/index.mjs +4 -3
- package/dist/external-api-DS3mujT5.d.mts +86 -0
- package/dist/external-api-DS3mujT5.d.mts.map +1 -0
- package/dist/external-api-LBfE-q3g.d.cts +86 -0
- package/dist/external-api-LBfE-q3g.d.cts.map +1 -0
- package/dist/external-api.cjs +124 -0
- package/dist/external-api.cjs.map +1 -0
- package/dist/external-api.d.cts +2 -0
- package/dist/external-api.d.mts +2 -0
- package/dist/external-api.mjs +121 -0
- package/dist/external-api.mjs.map +1 -0
- package/dist/file-server.d.cts +1 -1
- package/dist/file-server.d.mts +1 -1
- package/dist/functions/index.cjs +1 -1
- package/dist/functions/index.d.cts +1 -1
- package/dist/functions/index.d.mts +1 -1
- package/dist/functions/index.mjs +1 -1
- package/dist/{functions-DlFm8HmH.mjs → functions-DCIfCRR-.mjs} +94 -23
- package/dist/functions-DCIfCRR-.mjs.map +1 -0
- package/dist/{functions-DKN6aQWJ.cjs → functions-ZH60FE7H.cjs} +99 -19
- package/dist/functions-ZH60FE7H.cjs.map +1 -0
- package/dist/{index-BI23K3wy.d.cts → index-B0kxstwf.d.cts} +36 -24
- package/dist/index-B0kxstwf.d.cts.map +1 -0
- package/dist/{index-yb3fXNyH.d.mts → index-CjVEjOw0.d.mts} +36 -24
- package/dist/index-CjVEjOw0.d.mts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{kysely-CEVXacPN.d.cts → kysely-BJ8IQ_1P.d.mts} +4 -4
- package/dist/{kysely-CEVXacPN.d.cts.map → kysely-BJ8IQ_1P.d.mts.map} +1 -1
- package/dist/{kysely-mcTdPNhl.d.mts → kysely-DVF8wOT4.d.cts} +4 -4
- package/dist/{kysely-mcTdPNhl.d.mts.map → kysely-DVF8wOT4.d.cts.map} +1 -1
- package/dist/{lazyAccessors-BHtcqgz2.mjs → lazyAccessors-CFanua0O.mjs} +2 -39
- package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
- package/dist/{lazyAccessors-Dx9NLwJZ.cjs → lazyAccessors-hJKGv8Ay.cjs} +1 -50
- package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
- package/dist/mobile-app.d.cts +1 -1
- package/dist/mobile-app.d.mts +1 -1
- package/dist/object-storage.d.cts +1 -1
- package/dist/object-storage.d.mts +1 -1
- package/dist/processAudits-BpRlPQMW.mjs.map +1 -1
- package/dist/processAudits-D_2W5x8k.cjs.map +1 -1
- package/dist/queue/index.cjs +4 -78
- package/dist/queue/index.d.cts +3 -53
- package/dist/queue/index.d.mts +3 -53
- package/dist/queue/index.mjs +3 -77
- package/dist/rest-api.cjs +2 -4
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +4 -5
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +4 -5
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +2 -4
- package/dist/rest-api.mjs.map +1 -1
- package/dist/site.d.cts +1 -1
- package/dist/site.d.mts +1 -1
- package/dist/subscribers/index.cjs +1 -1
- package/dist/subscribers/index.d.cts +2 -2
- package/dist/subscribers/index.d.mts +2 -2
- package/dist/subscribers/index.mjs +1 -1
- package/dist/topic/index.cjs +1 -36
- package/dist/topic/index.d.cts +2 -3
- package/dist/topic/index.d.mts +2 -3
- package/dist/topic/index.mjs +2 -35
- package/dist/worker.cjs +26 -17
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +37 -29
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +37 -29
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +26 -17
- package/dist/worker.mjs.map +1 -1
- package/package.json +41 -31
- package/dist/Construct-DTqYvkPG.d.cts +0 -115
- package/dist/Construct-DTqYvkPG.d.cts.map +0 -1
- package/dist/Construct-Detz65RA.mjs.map +0 -1
- package/dist/Construct-pVadmURD.d.mts +0 -115
- package/dist/Construct-pVadmURD.d.mts.map +0 -1
- package/dist/Construct-yG9Sw-5p.cjs.map +0 -1
- package/dist/Cron-B_iuyNxr.d.mts.map +0 -1
- package/dist/Cron-CA2oa2nC.d.cts.map +0 -1
- package/dist/CronBuilder-BIKCLWu7.d.mts.map +0 -1
- package/dist/CronBuilder-BRkzUOAs.mjs.map +0 -1
- package/dist/CronBuilder-B_KqaodP.d.cts.map +0 -1
- package/dist/CronBuilder-BbnT7tqo.cjs.map +0 -1
- package/dist/Endpoint-1-XYQSx0.d.cts.map +0 -1
- package/dist/Endpoint-DO332Dnm.mjs.map +0 -1
- package/dist/Endpoint-GFIxYb9L.d.mts.map +0 -1
- package/dist/Endpoint-QKuFg5gs.cjs.map +0 -1
- package/dist/EndpointFactory-B9HAjDAP.mjs.map +0 -1
- package/dist/EndpointFactory-BCZdh_u3.d.mts.map +0 -1
- package/dist/EndpointFactory-BmO0WnXE.cjs.map +0 -1
- package/dist/EndpointFactory-BnK_YkW1.d.cts.map +0 -1
- package/dist/HonoEndpointAdaptor-CiqAZ5Mt.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DoEQdC3r.cjs.map +0 -1
- package/dist/Queue-B7yRXQmL.cjs.map +0 -1
- package/dist/Queue-Bhzi2WQC.d.cts.map +0 -1
- package/dist/Queue-BoUA-e83.d.mts.map +0 -1
- package/dist/Queue-DpKTLl6E.mjs.map +0 -1
- package/dist/Subscriber-CIO3pwji.d.mts.map +0 -1
- package/dist/Subscriber-DQCaiOXF.d.cts.map +0 -1
- package/dist/SubscriberBuilder-B4YRTBng.mjs.map +0 -1
- package/dist/SubscriberBuilder-C2FRfd26.d.mts.map +0 -1
- package/dist/SubscriberBuilder-C2bCOuPT.cjs.map +0 -1
- package/dist/SubscriberBuilder-CjDGSTZc.d.cts.map +0 -1
- package/dist/Topic-Ct3Le8Wt.mjs +0 -103
- package/dist/Topic-Ct3Le8Wt.mjs.map +0 -1
- package/dist/Topic-D5rlM9wS.cjs.map +0 -1
- package/dist/Topic-D6blllEn.d.cts +0 -89
- package/dist/Topic-D6blllEn.d.cts.map +0 -1
- package/dist/Topic-DVvheJ_-.d.mts +0 -89
- package/dist/Topic-DVvheJ_-.d.mts.map +0 -1
- package/dist/functions-DKN6aQWJ.cjs.map +0 -1
- package/dist/functions-DlFm8HmH.mjs.map +0 -1
- package/dist/index-BI23K3wy.d.cts.map +0 -1
- package/dist/index-fnpjXiA-.d.mts +0 -26
- package/dist/index-fnpjXiA-.d.mts.map +0 -1
- package/dist/index-tE_119SX.d.cts +0 -26
- package/dist/index-tE_119SX.d.cts.map +0 -1
- package/dist/index-yb3fXNyH.d.mts.map +0 -1
- package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
- package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts.map +0 -1
- package/dist/queue/index.d.mts.map +0 -1
- package/dist/queue/index.mjs.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
package/dist/Topic-Ct3Le8Wt.mjs
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { t as Construct } from "./Construct-Detz65RA.mjs";
|
|
2
|
-
import { derivedFrom } from "./construct-interface.mjs";
|
|
3
|
-
import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
4
|
-
import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
5
|
-
import { Publisher } from "@geekmidas/events";
|
|
6
|
-
//#region src/topic/Topic.ts
|
|
7
|
-
/**
|
|
8
|
-
* A topic — pub/sub fan-out. Unlike a `Queue` (point-to-point, one consumer), a
|
|
9
|
-
* topic is a *resource* owned by no single handler: it declares the event
|
|
10
|
-
* contract, derives a typed producer (`topic.publisher`), and any number of
|
|
11
|
-
* subscribers (`s.topic(topic)`) bind to it. `gkm build` discovers it into the
|
|
12
|
-
* manifest's `topics` field; infra provisions an SNS topic.
|
|
13
|
-
*
|
|
14
|
-
* This replaces hand-writing a publisher `Service`: the publisher is *derived*
|
|
15
|
-
* from the declared event contract, the same way `Queue` derives its publisher.
|
|
16
|
-
*/
|
|
17
|
-
var Topic = class extends Construct {
|
|
18
|
-
name;
|
|
19
|
-
eventSchemas;
|
|
20
|
-
__IS_TOPIC__ = true;
|
|
21
|
-
static isTopic(obj) {
|
|
22
|
-
return Boolean(obj && obj.__IS_TOPIC__ === true && obj.type === "dev.geekmidas.resource.topic");
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* The canonical id this topic is declared under.
|
|
26
|
-
*
|
|
27
|
-
* Derived from the name, so `users` and `Users` are one topic. The name is
|
|
28
|
-
* left alone: subscribers bind to it and it is what the broker routes on.
|
|
29
|
-
*/
|
|
30
|
-
id;
|
|
31
|
-
/**
|
|
32
|
-
* The producer's env key, read by both {@link declare} and
|
|
33
|
-
* {@link publisher} so the two cannot drift.
|
|
34
|
-
*/
|
|
35
|
-
connectionKey;
|
|
36
|
-
constructor(name, eventSchemas, logger = DEFAULT_LOGGER) {
|
|
37
|
-
super("dev.geekmidas.resource.topic", logger, [], []);
|
|
38
|
-
this.name = name;
|
|
39
|
-
this.eventSchemas = eventSchemas;
|
|
40
|
-
this.id = canonicalId(name);
|
|
41
|
-
this.connectionKey = provideKey(this.id, "publisherConnectionString");
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* What this topic is in the manifest.
|
|
45
|
-
*
|
|
46
|
-
* Only the producer's key: a subscriber is *bound* to a topic rather than
|
|
47
|
-
* depending on it, so the binding is an edge the deploy target reads and not
|
|
48
|
-
* an env key anyone can hold. Locally both sides meet on the same broker.
|
|
49
|
-
*/
|
|
50
|
-
declare() {
|
|
51
|
-
return [{
|
|
52
|
-
kind: "topic",
|
|
53
|
-
id: this.id,
|
|
54
|
-
provides: [this.connectionKey],
|
|
55
|
-
events: this.eventTypes,
|
|
56
|
-
subscribers: []
|
|
57
|
-
}];
|
|
58
|
-
}
|
|
59
|
-
/** The event type names this topic carries. */
|
|
60
|
-
get eventTypes() {
|
|
61
|
-
return Object.keys(this.eventSchemas);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The producer side — a `Service` exposing an `EventPublisher` typed to the
|
|
65
|
-
* union of this topic's events. Inject via `.publisher(topic.publisher)` (for
|
|
66
|
-
* declarative `.event(...)`) or `.services([topic.publisher])` (to publish
|
|
67
|
-
* imperatively). Reads `<NAME>_PUBLISHER_CONNECTION_STRING` and selects the
|
|
68
|
-
* transport from the URL protocol — `pgboss://` locally, `sns://` deployed.
|
|
69
|
-
*
|
|
70
|
-
* Because it's a `Service`, the connection-string requirement is sniffed into
|
|
71
|
-
* the manifest of whatever construct injects it (least-privilege linking).
|
|
72
|
-
*/
|
|
73
|
-
/**
|
|
74
|
-
* The topic as a dependency — what `.dependsOn([users])` dissolves into,
|
|
75
|
-
* reachable as `services.users`.
|
|
76
|
-
*
|
|
77
|
-
* It is the producer, because publishing is the only thing depending on a
|
|
78
|
-
* topic can mean: a subscriber *binds* with `s.topic(…)` instead, and is
|
|
79
|
-
* deliberately never handed this. {@link publisher} is the same service
|
|
80
|
-
* under its older `<name>Publisher` key.
|
|
81
|
-
*/
|
|
82
|
-
get service() {
|
|
83
|
-
const { register } = this.publisher;
|
|
84
|
-
return {
|
|
85
|
-
serviceName: serviceKey(this.id),
|
|
86
|
-
register
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
get publisher() {
|
|
90
|
-
const envVar = this.connectionKey;
|
|
91
|
-
return derivedFrom({
|
|
92
|
-
serviceName: `${this.name}Publisher`,
|
|
93
|
-
async register({ envParser }) {
|
|
94
|
-
const { connectionString } = envParser.create((get) => ({ connectionString: get(envVar).string() })).parse();
|
|
95
|
-
return Publisher.fromConnectionString(connectionString);
|
|
96
|
-
}
|
|
97
|
-
}, this);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
//#endregion
|
|
101
|
-
export { Topic as t };
|
|
102
|
-
|
|
103
|
-
//# sourceMappingURL=Topic-Ct3Le8Wt.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Topic-Ct3Le8Wt.mjs","names":[],"sources":["../src/topic/Topic.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\nimport { derivedFrom } from '../construct-interface';\n\n/** A topic's event contract — a map of event type → payload schema. */\nexport type TopicEvents = Record<string, StandardSchemaV1>;\n\n/**\n * The union of wire messages a topic carries, derived from its event map:\n * `{ type: 'user.created'; payload: … } | { type: 'user.updated'; payload: … }`.\n */\nexport type TopicMessage<TEvents extends TopicEvents> = {\n\t[K in keyof TEvents & string]: PublishableMessage<\n\t\tK,\n\t\tInferStandardSchema<TEvents[K]>\n\t>;\n}[keyof TEvents & string];\n\n/**\n * A topic — pub/sub fan-out. Unlike a `Queue` (point-to-point, one consumer), a\n * topic is a *resource* owned by no single handler: it declares the event\n * contract, derives a typed producer (`topic.publisher`), and any number of\n * subscribers (`s.topic(topic)`) bind to it. `gkm build` discovers it into the\n * manifest's `topics` field; infra provisions an SNS topic.\n *\n * This replaces hand-writing a publisher `Service`: the publisher is *derived*\n * from the declared event contract, the same way `Queue` derives its publisher.\n */\nexport class Topic<\n\tTName extends string = string,\n\tTEvents extends TopicEvents = TopicEvents,\n> extends Construct {\n\t__IS_TOPIC__ = true;\n\n\tstatic isTopic(obj: unknown): obj is Topic<string, TopicEvents> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_TOPIC__?: boolean }).__IS_TOPIC__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Topic,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this topic is declared under.\n\t *\n\t * Derived from the name, so `users` and `Users` are one topic. The name is\n\t * left alone: subscribers bind to it and it is what the broker routes on.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The producer's env key, read by both {@link declare} and\n\t * {@link publisher} so the two cannot drift.\n\t */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\t/**\n\t\t * The event contract — a map of event type → payload schema. Named\n\t\t * `eventSchemas` (not `events`) to avoid clashing with `Construct.events`,\n\t\t * which is the array of `MappedEvent`s a construct *publishes*.\n\t\t */\n\t\tpublic readonly eventSchemas: TEvents,\n\t\tlogger: Logger = DEFAULT_LOGGER,\n\t) {\n\t\tsuper(ConstructType.Topic, logger, [], []);\n\n\t\tthis.id = canonicalId(name);\n\t\tthis.connectionKey = provideKey(this.id, 'publisherConnectionString');\n\t}\n\n\t/**\n\t * What this topic is in the manifest.\n\t *\n\t * Only the producer's key: a subscriber is *bound* to a topic rather than\n\t * depending on it, so the binding is an edge the deploy target reads and not\n\t * an env key anyone can hold. Locally both sides meet on the same broker.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'topic',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t// The contract this topic carries. Structural: which events exist\n\t\t\t\t// is a fact about the application, and a subscriber binding to one\n\t\t\t\t// that does not is a mistake worth catching at build.\n\t\t\t\tevents: this.eventTypes,\n\t\t\t\t// Bound rather than declared here — a subscriber names the topic,\n\t\t\t\t// not the other way round — so the build fills these from what it\n\t\t\t\t// found. Nested when it does, because position is the trigger.\n\t\t\t\tsubscribers: [],\n\t\t\t},\n\t\t];\n\t}\n\n\t/** The event type names this topic carries. */\n\tget eventTypes(): (keyof TEvents & string)[] {\n\t\treturn Object.keys(this.eventSchemas) as (keyof TEvents & string)[];\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to the\n\t * union of this topic's events. Inject via `.publisher(topic.publisher)` (for\n\t * declarative `.event(...)`) or `.services([topic.publisher])` (to publish\n\t * imperatively). Reads `<NAME>_PUBLISHER_CONNECTION_STRING` and selects the\n\t * transport from the URL protocol — `pgboss://` locally, `sns://` deployed.\n\t *\n\t * Because it's a `Service`, the connection-string requirement is sniffed into\n\t * the manifest of whatever construct injects it (least-privilege linking).\n\t */\n\t/**\n\t * The topic as a dependency — what `.dependsOn([users])` dissolves into,\n\t * reachable as `services.users`.\n\t *\n\t * It is the producer, because publishing is the only thing depending on a\n\t * topic can mean: a subscriber *binds* with `s.topic(…)` instead, and is\n\t * deliberately never handed this. {@link publisher} is the same service\n\t * under its older `<name>Publisher` key.\n\t */\n\tget service(): Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<TopicMessage<TEvents>>\n\t> {\n\t\tconst { register } = this.publisher;\n\n\t\treturn {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister,\n\t\t};\n\t}\n\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<TopicMessage<TEvents>>\n\t> {\n\t\tconst envVar = this.connectionKey;\n\t\t// Marked with this construct, so whatever it is injected into records an\n\t\t// edge to it — and is given this construct's connection string.\n\t\treturn derivedFrom(\n\t\t\t{\n\t\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\t\tasync register({ envParser }) {\n\t\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t\t}))\n\t\t\t\t\t\t.parse();\n\n\t\t\t\t\treturn Publisher.fromConnectionString<TopicMessage<TEvents>>(\n\t\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t},\n\t\t\tthis,\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4CA,IAAa,QAAb,cAGU,UAAU;CA0BF;CAMA;CA/BjB,eAAe;CAEf,OAAO,QAAQ,KAAiD;EAC/D,OAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAAA,8BACrB;CACD;;;;;;;CAQA;;;;;CAMA;CAEA,YACC,MAMA,cACA,SAAiB,gBAChB;EACD,MAAA,gCAA2B,QAAQ,CAAC,GAAG,CAAC,CAAC;EATzB,KAAA,OAAA;EAMA,KAAA,eAAA;EAKhB,KAAK,KAAK,YAAY,IAAI;EAC1B,KAAK,gBAAgB,WAAW,KAAK,IAAI,2BAA2B;CACrE;;;;;;;;CASA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,aAAa;GAI7B,QAAQ,KAAK;GAIb,aAAa,CAAC;EACf,CACD;CACD;;CAGA,IAAI,aAAyC;EAC5C,OAAO,OAAO,KAAK,KAAK,YAAY;CACrC;;;;;;;;;;;;;;;;;;;;CAqBA,IAAI,UAGF;EACD,MAAM,EAAE,aAAa,KAAK;EAE1B,OAAO;GACN,aAAa,WAAW,KAAK,EAAE;GAC/B;EACD;CACD;CAEA,IAAI,YAGF;EACD,MAAM,SAAS,KAAK;EAGpB,OAAO,YACN;GACC,aAAa,GAAG,KAAK,KAAK;GAC1B,MAAM,SAAS,EAAE,aAAa;IAC7B,MAAM,EAAE,qBAAqB,UAC3B,QAAQ,SAAS,EACjB,kBAAkB,IAAI,MAAM,CAAC,CAAC,OAAO,EACtC,EAAE,CAAC,CACF,MAAM;IAER,OAAO,UAAU,qBAChB,gBACD;GACD;EACD,GACA,IACD;CACD;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Topic-D5rlM9wS.cjs","names":["Construct","DEFAULT_LOGGER","canonicalId","provideKey","serviceKey","derivedFrom","Publisher"],"sources":["../src/topic/Topic.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\nimport { derivedFrom } from '../construct-interface';\n\n/** A topic's event contract — a map of event type → payload schema. */\nexport type TopicEvents = Record<string, StandardSchemaV1>;\n\n/**\n * The union of wire messages a topic carries, derived from its event map:\n * `{ type: 'user.created'; payload: … } | { type: 'user.updated'; payload: … }`.\n */\nexport type TopicMessage<TEvents extends TopicEvents> = {\n\t[K in keyof TEvents & string]: PublishableMessage<\n\t\tK,\n\t\tInferStandardSchema<TEvents[K]>\n\t>;\n}[keyof TEvents & string];\n\n/**\n * A topic — pub/sub fan-out. Unlike a `Queue` (point-to-point, one consumer), a\n * topic is a *resource* owned by no single handler: it declares the event\n * contract, derives a typed producer (`topic.publisher`), and any number of\n * subscribers (`s.topic(topic)`) bind to it. `gkm build` discovers it into the\n * manifest's `topics` field; infra provisions an SNS topic.\n *\n * This replaces hand-writing a publisher `Service`: the publisher is *derived*\n * from the declared event contract, the same way `Queue` derives its publisher.\n */\nexport class Topic<\n\tTName extends string = string,\n\tTEvents extends TopicEvents = TopicEvents,\n> extends Construct {\n\t__IS_TOPIC__ = true;\n\n\tstatic isTopic(obj: unknown): obj is Topic<string, TopicEvents> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_TOPIC__?: boolean }).__IS_TOPIC__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Topic,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this topic is declared under.\n\t *\n\t * Derived from the name, so `users` and `Users` are one topic. The name is\n\t * left alone: subscribers bind to it and it is what the broker routes on.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The producer's env key, read by both {@link declare} and\n\t * {@link publisher} so the two cannot drift.\n\t */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\t/**\n\t\t * The event contract — a map of event type → payload schema. Named\n\t\t * `eventSchemas` (not `events`) to avoid clashing with `Construct.events`,\n\t\t * which is the array of `MappedEvent`s a construct *publishes*.\n\t\t */\n\t\tpublic readonly eventSchemas: TEvents,\n\t\tlogger: Logger = DEFAULT_LOGGER,\n\t) {\n\t\tsuper(ConstructType.Topic, logger, [], []);\n\n\t\tthis.id = canonicalId(name);\n\t\tthis.connectionKey = provideKey(this.id, 'publisherConnectionString');\n\t}\n\n\t/**\n\t * What this topic is in the manifest.\n\t *\n\t * Only the producer's key: a subscriber is *bound* to a topic rather than\n\t * depending on it, so the binding is an edge the deploy target reads and not\n\t * an env key anyone can hold. Locally both sides meet on the same broker.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'topic',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t// The contract this topic carries. Structural: which events exist\n\t\t\t\t// is a fact about the application, and a subscriber binding to one\n\t\t\t\t// that does not is a mistake worth catching at build.\n\t\t\t\tevents: this.eventTypes,\n\t\t\t\t// Bound rather than declared here — a subscriber names the topic,\n\t\t\t\t// not the other way round — so the build fills these from what it\n\t\t\t\t// found. Nested when it does, because position is the trigger.\n\t\t\t\tsubscribers: [],\n\t\t\t},\n\t\t];\n\t}\n\n\t/** The event type names this topic carries. */\n\tget eventTypes(): (keyof TEvents & string)[] {\n\t\treturn Object.keys(this.eventSchemas) as (keyof TEvents & string)[];\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to the\n\t * union of this topic's events. Inject via `.publisher(topic.publisher)` (for\n\t * declarative `.event(...)`) or `.services([topic.publisher])` (to publish\n\t * imperatively). Reads `<NAME>_PUBLISHER_CONNECTION_STRING` and selects the\n\t * transport from the URL protocol — `pgboss://` locally, `sns://` deployed.\n\t *\n\t * Because it's a `Service`, the connection-string requirement is sniffed into\n\t * the manifest of whatever construct injects it (least-privilege linking).\n\t */\n\t/**\n\t * The topic as a dependency — what `.dependsOn([users])` dissolves into,\n\t * reachable as `services.users`.\n\t *\n\t * It is the producer, because publishing is the only thing depending on a\n\t * topic can mean: a subscriber *binds* with `s.topic(…)` instead, and is\n\t * deliberately never handed this. {@link publisher} is the same service\n\t * under its older `<name>Publisher` key.\n\t */\n\tget service(): Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<TopicMessage<TEvents>>\n\t> {\n\t\tconst { register } = this.publisher;\n\n\t\treturn {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister,\n\t\t};\n\t}\n\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<TopicMessage<TEvents>>\n\t> {\n\t\tconst envVar = this.connectionKey;\n\t\t// Marked with this construct, so whatever it is injected into records an\n\t\t// edge to it — and is given this construct's connection string.\n\t\treturn derivedFrom(\n\t\t\t{\n\t\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\t\tasync register({ envParser }) {\n\t\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t\t}))\n\t\t\t\t\t\t.parse();\n\n\t\t\t\t\treturn Publisher.fromConnectionString<TopicMessage<TEvents>>(\n\t\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t},\n\t\t\tthis,\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4CA,IAAa,QAAb,cAGUA,kBAAAA,UAAU;CA0BF;CAMA;CA/BjB,eAAe;CAEf,OAAO,QAAQ,KAAiD;EAC/D,OAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAAA,8BACrB;CACD;;;;;;;CAQA;;;;;CAMA;CAEA,YACC,MAMA,cACA,SAAiBC,0BAAAA,gBAChB;EACD,MAAA,gCAA2B,QAAQ,CAAC,GAAG,CAAC,CAAC;EATzB,KAAA,OAAA;EAMA,KAAA,eAAA;EAKhB,KAAK,MAAA,GAAKC,oBAAAA,YAAAA,CAAY,IAAI;EAC1B,KAAK,iBAAA,GAAgBC,oBAAAA,WAAAA,CAAW,KAAK,IAAI,2BAA2B;CACrE;;;;;;;;CASA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,aAAa;GAI7B,QAAQ,KAAK;GAIb,aAAa,CAAC;EACf,CACD;CACD;;CAGA,IAAI,aAAyC;EAC5C,OAAO,OAAO,KAAK,KAAK,YAAY;CACrC;;;;;;;;;;;;;;;;;;;;CAqBA,IAAI,UAGF;EACD,MAAM,EAAE,aAAa,KAAK;EAE1B,OAAO;GACN,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,KAAK,EAAE;GAC/B;EACD;CACD;CAEA,IAAI,YAGF;EACD,MAAM,SAAS,KAAK;EAGpB,OAAOC,4BAAAA,YACN;GACC,aAAa,GAAG,KAAK,KAAK;GAC1B,MAAM,SAAS,EAAE,aAAa;IAC7B,MAAM,EAAE,qBAAqB,UAC3B,QAAQ,SAAS,EACjB,kBAAkB,IAAI,MAAM,CAAC,CAAC,OAAO,EACtC,EAAE,CAAC,CACF,MAAM;IAER,OAAOC,kBAAAA,UAAU,qBAChB,gBACD;GACD;EACD,GACA,IACD;CACD;AACD"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { t as StandardSchemaV1 } from "./index-CeEtxDmK.cjs";
|
|
2
|
-
import { t as Construct } from "./Construct-DTqYvkPG.cjs";
|
|
3
|
-
import { EventPublisher, PublishableMessage } from "@geekmidas/events";
|
|
4
|
-
import { Logger } from "@geekmidas/logger";
|
|
5
|
-
import { InferStandardSchema } from "@geekmidas/schema";
|
|
6
|
-
import { Service } from "@geekmidas/services";
|
|
7
|
-
import { Declaration } from "@geekmidas/manifest";
|
|
8
|
-
//#region src/topic/Topic.d.ts
|
|
9
|
-
/** A topic's event contract — a map of event type → payload schema. */
|
|
10
|
-
type TopicEvents = Record<string, StandardSchemaV1>;
|
|
11
|
-
/**
|
|
12
|
-
* The union of wire messages a topic carries, derived from its event map:
|
|
13
|
-
* `{ type: 'user.created'; payload: … } | { type: 'user.updated'; payload: … }`.
|
|
14
|
-
*/
|
|
15
|
-
type TopicMessage<TEvents extends TopicEvents> = { [K in keyof TEvents & string]: PublishableMessage<K, InferStandardSchema<TEvents[K]>>; }[keyof TEvents & string];
|
|
16
|
-
/**
|
|
17
|
-
* A topic — pub/sub fan-out. Unlike a `Queue` (point-to-point, one consumer), a
|
|
18
|
-
* topic is a *resource* owned by no single handler: it declares the event
|
|
19
|
-
* contract, derives a typed producer (`topic.publisher`), and any number of
|
|
20
|
-
* subscribers (`s.topic(topic)`) bind to it. `gkm build` discovers it into the
|
|
21
|
-
* manifest's `topics` field; infra provisions an SNS topic.
|
|
22
|
-
*
|
|
23
|
-
* This replaces hand-writing a publisher `Service`: the publisher is *derived*
|
|
24
|
-
* from the declared event contract, the same way `Queue` derives its publisher.
|
|
25
|
-
*/
|
|
26
|
-
declare class Topic<TName extends string = string, TEvents extends TopicEvents = TopicEvents> extends Construct {
|
|
27
|
-
readonly name: TName;
|
|
28
|
-
/**
|
|
29
|
-
* The event contract — a map of event type → payload schema. Named
|
|
30
|
-
* `eventSchemas` (not `events`) to avoid clashing with `Construct.events`,
|
|
31
|
-
* which is the array of `MappedEvent`s a construct *publishes*.
|
|
32
|
-
*/
|
|
33
|
-
readonly eventSchemas: TEvents;
|
|
34
|
-
__IS_TOPIC__: boolean;
|
|
35
|
-
static isTopic(obj: unknown): obj is Topic<string, TopicEvents>;
|
|
36
|
-
/**
|
|
37
|
-
* The canonical id this topic is declared under.
|
|
38
|
-
*
|
|
39
|
-
* Derived from the name, so `users` and `Users` are one topic. The name is
|
|
40
|
-
* left alone: subscribers bind to it and it is what the broker routes on.
|
|
41
|
-
*/
|
|
42
|
-
readonly id: string;
|
|
43
|
-
/**
|
|
44
|
-
* The producer's env key, read by both {@link declare} and
|
|
45
|
-
* {@link publisher} so the two cannot drift.
|
|
46
|
-
*/
|
|
47
|
-
private readonly connectionKey;
|
|
48
|
-
constructor(name: TName,
|
|
49
|
-
/**
|
|
50
|
-
* The event contract — a map of event type → payload schema. Named
|
|
51
|
-
* `eventSchemas` (not `events`) to avoid clashing with `Construct.events`,
|
|
52
|
-
* which is the array of `MappedEvent`s a construct *publishes*.
|
|
53
|
-
*/
|
|
54
|
-
eventSchemas: TEvents, logger?: Logger);
|
|
55
|
-
/**
|
|
56
|
-
* What this topic is in the manifest.
|
|
57
|
-
*
|
|
58
|
-
* Only the producer's key: a subscriber is *bound* to a topic rather than
|
|
59
|
-
* depending on it, so the binding is an edge the deploy target reads and not
|
|
60
|
-
* an env key anyone can hold. Locally both sides meet on the same broker.
|
|
61
|
-
*/
|
|
62
|
-
declare(): Declaration[];
|
|
63
|
-
/** The event type names this topic carries. */
|
|
64
|
-
get eventTypes(): (keyof TEvents & string)[];
|
|
65
|
-
/**
|
|
66
|
-
* The producer side — a `Service` exposing an `EventPublisher` typed to the
|
|
67
|
-
* union of this topic's events. Inject via `.publisher(topic.publisher)` (for
|
|
68
|
-
* declarative `.event(...)`) or `.services([topic.publisher])` (to publish
|
|
69
|
-
* imperatively). Reads `<NAME>_PUBLISHER_CONNECTION_STRING` and selects the
|
|
70
|
-
* transport from the URL protocol — `pgboss://` locally, `sns://` deployed.
|
|
71
|
-
*
|
|
72
|
-
* Because it's a `Service`, the connection-string requirement is sniffed into
|
|
73
|
-
* the manifest of whatever construct injects it (least-privilege linking).
|
|
74
|
-
*/
|
|
75
|
-
/**
|
|
76
|
-
* The topic as a dependency — what `.dependsOn([users])` dissolves into,
|
|
77
|
-
* reachable as `services.users`.
|
|
78
|
-
*
|
|
79
|
-
* It is the producer, because publishing is the only thing depending on a
|
|
80
|
-
* topic can mean: a subscriber *binds* with `s.topic(…)` instead, and is
|
|
81
|
-
* deliberately never handed this. {@link publisher} is the same service
|
|
82
|
-
* under its older `<name>Publisher` key.
|
|
83
|
-
*/
|
|
84
|
-
get service(): Service<Uncapitalize<TName>, EventPublisher<TopicMessage<TEvents>>>;
|
|
85
|
-
get publisher(): Service<`${TName}Publisher`, EventPublisher<TopicMessage<TEvents>>>;
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
export { TopicEvents as n, TopicMessage as r, Topic as t };
|
|
89
|
-
//# sourceMappingURL=Topic-D6blllEn.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Topic-D6blllEn.d.cts","names":[],"sources":["../src/topic/Topic.ts"],"mappings":";;;;;;;;;KAqBY,cAAc,eAAe;;;;;KAM7B,aAAa,gBAAgB,kBACvC,WAAW,mBAAmB,mBAC9B,GACA,oBAAoB,QAAQ,cAEtB;;;;;;;;;;;cAYK,MACZ,+BACA,gBAAgB,cAAc,qBACrB;WA0BQ,MAAM;;;;;;WAMN,cAAc;EA/B/B;SAEO,QAAQ,eAAe,OAAO,cAAc;;;;;;;WAc1C;;;;;mBAMQ;EAEjB,YACiB,MAAM,OAMN;;;;;;EAAA,cAAc,SAC9B,SAAQ;;;;;;;;EAeT,WAAW;;MAmBP,qBAAqB;;;;;;;;;;;;;;;;;;;;MAuBrB,WAAW,QACd,aAAa,QACb,eAAe,aAAa;MAUzB,aAAa,WACb,kBACH,eAAe,aAAa"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { t as StandardSchemaV1 } from "./index-CeEtxDmK.mjs";
|
|
2
|
-
import { t as Construct } from "./Construct-pVadmURD.mjs";
|
|
3
|
-
import { Declaration } from "@geekmidas/manifest";
|
|
4
|
-
import { EventPublisher, PublishableMessage } from "@geekmidas/events";
|
|
5
|
-
import { Service } from "@geekmidas/services";
|
|
6
|
-
import { Logger } from "@geekmidas/logger";
|
|
7
|
-
import { InferStandardSchema } from "@geekmidas/schema";
|
|
8
|
-
//#region src/topic/Topic.d.ts
|
|
9
|
-
/** A topic's event contract — a map of event type → payload schema. */
|
|
10
|
-
type TopicEvents = Record<string, StandardSchemaV1>;
|
|
11
|
-
/**
|
|
12
|
-
* The union of wire messages a topic carries, derived from its event map:
|
|
13
|
-
* `{ type: 'user.created'; payload: … } | { type: 'user.updated'; payload: … }`.
|
|
14
|
-
*/
|
|
15
|
-
type TopicMessage<TEvents extends TopicEvents> = { [K in keyof TEvents & string]: PublishableMessage<K, InferStandardSchema<TEvents[K]>>; }[keyof TEvents & string];
|
|
16
|
-
/**
|
|
17
|
-
* A topic — pub/sub fan-out. Unlike a `Queue` (point-to-point, one consumer), a
|
|
18
|
-
* topic is a *resource* owned by no single handler: it declares the event
|
|
19
|
-
* contract, derives a typed producer (`topic.publisher`), and any number of
|
|
20
|
-
* subscribers (`s.topic(topic)`) bind to it. `gkm build` discovers it into the
|
|
21
|
-
* manifest's `topics` field; infra provisions an SNS topic.
|
|
22
|
-
*
|
|
23
|
-
* This replaces hand-writing a publisher `Service`: the publisher is *derived*
|
|
24
|
-
* from the declared event contract, the same way `Queue` derives its publisher.
|
|
25
|
-
*/
|
|
26
|
-
declare class Topic<TName extends string = string, TEvents extends TopicEvents = TopicEvents> extends Construct {
|
|
27
|
-
readonly name: TName;
|
|
28
|
-
/**
|
|
29
|
-
* The event contract — a map of event type → payload schema. Named
|
|
30
|
-
* `eventSchemas` (not `events`) to avoid clashing with `Construct.events`,
|
|
31
|
-
* which is the array of `MappedEvent`s a construct *publishes*.
|
|
32
|
-
*/
|
|
33
|
-
readonly eventSchemas: TEvents;
|
|
34
|
-
__IS_TOPIC__: boolean;
|
|
35
|
-
static isTopic(obj: unknown): obj is Topic<string, TopicEvents>;
|
|
36
|
-
/**
|
|
37
|
-
* The canonical id this topic is declared under.
|
|
38
|
-
*
|
|
39
|
-
* Derived from the name, so `users` and `Users` are one topic. The name is
|
|
40
|
-
* left alone: subscribers bind to it and it is what the broker routes on.
|
|
41
|
-
*/
|
|
42
|
-
readonly id: string;
|
|
43
|
-
/**
|
|
44
|
-
* The producer's env key, read by both {@link declare} and
|
|
45
|
-
* {@link publisher} so the two cannot drift.
|
|
46
|
-
*/
|
|
47
|
-
private readonly connectionKey;
|
|
48
|
-
constructor(name: TName,
|
|
49
|
-
/**
|
|
50
|
-
* The event contract — a map of event type → payload schema. Named
|
|
51
|
-
* `eventSchemas` (not `events`) to avoid clashing with `Construct.events`,
|
|
52
|
-
* which is the array of `MappedEvent`s a construct *publishes*.
|
|
53
|
-
*/
|
|
54
|
-
eventSchemas: TEvents, logger?: Logger);
|
|
55
|
-
/**
|
|
56
|
-
* What this topic is in the manifest.
|
|
57
|
-
*
|
|
58
|
-
* Only the producer's key: a subscriber is *bound* to a topic rather than
|
|
59
|
-
* depending on it, so the binding is an edge the deploy target reads and not
|
|
60
|
-
* an env key anyone can hold. Locally both sides meet on the same broker.
|
|
61
|
-
*/
|
|
62
|
-
declare(): Declaration[];
|
|
63
|
-
/** The event type names this topic carries. */
|
|
64
|
-
get eventTypes(): (keyof TEvents & string)[];
|
|
65
|
-
/**
|
|
66
|
-
* The producer side — a `Service` exposing an `EventPublisher` typed to the
|
|
67
|
-
* union of this topic's events. Inject via `.publisher(topic.publisher)` (for
|
|
68
|
-
* declarative `.event(...)`) or `.services([topic.publisher])` (to publish
|
|
69
|
-
* imperatively). Reads `<NAME>_PUBLISHER_CONNECTION_STRING` and selects the
|
|
70
|
-
* transport from the URL protocol — `pgboss://` locally, `sns://` deployed.
|
|
71
|
-
*
|
|
72
|
-
* Because it's a `Service`, the connection-string requirement is sniffed into
|
|
73
|
-
* the manifest of whatever construct injects it (least-privilege linking).
|
|
74
|
-
*/
|
|
75
|
-
/**
|
|
76
|
-
* The topic as a dependency — what `.dependsOn([users])` dissolves into,
|
|
77
|
-
* reachable as `services.users`.
|
|
78
|
-
*
|
|
79
|
-
* It is the producer, because publishing is the only thing depending on a
|
|
80
|
-
* topic can mean: a subscriber *binds* with `s.topic(…)` instead, and is
|
|
81
|
-
* deliberately never handed this. {@link publisher} is the same service
|
|
82
|
-
* under its older `<name>Publisher` key.
|
|
83
|
-
*/
|
|
84
|
-
get service(): Service<Uncapitalize<TName>, EventPublisher<TopicMessage<TEvents>>>;
|
|
85
|
-
get publisher(): Service<`${TName}Publisher`, EventPublisher<TopicMessage<TEvents>>>;
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
export { TopicEvents as n, TopicMessage as r, Topic as t };
|
|
89
|
-
//# sourceMappingURL=Topic-DVvheJ_-.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Topic-DVvheJ_-.d.mts","names":[],"sources":["../src/topic/Topic.ts"],"mappings":";;;;;;;;;KAqBY,cAAc,eAAe;;;;;KAM7B,aAAa,gBAAgB,kBACvC,WAAW,mBAAmB,mBAC9B,GACA,oBAAoB,QAAQ,cAEtB;;;;;;;;;;;cAYK,MACZ,+BACA,gBAAgB,cAAc,qBACrB;WA0BQ,MAAM;;;;;;WAMN,cAAc;EA/B/B;SAEO,QAAQ,eAAe,OAAO,cAAc;;;;;;;WAc1C;;;;;mBAMQ;EAEjB,YACiB,MAAM,OAMN;;;;;;EAAA,cAAc,SAC9B,SAAQ;;;;;;;;EAeT,WAAW;;MAmBP,qBAAqB;;;;;;;;;;;;;;;;;;;;MAuBrB,WAAW,QACd,aAAa,QACb,eAAe,aAAa;MAUzB,aAAa,WACb,kBACH,eAAe,aAAa"}
|