@geekmidas/constructs 10.0.0-alpha.17 → 10.0.0-alpha.170
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 +246 -158
- package/dist/Construct-127M7yrl.d.cts +231 -0
- package/dist/Construct-127M7yrl.d.cts.map +1 -0
- package/dist/Construct-BMk_CRSD.d.mts +231 -0
- package/dist/Construct-BMk_CRSD.d.mts.map +1 -0
- package/dist/{Construct-BeYVu_QF.mjs → Construct-CGuc_Ijk.mjs} +8 -9
- package/dist/Construct-CGuc_Ijk.mjs.map +1 -0
- package/dist/{Construct-DqdlARxq.cjs → Construct-DorKS0Ua.cjs} +8 -9
- package/dist/Construct-DorKS0Ua.cjs.map +1 -0
- package/dist/{Cron-l4Wlz6G9.d.mts → Cron-Ca_qHQu2.d.cts} +16 -9
- package/dist/Cron-Ca_qHQu2.d.cts.map +1 -0
- package/dist/{Cron-zsoSAwZo.d.cts → Cron-DPJiR7Lt.d.mts} +15 -8
- package/dist/Cron-DPJiR7Lt.d.mts.map +1 -0
- package/dist/CronBuilder-BC4za5Bx.d.mts +47 -0
- package/dist/CronBuilder-BC4za5Bx.d.mts.map +1 -0
- package/dist/{CronBuilder-D_0HNBTr.mjs → CronBuilder-BJ5LoadF.mjs} +28 -11
- package/dist/CronBuilder-BJ5LoadF.mjs.map +1 -0
- package/dist/{CronBuilder-BdnI6lxF.cjs → CronBuilder-B_NSP-Y5.cjs} +27 -10
- package/dist/CronBuilder-B_NSP-Y5.cjs.map +1 -0
- package/dist/CronBuilder-C3RrAF1-.d.cts +47 -0
- package/dist/CronBuilder-C3RrAF1-.d.cts.map +1 -0
- package/dist/Endpoint-52z1P0Ue.cjs +581 -0
- package/dist/Endpoint-52z1P0Ue.cjs.map +1 -0
- package/dist/{Endpoint-DBflWAe4.d.cts → Endpoint-BlIZLsBQ.d.cts} +101 -20
- package/dist/Endpoint-BlIZLsBQ.d.cts.map +1 -0
- package/dist/{Endpoint-oS-Fe3d_.d.mts → Endpoint-DC7mreOr.d.mts} +104 -23
- package/dist/Endpoint-DC7mreOr.d.mts.map +1 -0
- package/dist/Endpoint-sUOU7uLx.mjs +552 -0
- package/dist/Endpoint-sUOU7uLx.mjs.map +1 -0
- package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
- package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
- package/dist/{EndpointFactory-CLvWuHyt.cjs → EndpointFactory-Cf_Cs1ym.cjs} +309 -51
- package/dist/EndpointFactory-Cf_Cs1ym.cjs.map +1 -0
- package/dist/{index-Cc4kKPag.d.mts → EndpointFactory-DCmnCmkX.d.mts} +189 -106
- package/dist/EndpointFactory-DCmnCmkX.d.mts.map +1 -0
- package/dist/{index-C1ZwNOOk.d.cts → EndpointFactory-cVTb8kCc.d.cts} +187 -104
- package/dist/EndpointFactory-cVTb8kCc.d.cts.map +1 -0
- package/dist/Function-BIEsY0Hm.d.cts +76 -0
- package/dist/Function-BIEsY0Hm.d.cts.map +1 -0
- package/dist/Function-BKReud5p.d.mts +76 -0
- package/dist/Function-BKReud5p.d.mts.map +1 -0
- package/dist/{HonoEndpointAdaptor-92zavCsV.cjs → HonoEndpointAdaptor-BTbqfSaa.cjs} +115 -41
- package/dist/HonoEndpointAdaptor-BTbqfSaa.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-yYaU7jVJ.mjs → HonoEndpointAdaptor-CBVey2cY.mjs} +112 -38
- package/dist/HonoEndpointAdaptor-CBVey2cY.mjs.map +1 -0
- package/dist/ObjectSubscriberBuilder-AwGKoUKy.d.mts +129 -0
- package/dist/ObjectSubscriberBuilder-AwGKoUKy.d.mts.map +1 -0
- package/dist/ObjectSubscriberBuilder-CB6imsX4.d.cts +129 -0
- package/dist/ObjectSubscriberBuilder-CB6imsX4.d.cts.map +1 -0
- package/dist/ProcessorBuilder-CeEZ2vCx.d.cts +216 -0
- package/dist/ProcessorBuilder-CeEZ2vCx.d.cts.map +1 -0
- package/dist/ProcessorBuilder-CwIlm75W.d.mts +216 -0
- package/dist/ProcessorBuilder-CwIlm75W.d.mts.map +1 -0
- package/dist/Queue-9Hh20ZCk.mjs +104 -0
- package/dist/Queue-9Hh20ZCk.mjs.map +1 -0
- package/dist/{Queue-D9X6OoON.d.mts → Queue-B8HGg439.d.mts} +42 -41
- package/dist/Queue-B8HGg439.d.mts.map +1 -0
- package/dist/{Queue-DYPB2KWL.d.cts → Queue-C4rijiM7.d.cts} +43 -42
- package/dist/Queue-C4rijiM7.d.cts.map +1 -0
- package/dist/Queue-W1wueijP.cjs +109 -0
- package/dist/Queue-W1wueijP.cjs.map +1 -0
- package/dist/QueueBuilder-BDcv9B71.cjs +135 -0
- package/dist/QueueBuilder-BDcv9B71.cjs.map +1 -0
- package/dist/QueueBuilder-CUERv8jt.d.mts +75 -0
- package/dist/QueueBuilder-CUERv8jt.d.mts.map +1 -0
- package/dist/QueueBuilder-CmB1vOgn.d.cts +75 -0
- package/dist/QueueBuilder-CmB1vOgn.d.cts.map +1 -0
- package/dist/QueueBuilder-CrZL8HHs.mjs +118 -0
- package/dist/QueueBuilder-CrZL8HHs.mjs.map +1 -0
- package/dist/Subscriber-5rCX1Nph.d.cts +83 -0
- package/dist/Subscriber-5rCX1Nph.d.cts.map +1 -0
- package/dist/Subscriber-CtQXhcL7.d.mts +83 -0
- package/dist/Subscriber-CtQXhcL7.d.mts.map +1 -0
- package/dist/SubscriberBuilder-CpFhShTJ.mjs +238 -0
- package/dist/SubscriberBuilder-CpFhShTJ.mjs.map +1 -0
- package/dist/SubscriberBuilder-DJEvNRdD.cjs +261 -0
- package/dist/SubscriberBuilder-DJEvNRdD.cjs.map +1 -0
- package/dist/Topic-BGoOeCT6.mjs +99 -0
- package/dist/Topic-BGoOeCT6.mjs.map +1 -0
- package/dist/Topic-DLCZBNwK.cjs +104 -0
- package/dist/Topic-DLCZBNwK.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +147 -168
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +57 -48
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +58 -49
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +142 -164
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/awsWebsocket.cjs +354 -0
- package/dist/adaptors/awsWebsocket.cjs.map +1 -0
- package/dist/adaptors/awsWebsocket.d.cts +156 -0
- package/dist/adaptors/awsWebsocket.d.cts.map +1 -0
- package/dist/adaptors/awsWebsocket.d.mts +156 -0
- package/dist/adaptors/awsWebsocket.d.mts.map +1 -0
- package/dist/adaptors/awsWebsocket.mjs +347 -0
- package/dist/adaptors/awsWebsocket.mjs.map +1 -0
- package/dist/adaptors/hono.cjs +1 -1
- package/dist/adaptors/hono.d.cts +8 -7
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +10 -9
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +1 -1
- package/dist/adaptors/testing.cjs +1174 -41
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +517 -40
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +517 -40
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +1140 -36
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-1yI2wR-4.d.cts +274 -0
- package/dist/auth-1yI2wR-4.d.cts.map +1 -0
- package/dist/auth-D4NMXgLt.d.mts +274 -0
- package/dist/auth-D4NMXgLt.d.mts.map +1 -0
- package/dist/auth.cjs +311 -26
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -104
- package/dist/auth.d.mts +2 -104
- package/dist/auth.mjs +307 -28
- package/dist/auth.mjs.map +1 -1
- package/dist/cache-0VoeOTF9.d.mts +44 -0
- package/dist/cache-0VoeOTF9.d.mts.map +1 -0
- package/dist/cache-CW-sArzS.d.cts +44 -0
- package/dist/cache-CW-sArzS.d.cts.map +1 -0
- package/dist/cache.cjs +4 -20
- package/dist/cache.cjs.map +1 -1
- package/dist/cache.d.cts +2 -43
- package/dist/cache.d.mts +2 -43
- package/dist/cache.mjs +4 -20
- package/dist/cache.mjs.map +1 -1
- package/dist/cipher-C1lEFX63.mjs +225 -0
- package/dist/cipher-C1lEFX63.mjs.map +1 -0
- package/dist/cipher-CVxfwLjk.cjs +332 -0
- package/dist/cipher-CVxfwLjk.cjs.map +1 -0
- package/dist/cipher-DSDxPRIp.d.cts +106 -0
- package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
- package/dist/cipher-DSDxPRIp.d.mts +106 -0
- package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
- package/dist/{construct-interface-DPlxfpoS.d.mts → construct-interface-DhbaONW2.d.cts} +63 -8
- package/dist/construct-interface-DhbaONW2.d.cts.map +1 -0
- package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-DxfkFxkl.d.mts} +63 -8
- package/dist/construct-interface-DxfkFxkl.d.mts.map +1 -0
- package/dist/construct-interface.cjs +47 -4
- package/dist/construct-interface.cjs.map +1 -1
- package/dist/construct-interface.d.cts +2 -2
- package/dist/construct-interface.d.mts +2 -2
- package/dist/construct-interface.mjs +45 -5
- package/dist/construct-interface.mjs.map +1 -1
- package/dist/credential-B80mOxwT.mjs +222 -0
- package/dist/credential-B80mOxwT.mjs.map +1 -0
- package/dist/credential-RlgbzZAc.cjs +257 -0
- package/dist/credential-RlgbzZAc.cjs.map +1 -0
- package/dist/credential.cjs +7 -129
- package/dist/credential.d.cts +2 -58
- package/dist/credential.d.mts +2 -58
- package/dist/credential.mjs +2 -128
- package/dist/crons/index.cjs +127 -1
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +43 -3
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +43 -3
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +126 -2
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +3 -194
- package/dist/database/kysely.d.cts +2 -149
- package/dist/database/kysely.d.mts +2 -149
- package/dist/database/kysely.mjs +2 -192
- package/dist/email.cjs +24 -17
- package/dist/email.cjs.map +1 -1
- package/dist/email.d.cts +15 -5
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +16 -6
- package/dist/email.d.mts.map +1 -1
- package/dist/email.mjs +23 -17
- package/dist/email.mjs.map +1 -1
- package/dist/encryption/kms.cjs +95 -0
- package/dist/encryption/kms.cjs.map +1 -0
- package/dist/encryption/kms.d.cts +7 -0
- package/dist/encryption/kms.d.cts.map +1 -0
- package/dist/encryption/kms.d.mts +7 -0
- package/dist/encryption/kms.d.mts.map +1 -0
- package/dist/encryption/kms.mjs +93 -0
- package/dist/encryption/kms.mjs.map +1 -0
- package/dist/encryption.cjs +116 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +37 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +37 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +101 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +32 -10
- package/dist/endpoints/index.d.cts +106 -3
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +106 -3
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -4
- package/dist/expire-C586zznE.d.cts +38 -0
- package/dist/expire-C586zznE.d.cts.map +1 -0
- package/dist/expire-C586zznE.d.mts +38 -0
- package/dist/expire-C586zznE.d.mts.map +1 -0
- package/dist/expire-CieftS01.cjs +67 -0
- package/dist/expire-CieftS01.cjs.map +1 -0
- package/dist/expire-CpzUAfr9.mjs +50 -0
- package/dist/expire-CpzUAfr9.mjs.map +1 -0
- package/dist/external-api.cjs +106 -0
- package/dist/external-api.cjs.map +1 -0
- package/dist/external-api.d.cts +2 -0
- package/dist/external-api.d.mts +2 -0
- package/dist/external-api.mjs +103 -0
- package/dist/external-api.mjs.map +1 -0
- package/dist/fake-BvOXkZmj.d.mts +201 -0
- package/dist/fake-BvOXkZmj.d.mts.map +1 -0
- package/dist/fake-Djx8E0o1.d.cts +201 -0
- package/dist/fake-Djx8E0o1.d.cts.map +1 -0
- package/dist/file-server.cjs +200 -48
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +147 -15
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +147 -15
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +198 -50
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +1 -1
- package/dist/functions/index.d.cts +2 -1
- package/dist/functions/index.d.mts +2 -1
- package/dist/functions/index.mjs +1 -1
- package/dist/{functions-C53GW2eQ.mjs → functions-BvIDQKAA.mjs} +117 -22
- package/dist/functions-BvIDQKAA.mjs.map +1 -0
- package/dist/{functions-B6qCvfmy.cjs → functions-DLF6-IK8.cjs} +122 -18
- package/dist/functions-DLF6-IK8.cjs.map +1 -0
- package/dist/inbox-BjvMs7EJ.d.cts +195 -0
- package/dist/inbox-BjvMs7EJ.d.cts.map +1 -0
- package/dist/inbox-C8bOR9UL.d.mts +195 -0
- package/dist/inbox-C8bOR9UL.d.mts.map +1 -0
- package/dist/inbox.cjs +291 -0
- package/dist/inbox.cjs.map +1 -0
- package/dist/inbox.d.cts +2 -0
- package/dist/inbox.d.mts +2 -0
- package/dist/inbox.mjs +283 -0
- package/dist/inbox.mjs.map +1 -0
- package/dist/index-DaK-C7N3.d.cts +115 -0
- package/dist/index-DaK-C7N3.d.cts.map +1 -0
- package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
- package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
- package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
- package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
- package/dist/index-vCS4HBEG.d.mts +115 -0
- package/dist/index-vCS4HBEG.d.mts.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +26 -3
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +26 -3
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -2
- package/dist/kysely-2HqIQ2fC.d.cts +216 -0
- package/dist/kysely-2HqIQ2fC.d.cts.map +1 -0
- package/dist/kysely-BGvpd_ZH.d.mts +216 -0
- package/dist/kysely-BGvpd_ZH.d.mts.map +1 -0
- package/dist/kysely-Bc9xzaik.mjs +371 -0
- package/dist/kysely-Bc9xzaik.mjs.map +1 -0
- package/dist/kysely-D7f6J2lh.cjs +384 -0
- package/dist/kysely-D7f6J2lh.cjs.map +1 -0
- package/dist/{telemetry-DGcFlVpB.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +2 -2
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
- package/dist/{telemetry-DGcFlVpB.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +2 -2
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
- package/dist/mobile-app.cjs +78 -0
- package/dist/mobile-app.cjs.map +1 -0
- package/dist/mobile-app.d.cts +77 -0
- package/dist/mobile-app.d.cts.map +1 -0
- package/dist/mobile-app.d.mts +77 -0
- package/dist/mobile-app.d.mts.map +1 -0
- package/dist/mobile-app.mjs +77 -0
- package/dist/mobile-app.mjs.map +1 -0
- package/dist/object-storage.cjs +14 -7
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +12 -3
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +12 -3
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +14 -9
- package/dist/object-storage.mjs.map +1 -1
- package/dist/optionalPeers-D7Wt6dnF.mjs +140 -0
- package/dist/optionalPeers-D7Wt6dnF.mjs.map +1 -0
- package/dist/optionalPeers-DuNQXXe1.cjs +223 -0
- package/dist/optionalPeers-DuNQXXe1.cjs.map +1 -0
- package/dist/origins-BjxYht13.cjs +96 -0
- package/dist/origins-BjxYht13.cjs.map +1 -0
- package/dist/origins-Boc9qbo-.mjs +73 -0
- package/dist/origins-Boc9qbo-.mjs.map +1 -0
- package/dist/pattern-C1CEcglD.mjs +241 -0
- package/dist/pattern-C1CEcglD.mjs.map +1 -0
- package/dist/pattern-QFaUIr77.cjs +288 -0
- package/dist/pattern-QFaUIr77.cjs.map +1 -0
- package/dist/privateAddress-Bg5fUsbp.mjs +21 -0
- package/dist/privateAddress-Bg5fUsbp.mjs.map +1 -0
- package/dist/privateAddress-CqGyuFHn.cjs +26 -0
- package/dist/privateAddress-CqGyuFHn.cjs.map +1 -0
- package/dist/processors/index.cjs +214 -0
- package/dist/processors/index.cjs.map +1 -0
- package/dist/processors/index.d.cts +78 -0
- package/dist/processors/index.d.cts.map +1 -0
- package/dist/processors/index.d.mts +78 -0
- package/dist/processors/index.d.mts.map +1 -0
- package/dist/processors/index.mjs +193 -0
- package/dist/processors/index.mjs.map +1 -0
- package/dist/queue/index.cjs +5 -192
- package/dist/queue/index.d.cts +3 -53
- package/dist/queue/index.d.mts +3 -53
- package/dist/queue/index.mjs +3 -190
- package/dist/random-password.cjs +86 -0
- package/dist/random-password.cjs.map +1 -0
- package/dist/random-password.d.cts +30 -0
- package/dist/random-password.d.cts.map +1 -0
- package/dist/random-password.d.mts +30 -0
- package/dist/random-password.d.mts.map +1 -0
- package/dist/random-password.mjs +84 -0
- package/dist/random-password.mjs.map +1 -0
- package/dist/readRequestBody-BmKnPl0a.mjs +293 -0
- package/dist/readRequestBody-BmKnPl0a.mjs.map +1 -0
- package/dist/{lazyAccessors-Dx9NLwJZ.cjs → readRequestBody-CN9GVdeE.cjs} +141 -47
- package/dist/readRequestBody-CN9GVdeE.cjs.map +1 -0
- package/dist/{processAudits-D_2W5x8k.cjs → requestLogger-CnoYd-Ah.cjs} +63 -3
- package/dist/requestLogger-CnoYd-Ah.cjs.map +1 -0
- package/dist/{processAudits-BpRlPQMW.mjs → requestLogger-D2JS7pPM.mjs} +51 -3
- package/dist/requestLogger-D2JS7pPM.mjs.map +1 -0
- package/dist/rest-api.cjs +100 -73
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +83 -59
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +83 -59
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +97 -76
- package/dist/rest-api.mjs.map +1 -1
- package/dist/runSubscriber-HEqXkin1.mjs +117 -0
- package/dist/runSubscriber-HEqXkin1.mjs.map +1 -0
- package/dist/runSubscriber-sVJfLA0-.cjs +134 -0
- package/dist/runSubscriber-sVJfLA0-.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 +137 -10
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +153 -3
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +153 -3
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +117 -13
- package/dist/site.mjs.map +1 -1
- package/dist/stages-DaTaoQei.d.cts +73 -0
- package/dist/stages-DaTaoQei.d.cts.map +1 -0
- package/dist/stages-DaTaoQei.d.mts +73 -0
- package/dist/stages-DaTaoQei.d.mts.map +1 -0
- package/dist/subscribers/index.cjs +134 -1
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +74 -3
- package/dist/subscribers/index.d.cts.map +1 -0
- package/dist/subscribers/index.d.mts +74 -3
- package/dist/subscribers/index.d.mts.map +1 -0
- package/dist/subscribers/index.mjs +132 -2
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/telemetry-BirKau0X.d.mts +40 -0
- package/dist/telemetry-BirKau0X.d.mts.map +1 -0
- package/dist/telemetry-DjJgtQ_N.d.cts +40 -0
- package/dist/telemetry-DjJgtQ_N.d.cts.map +1 -0
- package/dist/telemetry.cjs +56 -0
- package/dist/telemetry.cjs.map +1 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +55 -0
- package/dist/telemetry.mjs.map +1 -0
- package/dist/topic/index.cjs +2 -134
- package/dist/topic/index.d.cts +2 -3
- package/dist/topic/index.d.mts +2 -3
- package/dist/topic/index.mjs +2 -132
- package/dist/tracing-Bbj1uoFJ.mjs +127 -0
- package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
- package/dist/tracing-C0ooU0V2.cjs +150 -0
- package/dist/tracing-C0ooU0V2.cjs.map +1 -0
- package/dist/websocket-api-C6LGg9-D.mjs +1716 -0
- package/dist/websocket-api-C6LGg9-D.mjs.map +1 -0
- package/dist/websocket-api-CD-E5Ogr.d.cts +1207 -0
- package/dist/websocket-api-CD-E5Ogr.d.cts.map +1 -0
- package/dist/websocket-api-CoKPJJRl.cjs +1895 -0
- package/dist/websocket-api-CoKPJJRl.cjs.map +1 -0
- package/dist/websocket-api-pJJfeTcm.d.mts +1207 -0
- package/dist/websocket-api-pJJfeTcm.d.mts.map +1 -0
- package/dist/websocket-api.cjs +42 -0
- package/dist/websocket-api.d.cts +2 -0
- package/dist/websocket-api.d.mts +2 -0
- package/dist/websocket-api.mjs +3 -0
- package/dist/worker.cjs +174 -32
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +147 -47
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +147 -47
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +175 -33
- package/dist/worker.mjs.map +1 -1
- package/package.json +180 -43
- package/dist/Construct-BeYVu_QF.mjs.map +0 -1
- package/dist/Construct-DfbwIntp.d.cts +0 -115
- package/dist/Construct-DfbwIntp.d.cts.map +0 -1
- package/dist/Construct-DqdlARxq.cjs.map +0 -1
- package/dist/Construct-l5aOn_jv.d.mts +0 -115
- package/dist/Construct-l5aOn_jv.d.mts.map +0 -1
- package/dist/Cron-l4Wlz6G9.d.mts.map +0 -1
- package/dist/Cron-zsoSAwZo.d.cts.map +0 -1
- package/dist/CronBuilder-BdnI6lxF.cjs.map +0 -1
- package/dist/CronBuilder-CyT71Nzg.d.cts +0 -41
- package/dist/CronBuilder-CyT71Nzg.d.cts.map +0 -1
- package/dist/CronBuilder-D_0HNBTr.mjs.map +0 -1
- package/dist/CronBuilder-UoNgFe8S.d.mts +0 -41
- package/dist/CronBuilder-UoNgFe8S.d.mts.map +0 -1
- package/dist/Endpoint-BpZHtJ2W.cjs +0 -1689
- package/dist/Endpoint-BpZHtJ2W.cjs.map +0 -1
- package/dist/Endpoint-DBflWAe4.d.cts.map +0 -1
- package/dist/Endpoint-ONsly_dq.mjs +0 -1671
- package/dist/Endpoint-ONsly_dq.mjs.map +0 -1
- package/dist/Endpoint-oS-Fe3d_.d.mts.map +0 -1
- package/dist/EndpointFactory-Bm3aKRdV.mjs.map +0 -1
- package/dist/EndpointFactory-CLvWuHyt.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-92zavCsV.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-yYaU7jVJ.mjs.map +0 -1
- package/dist/Queue-D9X6OoON.d.mts.map +0 -1
- package/dist/Queue-DYPB2KWL.d.cts.map +0 -1
- package/dist/Subscriber-C4heaAyO.d.mts +0 -51
- package/dist/Subscriber-C4heaAyO.d.mts.map +0 -1
- package/dist/Subscriber-CotDUELC.d.cts +0 -51
- package/dist/Subscriber-CotDUELC.d.cts.map +0 -1
- package/dist/SubscriberBuilder-BEv0eoHy.d.cts +0 -59
- package/dist/SubscriberBuilder-BEv0eoHy.d.cts.map +0 -1
- package/dist/SubscriberBuilder-C0ZEtGDI.cjs +0 -125
- package/dist/SubscriberBuilder-C0ZEtGDI.cjs.map +0 -1
- package/dist/SubscriberBuilder-h7B_cHMr.mjs +0 -114
- package/dist/SubscriberBuilder-h7B_cHMr.mjs.map +0 -1
- package/dist/SubscriberBuilder-tyH5yTk5.d.mts +0 -59
- package/dist/SubscriberBuilder-tyH5yTk5.d.mts.map +0 -1
- package/dist/Topic-DEVGo0Dm.d.cts +0 -89
- package/dist/Topic-DEVGo0Dm.d.cts.map +0 -1
- package/dist/Topic-zk_6Gthr.d.mts +0 -89
- package/dist/Topic-zk_6Gthr.d.mts.map +0 -1
- package/dist/auth.d.cts.map +0 -1
- package/dist/auth.d.mts.map +0 -1
- package/dist/cache.d.cts.map +0 -1
- package/dist/cache.d.mts.map +0 -1
- package/dist/construct-interface-DPlxfpoS.d.mts.map +0 -1
- package/dist/construct-interface-DgXTJcOD.d.cts.map +0 -1
- package/dist/credential.cjs.map +0 -1
- package/dist/credential.d.cts.map +0 -1
- package/dist/credential.d.mts.map +0 -1
- package/dist/credential.mjs.map +0 -1
- package/dist/database/kysely.cjs.map +0 -1
- package/dist/database/kysely.d.cts.map +0 -1
- package/dist/database/kysely.d.mts.map +0 -1
- package/dist/database/kysely.mjs.map +0 -1
- package/dist/functions-B6qCvfmy.cjs.map +0 -1
- package/dist/functions-C53GW2eQ.mjs.map +0 -1
- package/dist/index-B2urf3YI.d.cts +0 -26
- package/dist/index-B2urf3YI.d.cts.map +0 -1
- package/dist/index-C1ZwNOOk.d.cts.map +0 -1
- package/dist/index-Cc4kKPag.d.mts.map +0 -1
- package/dist/index-DMCDvnsM.d.mts +0 -26
- package/dist/index-DMCDvnsM.d.mts.map +0 -1
- package/dist/index-D_frT6MP.d.cts +0 -165
- package/dist/index-D_frT6MP.d.cts.map +0 -1
- package/dist/index-DcyIYbDS.d.mts +0 -165
- package/dist/index-DcyIYbDS.d.mts.map +0 -1
- package/dist/lazyAccessors-BHtcqgz2.mjs +0 -211
- package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
- package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
- package/dist/processAudits-BpRlPQMW.mjs.map +0 -1
- package/dist/processAudits-D_2W5x8k.cjs.map +0 -1
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts.map +0 -1
- package/dist/queue/index.d.mts.map +0 -1
- package/dist/queue/index.mjs.map +0 -1
- package/dist/telemetry-DGcFlVpB.d.cts.map +0 -1
- package/dist/telemetry-DGcFlVpB.d.mts.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { HttpError } from "@geekmidas/errors";
|
|
2
|
+
//#region src/endpoints/lazyAccessors.ts
|
|
3
|
+
/**
|
|
4
|
+
* One cookie from a `Cookie` header, read the way Hono's `getCookie` reads it:
|
|
5
|
+
* surrounding quotes dropped and percent-escapes decoded.
|
|
6
|
+
*
|
|
7
|
+
* Not `getCookie` itself: `hono` is an optional peer, and `./endpoints` is
|
|
8
|
+
* loaded by every app — including one served by API Gateway, which never
|
|
9
|
+
* installs Hono.
|
|
10
|
+
*/
|
|
11
|
+
function readCookie(header, name) {
|
|
12
|
+
if (!header) return void 0;
|
|
13
|
+
for (const part of header.split(";")) {
|
|
14
|
+
const eq = part.indexOf("=");
|
|
15
|
+
if (eq <= 0 || part.slice(0, eq).trim() !== name) continue;
|
|
16
|
+
let value = part.slice(eq + 1).trim();
|
|
17
|
+
if (value.length >= 2 && value.startsWith("\"") && value.endsWith("\"")) value = value.slice(1, -1);
|
|
18
|
+
if (!value.includes("%")) return value;
|
|
19
|
+
try {
|
|
20
|
+
return decodeURIComponent(value);
|
|
21
|
+
} catch {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a lazy header accessor for Hono.
|
|
28
|
+
* Uses `c.req.header(name)` for single lookups (native, case-insensitive).
|
|
29
|
+
* Only calls `c.req.header()` to get all headers when needed.
|
|
30
|
+
*/
|
|
31
|
+
function createHonoHeaders(c) {
|
|
32
|
+
let allHeaders = null;
|
|
33
|
+
return ((key) => {
|
|
34
|
+
if (key !== void 0) return c.req.header(key);
|
|
35
|
+
if (!allHeaders) allHeaders = c.req.header();
|
|
36
|
+
return allHeaders;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a lazy cookie accessor for Hono.
|
|
41
|
+
* Reads one cookie from the header for single lookups.
|
|
42
|
+
* Only parses the cookie header when all cookies are requested.
|
|
43
|
+
*/
|
|
44
|
+
function createHonoCookies(c) {
|
|
45
|
+
let allCookies = null;
|
|
46
|
+
return ((name) => {
|
|
47
|
+
if (name !== void 0) return readCookie(c.req.header("cookie"), name);
|
|
48
|
+
if (!allCookies) {
|
|
49
|
+
allCookies = {};
|
|
50
|
+
const cookieHeader = c.req.header("cookie");
|
|
51
|
+
if (cookieHeader) for (const part of cookieHeader.split(";")) {
|
|
52
|
+
const trimmed = part.trim();
|
|
53
|
+
const eqIndex = trimmed.indexOf("=");
|
|
54
|
+
if (eqIndex > 0) {
|
|
55
|
+
const key = trimmed.slice(0, eqIndex);
|
|
56
|
+
const value = trimmed.slice(eqIndex + 1);
|
|
57
|
+
allCookies[key] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return allCookies;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a lazy header accessor for API Gateway events.
|
|
66
|
+
* Handles case-insensitive lookups.
|
|
67
|
+
*/
|
|
68
|
+
function createApiGatewayHeaders(headers) {
|
|
69
|
+
let normalizedHeaders = null;
|
|
70
|
+
const normalize = () => {
|
|
71
|
+
if (!normalizedHeaders) {
|
|
72
|
+
normalizedHeaders = {};
|
|
73
|
+
if (headers) {
|
|
74
|
+
for (const [k, v] of Object.entries(headers)) if (v !== void 0) normalizedHeaders[k.toLowerCase()] = v;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return normalizedHeaders;
|
|
78
|
+
};
|
|
79
|
+
return ((key) => {
|
|
80
|
+
if (key !== void 0) {
|
|
81
|
+
if (headers) {
|
|
82
|
+
const direct = headers[key] ?? headers[key.toLowerCase()];
|
|
83
|
+
if (direct !== void 0) return direct;
|
|
84
|
+
return normalize()[key.toLowerCase()];
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
return normalize();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a lazy cookie accessor for API Gateway events.
|
|
93
|
+
* Decodes URL-encoded values to match browser behavior.
|
|
94
|
+
*/
|
|
95
|
+
function createApiGatewayCookies(cookies, cookieHeader) {
|
|
96
|
+
let parsed = null;
|
|
97
|
+
const parse = () => {
|
|
98
|
+
if (!parsed) {
|
|
99
|
+
parsed = {};
|
|
100
|
+
if (cookies) for (const cookie of cookies) {
|
|
101
|
+
const eqIndex = cookie.indexOf("=");
|
|
102
|
+
if (eqIndex > 0) {
|
|
103
|
+
const key = cookie.slice(0, eqIndex);
|
|
104
|
+
const value = cookie.slice(eqIndex + 1);
|
|
105
|
+
parsed[key] = decodeURIComponent(value);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (cookieHeader) for (const part of cookieHeader.split(";")) {
|
|
109
|
+
const trimmed = part.trim();
|
|
110
|
+
const eqIndex = trimmed.indexOf("=");
|
|
111
|
+
if (eqIndex > 0) {
|
|
112
|
+
const key = trimmed.slice(0, eqIndex);
|
|
113
|
+
const value = trimmed.slice(eqIndex + 1);
|
|
114
|
+
parsed[key] = decodeURIComponent(value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return parsed;
|
|
119
|
+
};
|
|
120
|
+
return ((name) => {
|
|
121
|
+
if (name !== void 0) return parse()[name];
|
|
122
|
+
return parse();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Create a lazy header accessor for plain object headers (test adaptor, etc).
|
|
127
|
+
* Headers are already available as an object, just provide lazy access.
|
|
128
|
+
*/
|
|
129
|
+
function createObjectHeaders(headers) {
|
|
130
|
+
let normalized = null;
|
|
131
|
+
return ((key) => {
|
|
132
|
+
if (key !== void 0) {
|
|
133
|
+
if (headers) {
|
|
134
|
+
const direct = headers[key] ?? headers[key.toLowerCase()];
|
|
135
|
+
if (direct !== void 0) return direct;
|
|
136
|
+
}
|
|
137
|
+
if (!normalized && headers) {
|
|
138
|
+
normalized = {};
|
|
139
|
+
for (const [k, v] of Object.entries(headers)) normalized[k.toLowerCase()] = v;
|
|
140
|
+
}
|
|
141
|
+
return normalized?.[key.toLowerCase()];
|
|
142
|
+
}
|
|
143
|
+
if (!normalized && headers) {
|
|
144
|
+
normalized = {};
|
|
145
|
+
for (const [k, v] of Object.entries(headers)) normalized[k.toLowerCase()] = v;
|
|
146
|
+
}
|
|
147
|
+
return normalized ?? {};
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Create a lazy cookie accessor from a cookie header string.
|
|
152
|
+
* Decodes URL-encoded values to match browser behavior.
|
|
153
|
+
*/
|
|
154
|
+
function createCookieHeaderAccessor(cookieHeader) {
|
|
155
|
+
let parsed = null;
|
|
156
|
+
const parse = () => {
|
|
157
|
+
if (!parsed) {
|
|
158
|
+
parsed = {};
|
|
159
|
+
if (cookieHeader) for (const part of cookieHeader.split(";")) {
|
|
160
|
+
const trimmed = part.trim();
|
|
161
|
+
const eqIndex = trimmed.indexOf("=");
|
|
162
|
+
if (eqIndex > 0) {
|
|
163
|
+
const key = trimmed.slice(0, eqIndex);
|
|
164
|
+
const value = trimmed.slice(eqIndex + 1);
|
|
165
|
+
parsed[key] = decodeURIComponent(value);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return parsed;
|
|
170
|
+
};
|
|
171
|
+
return ((name) => {
|
|
172
|
+
if (name !== void 0) return parse()[name];
|
|
173
|
+
return parse();
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create a no-op header accessor (for minimal endpoints that don't use headers).
|
|
178
|
+
*/
|
|
179
|
+
function createNoopHeaders() {
|
|
180
|
+
return ((key) => {
|
|
181
|
+
if (key !== void 0) return void 0;
|
|
182
|
+
return {};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Create a no-op cookie accessor (for minimal endpoints that don't use cookies).
|
|
187
|
+
*/
|
|
188
|
+
function createNoopCookies() {
|
|
189
|
+
return ((name) => {
|
|
190
|
+
if (name !== void 0) return void 0;
|
|
191
|
+
return {};
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/endpoints/readRequestBody.ts
|
|
196
|
+
/**
|
|
197
|
+
* The media types an endpoint's `.body()` schema can be handed — as written
|
|
198
|
+
* in the 415 a request in any other type is answered with.
|
|
199
|
+
*/
|
|
200
|
+
const SUPPORTED_BODY_TYPES = [
|
|
201
|
+
"application/json",
|
|
202
|
+
"application/x-www-form-urlencoded",
|
|
203
|
+
"multipart/form-data",
|
|
204
|
+
"text/*"
|
|
205
|
+
];
|
|
206
|
+
/**
|
|
207
|
+
* A request whose body is in a media type no endpoint reads — XML, a bare
|
|
208
|
+
* octet stream. Answered with a 415, before the body schema runs.
|
|
209
|
+
*/
|
|
210
|
+
var UnsupportedRequestContentType = class extends HttpError {
|
|
211
|
+
contentType;
|
|
212
|
+
constructor(contentType) {
|
|
213
|
+
super(415, `A body sent as '${contentType}' can't be read. Send it as ${SUPPORTED_BODY_TYPES.join(", ")}.`, {
|
|
214
|
+
statusMessage: "Unsupported Media Type",
|
|
215
|
+
details: {
|
|
216
|
+
contentType,
|
|
217
|
+
supported: [...SUPPORTED_BODY_TYPES]
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
this.contentType = contentType;
|
|
221
|
+
this.name = "UnsupportedRequestContentType";
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* A body that says it is JSON and is not. Answered with a 400 — the request
|
|
226
|
+
* is broken, not merely invalid against the schema.
|
|
227
|
+
*/
|
|
228
|
+
var MalformedRequestBody = class extends HttpError {
|
|
229
|
+
contentType;
|
|
230
|
+
constructor(contentType, cause) {
|
|
231
|
+
super(400, `The body says it is '${contentType}' but can't be parsed as that. Send a well-formed body, with the Content-Type it is written in.`, { cause });
|
|
232
|
+
this.contentType = contentType;
|
|
233
|
+
this.name = "MalformedRequestBody";
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* A request body, read by its Content-Type into what an endpoint's `.body()`
|
|
238
|
+
* schema validates — the one place every adaptor reads a body:
|
|
239
|
+
*
|
|
240
|
+
* - `application/json` (and `application/*+json`) — the parsed JSON.
|
|
241
|
+
* - `application/x-www-form-urlencoded` and `multipart/form-data` — a plain
|
|
242
|
+
* object of fields, as an HTML form posts them. A repeated field, or one
|
|
243
|
+
* named `field[]`, is an array; a file part is a `File`.
|
|
244
|
+
* - `text/*` — the text.
|
|
245
|
+
*
|
|
246
|
+
* Anything else is an {@link UnsupportedRequestContentType}.
|
|
247
|
+
*/
|
|
248
|
+
async function readRequestBody(source, contentType, options) {
|
|
249
|
+
const mediaType = contentType?.split(";")[0]?.trim().toLowerCase();
|
|
250
|
+
if (!mediaType) {
|
|
251
|
+
if (options.untyped === "empty") return {};
|
|
252
|
+
return readJson(source, "application/json");
|
|
253
|
+
}
|
|
254
|
+
if (isJson(mediaType)) return readJson(source, mediaType);
|
|
255
|
+
if (mediaType === "application/x-www-form-urlencoded" || mediaType === "multipart/form-data") return formFields(await readForm(source, mediaType));
|
|
256
|
+
if (mediaType.startsWith("text/")) return source.text();
|
|
257
|
+
throw new UnsupportedRequestContentType(mediaType);
|
|
258
|
+
}
|
|
259
|
+
function isJson(mediaType) {
|
|
260
|
+
return mediaType === "application/json" || mediaType.startsWith("application/") && mediaType.endsWith("+json");
|
|
261
|
+
}
|
|
262
|
+
async function readJson(source, mediaType) {
|
|
263
|
+
try {
|
|
264
|
+
return await source.json();
|
|
265
|
+
} catch (error) {
|
|
266
|
+
throw new MalformedRequestBody(mediaType, error);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
async function readForm(source, mediaType) {
|
|
270
|
+
try {
|
|
271
|
+
return await source.formData();
|
|
272
|
+
} catch (error) {
|
|
273
|
+
throw new MalformedRequestBody(mediaType, error);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* A form's fields as an object, the way Hono's `parseBody({ all: true })`
|
|
278
|
+
* reads them. Without a prototype, so a field named `__proto__` is a field.
|
|
279
|
+
*/
|
|
280
|
+
function formFields(form) {
|
|
281
|
+
const fields = Object.create(null);
|
|
282
|
+
for (const [key, value] of form.entries()) {
|
|
283
|
+
const existing = fields[key];
|
|
284
|
+
if (existing === void 0) fields[key] = key.endsWith("[]") ? [value] : value;
|
|
285
|
+
else if (Array.isArray(existing)) existing.push(value);
|
|
286
|
+
else fields[key] = [existing, value];
|
|
287
|
+
}
|
|
288
|
+
return fields;
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
export { createApiGatewayCookies as a, createHonoCookies as c, createNoopHeaders as d, createObjectHeaders as f, readRequestBody as i, createHonoHeaders as l, SUPPORTED_BODY_TYPES as n, createApiGatewayHeaders as o, UnsupportedRequestContentType as r, createCookieHeaderAccessor as s, MalformedRequestBody as t, createNoopCookies as u };
|
|
292
|
+
|
|
293
|
+
//# sourceMappingURL=readRequestBody-BmKnPl0a.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readRequestBody-BmKnPl0a.mjs","names":[],"sources":["../src/endpoints/lazyAccessors.ts","../src/endpoints/readRequestBody.ts"],"sourcesContent":["/**\n * Lazy header and cookie accessors for different adaptors.\n *\n * Instead of parsing all headers/cookies upfront, these accessors\n * use native adaptor methods for single lookups and only parse\n * everything when `header()` or `cookie()` is called without arguments.\n */\nimport type { Context } from 'hono';\nimport type { CookieFn, HeaderFn } from './Endpoint';\n\n/**\n * One cookie from a `Cookie` header, read the way Hono's `getCookie` reads it:\n * surrounding quotes dropped and percent-escapes decoded.\n *\n * Not `getCookie` itself: `hono` is an optional peer, and `./endpoints` is\n * loaded by every app — including one served by API Gateway, which never\n * installs Hono.\n */\nfunction readCookie(header: string | undefined, name: string) {\n\tif (!header) return undefined;\n\tfor (const part of header.split(';')) {\n\t\tconst eq = part.indexOf('=');\n\t\tif (eq <= 0 || part.slice(0, eq).trim() !== name) continue;\n\t\tlet value = part.slice(eq + 1).trim();\n\t\tif (value.length >= 2 && value.startsWith('\"') && value.endsWith('\"')) {\n\t\t\tvalue = value.slice(1, -1);\n\t\t}\n\t\tif (!value.includes('%')) return value;\n\t\ttry {\n\t\t\treturn decodeURIComponent(value);\n\t\t} catch {\n\t\t\treturn value;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Create a lazy header accessor for Hono.\n * Uses `c.req.header(name)` for single lookups (native, case-insensitive).\n * Only calls `c.req.header()` to get all headers when needed.\n */\nexport function createHonoHeaders(c: Context): HeaderFn {\n\tlet allHeaders: Record<string, string> | null = null;\n\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) {\n\t\t\t// Single header lookup - use native Hono method (case-insensitive)\n\t\t\treturn c.req.header(key);\n\t\t}\n\t\t// Get all headers - cache the result\n\t\tif (!allHeaders) {\n\t\t\tallHeaders = c.req.header();\n\t\t}\n\t\treturn allHeaders;\n\t}) as HeaderFn;\n}\n\n/**\n * Create a lazy cookie accessor for Hono.\n * Reads one cookie from the header for single lookups.\n * Only parses the cookie header when all cookies are requested.\n */\nexport function createHonoCookies(c: Context): CookieFn {\n\tlet allCookies: Record<string, string> | null = null;\n\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) {\n\t\t\t// Single cookie lookup\n\t\t\treturn readCookie(c.req.header('cookie'), name);\n\t\t}\n\t\t// Get all cookies - parse and cache\n\t\tif (!allCookies) {\n\t\t\tallCookies = {};\n\t\t\tconst cookieHeader = c.req.header('cookie');\n\t\t\tif (cookieHeader) {\n\t\t\t\tfor (const part of cookieHeader.split(';')) {\n\t\t\t\t\tconst trimmed = part.trim();\n\t\t\t\t\tconst eqIndex = trimmed.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = trimmed.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = trimmed.slice(eqIndex + 1);\n\t\t\t\t\t\tallCookies[key] = value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn allCookies;\n\t}) as CookieFn;\n}\n\n/**\n * Create a lazy header accessor for API Gateway events.\n * Handles case-insensitive lookups.\n */\nexport function createApiGatewayHeaders(\n\theaders: Record<string, string | undefined> | null | undefined,\n): HeaderFn {\n\tlet normalizedHeaders: Record<string, string> | null = null;\n\n\tconst normalize = () => {\n\t\tif (!normalizedHeaders) {\n\t\t\tnormalizedHeaders = {};\n\t\t\tif (headers) {\n\t\t\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\t\t\tif (v !== undefined) {\n\t\t\t\t\t\tnormalizedHeaders[k.toLowerCase()] = v;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn normalizedHeaders;\n\t};\n\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) {\n\t\t\t// Try direct lookup first (common case: headers already lowercase)\n\t\t\tif (headers) {\n\t\t\t\tconst direct = headers[key] ?? headers[key.toLowerCase()];\n\t\t\t\tif (direct !== undefined) return direct;\n\t\t\t\t// Fall back to normalized lookup\n\t\t\t\treturn normalize()[key.toLowerCase()];\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn normalize();\n\t}) as HeaderFn;\n}\n\n/**\n * Create a lazy cookie accessor for API Gateway events.\n * Decodes URL-encoded values to match browser behavior.\n */\nexport function createApiGatewayCookies(\n\tcookies: string[] | undefined,\n\tcookieHeader: string | undefined,\n): CookieFn {\n\tlet parsed: Record<string, string> | null = null;\n\n\tconst parse = () => {\n\t\tif (!parsed) {\n\t\t\tparsed = {};\n\t\t\t// API Gateway v2 provides cookies as array\n\t\t\tif (cookies) {\n\t\t\t\tfor (const cookie of cookies) {\n\t\t\t\t\tconst eqIndex = cookie.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = cookie.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = cookie.slice(eqIndex + 1);\n\t\t\t\t\t\tparsed[key] = decodeURIComponent(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (cookieHeader) {\n\t\t\t\t// Fall back to parsing cookie header\n\t\t\t\tfor (const part of cookieHeader.split(';')) {\n\t\t\t\t\tconst trimmed = part.trim();\n\t\t\t\t\tconst eqIndex = trimmed.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = trimmed.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = trimmed.slice(eqIndex + 1);\n\t\t\t\t\t\tparsed[key] = decodeURIComponent(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn parsed;\n\t};\n\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) {\n\t\t\treturn parse()[name];\n\t\t}\n\t\treturn parse();\n\t}) as CookieFn;\n}\n\n/**\n * Create a lazy header accessor for plain object headers (test adaptor, etc).\n * Headers are already available as an object, just provide lazy access.\n */\nexport function createObjectHeaders(\n\theaders: Record<string, string> | undefined,\n): HeaderFn {\n\tlet normalized: Record<string, string> | null = null;\n\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) {\n\t\t\t// Try direct lookup first (common case)\n\t\t\tif (headers) {\n\t\t\t\tconst direct = headers[key] ?? headers[key.toLowerCase()];\n\t\t\t\tif (direct !== undefined) return direct;\n\t\t\t}\n\t\t\t// Fall back to normalized lookup for case-insensitivity\n\t\t\tif (!normalized && headers) {\n\t\t\t\tnormalized = {};\n\t\t\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\t\t\tnormalized[k.toLowerCase()] = v;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn normalized?.[key.toLowerCase()];\n\t\t}\n\t\t// Return all headers\n\t\tif (!normalized && headers) {\n\t\t\tnormalized = {};\n\t\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\t\tnormalized[k.toLowerCase()] = v;\n\t\t\t}\n\t\t}\n\t\treturn normalized ?? {};\n\t}) as HeaderFn;\n}\n\n/**\n * Create a lazy cookie accessor from a cookie header string.\n * Decodes URL-encoded values to match browser behavior.\n */\nexport function createCookieHeaderAccessor(\n\tcookieHeader: string | undefined,\n): CookieFn {\n\tlet parsed: Record<string, string> | null = null;\n\n\tconst parse = () => {\n\t\tif (!parsed) {\n\t\t\tparsed = {};\n\t\t\tif (cookieHeader) {\n\t\t\t\tfor (const part of cookieHeader.split(';')) {\n\t\t\t\t\tconst trimmed = part.trim();\n\t\t\t\t\tconst eqIndex = trimmed.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = trimmed.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = trimmed.slice(eqIndex + 1);\n\t\t\t\t\t\t// Decode URL-encoded values to match Endpoint.createCookies behavior\n\t\t\t\t\t\tparsed[key] = decodeURIComponent(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn parsed;\n\t};\n\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) {\n\t\t\treturn parse()[name];\n\t\t}\n\t\treturn parse();\n\t}) as CookieFn;\n}\n\n/**\n * Create a no-op header accessor (for minimal endpoints that don't use headers).\n */\nexport function createNoopHeaders(): HeaderFn {\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) return undefined;\n\t\treturn {};\n\t}) as HeaderFn;\n}\n\n/**\n * Create a no-op cookie accessor (for minimal endpoints that don't use cookies).\n */\nexport function createNoopCookies(): CookieFn {\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) return undefined;\n\t\treturn {};\n\t}) as CookieFn;\n}\n","import { HttpError } from '@geekmidas/errors';\n\n/**\n * The media types an endpoint's `.body()` schema can be handed — as written\n * in the 415 a request in any other type is answered with.\n */\nexport const SUPPORTED_BODY_TYPES = [\n\t'application/json',\n\t'application/x-www-form-urlencoded',\n\t'multipart/form-data',\n\t'text/*',\n] as const;\n\n/**\n * A request whose body is in a media type no endpoint reads — XML, a bare\n * octet stream. Answered with a 415, before the body schema runs.\n */\nexport class UnsupportedRequestContentType extends HttpError {\n\tconstructor(readonly contentType: string) {\n\t\tsuper(\n\t\t\t415,\n\t\t\t`A body sent as '${contentType}' can't be read. Send it as ${SUPPORTED_BODY_TYPES.join(', ')}.`,\n\t\t\t{\n\t\t\t\tstatusMessage: 'Unsupported Media Type',\n\t\t\t\tdetails: { contentType, supported: [...SUPPORTED_BODY_TYPES] },\n\t\t\t},\n\t\t);\n\t\tthis.name = 'UnsupportedRequestContentType';\n\t}\n}\n\n/**\n * A body that says it is JSON and is not. Answered with a 400 — the request\n * is broken, not merely invalid against the schema.\n */\nexport class MalformedRequestBody extends HttpError {\n\tconstructor(\n\t\treadonly contentType: string,\n\t\tcause?: Error,\n\t) {\n\t\tsuper(\n\t\t\t400,\n\t\t\t`The body says it is '${contentType}' but can't be parsed as that. Send a well-formed body, with the Content-Type it is written in.`,\n\t\t\t{ cause },\n\t\t);\n\t\tthis.name = 'MalformedRequestBody';\n\t}\n}\n\n/**\n * What a body is read from: a `Request`, or Hono's request — which caches\n * what it read, so a later reader is not handed a spent stream.\n */\nexport interface RequestBodySource {\n\tjson(): Promise<unknown>;\n\ttext(): Promise<string>;\n\tformData(): Promise<FormData>;\n}\n\nexport interface ReadRequestBodyOptions {\n\t/**\n\t * A body with no Content-Type: read as JSON (`'json'`, what API Gateway\n\t * has always done), or not read at all and handed to the schema as `{}`\n\t * (`'empty'`, what a Hono server has always done).\n\t */\n\tuntyped: 'json' | 'empty';\n}\n\n/**\n * A request body, read by its Content-Type into what an endpoint's `.body()`\n * schema validates — the one place every adaptor reads a body:\n *\n * - `application/json` (and `application/*+json`) — the parsed JSON.\n * - `application/x-www-form-urlencoded` and `multipart/form-data` — a plain\n * object of fields, as an HTML form posts them. A repeated field, or one\n * named `field[]`, is an array; a file part is a `File`.\n * - `text/*` — the text.\n *\n * Anything else is an {@link UnsupportedRequestContentType}.\n */\nexport async function readRequestBody(\n\tsource: RequestBodySource,\n\tcontentType: string | null | undefined,\n\toptions: ReadRequestBodyOptions,\n): Promise<unknown> {\n\tconst mediaType = contentType?.split(';')[0]?.trim().toLowerCase();\n\n\tif (!mediaType) {\n\t\tif (options.untyped === 'empty') return {};\n\t\treturn readJson(source, 'application/json');\n\t}\n\n\tif (isJson(mediaType)) return readJson(source, mediaType);\n\n\tif (\n\t\tmediaType === 'application/x-www-form-urlencoded' ||\n\t\tmediaType === 'multipart/form-data'\n\t) {\n\t\treturn formFields(await readForm(source, mediaType));\n\t}\n\n\tif (mediaType.startsWith('text/')) return source.text();\n\n\tthrow new UnsupportedRequestContentType(mediaType);\n}\n\nfunction isJson(mediaType: string): boolean {\n\treturn (\n\t\tmediaType === 'application/json' ||\n\t\t(mediaType.startsWith('application/') && mediaType.endsWith('+json'))\n\t);\n}\n\nasync function readJson(\n\tsource: RequestBodySource,\n\tmediaType: string,\n): Promise<unknown> {\n\ttry {\n\t\treturn await source.json();\n\t} catch (error) {\n\t\tthrow new MalformedRequestBody(mediaType, error as Error);\n\t}\n}\n\nasync function readForm(\n\tsource: RequestBodySource,\n\tmediaType: string,\n): Promise<FormData> {\n\ttry {\n\t\treturn await source.formData();\n\t} catch (error) {\n\t\tthrow new MalformedRequestBody(mediaType, error as Error);\n\t}\n}\n\n/** A form field's value: its text, or a `File` for a file part. */\ntype FormValue = NonNullable<ReturnType<FormData['get']>>;\n\n/**\n * A form's fields as an object, the way Hono's `parseBody({ all: true })`\n * reads them. Without a prototype, so a field named `__proto__` is a field.\n */\nfunction formFields(form: FormData): Record<string, FormValue | FormValue[]> {\n\tconst fields: Record<string, FormValue | FormValue[]> = Object.create(null);\n\n\tfor (const [key, value] of form.entries()) {\n\t\tconst existing = fields[key];\n\t\tif (existing === undefined) {\n\t\t\tfields[key] = key.endsWith('[]') ? [value] : value;\n\t\t} else if (Array.isArray(existing)) {\n\t\t\texisting.push(value);\n\t\t} else {\n\t\t\tfields[key] = [existing, value];\n\t\t}\n\t}\n\n\treturn fields;\n}\n"],"mappings":";;;;;;;;;;AAkBA,SAAS,WAAW,QAA4B,MAAc;CAC7D,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,KAAK,MAAM,QAAQ,OAAO,MAAM,GAAG,GAAG;EACrC,MAAM,KAAK,KAAK,QAAQ,GAAG;EAC3B,IAAI,MAAM,KAAK,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,MAAM,MAAM;EAClD,IAAI,QAAQ,KAAK,MAAM,KAAK,CAAC,CAAC,CAAC,KAAK;EACpC,IAAI,MAAM,UAAU,KAAK,MAAM,WAAW,IAAG,KAAK,MAAM,SAAS,IAAG,GACnE,QAAQ,MAAM,MAAM,GAAG,EAAE;EAE1B,IAAI,CAAC,MAAM,SAAS,GAAG,GAAG,OAAO;EACjC,IAAI;GACH,OAAO,mBAAmB,KAAK;EAChC,QAAQ;GACP,OAAO;EACR;CACD;AAED;;;;;;AAOA,SAAgB,kBAAkB,GAAsB;CACvD,IAAI,aAA4C;CAEhD,SAAS,QAAiB;EACzB,IAAI,QAAQ,KAAA,GAEX,OAAO,EAAE,IAAI,OAAO,GAAG;EAGxB,IAAI,CAAC,YACJ,aAAa,EAAE,IAAI,OAAO;EAE3B,OAAO;CACR;AACD;;;;;;AAOA,SAAgB,kBAAkB,GAAsB;CACvD,IAAI,aAA4C;CAEhD,SAAS,SAAkB;EAC1B,IAAI,SAAS,KAAA,GAEZ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-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!when || when(response)) events.push(event);
|
|
24
|
-
}
|
|
25
|
-
if (events.length) {
|
|
26
|
-
logger.debug({ eventCount: ev.length }, "Publishing events");
|
|
27
|
-
await publisher.publish(events).catch((err) => {
|
|
28
|
-
logger.error(err, "Failed to publish events");
|
|
29
|
-
});
|
|
1
|
+
let _geekmidas_errors = require("@geekmidas/errors");
|
|
2
|
+
//#region src/endpoints/lazyAccessors.ts
|
|
3
|
+
/**
|
|
4
|
+
* One cookie from a `Cookie` header, read the way Hono's `getCookie` reads it:
|
|
5
|
+
* surrounding quotes dropped and percent-escapes decoded.
|
|
6
|
+
*
|
|
7
|
+
* Not `getCookie` itself: `hono` is an optional peer, and `./endpoints` is
|
|
8
|
+
* loaded by every app — including one served by API Gateway, which never
|
|
9
|
+
* installs Hono.
|
|
10
|
+
*/
|
|
11
|
+
function readCookie(header, name) {
|
|
12
|
+
if (!header) return void 0;
|
|
13
|
+
for (const part of header.split(";")) {
|
|
14
|
+
const eq = part.indexOf("=");
|
|
15
|
+
if (eq <= 0 || part.slice(0, eq).trim() !== name) continue;
|
|
16
|
+
let value = part.slice(eq + 1).trim();
|
|
17
|
+
if (value.length >= 2 && value.startsWith("\"") && value.endsWith("\"")) value = value.slice(1, -1);
|
|
18
|
+
if (!value.includes("%")) return value;
|
|
19
|
+
try {
|
|
20
|
+
return decodeURIComponent(value);
|
|
21
|
+
} catch {
|
|
22
|
+
return value;
|
|
30
23
|
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
logger.error(error, "Something went wrong publishing events");
|
|
33
24
|
}
|
|
34
25
|
}
|
|
35
|
-
async function publishConstructEvents(construct, response, serviceDiscovery, logger = construct.logger) {
|
|
36
|
-
return publishEvents(logger, serviceDiscovery, construct.events, response, construct.publisherService);
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/endpoints/lazyAccessors.ts
|
|
40
26
|
/**
|
|
41
27
|
* Create a lazy header accessor for Hono.
|
|
42
28
|
* Uses `c.req.header(name)` for single lookups (native, case-insensitive).
|
|
@@ -52,13 +38,13 @@ function createHonoHeaders(c) {
|
|
|
52
38
|
}
|
|
53
39
|
/**
|
|
54
40
|
* Create a lazy cookie accessor for Hono.
|
|
55
|
-
*
|
|
41
|
+
* Reads one cookie from the header for single lookups.
|
|
56
42
|
* Only parses the cookie header when all cookies are requested.
|
|
57
43
|
*/
|
|
58
44
|
function createHonoCookies(c) {
|
|
59
45
|
let allCookies = null;
|
|
60
46
|
return ((name) => {
|
|
61
|
-
if (name !== void 0) return (
|
|
47
|
+
if (name !== void 0) return readCookie(c.req.header("cookie"), name);
|
|
62
48
|
if (!allCookies) {
|
|
63
49
|
allCookies = {};
|
|
64
50
|
const cookieHeader = c.req.header("cookie");
|
|
@@ -206,6 +192,120 @@ function createNoopCookies() {
|
|
|
206
192
|
});
|
|
207
193
|
}
|
|
208
194
|
//#endregion
|
|
195
|
+
//#region src/endpoints/readRequestBody.ts
|
|
196
|
+
/**
|
|
197
|
+
* The media types an endpoint's `.body()` schema can be handed — as written
|
|
198
|
+
* in the 415 a request in any other type is answered with.
|
|
199
|
+
*/
|
|
200
|
+
const SUPPORTED_BODY_TYPES = [
|
|
201
|
+
"application/json",
|
|
202
|
+
"application/x-www-form-urlencoded",
|
|
203
|
+
"multipart/form-data",
|
|
204
|
+
"text/*"
|
|
205
|
+
];
|
|
206
|
+
/**
|
|
207
|
+
* A request whose body is in a media type no endpoint reads — XML, a bare
|
|
208
|
+
* octet stream. Answered with a 415, before the body schema runs.
|
|
209
|
+
*/
|
|
210
|
+
var UnsupportedRequestContentType = class extends _geekmidas_errors.HttpError {
|
|
211
|
+
contentType;
|
|
212
|
+
constructor(contentType) {
|
|
213
|
+
super(415, `A body sent as '${contentType}' can't be read. Send it as ${SUPPORTED_BODY_TYPES.join(", ")}.`, {
|
|
214
|
+
statusMessage: "Unsupported Media Type",
|
|
215
|
+
details: {
|
|
216
|
+
contentType,
|
|
217
|
+
supported: [...SUPPORTED_BODY_TYPES]
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
this.contentType = contentType;
|
|
221
|
+
this.name = "UnsupportedRequestContentType";
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* A body that says it is JSON and is not. Answered with a 400 — the request
|
|
226
|
+
* is broken, not merely invalid against the schema.
|
|
227
|
+
*/
|
|
228
|
+
var MalformedRequestBody = class extends _geekmidas_errors.HttpError {
|
|
229
|
+
contentType;
|
|
230
|
+
constructor(contentType, cause) {
|
|
231
|
+
super(400, `The body says it is '${contentType}' but can't be parsed as that. Send a well-formed body, with the Content-Type it is written in.`, { cause });
|
|
232
|
+
this.contentType = contentType;
|
|
233
|
+
this.name = "MalformedRequestBody";
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* A request body, read by its Content-Type into what an endpoint's `.body()`
|
|
238
|
+
* schema validates — the one place every adaptor reads a body:
|
|
239
|
+
*
|
|
240
|
+
* - `application/json` (and `application/*+json`) — the parsed JSON.
|
|
241
|
+
* - `application/x-www-form-urlencoded` and `multipart/form-data` — a plain
|
|
242
|
+
* object of fields, as an HTML form posts them. A repeated field, or one
|
|
243
|
+
* named `field[]`, is an array; a file part is a `File`.
|
|
244
|
+
* - `text/*` — the text.
|
|
245
|
+
*
|
|
246
|
+
* Anything else is an {@link UnsupportedRequestContentType}.
|
|
247
|
+
*/
|
|
248
|
+
async function readRequestBody(source, contentType, options) {
|
|
249
|
+
const mediaType = contentType?.split(";")[0]?.trim().toLowerCase();
|
|
250
|
+
if (!mediaType) {
|
|
251
|
+
if (options.untyped === "empty") return {};
|
|
252
|
+
return readJson(source, "application/json");
|
|
253
|
+
}
|
|
254
|
+
if (isJson(mediaType)) return readJson(source, mediaType);
|
|
255
|
+
if (mediaType === "application/x-www-form-urlencoded" || mediaType === "multipart/form-data") return formFields(await readForm(source, mediaType));
|
|
256
|
+
if (mediaType.startsWith("text/")) return source.text();
|
|
257
|
+
throw new UnsupportedRequestContentType(mediaType);
|
|
258
|
+
}
|
|
259
|
+
function isJson(mediaType) {
|
|
260
|
+
return mediaType === "application/json" || mediaType.startsWith("application/") && mediaType.endsWith("+json");
|
|
261
|
+
}
|
|
262
|
+
async function readJson(source, mediaType) {
|
|
263
|
+
try {
|
|
264
|
+
return await source.json();
|
|
265
|
+
} catch (error) {
|
|
266
|
+
throw new MalformedRequestBody(mediaType, error);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
async function readForm(source, mediaType) {
|
|
270
|
+
try {
|
|
271
|
+
return await source.formData();
|
|
272
|
+
} catch (error) {
|
|
273
|
+
throw new MalformedRequestBody(mediaType, error);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* A form's fields as an object, the way Hono's `parseBody({ all: true })`
|
|
278
|
+
* reads them. Without a prototype, so a field named `__proto__` is a field.
|
|
279
|
+
*/
|
|
280
|
+
function formFields(form) {
|
|
281
|
+
const fields = Object.create(null);
|
|
282
|
+
for (const [key, value] of form.entries()) {
|
|
283
|
+
const existing = fields[key];
|
|
284
|
+
if (existing === void 0) fields[key] = key.endsWith("[]") ? [value] : value;
|
|
285
|
+
else if (Array.isArray(existing)) existing.push(value);
|
|
286
|
+
else fields[key] = [existing, value];
|
|
287
|
+
}
|
|
288
|
+
return fields;
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
Object.defineProperty(exports, "MalformedRequestBody", {
|
|
292
|
+
enumerable: true,
|
|
293
|
+
get: function() {
|
|
294
|
+
return MalformedRequestBody;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
Object.defineProperty(exports, "SUPPORTED_BODY_TYPES", {
|
|
298
|
+
enumerable: true,
|
|
299
|
+
get: function() {
|
|
300
|
+
return SUPPORTED_BODY_TYPES;
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
Object.defineProperty(exports, "UnsupportedRequestContentType", {
|
|
304
|
+
enumerable: true,
|
|
305
|
+
get: function() {
|
|
306
|
+
return UnsupportedRequestContentType;
|
|
307
|
+
}
|
|
308
|
+
});
|
|
209
309
|
Object.defineProperty(exports, "createApiGatewayCookies", {
|
|
210
310
|
enumerable: true,
|
|
211
311
|
get: function() {
|
|
@@ -254,17 +354,11 @@ Object.defineProperty(exports, "createObjectHeaders", {
|
|
|
254
354
|
return createObjectHeaders;
|
|
255
355
|
}
|
|
256
356
|
});
|
|
257
|
-
Object.defineProperty(exports, "
|
|
258
|
-
enumerable: true,
|
|
259
|
-
get: function() {
|
|
260
|
-
return publishConstructEvents;
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
Object.defineProperty(exports, "publishEvents", {
|
|
357
|
+
Object.defineProperty(exports, "readRequestBody", {
|
|
264
358
|
enumerable: true,
|
|
265
359
|
get: function() {
|
|
266
|
-
return
|
|
360
|
+
return readRequestBody;
|
|
267
361
|
}
|
|
268
362
|
});
|
|
269
363
|
|
|
270
|
-
//# sourceMappingURL=
|
|
364
|
+
//# sourceMappingURL=readRequestBody-CN9GVdeE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readRequestBody-CN9GVdeE.cjs","names":["HttpError"],"sources":["../src/endpoints/lazyAccessors.ts","../src/endpoints/readRequestBody.ts"],"sourcesContent":["/**\n * Lazy header and cookie accessors for different adaptors.\n *\n * Instead of parsing all headers/cookies upfront, these accessors\n * use native adaptor methods for single lookups and only parse\n * everything when `header()` or `cookie()` is called without arguments.\n */\nimport type { Context } from 'hono';\nimport type { CookieFn, HeaderFn } from './Endpoint';\n\n/**\n * One cookie from a `Cookie` header, read the way Hono's `getCookie` reads it:\n * surrounding quotes dropped and percent-escapes decoded.\n *\n * Not `getCookie` itself: `hono` is an optional peer, and `./endpoints` is\n * loaded by every app — including one served by API Gateway, which never\n * installs Hono.\n */\nfunction readCookie(header: string | undefined, name: string) {\n\tif (!header) return undefined;\n\tfor (const part of header.split(';')) {\n\t\tconst eq = part.indexOf('=');\n\t\tif (eq <= 0 || part.slice(0, eq).trim() !== name) continue;\n\t\tlet value = part.slice(eq + 1).trim();\n\t\tif (value.length >= 2 && value.startsWith('\"') && value.endsWith('\"')) {\n\t\t\tvalue = value.slice(1, -1);\n\t\t}\n\t\tif (!value.includes('%')) return value;\n\t\ttry {\n\t\t\treturn decodeURIComponent(value);\n\t\t} catch {\n\t\t\treturn value;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Create a lazy header accessor for Hono.\n * Uses `c.req.header(name)` for single lookups (native, case-insensitive).\n * Only calls `c.req.header()` to get all headers when needed.\n */\nexport function createHonoHeaders(c: Context): HeaderFn {\n\tlet allHeaders: Record<string, string> | null = null;\n\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) {\n\t\t\t// Single header lookup - use native Hono method (case-insensitive)\n\t\t\treturn c.req.header(key);\n\t\t}\n\t\t// Get all headers - cache the result\n\t\tif (!allHeaders) {\n\t\t\tallHeaders = c.req.header();\n\t\t}\n\t\treturn allHeaders;\n\t}) as HeaderFn;\n}\n\n/**\n * Create a lazy cookie accessor for Hono.\n * Reads one cookie from the header for single lookups.\n * Only parses the cookie header when all cookies are requested.\n */\nexport function createHonoCookies(c: Context): CookieFn {\n\tlet allCookies: Record<string, string> | null = null;\n\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) {\n\t\t\t// Single cookie lookup\n\t\t\treturn readCookie(c.req.header('cookie'), name);\n\t\t}\n\t\t// Get all cookies - parse and cache\n\t\tif (!allCookies) {\n\t\t\tallCookies = {};\n\t\t\tconst cookieHeader = c.req.header('cookie');\n\t\t\tif (cookieHeader) {\n\t\t\t\tfor (const part of cookieHeader.split(';')) {\n\t\t\t\t\tconst trimmed = part.trim();\n\t\t\t\t\tconst eqIndex = trimmed.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = trimmed.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = trimmed.slice(eqIndex + 1);\n\t\t\t\t\t\tallCookies[key] = value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn allCookies;\n\t}) as CookieFn;\n}\n\n/**\n * Create a lazy header accessor for API Gateway events.\n * Handles case-insensitive lookups.\n */\nexport function createApiGatewayHeaders(\n\theaders: Record<string, string | undefined> | null | undefined,\n): HeaderFn {\n\tlet normalizedHeaders: Record<string, string> | null = null;\n\n\tconst normalize = () => {\n\t\tif (!normalizedHeaders) {\n\t\t\tnormalizedHeaders = {};\n\t\t\tif (headers) {\n\t\t\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\t\t\tif (v !== undefined) {\n\t\t\t\t\t\tnormalizedHeaders[k.toLowerCase()] = v;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn normalizedHeaders;\n\t};\n\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) {\n\t\t\t// Try direct lookup first (common case: headers already lowercase)\n\t\t\tif (headers) {\n\t\t\t\tconst direct = headers[key] ?? headers[key.toLowerCase()];\n\t\t\t\tif (direct !== undefined) return direct;\n\t\t\t\t// Fall back to normalized lookup\n\t\t\t\treturn normalize()[key.toLowerCase()];\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn normalize();\n\t}) as HeaderFn;\n}\n\n/**\n * Create a lazy cookie accessor for API Gateway events.\n * Decodes URL-encoded values to match browser behavior.\n */\nexport function createApiGatewayCookies(\n\tcookies: string[] | undefined,\n\tcookieHeader: string | undefined,\n): CookieFn {\n\tlet parsed: Record<string, string> | null = null;\n\n\tconst parse = () => {\n\t\tif (!parsed) {\n\t\t\tparsed = {};\n\t\t\t// API Gateway v2 provides cookies as array\n\t\t\tif (cookies) {\n\t\t\t\tfor (const cookie of cookies) {\n\t\t\t\t\tconst eqIndex = cookie.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = cookie.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = cookie.slice(eqIndex + 1);\n\t\t\t\t\t\tparsed[key] = decodeURIComponent(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (cookieHeader) {\n\t\t\t\t// Fall back to parsing cookie header\n\t\t\t\tfor (const part of cookieHeader.split(';')) {\n\t\t\t\t\tconst trimmed = part.trim();\n\t\t\t\t\tconst eqIndex = trimmed.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = trimmed.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = trimmed.slice(eqIndex + 1);\n\t\t\t\t\t\tparsed[key] = decodeURIComponent(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn parsed;\n\t};\n\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) {\n\t\t\treturn parse()[name];\n\t\t}\n\t\treturn parse();\n\t}) as CookieFn;\n}\n\n/**\n * Create a lazy header accessor for plain object headers (test adaptor, etc).\n * Headers are already available as an object, just provide lazy access.\n */\nexport function createObjectHeaders(\n\theaders: Record<string, string> | undefined,\n): HeaderFn {\n\tlet normalized: Record<string, string> | null = null;\n\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) {\n\t\t\t// Try direct lookup first (common case)\n\t\t\tif (headers) {\n\t\t\t\tconst direct = headers[key] ?? headers[key.toLowerCase()];\n\t\t\t\tif (direct !== undefined) return direct;\n\t\t\t}\n\t\t\t// Fall back to normalized lookup for case-insensitivity\n\t\t\tif (!normalized && headers) {\n\t\t\t\tnormalized = {};\n\t\t\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\t\t\tnormalized[k.toLowerCase()] = v;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn normalized?.[key.toLowerCase()];\n\t\t}\n\t\t// Return all headers\n\t\tif (!normalized && headers) {\n\t\t\tnormalized = {};\n\t\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\t\tnormalized[k.toLowerCase()] = v;\n\t\t\t}\n\t\t}\n\t\treturn normalized ?? {};\n\t}) as HeaderFn;\n}\n\n/**\n * Create a lazy cookie accessor from a cookie header string.\n * Decodes URL-encoded values to match browser behavior.\n */\nexport function createCookieHeaderAccessor(\n\tcookieHeader: string | undefined,\n): CookieFn {\n\tlet parsed: Record<string, string> | null = null;\n\n\tconst parse = () => {\n\t\tif (!parsed) {\n\t\t\tparsed = {};\n\t\t\tif (cookieHeader) {\n\t\t\t\tfor (const part of cookieHeader.split(';')) {\n\t\t\t\t\tconst trimmed = part.trim();\n\t\t\t\t\tconst eqIndex = trimmed.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = trimmed.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = trimmed.slice(eqIndex + 1);\n\t\t\t\t\t\t// Decode URL-encoded values to match Endpoint.createCookies behavior\n\t\t\t\t\t\tparsed[key] = decodeURIComponent(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn parsed;\n\t};\n\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) {\n\t\t\treturn parse()[name];\n\t\t}\n\t\treturn parse();\n\t}) as CookieFn;\n}\n\n/**\n * Create a no-op header accessor (for minimal endpoints that don't use headers).\n */\nexport function createNoopHeaders(): HeaderFn {\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) return undefined;\n\t\treturn {};\n\t}) as HeaderFn;\n}\n\n/**\n * Create a no-op cookie accessor (for minimal endpoints that don't use cookies).\n */\nexport function createNoopCookies(): CookieFn {\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) return undefined;\n\t\treturn {};\n\t}) as CookieFn;\n}\n","import { HttpError } from '@geekmidas/errors';\n\n/**\n * The media types an endpoint's `.body()` schema can be handed — as written\n * in the 415 a request in any other type is answered with.\n */\nexport const SUPPORTED_BODY_TYPES = [\n\t'application/json',\n\t'application/x-www-form-urlencoded',\n\t'multipart/form-data',\n\t'text/*',\n] as const;\n\n/**\n * A request whose body is in a media type no endpoint reads — XML, a bare\n * octet stream. Answered with a 415, before the body schema runs.\n */\nexport class UnsupportedRequestContentType extends HttpError {\n\tconstructor(readonly contentType: string) {\n\t\tsuper(\n\t\t\t415,\n\t\t\t`A body sent as '${contentType}' can't be read. Send it as ${SUPPORTED_BODY_TYPES.join(', ')}.`,\n\t\t\t{\n\t\t\t\tstatusMessage: 'Unsupported Media Type',\n\t\t\t\tdetails: { contentType, supported: [...SUPPORTED_BODY_TYPES] },\n\t\t\t},\n\t\t);\n\t\tthis.name = 'UnsupportedRequestContentType';\n\t}\n}\n\n/**\n * A body that says it is JSON and is not. Answered with a 400 — the request\n * is broken, not merely invalid against the schema.\n */\nexport class MalformedRequestBody extends HttpError {\n\tconstructor(\n\t\treadonly contentType: string,\n\t\tcause?: Error,\n\t) {\n\t\tsuper(\n\t\t\t400,\n\t\t\t`The body says it is '${contentType}' but can't be parsed as that. Send a well-formed body, with the Content-Type it is written in.`,\n\t\t\t{ cause },\n\t\t);\n\t\tthis.name = 'MalformedRequestBody';\n\t}\n}\n\n/**\n * What a body is read from: a `Request`, or Hono's request — which caches\n * what it read, so a later reader is not handed a spent stream.\n */\nexport interface RequestBodySource {\n\tjson(): Promise<unknown>;\n\ttext(): Promise<string>;\n\tformData(): Promise<FormData>;\n}\n\nexport interface ReadRequestBodyOptions {\n\t/**\n\t * A body with no Content-Type: read as JSON (`'json'`, what API Gateway\n\t * has always done), or not read at all and handed to the schema as `{}`\n\t * (`'empty'`, what a Hono server has always done).\n\t */\n\tuntyped: 'json' | 'empty';\n}\n\n/**\n * A request body, read by its Content-Type into what an endpoint's `.body()`\n * schema validates — the one place every adaptor reads a body:\n *\n * - `application/json` (and `application/*+json`) — the parsed JSON.\n * - `application/x-www-form-urlencoded` and `multipart/form-data` — a plain\n * object of fields, as an HTML form posts them. A repeated field, or one\n * named `field[]`, is an array; a file part is a `File`.\n * - `text/*` — the text.\n *\n * Anything else is an {@link UnsupportedRequestContentType}.\n */\nexport async function readRequestBody(\n\tsource: RequestBodySource,\n\tcontentType: string | null | undefined,\n\toptions: ReadRequestBodyOptions,\n): Promise<unknown> {\n\tconst mediaType = contentType?.split(';')[0]?.trim().toLowerCase();\n\n\tif (!mediaType) {\n\t\tif (options.untyped === 'empty') return {};\n\t\treturn readJson(source, 'application/json');\n\t}\n\n\tif (isJson(mediaType)) return readJson(source, mediaType);\n\n\tif (\n\t\tmediaType === 'application/x-www-form-urlencoded' ||\n\t\tmediaType === 'multipart/form-data'\n\t) {\n\t\treturn formFields(await readForm(source, mediaType));\n\t}\n\n\tif (mediaType.startsWith('text/')) return source.text();\n\n\tthrow new UnsupportedRequestContentType(mediaType);\n}\n\nfunction isJson(mediaType: string): boolean {\n\treturn (\n\t\tmediaType === 'application/json' ||\n\t\t(mediaType.startsWith('application/') && mediaType.endsWith('+json'))\n\t);\n}\n\nasync function readJson(\n\tsource: RequestBodySource,\n\tmediaType: string,\n): Promise<unknown> {\n\ttry {\n\t\treturn await source.json();\n\t} catch (error) {\n\t\tthrow new MalformedRequestBody(mediaType, error as Error);\n\t}\n}\n\nasync function readForm(\n\tsource: RequestBodySource,\n\tmediaType: string,\n): Promise<FormData> {\n\ttry {\n\t\treturn await source.formData();\n\t} catch (error) {\n\t\tthrow new MalformedRequestBody(mediaType, error as Error);\n\t}\n}\n\n/** A form field's value: its text, or a `File` for a file part. */\ntype FormValue = NonNullable<ReturnType<FormData['get']>>;\n\n/**\n * A form's fields as an object, the way Hono's `parseBody({ all: true })`\n * reads them. Without a prototype, so a field named `__proto__` is a field.\n */\nfunction formFields(form: FormData): Record<string, FormValue | FormValue[]> {\n\tconst fields: Record<string, FormValue | FormValue[]> = Object.create(null);\n\n\tfor (const [key, value] of form.entries()) {\n\t\tconst existing = fields[key];\n\t\tif (existing === undefined) {\n\t\t\tfields[key] = key.endsWith('[]') ? [value] : value;\n\t\t} else if (Array.isArray(existing)) {\n\t\t\texisting.push(value);\n\t\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