@geekmidas/constructs 10.0.0-alpha.1 → 10.0.0-alpha.100
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 +223 -158
- package/dist/{Construct-CdhThxDI.mjs → Construct-B1vGBPme.mjs} +45 -33
- package/dist/Construct-B1vGBPme.mjs.map +1 -0
- package/dist/Construct-BQALFCh2.d.cts +230 -0
- package/dist/Construct-BQALFCh2.d.cts.map +1 -0
- package/dist/{Construct-roId57cU.cjs → Construct-DUSXuTHP.cjs} +65 -47
- package/dist/Construct-DUSXuTHP.cjs.map +1 -0
- package/dist/Construct-QXnl3VqT.d.mts +230 -0
- package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
- package/dist/Cron-DI3nKoic.d.cts +45 -0
- package/dist/Cron-DI3nKoic.d.cts.map +1 -0
- package/dist/Cron-uYAHPnp7.d.mts +45 -0
- package/dist/Cron-uYAHPnp7.d.mts.map +1 -0
- package/dist/CronBuilder-C0Ek1-RA.cjs +121 -0
- package/dist/CronBuilder-C0Ek1-RA.cjs.map +1 -0
- package/dist/CronBuilder-DaSUm2Na.d.mts +47 -0
- package/dist/CronBuilder-DaSUm2Na.d.mts.map +1 -0
- package/dist/CronBuilder-Dmix_Pen.mjs +109 -0
- package/dist/CronBuilder-Dmix_Pen.mjs.map +1 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
- package/dist/{Endpoint-BTj58Gob.mjs → Endpoint-BG4UJ9oA.mjs} +146 -109
- package/dist/Endpoint-BG4UJ9oA.mjs.map +1 -0
- package/dist/{Endpoint-BBkV6l0k.cjs → Endpoint-BoUg8ocM.cjs} +174 -131
- package/dist/Endpoint-BoUg8ocM.cjs.map +1 -0
- package/dist/{Endpoint-BKR5QH6O.d.mts → Endpoint-Du-NwPX2.d.mts} +83 -91
- package/dist/Endpoint-Du-NwPX2.d.mts.map +1 -0
- package/dist/{Endpoint-BQ9O0P1w.d.cts → Endpoint-aCvBMPoH.d.cts} +82 -90
- package/dist/Endpoint-aCvBMPoH.d.cts.map +1 -0
- package/dist/{EndpointFactory-BejSTzbB.mjs → EndpointFactory-BDtsrEvJ.mjs} +60 -77
- package/dist/EndpointFactory-BDtsrEvJ.mjs.map +1 -0
- package/dist/{EndpointFactory-DYoGLaIT.cjs → EndpointFactory-DJ7gXLpR.cjs} +96 -113
- package/dist/EndpointFactory-DJ7gXLpR.cjs.map +1 -0
- package/dist/{index-D5zqAJ2e.d.cts → EndpointFactory-DMYdJCOj.d.mts} +78 -134
- package/dist/EndpointFactory-DMYdJCOj.d.mts.map +1 -0
- package/dist/{index-Cvz551AO.d.mts → EndpointFactory-I7s1co3Y.d.cts} +79 -135
- package/dist/EndpointFactory-I7s1co3Y.d.cts.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-7aYNdqJq.mjs → HonoEndpointAdaptor-PtPlbeKY.mjs} +75 -57
- package/dist/HonoEndpointAdaptor-PtPlbeKY.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-wMsCyMgt.cjs → HonoEndpointAdaptor-zVzVLJEO.cjs} +83 -62
- package/dist/HonoEndpointAdaptor-zVzVLJEO.cjs.map +1 -0
- package/dist/Queue-A3wfD0it.cjs +109 -0
- package/dist/Queue-A3wfD0it.cjs.map +1 -0
- package/dist/Queue-D6USGS4q.mjs +104 -0
- package/dist/Queue-D6USGS4q.mjs.map +1 -0
- package/dist/{Queue-D6WeziRD.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
- package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
- package/dist/{Queue-DpUeqdC8.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
- package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
- package/dist/QueueBuilder-BjuF0UBl.cjs +135 -0
- package/dist/QueueBuilder-BjuF0UBl.cjs.map +1 -0
- package/dist/QueueBuilder-Cue73M4t.mjs +118 -0
- package/dist/QueueBuilder-Cue73M4t.mjs.map +1 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
- package/dist/QueueBuilder-QHsnVt1P.d.mts +75 -0
- package/dist/QueueBuilder-QHsnVt1P.d.mts.map +1 -0
- package/dist/{Subscriber-4rBJgDKI.d.mts → Subscriber-Bpp02cGr.d.cts} +30 -21
- package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
- package/dist/{Subscriber-DVQowdyj.d.cts → Subscriber-CtN9R48-.d.mts} +29 -20
- package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
- package/dist/SubscriberBuilder-CDy4nHCz.mjs +134 -0
- package/dist/SubscriberBuilder-CDy4nHCz.mjs.map +1 -0
- package/dist/SubscriberBuilder-CuCMFpYW.d.mts +67 -0
- package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +1 -0
- package/dist/SubscriberBuilder-D_owVoHo.cjs +145 -0
- package/dist/SubscriberBuilder-D_owVoHo.cjs.map +1 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
- package/dist/Topic-D74b5cgs.mjs +99 -0
- package/dist/Topic-D74b5cgs.mjs.map +1 -0
- package/dist/Topic-GHxcU8AG.cjs +104 -0
- package/dist/Topic-GHxcU8AG.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +332 -188
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +114 -44
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +114 -44
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +308 -166
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +3 -11
- package/dist/adaptors/hono.d.cts +7 -16
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +8 -17
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +2 -11
- package/dist/adaptors/testing.cjs +743 -90
- 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 +706 -71
- 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-CcuceLYo.d.mts +268 -0
- package/dist/auth-CcuceLYo.d.mts.map +1 -0
- package/dist/auth.cjs +302 -34
- 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 +290 -28
- package/dist/auth.mjs.map +1 -1
- package/dist/{cache-CdQ7OLpR.d.cts → cache-CXh6GIgb.d.mts} +4 -7
- package/dist/cache-CXh6GIgb.d.mts.map +1 -0
- package/dist/{cache-DYoJFcfd.d.mts → cache-DnGDGly3.d.cts} +4 -7
- 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-BqwRNYA2.d.mts → construct-interface-B1AfqRl4.d.cts} +43 -12
- package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
- package/dist/{construct-interface-D2nNkHUN.d.cts → construct-interface-DluK3_da.d.mts} +43 -12
- package/dist/construct-interface-DluK3_da.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.cjs +77 -17
- package/dist/credential.cjs.map +1 -1
- package/dist/credential.d.cts +34 -9
- package/dist/credential.d.cts.map +1 -1
- package/dist/credential.d.mts +34 -9
- package/dist/credential.d.mts.map +1 -1
- package/dist/credential.mjs +71 -13
- package/dist/credential.mjs.map +1 -1
- package/dist/crons/index.cjs +189 -85
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +70 -48
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +70 -48
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +183 -81
- 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 +3 -7
- 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 +8 -11
- package/dist/endpoints/index.d.cts +51 -7
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +51 -7
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -11
- package/dist/external-api-MJ8id87V.d.mts +105 -0
- package/dist/external-api-MJ8id87V.d.mts.map +1 -0
- package/dist/external-api-O107yzZJ.d.cts +105 -0
- package/dist/external-api-O107yzZJ.d.cts.map +1 -0
- package/dist/external-api.cjs +142 -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 +139 -0
- package/dist/external-api.mjs.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 +2 -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-Cpff1uZH.mjs → functions-BFizikJU.mjs} +394 -243
- package/dist/functions-BFizikJU.mjs.map +1 -0
- package/dist/{functions-DukjG8ov.cjs → functions-CfzJG9hK.cjs} +432 -275
- package/dist/functions-CfzJG9hK.cjs.map +1 -0
- package/dist/index-BuzRvKOQ.d.cts +115 -0
- package/dist/index-BuzRvKOQ.d.cts.map +1 -0
- package/dist/index-CTkKOer4.d.mts +115 -0
- package/dist/index-CTkKOer4.d.mts.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-Bii4l6eP.mjs +370 -0
- package/dist/kysely-Bii4l6eP.mjs.map +1 -0
- package/dist/kysely-CO_Dk43W.cjs +383 -0
- package/dist/kysely-CO_Dk43W.cjs.map +1 -0
- package/dist/kysely-D0bpzgPs.d.cts +175 -0
- package/dist/kysely-D0bpzgPs.d.cts.map +1 -0
- package/dist/kysely-DUqC3Ie0.d.mts +175 -0
- package/dist/kysely-DUqC3Ie0.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/{lazyAccessors-DM6HcXQk.mjs → lazyAccessors-CFanua0O.mjs} +20 -21
- package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
- package/dist/{lazyAccessors-DrJj8NpA.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -62
- package/dist/lazyAccessors-hJKGv8Ay.cjs.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/processAudits-BRRVVHUB.mjs +131 -0
- package/dist/processAudits-BRRVVHUB.mjs.map +1 -0
- package/dist/processAudits-DasOZjPl.cjs +154 -0
- package/dist/processAudits-DasOZjPl.cjs.map +1 -0
- 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/rest-api.cjs +92 -63
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +81 -61
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +81 -61
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +84 -55
- 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 +35 -9
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +25 -22
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +25 -22
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +31 -5
- 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 +111 -101
- package/dist/subscribers/index.cjs.map +1 -1
- package/dist/subscribers/index.d.cts +44 -56
- package/dist/subscribers/index.d.cts.map +1 -1
- package/dist/subscribers/index.d.mts +44 -56
- package/dist/subscribers/index.d.mts.map +1 -1
- package/dist/subscribers/index.mjs +108 -98
- package/dist/subscribers/index.mjs.map +1 -1
- 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-DRtT1_0A.d.mts +40 -0
- package/dist/telemetry-DRtT1_0A.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 -32
- package/dist/topic/index.d.mts +2 -32
- package/dist/topic/index.mjs +2 -134
- package/dist/tracing-CxaZ98IB.mjs +110 -0
- package/dist/tracing-CxaZ98IB.mjs.map +1 -0
- package/dist/tracing-DPMidF_r.cjs +127 -0
- package/dist/tracing-DPMidF_r.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 +191 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +171 -0
- package/dist/worker.d.cts.map +1 -0
- package/dist/worker.d.mts +171 -0
- package/dist/worker.d.mts.map +1 -0
- package/dist/worker.mjs +190 -0
- package/dist/worker.mjs.map +1 -0
- package/package.json +116 -70
- package/dist/AWSScheduledFunction-9bJS4WdJ.d.cts +0 -122
- package/dist/AWSScheduledFunction-9bJS4WdJ.d.cts.map +0 -1
- package/dist/AWSScheduledFunction-BJjj8B5V.mjs +0 -243
- package/dist/AWSScheduledFunction-BJjj8B5V.mjs.map +0 -1
- package/dist/AWSScheduledFunction-BO5iEMSh.d.mts +0 -122
- package/dist/AWSScheduledFunction-BO5iEMSh.d.mts.map +0 -1
- package/dist/AWSScheduledFunction-qu4ieRZR.cjs +0 -255
- package/dist/AWSScheduledFunction-qu4ieRZR.cjs.map +0 -1
- package/dist/Construct-B-xc0SE9.d.mts +0 -104
- package/dist/Construct-B-xc0SE9.d.mts.map +0 -1
- package/dist/Construct-CdhThxDI.mjs.map +0 -1
- package/dist/Construct-WhCXIOPV.d.cts +0 -104
- package/dist/Construct-WhCXIOPV.d.cts.map +0 -1
- package/dist/Construct-roId57cU.cjs.map +0 -1
- package/dist/Endpoint-BBkV6l0k.cjs.map +0 -1
- package/dist/Endpoint-BKR5QH6O.d.mts.map +0 -1
- package/dist/Endpoint-BQ9O0P1w.d.cts.map +0 -1
- package/dist/Endpoint-BTj58Gob.mjs.map +0 -1
- package/dist/EndpointFactory-BejSTzbB.mjs.map +0 -1
- package/dist/EndpointFactory-DYoGLaIT.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-7aYNdqJq.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-wMsCyMgt.cjs.map +0 -1
- package/dist/Queue-D6WeziRD.d.cts.map +0 -1
- package/dist/Queue-DpUeqdC8.d.mts.map +0 -1
- package/dist/Subscriber-4rBJgDKI.d.mts.map +0 -1
- package/dist/Subscriber-DVQowdyj.d.cts.map +0 -1
- package/dist/Topic-Ohx9dvWr.d.cts +0 -91
- package/dist/Topic-Ohx9dvWr.d.cts.map +0 -1
- package/dist/Topic-cmy2jOUy.d.mts +0 -91
- package/dist/Topic-cmy2jOUy.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-CdQ7OLpR.d.cts.map +0 -1
- package/dist/cache-DYoJFcfd.d.mts.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-BqwRNYA2.d.mts.map +0 -1
- package/dist/construct-interface-D2nNkHUN.d.cts.map +0 -1
- package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
- package/dist/construct-interface-Z4CpS8tK.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-Cpff1uZH.mjs.map +0 -1
- package/dist/functions-DukjG8ov.cjs.map +0 -1
- package/dist/index-BTvozlUD.d.cts +0 -163
- package/dist/index-BTvozlUD.d.cts.map +0 -1
- package/dist/index-Cvz551AO.d.mts.map +0 -1
- package/dist/index-D5zqAJ2e.d.cts.map +0 -1
- package/dist/index-L7pz0R0T.d.mts +0 -162
- package/dist/index-L7pz0R0T.d.mts.map +0 -1
- package/dist/lazyAccessors-DM6HcXQk.mjs.map +0 -1
- package/dist/lazyAccessors-DrJj8NpA.cjs.map +0 -1
- package/dist/processAudits-Bc8rz6Ev.cjs +0 -92
- package/dist/processAudits-Bc8rz6Ev.cjs.map +0 -1
- package/dist/processAudits-D89tICM4.mjs +0 -80
- package/dist/processAudits-D89tICM4.mjs.map +0 -1
- package/dist/publisher-CGEo8UKD.mjs +0 -41
- package/dist/publisher-CGEo8UKD.mjs.map +0 -1
- package/dist/publisher-CqGsXB2X.cjs +0 -53
- package/dist/publisher-CqGsXB2X.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/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.d.cts.map +0 -1
- package/dist/topic/index.d.mts.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
|
@@ -1,106 +1,116 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/subscribers/SubscriberBuilder.ts
|
|
30
|
-
var SubscriberBuilder = class {
|
|
31
|
-
_subscribedEvents = [];
|
|
32
|
-
_timeout;
|
|
33
|
-
outputSchema;
|
|
34
|
-
_services = [];
|
|
35
|
-
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
36
|
-
_constructs = [];
|
|
37
|
-
_logger = DEFAULT_LOGGER;
|
|
38
|
-
_publisher;
|
|
39
|
-
_topicName;
|
|
40
|
-
constructor() {
|
|
41
|
-
this._timeout = 3e4;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Bind this subscriber to a {@link Topic} — the preferred way to type and wire
|
|
45
|
-
* a fan-out consumer. It supplies the subscribable event types (and their
|
|
46
|
-
* payloads) from the topic's contract and records the binding for the manifest,
|
|
47
|
-
* so infra wires the SNS subscription.
|
|
48
|
-
*
|
|
49
|
-
* Prefer this over typing via a hand-written publisher service: a consumer does
|
|
50
|
-
* not publish, so binding a topic does *not* require the topic's publisher
|
|
51
|
-
* connection string (least privilege). Use `.publisher(...)` only when the
|
|
52
|
-
* subscriber actually publishes follow-up events.
|
|
53
|
-
*/
|
|
54
|
-
topic(topic) {
|
|
55
|
-
return cloneWith(this, { _topicName: topic.name });
|
|
1
|
+
import { n as Subscriber, t as SubscriberBuilder } from "../SubscriberBuilder-CDy4nHCz.mjs";
|
|
2
|
+
import { n as subscribedEvents, r as subscriberContext, t as runSubscriber } from "../runSubscriber-BHvJ8POr.mjs";
|
|
3
|
+
import { carrierFromAttributes, consumeTraced } from "@geekmidas/events";
|
|
4
|
+
import { wrapError } from "@geekmidas/errors";
|
|
5
|
+
import { runWithRequestContext } from "@geekmidas/services";
|
|
6
|
+
import { confirmSnsSubscription, toSnsEvent, verifySnsMessage } from "@geekmidas/events/sns";
|
|
7
|
+
//#region src/subscribers/SnsPushSubscriberAdaptor.ts
|
|
8
|
+
/**
|
|
9
|
+
* A topic subscriber run by SNS pushing to an HTTP endpoint, rather than by a
|
|
10
|
+
* poller.
|
|
11
|
+
*
|
|
12
|
+
* The notification is read as the Lambda event SNS would have invoked a
|
|
13
|
+
* function with, and run through the same parsing, services and handler as the
|
|
14
|
+
* Lambda adaptor — without its middy wrapper, which is Lambda's alone: a
|
|
15
|
+
* server serving this route has no reason to install `@middy/core`.
|
|
16
|
+
*/
|
|
17
|
+
var SnsPushSubscriberAdaptor = class {
|
|
18
|
+
envParser;
|
|
19
|
+
subscriber;
|
|
20
|
+
options;
|
|
21
|
+
constructor(envParser, subscriber, options) {
|
|
22
|
+
this.envParser = envParser;
|
|
23
|
+
this.subscriber = subscriber;
|
|
24
|
+
this.options = options;
|
|
56
25
|
}
|
|
57
|
-
|
|
58
|
-
|
|
26
|
+
async handle(body) {
|
|
27
|
+
const message = body;
|
|
28
|
+
if (typeof message?.Type !== "string" || !message.TopicArn) return refuse(400, "not an SNS message");
|
|
29
|
+
if (message.TopicArn !== this.options.topicArn) return refuse(403, `not subscribed to ${message.TopicArn}`);
|
|
30
|
+
if (this.options.verify) try {
|
|
31
|
+
await verifySnsMessage(message);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
this.subscriber.logger.warn({
|
|
34
|
+
err: error,
|
|
35
|
+
topicArn: message.TopicArn
|
|
36
|
+
}, "Refused an SNS message that did not verify");
|
|
37
|
+
return refuse(403, error.name);
|
|
38
|
+
}
|
|
39
|
+
switch (message.Type) {
|
|
40
|
+
case "SubscriptionConfirmation":
|
|
41
|
+
await confirmSnsSubscription(this.options.emulatorEndpoint && message.SubscribeURL ? {
|
|
42
|
+
...message,
|
|
43
|
+
SubscribeURL: throughEndpoint(message.SubscribeURL, this.options.emulatorEndpoint)
|
|
44
|
+
} : message);
|
|
45
|
+
this.subscriber.logger.info({ topicArn: message.TopicArn }, "Confirmed SNS subscription");
|
|
46
|
+
return {
|
|
47
|
+
status: 200,
|
|
48
|
+
body: { status: "confirmed" }
|
|
49
|
+
};
|
|
50
|
+
case "Notification": try {
|
|
51
|
+
await this.notify(message);
|
|
52
|
+
return {
|
|
53
|
+
status: 200,
|
|
54
|
+
body: { status: "ok" }
|
|
55
|
+
};
|
|
56
|
+
} catch (error) {
|
|
57
|
+
return refuse(500, error.name);
|
|
58
|
+
}
|
|
59
|
+
default: return {
|
|
60
|
+
status: 200,
|
|
61
|
+
body: { status: "ignored" }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
59
64
|
}
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
async notify(message) {
|
|
66
|
+
const requestId = message.MessageId;
|
|
67
|
+
const logger = this.subscriber.logger.child({ requestId });
|
|
68
|
+
await runWithRequestContext({
|
|
69
|
+
logger,
|
|
70
|
+
requestId,
|
|
71
|
+
startTime: Date.now(),
|
|
72
|
+
operation: `subscriber ${this.subscriber.topicName ?? "sns"}`
|
|
73
|
+
}, () => consumeTraced({
|
|
74
|
+
system: "aws_sns",
|
|
75
|
+
destination: this.subscriber.topicName ?? message.TopicArn.split(":").pop() ?? message.TopicArn,
|
|
76
|
+
type: message.MessageAttributes?.type?.Value,
|
|
77
|
+
messageId: message.MessageId
|
|
78
|
+
}, carrierFromAttributes(message.MessageAttributes), () => this.run(message, logger)));
|
|
62
79
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
_services: [...this._services, ...services],
|
|
78
|
-
_constructs: idsOf(constructs, this._constructs)
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
services(services) {
|
|
82
|
-
return cloneWith(this, { _services: [...this._services, ...services] });
|
|
83
|
-
}
|
|
84
|
-
logger(logger) {
|
|
85
|
-
return cloneWith(this, { _logger: logger });
|
|
86
|
-
}
|
|
87
|
-
publisher(publisher) {
|
|
88
|
-
return cloneWith(this, { _publisher: publisher });
|
|
89
|
-
}
|
|
90
|
-
subscribe(event) {
|
|
91
|
-
const eventsToAdd = Array.isArray(event) ? event : [event];
|
|
92
|
-
return cloneWith(this, { _subscribedEvents: [...this._subscribedEvents, ...eventsToAdd] });
|
|
93
|
-
}
|
|
94
|
-
handle(fn) {
|
|
95
|
-
const subscriber = new Subscriber(fn, this._timeout, this._subscribedEvents, this.outputSchema, this._services, this._logger, this._publisher, this._topicName, this._constructs);
|
|
96
|
-
return subscriber;
|
|
80
|
+
async run(message, logger) {
|
|
81
|
+
try {
|
|
82
|
+
const { services, db } = await subscriberContext(this.subscriber, this.envParser);
|
|
83
|
+
const events = subscribedEvents(this.subscriber, toSnsEvent(message), logger);
|
|
84
|
+
await runSubscriber(this.subscriber, {
|
|
85
|
+
events,
|
|
86
|
+
services,
|
|
87
|
+
logger,
|
|
88
|
+
db
|
|
89
|
+
});
|
|
90
|
+
} catch (error) {
|
|
91
|
+
logger.error(error, "Error processing subscriber");
|
|
92
|
+
throw wrapError(error);
|
|
93
|
+
}
|
|
97
94
|
}
|
|
98
95
|
};
|
|
99
|
-
|
|
96
|
+
/** `url`, sent to `endpoint`'s origin instead of its own. */
|
|
97
|
+
function throughEndpoint(url, endpoint) {
|
|
98
|
+
const target = new URL(url);
|
|
99
|
+
const origin = new URL(endpoint);
|
|
100
|
+
target.protocol = origin.protocol;
|
|
101
|
+
target.host = origin.host;
|
|
102
|
+
return target.toString();
|
|
103
|
+
}
|
|
104
|
+
function refuse(status, error) {
|
|
105
|
+
return {
|
|
106
|
+
status,
|
|
107
|
+
body: {
|
|
108
|
+
status: "refused",
|
|
109
|
+
error
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
100
113
|
//#endregion
|
|
101
|
-
|
|
102
|
-
const s = new SubscriberBuilder();
|
|
114
|
+
export { SnsPushSubscriberAdaptor, Subscriber, SubscriberBuilder };
|
|
103
115
|
|
|
104
|
-
//#endregion
|
|
105
|
-
export { Subscriber, SubscriberBuilder, s };
|
|
106
116
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["obj: any","handler: SubscriberHandler<\n\t\t\tTEventPublisher,\n\t\t\tTSubscribedEvents,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema\n\t\t>","timeout: number","_subscribedEvents?: TSubscribedEvents","outputSchema?: OutSchema","services: TServices","logger: TLogger","publisherService?: Service<\n\t\t\tTEventPublisherServiceName,\n\t\t\tTEventPublisher\n\t\t>","topicName?: string","constructs: string[]","topic: Topic<TName, TEvents>","timeout: number","schema: T","constructs: T","services: T","logger: T","publisher: Service<TName, T>","event: TEvent","fn: SubscriberHandler<\n\t\t\tTEventPublisher,\n\t\t\tTSubscribedEvents,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema\n\t\t>"],"sources":["../../src/subscribers/Subscriber.ts","../../src/subscribers/SubscriberBuilder.ts","../../src/subscribers/index.ts"],"sourcesContent":["import type {\n\tEventPublisher,\n\tExtractPublisherMessage,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\n// Helper type to extract payload types for subscribed events\ntype ExtractEventPayloads<\n\tTPublisher extends EventPublisher<any> | undefined,\n\tTEventTypes extends any[],\n> = TPublisher extends EventPublisher<any>\n\t? Extract<ExtractPublisherMessage<TPublisher>, { type: TEventTypes[number] }>\n\t: never;\n\nexport class Subscriber<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTSubscribedEvents extends\n\t\tExtractPublisherMessage<TEventPublisher>['type'][] = ExtractPublisherMessage<TEventPublisher>['type'][],\n> extends Construct<\n\tTLogger,\n\tTEventPublisherServiceName,\n\tTEventPublisher,\n\tOutSchema,\n\tTServices\n> {\n\t__IS_SUBSCRIBER__ = true;\n\n\tstatic isSubscriber(\n\t\tobj: any,\n\t): obj is Subscriber<any, any, any, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\tobj.__IS_SUBSCRIBER__ === true &&\n\t\t\t\tobj.type === ConstructType.Subscriber,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tpublic readonly handler: SubscriberHandler<\n\t\t\tTEventPublisher,\n\t\t\tTSubscribedEvents,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema\n\t\t>,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tprotected _subscribedEvents?: TSubscribedEvents,\n\t\tpublic override readonly outputSchema?: OutSchema,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\tpublic override readonly publisherService?: Service<\n\t\t\tTEventPublisherServiceName,\n\t\t\tTEventPublisher\n\t\t>,\n\t\t/**\n\t\t * The name of the {@link Topic} this subscriber binds to (via\n\t\t * `s.topic(topic)`), recorded for the manifest so infra wires the SNS\n\t\t * subscription. Undefined when the subscriber's events are typed from a\n\t\t * (hand-written) publisher instead.\n\t\t */\n\t\tpublic readonly topicName?: string,\n\t\t/**\n\t\t * The construct ids `.dependsOn()` named — last, so no existing positional\n\t\t * argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Subscriber,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tpublisherService,\n\t\t\toutputSchema,\n\t\t\ttimeout,\n\t\t\tundefined, // memorySize\n\t\t\tundefined, // auditorStorageService\n\t\t\tconstructs,\n\t\t);\n\t}\n\n\tget subscribedEvents(): TSubscribedEvents | undefined {\n\t\treturn this._subscribedEvents;\n\t}\n}\n\n// Handler type for subscribers that receives an array of events\nexport type SubscriberHandler<\n\tTEventPublisher extends EventPublisher<any> | undefined,\n\tTSubscribedEvents extends ExtractPublisherMessage<TEventPublisher>['type'][],\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n> = (\n\tctx: SubscriberContext<\n\t\tTEventPublisher,\n\t\tTSubscribedEvents,\n\t\tTServices,\n\t\tTLogger\n\t>,\n) => OutSchema extends StandardSchemaV1\n\t? InferStandardSchema<OutSchema> | Promise<InferStandardSchema<OutSchema>>\n\t: any | Promise<any>;\n\n// Context type for subscriber handlers\nexport type SubscriberContext<\n\tTEventPublisher extends EventPublisher<any> | undefined,\n\tTSubscribedEvents extends ExtractPublisherMessage<TEventPublisher>['type'][],\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tevents: ExtractEventPayloads<TEventPublisher, TSubscribedEvents>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n","import type {\n\tEventPublisher,\n\tExtractPublisherMessage,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport type { Topic, TopicEvents, TopicMessage } from '../topic/Topic';\nimport { Subscriber, type SubscriberHandler } from './Subscriber';\n\nexport class SubscriberBuilder<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTSubscribedEvents extends any[] = [],\n> {\n\tprivate _subscribedEvents: TSubscribedEvents = [] as any;\n\tprivate _timeout?: number;\n\tprivate outputSchema?: OutSchema;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER;\n\tprivate _publisher?: Service<TEventPublisherServiceName, TEventPublisher>;\n\tprivate _topicName?: string;\n\n\tconstructor() {\n\t\tthis._timeout = 30000; // Default timeout\n\t}\n\n\t/**\n\t * Bind this subscriber to a {@link Topic} — the preferred way to type and wire\n\t * a fan-out consumer. It supplies the subscribable event types (and their\n\t * payloads) from the topic's contract and records the binding for the manifest,\n\t * so infra wires the SNS subscription.\n\t *\n\t * Prefer this over typing via a hand-written publisher service: a consumer does\n\t * not publish, so binding a topic does *not* require the topic's publisher\n\t * connection string (least privilege). Use `.publisher(...)` only when the\n\t * subscriber actually publishes follow-up events.\n\t */\n\ttopic<TName extends string, TEvents extends TopicEvents>(\n\t\ttopic: Topic<TName, TEvents>,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tEventPublisher<TopicMessage<TEvents>>,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_topicName: topic.name,\n\t\t}) as unknown as SubscriberBuilder<\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tEventPublisher<TopicMessage<TEvents>>,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTSubscribedEvents\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\toutput<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tTLogger,\n\t\tT,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\toutputSchema: schema as unknown as OutSchema,\n\t\t}) as any;\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): SubscriberBuilder<\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as SubscriberBuilder<\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTSubscribedEvents\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): SubscriberBuilder<\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as any,\n\t\t}) as any;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tT,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, { _logger: logger as unknown as TLogger }) as any;\n\t}\n\n\tpublisher<T extends EventPublisher<any>, TName extends string>(\n\t\tpublisher: Service<TName, T>,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tT,\n\t\tTName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, { _publisher: publisher as any }) as any;\n\t}\n\n\tsubscribe<\n\t\tTEvent extends TEventPublisher extends EventPublisher<any>\n\t\t\t?\n\t\t\t\t\t| ExtractPublisherMessage<TEventPublisher>['type']\n\t\t\t\t\t| ExtractPublisherMessage<TEventPublisher>['type'][]\n\t\t\t: never,\n\t>(\n\t\tevent: TEvent,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTEvent extends any[]\n\t\t\t? [...TSubscribedEvents, ...TEvent]\n\t\t\t: [...TSubscribedEvents, TEvent]\n\t> {\n\t\tconst eventsToAdd = Array.isArray(event) ? event : [event];\n\t\treturn cloneWith(this, {\n\t\t\t_subscribedEvents: [...this._subscribedEvents, ...eventsToAdd] as any,\n\t\t}) as any;\n\t}\n\n\thandle(\n\t\tfn: SubscriberHandler<\n\t\t\tTEventPublisher,\n\t\t\tTSubscribedEvents,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema\n\t\t>,\n\t): Subscriber<\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\tconst subscriber = new Subscriber(\n\t\t\tfn,\n\t\t\tthis._timeout,\n\t\t\tthis._subscribedEvents,\n\t\t\tthis.outputSchema,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._publisher,\n\t\t\tthis._topicName,\n\t\t\tthis._constructs,\n\t\t);\n\n\t\t// No reset: `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base stays usable for the next subscriber.\n\t\treturn subscriber;\n\t}\n}\n","import { SubscriberBuilder } from './SubscriberBuilder';\n\nexport { Subscriber } from './Subscriber';\nexport { SubscriberBuilder };\n\nexport const s = new SubscriberBuilder();\n"],"mappings":";;;;;;AAmBA,IAAa,aAAb,cAQU,UAMR;CACD,oBAAoB;CAEpB,OAAO,aACNA,KACkD;AAClD,SAAO,QACN,OACC,IAAI,sBAAsB,QAC1B,IAAI,SAAS,cAAc,WAC5B;CACD;CAED,YACiBC,SAOSC,UAAkB,KACjCC,mBACeC,cACAC,WAAsB,CAAE,GACxBC,SAAkB,gBAClBC,kBAUTC,WAKhBC,aAAuB,CAAE,GACxB;AACD,QACC,cAAc,YACd,QACA,UACA,CAAE,GACF,kBACA,cACA,yBAGA,WACA;EAxCe;EAOS;EACf;EACe;EACA;EACA;EACA;EAUT;CAmBhB;CAED,IAAI,mBAAkD;AACrD,SAAO,KAAK;CACZ;AACD;;;;AC3ED,IAAa,oBAAb,MAOE;CACD,AAAQ,oBAAuC,CAAE;CACjD,AAAQ;CACR,AAAQ;CACR,AAAQ,YAAuB,CAAE;;CAEjC,AAAO,cAAwB,CAAE;CACjC,AAAQ,UAAmB;CAC3B,AAAQ;CACR,AAAQ;CAER,cAAc;AACb,OAAK,WAAW;CAChB;;;;;;;;;;;;CAaD,MACCC,OAQC;AACD,SAAO,UAAU,MAAM,EACtB,YAAY,MAAM,KAClB,EAAC;CAQF;CAED,QAAQC,SAAuB;AAC9B,SAAO,UAAU,MAAM,EAAE,UAAU,QAAS,EAAC;CAC7C;CAED,OACCC,QAQC;AACD,SAAO,UAAU,MAAM,EACtB,cAAc,OACd,EAAC;CACF;;;;;;;;;;;;CAaD,UACCC,YAQC;EAQD,MAAM,WAAW,WAAW,WAAW;AAEvC,SAAO,UAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS;GAC3C,aAAa,MAAM,YAAY,KAAK,YAAY;EAChD,EAAC;CAQF;CAED,SACCC,UAQC;AACD,SAAO,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,EAC3C,EAAC;CACF;CAED,OACCC,QAQC;AACD,SAAO,UAAU,MAAM,EAAE,SAAS,OAA8B,EAAC;CACjE;CAED,UACCC,WAQC;AACD,SAAO,UAAU,MAAM,EAAE,YAAY,UAAkB,EAAC;CACxD;CAED,UAOCC,OAUC;EACD,MAAM,cAAc,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,KAAM;AAC1D,SAAO,UAAU,MAAM,EACtB,mBAAmB,CAAC,GAAG,KAAK,mBAAmB,GAAG,WAAY,EAC9D,EAAC;CACF;CAED,OACCC,IAcC;EACD,MAAM,aAAa,IAAI,WACtB,IACA,KAAK,UACL,KAAK,mBACL,KAAK,cACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,YACL,KAAK;AAKN,SAAO;CACP;AACD;;;;ACnOD,MAAa,IAAI,IAAI"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/subscribers/SnsPushSubscriberAdaptor.ts"],"sourcesContent":["import type { EnvironmentParser } from '@geekmidas/envkit';\nimport { wrapError } from '@geekmidas/errors';\nimport { carrierFromAttributes, consumeTraced } from '@geekmidas/events';\nimport {\n\tconfirmSnsSubscription,\n\ttype SnsHttpMessage,\n\ttoSnsEvent,\n\tverifySnsMessage,\n} from '@geekmidas/events/sns';\nimport { runWithRequestContext } from '@geekmidas/services';\nimport {\n\trunSubscriber,\n\tsubscribedEvents,\n\tsubscriberContext,\n} from './runSubscriber';\nimport type { Subscriber } from './Subscriber';\n\nexport interface SnsPushOptions {\n\t/** The topic this subscriber is subscribed to. Anything else is refused. */\n\ttopicArn: string;\n\t/**\n\t * Verify each message's signature. Off only against an emulator, which\n\t * signs nothing — decided by the connection string's endpoint, never by\n\t * anything the request says about itself.\n\t */\n\tverify: boolean;\n\t/**\n\t * The emulator's address, as this server was configured with it. An\n\t * emulator names itself in `SubscribeURL` by the port it listens on inside\n\t * its container, which is not the port published to the host — so against\n\t * one, the confirmation is sent here instead. From configuration, never\n\t * from the request.\n\t */\n\temulatorEndpoint?: string;\n}\n\n/** What to answer SNS with. A non-2xx tells SNS to retry. */\nexport interface SnsPushResponse {\n\tstatus: 200 | 400 | 403 | 500;\n\tbody: { status: string; error?: string };\n}\n\n/**\n * A topic subscriber run by SNS pushing to an HTTP endpoint, rather than by a\n * poller.\n *\n * The notification is read as the Lambda event SNS would have invoked a\n * function with, and run through the same parsing, services and handler as the\n * Lambda adaptor — without its middy wrapper, which is Lambda's alone: a\n * server serving this route has no reason to install `@middy/core`.\n */\nexport class SnsPushSubscriberAdaptor {\n\tconstructor(\n\t\tprivate readonly envParser: EnvironmentParser<{}>,\n\t\treadonly subscriber: Subscriber<any, any, any, any, any, any, any>,\n\t\tprivate readonly options: SnsPushOptions,\n\t) {}\n\n\tasync handle(body: unknown): Promise<SnsPushResponse> {\n\t\tconst message = body as SnsHttpMessage;\n\t\tif (typeof message?.Type !== 'string' || !message.TopicArn) {\n\t\t\treturn refuse(400, 'not an SNS message');\n\t\t}\n\t\t// Checked before the signature: a genuine message for another topic is\n\t\t// still not this subscriber's to confirm or to handle.\n\t\tif (message.TopicArn !== this.options.topicArn) {\n\t\t\treturn refuse(403, `not subscribed to ${message.TopicArn}`);\n\t\t}\n\n\t\tif (this.options.verify) {\n\t\t\ttry {\n\t\t\t\tawait verifySnsMessage(message);\n\t\t\t} catch (error) {\n\t\t\t\tthis.subscriber.logger.warn(\n\t\t\t\t\t{ err: error, topicArn: message.TopicArn },\n\t\t\t\t\t'Refused an SNS message that did not verify',\n\t\t\t\t);\n\t\t\t\treturn refuse(403, (error as Error).name);\n\t\t\t}\n\t\t}\n\n\t\tswitch (message.Type) {\n\t\t\tcase 'SubscriptionConfirmation':\n\t\t\t\tawait confirmSnsSubscription(\n\t\t\t\t\tthis.options.emulatorEndpoint && message.SubscribeURL\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...message,\n\t\t\t\t\t\t\t\tSubscribeURL: throughEndpoint(\n\t\t\t\t\t\t\t\t\tmessage.SubscribeURL,\n\t\t\t\t\t\t\t\t\tthis.options.emulatorEndpoint,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: message,\n\t\t\t\t);\n\t\t\t\tthis.subscriber.logger.info(\n\t\t\t\t\t{ topicArn: message.TopicArn },\n\t\t\t\t\t'Confirmed SNS subscription',\n\t\t\t\t);\n\t\t\t\treturn { status: 200, body: { status: 'confirmed' } };\n\t\t\tcase 'Notification':\n\t\t\t\ttry {\n\t\t\t\t\tawait this.notify(message);\n\t\t\t\t\treturn { status: 200, body: { status: 'ok' } };\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Already logged. A 500 makes SNS retry, which is the point of\n\t\t\t\t\t// answering at all.\n\t\t\t\t\treturn refuse(500, (error as Error).name);\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn { status: 200, body: { status: 'ignored' } };\n\t\t}\n\t}\n\n\tprivate async notify(message: SnsHttpMessage): Promise<void> {\n\t\tconst requestId = message.MessageId;\n\t\tconst logger = this.subscriber.logger.child({ requestId });\n\n\t\tawait runWithRequestContext(\n\t\t\t{\n\t\t\t\tlogger,\n\t\t\t\trequestId,\n\t\t\t\tstartTime: Date.now(),\n\t\t\t\toperation: `subscriber ${this.subscriber.topicName ?? 'sns'}`,\n\t\t\t},\n\t\t\t// A CONSUMER span, child of the publisher's: SNS hands the trace\n\t\t\t// context on in the message attributes it was published with.\n\t\t\t() =>\n\t\t\t\tconsumeTraced(\n\t\t\t\t\t{\n\t\t\t\t\t\tsystem: 'aws_sns',\n\t\t\t\t\t\tdestination:\n\t\t\t\t\t\t\tthis.subscriber.topicName ??\n\t\t\t\t\t\t\tmessage.TopicArn.split(':').pop() ??\n\t\t\t\t\t\t\tmessage.TopicArn,\n\t\t\t\t\t\ttype: message.MessageAttributes?.type?.Value,\n\t\t\t\t\t\tmessageId: message.MessageId,\n\t\t\t\t\t},\n\t\t\t\t\tcarrierFromAttributes(message.MessageAttributes),\n\t\t\t\t\t() => this.run(message, logger),\n\t\t\t\t),\n\t\t);\n\t}\n\n\tprivate async run(\n\t\tmessage: SnsHttpMessage,\n\t\tlogger: Subscriber<any, any, any, any, any, any, any>['logger'],\n\t): Promise<void> {\n\t\ttry {\n\t\t\tconst { services, db } = await subscriberContext(\n\t\t\t\tthis.subscriber,\n\t\t\t\tthis.envParser,\n\t\t\t);\n\t\t\tconst events = subscribedEvents(\n\t\t\t\tthis.subscriber,\n\t\t\t\ttoSnsEvent(message),\n\t\t\t\tlogger,\n\t\t\t);\n\t\t\tawait runSubscriber(this.subscriber, {\n\t\t\t\tevents,\n\t\t\t\tservices,\n\t\t\t\tlogger,\n\t\t\t\tdb,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlogger.error(error as object, 'Error processing subscriber');\n\t\t\tthrow wrapError(error);\n\t\t}\n\t}\n}\n\n/** `url`, sent to `endpoint`'s origin instead of its own. */\nfunction throughEndpoint(url: string, endpoint: string): string {\n\tconst target = new URL(url);\n\tconst origin = new URL(endpoint);\n\ttarget.protocol = origin.protocol;\n\ttarget.host = origin.host;\n\treturn target.toString();\n}\n\nfunction refuse(\n\tstatus: SnsPushResponse['status'],\n\terror: string,\n): SnsPushResponse {\n\treturn { status, body: { status: 'refused', error } };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmDA,IAAa,2BAAb,MAAsC;CAEnB;CACR;CACQ;CAHlB,YACC,WACA,YACA,SACC;EAHgB,KAAA,YAAA;EACR,KAAA,aAAA;EACQ,KAAA,UAAA;CACf;CAEH,MAAM,OAAO,MAAyC;EACrD,MAAM,UAAU;EAChB,IAAI,OAAO,SAAS,SAAS,YAAY,CAAC,QAAQ,UACjD,OAAO,OAAO,KAAK,oBAAoB;EAIxC,IAAI,QAAQ,aAAa,KAAK,QAAQ,UACrC,OAAO,OAAO,KAAK,qBAAqB,QAAQ,UAAU;EAG3D,IAAI,KAAK,QAAQ,QAChB,IAAI;GACH,MAAM,iBAAiB,OAAO;EAC/B,SAAS,OAAO;GACf,KAAK,WAAW,OAAO,KACtB;IAAE,KAAK;IAAO,UAAU,QAAQ;GAAS,GACzC,4CACD;GACA,OAAO,OAAO,KAAM,MAAgB,IAAI;EACzC;EAGD,QAAQ,QAAQ,MAAhB;GACC,KAAK;IACJ,MAAM,uBACL,KAAK,QAAQ,oBAAoB,QAAQ,eACtC;KACA,GAAG;KACH,cAAc,gBACb,QAAQ,cACR,KAAK,QAAQ,gBACd;IACD,IACC,OACJ;IACA,KAAK,WAAW,OAAO,KACtB,EAAE,UAAU,QAAQ,SAAS,GAC7B,4BACD;IACA,OAAO;KAAE,QAAQ;KAAK,MAAM,EAAE,QAAQ,YAAY;IAAE;GACrD,KAAK,gBACJ,IAAI;IACH,MAAM,KAAK,OAAO,OAAO;IACzB,OAAO;KAAE,QAAQ;KAAK,MAAM,EAAE,QAAQ,KAAK;IAAE;GAC9C,SAAS,OAAO;IAGf,OAAO,OAAO,KAAM,MAAgB,IAAI;GACzC;GACD,SACC,OAAO;IAAE,QAAQ;IAAK,MAAM,EAAE,QAAQ,UAAU;GAAE;EACpD;CACD;CAEA,MAAc,OAAO,SAAwC;EAC5D,MAAM,YAAY,QAAQ;EAC1B,MAAM,SAAS,KAAK,WAAW,OAAO,MAAM,EAAE,UAAU,CAAC;EAEzD,MAAM,sBACL;GACC;GACA;GACA,WAAW,KAAK,IAAI;GACpB,WAAW,cAAc,KAAK,WAAW,aAAa;EACvD,SAIC,cACC;GACC,QAAQ;GACR,aACC,KAAK,WAAW,aAChB,QAAQ,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,KAChC,QAAQ;GACT,MAAM,QAAQ,mBAAmB,MAAM;GACvC,WAAW,QAAQ;EACpB,GACA,sBAAsB,QAAQ,iBAAiB,SACzC,KAAK,IAAI,SAAS,MAAM,CAC/B,CACF;CACD;CAEA,MAAc,IACb,SACA,QACgB;EAChB,IAAI;GACH,MAAM,EAAE,UAAU,OAAO,MAAM,kBAC9B,KAAK,YACL,KAAK,SACN;GACA,MAAM,SAAS,iBACd,KAAK,YACL,WAAW,OAAO,GAClB,MACD;GACA,MAAM,cAAc,KAAK,YAAY;IACpC;IACA;IACA;IACA;GACD,CAAC;EACF,SAAS,OAAO;GACf,OAAO,MAAM,OAAiB,6BAA6B;GAC3D,MAAM,UAAU,KAAK;EACtB;CACD;AACD;;AAGA,SAAS,gBAAgB,KAAa,UAA0B;CAC/D,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,SAAS,IAAI,IAAI,QAAQ;CAC/B,OAAO,WAAW,OAAO;CACzB,OAAO,OAAO,OAAO;CACrB,OAAO,OAAO,SAAS;AACxB;AAEA,SAAS,OACR,QACA,OACkB;CAClB,OAAO;EAAE;EAAQ,MAAM;GAAE,QAAQ;GAAW;EAAM;CAAE;AACrD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
let _geekmidas_envkit = require("@geekmidas/envkit");
|
|
2
|
+
let _geekmidas_envkit_credentials = require("@geekmidas/envkit/credentials");
|
|
3
|
+
//#region src/endpoints/surfaceEnv.ts
|
|
4
|
+
/**
|
|
5
|
+
* The environment parser an endpoint runs with.
|
|
6
|
+
*
|
|
7
|
+
* Three facts, in order:
|
|
8
|
+
*
|
|
9
|
+
* 1. An endpoint built from a surface carries whatever parser that surface was
|
|
10
|
+
* given. This is the whole point of `api.get()` — the handler already has
|
|
11
|
+
* the thing, so nothing has to be named in config and nothing has to be
|
|
12
|
+
* printed into generated code.
|
|
13
|
+
* 2. A surface that named none gets this default, which is what every
|
|
14
|
+
* application's own `config/env.ts` was: `process.env` merged with the
|
|
15
|
+
* credentials `gkm dev`/`gkm exec` injected. It was boilerplate identical in
|
|
16
|
+
* every project, and mandatory, which is a poor combination.
|
|
17
|
+
* 3. An endpoint with no surface at all — a test, an MSW handler — gets the
|
|
18
|
+
* same default. Nothing has to opt in.
|
|
19
|
+
*
|
|
20
|
+
* Named a parser only when it is genuinely different: a merged secret source, a
|
|
21
|
+
* fixture, a parser that reads from somewhere other than the process.
|
|
22
|
+
*/
|
|
23
|
+
let fallback;
|
|
24
|
+
/**
|
|
25
|
+
* The default parser, built once.
|
|
26
|
+
*
|
|
27
|
+
* Once because `Credentials` resolves through `globalThis` and decryption is
|
|
28
|
+
* not free, and because two parsers over the same environment are two caches of
|
|
29
|
+
* the same answer.
|
|
30
|
+
*/
|
|
31
|
+
function defaultEnvParser() {
|
|
32
|
+
if (!fallback) fallback = new _geekmidas_envkit.EnvironmentParser({
|
|
33
|
+
...process.env,
|
|
34
|
+
..._geekmidas_envkit_credentials.Credentials
|
|
35
|
+
});
|
|
36
|
+
return fallback;
|
|
37
|
+
}
|
|
38
|
+
/** The parser for an endpoint, from its surface or the default. */
|
|
39
|
+
function envParserFor(surface) {
|
|
40
|
+
return surface?.envParser ?? defaultEnvParser();
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
Object.defineProperty(exports, "defaultEnvParser", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function() {
|
|
46
|
+
return defaultEnvParser;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "envParserFor", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function() {
|
|
52
|
+
return envParserFor;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=surfaceEnv-CNimK76p.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surfaceEnv-CNimK76p.cjs","names":["EnvironmentParser","Credentials"],"sources":["../src/endpoints/surfaceEnv.ts"],"sourcesContent":["/**\n * The environment parser an endpoint runs with.\n *\n * Three facts, in order:\n *\n * 1. An endpoint built from a surface carries whatever parser that surface was\n * given. This is the whole point of `api.get()` — the handler already has\n * the thing, so nothing has to be named in config and nothing has to be\n * printed into generated code.\n * 2. A surface that named none gets this default, which is what every\n * application's own `config/env.ts` was: `process.env` merged with the\n * credentials `gkm dev`/`gkm exec` injected. It was boilerplate identical in\n * every project, and mandatory, which is a poor combination.\n * 3. An endpoint with no surface at all — a test, an MSW handler — gets the\n * same default. Nothing has to opt in.\n *\n * Named a parser only when it is genuinely different: a merged secret source, a\n * fixture, a parser that reads from somewhere other than the process.\n */\n\nimport { EnvironmentParser } from '@geekmidas/envkit';\nimport { Credentials } from '@geekmidas/envkit/credentials';\nimport type { EndpointSurface } from './Endpoint';\n\nlet fallback: EnvironmentParser<{}> | undefined;\n\n/**\n * The default parser, built once.\n *\n * Once because `Credentials` resolves through `globalThis` and decryption is\n * not free, and because two parsers over the same environment are two caches of\n * the same answer.\n */\nexport function defaultEnvParser(): EnvironmentParser<{}> {\n\tif (!fallback) {\n\t\tfallback = new EnvironmentParser({ ...process.env, ...Credentials });\n\t}\n\n\treturn fallback;\n}\n\n/** The parser for an endpoint, from its surface or the default. */\nexport function envParserFor(\n\tsurface: EndpointSurface | undefined,\n): EnvironmentParser<{}> {\n\treturn surface?.envParser ?? defaultEnvParser();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAI;;;;;;;;AASJ,SAAgB,mBAA0C;CACzD,IAAI,CAAC,UACJ,WAAW,IAAIA,kBAAAA,kBAAkB;EAAE,GAAG,QAAQ;EAAK,GAAGC,8BAAAA;CAAY,CAAC;CAGpE,OAAO;AACR;;AAGA,SAAgB,aACf,SACwB;CACxB,OAAO,SAAS,aAAa,iBAAiB;AAC/C"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
2
|
+
import { Credentials } from "@geekmidas/envkit/credentials";
|
|
3
|
+
//#region src/endpoints/surfaceEnv.ts
|
|
4
|
+
/**
|
|
5
|
+
* The environment parser an endpoint runs with.
|
|
6
|
+
*
|
|
7
|
+
* Three facts, in order:
|
|
8
|
+
*
|
|
9
|
+
* 1. An endpoint built from a surface carries whatever parser that surface was
|
|
10
|
+
* given. This is the whole point of `api.get()` — the handler already has
|
|
11
|
+
* the thing, so nothing has to be named in config and nothing has to be
|
|
12
|
+
* printed into generated code.
|
|
13
|
+
* 2. A surface that named none gets this default, which is what every
|
|
14
|
+
* application's own `config/env.ts` was: `process.env` merged with the
|
|
15
|
+
* credentials `gkm dev`/`gkm exec` injected. It was boilerplate identical in
|
|
16
|
+
* every project, and mandatory, which is a poor combination.
|
|
17
|
+
* 3. An endpoint with no surface at all — a test, an MSW handler — gets the
|
|
18
|
+
* same default. Nothing has to opt in.
|
|
19
|
+
*
|
|
20
|
+
* Named a parser only when it is genuinely different: a merged secret source, a
|
|
21
|
+
* fixture, a parser that reads from somewhere other than the process.
|
|
22
|
+
*/
|
|
23
|
+
let fallback;
|
|
24
|
+
/**
|
|
25
|
+
* The default parser, built once.
|
|
26
|
+
*
|
|
27
|
+
* Once because `Credentials` resolves through `globalThis` and decryption is
|
|
28
|
+
* not free, and because two parsers over the same environment are two caches of
|
|
29
|
+
* the same answer.
|
|
30
|
+
*/
|
|
31
|
+
function defaultEnvParser() {
|
|
32
|
+
if (!fallback) fallback = new EnvironmentParser({
|
|
33
|
+
...process.env,
|
|
34
|
+
...Credentials
|
|
35
|
+
});
|
|
36
|
+
return fallback;
|
|
37
|
+
}
|
|
38
|
+
/** The parser for an endpoint, from its surface or the default. */
|
|
39
|
+
function envParserFor(surface) {
|
|
40
|
+
return surface?.envParser ?? defaultEnvParser();
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { envParserFor as n, defaultEnvParser as t };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=surfaceEnv-wMT5QzgZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surfaceEnv-wMT5QzgZ.mjs","names":[],"sources":["../src/endpoints/surfaceEnv.ts"],"sourcesContent":["/**\n * The environment parser an endpoint runs with.\n *\n * Three facts, in order:\n *\n * 1. An endpoint built from a surface carries whatever parser that surface was\n * given. This is the whole point of `api.get()` — the handler already has\n * the thing, so nothing has to be named in config and nothing has to be\n * printed into generated code.\n * 2. A surface that named none gets this default, which is what every\n * application's own `config/env.ts` was: `process.env` merged with the\n * credentials `gkm dev`/`gkm exec` injected. It was boilerplate identical in\n * every project, and mandatory, which is a poor combination.\n * 3. An endpoint with no surface at all — a test, an MSW handler — gets the\n * same default. Nothing has to opt in.\n *\n * Named a parser only when it is genuinely different: a merged secret source, a\n * fixture, a parser that reads from somewhere other than the process.\n */\n\nimport { EnvironmentParser } from '@geekmidas/envkit';\nimport { Credentials } from '@geekmidas/envkit/credentials';\nimport type { EndpointSurface } from './Endpoint';\n\nlet fallback: EnvironmentParser<{}> | undefined;\n\n/**\n * The default parser, built once.\n *\n * Once because `Credentials` resolves through `globalThis` and decryption is\n * not free, and because two parsers over the same environment are two caches of\n * the same answer.\n */\nexport function defaultEnvParser(): EnvironmentParser<{}> {\n\tif (!fallback) {\n\t\tfallback = new EnvironmentParser({ ...process.env, ...Credentials });\n\t}\n\n\treturn fallback;\n}\n\n/** The parser for an endpoint, from its surface or the default. */\nexport function envParserFor(\n\tsurface: EndpointSurface | undefined,\n): EnvironmentParser<{}> {\n\treturn surface?.envParser ?? defaultEnvParser();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAI;;;;;;;;AASJ,SAAgB,mBAA0C;CACzD,IAAI,CAAC,UACJ,WAAW,IAAI,kBAAkB;EAAE,GAAG,QAAQ;EAAK,GAAG;CAAY,CAAC;CAGpE,OAAO;AACR;;AAGA,SAAgB,aACf,SACwB;CACxB,OAAO,SAAS,aAAa,iBAAiB;AAC/C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { i as Declarable } from "./construct-interface-B1AfqRl4.cjs";
|
|
2
|
+
import { ConstructName, Declaration } from "@geekmidas/manifest";
|
|
3
|
+
//#region src/telemetry.d.ts
|
|
4
|
+
interface TelemetryConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Request paths no span is recorded for, on every surface that uses this —
|
|
7
|
+
* health checks, by default the only noise worth naming. A trailing `*`
|
|
8
|
+
* matches a prefix. One route on one surface says so itself:
|
|
9
|
+
* `.telemetry({ ignore: true })`.
|
|
10
|
+
*/
|
|
11
|
+
ignorePaths?: readonly string[];
|
|
12
|
+
/**
|
|
13
|
+
* Resource attributes every span and log record carries —
|
|
14
|
+
* `{ 'service.namespace': 'shop' }`. The service's name is not one of
|
|
15
|
+
* them: it is the app's, set per process.
|
|
16
|
+
*/
|
|
17
|
+
attributes?: Readonly<Record<string, string>>;
|
|
18
|
+
}
|
|
19
|
+
declare class Telemetry<TName extends string = string> implements Declarable<TName> {
|
|
20
|
+
readonly id: TName;
|
|
21
|
+
readonly ignorePaths: readonly string[];
|
|
22
|
+
readonly attributes: Readonly<Record<string, string>>;
|
|
23
|
+
constructor(id: ConstructName<TName>, config?: TelemetryConfig);
|
|
24
|
+
/**
|
|
25
|
+
* One node, providing OpenTelemetry's own variables. No address of its
|
|
26
|
+
* own: where the telemetry goes is the deploy's, so it is resolved by the
|
|
27
|
+
* target for each stage, never declared here.
|
|
28
|
+
*/
|
|
29
|
+
declare(): Declaration[];
|
|
30
|
+
}
|
|
31
|
+
/** Per-route telemetry, on the endpoint builder — `.telemetry({ ignore: true })`. */
|
|
32
|
+
interface EndpointTelemetry {
|
|
33
|
+
/** Record no span for this route. */
|
|
34
|
+
ignore?: boolean;
|
|
35
|
+
/** Attributes this route's request span carries. */
|
|
36
|
+
attributes?: Readonly<Record<string, string>>;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { Telemetry as n, TelemetryConfig as r, EndpointTelemetry as t };
|
|
40
|
+
//# sourceMappingURL=telemetry-B48RLjyk.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-B48RLjyk.d.cts","names":[],"sources":["../src/telemetry.ts"],"mappings":";;;UAkCiB;;;;;;;EAOhB;;;;;;EAMA,aAAa,SAAS;;cAGV,UAAU,0CACX,WAAW;WAEb,IAAI;WACJ;WACA,YAAY,SAAS;EAE9B,YAAY,IAAI,cAAc,QAAQ,SAAQ;;;;;;EAW9C,WAAW;;;UAgBK;;EAEhB;;EAEA,aAAa,SAAS"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { i as Declarable } from "./construct-interface-DluK3_da.mjs";
|
|
2
|
+
import { ConstructName, Declaration } from "@geekmidas/manifest";
|
|
3
|
+
//#region src/telemetry.d.ts
|
|
4
|
+
interface TelemetryConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Request paths no span is recorded for, on every surface that uses this —
|
|
7
|
+
* health checks, by default the only noise worth naming. A trailing `*`
|
|
8
|
+
* matches a prefix. One route on one surface says so itself:
|
|
9
|
+
* `.telemetry({ ignore: true })`.
|
|
10
|
+
*/
|
|
11
|
+
ignorePaths?: readonly string[];
|
|
12
|
+
/**
|
|
13
|
+
* Resource attributes every span and log record carries —
|
|
14
|
+
* `{ 'service.namespace': 'shop' }`. The service's name is not one of
|
|
15
|
+
* them: it is the app's, set per process.
|
|
16
|
+
*/
|
|
17
|
+
attributes?: Readonly<Record<string, string>>;
|
|
18
|
+
}
|
|
19
|
+
declare class Telemetry<TName extends string = string> implements Declarable<TName> {
|
|
20
|
+
readonly id: TName;
|
|
21
|
+
readonly ignorePaths: readonly string[];
|
|
22
|
+
readonly attributes: Readonly<Record<string, string>>;
|
|
23
|
+
constructor(id: ConstructName<TName>, config?: TelemetryConfig);
|
|
24
|
+
/**
|
|
25
|
+
* One node, providing OpenTelemetry's own variables. No address of its
|
|
26
|
+
* own: where the telemetry goes is the deploy's, so it is resolved by the
|
|
27
|
+
* target for each stage, never declared here.
|
|
28
|
+
*/
|
|
29
|
+
declare(): Declaration[];
|
|
30
|
+
}
|
|
31
|
+
/** Per-route telemetry, on the endpoint builder — `.telemetry({ ignore: true })`. */
|
|
32
|
+
interface EndpointTelemetry {
|
|
33
|
+
/** Record no span for this route. */
|
|
34
|
+
ignore?: boolean;
|
|
35
|
+
/** Attributes this route's request span carries. */
|
|
36
|
+
attributes?: Readonly<Record<string, string>>;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { Telemetry as n, TelemetryConfig as r, EndpointTelemetry as t };
|
|
40
|
+
//# sourceMappingURL=telemetry-DRtT1_0A.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-DRtT1_0A.d.mts","names":[],"sources":["../src/telemetry.ts"],"mappings":";;;UAkCiB;;;;;;;EAOhB;;;;;;EAMA,aAAa,SAAS;;cAGV,UAAU,0CACX,WAAW;WAEb,IAAI;WACJ;WACA,YAAY,SAAS;EAE9B,YAAY,IAAI,cAAc,QAAQ,SAAQ;;;;;;EAW9C,WAAW;;;UAgBK;;EAEhB;;EAEA,aAAa,SAAS"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
3
|
+
//#region src/telemetry.ts
|
|
4
|
+
/**
|
|
5
|
+
* `Telemetry` — what an application emits, declared.
|
|
6
|
+
*
|
|
7
|
+
* Traces and logs over OTLP, from every process that is given it. The
|
|
8
|
+
* construct says *what* is emitted — which requests are noise, which
|
|
9
|
+
* attributes every span carries — and never where it goes or how much of it:
|
|
10
|
+
* the provider and the sample rate are the deploy's, per stage
|
|
11
|
+
* (`deploy.telemetry` in `gkm.config.ts`), and locally `gkm dev` runs
|
|
12
|
+
* OpenObserve and sends everything there.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* export const telemetry = new Telemetry('Telemetry', {
|
|
16
|
+
* ignorePaths: ['/health', '/ready'],
|
|
17
|
+
* attributes: { 'service.namespace': 'shop' },
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // passed like the logger: a fact about the process
|
|
21
|
+
* new RestApi('Api', { path: 'apps/api', defaultAuthorizer: 'none', telemetry });
|
|
22
|
+
* new Worker('Jobs', { logger, telemetry });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Each process given it is an edge to this node, so the `OTEL_*` keys it
|
|
26
|
+
* provides reach exactly those processes, and the build of each one fails
|
|
27
|
+
* without the OpenTelemetry packages it needs.
|
|
28
|
+
*/
|
|
29
|
+
var Telemetry = class {
|
|
30
|
+
id;
|
|
31
|
+
ignorePaths;
|
|
32
|
+
attributes;
|
|
33
|
+
constructor(id, config = {}) {
|
|
34
|
+
this.id = (0, _geekmidas_manifest.canonicalId)(id);
|
|
35
|
+
this.ignorePaths = [...config.ignorePaths ?? []];
|
|
36
|
+
this.attributes = { ...config.attributes };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One node, providing OpenTelemetry's own variables. No address of its
|
|
40
|
+
* own: where the telemetry goes is the deploy's, so it is resolved by the
|
|
41
|
+
* target for each stage, never declared here.
|
|
42
|
+
*/
|
|
43
|
+
declare() {
|
|
44
|
+
return [{
|
|
45
|
+
kind: "telemetry",
|
|
46
|
+
id: this.id,
|
|
47
|
+
...this.ignorePaths.length ? { ignorePaths: this.ignorePaths } : {},
|
|
48
|
+
...Object.keys(this.attributes).length ? { attributes: this.attributes } : {},
|
|
49
|
+
provides: [..._geekmidas_manifest.TELEMETRY_KEYS]
|
|
50
|
+
}];
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
exports.Telemetry = Telemetry;
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=telemetry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.cjs","names":["canonicalId","TELEMETRY_KEYS"],"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,MAAA,GAAKA,oBAAAA,YAAAA,CAAY,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,GAAGC,oBAAAA,cAAc;EAC7B,CACD;CACD;AACD"}
|
|
@@ -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"}
|