@geekmidas/constructs 10.0.0-alpha.11 → 10.0.0-alpha.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +222 -158
- package/dist/Construct-BQALFCh2.d.cts +230 -0
- package/dist/Construct-BQALFCh2.d.cts.map +1 -0
- package/dist/{Construct-BD5neF7w.mjs → Construct-CKUA-CTA.mjs} +35 -35
- package/dist/Construct-CKUA-CTA.mjs.map +1 -0
- package/dist/{Construct-CyS3RpTL.cjs → Construct-DEOVauyA.cjs} +55 -49
- package/dist/Construct-DEOVauyA.cjs.map +1 -0
- package/dist/Construct-QXnl3VqT.d.mts +230 -0
- package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
- package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-CQJqqkhY.d.mts} +17 -11
- package/dist/Cron-CQJqqkhY.d.mts.map +1 -0
- package/dist/{Cron-dh4rUgib.d.mts → Cron-DI3nKoic.d.cts} +17 -11
- package/dist/Cron-DI3nKoic.d.cts.map +1 -0
- package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BXTG10u5.cjs} +47 -31
- package/dist/CronBuilder-BXTG10u5.cjs.map +1 -0
- package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-D3sF9tS_.mjs} +37 -21
- package/dist/CronBuilder-D3sF9tS_.mjs.map +1 -0
- package/dist/CronBuilder-Xx_zakuc.d.mts +47 -0
- package/dist/CronBuilder-Xx_zakuc.d.mts.map +1 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
- package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-BWyKCa2x.d.cts} +130 -100
- package/dist/Endpoint-BWyKCa2x.d.cts.map +1 -0
- package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-CrE9Ppdk.d.mts} +130 -100
- package/dist/Endpoint-CrE9Ppdk.d.mts.map +1 -0
- package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-gPXhHKhJ.mjs} +208 -100
- package/dist/Endpoint-gPXhHKhJ.mjs.map +1 -0
- package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-yhR2T2Wt.cjs} +248 -122
- package/dist/Endpoint-yhR2T2Wt.cjs.map +1 -0
- package/dist/{index-lAO9egTb.d.mts → EndpointFactory-BV-nfnaP.d.mts} +85 -136
- package/dist/EndpointFactory-BV-nfnaP.d.mts.map +1 -0
- package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-BVv6EIDu.cjs} +98 -112
- package/dist/EndpointFactory-BVv6EIDu.cjs.map +1 -0
- package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-C1-IBwm4.d.cts} +84 -135
- package/dist/EndpointFactory-C1-IBwm4.d.cts.map +1 -0
- package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-Cs8IHvwF.mjs} +62 -76
- package/dist/EndpointFactory-Cs8IHvwF.mjs.map +1 -0
- package/dist/Function-DuqGcbOI.d.mts +76 -0
- package/dist/Function-DuqGcbOI.d.mts.map +1 -0
- package/dist/Function-Pu-1kKZz.d.cts +76 -0
- package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-CN1jjUBJ.cjs} +115 -71
- package/dist/HonoEndpointAdaptor-CN1jjUBJ.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-euH1oSdY.mjs} +105 -64
- package/dist/HonoEndpointAdaptor-euH1oSdY.mjs.map +1 -0
- package/dist/Queue-BhuofM3k.cjs +109 -0
- package/dist/Queue-BhuofM3k.cjs.map +1 -0
- package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
- package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
- package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
- package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
- package/dist/Queue-cmhqEBOB.mjs +104 -0
- package/dist/Queue-cmhqEBOB.mjs.map +1 -0
- package/dist/QueueBuilder-Cx9lKC5d.d.mts +75 -0
- package/dist/QueueBuilder-Cx9lKC5d.d.mts.map +1 -0
- package/dist/QueueBuilder-DXu1qxT1.mjs +118 -0
- package/dist/QueueBuilder-DXu1qxT1.mjs.map +1 -0
- package/dist/QueueBuilder-DdU2klPu.cjs +135 -0
- package/dist/QueueBuilder-DdU2klPu.cjs.map +1 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
- package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
- package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
- package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
- package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
- package/dist/SubscriberBuilder-4DWe9feX.d.mts +67 -0
- package/dist/SubscriberBuilder-4DWe9feX.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DRXfxWn_.mjs} +50 -24
- package/dist/SubscriberBuilder-DRXfxWn_.mjs.map +1 -0
- package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-M2EAgQhC.cjs} +61 -36
- package/dist/SubscriberBuilder-M2EAgQhC.cjs.map +1 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
- package/dist/Topic-D2R0r24C.mjs +99 -0
- package/dist/Topic-D2R0r24C.mjs.map +1 -0
- package/dist/Topic-DwS3QO0m.cjs +104 -0
- package/dist/Topic-DwS3QO0m.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +200 -246
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +58 -62
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +59 -63
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +171 -219
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +3 -10
- package/dist/adaptors/hono.d.cts +7 -16
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +9 -18
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +2 -10
- package/dist/adaptors/testing.cjs +765 -99
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +351 -54
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +351 -54
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +726 -78
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-BMCJN30Y.d.cts +268 -0
- package/dist/auth-BMCJN30Y.d.cts.map +1 -0
- package/dist/auth-D_0788uW.d.mts +268 -0
- package/dist/auth-D_0788uW.d.mts.map +1 -0
- package/dist/auth.cjs +301 -33
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -108
- package/dist/auth.d.mts +2 -108
- package/dist/auth.mjs +289 -27
- package/dist/auth.mjs.map +1 -1
- package/dist/{cache-BrRz3fEB.d.mts → cache-5QZzh5Er.d.mts} +3 -6
- package/dist/cache-5QZzh5Er.d.mts.map +1 -0
- package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
- package/dist/cache-DnGDGly3.d.cts.map +1 -0
- package/dist/cache.cjs +68 -2
- package/dist/cache.cjs.map +1 -0
- package/dist/cache.d.cts +1 -2
- package/dist/cache.d.mts +1 -2
- package/dist/cache.mjs +67 -2
- package/dist/cache.mjs.map +1 -0
- package/dist/cipher-C1lEFX63.mjs +225 -0
- package/dist/cipher-C1lEFX63.mjs.map +1 -0
- package/dist/cipher-CVxfwLjk.cjs +332 -0
- package/dist/cipher-CVxfwLjk.cjs.map +1 -0
- package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
- package/dist/clone-EKNovYHu.mjs.map +1 -0
- package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
- package/dist/clone-UGJpvQnL.cjs.map +1 -0
- package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
- package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
- package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-ZvYQbivO.d.mts} +42 -11
- package/dist/construct-interface-ZvYQbivO.d.mts.map +1 -0
- package/dist/construct-interface.cjs +113 -7
- package/dist/construct-interface.cjs.map +1 -0
- package/dist/construct-interface.d.cts +2 -2
- package/dist/construct-interface.d.mts +2 -2
- package/dist/construct-interface.mjs +106 -2
- package/dist/construct-interface.mjs.map +1 -0
- package/dist/credential-DYymbp_7.cjs +257 -0
- package/dist/credential-DYymbp_7.cjs.map +1 -0
- package/dist/credential-DfSAOOdY.mjs +222 -0
- package/dist/credential-DfSAOOdY.mjs.map +1 -0
- package/dist/credential.cjs +8 -96
- package/dist/credential.d.cts +2 -61
- package/dist/credential.d.mts +2 -61
- package/dist/credential.mjs +2 -94
- package/dist/crons/index.cjs +129 -7
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +45 -11
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +45 -11
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +127 -8
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +4 -181
- package/dist/database/kysely.d.cts +2 -152
- package/dist/database/kysely.d.mts +2 -152
- package/dist/database/kysely.mjs +2 -180
- package/dist/email.cjs +25 -12
- package/dist/email.cjs.map +1 -1
- package/dist/email.d.cts +3 -7
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +4 -8
- package/dist/email.d.mts.map +1 -1
- package/dist/email.mjs +16 -3
- package/dist/email.mjs.map +1 -1
- package/dist/encryption.cjs +96 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +117 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +117 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +83 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +20 -16
- package/dist/endpoints/index.d.cts +105 -7
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +105 -7
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -10
- package/dist/external-api.cjs +106 -0
- package/dist/external-api.cjs.map +1 -0
- package/dist/external-api.d.cts +2 -0
- package/dist/external-api.d.mts +2 -0
- package/dist/external-api.mjs +103 -0
- package/dist/external-api.mjs.map +1 -0
- package/dist/fake-DqKo8INJ.d.mts +201 -0
- package/dist/fake-DqKo8INJ.d.mts.map +1 -0
- package/dist/fake-Dvion_Fh.d.cts +201 -0
- package/dist/fake-Dvion_Fh.d.cts.map +1 -0
- package/dist/file-server.cjs +42 -10
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +6 -10
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +6 -10
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +34 -2
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +3 -6
- package/dist/functions/index.d.cts +3 -4
- package/dist/functions/index.d.mts +3 -4
- package/dist/functions/index.mjs +2 -6
- package/dist/{functions-14lpEFL4.mjs → functions-CTI-hDem.mjs} +376 -238
- package/dist/{functions-14lpEFL4.mjs.map → functions-CTI-hDem.mjs.map} +1 -1
- package/dist/{functions-i_la-N5r.cjs → functions-D7O5SGVc.cjs} +414 -264
- package/dist/functions-D7O5SGVc.cjs.map +1 -0
- package/dist/index-B13kQB_U.d.mts +115 -0
- package/dist/index-B13kQB_U.d.mts.map +1 -0
- package/dist/index-BuzRvKOQ.d.cts +115 -0
- package/dist/index-BuzRvKOQ.d.cts.map +1 -0
- package/dist/index-CeEtxDmK.d.cts +79 -0
- package/dist/index-CeEtxDmK.d.cts.map +1 -0
- package/dist/index-CeEtxDmK.d.mts +79 -0
- package/dist/index-CeEtxDmK.d.mts.map +1 -0
- package/dist/index.cjs +6 -3
- package/dist/index.d.cts +27 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +27 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -3
- package/dist/kms-B-Hm3d5r.cjs +85 -0
- package/dist/kms-B-Hm3d5r.cjs.map +1 -0
- package/dist/kms-BdUlMJEZ.mjs +85 -0
- package/dist/kms-BdUlMJEZ.mjs.map +1 -0
- package/dist/kysely-B3zfg9ti.cjs +383 -0
- package/dist/kysely-B3zfg9ti.cjs.map +1 -0
- package/dist/kysely-B_0BAr0T.mjs +370 -0
- package/dist/kysely-B_0BAr0T.mjs.map +1 -0
- package/dist/kysely-D0bpzgPs.d.cts +175 -0
- package/dist/kysely-D0bpzgPs.d.cts.map +1 -0
- package/dist/kysely-DKwnl0nf.d.mts +175 -0
- package/dist/kysely-DKwnl0nf.d.mts.map +1 -0
- package/dist/{telemetry-C3L0iS28.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +3 -6
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
- package/dist/{telemetry-D7bVFLGi.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +3 -6
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
- package/dist/mobile-app.cjs +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 +18 -10
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +3 -7
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +3 -7
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +11 -3
- package/dist/object-storage.mjs.map +1 -1
- package/dist/queue/index.cjs +6 -189
- package/dist/queue/index.d.cts +3 -60
- package/dist/queue/index.d.mts +3 -60
- package/dist/queue/index.mjs +3 -186
- package/dist/random-password.cjs +86 -0
- package/dist/random-password.cjs.map +1 -0
- package/dist/random-password.d.cts +30 -0
- package/dist/random-password.d.cts.map +1 -0
- package/dist/random-password.d.mts +30 -0
- package/dist/random-password.d.mts.map +1 -0
- package/dist/random-password.mjs +84 -0
- package/dist/random-password.mjs.map +1 -0
- package/dist/{lazyAccessors-BoJN3SMd.mjs → readRequestBody-BTIl3k-D.mjs} +117 -60
- package/dist/readRequestBody-BTIl3k-D.mjs.map +1 -0
- package/dist/readRequestBody-Dej_L3c4.cjs +342 -0
- package/dist/readRequestBody-Dej_L3c4.cjs.map +1 -0
- package/dist/requestLogger-BZcXwdBs.cjs +207 -0
- package/dist/requestLogger-BZcXwdBs.cjs.map +1 -0
- package/dist/requestLogger-pA4gi3E1.mjs +178 -0
- package/dist/requestLogger-pA4gi3E1.mjs.map +1 -0
- package/dist/rest-api.cjs +90 -59
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +70 -42
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +70 -42
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +82 -51
- package/dist/rest-api.mjs.map +1 -1
- package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
- package/dist/runSubscriber-BHvJ8POr.mjs +109 -0
- package/dist/runSubscriber-BHvJ8POr.mjs.map +1 -0
- package/dist/runSubscriber-D8nLXIv1.cjs +126 -0
- package/dist/runSubscriber-D8nLXIv1.cjs.map +1 -0
- package/dist/shutdown-BMJmAhSt.cjs +38 -0
- package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
- package/dist/shutdown-C7xa8x9S.mjs +27 -0
- package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
- package/dist/site.cjs +33 -7
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +17 -7
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +17 -7
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +29 -3
- package/dist/site.mjs.map +1 -1
- package/dist/stages-BSCF19o2.d.cts +56 -0
- package/dist/stages-BSCF19o2.d.cts.map +1 -0
- package/dist/stages-BSCF19o2.d.mts +56 -0
- package/dist/stages-BSCF19o2.d.mts.map +1 -0
- package/dist/subscribers/index.cjs +118 -6
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +51 -6
- package/dist/subscribers/index.d.cts.map +1 -0
- package/dist/subscribers/index.d.mts +51 -6
- package/dist/subscribers/index.d.mts.map +1 -0
- package/dist/subscribers/index.mjs +115 -5
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/surfaceEnv-CNimK76p.cjs +56 -0
- package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
- package/dist/telemetry-B48RLjyk.d.cts +40 -0
- package/dist/telemetry-B48RLjyk.d.cts.map +1 -0
- package/dist/telemetry-BEoBn6GO.d.mts +40 -0
- package/dist/telemetry-BEoBn6GO.d.mts.map +1 -0
- package/dist/telemetry.cjs +56 -0
- package/dist/telemetry.cjs.map +1 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +55 -0
- package/dist/telemetry.mjs.map +1 -0
- package/dist/topic/index.cjs +3 -137
- package/dist/topic/index.d.cts +2 -4
- package/dist/topic/index.d.mts +2 -4
- package/dist/topic/index.mjs +2 -134
- package/dist/tracing-Bbj1uoFJ.mjs +127 -0
- package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
- package/dist/tracing-C0ooU0V2.cjs +150 -0
- package/dist/tracing-C0ooU0V2.cjs.map +1 -0
- package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
- package/dist/types-DMuSQeLL.d.cts.map +1 -0
- package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
- package/dist/types-DMuSQeLL.d.mts.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -0
- package/dist/worker.cjs +59 -34
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +70 -45
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +71 -46
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +54 -29
- package/dist/worker.mjs.map +1 -1
- package/package.json +106 -42
- package/dist/Construct-BD5neF7w.mjs.map +0 -1
- package/dist/Construct-C0ijr2qp.d.cts +0 -117
- package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
- package/dist/Construct-Ct8nalEi.d.mts +0 -117
- package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
- package/dist/Construct-CyS3RpTL.cjs.map +0 -1
- package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
- package/dist/Cron-dh4rUgib.d.mts.map +0 -1
- package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
- package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
- package/dist/CronBuilder-CGgY2080.d.mts +0 -44
- package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
- package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
- package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
- package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
- package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
- package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
- package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
- package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
- package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
- package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
- package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
- package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
- package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
- package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
- package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
- package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
- package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
- package/dist/Topic-19QeHBIR.d.cts +0 -91
- package/dist/Topic-19QeHBIR.d.cts.map +0 -1
- package/dist/Topic-DuFeqkBh.d.mts +0 -91
- package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
- package/dist/auth.d.cts.map +0 -1
- package/dist/auth.d.mts.map +0 -1
- package/dist/cache-0ANvRQnD.mjs +0 -51
- package/dist/cache-0ANvRQnD.mjs.map +0 -1
- package/dist/cache-3WSvAulx.cjs +0 -57
- package/dist/cache-3WSvAulx.cjs.map +0 -1
- package/dist/cache-BrRz3fEB.d.mts.map +0 -1
- package/dist/cache-BtZY_tHe.d.cts.map +0 -1
- package/dist/clone-DblgEZZa.mjs.map +0 -1
- package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
- package/dist/construct-interface-BfjcOD_E.cjs +0 -117
- package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
- package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
- package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
- package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
- package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
- package/dist/credential.cjs.map +0 -1
- package/dist/credential.d.cts.map +0 -1
- package/dist/credential.d.mts.map +0 -1
- package/dist/credential.mjs.map +0 -1
- package/dist/database/kysely.cjs.map +0 -1
- package/dist/database/kysely.d.cts.map +0 -1
- package/dist/database/kysely.d.mts.map +0 -1
- package/dist/database/kysely.mjs.map +0 -1
- package/dist/functions-i_la-N5r.cjs.map +0 -1
- package/dist/index-Bd5FqCoe.d.cts.map +0 -1
- package/dist/index-BknhM6Ux.d.mts +0 -31
- package/dist/index-BknhM6Ux.d.mts.map +0 -1
- package/dist/index-CBSfrowv.d.cts +0 -31
- package/dist/index-CBSfrowv.d.cts.map +0 -1
- package/dist/index-D24Xm79M.d.cts +0 -171
- package/dist/index-D24Xm79M.d.cts.map +0 -1
- package/dist/index-_ajboYxK.d.mts +0 -171
- package/dist/index-_ajboYxK.d.mts.map +0 -1
- package/dist/index-lAO9egTb.d.mts.map +0 -1
- package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
- package/dist/lazyAccessors-e3j2oE2m.cjs +0 -274
- package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
- package/dist/processAudits-CGqttuXm.cjs +0 -92
- package/dist/processAudits-CGqttuXm.cjs.map +0 -1
- package/dist/processAudits-Dmts9H_b.mjs +0 -80
- package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts.map +0 -1
- package/dist/queue/index.d.mts.map +0 -1
- package/dist/queue/index.mjs.map +0 -1
- package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
- package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
- package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
- package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
- package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
- package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
- package/dist/types-BlAkSuGI.d.cts.map +0 -1
- package/dist/types-aKksMEWL.d.mts.map +0 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { _ as rotateKeyring, a as EncryptionUrlInvalid, d as generateKeyring, f as keyringCipher, g as retireKey, h as parseKeyring, i as EncryptionKeyRetired, n as CiphertextNotAuthentic, r as CurrentKeyCannotRetire, s as UnknownEncryptionScheme, t as CiphertextMalformed, u as formatKeyring } from "./cipher-C1lEFX63.mjs";
|
|
2
|
+
import { KMS_SCHEME, canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
3
|
+
//#region src/encryption.ts
|
|
4
|
+
/**
|
|
5
|
+
* `Encryption` — a key that encrypts what the application stores.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* export const pii = new Encryption('Pii');
|
|
9
|
+
*
|
|
10
|
+
* // an endpoint that `.dependsOn([pii])`
|
|
11
|
+
* const email = await services.pii.encrypt(body.email);
|
|
12
|
+
* const emailIndex = await services.pii.index(body.email);
|
|
13
|
+
* await db.insertInto('users').values({ email, emailIndex }).execute();
|
|
14
|
+
*
|
|
15
|
+
* // and to find them again, without decrypting a column
|
|
16
|
+
* db.selectFrom('users').where('emailIndex', '=', await services.pii.index(q));
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* The app names no cipher and holds no key. The construct provides one URL,
|
|
20
|
+
* `<ID>_URL`, and its scheme picks the backend the way a queue's connection
|
|
21
|
+
* string picks its broker:
|
|
22
|
+
*
|
|
23
|
+
* - **AWS** — `kms://`: envelope encryption under a KMS key that rotates
|
|
24
|
+
* yearly, and a KMS HMAC key for the index. Only a function that depends on
|
|
25
|
+
* the construct is granted either key.
|
|
26
|
+
* - **Server, local, tests** — `aes256gcm://`: a keyring the process holds.
|
|
27
|
+
* Derived locally, so `gkm dev` and `gkm test` need nothing set; generated
|
|
28
|
+
* into a server stage's secrets on its first deploy, and rotated there with
|
|
29
|
+
* `gkm encryption:rotate`.
|
|
30
|
+
*
|
|
31
|
+
* Every ciphertext names the key that wrote it, so a rotated key still opens
|
|
32
|
+
* what it wrote. Retiring one is explicit — `reencrypt` the column, then
|
|
33
|
+
* `gkm encryption:retire` — and a value still under an old key says so when it
|
|
34
|
+
* is decrypted, once per key per process.
|
|
35
|
+
*/
|
|
36
|
+
var Encryption = class {
|
|
37
|
+
id;
|
|
38
|
+
service;
|
|
39
|
+
/**
|
|
40
|
+
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
41
|
+
* target publishes and the key the client reads cannot drift.
|
|
42
|
+
*/
|
|
43
|
+
key;
|
|
44
|
+
/**
|
|
45
|
+
* One cipher per process, held as the promise: a keyring is parsed once and
|
|
46
|
+
* a KMS client is built once, however many handlers register it at once.
|
|
47
|
+
*/
|
|
48
|
+
cipher;
|
|
49
|
+
constructor(id) {
|
|
50
|
+
const canonical = canonicalId(id);
|
|
51
|
+
this.id = canonical;
|
|
52
|
+
this.key = provideKey(canonical, "url");
|
|
53
|
+
this.service = {
|
|
54
|
+
serviceName: serviceKey(canonical),
|
|
55
|
+
register: (options) => this.connect(options)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
declare() {
|
|
59
|
+
return [{
|
|
60
|
+
kind: "encryption",
|
|
61
|
+
id: this.id,
|
|
62
|
+
provides: [this.key]
|
|
63
|
+
}];
|
|
64
|
+
}
|
|
65
|
+
connect(options) {
|
|
66
|
+
this.cipher ??= this.open(options);
|
|
67
|
+
return this.cipher;
|
|
68
|
+
}
|
|
69
|
+
async open(options) {
|
|
70
|
+
const { url } = options.envParser.create((get) => ({ url: get(this.key).string() })).parse();
|
|
71
|
+
const scheme = url.slice(0, url.indexOf(":") + 1);
|
|
72
|
+
if (scheme === "aes256gcm:") return keyringCipher(this.id, url, (stale, current) => console.warn(`${this.id} decrypted a value still under '${stale}' (current: '${current}'). reencrypt it, and retire '${stale}' once nothing is left under it.`));
|
|
73
|
+
if (scheme === KMS_SCHEME) {
|
|
74
|
+
const { kmsCipher } = await import("./kms-BdUlMJEZ.mjs");
|
|
75
|
+
return kmsCipher(this.id, url);
|
|
76
|
+
}
|
|
77
|
+
throw new UnknownEncryptionScheme(this.id, scheme);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { CiphertextMalformed, CiphertextNotAuthentic, CurrentKeyCannotRetire, Encryption, EncryptionKeyRetired, EncryptionUrlInvalid, UnknownEncryptionScheme, formatKeyring, generateKeyring, keyringCipher, parseKeyring, retireKey, rotateKeyring };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=encryption.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.mjs","names":[],"sources":["../src/encryption.ts"],"sourcesContent":["/**\n * `Encryption` — a key that encrypts what the application stores.\n *\n * ```ts\n * export const pii = new Encryption('Pii');\n *\n * // an endpoint that `.dependsOn([pii])`\n * const email = await services.pii.encrypt(body.email);\n * const emailIndex = await services.pii.index(body.email);\n * await db.insertInto('users').values({ email, emailIndex }).execute();\n *\n * // and to find them again, without decrypting a column\n * db.selectFrom('users').where('emailIndex', '=', await services.pii.index(q));\n * ```\n *\n * The app names no cipher and holds no key. The construct provides one URL,\n * `<ID>_URL`, and its scheme picks the backend the way a queue's connection\n * string picks its broker:\n *\n * - **AWS** — `kms://`: envelope encryption under a KMS key that rotates\n * yearly, and a KMS HMAC key for the index. Only a function that depends on\n * the construct is granted either key.\n * - **Server, local, tests** — `aes256gcm://`: a keyring the process holds.\n * Derived locally, so `gkm dev` and `gkm test` need nothing set; generated\n * into a server stage's secrets on its first deploy, and rotated there with\n * `gkm encryption:rotate`.\n *\n * Every ciphertext names the key that wrote it, so a rotated key still opens\n * what it wrote. Retiring one is explicit — `reencrypt` the column, then\n * `gkm encryption:retire` — and a value still under an old key says so when it\n * is decrypted, once per key per process.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tKMS_SCHEME,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\nimport {\n\ttype Cipher,\n\tkeyringCipher,\n\tLOCAL_SCHEME,\n\tUnknownEncryptionScheme,\n} from './encryption/cipher';\n\nexport type { Cipher } from './encryption/cipher';\nexport {\n\tCiphertextMalformed,\n\tCiphertextNotAuthentic,\n\tCurrentKeyCannotRetire,\n\tEncryptionKeyRetired,\n\tEncryptionUrlInvalid,\n\tformatKeyring,\n\tgenerateKeyring,\n\ttype Keyring,\n\tkeyringCipher,\n\tparseKeyring,\n\tretireKey,\n\trotateKeyring,\n\tUnknownEncryptionScheme,\n} from './encryption/cipher';\n\nexport class Encryption<TName extends string = string>\n\timplements Construct<TName, Cipher>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Cipher>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly key: string;\n\n\t/**\n\t * One cipher per process, held as the promise: a keyring is parsed once and\n\t * a KMS client is built once, however many handlers register it at once.\n\t */\n\tprivate cipher?: Promise<Cipher>;\n\n\tconstructor(id: ConstructName<TName>) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.key = provideKey(canonical, 'url');\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [{ kind: 'encryption', id: this.id, provides: [this.key] }];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Cipher> {\n\t\tthis.cipher ??= this.open(options);\n\t\treturn this.cipher;\n\t}\n\n\tprivate async open(options: ServiceRegisterOptions): Promise<Cipher> {\n\t\tconst { url } = options.envParser\n\t\t\t.create((get) => ({ url: get(this.key).string() }))\n\t\t\t.parse();\n\t\tconst scheme = url.slice(0, url.indexOf(':') + 1);\n\n\t\tif (scheme === LOCAL_SCHEME) {\n\t\t\treturn keyringCipher(this.id, url, (stale, current) =>\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${this.id} decrypted a value still under '${stale}' (current: '${current}'). reencrypt it, and retire '${stale}' once nothing is left under it.`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (scheme === KMS_SCHEME) {\n\t\t\t// Loaded only here, so a project that never deploys to AWS never\n\t\t\t// needs `@aws-sdk/client-kms` installed.\n\t\t\tconst { kmsCipher } = await import('./encryption/kms');\n\t\t\treturn kmsCipher(this.id, url);\n\t\t}\n\n\t\tthrow new UnknownEncryptionScheme(this.id, scheme);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,IAAa,aAAb,MAEA;CACC;CACA;;;;;CAMA;;;;;CAMA;CAEA,YAAY,IAA0B;EACrC,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,MAAM,WAAW,WAAW,KAAK;EAGtC,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CAAC;GAAE,MAAM;GAAc,IAAI,KAAK;GAAI,UAAU,CAAC,KAAK,GAAG;EAAE,CAAC;CAClE;CAEA,QAAgB,SAAkD;EACjE,KAAK,WAAW,KAAK,KAAK,OAAO;EACjC,OAAO,KAAK;CACb;CAEA,MAAc,KAAK,SAAkD;EACpE,MAAM,EAAE,QAAQ,QAAQ,UACtB,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAClD,MAAM;EACR,MAAM,SAAS,IAAI,MAAM,GAAG,IAAI,QAAQ,GAAG,IAAI,CAAC;EAEhD,IAAI,WAAA,cACH,OAAO,cAAc,KAAK,IAAI,MAAM,OAAO,YAC1C,QAAQ,KACP,GAAG,KAAK,GAAG,kCAAkC,MAAM,eAAe,QAAQ,gCAAgC,MAAM,iCACjH,CACD;EAGD,IAAI,WAAW,YAAY;GAG1B,MAAM,EAAE,cAAc,MAAM,OAAO;GACnC,OAAO,UAAU,KAAK,IAAI,GAAG;EAC9B;EAEA,MAAM,IAAI,wBAAwB,KAAK,IAAI,MAAM;CAClD;AACD"}
|
package/dist/endpoints/index.cjs
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
require(
|
|
3
|
-
require(
|
|
4
|
-
const
|
|
5
|
-
require(
|
|
6
|
-
const
|
|
7
|
-
const require_surfaceEnv = require('../surfaceEnv-BFXEms2f.cjs');
|
|
8
|
-
const require_lazyAccessors = require('../lazyAccessors-e3j2oE2m.cjs');
|
|
9
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_EndpointFactory = require("../EndpointFactory-BVv6EIDu.cjs");
|
|
3
|
+
const require_functions = require("../functions-D7O5SGVc.cjs");
|
|
4
|
+
const require_Endpoint = require("../Endpoint-yhR2T2Wt.cjs");
|
|
5
|
+
const require_surfaceEnv = require("../surfaceEnv-CNimK76p.cjs");
|
|
6
|
+
const require_readRequestBody = require("../readRequestBody-Dej_L3c4.cjs");
|
|
10
7
|
exports.BUILT_IN_SECURITY_SCHEMES = require_EndpointFactory.BUILT_IN_SECURITY_SCHEMES;
|
|
11
8
|
exports.Endpoint = require_Endpoint.Endpoint;
|
|
12
9
|
exports.EndpointBuilder = require_EndpointFactory.EndpointBuilder;
|
|
13
10
|
exports.EndpointFactory = require_EndpointFactory.EndpointFactory;
|
|
11
|
+
exports.MalformedRequestBody = require_readRequestBody.MalformedRequestBody;
|
|
12
|
+
exports.NoAuthenticator = require_Endpoint.NoAuthenticator;
|
|
14
13
|
exports.RLS_BYPASS = require_EndpointFactory.RLS_BYPASS;
|
|
14
|
+
exports.RedirectStatus = require_Endpoint.RedirectStatus;
|
|
15
15
|
exports.ResponseBuilder = require_Endpoint.ResponseBuilder;
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
16
|
+
exports.SUPPORTED_BODY_TYPES = require_readRequestBody.SUPPORTED_BODY_TYPES;
|
|
17
|
+
exports.SuccessStatus = require_Endpoint.SuccessStatus;
|
|
18
|
+
exports.UnsupportedRequestContentType = require_readRequestBody.UnsupportedRequestContentType;
|
|
19
|
+
exports.createApiGatewayCookies = require_readRequestBody.createApiGatewayCookies;
|
|
20
|
+
exports.createApiGatewayHeaders = require_readRequestBody.createApiGatewayHeaders;
|
|
18
21
|
exports.createAuthorizer = require_EndpointFactory.createAuthorizer;
|
|
19
|
-
exports.createHonoCookies =
|
|
20
|
-
exports.createHonoHeaders =
|
|
21
|
-
exports.createNoopCookies =
|
|
22
|
-
exports.createNoopHeaders =
|
|
22
|
+
exports.createHonoCookies = require_readRequestBody.createHonoCookies;
|
|
23
|
+
exports.createHonoHeaders = require_readRequestBody.createHonoHeaders;
|
|
24
|
+
exports.createNoopCookies = require_readRequestBody.createNoopCookies;
|
|
25
|
+
exports.createNoopHeaders = require_readRequestBody.createNoopHeaders;
|
|
23
26
|
exports.defaultEnvParser = require_surfaceEnv.defaultEnvParser;
|
|
24
27
|
exports.envParserFor = require_surfaceEnv.envParserFor;
|
|
25
28
|
exports.getSecurityScheme = require_EndpointFactory.getSecurityScheme;
|
|
26
29
|
exports.isBuiltInSecurityScheme = require_EndpointFactory.isBuiltInSecurityScheme;
|
|
27
|
-
exports.publishConstructEvents =
|
|
30
|
+
exports.publishConstructEvents = require_functions.publishConstructEvents;
|
|
31
|
+
exports.readRequestBody = require_readRequestBody.readRequestBody;
|
|
@@ -1,7 +1,105 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { s as publishConstructEvents } from "../Construct-BQALFCh2.cjs";
|
|
2
|
+
import { A as SecurityScheme, C as ActorExtractor, D as BuiltInSecuritySchemeId, E as BUILT_IN_SECURITY_SCHEMES, M as getSecurityScheme, N as isBuiltInSecurityScheme, O as OAuthFlow, S as RlsContextExtractor, T as Authorizer, _ as SessionAuth, a as EndpointContext, b as RlsConfig, c as EndpointSchemas, d as HeaderFn, f as RedirectStatus, g as NoAuthenticator, h as SuccessStatus, i as Endpoint, j as createAuthorizer, k as OAuthFlows, l as EndpointStatus, n as ConvertRouteParams, o as EndpointHandler, p as ResponseBuilder, r as CookieFn, s as EndpointOutput, u as EndpointSurface, v as RLS_BYPASS, w as MappedAudit, x as RlsContext, y as RlsBypass } from "../Endpoint-BWyKCa2x.cjs";
|
|
3
|
+
import { n as EndpointBuilder, t as EndpointFactory } from "../EndpointFactory-C1-IBwm4.cjs";
|
|
4
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
5
|
+
import { Context } from "hono";
|
|
6
|
+
import { HttpError } from "@geekmidas/errors";
|
|
7
|
+
//#region src/endpoints/lazyAccessors.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Create a lazy header accessor for Hono.
|
|
10
|
+
* Uses `c.req.header(name)` for single lookups (native, case-insensitive).
|
|
11
|
+
* Only calls `c.req.header()` to get all headers when needed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createHonoHeaders(c: Context): HeaderFn;
|
|
14
|
+
/**
|
|
15
|
+
* Create a lazy cookie accessor for Hono.
|
|
16
|
+
* Uses `getCookie(c, name)` for single lookups (native).
|
|
17
|
+
* Only parses the cookie header when all cookies are requested.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createHonoCookies(c: Context): CookieFn;
|
|
20
|
+
/**
|
|
21
|
+
* Create a lazy header accessor for API Gateway events.
|
|
22
|
+
* Handles case-insensitive lookups.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createApiGatewayHeaders(headers: Record<string, string | undefined> | null | undefined): HeaderFn;
|
|
25
|
+
/**
|
|
26
|
+
* Create a lazy cookie accessor for API Gateway events.
|
|
27
|
+
* Decodes URL-encoded values to match browser behavior.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createApiGatewayCookies(cookies: string[] | undefined, cookieHeader: string | undefined): CookieFn;
|
|
30
|
+
/**
|
|
31
|
+
* Create a no-op header accessor (for minimal endpoints that don't use headers).
|
|
32
|
+
*/
|
|
33
|
+
export declare function createNoopHeaders(): HeaderFn;
|
|
34
|
+
/**
|
|
35
|
+
* Create a no-op cookie accessor (for minimal endpoints that don't use cookies).
|
|
36
|
+
*/
|
|
37
|
+
export declare function createNoopCookies(): CookieFn;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/endpoints/readRequestBody.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* The media types an endpoint's `.body()` schema can be handed — as written
|
|
42
|
+
* in the 415 a request in any other type is answered with.
|
|
43
|
+
*/
|
|
44
|
+
export declare const SUPPORTED_BODY_TYPES: readonly ['application/json', 'application/x-www-form-urlencoded', 'multipart/form-data', 'text/*'];
|
|
45
|
+
/**
|
|
46
|
+
* A request whose body is in a media type no endpoint reads — XML, a bare
|
|
47
|
+
* octet stream. Answered with a 415, before the body schema runs.
|
|
48
|
+
*/
|
|
49
|
+
export declare class UnsupportedRequestContentType extends HttpError {
|
|
50
|
+
readonly contentType: string;
|
|
51
|
+
constructor(contentType: string);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A body that says it is JSON and is not. Answered with a 400 — the request
|
|
55
|
+
* is broken, not merely invalid against the schema.
|
|
56
|
+
*/
|
|
57
|
+
export declare class MalformedRequestBody extends HttpError {
|
|
58
|
+
readonly contentType: string;
|
|
59
|
+
constructor(contentType: string, cause?: Error);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* What a body is read from: a `Request`, or Hono's request — which caches
|
|
63
|
+
* what it read, so a later reader is not handed a spent stream.
|
|
64
|
+
*/
|
|
65
|
+
interface RequestBodySource {
|
|
66
|
+
json(): Promise<unknown>;
|
|
67
|
+
text(): Promise<string>;
|
|
68
|
+
formData(): Promise<FormData>;
|
|
69
|
+
}
|
|
70
|
+
interface ReadRequestBodyOptions {
|
|
71
|
+
/**
|
|
72
|
+
* A body with no Content-Type: read as JSON (`'json'`, what API Gateway
|
|
73
|
+
* has always done), or not read at all and handed to the schema as `{}`
|
|
74
|
+
* (`'empty'`, what a Hono server has always done).
|
|
75
|
+
*/
|
|
76
|
+
untyped: 'json' | 'empty';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A request body, read by its Content-Type into what an endpoint's `.body()`
|
|
80
|
+
* schema validates — the one place every adaptor reads a body:
|
|
81
|
+
*
|
|
82
|
+
* - `application/json` (and `application/*+json`) — the parsed JSON.
|
|
83
|
+
* - `application/x-www-form-urlencoded` and `multipart/form-data` — a plain
|
|
84
|
+
* object of fields, as an HTML form posts them. A repeated field, or one
|
|
85
|
+
* named `field[]`, is an array; a file part is a `File`.
|
|
86
|
+
* - `text/*` — the text.
|
|
87
|
+
*
|
|
88
|
+
* Anything else is an {@link UnsupportedRequestContentType}.
|
|
89
|
+
*/
|
|
90
|
+
export declare function readRequestBody(source: RequestBodySource, contentType: string | null | undefined, options: ReadRequestBodyOptions): Promise<unknown>;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/endpoints/surfaceEnv.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* The default parser, built once.
|
|
95
|
+
*
|
|
96
|
+
* Once because `Credentials` resolves through `globalThis` and decryption is
|
|
97
|
+
* not free, and because two parsers over the same environment are two caches of
|
|
98
|
+
* the same answer.
|
|
99
|
+
*/
|
|
100
|
+
export declare function defaultEnvParser(): EnvironmentParser<{}>;
|
|
101
|
+
/** The parser for an endpoint, from its surface or the default. */
|
|
102
|
+
export declare function envParserFor(surface: EndpointSurface | undefined): EnvironmentParser<{}>;
|
|
103
|
+
//#endregion
|
|
104
|
+
export { type ActorExtractor, type Authorizer, BUILT_IN_SECURITY_SCHEMES, type BuiltInSecuritySchemeId, type ConvertRouteParams, Endpoint, EndpointBuilder, type EndpointContext, EndpointFactory, type EndpointHandler, type EndpointOutput, type EndpointSchemas, type EndpointStatus, type MappedAudit, NoAuthenticator, type OAuthFlow, type OAuthFlows, RLS_BYPASS, RedirectStatus, type RequestBodySource, ResponseBuilder, type RlsBypass, type RlsConfig, type RlsContext, type RlsContextExtractor, type SecurityScheme, type SessionAuth, SuccessStatus, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme, publishConstructEvents };
|
|
105
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/endpoints/lazyAccessors.ts","../../src/endpoints/readRequestBody.ts","../../src/endpoints/surfaceEnv.ts"],"mappings":";;;;;;;;;;;;wBAgBgB,kBAAkB,GAAG,UAAU;;;;;;wBAqB/B,kBAAkB,GAAG,UAAU;;;;;wBAgC/B,wBACf,SAAS,wDACP;;;;;wBAoCa,wBACf,+BACA,mCACE;;;;wBAmHa,qBAAqB;;;;wBAUrB,qBAAqB;;;;;;;qBCrOxB;;;;;qBAWA,sCAAsC;WAC7B;EAArB,YAAqB;;;;;;qBAiBT,6BAA6B;WAE/B;EADV,YACU,qBACT,QAAQ;;;;;;UAeO;EAChB,QAAQ;EACR,QAAQ;EACR,YAAY,QAAQ;;UAGJ;;;;;;EAMhB;;;;;;;;;;;;;;wBAeqB,gBACrB,QAAQ,mBACR,wCACA,SAAS,yBACP;;;;;;;;;;wBCnDa,oBAAoB;;wBASpB,aACf,SAAS,8BACP"}
|
|
@@ -1,7 +1,105 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { s as publishConstructEvents } from "../Construct-QXnl3VqT.mjs";
|
|
2
|
+
import { A as SecurityScheme, C as ActorExtractor, D as BuiltInSecuritySchemeId, E as BUILT_IN_SECURITY_SCHEMES, M as getSecurityScheme, N as isBuiltInSecurityScheme, O as OAuthFlow, S as RlsContextExtractor, T as Authorizer, _ as SessionAuth, a as EndpointContext, b as RlsConfig, c as EndpointSchemas, d as HeaderFn, f as RedirectStatus, g as NoAuthenticator, h as SuccessStatus, i as Endpoint, j as createAuthorizer, k as OAuthFlows, l as EndpointStatus, n as ConvertRouteParams, o as EndpointHandler, p as ResponseBuilder, r as CookieFn, s as EndpointOutput, u as EndpointSurface, v as RLS_BYPASS, w as MappedAudit, x as RlsContext, y as RlsBypass } from "../Endpoint-CrE9Ppdk.mjs";
|
|
3
|
+
import { n as EndpointBuilder, t as EndpointFactory } from "../EndpointFactory-BV-nfnaP.mjs";
|
|
4
|
+
import { HttpError } from "@geekmidas/errors";
|
|
5
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
6
|
+
import { Context } from "hono";
|
|
7
|
+
//#region src/endpoints/lazyAccessors.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Create a lazy header accessor for Hono.
|
|
10
|
+
* Uses `c.req.header(name)` for single lookups (native, case-insensitive).
|
|
11
|
+
* Only calls `c.req.header()` to get all headers when needed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createHonoHeaders(c: Context): HeaderFn;
|
|
14
|
+
/**
|
|
15
|
+
* Create a lazy cookie accessor for Hono.
|
|
16
|
+
* Uses `getCookie(c, name)` for single lookups (native).
|
|
17
|
+
* Only parses the cookie header when all cookies are requested.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createHonoCookies(c: Context): CookieFn;
|
|
20
|
+
/**
|
|
21
|
+
* Create a lazy header accessor for API Gateway events.
|
|
22
|
+
* Handles case-insensitive lookups.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createApiGatewayHeaders(headers: Record<string, string | undefined> | null | undefined): HeaderFn;
|
|
25
|
+
/**
|
|
26
|
+
* Create a lazy cookie accessor for API Gateway events.
|
|
27
|
+
* Decodes URL-encoded values to match browser behavior.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createApiGatewayCookies(cookies: string[] | undefined, cookieHeader: string | undefined): CookieFn;
|
|
30
|
+
/**
|
|
31
|
+
* Create a no-op header accessor (for minimal endpoints that don't use headers).
|
|
32
|
+
*/
|
|
33
|
+
export declare function createNoopHeaders(): HeaderFn;
|
|
34
|
+
/**
|
|
35
|
+
* Create a no-op cookie accessor (for minimal endpoints that don't use cookies).
|
|
36
|
+
*/
|
|
37
|
+
export declare function createNoopCookies(): CookieFn;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/endpoints/readRequestBody.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* The media types an endpoint's `.body()` schema can be handed — as written
|
|
42
|
+
* in the 415 a request in any other type is answered with.
|
|
43
|
+
*/
|
|
44
|
+
export declare const SUPPORTED_BODY_TYPES: readonly ['application/json', 'application/x-www-form-urlencoded', 'multipart/form-data', 'text/*'];
|
|
45
|
+
/**
|
|
46
|
+
* A request whose body is in a media type no endpoint reads — XML, a bare
|
|
47
|
+
* octet stream. Answered with a 415, before the body schema runs.
|
|
48
|
+
*/
|
|
49
|
+
export declare class UnsupportedRequestContentType extends HttpError {
|
|
50
|
+
readonly contentType: string;
|
|
51
|
+
constructor(contentType: string);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A body that says it is JSON and is not. Answered with a 400 — the request
|
|
55
|
+
* is broken, not merely invalid against the schema.
|
|
56
|
+
*/
|
|
57
|
+
export declare class MalformedRequestBody extends HttpError {
|
|
58
|
+
readonly contentType: string;
|
|
59
|
+
constructor(contentType: string, cause?: Error);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* What a body is read from: a `Request`, or Hono's request — which caches
|
|
63
|
+
* what it read, so a later reader is not handed a spent stream.
|
|
64
|
+
*/
|
|
65
|
+
interface RequestBodySource {
|
|
66
|
+
json(): Promise<unknown>;
|
|
67
|
+
text(): Promise<string>;
|
|
68
|
+
formData(): Promise<FormData>;
|
|
69
|
+
}
|
|
70
|
+
interface ReadRequestBodyOptions {
|
|
71
|
+
/**
|
|
72
|
+
* A body with no Content-Type: read as JSON (`'json'`, what API Gateway
|
|
73
|
+
* has always done), or not read at all and handed to the schema as `{}`
|
|
74
|
+
* (`'empty'`, what a Hono server has always done).
|
|
75
|
+
*/
|
|
76
|
+
untyped: 'json' | 'empty';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A request body, read by its Content-Type into what an endpoint's `.body()`
|
|
80
|
+
* schema validates — the one place every adaptor reads a body:
|
|
81
|
+
*
|
|
82
|
+
* - `application/json` (and `application/*+json`) — the parsed JSON.
|
|
83
|
+
* - `application/x-www-form-urlencoded` and `multipart/form-data` — a plain
|
|
84
|
+
* object of fields, as an HTML form posts them. A repeated field, or one
|
|
85
|
+
* named `field[]`, is an array; a file part is a `File`.
|
|
86
|
+
* - `text/*` — the text.
|
|
87
|
+
*
|
|
88
|
+
* Anything else is an {@link UnsupportedRequestContentType}.
|
|
89
|
+
*/
|
|
90
|
+
export declare function readRequestBody(source: RequestBodySource, contentType: string | null | undefined, options: ReadRequestBodyOptions): Promise<unknown>;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/endpoints/surfaceEnv.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* The default parser, built once.
|
|
95
|
+
*
|
|
96
|
+
* Once because `Credentials` resolves through `globalThis` and decryption is
|
|
97
|
+
* not free, and because two parsers over the same environment are two caches of
|
|
98
|
+
* the same answer.
|
|
99
|
+
*/
|
|
100
|
+
export declare function defaultEnvParser(): EnvironmentParser<{}>;
|
|
101
|
+
/** The parser for an endpoint, from its surface or the default. */
|
|
102
|
+
export declare function envParserFor(surface: EndpointSurface | undefined): EnvironmentParser<{}>;
|
|
103
|
+
//#endregion
|
|
104
|
+
export { type ActorExtractor, type Authorizer, BUILT_IN_SECURITY_SCHEMES, type BuiltInSecuritySchemeId, type ConvertRouteParams, Endpoint, EndpointBuilder, type EndpointContext, EndpointFactory, type EndpointHandler, type EndpointOutput, type EndpointSchemas, type EndpointStatus, type MappedAudit, NoAuthenticator, type OAuthFlow, type OAuthFlows, RLS_BYPASS, RedirectStatus, type RequestBodySource, ResponseBuilder, type RlsBypass, type RlsConfig, type RlsContext, type RlsContextExtractor, type SecurityScheme, type SessionAuth, SuccessStatus, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme, publishConstructEvents };
|
|
105
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/endpoints/lazyAccessors.ts","../../src/endpoints/readRequestBody.ts","../../src/endpoints/surfaceEnv.ts"],"mappings":";;;;;;;;;;;;wBAgBgB,kBAAkB,GAAG,UAAU;;;;;;wBAqB/B,kBAAkB,GAAG,UAAU;;;;;wBAgC/B,wBACf,SAAS,wDACP;;;;;wBAoCa,wBACf,+BACA,mCACE;;;;wBAmHa,qBAAqB;;;;wBAUrB,qBAAqB;;;;;;;qBCrOxB;;;;;qBAWA,sCAAsC;WAC7B;EAArB,YAAqB;;;;;;qBAiBT,6BAA6B;WAE/B;EADV,YACU,qBACT,QAAQ;;;;;;UAeO;EAChB,QAAQ;EACR,QAAQ;EACR,YAAY,QAAQ;;UAGJ;;;;;;EAMhB;;;;;;;;;;;;;;wBAeqB,gBACrB,QAAQ,mBACR,wCACA,SAAS,yBACP;;;;;;;;;;wBCnDa,oBAAoB;;wBASpB,aACf,SAAS,8BACP"}
|
package/dist/endpoints/index.mjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import {
|
|
5
|
-
import "../
|
|
6
|
-
|
|
7
|
-
import { defaultEnvParser, envParserFor } from "../surfaceEnv-C3Ktahea.mjs";
|
|
8
|
-
import { createApiGatewayCookies, createApiGatewayHeaders, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, publishConstructEvents } from "../lazyAccessors-BoJN3SMd.mjs";
|
|
9
|
-
|
|
10
|
-
export { BUILT_IN_SECURITY_SCHEMES, Endpoint, EndpointBuilder, EndpointFactory, RLS_BYPASS, ResponseBuilder, createApiGatewayCookies, createApiGatewayHeaders, createAuthorizer, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, getSecurityScheme, isBuiltInSecurityScheme, publishConstructEvents };
|
|
1
|
+
import { a as createAuthorizer, i as BUILT_IN_SECURITY_SCHEMES, n as EndpointBuilder, o as getSecurityScheme, r as RLS_BYPASS, s as isBuiltInSecurityScheme, t as EndpointFactory } from "../EndpointFactory-Cs8IHvwF.mjs";
|
|
2
|
+
import { i as publishConstructEvents } from "../functions-CTI-hDem.mjs";
|
|
3
|
+
import { a as NoAuthenticator, i as SuccessStatus, n as RedirectStatus, r as ResponseBuilder, t as Endpoint } from "../Endpoint-gPXhHKhJ.mjs";
|
|
4
|
+
import { n as envParserFor, t as defaultEnvParser } from "../surfaceEnv-wMT5QzgZ.mjs";
|
|
5
|
+
import { a as createApiGatewayCookies, c as createHonoCookies, d as createNoopHeaders, i as readRequestBody, l as createHonoHeaders, n as SUPPORTED_BODY_TYPES, o as createApiGatewayHeaders, r as UnsupportedRequestContentType, t as MalformedRequestBody, u as createNoopCookies } from "../readRequestBody-BTIl3k-D.mjs";
|
|
6
|
+
export { BUILT_IN_SECURITY_SCHEMES, Endpoint, EndpointBuilder, EndpointFactory, MalformedRequestBody, NoAuthenticator, RLS_BYPASS, RedirectStatus, ResponseBuilder, SUPPORTED_BODY_TYPES, SuccessStatus, UnsupportedRequestContentType, createApiGatewayCookies, createApiGatewayHeaders, createAuthorizer, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, getSecurityScheme, isBuiltInSecurityScheme, publishConstructEvents, readRequestBody };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_credential = require("./credential-DYymbp_7.cjs");
|
|
3
|
+
const require_tracing = require("./tracing-C0ooU0V2.cjs");
|
|
4
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
5
|
+
//#region src/external-api.ts
|
|
6
|
+
/**
|
|
7
|
+
* `ExternalApi` — an HTTP API somebody else runs.
|
|
8
|
+
*
|
|
9
|
+
* Polar, Stripe, a payment gateway: nothing to provision, but an address that
|
|
10
|
+
* changes by stage and credentials the provider issued for each one. Without a
|
|
11
|
+
* construct every integration writes that switching by hand — an optional
|
|
12
|
+
* `POLAR_URL`, a fake started somewhere, a client built in a service — and the
|
|
13
|
+
* target cannot see any of it.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* // constructs/polar.ts
|
|
17
|
+
* export const polar = new ExternalApi('Polar', {
|
|
18
|
+
* url: 'https://www.polaraccesslink.com',
|
|
19
|
+
* credentials: z.object({ clientId: z.string(), clientSecret: z.string() }),
|
|
20
|
+
* client: ({ url, credentials }) => new PolarClient(url, credentials),
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // test/fakes/polar.ts
|
|
24
|
+
* export default fake.app(new Hono().post('/v3/oauth2/token', …), {
|
|
25
|
+
* credentials: { clientId: 'fake', clientSecret: 'fake' },
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // in a handler — the real API deployed, the fake locally and in tests
|
|
29
|
+
* .dependsOn([polar])
|
|
30
|
+
* .handle(({ services }) => services.polar.exchangeCode(code))
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Deployed, the URL is `url` — one for every stage, or one per stage name with
|
|
34
|
+
* a `default` — and the credentials are the stage's `<ID>_CREDENTIALS`, one
|
|
35
|
+
* JSON value read the way a `Credential`'s is. Locally and in tests both come
|
|
36
|
+
* from the fake.
|
|
37
|
+
*
|
|
38
|
+
* **The construct never names its fake.** It is found by convention, at
|
|
39
|
+
* `test/fakes/<id>.ts`, and read only by gkm and the generated test harness —
|
|
40
|
+
* so a fake, and the recorded responses it answers from, cannot end up in a
|
|
41
|
+
* deployed bundle however the bundler follows imports.
|
|
42
|
+
*/
|
|
43
|
+
var ExternalApi = class {
|
|
44
|
+
options;
|
|
45
|
+
id;
|
|
46
|
+
service;
|
|
47
|
+
/** Read by both `declare()` and `connect()`, so the two cannot drift. */
|
|
48
|
+
keys;
|
|
49
|
+
/** The promise, so concurrent registrations share one client. */
|
|
50
|
+
connected;
|
|
51
|
+
constructor(id, options) {
|
|
52
|
+
this.options = options;
|
|
53
|
+
const canonical = (0, _geekmidas_manifest.canonicalId)(id);
|
|
54
|
+
this.id = canonical;
|
|
55
|
+
this.keys = {
|
|
56
|
+
url: (0, _geekmidas_manifest.provideKey)(canonical, "url"),
|
|
57
|
+
credentials: (0, _geekmidas_manifest.provideKey)(canonical, "credentials")
|
|
58
|
+
};
|
|
59
|
+
this.service = {
|
|
60
|
+
serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
|
|
61
|
+
register: (registerOptions) => {
|
|
62
|
+
this.connected ??= this.connect(registerOptions);
|
|
63
|
+
return this.connected;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* What the stage's `<ID>_CREDENTIALS` must look like — the schema the value
|
|
69
|
+
* is validated against where it is read. Public so a tool setting the value
|
|
70
|
+
* (`gkm secrets:add`) can check it, and describe its fields, before it is
|
|
71
|
+
* stored rather than at the first request.
|
|
72
|
+
*/
|
|
73
|
+
get credentialsSchema() {
|
|
74
|
+
return this.options.credentials;
|
|
75
|
+
}
|
|
76
|
+
declare() {
|
|
77
|
+
return [{
|
|
78
|
+
kind: "external-api",
|
|
79
|
+
id: this.id,
|
|
80
|
+
url: this.options.url,
|
|
81
|
+
provides: [this.keys.url, this.keys.credentials]
|
|
82
|
+
}];
|
|
83
|
+
}
|
|
84
|
+
async connect(options) {
|
|
85
|
+
const { url } = options.envParser.create((get) => ({ url: get(this.keys.url).string() })).parse();
|
|
86
|
+
const credentials = await require_credential.readCredentials(this.id, this.keys.credentials, this.options.credentials, options.envParser);
|
|
87
|
+
const client = await this.options.client({
|
|
88
|
+
url,
|
|
89
|
+
credentials
|
|
90
|
+
});
|
|
91
|
+
return require_tracing.traceClient(this.id, client, { "server.address": hostOf(url) });
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
function hostOf(url) {
|
|
95
|
+
try {
|
|
96
|
+
return new URL(url).host;
|
|
97
|
+
} catch {
|
|
98
|
+
return url;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
exports.ExternalApi = ExternalApi;
|
|
103
|
+
exports.fake = require_credential.fake;
|
|
104
|
+
exports.isFake = require_credential.isFake;
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=external-api.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-api.cjs","names":["canonicalId","provideKey","serviceKey","readCredentials","traceClient"],"sources":["../src/external-api.ts"],"sourcesContent":["/**\n * `ExternalApi` — an HTTP API somebody else runs.\n *\n * Polar, Stripe, a payment gateway: nothing to provision, but an address that\n * changes by stage and credentials the provider issued for each one. Without a\n * construct every integration writes that switching by hand — an optional\n * `POLAR_URL`, a fake started somewhere, a client built in a service — and the\n * target cannot see any of it.\n *\n * ```ts\n * // constructs/polar.ts\n * export const polar = new ExternalApi('Polar', {\n * url: 'https://www.polaraccesslink.com',\n * credentials: z.object({ clientId: z.string(), clientSecret: z.string() }),\n * client: ({ url, credentials }) => new PolarClient(url, credentials),\n * });\n *\n * // test/fakes/polar.ts\n * export default fake.app(new Hono().post('/v3/oauth2/token', …), {\n * credentials: { clientId: 'fake', clientSecret: 'fake' },\n * });\n *\n * // in a handler — the real API deployed, the fake locally and in tests\n * .dependsOn([polar])\n * .handle(({ services }) => services.polar.exchangeCode(code))\n * ```\n *\n * Deployed, the URL is `url` — one for every stage, or one per stage name with\n * a `default` — and the credentials are the stage's `<ID>_CREDENTIALS`, one\n * JSON value read the way a `Credential`'s is. Locally and in tests both come\n * from the fake.\n *\n * **The construct never names its fake.** It is found by convention, at\n * `test/fakes/<id>.ts`, and read only by gkm and the generated test harness —\n * so a fake, and the recorded responses it answers from, cannot end up in a\n * deployed bundle however the bundler follows imports.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\nimport { readCredentials } from './credential';\nimport type { DeployedStage, LocalStage } from './stages';\nimport { traceClient } from './tracing';\n\n/** What a credentials schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\n/**\n * Where an external API answers: one URL for every stage, or one per stage\n * name with `default` for any stage not listed.\n *\n * Keyed by the stages `gkm.config.ts` declares once `.gkm/stages.d.ts` exists,\n * so a key that names no stage — `prodution` — is a type error rather than a\n * URL nothing reads. Without the file any key goes, as before.\n */\nexport type ExternalApiUrl =\n\t| string\n\t| (string extends LocalStage | DeployedStage\n\t\t\t? Readonly<Record<string, string>>\n\t\t\t: { readonly [S in LocalStage | DeployedStage]?: string } & {\n\t\t\t\t\treadonly default?: string;\n\t\t\t\t});\n\nexport interface ExternalApiOptions<TSchema extends StandardSchemaV1, TClient> {\n\t/**\n\t * Where it answers deployed: one URL for every stage, or one per stage\n\t * name, with `default` for any stage not listed.\n\t */\n\turl: ExternalApiUrl;\n\t/** What the stage's `<ID>_CREDENTIALS` must look like. */\n\tcredentials: TSchema;\n\t/** What a handler is handed, built from where it answers and the credentials. */\n\tclient: (connection: {\n\t\turl: string;\n\t\tcredentials: Value<TSchema>;\n\t}) => TClient | Promise<TClient>;\n}\n\nexport class ExternalApi<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n\tTClient = unknown,\n> implements Consumable<TName, TClient>\n{\n\t// `Consumable` for the reason `Credential` gives: a client generic in\n\t// `TClient` cannot satisfy `Construct`'s conditional service type.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\n\t/** Read by both `declare()` and `connect()`, so the two cannot drift. */\n\tprivate readonly keys: { url: string; credentials: string };\n\n\t/** The promise, so concurrent registrations share one client. */\n\tprivate connected?: Promise<TClient>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: ExternalApiOptions<TSchema, TClient>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\tcredentials: provideKey(canonical, 'credentials'),\n\t\t};\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (registerOptions) => {\n\t\t\t\tthis.connected ??= this.connect(registerOptions);\n\t\t\t\treturn this.connected;\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value\n\t * is validated against where it is read. Public so a tool setting the value\n\t * (`gkm secrets:add`) can check it, and describe its fields, before it is\n\t * stored rather than at the first request.\n\t */\n\tget credentialsSchema(): TSchema {\n\t\treturn this.options.credentials;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'external-api',\n\t\t\t\tid: this.id,\n\t\t\t\t// The stage-keyed map is a record of URLs to the manifest, which\n\t\t\t\t// reads it by whatever stage it is resolving.\n\t\t\t\turl: this.options.url as Readonly<Record<string, string>> | string,\n\t\t\t\tprovides: [this.keys.url, this.keys.credentials],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate async connect(options: ServiceRegisterOptions): Promise<TClient> {\n\t\tconst { url } = options.envParser\n\t\t\t.create((get) => ({ url: get(this.keys.url).string() }))\n\t\t\t.parse();\n\t\tconst credentials = await readCredentials(\n\t\t\tthis.id,\n\t\t\tthis.keys.credentials,\n\t\t\tthis.options.credentials,\n\t\t\toptions.envParser,\n\t\t);\n\n\t\tconst client = await this.options.client({ url, credentials });\n\t\t// Each call a span carrying this API's name — the parent of the fetch\n\t\t// it makes, which is traced already.\n\t\treturn traceClient(this.id, client, {\n\t\t\t'server.address': hostOf(url),\n\t\t});\n\t}\n}\n\nfunction hostOf(url: string): string {\n\ttry {\n\t\treturn new URL(url).host;\n\t} catch {\n\t\treturn url;\n\t}\n}\n\nexport {\n\ttype Fake,\n\ttype FetchHandler,\n\tfake,\n\tisFake,\n} from './fake';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,IAAa,cAAb,MAKA;CAcmB;CAXlB;CACA;;CAGA;;CAGA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,aAAA,GAAYA,oBAAAA,YAAAA,CAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO;GACX,MAAA,GAAKC,oBAAAA,WAAAA,CAAW,WAAW,KAAK;GAChC,cAAA,GAAaA,oBAAAA,WAAAA,CAAW,WAAW,aAAa;EACjD;EAGA,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,SAAS;GACjC,WAAW,oBAAoB;IAC9B,KAAK,cAAc,KAAK,QAAQ,eAAe;IAC/C,OAAO,KAAK;GACb;EACD;CACD;;;;;;;CAQA,IAAI,oBAA6B;EAChC,OAAO,KAAK,QAAQ;CACrB;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GAGT,KAAK,KAAK,QAAQ;GAClB,UAAU,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,WAAW;EAChD,CACD;CACD;CAEA,MAAc,QAAQ,SAAmD;EACxE,MAAM,EAAE,QAAQ,QAAQ,UACtB,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACvD,MAAM;EACR,MAAM,cAAc,MAAMC,mBAAAA,gBACzB,KAAK,IACL,KAAK,KAAK,aACV,KAAK,QAAQ,aACb,QAAQ,SACT;EAEA,MAAM,SAAS,MAAM,KAAK,QAAQ,OAAO;GAAE;GAAK;EAAY,CAAC;EAG7D,OAAOC,gBAAAA,YAAY,KAAK,IAAI,QAAQ,EACnC,kBAAkB,OAAO,GAAG,EAC7B,CAAC;CACF;AACD;AAEA,SAAS,OAAO,KAAqB;CACpC,IAAI;EACH,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC;CACrB,QAAQ;EACP,OAAO;CACR;AACD"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { a as fake, i as readCredentials, o as isFake } from "./credential-DfSAOOdY.mjs";
|
|
2
|
+
import { i as traceClient } from "./tracing-Bbj1uoFJ.mjs";
|
|
3
|
+
import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
4
|
+
//#region src/external-api.ts
|
|
5
|
+
/**
|
|
6
|
+
* `ExternalApi` — an HTTP API somebody else runs.
|
|
7
|
+
*
|
|
8
|
+
* Polar, Stripe, a payment gateway: nothing to provision, but an address that
|
|
9
|
+
* changes by stage and credentials the provider issued for each one. Without a
|
|
10
|
+
* construct every integration writes that switching by hand — an optional
|
|
11
|
+
* `POLAR_URL`, a fake started somewhere, a client built in a service — and the
|
|
12
|
+
* target cannot see any of it.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* // constructs/polar.ts
|
|
16
|
+
* export const polar = new ExternalApi('Polar', {
|
|
17
|
+
* url: 'https://www.polaraccesslink.com',
|
|
18
|
+
* credentials: z.object({ clientId: z.string(), clientSecret: z.string() }),
|
|
19
|
+
* client: ({ url, credentials }) => new PolarClient(url, credentials),
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // test/fakes/polar.ts
|
|
23
|
+
* export default fake.app(new Hono().post('/v3/oauth2/token', …), {
|
|
24
|
+
* credentials: { clientId: 'fake', clientSecret: 'fake' },
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // in a handler — the real API deployed, the fake locally and in tests
|
|
28
|
+
* .dependsOn([polar])
|
|
29
|
+
* .handle(({ services }) => services.polar.exchangeCode(code))
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Deployed, the URL is `url` — one for every stage, or one per stage name with
|
|
33
|
+
* a `default` — and the credentials are the stage's `<ID>_CREDENTIALS`, one
|
|
34
|
+
* JSON value read the way a `Credential`'s is. Locally and in tests both come
|
|
35
|
+
* from the fake.
|
|
36
|
+
*
|
|
37
|
+
* **The construct never names its fake.** It is found by convention, at
|
|
38
|
+
* `test/fakes/<id>.ts`, and read only by gkm and the generated test harness —
|
|
39
|
+
* so a fake, and the recorded responses it answers from, cannot end up in a
|
|
40
|
+
* deployed bundle however the bundler follows imports.
|
|
41
|
+
*/
|
|
42
|
+
var ExternalApi = class {
|
|
43
|
+
options;
|
|
44
|
+
id;
|
|
45
|
+
service;
|
|
46
|
+
/** Read by both `declare()` and `connect()`, so the two cannot drift. */
|
|
47
|
+
keys;
|
|
48
|
+
/** The promise, so concurrent registrations share one client. */
|
|
49
|
+
connected;
|
|
50
|
+
constructor(id, options) {
|
|
51
|
+
this.options = options;
|
|
52
|
+
const canonical = canonicalId(id);
|
|
53
|
+
this.id = canonical;
|
|
54
|
+
this.keys = {
|
|
55
|
+
url: provideKey(canonical, "url"),
|
|
56
|
+
credentials: provideKey(canonical, "credentials")
|
|
57
|
+
};
|
|
58
|
+
this.service = {
|
|
59
|
+
serviceName: serviceKey(canonical),
|
|
60
|
+
register: (registerOptions) => {
|
|
61
|
+
this.connected ??= this.connect(registerOptions);
|
|
62
|
+
return this.connected;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* What the stage's `<ID>_CREDENTIALS` must look like — the schema the value
|
|
68
|
+
* is validated against where it is read. Public so a tool setting the value
|
|
69
|
+
* (`gkm secrets:add`) can check it, and describe its fields, before it is
|
|
70
|
+
* stored rather than at the first request.
|
|
71
|
+
*/
|
|
72
|
+
get credentialsSchema() {
|
|
73
|
+
return this.options.credentials;
|
|
74
|
+
}
|
|
75
|
+
declare() {
|
|
76
|
+
return [{
|
|
77
|
+
kind: "external-api",
|
|
78
|
+
id: this.id,
|
|
79
|
+
url: this.options.url,
|
|
80
|
+
provides: [this.keys.url, this.keys.credentials]
|
|
81
|
+
}];
|
|
82
|
+
}
|
|
83
|
+
async connect(options) {
|
|
84
|
+
const { url } = options.envParser.create((get) => ({ url: get(this.keys.url).string() })).parse();
|
|
85
|
+
const credentials = await readCredentials(this.id, this.keys.credentials, this.options.credentials, options.envParser);
|
|
86
|
+
const client = await this.options.client({
|
|
87
|
+
url,
|
|
88
|
+
credentials
|
|
89
|
+
});
|
|
90
|
+
return traceClient(this.id, client, { "server.address": hostOf(url) });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function hostOf(url) {
|
|
94
|
+
try {
|
|
95
|
+
return new URL(url).host;
|
|
96
|
+
} catch {
|
|
97
|
+
return url;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { ExternalApi, fake, isFake };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=external-api.mjs.map
|