@geekmidas/constructs 10.0.0-alpha.11 → 10.0.0-alpha.110
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 +222 -158
- package/dist/Construct-BQALFCh2.d.cts +230 -0
- package/dist/Construct-BQALFCh2.d.cts.map +1 -0
- package/dist/{Construct-BD5neF7w.mjs → Construct-CKUA-CTA.mjs} +35 -35
- package/dist/Construct-CKUA-CTA.mjs.map +1 -0
- package/dist/{Construct-CyS3RpTL.cjs → Construct-DEOVauyA.cjs} +55 -49
- package/dist/Construct-DEOVauyA.cjs.map +1 -0
- package/dist/Construct-QXnl3VqT.d.mts +230 -0
- package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
- package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-CQJqqkhY.d.mts} +17 -11
- package/dist/Cron-CQJqqkhY.d.mts.map +1 -0
- package/dist/{Cron-dh4rUgib.d.mts → Cron-DI3nKoic.d.cts} +17 -11
- package/dist/Cron-DI3nKoic.d.cts.map +1 -0
- package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BXTG10u5.cjs} +47 -31
- package/dist/CronBuilder-BXTG10u5.cjs.map +1 -0
- package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-D3sF9tS_.mjs} +37 -21
- package/dist/CronBuilder-D3sF9tS_.mjs.map +1 -0
- package/dist/CronBuilder-Xx_zakuc.d.mts +47 -0
- package/dist/CronBuilder-Xx_zakuc.d.mts.map +1 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
- package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-BWyKCa2x.d.cts} +130 -100
- package/dist/Endpoint-BWyKCa2x.d.cts.map +1 -0
- package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-CrE9Ppdk.d.mts} +130 -100
- package/dist/Endpoint-CrE9Ppdk.d.mts.map +1 -0
- package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-gPXhHKhJ.mjs} +208 -100
- package/dist/Endpoint-gPXhHKhJ.mjs.map +1 -0
- package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-yhR2T2Wt.cjs} +248 -122
- package/dist/Endpoint-yhR2T2Wt.cjs.map +1 -0
- package/dist/{index-lAO9egTb.d.mts → EndpointFactory-BV-nfnaP.d.mts} +85 -136
- package/dist/EndpointFactory-BV-nfnaP.d.mts.map +1 -0
- package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-BVv6EIDu.cjs} +98 -112
- package/dist/EndpointFactory-BVv6EIDu.cjs.map +1 -0
- package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-C1-IBwm4.d.cts} +84 -135
- package/dist/EndpointFactory-C1-IBwm4.d.cts.map +1 -0
- package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-Cs8IHvwF.mjs} +62 -76
- package/dist/EndpointFactory-Cs8IHvwF.mjs.map +1 -0
- package/dist/Function-DuqGcbOI.d.mts +76 -0
- package/dist/Function-DuqGcbOI.d.mts.map +1 -0
- package/dist/Function-Pu-1kKZz.d.cts +76 -0
- package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-CN1jjUBJ.cjs} +115 -71
- package/dist/HonoEndpointAdaptor-CN1jjUBJ.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-euH1oSdY.mjs} +105 -64
- package/dist/HonoEndpointAdaptor-euH1oSdY.mjs.map +1 -0
- package/dist/Queue-BhuofM3k.cjs +109 -0
- package/dist/Queue-BhuofM3k.cjs.map +1 -0
- package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
- package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
- package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
- package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
- package/dist/Queue-cmhqEBOB.mjs +104 -0
- package/dist/Queue-cmhqEBOB.mjs.map +1 -0
- package/dist/QueueBuilder-Cx9lKC5d.d.mts +75 -0
- package/dist/QueueBuilder-Cx9lKC5d.d.mts.map +1 -0
- package/dist/QueueBuilder-DXu1qxT1.mjs +118 -0
- package/dist/QueueBuilder-DXu1qxT1.mjs.map +1 -0
- package/dist/QueueBuilder-DdU2klPu.cjs +135 -0
- package/dist/QueueBuilder-DdU2klPu.cjs.map +1 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
- package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
- package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
- package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
- package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
- package/dist/SubscriberBuilder-4DWe9feX.d.mts +67 -0
- package/dist/SubscriberBuilder-4DWe9feX.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DRXfxWn_.mjs} +50 -24
- package/dist/SubscriberBuilder-DRXfxWn_.mjs.map +1 -0
- package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-M2EAgQhC.cjs} +61 -36
- package/dist/SubscriberBuilder-M2EAgQhC.cjs.map +1 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
- package/dist/Topic-D2R0r24C.mjs +99 -0
- package/dist/Topic-D2R0r24C.mjs.map +1 -0
- package/dist/Topic-DwS3QO0m.cjs +104 -0
- package/dist/Topic-DwS3QO0m.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +200 -246
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +58 -62
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +59 -63
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +171 -219
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +3 -10
- package/dist/adaptors/hono.d.cts +7 -16
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +9 -18
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +2 -10
- package/dist/adaptors/testing.cjs +765 -99
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +351 -54
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +351 -54
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +726 -78
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-BMCJN30Y.d.cts +268 -0
- package/dist/auth-BMCJN30Y.d.cts.map +1 -0
- package/dist/auth-D_0788uW.d.mts +268 -0
- package/dist/auth-D_0788uW.d.mts.map +1 -0
- package/dist/auth.cjs +301 -33
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -108
- package/dist/auth.d.mts +2 -108
- package/dist/auth.mjs +289 -27
- package/dist/auth.mjs.map +1 -1
- package/dist/{cache-BrRz3fEB.d.mts → cache-5QZzh5Er.d.mts} +3 -6
- package/dist/cache-5QZzh5Er.d.mts.map +1 -0
- package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
- package/dist/cache-DnGDGly3.d.cts.map +1 -0
- package/dist/cache.cjs +68 -2
- package/dist/cache.cjs.map +1 -0
- package/dist/cache.d.cts +1 -2
- package/dist/cache.d.mts +1 -2
- package/dist/cache.mjs +67 -2
- package/dist/cache.mjs.map +1 -0
- package/dist/cipher-C1lEFX63.mjs +225 -0
- package/dist/cipher-C1lEFX63.mjs.map +1 -0
- package/dist/cipher-CVxfwLjk.cjs +332 -0
- package/dist/cipher-CVxfwLjk.cjs.map +1 -0
- package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
- package/dist/clone-EKNovYHu.mjs.map +1 -0
- package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
- package/dist/clone-UGJpvQnL.cjs.map +1 -0
- package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
- package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
- package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-ZvYQbivO.d.mts} +42 -11
- package/dist/construct-interface-ZvYQbivO.d.mts.map +1 -0
- package/dist/construct-interface.cjs +113 -7
- package/dist/construct-interface.cjs.map +1 -0
- package/dist/construct-interface.d.cts +2 -2
- package/dist/construct-interface.d.mts +2 -2
- package/dist/construct-interface.mjs +106 -2
- package/dist/construct-interface.mjs.map +1 -0
- package/dist/credential-DYymbp_7.cjs +257 -0
- package/dist/credential-DYymbp_7.cjs.map +1 -0
- package/dist/credential-DfSAOOdY.mjs +222 -0
- package/dist/credential-DfSAOOdY.mjs.map +1 -0
- package/dist/credential.cjs +8 -96
- package/dist/credential.d.cts +2 -61
- package/dist/credential.d.mts +2 -61
- package/dist/credential.mjs +2 -94
- package/dist/crons/index.cjs +129 -7
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +45 -11
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +45 -11
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +127 -8
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +4 -181
- package/dist/database/kysely.d.cts +2 -152
- package/dist/database/kysely.d.mts +2 -152
- package/dist/database/kysely.mjs +2 -180
- package/dist/email.cjs +25 -12
- package/dist/email.cjs.map +1 -1
- package/dist/email.d.cts +3 -7
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +4 -8
- package/dist/email.d.mts.map +1 -1
- package/dist/email.mjs +16 -3
- package/dist/email.mjs.map +1 -1
- package/dist/encryption.cjs +96 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +117 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +117 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +83 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +20 -16
- package/dist/endpoints/index.d.cts +105 -7
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +105 -7
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -10
- package/dist/external-api.cjs +106 -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 +103 -0
- package/dist/external-api.mjs.map +1 -0
- package/dist/fake-DqKo8INJ.d.mts +201 -0
- package/dist/fake-DqKo8INJ.d.mts.map +1 -0
- package/dist/fake-Dvion_Fh.d.cts +201 -0
- package/dist/fake-Dvion_Fh.d.cts.map +1 -0
- package/dist/file-server.cjs +42 -10
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +6 -10
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +6 -10
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +34 -2
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +3 -6
- package/dist/functions/index.d.cts +3 -4
- package/dist/functions/index.d.mts +3 -4
- package/dist/functions/index.mjs +2 -6
- package/dist/{functions-14lpEFL4.mjs → functions-CTI-hDem.mjs} +376 -238
- package/dist/{functions-14lpEFL4.mjs.map → functions-CTI-hDem.mjs.map} +1 -1
- package/dist/{functions-i_la-N5r.cjs → functions-D7O5SGVc.cjs} +414 -264
- package/dist/functions-D7O5SGVc.cjs.map +1 -0
- package/dist/index-B13kQB_U.d.mts +115 -0
- package/dist/index-B13kQB_U.d.mts.map +1 -0
- package/dist/index-BuzRvKOQ.d.cts +115 -0
- package/dist/index-BuzRvKOQ.d.cts.map +1 -0
- package/dist/index-CeEtxDmK.d.cts +79 -0
- package/dist/index-CeEtxDmK.d.cts.map +1 -0
- package/dist/index-CeEtxDmK.d.mts +79 -0
- package/dist/index-CeEtxDmK.d.mts.map +1 -0
- package/dist/index.cjs +6 -3
- package/dist/index.d.cts +27 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +27 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -3
- package/dist/kms-B-Hm3d5r.cjs +85 -0
- package/dist/kms-B-Hm3d5r.cjs.map +1 -0
- package/dist/kms-BdUlMJEZ.mjs +85 -0
- package/dist/kms-BdUlMJEZ.mjs.map +1 -0
- package/dist/kysely-B3zfg9ti.cjs +383 -0
- package/dist/kysely-B3zfg9ti.cjs.map +1 -0
- package/dist/kysely-B_0BAr0T.mjs +370 -0
- package/dist/kysely-B_0BAr0T.mjs.map +1 -0
- package/dist/kysely-D0bpzgPs.d.cts +175 -0
- package/dist/kysely-D0bpzgPs.d.cts.map +1 -0
- package/dist/kysely-DKwnl0nf.d.mts +175 -0
- package/dist/kysely-DKwnl0nf.d.mts.map +1 -0
- package/dist/{telemetry-C3L0iS28.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +3 -6
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
- package/dist/{telemetry-D7bVFLGi.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +3 -6
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
- package/dist/mobile-app.cjs +73 -0
- package/dist/mobile-app.cjs.map +1 -0
- package/dist/mobile-app.d.cts +61 -0
- package/dist/mobile-app.d.cts.map +1 -0
- package/dist/mobile-app.d.mts +61 -0
- package/dist/mobile-app.d.mts.map +1 -0
- package/dist/mobile-app.mjs +72 -0
- package/dist/mobile-app.mjs.map +1 -0
- package/dist/object-storage.cjs +18 -10
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +3 -7
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +3 -7
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +11 -3
- package/dist/object-storage.mjs.map +1 -1
- package/dist/queue/index.cjs +6 -189
- package/dist/queue/index.d.cts +3 -60
- package/dist/queue/index.d.mts +3 -60
- package/dist/queue/index.mjs +3 -186
- package/dist/random-password.cjs +86 -0
- package/dist/random-password.cjs.map +1 -0
- package/dist/random-password.d.cts +30 -0
- package/dist/random-password.d.cts.map +1 -0
- package/dist/random-password.d.mts +30 -0
- package/dist/random-password.d.mts.map +1 -0
- package/dist/random-password.mjs +84 -0
- package/dist/random-password.mjs.map +1 -0
- package/dist/{lazyAccessors-BoJN3SMd.mjs → readRequestBody-BTIl3k-D.mjs} +117 -60
- package/dist/readRequestBody-BTIl3k-D.mjs.map +1 -0
- package/dist/readRequestBody-Dej_L3c4.cjs +342 -0
- package/dist/readRequestBody-Dej_L3c4.cjs.map +1 -0
- package/dist/requestLogger-BZcXwdBs.cjs +207 -0
- package/dist/requestLogger-BZcXwdBs.cjs.map +1 -0
- package/dist/requestLogger-pA4gi3E1.mjs +178 -0
- package/dist/requestLogger-pA4gi3E1.mjs.map +1 -0
- package/dist/rest-api.cjs +90 -59
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +70 -42
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +70 -42
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +82 -51
- package/dist/rest-api.mjs.map +1 -1
- package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
- package/dist/runSubscriber-BHvJ8POr.mjs +109 -0
- package/dist/runSubscriber-BHvJ8POr.mjs.map +1 -0
- package/dist/runSubscriber-D8nLXIv1.cjs +126 -0
- package/dist/runSubscriber-D8nLXIv1.cjs.map +1 -0
- package/dist/shutdown-BMJmAhSt.cjs +38 -0
- package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
- package/dist/shutdown-C7xa8x9S.mjs +27 -0
- package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
- package/dist/site.cjs +33 -7
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +17 -7
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +17 -7
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +29 -3
- package/dist/site.mjs.map +1 -1
- package/dist/stages-BSCF19o2.d.cts +56 -0
- package/dist/stages-BSCF19o2.d.cts.map +1 -0
- package/dist/stages-BSCF19o2.d.mts +56 -0
- package/dist/stages-BSCF19o2.d.mts.map +1 -0
- package/dist/subscribers/index.cjs +118 -6
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +51 -6
- package/dist/subscribers/index.d.cts.map +1 -0
- package/dist/subscribers/index.d.mts +51 -6
- package/dist/subscribers/index.d.mts.map +1 -0
- package/dist/subscribers/index.mjs +115 -5
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/surfaceEnv-CNimK76p.cjs +56 -0
- package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
- package/dist/telemetry-B48RLjyk.d.cts +40 -0
- package/dist/telemetry-B48RLjyk.d.cts.map +1 -0
- package/dist/telemetry-BEoBn6GO.d.mts +40 -0
- package/dist/telemetry-BEoBn6GO.d.mts.map +1 -0
- package/dist/telemetry.cjs +56 -0
- package/dist/telemetry.cjs.map +1 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +55 -0
- package/dist/telemetry.mjs.map +1 -0
- package/dist/topic/index.cjs +3 -137
- package/dist/topic/index.d.cts +2 -4
- package/dist/topic/index.d.mts +2 -4
- package/dist/topic/index.mjs +2 -134
- package/dist/tracing-Bbj1uoFJ.mjs +127 -0
- package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
- package/dist/tracing-C0ooU0V2.cjs +150 -0
- package/dist/tracing-C0ooU0V2.cjs.map +1 -0
- package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
- package/dist/types-DMuSQeLL.d.cts.map +1 -0
- package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
- package/dist/types-DMuSQeLL.d.mts.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -0
- package/dist/worker.cjs +59 -34
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +70 -45
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +71 -46
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +54 -29
- package/dist/worker.mjs.map +1 -1
- package/package.json +106 -42
- package/dist/Construct-BD5neF7w.mjs.map +0 -1
- package/dist/Construct-C0ijr2qp.d.cts +0 -117
- package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
- package/dist/Construct-Ct8nalEi.d.mts +0 -117
- package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
- package/dist/Construct-CyS3RpTL.cjs.map +0 -1
- package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
- package/dist/Cron-dh4rUgib.d.mts.map +0 -1
- package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
- package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
- package/dist/CronBuilder-CGgY2080.d.mts +0 -44
- package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
- package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
- package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
- package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
- package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
- package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
- package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
- package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
- package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
- package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
- package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
- package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
- package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
- package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
- package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
- package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
- package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
- package/dist/Topic-19QeHBIR.d.cts +0 -91
- package/dist/Topic-19QeHBIR.d.cts.map +0 -1
- package/dist/Topic-DuFeqkBh.d.mts +0 -91
- package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
- package/dist/auth.d.cts.map +0 -1
- package/dist/auth.d.mts.map +0 -1
- package/dist/cache-0ANvRQnD.mjs +0 -51
- package/dist/cache-0ANvRQnD.mjs.map +0 -1
- package/dist/cache-3WSvAulx.cjs +0 -57
- package/dist/cache-3WSvAulx.cjs.map +0 -1
- package/dist/cache-BrRz3fEB.d.mts.map +0 -1
- package/dist/cache-BtZY_tHe.d.cts.map +0 -1
- package/dist/clone-DblgEZZa.mjs.map +0 -1
- package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
- package/dist/construct-interface-BfjcOD_E.cjs +0 -117
- package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
- package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
- package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
- package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
- package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
- package/dist/credential.cjs.map +0 -1
- package/dist/credential.d.cts.map +0 -1
- package/dist/credential.d.mts.map +0 -1
- package/dist/credential.mjs.map +0 -1
- package/dist/database/kysely.cjs.map +0 -1
- package/dist/database/kysely.d.cts.map +0 -1
- package/dist/database/kysely.d.mts.map +0 -1
- package/dist/database/kysely.mjs.map +0 -1
- package/dist/functions-i_la-N5r.cjs.map +0 -1
- package/dist/index-Bd5FqCoe.d.cts.map +0 -1
- package/dist/index-BknhM6Ux.d.mts +0 -31
- package/dist/index-BknhM6Ux.d.mts.map +0 -1
- package/dist/index-CBSfrowv.d.cts +0 -31
- package/dist/index-CBSfrowv.d.cts.map +0 -1
- package/dist/index-D24Xm79M.d.cts +0 -171
- package/dist/index-D24Xm79M.d.cts.map +0 -1
- package/dist/index-_ajboYxK.d.mts +0 -171
- package/dist/index-_ajboYxK.d.mts.map +0 -1
- package/dist/index-lAO9egTb.d.mts.map +0 -1
- package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
- package/dist/lazyAccessors-e3j2oE2m.cjs +0 -274
- package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
- package/dist/processAudits-CGqttuXm.cjs +0 -92
- package/dist/processAudits-CGqttuXm.cjs.map +0 -1
- package/dist/processAudits-Dmts9H_b.mjs +0 -80
- package/dist/processAudits-Dmts9H_b.mjs.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/surfaceEnv-BFXEms2f.cjs +0 -39
- package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
- package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
- package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
- package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
- package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
- package/dist/types-BlAkSuGI.d.cts.map +0 -1
- package/dist/types-aKksMEWL.d.mts.map +0 -1
package/dist/topic/index.mjs
CHANGED
|
@@ -1,134 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
4
|
-
import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
5
|
-
import { Publisher } from "@geekmidas/events";
|
|
6
|
-
|
|
7
|
-
//#region src/topic/Topic.ts
|
|
8
|
-
/**
|
|
9
|
-
* A topic — pub/sub fan-out. Unlike a `Queue` (point-to-point, one consumer), a
|
|
10
|
-
* topic is a *resource* owned by no single handler: it declares the event
|
|
11
|
-
* contract, derives a typed producer (`topic.publisher`), and any number of
|
|
12
|
-
* subscribers (`s.topic(topic)`) bind to it. `gkm build` discovers it into the
|
|
13
|
-
* manifest's `topics` field; infra provisions an SNS topic.
|
|
14
|
-
*
|
|
15
|
-
* This replaces hand-writing a publisher `Service`: the publisher is *derived*
|
|
16
|
-
* from the declared event contract, the same way `Queue` derives its publisher.
|
|
17
|
-
*/
|
|
18
|
-
var Topic = class extends Construct {
|
|
19
|
-
__IS_TOPIC__ = true;
|
|
20
|
-
static isTopic(obj) {
|
|
21
|
-
return Boolean(obj && obj.__IS_TOPIC__ === true && obj.type === ConstructType.Topic);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The canonical id this topic is declared under.
|
|
25
|
-
*
|
|
26
|
-
* Derived from the name, so `users` and `Users` are one topic. The name is
|
|
27
|
-
* left alone: subscribers bind to it and it is what the broker routes on.
|
|
28
|
-
*/
|
|
29
|
-
id;
|
|
30
|
-
/**
|
|
31
|
-
* The producer's env key, read by both {@link declare} and
|
|
32
|
-
* {@link publisher} so the two cannot drift.
|
|
33
|
-
*/
|
|
34
|
-
connectionKey;
|
|
35
|
-
constructor(name, eventSchemas, logger = DEFAULT_LOGGER) {
|
|
36
|
-
super(ConstructType.Topic, logger, [], []);
|
|
37
|
-
this.name = name;
|
|
38
|
-
this.eventSchemas = eventSchemas;
|
|
39
|
-
this.id = canonicalId(name);
|
|
40
|
-
this.connectionKey = provideKey(this.id, "publisherConnectionString");
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* What this topic is in the manifest.
|
|
44
|
-
*
|
|
45
|
-
* Only the producer's key: a subscriber is *bound* to a topic rather than
|
|
46
|
-
* depending on it, so the binding is an edge the deploy target reads and not
|
|
47
|
-
* an env key anyone can hold. Locally both sides meet on the same broker.
|
|
48
|
-
*/
|
|
49
|
-
declare() {
|
|
50
|
-
return [{
|
|
51
|
-
kind: "topic",
|
|
52
|
-
id: this.id,
|
|
53
|
-
provides: [this.connectionKey],
|
|
54
|
-
events: this.eventTypes,
|
|
55
|
-
subscribers: []
|
|
56
|
-
}];
|
|
57
|
-
}
|
|
58
|
-
/** The event type names this topic carries. */
|
|
59
|
-
get eventTypes() {
|
|
60
|
-
return Object.keys(this.eventSchemas);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The producer side — a `Service` exposing an `EventPublisher` typed to the
|
|
64
|
-
* union of this topic's events. Inject via `.publisher(topic.publisher)` (for
|
|
65
|
-
* declarative `.event(...)`) or `.services([topic.publisher])` (to publish
|
|
66
|
-
* imperatively). Reads `<NAME>_PUBLISHER_CONNECTION_STRING` and selects the
|
|
67
|
-
* transport from the URL protocol — `pgboss://` locally, `sns://` deployed.
|
|
68
|
-
*
|
|
69
|
-
* Because it's a `Service`, the connection-string requirement is sniffed into
|
|
70
|
-
* the manifest of whatever construct injects it (least-privilege linking).
|
|
71
|
-
*/
|
|
72
|
-
/**
|
|
73
|
-
* The topic as a dependency — what `.dependsOn([users])` dissolves into,
|
|
74
|
-
* reachable as `services.users`.
|
|
75
|
-
*
|
|
76
|
-
* It is the producer, because publishing is the only thing depending on a
|
|
77
|
-
* topic can mean: a subscriber *binds* with `s.topic(…)` instead, and is
|
|
78
|
-
* deliberately never handed this. {@link publisher} is the same service
|
|
79
|
-
* under its older `<name>Publisher` key.
|
|
80
|
-
*/
|
|
81
|
-
get service() {
|
|
82
|
-
const { register } = this.publisher;
|
|
83
|
-
return {
|
|
84
|
-
serviceName: serviceKey(this.id),
|
|
85
|
-
register
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
get publisher() {
|
|
89
|
-
const envVar = this.connectionKey;
|
|
90
|
-
return {
|
|
91
|
-
serviceName: `${this.name}Publisher`,
|
|
92
|
-
async register({ envParser }) {
|
|
93
|
-
const { connectionString } = envParser.create((get) => ({ connectionString: get(envVar).string() })).parse();
|
|
94
|
-
return Publisher.fromConnectionString(connectionString);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/topic/TopicBuilder.ts
|
|
102
|
-
/**
|
|
103
|
-
* Builds a {@link Topic} — `t.topic('users').events({ 'user.created': schema, … })`.
|
|
104
|
-
* The event map is the topic's contract: it types the derived `topic.publisher`
|
|
105
|
-
* and the subscribers that bind via `s.topic(topic)`.
|
|
106
|
-
*/
|
|
107
|
-
var TopicBuilder = class {
|
|
108
|
-
_name;
|
|
109
|
-
_logger = DEFAULT_LOGGER;
|
|
110
|
-
/** The topic name — drives the infra topic and its `<NAME>_*` env vars. */
|
|
111
|
-
topic(name) {
|
|
112
|
-
return cloneWith(this, { _name: name });
|
|
113
|
-
}
|
|
114
|
-
logger(logger) {
|
|
115
|
-
return cloneWith(this, { _logger: logger });
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* The event contract — a map of event type → payload schema. Building the
|
|
119
|
-
* topic requires this; it's what types the publisher and subscribers.
|
|
120
|
-
*/
|
|
121
|
-
events(events) {
|
|
122
|
-
if (!this._name) throw new Error("Topic requires a name — call .topic(name) before .events().");
|
|
123
|
-
const topic = new Topic(this._name, events, this._logger);
|
|
124
|
-
return topic;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/topic/index.ts
|
|
130
|
-
const t = new TopicBuilder();
|
|
131
|
-
|
|
132
|
-
//#endregion
|
|
133
|
-
export { Topic, TopicBuilder, t };
|
|
134
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import { t as Topic } from "../Topic-D2R0r24C.mjs";
|
|
2
|
+
export { Topic };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { channel } from "node:diagnostics_channel";
|
|
2
|
+
import { carrierFromAttributes } from "@geekmidas/events";
|
|
3
|
+
import { identifyRequest } from "@geekmidas/services";
|
|
4
|
+
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
5
|
+
//#region src/tracing.ts
|
|
6
|
+
/**
|
|
7
|
+
* Where the constructs meet OpenTelemetry, beyond the spans `@geekmidas/events`
|
|
8
|
+
* starts for the brokers: the trace context in a Lambda's records, the spans
|
|
9
|
+
* around an `ExternalApi`'s client, and the context a call to a sibling
|
|
10
|
+
* service carries.
|
|
11
|
+
*
|
|
12
|
+
* Everything goes through the global API, so without a registered provider
|
|
13
|
+
* none of it records anything.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The trace context a Lambda record carries: an SQS record's message
|
|
19
|
+
* attributes, an SNS record's, or those of the SNS envelope an SQS
|
|
20
|
+
* subscription delivers in its body.
|
|
21
|
+
*/
|
|
22
|
+
function recordCarrier(record) {
|
|
23
|
+
const r = record;
|
|
24
|
+
if (r?.Sns) return carrierFromAttributes(r.Sns.MessageAttributes);
|
|
25
|
+
const own = carrierFromAttributes(r?.messageAttributes);
|
|
26
|
+
if (own || typeof r?.body !== "string") return own;
|
|
27
|
+
try {
|
|
28
|
+
const body = JSON.parse(r.body);
|
|
29
|
+
return body?.Type === "Notification" ? carrierFromAttributes(body.MessageAttributes) : void 0;
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `client`, with a span around each of its methods: `<api>.<method>`, carrying
|
|
36
|
+
* the API's name. An outbound `fetch` the method makes is traced already, and
|
|
37
|
+
* becomes this span's child, so the name is on the trace without anything
|
|
38
|
+
* knowing which URL belongs to which API.
|
|
39
|
+
*
|
|
40
|
+
* Only the client's own methods: what they return is the client's business.
|
|
41
|
+
* Methods are called on the client itself, never on the proxy, so private
|
|
42
|
+
* fields keep working.
|
|
43
|
+
*/
|
|
44
|
+
function traceClient(api, client, attributes = {}) {
|
|
45
|
+
if (!client || typeof client !== "object" && typeof client !== "function") return client;
|
|
46
|
+
const wrapped = /* @__PURE__ */ new Map();
|
|
47
|
+
return new Proxy(client, { get(target, property, receiver) {
|
|
48
|
+
const value = Reflect.get(target, property, receiver);
|
|
49
|
+
if (typeof value !== "function" || typeof property === "symbol") return value;
|
|
50
|
+
if (property === "constructor" || property === "then") return value;
|
|
51
|
+
const cached = wrapped.get(property);
|
|
52
|
+
if (cached && cached.original === value) return cached;
|
|
53
|
+
const traced = Object.assign((...args) => callTraced(api, property, attributes, () => value.apply(target, args)), { original: value });
|
|
54
|
+
wrapped.set(property, traced);
|
|
55
|
+
return traced;
|
|
56
|
+
} });
|
|
57
|
+
}
|
|
58
|
+
function callTraced(api, method, attributes, call) {
|
|
59
|
+
return trace.getTracer("@geekmidas/constructs").startActiveSpan(`${api}.${method}`, {
|
|
60
|
+
kind: SpanKind.INTERNAL,
|
|
61
|
+
attributes: {
|
|
62
|
+
"gkm.external_api.name": api,
|
|
63
|
+
"gkm.external_api.method": method,
|
|
64
|
+
...attributes
|
|
65
|
+
}
|
|
66
|
+
}, (span) => {
|
|
67
|
+
const fail = (error) => {
|
|
68
|
+
if (error instanceof Error) span.recordException(error);
|
|
69
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
70
|
+
span.end();
|
|
71
|
+
};
|
|
72
|
+
let result;
|
|
73
|
+
try {
|
|
74
|
+
result = call();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
fail(error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
if (result instanceof Promise) {
|
|
80
|
+
result.then(() => span.end(), (error) => fail(error));
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
span.end();
|
|
84
|
+
return result;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Where an instrumentation of `fetch` hears of each request — undici's own
|
|
89
|
+
* diagnostics channel, which OpenTelemetry's undici instrumentation (and every
|
|
90
|
+
* APM built on it) subscribes to.
|
|
91
|
+
*/
|
|
92
|
+
const FETCH_REQUESTS = channel("undici:request:create");
|
|
93
|
+
/**
|
|
94
|
+
* The active trace context, written into `headers` for a call this process
|
|
95
|
+
* makes to one of its own services — the auth server's session check — so the
|
|
96
|
+
* callee's span joins the caller's trace.
|
|
97
|
+
*
|
|
98
|
+
* Through the global propagator, so it is a no-op without one. And not at all
|
|
99
|
+
* when a `fetch` instrumentation is listening: that opens the request's own
|
|
100
|
+
* CLIENT span and writes its `traceparent` by appending a header, so a second
|
|
101
|
+
* one here would reach the callee as two values joined — `a, b` — which no
|
|
102
|
+
* propagator reads, and the trace would break instead of joining.
|
|
103
|
+
*/
|
|
104
|
+
function injectTraceContext(headers) {
|
|
105
|
+
if (FETCH_REQUESTS.hasSubscribers) return;
|
|
106
|
+
propagation.inject(context.active(), headers, { set: (carrier, key, value) => carrier.set(key, value) });
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Say who the current request is for: on its context — so its logger and
|
|
110
|
+
* every service read it — and on its span, as OpenTelemetry's `enduser.id`
|
|
111
|
+
* and `session.id`, so the request's trace can be found by who made it.
|
|
112
|
+
*
|
|
113
|
+
* The span is the active one: the request's own, since a session is verified
|
|
114
|
+
* before the handler opens any of its own. With no provider registered there
|
|
115
|
+
* is none, and only the context is told.
|
|
116
|
+
*/
|
|
117
|
+
function identifyUser(user) {
|
|
118
|
+
identifyRequest(user);
|
|
119
|
+
trace.getActiveSpan()?.setAttributes({
|
|
120
|
+
"enduser.id": user.id,
|
|
121
|
+
...user.sessionId ? { "session.id": user.sessionId } : {}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { traceClient as i, injectTraceContext as n, recordCarrier as r, identifyUser as t };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=tracing-Bbj1uoFJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracing-Bbj1uoFJ.mjs","names":[],"sources":["../src/tracing.ts"],"sourcesContent":["/**\n * Where the constructs meet OpenTelemetry, beyond the spans `@geekmidas/events`\n * starts for the brokers: the trace context in a Lambda's records, the spans\n * around an `ExternalApi`'s client, and the context a call to a sibling\n * service carries.\n *\n * Everything goes through the global API, so without a registered provider\n * none of it records anything.\n *\n * @module\n */\nimport { channel } from 'node:diagnostics_channel';\nimport { carrierFromAttributes, type TraceCarrier } from '@geekmidas/events';\nimport { identifyRequest, type RequestUser } from '@geekmidas/services';\nimport {\n\tcontext,\n\tpropagation,\n\tSpanKind,\n\tSpanStatusCode,\n\ttrace,\n} from '@opentelemetry/api';\n\n/**\n * The trace context a Lambda record carries: an SQS record's message\n * attributes, an SNS record's, or those of the SNS envelope an SQS\n * subscription delivers in its body.\n */\nexport function recordCarrier(record: unknown): TraceCarrier | undefined {\n\tconst r = record as {\n\t\tmessageAttributes?: Record<string, unknown>;\n\t\tbody?: string;\n\t\tSns?: { MessageAttributes?: Record<string, unknown> };\n\t};\n\tif (r?.Sns) return carrierFromAttributes(r.Sns.MessageAttributes);\n\n\tconst own = carrierFromAttributes(r?.messageAttributes);\n\tif (own || typeof r?.body !== 'string') return own;\n\ttry {\n\t\tconst body = JSON.parse(r.body);\n\t\treturn body?.Type === 'Notification'\n\t\t\t? carrierFromAttributes(body.MessageAttributes)\n\t\t\t: undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * `client`, with a span around each of its methods: `<api>.<method>`, carrying\n * the API's name. An outbound `fetch` the method makes is traced already, and\n * becomes this span's child, so the name is on the trace without anything\n * knowing which URL belongs to which API.\n *\n * Only the client's own methods: what they return is the client's business.\n * Methods are called on the client itself, never on the proxy, so private\n * fields keep working.\n */\nexport function traceClient<T>(\n\tapi: string,\n\tclient: T,\n\tattributes: Record<string, string> = {},\n): T {\n\tif (!client || (typeof client !== 'object' && typeof client !== 'function')) {\n\t\treturn client;\n\t}\n\tconst wrapped = new Map<PropertyKey, unknown>();\n\treturn new Proxy(client as object, {\n\t\tget(target, property, receiver) {\n\t\t\tconst value = Reflect.get(target, property, receiver);\n\t\t\tif (typeof value !== 'function' || typeof property === 'symbol') {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (property === 'constructor' || property === 'then') return value;\n\n\t\t\tconst cached = wrapped.get(property);\n\t\t\tif (cached && (cached as { original?: unknown }).original === value) {\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t\tconst traced = Object.assign(\n\t\t\t\t(...args: unknown[]) =>\n\t\t\t\t\tcallTraced(api, property, attributes, () =>\n\t\t\t\t\t\t(value as (...a: unknown[]) => unknown).apply(target, args),\n\t\t\t\t\t),\n\t\t\t\t{ original: value },\n\t\t\t);\n\t\t\twrapped.set(property, traced);\n\t\t\treturn traced;\n\t\t},\n\t}) as T;\n}\n\nfunction callTraced(\n\tapi: string,\n\tmethod: string,\n\tattributes: Record<string, string>,\n\tcall: () => unknown,\n): unknown {\n\treturn trace.getTracer('@geekmidas/constructs').startActiveSpan(\n\t\t`${api}.${method}`,\n\t\t{\n\t\t\tkind: SpanKind.INTERNAL,\n\t\t\tattributes: {\n\t\t\t\t'gkm.external_api.name': api,\n\t\t\t\t'gkm.external_api.method': method,\n\t\t\t\t...attributes,\n\t\t\t},\n\t\t},\n\t\t(span) => {\n\t\t\tconst fail = (error: unknown) => {\n\t\t\t\tif (error instanceof Error) span.recordException(error);\n\t\t\t\tspan.setStatus({ code: SpanStatusCode.ERROR });\n\t\t\t\tspan.end();\n\t\t\t};\n\t\t\tlet result: unknown;\n\t\t\ttry {\n\t\t\t\tresult = call();\n\t\t\t} catch (error) {\n\t\t\t\tfail(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// Only a native promise is waited on, and the caller gets it back as\n\t\t\t// it was: a lazy thenable runs on `then`, and a promise subclass has\n\t\t\t// methods a chained promise would not.\n\t\t\tif (result instanceof Promise) {\n\t\t\t\tresult.then(\n\t\t\t\t\t() => span.end(),\n\t\t\t\t\t(error) => fail(error),\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tspan.end();\n\t\t\treturn result;\n\t\t},\n\t);\n}\n\n/**\n * Where an instrumentation of `fetch` hears of each request — undici's own\n * diagnostics channel, which OpenTelemetry's undici instrumentation (and every\n * APM built on it) subscribes to.\n */\nconst FETCH_REQUESTS = channel('undici:request:create');\n\n/**\n * The active trace context, written into `headers` for a call this process\n * makes to one of its own services — the auth server's session check — so the\n * callee's span joins the caller's trace.\n *\n * Through the global propagator, so it is a no-op without one. And not at all\n * when a `fetch` instrumentation is listening: that opens the request's own\n * CLIENT span and writes its `traceparent` by appending a header, so a second\n * one here would reach the callee as two values joined — `a, b` — which no\n * propagator reads, and the trace would break instead of joining.\n */\nexport function injectTraceContext(headers: Headers): void {\n\tif (FETCH_REQUESTS.hasSubscribers) return;\n\tpropagation.inject(context.active(), headers, {\n\t\tset: (carrier, key, value) => carrier.set(key, value),\n\t});\n}\n\n/**\n * Say who the current request is for: on its context — so its logger and\n * every service read it — and on its span, as OpenTelemetry's `enduser.id`\n * and `session.id`, so the request's trace can be found by who made it.\n *\n * The span is the active one: the request's own, since a session is verified\n * before the handler opens any of its own. With no provider registered there\n * is none, and only the context is told.\n */\nexport function identifyUser(user: RequestUser): void {\n\tidentifyRequest(user);\n\ttrace.getActiveSpan()?.setAttributes({\n\t\t'enduser.id': user.id,\n\t\t...(user.sessionId ? { 'session.id': user.sessionId } : {}),\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,cAAc,QAA2C;CACxE,MAAM,IAAI;CAKV,IAAI,GAAG,KAAK,OAAO,sBAAsB,EAAE,IAAI,iBAAiB;CAEhE,MAAM,MAAM,sBAAsB,GAAG,iBAAiB;CACtD,IAAI,OAAO,OAAO,GAAG,SAAS,UAAU,OAAO;CAC/C,IAAI;EACH,MAAM,OAAO,KAAK,MAAM,EAAE,IAAI;EAC9B,OAAO,MAAM,SAAS,iBACnB,sBAAsB,KAAK,iBAAiB,IAC5C,KAAA;CACJ,QAAQ;EACP;CACD;AACD;;;;;;;;;;;AAYA,SAAgB,YACf,KACA,QACA,aAAqC,CAAC,GAClC;CACJ,IAAI,CAAC,UAAW,OAAO,WAAW,YAAY,OAAO,WAAW,YAC/D,OAAO;CAER,MAAM,0BAAU,IAAI,IAA0B;CAC9C,OAAO,IAAI,MAAM,QAAkB,EAClC,IAAI,QAAQ,UAAU,UAAU;EAC/B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,UAAU,QAAQ;EACpD,IAAI,OAAO,UAAU,cAAc,OAAO,aAAa,UACtD,OAAO;EAER,IAAI,aAAa,iBAAiB,aAAa,QAAQ,OAAO;EAE9D,MAAM,SAAS,QAAQ,IAAI,QAAQ;EACnC,IAAI,UAAW,OAAkC,aAAa,OAC7D,OAAO;EAER,MAAM,SAAS,OAAO,QACpB,GAAG,SACH,WAAW,KAAK,UAAU,kBACxB,MAAuC,MAAM,QAAQ,IAAI,CAC3D,GACD,EAAE,UAAU,MAAM,CACnB;EACA,QAAQ,IAAI,UAAU,MAAM;EAC5B,OAAO;CACR,EACD,CAAC;AACF;AAEA,SAAS,WACR,KACA,QACA,YACA,MACU;CACV,OAAO,MAAM,UAAU,uBAAuB,CAAC,CAAC,gBAC/C,GAAG,IAAI,GAAG,UACV;EACC,MAAM,SAAS;EACf,YAAY;GACX,yBAAyB;GACzB,2BAA2B;GAC3B,GAAG;EACJ;CACD,IACC,SAAS;EACT,MAAM,QAAQ,UAAmB;GAChC,IAAI,iBAAiB,OAAO,KAAK,gBAAgB,KAAK;GACtD,KAAK,UAAU,EAAE,MAAM,eAAe,MAAM,CAAC;GAC7C,KAAK,IAAI;EACV;EACA,IAAI;EACJ,IAAI;GACH,SAAS,KAAK;EACf,SAAS,OAAO;GACf,KAAK,KAAK;GACV,MAAM;EACP;EAIA,IAAI,kBAAkB,SAAS;GAC9B,OAAO,WACA,KAAK,IAAI,IACd,UAAU,KAAK,KAAK,CACtB;GACA,OAAO;EACR;EACA,KAAK,IAAI;EACT,OAAO;CACR,CACD;AACD;;;;;;AAOA,MAAM,iBAAiB,QAAQ,uBAAuB;;;;;;;;;;;;AAatD,SAAgB,mBAAmB,SAAwB;CAC1D,IAAI,eAAe,gBAAgB;CACnC,YAAY,OAAO,QAAQ,OAAO,GAAG,SAAS,EAC7C,MAAM,SAAS,KAAK,UAAU,QAAQ,IAAI,KAAK,KAAK,EACrD,CAAC;AACF;;;;;;;;;;AAWA,SAAgB,aAAa,MAAyB;CACrD,gBAAgB,IAAI;CACpB,MAAM,cAAc,CAAC,EAAE,cAAc;EACpC,cAAc,KAAK;EACnB,GAAI,KAAK,YAAY,EAAE,cAAc,KAAK,UAAU,IAAI,CAAC;CAC1D,CAAC;AACF"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
let node_diagnostics_channel = require("node:diagnostics_channel");
|
|
2
|
+
let _geekmidas_events = require("@geekmidas/events");
|
|
3
|
+
let _geekmidas_services = require("@geekmidas/services");
|
|
4
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
5
|
+
//#region src/tracing.ts
|
|
6
|
+
/**
|
|
7
|
+
* Where the constructs meet OpenTelemetry, beyond the spans `@geekmidas/events`
|
|
8
|
+
* starts for the brokers: the trace context in a Lambda's records, the spans
|
|
9
|
+
* around an `ExternalApi`'s client, and the context a call to a sibling
|
|
10
|
+
* service carries.
|
|
11
|
+
*
|
|
12
|
+
* Everything goes through the global API, so without a registered provider
|
|
13
|
+
* none of it records anything.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The trace context a Lambda record carries: an SQS record's message
|
|
19
|
+
* attributes, an SNS record's, or those of the SNS envelope an SQS
|
|
20
|
+
* subscription delivers in its body.
|
|
21
|
+
*/
|
|
22
|
+
function recordCarrier(record) {
|
|
23
|
+
const r = record;
|
|
24
|
+
if (r?.Sns) return (0, _geekmidas_events.carrierFromAttributes)(r.Sns.MessageAttributes);
|
|
25
|
+
const own = (0, _geekmidas_events.carrierFromAttributes)(r?.messageAttributes);
|
|
26
|
+
if (own || typeof r?.body !== "string") return own;
|
|
27
|
+
try {
|
|
28
|
+
const body = JSON.parse(r.body);
|
|
29
|
+
return body?.Type === "Notification" ? (0, _geekmidas_events.carrierFromAttributes)(body.MessageAttributes) : void 0;
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `client`, with a span around each of its methods: `<api>.<method>`, carrying
|
|
36
|
+
* the API's name. An outbound `fetch` the method makes is traced already, and
|
|
37
|
+
* becomes this span's child, so the name is on the trace without anything
|
|
38
|
+
* knowing which URL belongs to which API.
|
|
39
|
+
*
|
|
40
|
+
* Only the client's own methods: what they return is the client's business.
|
|
41
|
+
* Methods are called on the client itself, never on the proxy, so private
|
|
42
|
+
* fields keep working.
|
|
43
|
+
*/
|
|
44
|
+
function traceClient(api, client, attributes = {}) {
|
|
45
|
+
if (!client || typeof client !== "object" && typeof client !== "function") return client;
|
|
46
|
+
const wrapped = /* @__PURE__ */ new Map();
|
|
47
|
+
return new Proxy(client, { get(target, property, receiver) {
|
|
48
|
+
const value = Reflect.get(target, property, receiver);
|
|
49
|
+
if (typeof value !== "function" || typeof property === "symbol") return value;
|
|
50
|
+
if (property === "constructor" || property === "then") return value;
|
|
51
|
+
const cached = wrapped.get(property);
|
|
52
|
+
if (cached && cached.original === value) return cached;
|
|
53
|
+
const traced = Object.assign((...args) => callTraced(api, property, attributes, () => value.apply(target, args)), { original: value });
|
|
54
|
+
wrapped.set(property, traced);
|
|
55
|
+
return traced;
|
|
56
|
+
} });
|
|
57
|
+
}
|
|
58
|
+
function callTraced(api, method, attributes, call) {
|
|
59
|
+
return _opentelemetry_api.trace.getTracer("@geekmidas/constructs").startActiveSpan(`${api}.${method}`, {
|
|
60
|
+
kind: _opentelemetry_api.SpanKind.INTERNAL,
|
|
61
|
+
attributes: {
|
|
62
|
+
"gkm.external_api.name": api,
|
|
63
|
+
"gkm.external_api.method": method,
|
|
64
|
+
...attributes
|
|
65
|
+
}
|
|
66
|
+
}, (span) => {
|
|
67
|
+
const fail = (error) => {
|
|
68
|
+
if (error instanceof Error) span.recordException(error);
|
|
69
|
+
span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
|
|
70
|
+
span.end();
|
|
71
|
+
};
|
|
72
|
+
let result;
|
|
73
|
+
try {
|
|
74
|
+
result = call();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
fail(error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
if (result instanceof Promise) {
|
|
80
|
+
result.then(() => span.end(), (error) => fail(error));
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
span.end();
|
|
84
|
+
return result;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Where an instrumentation of `fetch` hears of each request — undici's own
|
|
89
|
+
* diagnostics channel, which OpenTelemetry's undici instrumentation (and every
|
|
90
|
+
* APM built on it) subscribes to.
|
|
91
|
+
*/
|
|
92
|
+
const FETCH_REQUESTS = (0, node_diagnostics_channel.channel)("undici:request:create");
|
|
93
|
+
/**
|
|
94
|
+
* The active trace context, written into `headers` for a call this process
|
|
95
|
+
* makes to one of its own services — the auth server's session check — so the
|
|
96
|
+
* callee's span joins the caller's trace.
|
|
97
|
+
*
|
|
98
|
+
* Through the global propagator, so it is a no-op without one. And not at all
|
|
99
|
+
* when a `fetch` instrumentation is listening: that opens the request's own
|
|
100
|
+
* CLIENT span and writes its `traceparent` by appending a header, so a second
|
|
101
|
+
* one here would reach the callee as two values joined — `a, b` — which no
|
|
102
|
+
* propagator reads, and the trace would break instead of joining.
|
|
103
|
+
*/
|
|
104
|
+
function injectTraceContext(headers) {
|
|
105
|
+
if (FETCH_REQUESTS.hasSubscribers) return;
|
|
106
|
+
_opentelemetry_api.propagation.inject(_opentelemetry_api.context.active(), headers, { set: (carrier, key, value) => carrier.set(key, value) });
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Say who the current request is for: on its context — so its logger and
|
|
110
|
+
* every service read it — and on its span, as OpenTelemetry's `enduser.id`
|
|
111
|
+
* and `session.id`, so the request's trace can be found by who made it.
|
|
112
|
+
*
|
|
113
|
+
* The span is the active one: the request's own, since a session is verified
|
|
114
|
+
* before the handler opens any of its own. With no provider registered there
|
|
115
|
+
* is none, and only the context is told.
|
|
116
|
+
*/
|
|
117
|
+
function identifyUser(user) {
|
|
118
|
+
(0, _geekmidas_services.identifyRequest)(user);
|
|
119
|
+
_opentelemetry_api.trace.getActiveSpan()?.setAttributes({
|
|
120
|
+
"enduser.id": user.id,
|
|
121
|
+
...user.sessionId ? { "session.id": user.sessionId } : {}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
Object.defineProperty(exports, "identifyUser", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function() {
|
|
128
|
+
return identifyUser;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(exports, "injectTraceContext", {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function() {
|
|
134
|
+
return injectTraceContext;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(exports, "recordCarrier", {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function() {
|
|
140
|
+
return recordCarrier;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(exports, "traceClient", {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function() {
|
|
146
|
+
return traceClient;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=tracing-C0ooU0V2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracing-C0ooU0V2.cjs","names":["carrierFromAttributes","trace","SpanKind","SpanStatusCode","channel","context"],"sources":["../src/tracing.ts"],"sourcesContent":["/**\n * Where the constructs meet OpenTelemetry, beyond the spans `@geekmidas/events`\n * starts for the brokers: the trace context in a Lambda's records, the spans\n * around an `ExternalApi`'s client, and the context a call to a sibling\n * service carries.\n *\n * Everything goes through the global API, so without a registered provider\n * none of it records anything.\n *\n * @module\n */\nimport { channel } from 'node:diagnostics_channel';\nimport { carrierFromAttributes, type TraceCarrier } from '@geekmidas/events';\nimport { identifyRequest, type RequestUser } from '@geekmidas/services';\nimport {\n\tcontext,\n\tpropagation,\n\tSpanKind,\n\tSpanStatusCode,\n\ttrace,\n} from '@opentelemetry/api';\n\n/**\n * The trace context a Lambda record carries: an SQS record's message\n * attributes, an SNS record's, or those of the SNS envelope an SQS\n * subscription delivers in its body.\n */\nexport function recordCarrier(record: unknown): TraceCarrier | undefined {\n\tconst r = record as {\n\t\tmessageAttributes?: Record<string, unknown>;\n\t\tbody?: string;\n\t\tSns?: { MessageAttributes?: Record<string, unknown> };\n\t};\n\tif (r?.Sns) return carrierFromAttributes(r.Sns.MessageAttributes);\n\n\tconst own = carrierFromAttributes(r?.messageAttributes);\n\tif (own || typeof r?.body !== 'string') return own;\n\ttry {\n\t\tconst body = JSON.parse(r.body);\n\t\treturn body?.Type === 'Notification'\n\t\t\t? carrierFromAttributes(body.MessageAttributes)\n\t\t\t: undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * `client`, with a span around each of its methods: `<api>.<method>`, carrying\n * the API's name. An outbound `fetch` the method makes is traced already, and\n * becomes this span's child, so the name is on the trace without anything\n * knowing which URL belongs to which API.\n *\n * Only the client's own methods: what they return is the client's business.\n * Methods are called on the client itself, never on the proxy, so private\n * fields keep working.\n */\nexport function traceClient<T>(\n\tapi: string,\n\tclient: T,\n\tattributes: Record<string, string> = {},\n): T {\n\tif (!client || (typeof client !== 'object' && typeof client !== 'function')) {\n\t\treturn client;\n\t}\n\tconst wrapped = new Map<PropertyKey, unknown>();\n\treturn new Proxy(client as object, {\n\t\tget(target, property, receiver) {\n\t\t\tconst value = Reflect.get(target, property, receiver);\n\t\t\tif (typeof value !== 'function' || typeof property === 'symbol') {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (property === 'constructor' || property === 'then') return value;\n\n\t\t\tconst cached = wrapped.get(property);\n\t\t\tif (cached && (cached as { original?: unknown }).original === value) {\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t\tconst traced = Object.assign(\n\t\t\t\t(...args: unknown[]) =>\n\t\t\t\t\tcallTraced(api, property, attributes, () =>\n\t\t\t\t\t\t(value as (...a: unknown[]) => unknown).apply(target, args),\n\t\t\t\t\t),\n\t\t\t\t{ original: value },\n\t\t\t);\n\t\t\twrapped.set(property, traced);\n\t\t\treturn traced;\n\t\t},\n\t}) as T;\n}\n\nfunction callTraced(\n\tapi: string,\n\tmethod: string,\n\tattributes: Record<string, string>,\n\tcall: () => unknown,\n): unknown {\n\treturn trace.getTracer('@geekmidas/constructs').startActiveSpan(\n\t\t`${api}.${method}`,\n\t\t{\n\t\t\tkind: SpanKind.INTERNAL,\n\t\t\tattributes: {\n\t\t\t\t'gkm.external_api.name': api,\n\t\t\t\t'gkm.external_api.method': method,\n\t\t\t\t...attributes,\n\t\t\t},\n\t\t},\n\t\t(span) => {\n\t\t\tconst fail = (error: unknown) => {\n\t\t\t\tif (error instanceof Error) span.recordException(error);\n\t\t\t\tspan.setStatus({ code: SpanStatusCode.ERROR });\n\t\t\t\tspan.end();\n\t\t\t};\n\t\t\tlet result: unknown;\n\t\t\ttry {\n\t\t\t\tresult = call();\n\t\t\t} catch (error) {\n\t\t\t\tfail(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// Only a native promise is waited on, and the caller gets it back as\n\t\t\t// it was: a lazy thenable runs on `then`, and a promise subclass has\n\t\t\t// methods a chained promise would not.\n\t\t\tif (result instanceof Promise) {\n\t\t\t\tresult.then(\n\t\t\t\t\t() => span.end(),\n\t\t\t\t\t(error) => fail(error),\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tspan.end();\n\t\t\treturn result;\n\t\t},\n\t);\n}\n\n/**\n * Where an instrumentation of `fetch` hears of each request — undici's own\n * diagnostics channel, which OpenTelemetry's undici instrumentation (and every\n * APM built on it) subscribes to.\n */\nconst FETCH_REQUESTS = channel('undici:request:create');\n\n/**\n * The active trace context, written into `headers` for a call this process\n * makes to one of its own services — the auth server's session check — so the\n * callee's span joins the caller's trace.\n *\n * Through the global propagator, so it is a no-op without one. And not at all\n * when a `fetch` instrumentation is listening: that opens the request's own\n * CLIENT span and writes its `traceparent` by appending a header, so a second\n * one here would reach the callee as two values joined — `a, b` — which no\n * propagator reads, and the trace would break instead of joining.\n */\nexport function injectTraceContext(headers: Headers): void {\n\tif (FETCH_REQUESTS.hasSubscribers) return;\n\tpropagation.inject(context.active(), headers, {\n\t\tset: (carrier, key, value) => carrier.set(key, value),\n\t});\n}\n\n/**\n * Say who the current request is for: on its context — so its logger and\n * every service read it — and on its span, as OpenTelemetry's `enduser.id`\n * and `session.id`, so the request's trace can be found by who made it.\n *\n * The span is the active one: the request's own, since a session is verified\n * before the handler opens any of its own. With no provider registered there\n * is none, and only the context is told.\n */\nexport function identifyUser(user: RequestUser): void {\n\tidentifyRequest(user);\n\ttrace.getActiveSpan()?.setAttributes({\n\t\t'enduser.id': user.id,\n\t\t...(user.sessionId ? { 'session.id': user.sessionId } : {}),\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,cAAc,QAA2C;CACxE,MAAM,IAAI;CAKV,IAAI,GAAG,KAAK,QAAA,GAAOA,kBAAAA,sBAAAA,CAAsB,EAAE,IAAI,iBAAiB;CAEhE,MAAM,OAAA,GAAMA,kBAAAA,sBAAAA,CAAsB,GAAG,iBAAiB;CACtD,IAAI,OAAO,OAAO,GAAG,SAAS,UAAU,OAAO;CAC/C,IAAI;EACH,MAAM,OAAO,KAAK,MAAM,EAAE,IAAI;EAC9B,OAAO,MAAM,SAAS,kBAAA,GACnBA,kBAAAA,sBAAAA,CAAsB,KAAK,iBAAiB,IAC5C,KAAA;CACJ,QAAQ;EACP;CACD;AACD;;;;;;;;;;;AAYA,SAAgB,YACf,KACA,QACA,aAAqC,CAAC,GAClC;CACJ,IAAI,CAAC,UAAW,OAAO,WAAW,YAAY,OAAO,WAAW,YAC/D,OAAO;CAER,MAAM,0BAAU,IAAI,IAA0B;CAC9C,OAAO,IAAI,MAAM,QAAkB,EAClC,IAAI,QAAQ,UAAU,UAAU;EAC/B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,UAAU,QAAQ;EACpD,IAAI,OAAO,UAAU,cAAc,OAAO,aAAa,UACtD,OAAO;EAER,IAAI,aAAa,iBAAiB,aAAa,QAAQ,OAAO;EAE9D,MAAM,SAAS,QAAQ,IAAI,QAAQ;EACnC,IAAI,UAAW,OAAkC,aAAa,OAC7D,OAAO;EAER,MAAM,SAAS,OAAO,QACpB,GAAG,SACH,WAAW,KAAK,UAAU,kBACxB,MAAuC,MAAM,QAAQ,IAAI,CAC3D,GACD,EAAE,UAAU,MAAM,CACnB;EACA,QAAQ,IAAI,UAAU,MAAM;EAC5B,OAAO;CACR,EACD,CAAC;AACF;AAEA,SAAS,WACR,KACA,QACA,YACA,MACU;CACV,OAAOC,mBAAAA,MAAM,UAAU,uBAAuB,CAAC,CAAC,gBAC/C,GAAG,IAAI,GAAG,UACV;EACC,MAAMC,mBAAAA,SAAS;EACf,YAAY;GACX,yBAAyB;GACzB,2BAA2B;GAC3B,GAAG;EACJ;CACD,IACC,SAAS;EACT,MAAM,QAAQ,UAAmB;GAChC,IAAI,iBAAiB,OAAO,KAAK,gBAAgB,KAAK;GACtD,KAAK,UAAU,EAAE,MAAMC,mBAAAA,eAAe,MAAM,CAAC;GAC7C,KAAK,IAAI;EACV;EACA,IAAI;EACJ,IAAI;GACH,SAAS,KAAK;EACf,SAAS,OAAO;GACf,KAAK,KAAK;GACV,MAAM;EACP;EAIA,IAAI,kBAAkB,SAAS;GAC9B,OAAO,WACA,KAAK,IAAI,IACd,UAAU,KAAK,KAAK,CACtB;GACA,OAAO;EACR;EACA,KAAK,IAAI;EACT,OAAO;CACR,CACD;AACD;;;;;;AAOA,MAAM,kBAAA,GAAiBC,yBAAAA,QAAAA,CAAQ,uBAAuB;;;;;;;;;;;;AAatD,SAAgB,mBAAmB,SAAwB;CAC1D,IAAI,eAAe,gBAAgB;CACnC,mBAAA,YAAY,OAAOC,mBAAAA,QAAQ,OAAO,GAAG,SAAS,EAC7C,MAAM,SAAS,KAAK,UAAU,QAAQ,IAAI,KAAK,KAAK,EACrD,CAAC;AACF;;;;;;;;;;AAWA,SAAgB,aAAa,MAAyB;CACrD,CAAA,GAAA,oBAAA,gBAAA,CAAgB,IAAI;CACpB,mBAAA,MAAM,cAAc,CAAC,EAAE,cAAc;EACpC,cAAc,KAAK;EACnB,GAAI,KAAK,YAAY,EAAE,cAAc,KAAK,UAAU,IAAI,CAAC;CAC1D,CAAC;AACF"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
|
-
type RemoveUndefined<T> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K] };
|
|
2
|
+
type RemoveUndefined<T> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K]; };
|
|
3
3
|
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
|
4
4
|
type LowerHttpMethod<T extends HttpMethod> = Lowercase<T>;
|
|
5
|
-
//# sourceMappingURL=types.d.ts.map
|
|
6
|
-
|
|
7
5
|
//#endregion
|
|
8
|
-
export {
|
|
9
|
-
//# sourceMappingURL=types-
|
|
6
|
+
export { LowerHttpMethod as n, RemoveUndefined as r, HttpMethod as t };
|
|
7
|
+
//# sourceMappingURL=types-DMuSQeLL.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DMuSQeLL.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,gBAAgB,QAC1B,WAAW,KAAK,EAAE,+BAA+B,IAAI,EAAE;KAG7C;KAQA,gBAAgB,UAAU,cAAc,UAAU"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
|
-
type RemoveUndefined<T> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K] };
|
|
2
|
+
type RemoveUndefined<T> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K]; };
|
|
3
3
|
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
|
4
4
|
type LowerHttpMethod<T extends HttpMethod> = Lowercase<T>;
|
|
5
|
-
//# sourceMappingURL=types.d.ts.map
|
|
6
|
-
|
|
7
5
|
//#endregion
|
|
8
|
-
export {
|
|
9
|
-
//# sourceMappingURL=types-
|
|
6
|
+
export { LowerHttpMethod as n, RemoveUndefined as r, HttpMethod as t };
|
|
7
|
+
//# sourceMappingURL=types-DMuSQeLL.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DMuSQeLL.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,gBAAgB,QAC1B,WAAW,KAAK,EAAE,+BAA+B,IAAI,EAAE;KAG7C;KAQA,gBAAgB,UAAU,cAAc,UAAU"}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as LowerHttpMethod, r as RemoveUndefined, t as HttpMethod } from "./types-DMuSQeLL.cjs";
|
|
2
2
|
export { HttpMethod, LowerHttpMethod, RemoveUndefined };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as LowerHttpMethod, r as RemoveUndefined, t as HttpMethod } from "./types-DMuSQeLL.mjs";
|
|
2
2
|
export { HttpMethod, LowerHttpMethod, RemoveUndefined };
|
package/dist/types.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/worker.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
const require_construct_interface = require(
|
|
3
|
-
require(
|
|
4
|
-
const
|
|
5
|
-
require(
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const __geekmidas_logger_console = require_chunk.__toESM(require("@geekmidas/logger/console"));
|
|
11
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_construct_interface = require("./construct-interface.cjs");
|
|
3
|
+
const require_functions = require("./functions-D7O5SGVc.cjs");
|
|
4
|
+
const require_surfaceEnv = require("./surfaceEnv-CNimK76p.cjs");
|
|
5
|
+
const require_CronBuilder = require("./CronBuilder-BXTG10u5.cjs");
|
|
6
|
+
const require_QueueBuilder = require("./QueueBuilder-DdU2klPu.cjs");
|
|
7
|
+
const require_SubscriberBuilder = require("./SubscriberBuilder-M2EAgQhC.cjs");
|
|
8
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
9
|
+
let _geekmidas_logger_console = require("@geekmidas/logger/console");
|
|
12
10
|
//#region src/worker.ts
|
|
13
11
|
var Worker = class Worker {
|
|
12
|
+
config;
|
|
13
|
+
dependencies;
|
|
14
14
|
id;
|
|
15
15
|
/** Always defined — the worker's own, or the console logger. */
|
|
16
16
|
logger;
|
|
@@ -18,15 +18,16 @@ var Worker = class Worker {
|
|
|
18
18
|
envParser;
|
|
19
19
|
/**
|
|
20
20
|
* Where this worker's schedules live, when it has crons and a server runs
|
|
21
|
-
* them
|
|
21
|
+
* them — and the database everything built from it receives as `db`.
|
|
22
|
+
* `undefined` until `.database(…)` says.
|
|
22
23
|
*/
|
|
23
24
|
scheduleStore;
|
|
24
25
|
constructor(id, config = {}, dependencies = [], scheduleStore) {
|
|
25
26
|
this.config = config;
|
|
26
27
|
this.dependencies = dependencies;
|
|
27
|
-
const canonical = (0,
|
|
28
|
+
const canonical = (0, _geekmidas_manifest.canonicalId)(id);
|
|
28
29
|
this.id = canonical;
|
|
29
|
-
this.logger = config.logger ??
|
|
30
|
+
this.logger = config.logger ?? _geekmidas_logger_console.DEFAULT_LOGGER;
|
|
30
31
|
this.envParser = require_surfaceEnv.envParserFor(config.envParser ? {
|
|
31
32
|
id: canonical,
|
|
32
33
|
envParser: config.envParser
|
|
@@ -34,7 +35,10 @@ var Worker = class Worker {
|
|
|
34
35
|
this.scheduleStore = scheduleStore;
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
|
-
* The database this worker keeps its schedules in
|
|
38
|
+
* The database this worker keeps its schedules in, and the one everything
|
|
39
|
+
* built from it — crons, queues, subscribers, functions — receives as `db`.
|
|
40
|
+
* One of them that works against another database names it with its own
|
|
41
|
+
* `.database(other)`, which replaces this one for that runnable alone.
|
|
38
42
|
*
|
|
39
43
|
* Only a server target uses it. On AWS a cron is an EventBridge rule
|
|
40
44
|
* invoking a Lambda and nothing here is consulted — but a server has nothing
|
|
@@ -51,6 +55,10 @@ var Worker = class Worker {
|
|
|
51
55
|
* @example
|
|
52
56
|
* ```ts
|
|
53
57
|
* export const jobs = new Worker('Jobs', { logger }).database(database);
|
|
58
|
+
*
|
|
59
|
+
* export const sweep = jobs
|
|
60
|
+
* .cron('rate(1 hour)')
|
|
61
|
+
* .handle(async ({ db }) => db.deleteFrom('sessions').execute());
|
|
54
62
|
* ```
|
|
55
63
|
*/
|
|
56
64
|
database(source) {
|
|
@@ -65,12 +73,31 @@ var Worker = class Worker {
|
|
|
65
73
|
return this.own(new require_CronBuilder.CronBuilder().logger(this.logger)).schedule(schedule);
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
76
|
+
* A queue and its one consumer, run by this worker.
|
|
77
|
+
*
|
|
78
|
+
* One construct, because a queue has exactly one consumer: nothing else can
|
|
79
|
+
* attach a second, or forget to attach the first. Producers send to it by
|
|
80
|
+
* depending on it — `.dependsOn([emails])` makes `services.emails` the
|
|
81
|
+
* publisher.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* export const emails = worker
|
|
86
|
+
* .queue('Emails')
|
|
87
|
+
* .message(z.object({ userId: z.uuid(), template: z.string() }))
|
|
88
|
+
* .handle(async ({ messages, services }) => { … });
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
queue(name) {
|
|
92
|
+
return this.own(new require_QueueBuilder.QueueBuilder().logger(this.logger)).queue(name);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
68
95
|
* A runnable that consumes a topic.
|
|
69
96
|
*
|
|
70
97
|
* Binding is not publishing: a consumer is handed the topic's event types
|
|
71
|
-
* and no connection string it could publish with.
|
|
72
|
-
*
|
|
73
|
-
* one.
|
|
98
|
+
* and no connection string it could publish with. A handler that emits
|
|
99
|
+
* follow-up events depends on the topic it emits to —
|
|
100
|
+
* `.dependsOn([orders])` — which is the only reason it would need one.
|
|
74
101
|
*
|
|
75
102
|
* @example `worker.topic(users).subscribe(['user.created']).handle(…)`
|
|
76
103
|
*/
|
|
@@ -78,17 +105,6 @@ var Worker = class Worker {
|
|
|
78
105
|
return this.own(new require_SubscriberBuilder.SubscriberBuilder().logger(this.logger)).topic(topic);
|
|
79
106
|
}
|
|
80
107
|
/**
|
|
81
|
-
* A runnable that consumes events typed from a publisher service.
|
|
82
|
-
*
|
|
83
|
-
* The older of the two ways to bind a subscriber, kept for a project whose
|
|
84
|
-
* events come from a hand-written publisher rather than a `Topic`
|
|
85
|
-
* construct. `topic()` is the one to reach for: it types the events the same
|
|
86
|
-
* way and hands the consumer no connection string it could publish with.
|
|
87
|
-
*/
|
|
88
|
-
publisher(service) {
|
|
89
|
-
return this.own(new require_SubscriberBuilder.SubscriberBuilder().logger(this.logger)).publisher(service);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
108
|
* Everything below builds a function — the runnable with no schedule and no
|
|
93
109
|
* topic, invoked by something else.
|
|
94
110
|
*
|
|
@@ -144,23 +160,32 @@ var Worker = class Worker {
|
|
|
144
160
|
}
|
|
145
161
|
/**
|
|
146
162
|
* Stamps this worker's id onto a builder, so everything built from it says
|
|
147
|
-
* which process runs it.
|
|
163
|
+
* which process runs it — and hands it the worker's database.
|
|
164
|
+
*
|
|
165
|
+
* The database goes through the builder's own `.database()` rather than
|
|
166
|
+
* being written into its fields, so the default is recorded exactly as an
|
|
167
|
+
* explicit one would be: the client the handler gets, and the edge the
|
|
168
|
+
* manifest reads. That is also what lets a later `.database(other)` replace
|
|
169
|
+
* it outright. The builder arrives already typed with this worker's
|
|
170
|
+
* database; this is the runtime half of that.
|
|
148
171
|
*/
|
|
149
172
|
own(builder) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
173
|
+
const owned = this.scheduleStore ? builder.database(this.scheduleStore) : builder;
|
|
174
|
+
owned._owner = this.id;
|
|
175
|
+
owned._scheduleStore = this.scheduleStore;
|
|
176
|
+
return owned;
|
|
153
177
|
}
|
|
154
178
|
declare() {
|
|
155
179
|
return [{
|
|
156
180
|
kind: "worker",
|
|
157
181
|
id: this.id,
|
|
158
182
|
...this.dependencies.length ? { dependencies: this.dependencies } : {},
|
|
183
|
+
...this.config.telemetry ? { telemetry: this.config.telemetry.id } : {},
|
|
159
184
|
provides: []
|
|
160
185
|
}];
|
|
161
186
|
}
|
|
162
187
|
};
|
|
163
|
-
|
|
164
188
|
//#endregion
|
|
165
189
|
exports.Worker = Worker;
|
|
190
|
+
|
|
166
191
|
//# sourceMappingURL=worker.cjs.map
|