@geekmidas/constructs 10.0.0-alpha.15 → 10.0.0-alpha.151
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-127M7yrl.d.cts +231 -0
- package/dist/Construct-127M7yrl.d.cts.map +1 -0
- package/dist/{Construct-BeYVu_QF.mjs → Construct-CGuc_Ijk.mjs} +8 -9
- package/dist/Construct-CGuc_Ijk.mjs.map +1 -0
- package/dist/{Construct-DqdlARxq.cjs → Construct-DorKS0Ua.cjs} +8 -9
- package/dist/Construct-DorKS0Ua.cjs.map +1 -0
- package/dist/Construct-DySlwh8o.d.mts +231 -0
- package/dist/Construct-DySlwh8o.d.mts.map +1 -0
- package/dist/{Cron-DKqnnTdH.d.cts → Cron-D8mB_cPX.d.mts} +16 -9
- package/dist/Cron-D8mB_cPX.d.mts.map +1 -0
- package/dist/{Cron-SyqS5oWJ.d.mts → Cron-D_sfaMGz.d.cts} +16 -9
- package/dist/Cron-D_sfaMGz.d.cts.map +1 -0
- package/dist/{CronBuilder-D_0HNBTr.mjs → CronBuilder-BJ5LoadF.mjs} +28 -11
- package/dist/CronBuilder-BJ5LoadF.mjs.map +1 -0
- package/dist/{CronBuilder-BdnI6lxF.cjs → CronBuilder-B_NSP-Y5.cjs} +27 -10
- package/dist/CronBuilder-B_NSP-Y5.cjs.map +1 -0
- package/dist/CronBuilder-C91MVLSr.d.cts +47 -0
- package/dist/CronBuilder-C91MVLSr.d.cts.map +1 -0
- package/dist/CronBuilder-Cmajva3g.d.mts +47 -0
- package/dist/CronBuilder-Cmajva3g.d.mts.map +1 -0
- package/dist/Endpoint-52z1P0Ue.cjs +581 -0
- package/dist/Endpoint-52z1P0Ue.cjs.map +1 -0
- package/dist/{Endpoint-DuT4TEEq.d.mts → Endpoint-BbHh3Qoc.d.mts} +124 -43
- package/dist/Endpoint-BbHh3Qoc.d.mts.map +1 -0
- package/dist/{Endpoint-C6yyHpRS.d.cts → Endpoint-YYwjqtS1.d.cts} +122 -41
- package/dist/Endpoint-YYwjqtS1.d.cts.map +1 -0
- package/dist/Endpoint-sUOU7uLx.mjs +552 -0
- package/dist/Endpoint-sUOU7uLx.mjs.map +1 -0
- package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
- package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
- package/dist/{EndpointFactory-CLvWuHyt.cjs → EndpointFactory-Cf_Cs1ym.cjs} +309 -51
- package/dist/EndpointFactory-Cf_Cs1ym.cjs.map +1 -0
- package/dist/{index-BPSZ_Lp_.d.cts → EndpointFactory-Hh1r6J_C.d.cts} +187 -104
- package/dist/EndpointFactory-Hh1r6J_C.d.cts.map +1 -0
- package/dist/{index-BoZ-iisU.d.mts → EndpointFactory-qcLzi4f-.d.mts} +188 -105
- package/dist/EndpointFactory-qcLzi4f-.d.mts.map +1 -0
- package/dist/Function-BIEsY0Hm.d.cts +76 -0
- package/dist/Function-BIEsY0Hm.d.cts.map +1 -0
- package/dist/Function-DfMzTGS4.d.mts +76 -0
- package/dist/Function-DfMzTGS4.d.mts.map +1 -0
- package/dist/{HonoEndpointAdaptor-92zavCsV.cjs → HonoEndpointAdaptor-BXBdb2Bt.cjs} +79 -31
- package/dist/HonoEndpointAdaptor-BXBdb2Bt.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-yYaU7jVJ.mjs → HonoEndpointAdaptor-DR3j7S35.mjs} +76 -28
- package/dist/HonoEndpointAdaptor-DR3j7S35.mjs.map +1 -0
- package/dist/ObjectSubscriberBuilder-Cv8C7yS1.d.mts +129 -0
- package/dist/ObjectSubscriberBuilder-Cv8C7yS1.d.mts.map +1 -0
- package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts +129 -0
- package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts.map +1 -0
- package/dist/ProcessorBuilder-CwfP-M33.d.mts +216 -0
- package/dist/ProcessorBuilder-CwfP-M33.d.mts.map +1 -0
- package/dist/ProcessorBuilder-_jdZlbfW.d.cts +216 -0
- package/dist/ProcessorBuilder-_jdZlbfW.d.cts.map +1 -0
- package/dist/{Queue-D9X6OoON.d.mts → Queue-BnK3UH8r.d.mts} +42 -41
- package/dist/Queue-BnK3UH8r.d.mts.map +1 -0
- package/dist/{Queue-DYPB2KWL.d.cts → Queue-C4rijiM7.d.cts} +43 -42
- package/dist/Queue-C4rijiM7.d.cts.map +1 -0
- package/dist/Queue-D4Iaidrs.cjs +109 -0
- package/dist/Queue-D4Iaidrs.cjs.map +1 -0
- package/dist/Queue-u8w8_HpE.mjs +104 -0
- package/dist/Queue-u8w8_HpE.mjs.map +1 -0
- package/dist/QueueBuilder-2wP5lEC8.mjs +118 -0
- package/dist/QueueBuilder-2wP5lEC8.mjs.map +1 -0
- package/dist/QueueBuilder-BxsZ9o5z.cjs +135 -0
- package/dist/QueueBuilder-BxsZ9o5z.cjs.map +1 -0
- package/dist/QueueBuilder-DmwFtLzQ.d.mts +75 -0
- package/dist/QueueBuilder-DmwFtLzQ.d.mts.map +1 -0
- package/dist/QueueBuilder-SQli59An.d.cts +75 -0
- package/dist/QueueBuilder-SQli59An.d.cts.map +1 -0
- package/dist/Subscriber-5rCX1Nph.d.cts +83 -0
- package/dist/Subscriber-5rCX1Nph.d.cts.map +1 -0
- package/dist/Subscriber-CW_Dl-YR.d.mts +83 -0
- package/dist/Subscriber-CW_Dl-YR.d.mts.map +1 -0
- package/dist/SubscriberBuilder-BL_GTcwh.mjs +237 -0
- package/dist/SubscriberBuilder-BL_GTcwh.mjs.map +1 -0
- package/dist/SubscriberBuilder-CWzKwX1p.cjs +260 -0
- package/dist/SubscriberBuilder-CWzKwX1p.cjs.map +1 -0
- package/dist/Topic-DN2gYJ-p.mjs +99 -0
- package/dist/Topic-DN2gYJ-p.mjs.map +1 -0
- package/dist/Topic-Dp9Q7Lj2.cjs +104 -0
- package/dist/Topic-Dp9Q7Lj2.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +134 -160
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +57 -48
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +58 -49
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +130 -157
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +1 -1
- package/dist/adaptors/hono.d.cts +5 -6
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +6 -7
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +1 -1
- package/dist/adaptors/testing.cjs +955 -38
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +437 -39
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +436 -38
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +929 -34
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-BqWz2JxC.d.cts +274 -0
- package/dist/auth-BqWz2JxC.d.cts.map +1 -0
- package/dist/auth-DnB9H9KL.d.mts +274 -0
- package/dist/auth-DnB9H9KL.d.mts.map +1 -0
- package/dist/auth.cjs +320 -21
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -104
- package/dist/auth.d.mts +2 -104
- package/dist/auth.mjs +316 -23
- package/dist/auth.mjs.map +1 -1
- package/dist/cache-CQjMNPrC.d.cts +44 -0
- package/dist/cache-CQjMNPrC.d.cts.map +1 -0
- package/dist/cache-e3tfMQ9g.d.mts +44 -0
- package/dist/cache-e3tfMQ9g.d.mts.map +1 -0
- package/dist/cache.d.cts +2 -43
- package/dist/cache.d.mts +2 -43
- 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/cipher-DSDxPRIp.d.cts +106 -0
- package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
- package/dist/cipher-DSDxPRIp.d.mts +106 -0
- package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
- package/dist/{construct-interface-DPlxfpoS.d.mts → construct-interface-CSA9VeWM.d.mts} +47 -8
- package/dist/construct-interface-CSA9VeWM.d.mts.map +1 -0
- package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-DugP0E5q.d.cts} +47 -8
- package/dist/construct-interface-DugP0E5q.d.cts.map +1 -0
- package/dist/construct-interface.cjs +38 -4
- 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 +37 -5
- package/dist/construct-interface.mjs.map +1 -1
- 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 +7 -129
- package/dist/credential.d.cts +2 -58
- package/dist/credential.d.mts +2 -58
- package/dist/credential.mjs +2 -128
- package/dist/crons/index.cjs +126 -1
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +43 -3
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +43 -3
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +125 -2
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +3 -194
- package/dist/database/kysely.d.cts +2 -149
- package/dist/database/kysely.d.mts +2 -149
- package/dist/database/kysely.mjs +2 -192
- package/dist/email.d.cts +1 -1
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +2 -2
- package/dist/email.d.mts.map +1 -1
- package/dist/encryption/kms.cjs +95 -0
- package/dist/encryption/kms.cjs.map +1 -0
- package/dist/encryption/kms.d.cts +7 -0
- package/dist/encryption/kms.d.cts.map +1 -0
- package/dist/encryption/kms.d.mts +7 -0
- package/dist/encryption/kms.d.mts.map +1 -0
- package/dist/encryption/kms.mjs +93 -0
- package/dist/encryption/kms.mjs.map +1 -0
- package/dist/encryption.cjs +116 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +37 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +37 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +101 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +32 -10
- package/dist/endpoints/index.d.cts +106 -3
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +106 -3
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -4
- package/dist/expire-C586zznE.d.cts +38 -0
- package/dist/expire-C586zznE.d.cts.map +1 -0
- package/dist/expire-C586zznE.d.mts +38 -0
- package/dist/expire-C586zznE.d.mts.map +1 -0
- package/dist/expire-CieftS01.cjs +67 -0
- package/dist/expire-CieftS01.cjs.map +1 -0
- package/dist/expire-CpzUAfr9.mjs +50 -0
- package/dist/expire-CpzUAfr9.mjs.map +1 -0
- 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-BqhP8RRQ.d.mts +201 -0
- package/dist/fake-BqhP8RRQ.d.mts.map +1 -0
- package/dist/fake-DqieDYYA.d.cts +201 -0
- package/dist/fake-DqieDYYA.d.cts.map +1 -0
- package/dist/file-server.cjs +123 -30
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +115 -1
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +115 -1
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +122 -32
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +1 -1
- package/dist/functions/index.d.cts +2 -1
- package/dist/functions/index.d.mts +2 -1
- package/dist/functions/index.mjs +1 -1
- package/dist/{functions-C53GW2eQ.mjs → functions-BvIDQKAA.mjs} +117 -22
- package/dist/functions-BvIDQKAA.mjs.map +1 -0
- package/dist/{functions-B6qCvfmy.cjs → functions-DLF6-IK8.cjs} +122 -18
- package/dist/functions-DLF6-IK8.cjs.map +1 -0
- package/dist/inbox-CR3L1fOI.d.cts +195 -0
- package/dist/inbox-CR3L1fOI.d.cts.map +1 -0
- package/dist/inbox-CjxpLVkH.d.mts +195 -0
- package/dist/inbox-CjxpLVkH.d.mts.map +1 -0
- package/dist/inbox.cjs +291 -0
- package/dist/inbox.cjs.map +1 -0
- package/dist/inbox.d.cts +2 -0
- package/dist/inbox.d.mts +2 -0
- package/dist/inbox.mjs +283 -0
- package/dist/inbox.mjs.map +1 -0
- package/dist/index-DCkDQkwj.d.mts +115 -0
- package/dist/index-DCkDQkwj.d.mts.map +1 -0
- package/dist/index-DPTHa6Ud.d.cts +115 -0
- package/dist/index-DPTHa6Ud.d.cts.map +1 -0
- package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
- package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
- package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
- package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +26 -3
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +26 -3
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -2
- package/dist/kysely-CebjCWTl.d.cts +216 -0
- package/dist/kysely-CebjCWTl.d.cts.map +1 -0
- package/dist/kysely-Cs4uPO8k.mjs +371 -0
- package/dist/kysely-Cs4uPO8k.mjs.map +1 -0
- package/dist/kysely-CukArHJ0.cjs +384 -0
- package/dist/kysely-CukArHJ0.cjs.map +1 -0
- package/dist/kysely-DE4kADWD.d.mts +216 -0
- package/dist/kysely-DE4kADWD.d.mts.map +1 -0
- package/dist/{telemetry-DGcFlVpB.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +2 -2
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
- package/dist/{telemetry-DGcFlVpB.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +2 -2
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
- package/dist/mobile-app.cjs +74 -0
- package/dist/mobile-app.cjs.map +1 -0
- package/dist/mobile-app.d.cts +73 -0
- package/dist/mobile-app.d.cts.map +1 -0
- package/dist/mobile-app.d.mts +73 -0
- package/dist/mobile-app.d.mts.map +1 -0
- package/dist/mobile-app.mjs +73 -0
- package/dist/mobile-app.mjs.map +1 -0
- package/dist/object-storage.cjs +8 -1
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +10 -1
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +10 -1
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +7 -2
- package/dist/object-storage.mjs.map +1 -1
- package/dist/pattern-C1CEcglD.mjs +241 -0
- package/dist/pattern-C1CEcglD.mjs.map +1 -0
- package/dist/pattern-QFaUIr77.cjs +288 -0
- package/dist/pattern-QFaUIr77.cjs.map +1 -0
- package/dist/processors/index.cjs +214 -0
- package/dist/processors/index.cjs.map +1 -0
- package/dist/processors/index.d.cts +78 -0
- package/dist/processors/index.d.cts.map +1 -0
- package/dist/processors/index.d.mts +78 -0
- package/dist/processors/index.d.mts.map +1 -0
- package/dist/processors/index.mjs +193 -0
- package/dist/processors/index.mjs.map +1 -0
- package/dist/queue/index.cjs +5 -192
- package/dist/queue/index.d.cts +3 -53
- package/dist/queue/index.d.mts +3 -53
- package/dist/queue/index.mjs +3 -190
- 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-BHtcqgz2.mjs → readRequestBody-BTIl3k-D.mjs} +99 -39
- package/dist/readRequestBody-BTIl3k-D.mjs.map +1 -0
- package/dist/{lazyAccessors-Dx9NLwJZ.cjs → readRequestBody-Dej_L3c4.cjs} +118 -46
- 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 +85 -70
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +77 -59
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +77 -59
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +87 -72
- package/dist/rest-api.mjs.map +1 -1
- package/dist/runSubscriber-CC_2C9F2.cjs +133 -0
- package/dist/runSubscriber-CC_2C9F2.cjs.map +1 -0
- package/dist/runSubscriber-DyHWp_Lf.mjs +116 -0
- package/dist/runSubscriber-DyHWp_Lf.mjs.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 +85 -8
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +98 -2
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +98 -2
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +84 -11
- package/dist/site.mjs.map +1 -1
- package/dist/stages-DaTaoQei.d.cts +73 -0
- package/dist/stages-DaTaoQei.d.cts.map +1 -0
- package/dist/stages-DaTaoQei.d.mts +73 -0
- package/dist/stages-DaTaoQei.d.mts.map +1 -0
- package/dist/subscribers/index.cjs +134 -1
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +74 -3
- package/dist/subscribers/index.d.cts.map +1 -0
- package/dist/subscribers/index.d.mts +74 -3
- package/dist/subscribers/index.d.mts.map +1 -0
- package/dist/subscribers/index.mjs +132 -2
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/telemetry-C1oqncFY.d.cts +40 -0
- package/dist/telemetry-C1oqncFY.d.cts.map +1 -0
- package/dist/telemetry-CObow3Dn.d.mts +40 -0
- package/dist/telemetry-CObow3Dn.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 +2 -134
- package/dist/topic/index.d.cts +2 -3
- package/dist/topic/index.d.mts +2 -3
- package/dist/topic/index.mjs +2 -132
- 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/websocket-api.cjs +951 -0
- package/dist/websocket-api.cjs.map +1 -0
- package/dist/websocket-api.d.cts +556 -0
- package/dist/websocket-api.d.cts.map +1 -0
- package/dist/websocket-api.d.mts +556 -0
- package/dist/websocket-api.d.mts.map +1 -0
- package/dist/websocket-api.mjs +933 -0
- package/dist/websocket-api.mjs.map +1 -0
- package/dist/worker.cjs +174 -32
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +147 -47
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +147 -47
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +175 -33
- package/dist/worker.mjs.map +1 -1
- package/package.json +155 -44
- package/dist/Construct-BeYVu_QF.mjs.map +0 -1
- package/dist/Construct-DfbwIntp.d.cts +0 -115
- package/dist/Construct-DfbwIntp.d.cts.map +0 -1
- package/dist/Construct-DqdlARxq.cjs.map +0 -1
- package/dist/Construct-l5aOn_jv.d.mts +0 -115
- package/dist/Construct-l5aOn_jv.d.mts.map +0 -1
- package/dist/Cron-DKqnnTdH.d.cts.map +0 -1
- package/dist/Cron-SyqS5oWJ.d.mts.map +0 -1
- package/dist/CronBuilder-BdnI6lxF.cjs.map +0 -1
- package/dist/CronBuilder-CRGnDfTq.d.mts +0 -41
- package/dist/CronBuilder-CRGnDfTq.d.mts.map +0 -1
- package/dist/CronBuilder-D_0HNBTr.mjs.map +0 -1
- package/dist/CronBuilder-Df1q9PNy.d.cts +0 -41
- package/dist/CronBuilder-Df1q9PNy.d.cts.map +0 -1
- package/dist/Endpoint-BpZHtJ2W.cjs +0 -1689
- package/dist/Endpoint-BpZHtJ2W.cjs.map +0 -1
- package/dist/Endpoint-C6yyHpRS.d.cts.map +0 -1
- package/dist/Endpoint-DuT4TEEq.d.mts.map +0 -1
- package/dist/Endpoint-ONsly_dq.mjs +0 -1671
- package/dist/Endpoint-ONsly_dq.mjs.map +0 -1
- package/dist/EndpointFactory-Bm3aKRdV.mjs.map +0 -1
- package/dist/EndpointFactory-CLvWuHyt.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-92zavCsV.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-yYaU7jVJ.mjs.map +0 -1
- package/dist/Queue-D9X6OoON.d.mts.map +0 -1
- package/dist/Queue-DYPB2KWL.d.cts.map +0 -1
- package/dist/Subscriber-C4heaAyO.d.mts +0 -51
- package/dist/Subscriber-C4heaAyO.d.mts.map +0 -1
- package/dist/Subscriber-CotDUELC.d.cts +0 -51
- package/dist/Subscriber-CotDUELC.d.cts.map +0 -1
- package/dist/SubscriberBuilder-BEv0eoHy.d.cts +0 -59
- package/dist/SubscriberBuilder-BEv0eoHy.d.cts.map +0 -1
- package/dist/SubscriberBuilder-C0ZEtGDI.cjs +0 -125
- package/dist/SubscriberBuilder-C0ZEtGDI.cjs.map +0 -1
- package/dist/SubscriberBuilder-h7B_cHMr.mjs +0 -114
- package/dist/SubscriberBuilder-h7B_cHMr.mjs.map +0 -1
- package/dist/SubscriberBuilder-tyH5yTk5.d.mts +0 -59
- package/dist/SubscriberBuilder-tyH5yTk5.d.mts.map +0 -1
- package/dist/Topic-DEVGo0Dm.d.cts +0 -89
- package/dist/Topic-DEVGo0Dm.d.cts.map +0 -1
- package/dist/Topic-zk_6Gthr.d.mts +0 -89
- package/dist/Topic-zk_6Gthr.d.mts.map +0 -1
- package/dist/auth.d.cts.map +0 -1
- package/dist/auth.d.mts.map +0 -1
- package/dist/cache.d.cts.map +0 -1
- package/dist/cache.d.mts.map +0 -1
- package/dist/construct-interface-DPlxfpoS.d.mts.map +0 -1
- package/dist/construct-interface-DgXTJcOD.d.cts.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-B6qCvfmy.cjs.map +0 -1
- package/dist/functions-C53GW2eQ.mjs.map +0 -1
- package/dist/index-B2urf3YI.d.cts +0 -26
- package/dist/index-B2urf3YI.d.cts.map +0 -1
- package/dist/index-BPSZ_Lp_.d.cts.map +0 -1
- package/dist/index-BoZ-iisU.d.mts.map +0 -1
- package/dist/index-CdaU--_B.d.cts +0 -165
- package/dist/index-CdaU--_B.d.cts.map +0 -1
- package/dist/index-DMCDvnsM.d.mts +0 -26
- package/dist/index-DMCDvnsM.d.mts.map +0 -1
- package/dist/index-PQRWOQj4.d.mts +0 -165
- package/dist/index-PQRWOQj4.d.mts.map +0 -1
- package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
- package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
- package/dist/processAudits-BpRlPQMW.mjs +0 -77
- package/dist/processAudits-BpRlPQMW.mjs.map +0 -1
- package/dist/processAudits-D_2W5x8k.cjs +0 -88
- package/dist/processAudits-D_2W5x8k.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/telemetry-DGcFlVpB.d.cts.map +0 -1
- package/dist/telemetry-DGcFlVpB.d.mts.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { TELEMETRY_KEYS, canonicalId } from "@geekmidas/manifest";
|
|
2
|
+
//#region src/telemetry.ts
|
|
3
|
+
/**
|
|
4
|
+
* `Telemetry` — what an application emits, declared.
|
|
5
|
+
*
|
|
6
|
+
* Traces and logs over OTLP, from every process that is given it. The
|
|
7
|
+
* construct says *what* is emitted — which requests are noise, which
|
|
8
|
+
* attributes every span carries — and never where it goes or how much of it:
|
|
9
|
+
* the provider and the sample rate are the deploy's, per stage
|
|
10
|
+
* (`deploy.telemetry` in `gkm.config.ts`), and locally `gkm dev` runs
|
|
11
|
+
* OpenObserve and sends everything there.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* export const telemetry = new Telemetry('Telemetry', {
|
|
15
|
+
* ignorePaths: ['/health', '/ready'],
|
|
16
|
+
* attributes: { 'service.namespace': 'shop' },
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // passed like the logger: a fact about the process
|
|
20
|
+
* new RestApi('Api', { path: 'apps/api', defaultAuthorizer: 'none', telemetry });
|
|
21
|
+
* new Worker('Jobs', { logger, telemetry });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Each process given it is an edge to this node, so the `OTEL_*` keys it
|
|
25
|
+
* provides reach exactly those processes, and the build of each one fails
|
|
26
|
+
* without the OpenTelemetry packages it needs.
|
|
27
|
+
*/
|
|
28
|
+
var Telemetry = class {
|
|
29
|
+
id;
|
|
30
|
+
ignorePaths;
|
|
31
|
+
attributes;
|
|
32
|
+
constructor(id, config = {}) {
|
|
33
|
+
this.id = canonicalId(id);
|
|
34
|
+
this.ignorePaths = [...config.ignorePaths ?? []];
|
|
35
|
+
this.attributes = { ...config.attributes };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One node, providing OpenTelemetry's own variables. No address of its
|
|
39
|
+
* own: where the telemetry goes is the deploy's, so it is resolved by the
|
|
40
|
+
* target for each stage, never declared here.
|
|
41
|
+
*/
|
|
42
|
+
declare() {
|
|
43
|
+
return [{
|
|
44
|
+
kind: "telemetry",
|
|
45
|
+
id: this.id,
|
|
46
|
+
...this.ignorePaths.length ? { ignorePaths: this.ignorePaths } : {},
|
|
47
|
+
...Object.keys(this.attributes).length ? { attributes: this.attributes } : {},
|
|
48
|
+
provides: [...TELEMETRY_KEYS]
|
|
49
|
+
}];
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { Telemetry };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=telemetry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.mjs","names":[],"sources":["../src/telemetry.ts"],"sourcesContent":["/**\n * `Telemetry` — what an application emits, declared.\n *\n * Traces and logs over OTLP, from every process that is given it. The\n * construct says *what* is emitted — which requests are noise, which\n * attributes every span carries — and never where it goes or how much of it:\n * the provider and the sample rate are the deploy's, per stage\n * (`deploy.telemetry` in `gkm.config.ts`), and locally `gkm dev` runs\n * OpenObserve and sends everything there.\n *\n * ```ts\n * export const telemetry = new Telemetry('Telemetry', {\n * ignorePaths: ['/health', '/ready'],\n * attributes: { 'service.namespace': 'shop' },\n * });\n *\n * // passed like the logger: a fact about the process\n * new RestApi('Api', { path: 'apps/api', defaultAuthorizer: 'none', telemetry });\n * new Worker('Jobs', { logger, telemetry });\n * ```\n *\n * Each process given it is an edge to this node, so the `OTEL_*` keys it\n * provides reach exactly those processes, and the build of each one fails\n * without the OpenTelemetry packages it needs.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tTELEMETRY_KEYS,\n} from '@geekmidas/manifest';\nimport type { Declarable } from './construct-interface';\n\nexport interface TelemetryConfig {\n\t/**\n\t * Request paths no span is recorded for, on every surface that uses this —\n\t * health checks, by default the only noise worth naming. A trailing `*`\n\t * matches a prefix. One route on one surface says so itself:\n\t * `.telemetry({ ignore: true })`.\n\t */\n\tignorePaths?: readonly string[];\n\t/**\n\t * Resource attributes every span and log record carries —\n\t * `{ 'service.namespace': 'shop' }`. The service's name is not one of\n\t * them: it is the app's, set per process.\n\t */\n\tattributes?: Readonly<Record<string, string>>;\n}\n\nexport class Telemetry<TName extends string = string>\n\timplements Declarable<TName>\n{\n\treadonly id: TName;\n\treadonly ignorePaths: readonly string[];\n\treadonly attributes: Readonly<Record<string, string>>;\n\n\tconstructor(id: ConstructName<TName>, config: TelemetryConfig = {}) {\n\t\tthis.id = canonicalId(id as string) as TName;\n\t\tthis.ignorePaths = [...(config.ignorePaths ?? [])];\n\t\tthis.attributes = { ...config.attributes };\n\t}\n\n\t/**\n\t * One node, providing OpenTelemetry's own variables. No address of its\n\t * own: where the telemetry goes is the deploy's, so it is resolved by the\n\t * target for each stage, never declared here.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'telemetry',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.ignorePaths.length ? { ignorePaths: this.ignorePaths } : {}),\n\t\t\t\t...(Object.keys(this.attributes).length\n\t\t\t\t\t? { attributes: this.attributes }\n\t\t\t\t\t: {}),\n\t\t\t\tprovides: [...TELEMETRY_KEYS],\n\t\t\t},\n\t\t];\n\t}\n}\n\n/** Per-route telemetry, on the endpoint builder — `.telemetry({ ignore: true })`. */\nexport interface EndpointTelemetry {\n\t/** Record no span for this route. */\n\tignore?: boolean;\n\t/** Attributes this route's request span carries. */\n\tattributes?: Readonly<Record<string, string>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAa,YAAb,MAEA;CACC;CACA;CACA;CAEA,YAAY,IAA0B,SAA0B,CAAC,GAAG;EACnE,KAAK,KAAK,YAAY,EAAY;EAClC,KAAK,cAAc,CAAC,GAAI,OAAO,eAAe,CAAC,CAAE;EACjD,KAAK,aAAa,EAAE,GAAG,OAAO,WAAW;CAC1C;;;;;;CAOA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,YAAY,SAAS,EAAE,aAAa,KAAK,YAAY,IAAI,CAAC;GACnE,GAAI,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,SAC9B,EAAE,YAAY,KAAK,WAAW,IAC9B,CAAC;GACJ,UAAU,CAAC,GAAG,cAAc;EAC7B,CACD;CACD;AACD"}
|
package/dist/topic/index.cjs
CHANGED
|
@@ -1,135 +1,3 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
5
|
-
let _geekmidas_logger_console = require("@geekmidas/logger/console");
|
|
6
|
-
let _geekmidas_events = require("@geekmidas/events");
|
|
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 require_Construct.Construct {
|
|
19
|
-
name;
|
|
20
|
-
eventSchemas;
|
|
21
|
-
__IS_TOPIC__ = true;
|
|
22
|
-
static isTopic(obj) {
|
|
23
|
-
return Boolean(obj && obj.__IS_TOPIC__ === true && obj.type === "dev.geekmidas.resource.topic");
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The canonical id this topic is declared under.
|
|
27
|
-
*
|
|
28
|
-
* Derived from the name, so `users` and `Users` are one topic. The name is
|
|
29
|
-
* left alone: subscribers bind to it and it is what the broker routes on.
|
|
30
|
-
*/
|
|
31
|
-
id;
|
|
32
|
-
/**
|
|
33
|
-
* The producer's env key, read by both {@link declare} and
|
|
34
|
-
* {@link publisher} so the two cannot drift.
|
|
35
|
-
*/
|
|
36
|
-
connectionKey;
|
|
37
|
-
constructor(name, eventSchemas, logger = _geekmidas_logger_console.DEFAULT_LOGGER) {
|
|
38
|
-
super("dev.geekmidas.resource.topic", logger, [], []);
|
|
39
|
-
this.name = name;
|
|
40
|
-
this.eventSchemas = eventSchemas;
|
|
41
|
-
this.id = (0, _geekmidas_manifest.canonicalId)(name);
|
|
42
|
-
this.connectionKey = (0, _geekmidas_manifest.provideKey)(this.id, "publisherConnectionString");
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* What this topic is in the manifest.
|
|
46
|
-
*
|
|
47
|
-
* Only the producer's key: a subscriber is *bound* to a topic rather than
|
|
48
|
-
* depending on it, so the binding is an edge the deploy target reads and not
|
|
49
|
-
* an env key anyone can hold. Locally both sides meet on the same broker.
|
|
50
|
-
*/
|
|
51
|
-
declare() {
|
|
52
|
-
return [{
|
|
53
|
-
kind: "topic",
|
|
54
|
-
id: this.id,
|
|
55
|
-
provides: [this.connectionKey],
|
|
56
|
-
events: this.eventTypes,
|
|
57
|
-
subscribers: []
|
|
58
|
-
}];
|
|
59
|
-
}
|
|
60
|
-
/** The event type names this topic carries. */
|
|
61
|
-
get eventTypes() {
|
|
62
|
-
return Object.keys(this.eventSchemas);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The producer side — a `Service` exposing an `EventPublisher` typed to the
|
|
66
|
-
* union of this topic's events. Inject via `.publisher(topic.publisher)` (for
|
|
67
|
-
* declarative `.event(...)`) or `.services([topic.publisher])` (to publish
|
|
68
|
-
* imperatively). Reads `<NAME>_PUBLISHER_CONNECTION_STRING` and selects the
|
|
69
|
-
* transport from the URL protocol — `pgboss://` locally, `sns://` deployed.
|
|
70
|
-
*
|
|
71
|
-
* Because it's a `Service`, the connection-string requirement is sniffed into
|
|
72
|
-
* the manifest of whatever construct injects it (least-privilege linking).
|
|
73
|
-
*/
|
|
74
|
-
/**
|
|
75
|
-
* The topic as a dependency — what `.dependsOn([users])` dissolves into,
|
|
76
|
-
* reachable as `services.users`.
|
|
77
|
-
*
|
|
78
|
-
* It is the producer, because publishing is the only thing depending on a
|
|
79
|
-
* topic can mean: a subscriber *binds* with `s.topic(…)` instead, and is
|
|
80
|
-
* deliberately never handed this. {@link publisher} is the same service
|
|
81
|
-
* under its older `<name>Publisher` key.
|
|
82
|
-
*/
|
|
83
|
-
get service() {
|
|
84
|
-
const { register } = this.publisher;
|
|
85
|
-
return {
|
|
86
|
-
serviceName: (0, _geekmidas_manifest.serviceKey)(this.id),
|
|
87
|
-
register
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
get publisher() {
|
|
91
|
-
const envVar = this.connectionKey;
|
|
92
|
-
return {
|
|
93
|
-
serviceName: `${this.name}Publisher`,
|
|
94
|
-
async register({ envParser }) {
|
|
95
|
-
const { connectionString } = envParser.create((get) => ({ connectionString: get(envVar).string() })).parse();
|
|
96
|
-
return _geekmidas_events.Publisher.fromConnectionString(connectionString);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/topic/TopicBuilder.ts
|
|
103
|
-
/**
|
|
104
|
-
* Builds a {@link Topic} — `t.topic('users').events({ 'user.created': schema, … })`.
|
|
105
|
-
* The event map is the topic's contract: it types the derived `topic.publisher`
|
|
106
|
-
* and the subscribers that bind via `s.topic(topic)`.
|
|
107
|
-
*/
|
|
108
|
-
var TopicBuilder = class {
|
|
109
|
-
_name;
|
|
110
|
-
_logger = _geekmidas_logger_console.DEFAULT_LOGGER;
|
|
111
|
-
/** The topic name — drives the infra topic and its `<NAME>_*` env vars. */
|
|
112
|
-
topic(name) {
|
|
113
|
-
return require_clone.cloneWith(this, { _name: name });
|
|
114
|
-
}
|
|
115
|
-
logger(logger) {
|
|
116
|
-
return require_clone.cloneWith(this, { _logger: logger });
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* The event contract — a map of event type → payload schema. Building the
|
|
120
|
-
* topic requires this; it's what types the publisher and subscribers.
|
|
121
|
-
*/
|
|
122
|
-
events(events) {
|
|
123
|
-
if (!this._name) throw new Error("Topic requires a name — call .topic(name) before .events().");
|
|
124
|
-
return new Topic(this._name, events, this._logger);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/topic/index.ts
|
|
129
|
-
const t = new TopicBuilder();
|
|
130
|
-
//#endregion
|
|
131
|
-
exports.Topic = Topic;
|
|
132
|
-
exports.TopicBuilder = TopicBuilder;
|
|
133
|
-
exports.t = t;
|
|
134
|
-
|
|
135
|
-
//# sourceMappingURL=index.cjs.map
|
|
2
|
+
const require_Topic = require("../Topic-Dp9Q7Lj2.cjs");
|
|
3
|
+
exports.Topic = require_Topic.Topic;
|
package/dist/topic/index.d.cts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { Topic, TopicBuilder, type TopicEvents, type TopicMessage, t };
|
|
1
|
+
import { c as Topic, d as TopicOptions, l as TopicEvents, u as TopicMessage } from "../Construct-127M7yrl.cjs";
|
|
2
|
+
export { Topic, type TopicEvents, type TopicMessage, type TopicOptions };
|
package/dist/topic/index.d.mts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { Topic, TopicBuilder, type TopicEvents, type TopicMessage, t };
|
|
1
|
+
import { c as Topic, d as TopicOptions, l as TopicEvents, u as TopicMessage } from "../Construct-DySlwh8o.mjs";
|
|
2
|
+
export { Topic, type TopicEvents, type TopicMessage, type TopicOptions };
|
package/dist/topic/index.mjs
CHANGED
|
@@ -1,132 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
|
|
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 {
|
|
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
|
-
};
|
|
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
|
-
return new Topic(this._name, events, this._logger);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/topic/index.ts
|
|
128
|
-
const t = new TopicBuilder();
|
|
129
|
-
//#endregion
|
|
130
|
-
export { Topic, TopicBuilder, t };
|
|
131
|
-
|
|
132
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import { t as Topic } from "../Topic-DN2gYJ-p.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"}
|