@geekmidas/constructs 10.0.0-alpha.17 → 10.0.0-alpha.171
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-BcA8F0S-.d.cts} +16 -9
- package/dist/Cron-BcA8F0S-.d.cts.map +1 -0
- package/dist/{Cron-zsoSAwZo.d.cts → Cron-z2CiuQT_.d.mts} +15 -8
- package/dist/Cron-z2CiuQT_.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-BZvo34X2.d.cts +47 -0
- package/dist/CronBuilder-BZvo34X2.d.cts.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-BbgKo8OI.d.mts +47 -0
- package/dist/CronBuilder-BbgKo8OI.d.mts.map +1 -0
- package/dist/Endpoint-52z1P0Ue.cjs +581 -0
- package/dist/Endpoint-52z1P0Ue.cjs.map +1 -0
- package/dist/{Endpoint-oS-Fe3d_.d.mts → Endpoint-CIDUreMW.d.mts} +104 -23
- package/dist/Endpoint-CIDUreMW.d.mts.map +1 -0
- package/dist/{Endpoint-DBflWAe4.d.cts → Endpoint-COisi9jw.d.cts} +101 -20
- package/dist/Endpoint-COisi9jw.d.cts.map +1 -0
- package/dist/Endpoint-sUOU7uLx.mjs +552 -0
- package/dist/Endpoint-sUOU7uLx.mjs.map +1 -0
- package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
- package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
- package/dist/{index-Cc4kKPag.d.mts → EndpointFactory-CIM80WIK.d.mts} +189 -106
- package/dist/EndpointFactory-CIM80WIK.d.mts.map +1 -0
- package/dist/{index-C1ZwNOOk.d.cts → EndpointFactory-CfBg6jJE.d.cts} +187 -104
- package/dist/EndpointFactory-CfBg6jJE.d.cts.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/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-Ci_Cc-WZ.d.mts +129 -0
- package/dist/ObjectSubscriberBuilder-Ci_Cc-WZ.d.mts.map +1 -0
- package/dist/ObjectSubscriberBuilder-DWtLxfAJ.d.cts +129 -0
- package/dist/ObjectSubscriberBuilder-DWtLxfAJ.d.cts.map +1 -0
- package/dist/ProcessorBuilder-CdLwJK4k.d.mts +216 -0
- package/dist/ProcessorBuilder-CdLwJK4k.d.mts.map +1 -0
- package/dist/ProcessorBuilder-ClD7tmEe.d.cts +216 -0
- package/dist/ProcessorBuilder-ClD7tmEe.d.cts.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-CjULiiDN.d.mts +75 -0
- package/dist/QueueBuilder-CjULiiDN.d.mts.map +1 -0
- package/dist/QueueBuilder-CrZL8HHs.mjs +118 -0
- package/dist/QueueBuilder-CrZL8HHs.mjs.map +1 -0
- package/dist/QueueBuilder-Dacm9qAv.d.cts +75 -0
- package/dist/QueueBuilder-Dacm9qAv.d.cts.map +1 -0
- package/dist/Subscriber-5rCX1Nph.d.cts +83 -0
- package/dist/Subscriber-5rCX1Nph.d.cts.map +1 -0
- package/dist/Subscriber-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-CutSfNlr.d.mts +274 -0
- package/dist/auth-CutSfNlr.d.mts.map +1 -0
- package/dist/auth-b9ADezz9.d.cts +274 -0
- package/dist/auth-b9ADezz9.d.cts.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-9wLNSy3O.d.cts +44 -0
- package/dist/cache-9wLNSy3O.d.cts.map +1 -0
- package/dist/cache-BFPs_CGs.d.mts +44 -0
- package/dist/cache-BFPs_CGs.d.mts.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-CVoejIpo.d.cts} +79 -8
- package/dist/construct-interface-CVoejIpo.d.cts.map +1 -0
- package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-Nw5Dt9AC.d.mts} +79 -8
- package/dist/construct-interface-Nw5Dt9AC.d.mts.map +1 -0
- package/dist/construct-interface.cjs +62 -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 +59 -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/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-JI5uN1SF.d.cts +201 -0
- package/dist/fake-JI5uN1SF.d.cts.map +1 -0
- package/dist/fake-zpuXpBmY.d.mts +201 -0
- package/dist/fake-zpuXpBmY.d.mts.map +1 -0
- package/dist/file-server.cjs +170 -49
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +148 -16
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +148 -16
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +168 -51
- 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-CXLU7h_8.d.cts +195 -0
- package/dist/inbox-CXLU7h_8.d.cts.map +1 -0
- package/dist/inbox-DYFsLd9A.d.mts +195 -0
- package/dist/inbox-DYFsLd9A.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-BpE9_6l5.d.mts +115 -0
- package/dist/index-BpE9_6l5.d.mts.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-zRChehJ9.d.cts +115 -0
- package/dist/index-zRChehJ9.d.cts.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-5PAqFBzo.d.mts +216 -0
- package/dist/kysely-5PAqFBzo.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/kysely-lxNUBSTP.d.cts +216 -0
- package/dist/kysely-lxNUBSTP.d.cts.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 +79 -0
- package/dist/mobile-app.cjs.map +1 -0
- package/dist/mobile-app.d.cts +78 -0
- package/dist/mobile-app.d.cts.map +1 -0
- package/dist/mobile-app.d.mts +78 -0
- package/dist/mobile-app.d.mts.map +1 -0
- package/dist/mobile-app.mjs +78 -0
- package/dist/mobile-app.mjs.map +1 -0
- package/dist/object-storage.cjs +50 -7
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +37 -3
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +37 -3
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +49 -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/readOnlyStorage-C7bCe-z5.cjs +101 -0
- package/dist/readOnlyStorage-C7bCe-z5.cjs.map +1 -0
- package/dist/readOnlyStorage-DMCeLuS2.mjs +78 -0
- package/dist/readOnlyStorage-DMCeLuS2.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 +140 -10
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +156 -3
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +156 -3
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +120 -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-BbLyS7ln.d.cts +57 -0
- package/dist/telemetry-BbLyS7ln.d.cts.map +1 -0
- package/dist/telemetry-DWX-qKUh.d.mts +57 -0
- package/dist/telemetry-DWX-qKUh.d.mts.map +1 -0
- package/dist/telemetry.cjs +64 -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 +63 -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-9ndLBolx.d.cts +1207 -0
- package/dist/websocket-api-9ndLBolx.d.cts.map +1 -0
- package/dist/websocket-api-BPPXF79i.d.mts +1207 -0
- package/dist/websocket-api-BPPXF79i.d.mts.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-CoKPJJRl.cjs +1895 -0
- package/dist/websocket-api-CoKPJJRl.cjs.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
package/dist/file-server.mjs
CHANGED
|
@@ -1,36 +1,68 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { serverHalfOf } from "./construct-interface.mjs";
|
|
2
|
+
import { i as expiryDays, t as readOnlyStorage } from "./readOnlyStorage-DMCeLuS2.mjs";
|
|
3
|
+
import { a as parsePattern, o as ProcessorBuilder, r as fillPattern } from "./pattern-C1CEcglD.mjs";
|
|
4
|
+
import { DERIVED_PREFIX, canonicalId, fileServerSurfaceId, providedKeyFor, serviceKey } from "@geekmidas/manifest";
|
|
2
5
|
import { createStorageClient } from "@geekmidas/storage";
|
|
6
|
+
import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
3
7
|
//#region src/file-server.ts
|
|
8
|
+
/** A processed URL was asked of a file server the processor is not on. */
|
|
9
|
+
var ProcessorNotOnThisServer = class extends Error {
|
|
10
|
+
pattern;
|
|
11
|
+
server;
|
|
12
|
+
expected;
|
|
13
|
+
constructor(pattern, server, expected) {
|
|
14
|
+
super(`The processor at '${pattern}' belongs to '${server}', not '${expected}'. Ask its own file server for the URL: services.<its id>.processedUrl(…).`);
|
|
15
|
+
this.pattern = pattern;
|
|
16
|
+
this.server = server;
|
|
17
|
+
this.expected = expected;
|
|
18
|
+
this.name = "ProcessorNotOnThisServer";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/** An immutable pattern that no open pattern admits. */
|
|
22
|
+
var ImmutableNotOpen = class extends Error {
|
|
23
|
+
id;
|
|
24
|
+
pattern;
|
|
25
|
+
open;
|
|
26
|
+
constructor(id, pattern, open) {
|
|
27
|
+
super(`'${id}' says '${pattern}' is immutable, and no open path admits it` + (open.length ? ` (open: ${open.join(", ")})` : " — it opens none") + ". Only an open path is served by the edge, so only one can be cached there: add it to `open`, or narrow it to one that is.");
|
|
28
|
+
this.id = id;
|
|
29
|
+
this.pattern = pattern;
|
|
30
|
+
this.open = open;
|
|
31
|
+
this.name = "ImmutableNotOpen";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
4
34
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* serving half would be ceremony rather than safety. The client is a *superset*
|
|
24
|
-
* of `StorageClient`, made literal in the type, so anything taking
|
|
25
|
-
* `services.uploads` keeps compiling when the construct behind it grows a
|
|
26
|
-
* serving half.
|
|
27
|
-
*
|
|
28
|
-
* **The id names the bucket, not the surface.** This is the detail that has to
|
|
29
|
-
* be right before anything ships, because getting it backwards is destructive:
|
|
30
|
-
* the migration people actually perform is serving a bucket they already have,
|
|
31
|
-
* and naming the bucket after the construct makes that edit *add* a node rather
|
|
32
|
-
* than rename the one holding the data.
|
|
35
|
+
* A bucket setting given to a file server that fronts a bucket declared
|
|
36
|
+
* elsewhere — where the bucket's own construct is the one that says it.
|
|
37
|
+
*/
|
|
38
|
+
var BucketOptionOnOrigin = class extends Error {
|
|
39
|
+
server;
|
|
40
|
+
origin;
|
|
41
|
+
option;
|
|
42
|
+
constructor(server, origin, option) {
|
|
43
|
+
super(`'${server}' fronts '${origin}', which declares itself, so '${option}' belongs on the construct that declares '${origin}', not on the file server.`);
|
|
44
|
+
this.server = server;
|
|
45
|
+
this.origin = origin;
|
|
46
|
+
this.option = option;
|
|
47
|
+
this.name = "BucketOptionOnOrigin";
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* A bucket method called on a file server's client that was handed only its
|
|
52
|
+
* public address — a frontend's plain edge.
|
|
33
53
|
*/
|
|
54
|
+
var FileServerReadOnly = class extends Error {
|
|
55
|
+
id;
|
|
56
|
+
method;
|
|
57
|
+
key;
|
|
58
|
+
constructor(id, method, key) {
|
|
59
|
+
super(`'${id}' was reached through its public address only, so it serves and cannot ${method}(): ${key} is not in this process's environment. A site or app whose server half writes or presigns depends on '${id}'.server instead — .dependsOn([${id.charAt(0).toLowerCase()}${id.slice(1)}.server]).`);
|
|
60
|
+
this.id = id;
|
|
61
|
+
this.method = method;
|
|
62
|
+
this.key = key;
|
|
63
|
+
this.name = "FileServerReadOnly";
|
|
64
|
+
}
|
|
65
|
+
};
|
|
34
66
|
/** A key was asked to be served unsigned, and no open pattern admits it. */
|
|
35
67
|
var NotOpen = class extends Error {
|
|
36
68
|
key;
|
|
@@ -49,42 +81,94 @@ var FileServer = class {
|
|
|
49
81
|
/** The id of the surface node, as opposed to the bucket's. */
|
|
50
82
|
surfaceId;
|
|
51
83
|
open;
|
|
84
|
+
immutable;
|
|
85
|
+
/** The vended bucket's expiry, checked once: prefix → days. */
|
|
86
|
+
expire;
|
|
87
|
+
/** Days its processors' derivatives are kept, when it says. */
|
|
88
|
+
derivedDays;
|
|
52
89
|
/**
|
|
53
90
|
* Declared once and read by both `declare()` and `connect()`, so the keys the
|
|
54
91
|
* target publishes and the keys the client reads cannot drift.
|
|
55
92
|
*/
|
|
56
93
|
keys;
|
|
94
|
+
/**
|
|
95
|
+
* How a processor reaches the bucket: the bucket's own URL and nothing of
|
|
96
|
+
* the serving half, which a processor never needs. A field, not a getter:
|
|
97
|
+
* services are cached by object identity.
|
|
98
|
+
*/
|
|
99
|
+
origin;
|
|
57
100
|
constructor(id, options = {}) {
|
|
58
101
|
this.options = options;
|
|
59
102
|
const canonical = canonicalId(id);
|
|
60
103
|
this.id = canonical;
|
|
61
104
|
this.open = options.open ?? [];
|
|
105
|
+
this.immutable = options.immutable ?? [];
|
|
106
|
+
for (const pattern of this.immutable) if (!this.covers(pattern)) throw new ImmutableNotOpen(canonical, pattern, this.open);
|
|
62
107
|
const originId = options.origin?.id ?? canonical;
|
|
63
|
-
|
|
108
|
+
if (options.origin && options.expire) throw new BucketOptionOnOrigin(canonical, originId, "expire");
|
|
109
|
+
this.expire = expiryDays(canonical, options.expire);
|
|
110
|
+
this.derivedDays = options.derived ? expiryDays(canonical, { [DERIVED_PREFIX]: options.derived })?.[DERIVED_PREFIX] : void 0;
|
|
111
|
+
this.surfaceId = fileServerSurfaceId(canonical);
|
|
64
112
|
this.keys = {
|
|
65
|
-
origin:
|
|
66
|
-
server:
|
|
113
|
+
origin: providedKeyFor(originId, "objects", "connectionString"),
|
|
114
|
+
server: providedKeyFor(this.surfaceId, "file-server", "url")
|
|
67
115
|
};
|
|
68
116
|
this.service = {
|
|
69
117
|
serviceName: serviceKey(canonical),
|
|
70
118
|
register: (registerOptions) => this.connect(registerOptions)
|
|
71
119
|
};
|
|
120
|
+
const originKey = this.keys.origin;
|
|
121
|
+
this.origin = {
|
|
122
|
+
serviceName: `${serviceKey(originId)}ProcessorOrigin`,
|
|
123
|
+
register: ({ envParser }) => {
|
|
124
|
+
const { url } = envParser.create((get) => ({ url: get(originKey).string() })).parse();
|
|
125
|
+
return createStorageClient(url);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
72
128
|
}
|
|
73
129
|
/**
|
|
74
|
-
*
|
|
130
|
+
* A processor behind one path pattern of this server: a handler that makes
|
|
131
|
+
* a derivative of an open object on read.
|
|
132
|
+
*
|
|
133
|
+
* ```ts
|
|
134
|
+
* export const thumbnails = assets
|
|
135
|
+
* .process('/i/:width/*')
|
|
136
|
+
* .params(z.object({ width: z.enum(['64', '256', '1024']) }))
|
|
137
|
+
* .native(['sharp'])
|
|
138
|
+
* .handle(async ({ params, object }) => ({
|
|
139
|
+
* body: await sharp(await object.bytes()).resize(Number(params.width)).webp().toBuffer(),
|
|
140
|
+
* contentType: 'image/webp',
|
|
141
|
+
* cache: 'immutable',
|
|
142
|
+
* }));
|
|
143
|
+
* ```
|
|
75
144
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* a bucket's URL is never public, so a site depending on it gets nothing
|
|
79
|
-
* inlined, which is correct and also useless.
|
|
145
|
+
* Open paths only: a key no `open` pattern admits is answered 404, as an
|
|
146
|
+
* unsigned read of it would be.
|
|
80
147
|
*
|
|
81
|
-
*
|
|
82
|
-
* surface, whose address *is* public, and is what puts
|
|
83
|
-
* `VITE_UPLOADS_SERVER_URL` in a bundle. The same accessor shape
|
|
84
|
-
* `database.reader()` uses, and for the same reason — one construct owning
|
|
85
|
-
* two addresses needs a way to name the second.
|
|
148
|
+
* @throws {ProcessorPatternInvalid} for a pattern the edge cannot route.
|
|
86
149
|
*/
|
|
87
|
-
|
|
150
|
+
process(pattern, options = {}) {
|
|
151
|
+
return new ProcessorBuilder({
|
|
152
|
+
parsed: parsePattern(pattern),
|
|
153
|
+
surfaceId: this.surfaceId,
|
|
154
|
+
bucketId: this.options.origin?.id ?? this.id,
|
|
155
|
+
origin: this.origin,
|
|
156
|
+
serves: (key) => this.serves(key),
|
|
157
|
+
logger: options.logger ?? DEFAULT_LOGGER,
|
|
158
|
+
native: [],
|
|
159
|
+
services: [],
|
|
160
|
+
constructs: []
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The served surface: what a site's or a mobile app's plain
|
|
165
|
+
* `.dependsOn([uploads])` points at.
|
|
166
|
+
*
|
|
167
|
+
* Its address is public, so the frontend is built with it
|
|
168
|
+
* (`VITE_UPLOADS_URL`) — and it is all the frontend gets: no bucket, no
|
|
169
|
+
* key. A backend's plain edge is to the bucket, as it presigns and writes.
|
|
170
|
+
*/
|
|
171
|
+
get publicFace() {
|
|
88
172
|
const surface = this.declare().find((declaration) => declaration.id === this.surfaceId);
|
|
89
173
|
return {
|
|
90
174
|
id: this.surfaceId,
|
|
@@ -92,6 +176,18 @@ var FileServer = class {
|
|
|
92
176
|
};
|
|
93
177
|
}
|
|
94
178
|
/**
|
|
179
|
+
* Everything: the bucket, its credentials, and the address it is served
|
|
180
|
+
* on.
|
|
181
|
+
*
|
|
182
|
+
* What a backend's plain edge already is. A frontend asks for it by name —
|
|
183
|
+
* `.dependsOn([uploads.server])` — when its server half uploads or
|
|
184
|
+
* presigns: a full-stack site's, never a bundle's. The bucket's connection
|
|
185
|
+
* is never inlined into a bundle either way; only the served address is.
|
|
186
|
+
*/
|
|
187
|
+
get server() {
|
|
188
|
+
return serverHalfOf(this.options.origin ?? this);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
95
191
|
* The bucket and the surface over it — or just the surface, when the bucket
|
|
96
192
|
* was declared elsewhere.
|
|
97
193
|
*
|
|
@@ -107,6 +203,9 @@ var FileServer = class {
|
|
|
107
203
|
id: this.surfaceId,
|
|
108
204
|
of: origin?.id ?? this.id,
|
|
109
205
|
...this.open.length ? { open: this.open } : {},
|
|
206
|
+
...this.immutable.length ? { immutable: this.immutable } : {},
|
|
207
|
+
...this.derivedDays !== void 0 ? { derivedDays: this.derivedDays } : {},
|
|
208
|
+
...this.options.telemetry ? { telemetry: this.options.telemetry.id } : {},
|
|
110
209
|
provides: [this.keys.server]
|
|
111
210
|
};
|
|
112
211
|
if (origin) return [surface];
|
|
@@ -114,23 +213,28 @@ var FileServer = class {
|
|
|
114
213
|
kind: "objects",
|
|
115
214
|
id: this.id,
|
|
116
215
|
provides: [this.keys.origin],
|
|
117
|
-
...this.options.versioned ? { versioned: true } : {}
|
|
216
|
+
...this.options.versioned ? { versioned: true } : {},
|
|
217
|
+
...this.expire ? { expire: this.expire } : {}
|
|
118
218
|
}, surface];
|
|
119
219
|
}
|
|
120
220
|
/**
|
|
121
221
|
* The bucket's client, with the serving half added.
|
|
122
222
|
*
|
|
123
|
-
* Both
|
|
223
|
+
* Both keys are read here, which is also how the environment reaches a
|
|
124
224
|
* handler: the sniffer records what this reads, so `.dependsOn([uploads])`
|
|
125
|
-
* carries the bucket
|
|
126
|
-
* down beside the handler.
|
|
225
|
+
* carries the bucket's connection and the server's address without either
|
|
226
|
+
* being written down beside the handler.
|
|
227
|
+
*
|
|
228
|
+
* Without the connection — a site's or an app's plain edge, which is to
|
|
229
|
+
* the public face — the client serves and does nothing else: its bucket
|
|
230
|
+
* methods throw {@link FileServerReadOnly}.
|
|
127
231
|
*/
|
|
128
232
|
async connect(options) {
|
|
129
233
|
const { origin, server } = options.envParser.create((get) => ({
|
|
130
|
-
origin: get(this.keys.origin).string(),
|
|
234
|
+
origin: get(this.keys.origin).string().optional(),
|
|
131
235
|
server: get(this.keys.server).string()
|
|
132
236
|
})).parse();
|
|
133
|
-
const storage = createStorageClient(origin);
|
|
237
|
+
const storage = origin ? createStorageClient(origin) : readOnlyStorage((method) => new FileServerReadOnly(this.id, method, this.keys.origin));
|
|
134
238
|
const base = server.replace(/\/+$/, "");
|
|
135
239
|
const serve = (key) => {
|
|
136
240
|
if (!this.serves(key)) throw new NotOpen(key, this.open);
|
|
@@ -139,7 +243,12 @@ var FileServer = class {
|
|
|
139
243
|
return Object.assign(Object.create(storage), {
|
|
140
244
|
url: serve,
|
|
141
245
|
openUrl: serve,
|
|
142
|
-
signedUrl: (key, expiresIn) => storage.getDownloadURL({ path: key }, expiresIn)
|
|
246
|
+
signedUrl: (key, expiresIn) => storage.getDownloadURL({ path: key }, expiresIn),
|
|
247
|
+
processedUrl: (processor, params, key) => {
|
|
248
|
+
if (processor.surfaceId !== this.surfaceId) throw new ProcessorNotOnThisServer(processor.pattern, processor.surfaceId, this.surfaceId);
|
|
249
|
+
if (!this.serves(key)) throw new NotOpen(key, this.open);
|
|
250
|
+
return `${base}${fillPattern(processor.parsed, params, key)}`;
|
|
251
|
+
}
|
|
143
252
|
});
|
|
144
253
|
}
|
|
145
254
|
/**
|
|
@@ -153,6 +262,14 @@ var FileServer = class {
|
|
|
153
262
|
serves(key) {
|
|
154
263
|
return this.open.some((pattern) => globToRegExp(pattern).test(key));
|
|
155
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Whether every key a pattern admits is open: the pattern itself, each of
|
|
267
|
+
* its wildcards taken as a segment of its own, is a key an open pattern
|
|
268
|
+
* serves — `brand/logos/*` under `brand/**`, but not `**` under `brand/**`.
|
|
269
|
+
*/
|
|
270
|
+
covers(pattern) {
|
|
271
|
+
return this.serves(pattern.replace(/\*\*/g, "x/x").replace(/\*/g, "x"));
|
|
272
|
+
}
|
|
156
273
|
};
|
|
157
274
|
/**
|
|
158
275
|
* One open pattern as an anchored expression.
|
|
@@ -179,6 +296,6 @@ function globToRegExp(pattern) {
|
|
|
179
296
|
return new RegExp(`^${source}$`);
|
|
180
297
|
}
|
|
181
298
|
//#endregion
|
|
182
|
-
export { FileServer, NotOpen };
|
|
299
|
+
export { BucketOptionOnOrigin, FileServer, FileServerReadOnly, ImmutableNotOpen, NotOpen, ProcessorNotOnThisServer };
|
|
183
300
|
|
|
184
301
|
//# sourceMappingURL=file-server.mjs.map
|
package/dist/file-server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-server.mjs","names":[],"sources":["../src/file-server.ts"],"sourcesContent":["/**\n * `FileServer` — a domain that serves a bucket's objects.\n *\n * `ObjectStorage` is the bucket: it writes, it presigns, and its URL is never\n * public. Serving those objects on a domain is a different thing, and it is a\n * construct of its own rather than a flag on the bucket — see\n * `docs/design/constructs-paradigm.md`, \"Why a separate construct, and what it\n * costs\", for the comparison that rules the other two shapes out.\n *\n * ```ts\n * export const uploads = new FileServer('Uploads', { open: ['brand/**'] });\n *\n * uploads.getUploadURL({ path, contentType }) // an S3 presign at the bucket\n * uploads.url('brand/logo.png') // open path — no signature\n * uploads.signedUrl('invoices/7.pdf') // one object, one recipient\n * ```\n *\n * **One construct, one client, both halves.** How a file lands in the bucket is\n * the same whether or not it is served, so splitting the upload half from the\n * serving half would be ceremony rather than safety. The client is a *superset*\n * of `StorageClient`, made literal in the type, so anything taking\n * `services.uploads` keeps compiling when the construct behind it grows a\n * serving half.\n *\n * **The id names the bucket, not the surface.** This is the detail that has to\n * be right before anything ships, because getting it backwards is destructive:\n * the migration people actually perform is serving a bucket they already have,\n * and naming the bucket after the construct makes that edit *add* a node rather\n * than rename the one holding the data.\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 { createStorageClient, type StorageClient } from '@geekmidas/storage';\nimport type { Construct, Declarable } from './construct-interface';\n\n/**\n * A key an open pattern admits.\n *\n * The same template-literal trick `ConstructName` uses, so `open` is checked at\n * the call site rather than only at the edge:\n *\n * ```ts\n * files.url('brand/logo.png') // ok\n * files.url(`avatars/${id}.png`) // ok — a template literal still matches\n * files.url('invoices/7.pdf') // not assignable — never served unsigned\n * ```\n *\n * A single star and a double star resolve to the same type, stated rather than\n * discovered: a template literal cannot exclude `/`, so this is a prefix-and-\n * suffix guard while the *exact* pattern is enforced by the bucket policy, by\n * the cache behaviour, and by this construct's own runtime check. The type says\n * plausibly open; the infrastructure says definitely.\n */\nexport type Served<P extends string> = P extends `${infer Head}**`\n\t? `${Head}${string}`\n\t: P extends `${infer Head}*${infer Tail}`\n\t\t? `${Head}${string}${Tail}`\n\t\t: P;\n\n/** What consuming a file server hands you: a bucket client that also serves. */\nexport interface FileServerClient<TOpen extends string = never>\n\textends StorageClient {\n\t/**\n\t * The unsigned address of an open object.\n\t *\n\t * Compile-checked against the declared patterns, *and* checked again at\n\t * runtime — a JavaScript caller gets no compiler, and minting an unsigned\n\t * URL for a private object is a leak rather than a mistake.\n\t *\n\t * @throws {NotOpen} when the key matches no declared pattern.\n\t */\n\turl(key: Served<TOpen>): string;\n\n\t/**\n\t * The same thing for a key the compiler cannot see.\n\t *\n\t * A fully dynamic key does not type, which is correct and is also the case\n\t * people will hit — so the escape hatch is a named method rather than a\n\t * cast, and it runs the *same* runtime check rather than being a way around\n\t * it.\n\t *\n\t * @throws {NotOpen} when the key matches no declared pattern.\n\t */\n\topenUrl(key: string): string;\n\n\t/**\n\t * A signed address for one object and one recipient.\n\t *\n\t * Today this is an **S3 presign at the bucket**, which is what works\n\t * unchanged against MinIO locally and against S3 deployed. It is deliberately\n\t * not described as a CDN URL: CloudFront signing is a different mechanism,\n\t * with different keys, against a different host, and it needs key material\n\t * this construct does not yet declare.\n\t *\n\t * @param expiresIn - minutes, matching `getUploadURL`.\n\t */\n\tsignedUrl(key: string, expiresIn?: number): Promise<string>;\n}\n\nexport interface FileServerOptions<TOpen extends string = never> {\n\t/**\n\t * Paths served without a signature. Everything else needs one.\n\t *\n\t * Private by default: a bucket where forgetting a flag publishes user\n\t * uploads is the wrong default, so this is an exception list, and listing it\n\t * in code means exactly one set of paths is unauthenticated and it is\n\t * reviewable in a diff.\n\t *\n\t * Uploading is deliberately *not* restricted to these. Writing to a path\n\t * that happens to be open is ordinary; the only asymmetry worth enforcing is\n\t * that you cannot hand out an unsigned URL for something the server would\n\t * refuse to serve unsigned.\n\t */\n\topen?: readonly TOpen[];\n\t/** Keep previous versions of an object. */\n\tversioned?: boolean;\n\t/**\n\t * A bucket declared elsewhere, instead of one of this server's own.\n\t *\n\t * `new FileServer('Uploads')` declares both nodes; this fronts a bucket that\n\t * already exists, which is also how the two edges come back when you want\n\t * them separately — a handler depending on the bucket writes, a handler\n\t * depending on the server mints URLs.\n\t */\n\torigin?: Declarable;\n}\n\n/** A key was asked to be served unsigned, and no open pattern admits it. */\nexport class NotOpen extends Error {\n\tconstructor(\n\t\treadonly key: string,\n\t\treadonly open: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${key}' is not served without a signature. ` +\n\t\t\t\t(open.length\n\t\t\t\t\t? `Open paths: ${open.join(', ')}. Use signedUrl() for anything else.`\n\t\t\t\t\t: 'This file server declares no open paths, so every object needs signedUrl().'),\n\t\t);\n\t\tthis.name = 'NotOpen';\n\t}\n}\n\nexport class FileServer<\n\tTName extends string = string,\n\tTOpen extends string = never,\n> implements Construct<TName, FileServerClient<TOpen>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, FileServerClient<TOpen>>;\n\n\t/** The id of the surface node, as opposed to the bucket's. */\n\treadonly surfaceId: string;\n\n\tprivate readonly open: readonly string[];\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the keys the\n\t * target publishes and the keys the client reads cannot drift.\n\t */\n\tprivate readonly keys: { origin: string; server: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: FileServerOptions<TOpen> = {},\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.open = options.open ?? [];\n\n\t\t// The surface takes the suffix and the bucket keeps the plain id, which\n\t\t// is what makes \"serve a bucket I already have\" an edit that adds a node\n\t\t// instead of renaming the one holding the data.\n\t\tconst originId = options.origin?.id ?? canonical;\n\t\tthis.surfaceId = `${canonical}Server`;\n\n\t\tthis.keys = {\n\t\t\torigin: provideKey(originId, 'url'),\n\t\t\tserver: provideKey(this.surfaceId, 'url'),\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) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\t/**\n\t * The served surface, as something an edge can point at.\n\t *\n\t * Depending on the `FileServer` itself points at the **bucket** — its\n\t * canonical node — which is right for a handler: it presigns and writes. But\n\t * a bucket's URL is never public, so a site depending on it gets nothing\n\t * inlined, which is correct and also useless.\n\t *\n\t * This is the other half: `.dependsOn([uploads.server])` points at the\n\t * surface, whose address *is* public, and is what puts\n\t * `VITE_UPLOADS_SERVER_URL` in a bundle. The same accessor shape\n\t * `database.reader()` uses, and for the same reason — one construct owning\n\t * two addresses needs a way to name the second.\n\t */\n\tget server(): Declarable {\n\t\tconst surface = this.declare().find(\n\t\t\t(declaration) => declaration.id === this.surfaceId,\n\t\t);\n\n\t\treturn {\n\t\t\tid: this.surfaceId,\n\t\t\tdeclare: () => (surface ? [surface] : []),\n\t\t};\n\t}\n\n\t/**\n\t * The bucket and the surface over it — or just the surface, when the bucket\n\t * was declared elsewhere.\n\t *\n\t * The surface names its origin through `of`, which is what makes the\n\t * reference check work: an origin resolving to nothing is a build failure,\n\t * the same guarantee `assertDerivations` already gives a reader and a schema\n\t * tenant.\n\t */\n\tdeclare(): Declaration[] {\n\t\tconst origin = this.options.origin;\n\n\t\tconst surface: Declaration = {\n\t\t\tkind: 'file-server',\n\t\t\tid: this.surfaceId,\n\t\t\tof: origin?.id ?? this.id,\n\t\t\t...(this.open.length ? { open: this.open } : {}),\n\t\t\tprovides: [this.keys.server],\n\t\t};\n\n\t\t// A vended bucket is declared here; a given one already declares itself,\n\t\t// and declaring it twice is the duplication the whole model removes.\n\t\tif (origin) return [surface];\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'objects',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.origin],\n\t\t\t\t...(this.options.versioned ? { versioned: true } : {}),\n\t\t\t},\n\t\t\tsurface,\n\t\t];\n\t}\n\n\t/**\n\t * The bucket's client, with the serving half added.\n\t *\n\t * Both addresses are read here, which is also how the environment reaches a\n\t * handler: the sniffer records what this reads, so `.dependsOn([uploads])`\n\t * carries the bucket URL and the server URL without either being written\n\t * down beside the handler.\n\t */\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t): Promise<FileServerClient<TOpen>> {\n\t\tconst { origin, server } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\torigin: get(this.keys.origin).string(),\n\t\t\t\tserver: get(this.keys.server).string(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\tconst storage = createStorageClient(origin);\n\t\tconst base = server.replace(/\\/+$/, '');\n\n\t\tconst serve = (key: string): string => {\n\t\t\tif (!this.serves(key)) throw new NotOpen(key, this.open);\n\n\t\t\treturn `${base}/${key.replace(/^\\/+/, '')}`;\n\t\t};\n\n\t\t// Delegating rather than copying: the bucket half is whatever the driver\n\t\t// produced, including anything it grows later, and only the serving half\n\t\t// is added on top.\n\t\treturn Object.assign(Object.create(storage) as StorageClient, {\n\t\t\turl: serve as (key: Served<TOpen>) => string,\n\t\t\topenUrl: serve,\n\t\t\tsignedUrl: (key: string, expiresIn?: number) =>\n\t\t\t\tstorage.getDownloadURL({ path: key } as never, expiresIn),\n\t\t}) as FileServerClient<TOpen>;\n\t}\n\n\t/**\n\t * Whether an open pattern admits a key.\n\t *\n\t * The runtime half of {@link Served}, and stricter than it: here a single\n\t * star stops at a segment boundary and a double star does not, which is the\n\t * distinction a template-literal type cannot draw and the infrastructure\n\t * does.\n\t */\n\tprivate serves(key: string): boolean {\n\t\treturn this.open.some((pattern) => globToRegExp(pattern).test(key));\n\t}\n}\n\n/**\n * One open pattern as an anchored expression.\n *\n * A double star crosses `/`; a single star does not. Both are consumed in one\n * left-to-right pass rather than by substitution, so a pattern cannot be\n * rewritten into a placeholder that a later pass mistakes for literal text.\n */\nfunction globToRegExp(pattern: string): RegExp {\n\tlet source = '';\n\n\tfor (let index = 0; index < pattern.length; index++) {\n\t\tconst character = pattern[index];\n\n\t\tif (character !== '*') {\n\t\t\tsource += character?.replace(/[.+^${}()|[\\]\\\\?]/, '\\\\$&') ?? '';\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (pattern[index + 1] === '*') {\n\t\t\tsource += '.*';\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tsource += '[^/]*';\n\t}\n\n\treturn new RegExp(`^${source}$`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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file":"file-server.mjs","names":[],"sources":["../src/file-server.ts"],"sourcesContent":["/**\n * `FileServer` — a domain that serves a bucket's objects.\n *\n * `ObjectStorage` is the bucket: it writes, it presigns, and its URL is never\n * public. Serving those objects on a domain is a different thing, and it is a\n * construct of its own rather than a flag on the bucket — see\n * `docs/design/constructs-paradigm.md`, \"Why a separate construct, and what it\n * costs\", for the comparison that rules the other two shapes out.\n *\n * ```ts\n * export const uploads = new FileServer('Uploads', { open: ['brand/**'] });\n *\n * uploads.getUploadURL({ path, contentType }) // an S3 presign at the bucket\n * uploads.url('brand/logo.png') // open path — no signature\n * uploads.signedUrl('invoices/7.pdf') // one object, one recipient\n * ```\n *\n * **One construct, one client, both halves.** How a file lands in the bucket is\n * the same whether or not it is served, so splitting the upload half from the\n * serving half would be ceremony rather than safety. The client is a *superset*\n * of `StorageClient`, made literal in the type, so anything taking\n * `services.uploads` keeps compiling when the construct behind it grows a\n * serving half.\n *\n * **The id names the bucket, not the surface.** This is the detail that has to\n * be right before anything ships, because getting it backwards is destructive:\n * the migration people actually perform is serving a bucket they already have,\n * and naming the bucket after the construct makes that edit *add* a node rather\n * than rename the one holding the data.\n */\n\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\tDERIVED_PREFIX,\n\ttype Declaration,\n\tfileServerSurfaceId,\n\tprovidedKeyFor,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { createStorageClient, type StorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\ttype Construct,\n\ttype Declarable,\n\ttype HasPublicFace,\n\ttype ServerHalf,\n\tserverHalfOf,\n} from './construct-interface';\nimport { expiryDays, type ObjectExpiry } from './expire';\nimport type { Processor } from './processors/Processor';\nimport { ProcessorBuilder } from './processors/ProcessorBuilder';\nimport {\n\tfillPattern,\n\ttype PatternParams,\n\tparsePattern,\n} from './processors/pattern';\nimport { readOnlyStorage } from './readOnlyStorage';\nimport type { Telemetry } from './telemetry';\n\n/**\n * A key an open pattern admits.\n *\n * The same template-literal trick `ConstructName` uses, so `open` is checked at\n * the call site rather than only at the edge:\n *\n * ```ts\n * files.url('brand/logo.png') // ok\n * files.url(`avatars/${id}.png`) // ok — a template literal still matches\n * files.url('invoices/7.pdf') // not assignable — never served unsigned\n * ```\n *\n * A single star and a double star resolve to the same type, stated rather than\n * discovered: a template literal cannot exclude `/`, so this is a prefix-and-\n * suffix guard while the *exact* pattern is enforced by the bucket policy, by\n * the cache behaviour, and by this construct's own runtime check. The type says\n * plausibly open; the infrastructure says definitely.\n */\nexport type Served<P extends string> = P extends `${infer Head}**`\n\t? `${Head}${string}`\n\t: P extends `${infer Head}*${infer Tail}`\n\t\t? `${Head}${string}${Tail}`\n\t\t: P;\n\n/** What consuming a file server hands you: a bucket client that also serves. */\nexport interface FileServerClient<TOpen extends string = never>\n\textends StorageClient {\n\t/**\n\t * The unsigned address of an open object.\n\t *\n\t * Compile-checked against the declared patterns, *and* checked again at\n\t * runtime — a JavaScript caller gets no compiler, and minting an unsigned\n\t * URL for a private object is a leak rather than a mistake.\n\t *\n\t * @throws {NotOpen} when the key matches no declared pattern.\n\t */\n\turl(key: Served<TOpen>): string;\n\n\t/**\n\t * The same thing for a key the compiler cannot see.\n\t *\n\t * A fully dynamic key does not type, which is correct and is also the case\n\t * people will hit — so the escape hatch is a named method rather than a\n\t * cast, and it runs the *same* runtime check rather than being a way around\n\t * it.\n\t *\n\t * @throws {NotOpen} when the key matches no declared pattern.\n\t */\n\topenUrl(key: string): string;\n\n\t/**\n\t * A signed address for one object and one recipient.\n\t *\n\t * Today this is an **S3 presign at the bucket**, which is what works\n\t * unchanged against MinIO locally and against S3 deployed. It is deliberately\n\t * not described as a CDN URL: CloudFront signing is a different mechanism,\n\t * with different keys, against a different host, and it needs key material\n\t * this construct does not yet declare.\n\t *\n\t * @param expiresIn - minutes, matching `getUploadURL`.\n\t */\n\tsignedUrl(key: string, expiresIn?: number): Promise<string>;\n\n\t/**\n\t * The address of a processor's derivative of an open object — the\n\t * thumbnail, not the original.\n\t *\n\t * @throws {NotOpen} when the key matches no declared pattern.\n\t * @throws {ProcessorNotOnThisServer} for another file server's processor.\n\t */\n\tprocessedUrl<\n\t\tTPattern extends string,\n\t\tTSchema extends StandardSchemaV1 | undefined,\n\t>(\n\t\tprocessor: Processor<TPattern, TSchema, any, any>,\n\t\tparams: ProcessorUrlParams<TPattern, TSchema>,\n\t\tkey: string,\n\t): string;\n}\n\n/**\n * What addresses a derivative: the values the processor's schema accepts —\n * its input, since these go into a path — or, without one, the raw strings.\n */\nexport type ProcessorUrlParams<\n\tTPattern extends string,\n\tTSchema extends StandardSchemaV1 | undefined,\n> = TSchema extends StandardSchemaV1\n\t? StandardSchemaV1.InferInput<TSchema>\n\t: PatternParams<TPattern>;\n\n/** A processed URL was asked of a file server the processor is not on. */\nexport class ProcessorNotOnThisServer extends Error {\n\tconstructor(\n\t\treadonly pattern: string,\n\t\treadonly server: string,\n\t\treadonly expected: string,\n\t) {\n\t\tsuper(\n\t\t\t`The processor at '${pattern}' belongs to '${server}', not '${expected}'. ` +\n\t\t\t\t`Ask its own file server for the URL: services.<its id>.processedUrl(…).`,\n\t\t);\n\t\tthis.name = 'ProcessorNotOnThisServer';\n\t}\n}\n\nexport interface FileServerOptions<TOpen extends string = never> {\n\t/**\n\t * Paths served without a signature. Everything else needs one.\n\t *\n\t * Private by default: a bucket where forgetting a flag publishes user\n\t * uploads is the wrong default, so this is an exception list, and listing it\n\t * in code means exactly one set of paths is unauthenticated and it is\n\t * reviewable in a diff.\n\t *\n\t * Uploading is deliberately *not* restricted to these. Writing to a path\n\t * that happens to be open is ordinary; the only asymmetry worth enforcing is\n\t * that you cannot hand out an unsigned URL for something the server would\n\t * refuse to serve unsigned.\n\t */\n\topen?: readonly TOpen[];\n\t/**\n\t * Open paths whose objects never change once written — keyed by a content\n\t * hash or a file id — so every client may keep them forever: the edge\n\t * sends `Cache-Control: public, max-age=31536000, immutable`, over\n\t * whatever the object was stored with.\n\t *\n\t * A subset of `open`, because a signed object is never served by the edge.\n\t * Only say it of paths whose keys are written once: a client holding an\n\t * immutable copy never asks again.\n\t */\n\timmutable?: readonly string[];\n\t/** Keep previous versions of an object. */\n\tversioned?: boolean;\n\t/**\n\t * Delete the objects under each prefix this many days after they were\n\t * written — `{ 'previews/': { days: 7 } }`. A setting of the bucket this\n\t * server vends, so it cannot be given with `origin`.\n\t */\n\texpire?: ObjectExpiry;\n\t/**\n\t * How long its processors' derivatives are kept in the bucket before it\n\t * deletes them — 30 days unless said. They are remade on the next request,\n\t * so this trades storage for the work of making one again.\n\t */\n\tderived?: { readonly days: number };\n\t/**\n\t * What its processor unit emits — the `Telemetry` construct, as a worker\n\t * takes it: each request is a span, and the deploy hands the unit the\n\t * `OTEL_*` keys its stage resolves.\n\t */\n\ttelemetry?: Telemetry;\n\t/**\n\t * A bucket declared elsewhere, instead of one of this server's own.\n\t *\n\t * `new FileServer('Uploads')` declares both nodes; this fronts a bucket that\n\t * already exists, which is also how the two edges come back when you want\n\t * them separately — a handler depending on the bucket writes, a handler\n\t * depending on the server mints URLs.\n\t */\n\torigin?: Declarable;\n}\n\n/** An immutable pattern that no open pattern admits. */\nexport class ImmutableNotOpen extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly pattern: string,\n\t\treadonly open: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' says '${pattern}' is immutable, and no open path admits it` +\n\t\t\t\t(open.length ? ` (open: ${open.join(', ')})` : ' — it opens none') +\n\t\t\t\t'. Only an open path is served by the edge, so only one can be ' +\n\t\t\t\t'cached there: add it to `open`, or narrow it to one that is.',\n\t\t);\n\t\tthis.name = 'ImmutableNotOpen';\n\t}\n}\n\n/**\n * A bucket setting given to a file server that fronts a bucket declared\n * elsewhere — where the bucket's own construct is the one that says it.\n */\nexport class BucketOptionOnOrigin extends Error {\n\tconstructor(\n\t\treadonly server: string,\n\t\treadonly origin: string,\n\t\treadonly option: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${server}' fronts '${origin}', which declares itself, so '${option}' ` +\n\t\t\t\t`belongs on the construct that declares '${origin}', not on the file server.`,\n\t\t);\n\t\tthis.name = 'BucketOptionOnOrigin';\n\t}\n}\n\n/**\n * A bucket method called on a file server's client that was handed only its\n * public address — a frontend's plain edge.\n */\nexport class FileServerReadOnly extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly method: string,\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' was reached through its public address only, so it serves ` +\n\t\t\t\t`and cannot ${method}(): ${key} is not in this process's environment. ` +\n\t\t\t\t`A site or app whose server half writes or presigns depends on ` +\n\t\t\t\t`'${id}'.server instead — .dependsOn([${id.charAt(0).toLowerCase()}${id.slice(1)}.server]).`,\n\t\t);\n\t\tthis.name = 'FileServerReadOnly';\n\t}\n}\n\n/** A key was asked to be served unsigned, and no open pattern admits it. */\nexport class NotOpen extends Error {\n\tconstructor(\n\t\treadonly key: string,\n\t\treadonly open: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${key}' is not served without a signature. ` +\n\t\t\t\t(open.length\n\t\t\t\t\t? `Open paths: ${open.join(', ')}. Use signedUrl() for anything else.`\n\t\t\t\t\t: 'This file server declares no open paths, so every object needs signedUrl().'),\n\t\t);\n\t\tthis.name = 'NotOpen';\n\t}\n}\n\nexport class FileServer<\n\tTName extends string = string,\n\tTOpen extends string = never,\n> implements Construct<TName, FileServerClient<TOpen>>, HasPublicFace\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, FileServerClient<TOpen>>;\n\n\t/** The id of the surface node, as opposed to the bucket's. */\n\treadonly surfaceId: string;\n\n\tprivate readonly open: readonly string[];\n\tprivate readonly immutable: readonly string[];\n\n\t/** The vended bucket's expiry, checked once: prefix → days. */\n\tprivate readonly expire: Record<string, number> | undefined;\n\n\t/** Days its processors' derivatives are kept, when it says. */\n\tprivate readonly derivedDays: number | undefined;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the keys the\n\t * target publishes and the keys the client reads cannot drift.\n\t */\n\tprivate readonly keys: { origin: string; server: string };\n\n\t/**\n\t * How a processor reaches the bucket: the bucket's own URL and nothing of\n\t * the serving half, which a processor never needs. A field, not a getter:\n\t * services are cached by object identity.\n\t */\n\tprivate readonly origin: Service<string, StorageClient>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: FileServerOptions<TOpen> = {},\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.open = options.open ?? [];\n\t\tthis.immutable = options.immutable ?? [];\n\t\tfor (const pattern of this.immutable) {\n\t\t\tif (!this.covers(pattern)) {\n\t\t\t\tthrow new ImmutableNotOpen(canonical, pattern, this.open);\n\t\t\t}\n\t\t}\n\n\t\t// The surface takes the suffix and the bucket keeps the plain id, which\n\t\t// is what makes \"serve a bucket I already have\" an edit that adds a node\n\t\t// instead of renaming the one holding the data.\n\t\tconst originId = options.origin?.id ?? canonical;\n\t\tif (options.origin && options.expire) {\n\t\t\tthrow new BucketOptionOnOrigin(canonical, originId, 'expire');\n\t\t}\n\t\tthis.expire = expiryDays(canonical, options.expire);\n\t\tthis.derivedDays = options.derived\n\t\t\t? expiryDays(canonical, { [DERIVED_PREFIX]: options.derived })?.[\n\t\t\t\t\tDERIVED_PREFIX\n\t\t\t\t]\n\t\t\t: undefined;\n\t\tthis.surfaceId = fileServerSurfaceId(canonical);\n\n\t\tthis.keys = {\n\t\t\torigin: providedKeyFor(originId, 'objects', 'connectionString'),\n\t\t\tserver: providedKeyFor(this.surfaceId, 'file-server', 'url'),\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) => this.connect(registerOptions),\n\t\t};\n\n\t\tconst originKey = this.keys.origin;\n\t\tthis.origin = {\n\t\t\tserviceName: `${serviceKey(originId)}ProcessorOrigin`,\n\t\t\tregister: ({ envParser }) => {\n\t\t\t\tconst { url } = envParser\n\t\t\t\t\t.create((get) => ({ url: get(originKey).string() }))\n\t\t\t\t\t.parse();\n\t\t\t\treturn createStorageClient(url);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * A processor behind one path pattern of this server: a handler that makes\n\t * a derivative of an open object on read.\n\t *\n\t * ```ts\n\t * export const thumbnails = assets\n\t * .process('/i/:width/*')\n\t * .params(z.object({ width: z.enum(['64', '256', '1024']) }))\n\t * .native(['sharp'])\n\t * .handle(async ({ params, object }) => ({\n\t * body: await sharp(await object.bytes()).resize(Number(params.width)).webp().toBuffer(),\n\t * contentType: 'image/webp',\n\t * cache: 'immutable',\n\t * }));\n\t * ```\n\t *\n\t * Open paths only: a key no `open` pattern admits is answered 404, as an\n\t * unsigned read of it would be.\n\t *\n\t * @throws {ProcessorPatternInvalid} for a pattern the edge cannot route.\n\t */\n\tprocess<TPattern extends `/${string}/*`>(\n\t\tpattern: TPattern,\n\t\toptions: { logger?: Logger } = {},\n\t): ProcessorBuilder<TPattern> {\n\t\treturn new ProcessorBuilder<TPattern>({\n\t\t\tparsed: parsePattern(pattern),\n\t\t\tsurfaceId: this.surfaceId,\n\t\t\tbucketId: this.options.origin?.id ?? this.id,\n\t\t\torigin: this.origin,\n\t\t\tserves: (key) => this.serves(key),\n\t\t\tlogger: (options.logger ?? DEFAULT_LOGGER) as Logger,\n\t\t\tnative: [],\n\t\t\tservices: [],\n\t\t\tconstructs: [],\n\t\t});\n\t}\n\n\t/**\n\t * The served surface: what a site's or a mobile app's plain\n\t * `.dependsOn([uploads])` points at.\n\t *\n\t * Its address is public, so the frontend is built with it\n\t * (`VITE_UPLOADS_URL`) — and it is all the frontend gets: no bucket, no\n\t * key. A backend's plain edge is to the bucket, as it presigns and writes.\n\t */\n\tget publicFace(): Declarable {\n\t\tconst surface = this.declare().find(\n\t\t\t(declaration) => declaration.id === this.surfaceId,\n\t\t);\n\n\t\treturn {\n\t\t\tid: this.surfaceId,\n\t\t\tdeclare: () => (surface ? [surface] : []),\n\t\t};\n\t}\n\n\t/**\n\t * Everything: the bucket, its credentials, and the address it is served\n\t * on.\n\t *\n\t * What a backend's plain edge already is. A frontend asks for it by name —\n\t * `.dependsOn([uploads.server])` — when its server half uploads or\n\t * presigns: a full-stack site's, never a bundle's. The bucket's connection\n\t * is never inlined into a bundle either way; only the served address is.\n\t */\n\tget server(): ServerHalf {\n\t\treturn serverHalfOf(this.options.origin ?? this);\n\t}\n\n\t/**\n\t * The bucket and the surface over it — or just the surface, when the bucket\n\t * was declared elsewhere.\n\t *\n\t * The surface names its origin through `of`, which is what makes the\n\t * reference check work: an origin resolving to nothing is a build failure,\n\t * the same guarantee `assertDerivations` already gives a reader and a schema\n\t * tenant.\n\t */\n\tdeclare(): Declaration[] {\n\t\tconst origin = this.options.origin;\n\n\t\tconst surface: Declaration = {\n\t\t\tkind: 'file-server',\n\t\t\tid: this.surfaceId,\n\t\t\tof: origin?.id ?? this.id,\n\t\t\t...(this.open.length ? { open: this.open } : {}),\n\t\t\t...(this.immutable.length ? { immutable: this.immutable } : {}),\n\t\t\t...(this.derivedDays !== undefined\n\t\t\t\t? { derivedDays: this.derivedDays }\n\t\t\t\t: {}),\n\t\t\t...(this.options.telemetry\n\t\t\t\t? { telemetry: this.options.telemetry.id }\n\t\t\t\t: {}),\n\t\t\tprovides: [this.keys.server],\n\t\t};\n\n\t\t// A vended bucket is declared here; a given one already declares itself,\n\t\t// and declaring it twice is the duplication the whole model removes.\n\t\tif (origin) return [surface];\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'objects',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.origin],\n\t\t\t\t...(this.options.versioned ? { versioned: true } : {}),\n\t\t\t\t...(this.expire ? { expire: this.expire } : {}),\n\t\t\t},\n\t\t\tsurface,\n\t\t];\n\t}\n\n\t/**\n\t * The bucket's client, with the serving half added.\n\t *\n\t * Both keys are read here, which is also how the environment reaches a\n\t * handler: the sniffer records what this reads, so `.dependsOn([uploads])`\n\t * carries the bucket's connection and the server's address without either\n\t * being written down beside the handler.\n\t *\n\t * Without the connection — a site's or an app's plain edge, which is to\n\t * the public face — the client serves and does nothing else: its bucket\n\t * methods throw {@link FileServerReadOnly}.\n\t */\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t): Promise<FileServerClient<TOpen>> {\n\t\tconst { origin, server } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\torigin: get(this.keys.origin).string().optional(),\n\t\t\t\tserver: get(this.keys.server).string(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\tconst storage = origin\n\t\t\t? createStorageClient(origin)\n\t\t\t: readOnlyStorage(\n\t\t\t\t\t(method) => new FileServerReadOnly(this.id, method, this.keys.origin),\n\t\t\t\t);\n\t\tconst base = server.replace(/\\/+$/, '');\n\n\t\tconst serve = (key: string): string => {\n\t\t\tif (!this.serves(key)) throw new NotOpen(key, this.open);\n\n\t\t\treturn `${base}/${key.replace(/^\\/+/, '')}`;\n\t\t};\n\n\t\t// Delegating rather than copying: the bucket half is whatever the driver\n\t\t// produced, including anything it grows later, and only the serving half\n\t\t// is added on top.\n\t\treturn Object.assign(Object.create(storage) as StorageClient, {\n\t\t\turl: serve as (key: Served<TOpen>) => string,\n\t\t\topenUrl: serve,\n\t\t\tsignedUrl: (key: string, expiresIn?: number) =>\n\t\t\t\tstorage.getDownloadURL({ path: key } as never, expiresIn),\n\t\t\tprocessedUrl: (\n\t\t\t\tprocessor: Processor<string, any, any, any>,\n\t\t\t\tparams: Record<string, string | number>,\n\t\t\t\tkey: string,\n\t\t\t) => {\n\t\t\t\tif (processor.surfaceId !== this.surfaceId) {\n\t\t\t\t\tthrow new ProcessorNotOnThisServer(\n\t\t\t\t\t\tprocessor.pattern,\n\t\t\t\t\t\tprocessor.surfaceId,\n\t\t\t\t\t\tthis.surfaceId,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!this.serves(key)) throw new NotOpen(key, this.open);\n\t\t\t\treturn `${base}${fillPattern(processor.parsed, params, key)}`;\n\t\t\t},\n\t\t}) as FileServerClient<TOpen>;\n\t}\n\n\t/**\n\t * Whether an open pattern admits a key.\n\t *\n\t * The runtime half of {@link Served}, and stricter than it: here a single\n\t * star stops at a segment boundary and a double star does not, which is the\n\t * distinction a template-literal type cannot draw and the infrastructure\n\t * does.\n\t */\n\tprivate serves(key: string): boolean {\n\t\treturn this.open.some((pattern) => globToRegExp(pattern).test(key));\n\t}\n\n\t/**\n\t * Whether every key a pattern admits is open: the pattern itself, each of\n\t * its wildcards taken as a segment of its own, is a key an open pattern\n\t * serves — `brand/logos/*` under `brand/**`, but not `**` under `brand/**`.\n\t */\n\tprivate covers(pattern: string): boolean {\n\t\treturn this.serves(pattern.replace(/\\*\\*/g, 'x/x').replace(/\\*/g, 'x'));\n\t}\n}\n\n/**\n * One open pattern as an anchored expression.\n *\n * A double star crosses `/`; a single star does not. Both are consumed in one\n * left-to-right pass rather than by substitution, so a pattern cannot be\n * rewritten into a placeholder that a later pass mistakes for literal text.\n */\nfunction globToRegExp(pattern: string): RegExp {\n\tlet source = '';\n\n\tfor (let index = 0; index < pattern.length; index++) {\n\t\tconst character = pattern[index];\n\n\t\tif (character !== '*') {\n\t\t\tsource += character?.replace(/[.+^${}()|[\\]\\\\?]/, '\\\\$&') ?? '';\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (pattern[index + 1] === '*') {\n\t\t\tsource += '.*';\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tsource += '[^/]*';\n\t}\n\n\treturn new RegExp(`^${source}$`);\n}\n"],"mappings":";;;;;;;;AA2JA,IAAa,2BAAb,cAA8C,MAAM;CAEzC;CACA;CACA;CAHV,YACC,SACA,QACA,UACC;E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QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS;EACpD,MAAM,YAAY,QAAQ;EAE1B,IAAI,cAAc,KAAK;GACtB,UAAU,WAAW,QAAQ,qBAAqB,MAAM,KAAK;GAC7D;EACD;EAEA,IAAI,QAAQ,QAAQ,OAAO,KAAK;GAC/B,UAAU;GACV;GACA;EACD;EAEA,UAAU;CACX;CAEA,OAAO,IAAI,OAAO,IAAI,OAAO,EAAE;AAChC"}
|
package/dist/functions/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_functions = require("../functions-
|
|
2
|
+
const require_functions = require("../functions-DLF6-IK8.cjs");
|
|
3
3
|
exports.BaseFunctionBuilder = require_functions.BaseFunctionBuilder;
|
|
4
4
|
exports.Function = require_functions.Function;
|
|
5
5
|
exports.FunctionBuilder = require_functions.FunctionBuilder;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as FunctionHandler, n as Function, r as FunctionContext } from "../Function-BIEsY0Hm.cjs";
|
|
2
|
+
import { n as BaseFunctionBuilder, t as FunctionBuilder } from "../index-zRChehJ9.cjs";
|
|
2
3
|
export { BaseFunctionBuilder, Function, FunctionBuilder, type FunctionContext, type FunctionHandler };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as FunctionHandler, n as Function, r as FunctionContext } from "../Function-BKReud5p.mjs";
|
|
2
|
+
import { n as BaseFunctionBuilder, t as FunctionBuilder } from "../index-BpE9_6l5.mjs";
|
|
2
3
|
export { BaseFunctionBuilder, Function, FunctionBuilder, type FunctionContext, type FunctionHandler };
|
package/dist/functions/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as Function, r as BaseFunctionBuilder, t as FunctionBuilder } from "../functions-
|
|
1
|
+
import { n as Function, r as BaseFunctionBuilder, t as FunctionBuilder } from "../functions-BvIDQKAA.mjs";
|
|
2
2
|
export { BaseFunctionBuilder, Function, FunctionBuilder };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as __commonJSMin, o as __toESM, t as Construct } from "./Construct-
|
|
2
|
-
import { idsOf, serviceOf, servicesOf } from "./construct-interface.mjs";
|
|
1
|
+
import { a as __commonJSMin, o as __toESM, t as Construct } from "./Construct-CGuc_Ijk.mjs";
|
|
2
|
+
import { databaseEdges, idsOf, serviceOf, servicesOf } from "./construct-interface.mjs";
|
|
3
3
|
import { t as cloneWith } from "./clone-EKNovYHu.mjs";
|
|
4
|
-
import { parseSchema } from "@geekmidas/schema/parser";
|
|
5
4
|
import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
5
|
+
import { parseSchema } from "@geekmidas/schema/parser";
|
|
6
6
|
import { UnprocessableEntityError } from "@geekmidas/errors";
|
|
7
7
|
//#region ../../node_modules/.pnpm/lodash.uniqby@4.7.0/node_modules/lodash.uniqby/index.js
|
|
8
8
|
var require_lodash_uniqby = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -1922,8 +1922,8 @@ var require_lodash_uniqby = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
1922
1922
|
module.exports = uniqBy;
|
|
1923
1923
|
}));
|
|
1924
1924
|
//#endregion
|
|
1925
|
-
//#region
|
|
1926
|
-
var
|
|
1925
|
+
//#region ../../node_modules/.pnpm/lodash.get@4.4.2/node_modules/lodash.get/index.js
|
|
1926
|
+
var require_lodash_get = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1927
1927
|
/**
|
|
1928
1928
|
* lodash (Custom Build) <https://lodash.com/>
|
|
1929
1929
|
* Build: `lodash modularize exports="npm" -o ./`
|
|
@@ -2710,7 +2710,72 @@ var import_lodash_get = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin((
|
|
|
2710
2710
|
return result === void 0 ? defaultValue : result;
|
|
2711
2711
|
}
|
|
2712
2712
|
module.exports = get;
|
|
2713
|
-
}))
|
|
2713
|
+
}));
|
|
2714
|
+
//#endregion
|
|
2715
|
+
//#region src/publisher.ts
|
|
2716
|
+
var import_lodash_uniqby = /* @__PURE__ */ __toESM(require_lodash_uniqby(), 1);
|
|
2717
|
+
var import_lodash_get = /* @__PURE__ */ __toESM(require_lodash_get(), 1);
|
|
2718
|
+
/** A topic event, bound to its topic — what the builders store. */
|
|
2719
|
+
function topicEvent(topic, event) {
|
|
2720
|
+
return {
|
|
2721
|
+
topic: topic.service,
|
|
2722
|
+
type: event.type,
|
|
2723
|
+
payload: event.payload,
|
|
2724
|
+
...event.when ? { when: event.when } : {}
|
|
2725
|
+
};
|
|
2726
|
+
}
|
|
2727
|
+
/**
|
|
2728
|
+
* Publish a construct's events for what its handler returned, each through
|
|
2729
|
+
* its own topic's publisher.
|
|
2730
|
+
*
|
|
2731
|
+
* Failures are logged, never thrown: the handler has already succeeded, and an
|
|
2732
|
+
* event that could not be delivered must not turn its response into an error.
|
|
2733
|
+
*/
|
|
2734
|
+
async function publishEvents(logger, serviceDiscovery, events = [], response, provided = {}) {
|
|
2735
|
+
try {
|
|
2736
|
+
if (!events.length) {
|
|
2737
|
+
logger.debug("No events to publish");
|
|
2738
|
+
return;
|
|
2739
|
+
}
|
|
2740
|
+
const byTopic = /* @__PURE__ */ new Map();
|
|
2741
|
+
for (const { topic, type, payload, when } of events) {
|
|
2742
|
+
if (when && !when(response)) continue;
|
|
2743
|
+
logger.debug({ event: type }, "Processing event");
|
|
2744
|
+
const group = byTopic.get(topic.serviceName) ?? {
|
|
2745
|
+
topic,
|
|
2746
|
+
messages: []
|
|
2747
|
+
};
|
|
2748
|
+
group.messages.push({
|
|
2749
|
+
type,
|
|
2750
|
+
payload: await payload(response)
|
|
2751
|
+
});
|
|
2752
|
+
byTopic.set(topic.serviceName, group);
|
|
2753
|
+
}
|
|
2754
|
+
if (!byTopic.size) return;
|
|
2755
|
+
const missing = [...byTopic.values()].map(({ topic }) => topic).filter((topic) => !(topic.serviceName in provided));
|
|
2756
|
+
const services = {
|
|
2757
|
+
...missing.length ? await serviceDiscovery.register(missing) : {},
|
|
2758
|
+
...provided
|
|
2759
|
+
};
|
|
2760
|
+
await Promise.all([...byTopic.values()].map(async ({ topic, messages }) => {
|
|
2761
|
+
logger.debug({
|
|
2762
|
+
topic: topic.serviceName,
|
|
2763
|
+
eventCount: messages.length
|
|
2764
|
+
}, "Publishing events");
|
|
2765
|
+
await services[topic.serviceName].publish(messages).catch((err) => {
|
|
2766
|
+
logger.error(err, "Failed to publish events");
|
|
2767
|
+
});
|
|
2768
|
+
}));
|
|
2769
|
+
} catch (error) {
|
|
2770
|
+
logger.error(error, "Something went wrong publishing events");
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
/** Publish a construct's declared events for what its handler returned. */
|
|
2774
|
+
async function publishConstructEvents(construct, response, serviceDiscovery, logger = construct.logger, provided = {}) {
|
|
2775
|
+
return publishEvents(logger, serviceDiscovery, construct.events, response, provided);
|
|
2776
|
+
}
|
|
2777
|
+
//#endregion
|
|
2778
|
+
//#region src/functions/BaseFunctionBuilder.ts
|
|
2714
2779
|
var BaseFunctionBuilder = class BaseFunctionBuilder {
|
|
2715
2780
|
type;
|
|
2716
2781
|
inputSchema;
|
|
@@ -2742,10 +2807,12 @@ var BaseFunctionBuilder = class BaseFunctionBuilder {
|
|
|
2742
2807
|
* Only a server target reads it; on AWS the schedule is an EventBridge rule.
|
|
2743
2808
|
*/
|
|
2744
2809
|
_scheduleStore;
|
|
2810
|
+
/** What the built construct publishes, each event bound to its topic. */
|
|
2745
2811
|
_events = [];
|
|
2746
|
-
_publisher;
|
|
2747
2812
|
_auditorStorage;
|
|
2748
2813
|
_databaseService;
|
|
2814
|
+
/** The edge `.database()` added, so the next one can replace it. */
|
|
2815
|
+
_databaseEdge;
|
|
2749
2816
|
static isStandardSchemaV1(s) {
|
|
2750
2817
|
const schema = s["~standard"];
|
|
2751
2818
|
return schema && typeof schema.validate === "function";
|
|
@@ -2775,11 +2842,18 @@ var BaseFunctionBuilder = class BaseFunctionBuilder {
|
|
|
2775
2842
|
timeout(timeout) {
|
|
2776
2843
|
return cloneWith(this, { _timeout: timeout });
|
|
2777
2844
|
}
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2845
|
+
/**
|
|
2846
|
+
* A clone that publishes `event` to `topic` once the handler succeeds, and
|
|
2847
|
+
* has the topic as a dependency the way `.dependsOn([topic])` would: in
|
|
2848
|
+
* `services`, and an edge in the manifest. Each builder types it as its own
|
|
2849
|
+
* `event()`, since only it knows how its services widen.
|
|
2850
|
+
*/
|
|
2851
|
+
withEvent(topic, event) {
|
|
2852
|
+
return cloneWith(this, {
|
|
2853
|
+
_events: [...this._events, topicEvent(topic, event)],
|
|
2854
|
+
_services: (0, import_lodash_uniqby.default)([...this._services, topic.service], (s) => s.serviceName),
|
|
2855
|
+
_constructs: idsOf([topic], this._constructs)
|
|
2856
|
+
});
|
|
2783
2857
|
}
|
|
2784
2858
|
auditor(storage) {
|
|
2785
2859
|
return cloneWith(this, { _auditorStorage: storage });
|
|
@@ -2790,12 +2864,19 @@ var BaseFunctionBuilder = class BaseFunctionBuilder {
|
|
|
2790
2864
|
*/
|
|
2791
2865
|
database(source) {
|
|
2792
2866
|
const service = serviceOf(source);
|
|
2793
|
-
return cloneWith(this, {
|
|
2867
|
+
return cloneWith(this, {
|
|
2868
|
+
_databaseService: service,
|
|
2869
|
+
...databaseEdges({
|
|
2870
|
+
constructs: this._constructs,
|
|
2871
|
+
edge: this._databaseEdge,
|
|
2872
|
+
service: this._databaseService,
|
|
2873
|
+
services: this._services
|
|
2874
|
+
}, source)
|
|
2875
|
+
});
|
|
2794
2876
|
}
|
|
2795
2877
|
};
|
|
2796
2878
|
//#endregion
|
|
2797
2879
|
//#region src/functions/Function.ts
|
|
2798
|
-
var import_lodash_uniqby = /* @__PURE__ */ __toESM(require_lodash_uniqby(), 1);
|
|
2799
2880
|
var Function$1 = class Function$1 extends Construct {
|
|
2800
2881
|
fn;
|
|
2801
2882
|
input;
|
|
@@ -2839,8 +2920,8 @@ var Function$1 = class Function$1 extends Construct {
|
|
|
2839
2920
|
async parseOutput(output) {
|
|
2840
2921
|
return Function$1.parseSchema(this.outputSchema, output);
|
|
2841
2922
|
}
|
|
2842
|
-
constructor(fn, timeout = 3e4, type = "dev.geekmidas.function.function", input, outputSchema, services = [], logger = DEFAULT_LOGGER,
|
|
2843
|
-
super(type, logger, services, events,
|
|
2923
|
+
constructor(fn, timeout = 3e4, type = "dev.geekmidas.function.function", input, outputSchema, services = [], logger = DEFAULT_LOGGER, events = [], memorySize, auditorStorageService, databaseService, constructs = []) {
|
|
2924
|
+
super(type, logger, services, events, outputSchema, timeout, memorySize, auditorStorageService, constructs);
|
|
2844
2925
|
this.fn = fn;
|
|
2845
2926
|
this.input = input;
|
|
2846
2927
|
this.databaseService = databaseService;
|
|
@@ -2891,8 +2972,14 @@ var FunctionBuilder = class extends BaseFunctionBuilder {
|
|
|
2891
2972
|
logger(logger) {
|
|
2892
2973
|
return cloneWith(this, { _logger: logger });
|
|
2893
2974
|
}
|
|
2894
|
-
|
|
2895
|
-
|
|
2975
|
+
/**
|
|
2976
|
+
* Publish `event` to `topic` once the function has succeeded — repeatable,
|
|
2977
|
+
* one call per event, to as many topics as it names. The topic becomes a
|
|
2978
|
+
* dependency as with `.dependsOn([topic])`, so `services.<topic>` is there
|
|
2979
|
+
* for events the handler decides on itself.
|
|
2980
|
+
*/
|
|
2981
|
+
event(topic, event) {
|
|
2982
|
+
return this.withEvent(topic, event);
|
|
2896
2983
|
}
|
|
2897
2984
|
auditor(storage) {
|
|
2898
2985
|
return cloneWith(this, { _auditorStorage: storage });
|
|
@@ -2910,15 +2997,23 @@ var FunctionBuilder = class extends BaseFunctionBuilder {
|
|
|
2910
2997
|
*/
|
|
2911
2998
|
database(source) {
|
|
2912
2999
|
const service = serviceOf(source);
|
|
2913
|
-
return cloneWith(this, {
|
|
3000
|
+
return cloneWith(this, {
|
|
3001
|
+
_databaseService: service,
|
|
3002
|
+
...databaseEdges({
|
|
3003
|
+
constructs: this._constructs,
|
|
3004
|
+
edge: this._databaseEdge,
|
|
3005
|
+
service: this._databaseService,
|
|
3006
|
+
services: this._services
|
|
3007
|
+
}, source)
|
|
3008
|
+
});
|
|
2914
3009
|
}
|
|
2915
3010
|
handle(fn) {
|
|
2916
|
-
const func = new Function$1(fn, this._timeout, this.type, this.inputSchema, this.outputSchema, this._services, this._logger, this.
|
|
3011
|
+
const func = new Function$1(fn, this._timeout, this.type, this.inputSchema, this.outputSchema, this._services, this._logger, this._events, this._memorySize, this._auditorStorage, this._databaseService, this._constructs);
|
|
2917
3012
|
func.owner = this._owner;
|
|
2918
3013
|
return func;
|
|
2919
3014
|
}
|
|
2920
3015
|
};
|
|
2921
3016
|
//#endregion
|
|
2922
|
-
export {
|
|
3017
|
+
export { publishEvents as a, publishConstructEvents as i, Function$1 as n, require_lodash_uniqby as o, BaseFunctionBuilder as r, FunctionBuilder as t };
|
|
2923
3018
|
|
|
2924
|
-
//# sourceMappingURL=functions-
|
|
3019
|
+
//# sourceMappingURL=functions-BvIDQKAA.mjs.map
|