@geekmidas/constructs 10.0.0-alpha.6 → 10.0.0-alpha.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +223 -158
- package/dist/{Construct-BD5neF7w.mjs → Construct-BO1X-kt9.mjs} +32 -33
- package/dist/Construct-BO1X-kt9.mjs.map +1 -0
- package/dist/Construct-BQALFCh2.d.cts +230 -0
- package/dist/Construct-BQALFCh2.d.cts.map +1 -0
- package/dist/{Construct-CyS3RpTL.cjs → Construct-DmvXceVY.cjs} +52 -47
- package/dist/Construct-DmvXceVY.cjs.map +1 -0
- package/dist/Construct-QXnl3VqT.d.mts +230 -0
- package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
- package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-DI3nKoic.d.cts} +15 -9
- package/dist/Cron-DI3nKoic.d.cts.map +1 -0
- package/dist/{Cron-dh4rUgib.d.mts → Cron-uYAHPnp7.d.mts} +15 -9
- package/dist/Cron-uYAHPnp7.d.mts.map +1 -0
- package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BoHzlWU_.cjs} +47 -31
- package/dist/CronBuilder-BoHzlWU_.cjs.map +1 -0
- package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-CCgt0wCE.mjs} +37 -21
- package/dist/CronBuilder-CCgt0wCE.mjs.map +1 -0
- package/dist/CronBuilder-DaSUm2Na.d.mts +47 -0
- package/dist/CronBuilder-DaSUm2Na.d.mts.map +1 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
- package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-Bm9HjTPc.d.cts} +70 -93
- package/dist/Endpoint-Bm9HjTPc.d.cts.map +1 -0
- package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-CQ9RJ7p2.mjs} +130 -109
- package/dist/Endpoint-CQ9RJ7p2.mjs.map +1 -0
- package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-DOi8c_Gy.cjs} +158 -131
- package/dist/Endpoint-DOi8c_Gy.cjs.map +1 -0
- package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-KyMeR-B-.d.mts} +71 -94
- package/dist/Endpoint-KyMeR-B-.d.mts.map +1 -0
- package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-B6eZ3RDd.d.cts} +62 -132
- package/dist/EndpointFactory-B6eZ3RDd.d.cts.map +1 -0
- package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-Bo9lkMqB.cjs} +75 -110
- package/dist/EndpointFactory-Bo9lkMqB.cjs.map +1 -0
- package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-DR1rebok.mjs} +39 -74
- package/dist/EndpointFactory-DR1rebok.mjs.map +1 -0
- package/dist/{index-lAO9egTb.d.mts → EndpointFactory-GYkAuG3u.d.mts} +63 -133
- package/dist/EndpointFactory-GYkAuG3u.d.mts.map +1 -0
- package/dist/Function-DuqGcbOI.d.mts +76 -0
- package/dist/Function-DuqGcbOI.d.mts.map +1 -0
- package/dist/Function-Pu-1kKZz.d.cts +76 -0
- package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-XyxwoFnE.cjs} +52 -54
- package/dist/HonoEndpointAdaptor-XyxwoFnE.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-ja49poBI.mjs} +42 -47
- package/dist/HonoEndpointAdaptor-ja49poBI.mjs.map +1 -0
- package/dist/Queue-D5jcw0mu.cjs +109 -0
- package/dist/Queue-D5jcw0mu.cjs.map +1 -0
- package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
- package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
- package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
- package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
- package/dist/Queue-hwPN-t31.mjs +104 -0
- package/dist/Queue-hwPN-t31.mjs.map +1 -0
- package/dist/QueueBuilder-BFQn3OzZ.cjs +135 -0
- package/dist/QueueBuilder-BFQn3OzZ.cjs.map +1 -0
- package/dist/QueueBuilder-DCuYdjMw.mjs +118 -0
- package/dist/QueueBuilder-DCuYdjMw.mjs.map +1 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
- package/dist/QueueBuilder-QHsnVt1P.d.mts +75 -0
- package/dist/QueueBuilder-QHsnVt1P.d.mts.map +1 -0
- package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
- package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
- package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
- package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2PwqwIl.cjs} +61 -36
- package/dist/SubscriberBuilder-C2PwqwIl.cjs.map +1 -0
- package/dist/SubscriberBuilder-CuCMFpYW.d.mts +67 -0
- package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DMFk_Ap1.mjs} +50 -24
- package/dist/SubscriberBuilder-DMFk_Ap1.mjs.map +1 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
- package/dist/Topic-CkxOTrMv.cjs +104 -0
- package/dist/Topic-CkxOTrMv.cjs.map +1 -0
- package/dist/Topic-hPffOsot.mjs +99 -0
- package/dist/Topic-hPffOsot.mjs.map +1 -0
- package/dist/adaptors/aws.cjs +118 -216
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +34 -53
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +35 -54
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +91 -191
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +3 -10
- package/dist/adaptors/hono.d.cts +7 -16
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +8 -17
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +2 -10
- package/dist/adaptors/testing.cjs +711 -89
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +325 -54
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +325 -54
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +676 -70
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-CIFXNuDk.d.cts +194 -0
- package/dist/auth-CIFXNuDk.d.cts.map +1 -0
- package/dist/auth-CJ9Ff6Lu.d.mts +194 -0
- package/dist/auth-CJ9Ff6Lu.d.mts.map +1 -0
- package/dist/auth.cjs +172 -31
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -108
- package/dist/auth.d.mts +2 -108
- package/dist/auth.mjs +161 -24
- package/dist/auth.mjs.map +1 -1
- package/dist/{cache-BrRz3fEB.d.mts → cache-CXh6GIgb.d.mts} +3 -6
- package/dist/cache-CXh6GIgb.d.mts.map +1 -0
- package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
- package/dist/cache-DnGDGly3.d.cts.map +1 -0
- package/dist/cache.cjs +68 -2
- package/dist/cache.cjs.map +1 -0
- package/dist/cache.d.cts +1 -2
- package/dist/cache.d.mts +1 -2
- package/dist/cache.mjs +67 -2
- package/dist/cache.mjs.map +1 -0
- package/dist/cipher-C1lEFX63.mjs +225 -0
- package/dist/cipher-C1lEFX63.mjs.map +1 -0
- package/dist/cipher-CVxfwLjk.cjs +332 -0
- package/dist/cipher-CVxfwLjk.cjs.map +1 -0
- package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
- package/dist/clone-EKNovYHu.mjs.map +1 -0
- package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
- package/dist/clone-UGJpvQnL.cjs.map +1 -0
- package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
- package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
- package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-DluK3_da.d.mts} +42 -11
- package/dist/construct-interface-DluK3_da.d.mts.map +1 -0
- package/dist/construct-interface.cjs +113 -7
- package/dist/construct-interface.cjs.map +1 -0
- package/dist/construct-interface.d.cts +2 -2
- package/dist/construct-interface.d.mts +2 -2
- package/dist/construct-interface.mjs +106 -2
- package/dist/construct-interface.mjs.map +1 -0
- package/dist/credential.cjs +63 -16
- package/dist/credential.cjs.map +1 -1
- package/dist/credential.d.cts +16 -9
- package/dist/credential.d.cts.map +1 -1
- package/dist/credential.d.mts +16 -9
- package/dist/credential.d.mts.map +1 -1
- package/dist/credential.mjs +58 -12
- package/dist/credential.mjs.map +1 -1
- package/dist/crons/index.cjs +105 -7
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +40 -11
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +40 -11
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +103 -8
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +4 -181
- package/dist/database/kysely.d.cts +2 -152
- package/dist/database/kysely.d.mts +2 -152
- package/dist/database/kysely.mjs +2 -180
- package/dist/email.cjs +25 -12
- package/dist/email.cjs.map +1 -1
- package/dist/email.d.cts +3 -7
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +3 -7
- package/dist/email.d.mts.map +1 -1
- package/dist/email.mjs +16 -3
- package/dist/email.mjs.map +1 -1
- package/dist/encryption.cjs +96 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +117 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +117 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +83 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +8 -10
- package/dist/endpoints/index.d.cts +51 -7
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +51 -7
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -10
- package/dist/external-api-CWY9orcO.d.mts +86 -0
- package/dist/external-api-CWY9orcO.d.mts.map +1 -0
- package/dist/external-api-D-5WB-sr.d.cts +86 -0
- package/dist/external-api-D-5WB-sr.d.cts.map +1 -0
- package/dist/external-api.cjs +124 -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 +121 -0
- package/dist/external-api.mjs.map +1 -0
- package/dist/file-server.cjs +42 -10
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +6 -10
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +6 -10
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +34 -2
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +3 -6
- package/dist/functions/index.d.cts +3 -4
- package/dist/functions/index.d.mts +3 -4
- package/dist/functions/index.mjs +2 -6
- package/dist/{functions-i_la-N5r.cjs → functions-CbP5ZKma.cjs} +414 -264
- package/dist/functions-CbP5ZKma.cjs.map +1 -0
- package/dist/{functions-14lpEFL4.mjs → functions-Di6n5ltG.mjs} +376 -238
- package/dist/{functions-14lpEFL4.mjs.map → functions-Di6n5ltG.mjs.map} +1 -1
- package/dist/index-BuzRvKOQ.d.cts +115 -0
- package/dist/index-BuzRvKOQ.d.cts.map +1 -0
- package/dist/index-CTkKOer4.d.mts +115 -0
- package/dist/index-CTkKOer4.d.mts.map +1 -0
- package/dist/index-CeEtxDmK.d.cts +79 -0
- package/dist/index-CeEtxDmK.d.cts.map +1 -0
- package/dist/index-CeEtxDmK.d.mts +79 -0
- package/dist/index-CeEtxDmK.d.mts.map +1 -0
- package/dist/index.cjs +6 -3
- package/dist/index.d.cts +26 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +26 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -3
- package/dist/kms-B-Hm3d5r.cjs +85 -0
- package/dist/kms-B-Hm3d5r.cjs.map +1 -0
- package/dist/kms-BdUlMJEZ.mjs +85 -0
- package/dist/kms-BdUlMJEZ.mjs.map +1 -0
- package/dist/kysely-BEm5sDlU.d.cts +173 -0
- package/dist/kysely-BEm5sDlU.d.cts.map +1 -0
- package/dist/kysely-BRzzawr2.cjs +301 -0
- package/dist/kysely-BRzzawr2.cjs.map +1 -0
- package/dist/kysely-BYfM6Zby.mjs +288 -0
- package/dist/kysely-BYfM6Zby.mjs.map +1 -0
- package/dist/kysely-CjuvdXEV.d.mts +173 -0
- package/dist/kysely-CjuvdXEV.d.mts.map +1 -0
- package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-CFanua0O.mjs} +20 -60
- package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
- package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -113
- package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
- package/dist/mobile-app.cjs +73 -0
- package/dist/mobile-app.cjs.map +1 -0
- package/dist/mobile-app.d.cts +61 -0
- package/dist/mobile-app.d.cts.map +1 -0
- package/dist/mobile-app.d.mts +61 -0
- package/dist/mobile-app.d.mts.map +1 -0
- package/dist/mobile-app.mjs +72 -0
- package/dist/mobile-app.mjs.map +1 -0
- package/dist/object-storage.cjs +18 -10
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +3 -7
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +3 -7
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +11 -3
- package/dist/object-storage.mjs.map +1 -1
- package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
- package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
- package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
- package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
- package/dist/queue/index.cjs +6 -189
- package/dist/queue/index.d.cts +3 -60
- package/dist/queue/index.d.mts +3 -60
- package/dist/queue/index.mjs +3 -186
- package/dist/rest-api.cjs +88 -63
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +68 -61
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +68 -61
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +80 -55
- package/dist/rest-api.mjs.map +1 -1
- package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
- package/dist/runSubscriber-BRp9a_qi.cjs +126 -0
- package/dist/runSubscriber-BRp9a_qi.cjs.map +1 -0
- package/dist/runSubscriber-BYEY_bfA.mjs +109 -0
- package/dist/runSubscriber-BYEY_bfA.mjs.map +1 -0
- package/dist/shutdown-BMJmAhSt.cjs +38 -0
- package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
- package/dist/shutdown-C7xa8x9S.mjs +27 -0
- package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
- package/dist/site.cjs +34 -9
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +17 -22
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +17 -22
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +30 -5
- package/dist/site.mjs.map +1 -1
- package/dist/subscribers/index.cjs +111 -6
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +50 -6
- package/dist/subscribers/index.d.cts.map +1 -0
- package/dist/subscribers/index.d.mts +50 -6
- package/dist/subscribers/index.d.mts.map +1 -0
- package/dist/subscribers/index.mjs +108 -5
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/surfaceEnv-CNimK76p.cjs +56 -0
- package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
- package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
- package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
- package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
- package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
- package/dist/topic/index.cjs +3 -137
- package/dist/topic/index.d.cts +2 -4
- package/dist/topic/index.d.mts +2 -4
- package/dist/topic/index.mjs +2 -134
- package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
- package/dist/types-DMuSQeLL.d.cts.map +1 -0
- package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
- package/dist/types-DMuSQeLL.d.mts.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -0
- package/dist/worker.cjs +58 -34
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +63 -45
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +63 -44
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +53 -29
- package/dist/worker.mjs.map +1 -1
- package/package.json +82 -41
- package/dist/Construct-BD5neF7w.mjs.map +0 -1
- package/dist/Construct-C0ijr2qp.d.cts +0 -117
- package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
- package/dist/Construct-Ct8nalEi.d.mts +0 -117
- package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
- package/dist/Construct-CyS3RpTL.cjs.map +0 -1
- package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
- package/dist/Cron-dh4rUgib.d.mts.map +0 -1
- package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
- package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
- package/dist/CronBuilder-CGgY2080.d.mts +0 -44
- package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
- package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
- package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
- package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
- package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
- package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
- package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
- package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
- package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
- package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
- package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
- package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
- package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
- package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
- package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
- package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
- package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
- package/dist/Topic-19QeHBIR.d.cts +0 -91
- package/dist/Topic-19QeHBIR.d.cts.map +0 -1
- package/dist/Topic-DuFeqkBh.d.mts +0 -91
- package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
- package/dist/auth.d.cts.map +0 -1
- package/dist/auth.d.mts.map +0 -1
- package/dist/cache-0ANvRQnD.mjs +0 -51
- package/dist/cache-0ANvRQnD.mjs.map +0 -1
- package/dist/cache-3WSvAulx.cjs +0 -57
- package/dist/cache-3WSvAulx.cjs.map +0 -1
- package/dist/cache-BrRz3fEB.d.mts.map +0 -1
- package/dist/cache-BtZY_tHe.d.cts.map +0 -1
- package/dist/clone-DblgEZZa.mjs.map +0 -1
- package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
- package/dist/construct-interface-BfjcOD_E.cjs +0 -117
- package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
- package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
- package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
- package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
- package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
- package/dist/database/kysely.cjs.map +0 -1
- package/dist/database/kysely.d.cts.map +0 -1
- package/dist/database/kysely.d.mts.map +0 -1
- package/dist/database/kysely.mjs.map +0 -1
- package/dist/functions-i_la-N5r.cjs.map +0 -1
- package/dist/index-Bd5FqCoe.d.cts.map +0 -1
- package/dist/index-BknhM6Ux.d.mts +0 -31
- package/dist/index-BknhM6Ux.d.mts.map +0 -1
- package/dist/index-CBSfrowv.d.cts +0 -31
- package/dist/index-CBSfrowv.d.cts.map +0 -1
- package/dist/index-D24Xm79M.d.cts +0 -171
- package/dist/index-D24Xm79M.d.cts.map +0 -1
- package/dist/index-_ajboYxK.d.mts +0 -171
- package/dist/index-_ajboYxK.d.mts.map +0 -1
- package/dist/index-lAO9egTb.d.mts.map +0 -1
- package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
- package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
- package/dist/processAudits-CGqttuXm.cjs.map +0 -1
- package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts.map +0 -1
- package/dist/queue/index.d.mts.map +0 -1
- package/dist/queue/index.mjs.map +0 -1
- package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
- package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
- package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
- package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
- package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
- package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
- package/dist/types-BlAkSuGI.d.cts.map +0 -1
- package/dist/types-aKksMEWL.d.mts.map +0 -1
package/dist/crons/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["schedule: string","reason: string","schedule: ScheduleExpression"],"sources":["../../src/crons/schedule.ts"],"sourcesContent":["import type { ScheduleExpression } from './Cron';\n\n/**\n * A schedule a cron runner can take, as standard five-field cron.\n *\n * `ScheduleExpression` has two spellings. `cron(m h dom mon dow)` is already\n * five-field cron and unwraps; `rate(n unit)` is an interval, and an interval\n * is not a schedule — it says how often, where cron says when.\n *\n * Most intervals still have an exact cron equivalent, because they divide their\n * unit evenly: `rate(5 minutes)` is every fifth minute of every hour, and that\n * is `*/5 * * * *` precisely. `rate(7 hours)` has none. There is no cron field\n * that means \"every seven hours\" — `*/7` in the hour field fires at 0, 7, 14\n * and 21 and then starts over at midnight, so the gap between the last firing\n * of one day and the first of the next is three hours rather than seven.\n *\n * Those are refused rather than rounded. A job that runs at the wrong hour is\n * far harder to notice than one that refused to build, and a schedule quietly\n * adjusted by the framework is a bug nobody goes looking for.\n */\nexport class UnrepresentableSchedule extends Error {\n\tconstructor(\n\t\treadonly schedule: string,\n\t\treason: string,\n\t) {\n\t\tsuper(\n\t\t\t`\\`${schedule}\\` has no exact cron equivalent: ${reason}.\\n\\n` +\n\t\t\t\t'Cron says *when*, not *how often*, so an interval is only exact when ' +\n\t\t\t\t'it divides its unit evenly.\\n' +\n\t\t\t\t'Write the schedule you mean instead — `cron(0 */6 * * *)` for every ' +\n\t\t\t\t'sixth hour, say — or pick an interval that divides: minutes into 60, ' +\n\t\t\t\t'hours into 24.',\n\t\t);\n\t\tthis.name = 'UnrepresentableSchedule';\n\t}\n}\n\n/** Units `rate(…)` accepts, singular or plural. */\nconst UNITS = ['minute', 'hour', 'day'] as const;\ntype Unit = (typeof UNITS)[number];\n\n/**\n * Standard five-field cron for a schedule expression.\n *\n * @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.\n */\nexport function toCronExpression(schedule: ScheduleExpression): string {\n\tconst cron = /^cron\\((.+)\\)$/.exec(schedule);\n\tif (cron?.[1]) return cron[1].trim();\n\n\tconst rate = /^rate\\(\\s*(\\d+)\\s+(\\w+?)s?\\s*\\)$/.exec(schedule);\n\tif (!rate) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t'it is neither `cron(…)` nor `rate(n unit)`',\n\t\t);\n\t}\n\n\tconst every = Number(rate[1]);\n\tconst unit = rate[2] as Unit;\n\t/* c8 ignore next */ if (!unit)\n\t\tthrow new UnrepresentableSchedule(schedule, 'no unit');\n\n\tif (!UNITS.includes(unit)) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t`\\`${unit}\\` is not one of ${UNITS.join(', ')}`,\n\t\t);\n\t}\n\n\tif (every < 1) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t'an interval must be at least 1',\n\t\t);\n\t}\n\n\tswitch (unit) {\n\t\tcase 'minute':\n\t\t\tif (every === 1) return '* * * * *';\n\t\t\tif (60 % every !== 0) {\n\t\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\t\tschedule,\n\t\t\t\t\t`${every} does not divide 60, so the interval would reset at the top of each hour`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn `*/${every} * * * *`;\n\n\t\tcase 'hour':\n\t\t\tif (every === 1) return '0 * * * *';\n\t\t\tif (24 % every !== 0) {\n\t\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\t\tschedule,\n\t\t\t\t\t`${every} does not divide 24, so the interval would reset at midnight`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn `0 */${every} * * *`;\n\n\t\tcase 'day':\n\t\t\tif (every === 1) return '0 0 * * *';\n\t\t\t// `*/n` in day-of-month restarts on the 1st, so a 2-day interval fires\n\t\t\t// on the 1st and 3rd of a 31-day month and then again on the 1st — one\n\t\t\t// day later, not two. No month length makes that come out even.\n\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\tschedule,\n\t\t\t\t'day-of-month restarts every month, so no multi-day interval is even',\n\t\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,0BAAb,cAA6C,MAAM;CAClD,YACUA,UACTC,QACC;AACD,SACE,IAAI,SAAS,mCAAmC,OAAO;2JAMxD;EAVQ;AAWT,OAAK,OAAO;CACZ;AACD;;AAGD,MAAM,QAAQ;CAAC;CAAU;CAAQ;AAAM;;;;;;AAQvC,SAAgB,iBAAiBC,UAAsC;CACtE,MAAM,OAAO,iBAAiB,KAAK,SAAS;AAC5C,KAAI,OAAO,GAAI,QAAO,KAAK,GAAG,MAAM;CAEpC,MAAM,OAAO,mCAAmC,KAAK,SAAS;AAC9D,MAAK,KACJ,OAAM,IAAI,wBACT,UACA;CAIF,MAAM,QAAQ,OAAO,KAAK,GAAG;CAC7B,MAAM,OAAO,KAAK;qBACG,MAAK,KACzB,OAAM,IAAI,wBAAwB,UAAU;AAE7C,MAAK,MAAM,SAAS,KAAK,CACxB,OAAM,IAAI,wBACT,WACC,IAAI,KAAK,mBAAmB,MAAM,KAAK,KAAK,CAAC;AAIhD,KAAI,QAAQ,EACX,OAAM,IAAI,wBACT,UACA;AAIF,SAAQ,MAAR;EACC,KAAK;AACJ,OAAI,UAAU,EAAG,QAAO;AACxB,OAAI,KAAK,UAAU,EAClB,OAAM,IAAI,wBACT,WACC,EAAE,MAAM;AAGX,WAAQ,IAAI,MAAM;EAEnB,KAAK;AACJ,OAAI,UAAU,EAAG,QAAO;AACxB,OAAI,KAAK,UAAU,EAClB,OAAM,IAAI,wBACT,WACC,EAAE,MAAM;AAGX,WAAQ,MAAM,MAAM;EAErB,KAAK;AACJ,OAAI,UAAU,EAAG,QAAO;AAIxB,SAAM,IAAI,wBACT,UACA;CAEF;AACD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/crons/inProcess.ts","../../src/crons/runCron.ts","../../src/crons/schedule.ts"],"sourcesContent":["import { CronExpressionParser } from 'cron-parser';\n\n/**\n * The longest delay a timer takes. Node clamps anything longer to 1ms, so a\n * monthly cron would fire at once and then every millisecond.\n */\nconst MAX_DELAY = 2 ** 31 - 1;\n\n/** A schedule that is running, and the way to stop it. */\nexport interface InProcessSchedule {\n\tstop(): void;\n}\n\n/**\n * Run `fire` on a cron expression, in this process, by timer.\n *\n * For the one process that has no broker to keep a schedule: `gkm dev` on a\n * target whose crons are infrastructure once deployed — an EventBridge rule on\n * AWS. Deployed, a timer is the wrong tool: each replica would fire every job\n * once, and nothing would say so. That is why a server schedules through\n * pg-boss, and why this is never what a deployed process does.\n *\n * In UTC, as the deployed schedule is. The next firing is worked out from the\n * clock after each run rather than read off a sequence, so a run that outlasts\n * its interval skips what it overran instead of firing them back to back.\n */\nexport function scheduleInProcess(\n\texpression: string,\n\tfire: () => Promise<unknown> | unknown,\n): InProcessSchedule {\n\t// Parsed once up front, so a bad expression throws here — to the caller\n\t// scheduling it — rather than inside a timer.\n\tCronExpressionParser.parse(expression, { tz: 'UTC' });\n\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tlet stopped = false;\n\n\tconst arm = (at: number) => {\n\t\tif (stopped) return;\n\t\tconst delay = at - Date.now();\n\t\ttimer = setTimeout(\n\t\t\tasync () => {\n\t\t\t\tif (Date.now() < at) return arm(at);\n\t\t\t\tawait fire();\n\t\t\t\tarm(nextAfter(expression, new Date()));\n\t\t\t},\n\t\t\tMath.min(Math.max(delay, 0), MAX_DELAY),\n\t\t);\n\t\t// The server keeps the process alive; a schedule alone should not.\n\t\ttimer.unref?.();\n\t};\n\n\tarm(nextAfter(expression, new Date()));\n\n\treturn {\n\t\tstop() {\n\t\t\tstopped = true;\n\t\t\tclearTimeout(timer);\n\t\t},\n\t};\n}\n\nfunction nextAfter(expression: string, from: Date): number {\n\treturn CronExpressionParser.parse(expression, {\n\t\ttz: 'UTC',\n\t\tcurrentDate: from,\n\t})\n\t\t.next()\n\t\t.getTime();\n}\n","import type { AuditStorage } from '@geekmidas/audit';\nimport {\n\trunWithRequestContext,\n\ttype ServiceDiscovery,\n} from '@geekmidas/services';\nimport { publishEvents } from '../publisher';\nimport type { Cron } from './Cron';\n\n/**\n * Run a cron once, in this process: what an EventBridge rule's invocation does\n * on Lambda, for a server that schedules its own.\n *\n * The same steps as the Lambda adaptor — its services, its worker's database\n * as `db`, an auditor when it declared one, its output parsed, its events\n * published — because a cron that ran differently on a server than deployed\n * would pass locally and fail where it matters. Services come through the\n * discovery, which keeps one instance of each, so running every minute does not\n * reconnect a database every minute.\n */\nexport async function runCron(\n\tcron: Cron<any, any, any, any, any, any>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n): Promise<unknown> {\n\tconst services =\n\t\tcron.services.length > 0\n\t\t\t? await serviceDiscovery.register(cron.services)\n\t\t\t: {};\n\n\tconst db = cron.databaseService\n\t\t? (await serviceDiscovery.register([cron.databaseService]))[\n\t\t\t\tcron.databaseService.serviceName\n\t\t\t]\n\t\t: undefined;\n\n\t// Only imported for a cron that audits: `@geekmidas/audit` is optional.\n\tlet auditor: { flush(): Promise<void> } | undefined;\n\tif (cron.auditorStorageService) {\n\t\tconst { DefaultAuditor } = await import('@geekmidas/audit');\n\t\tconst registered: Record<string, unknown> = await serviceDiscovery.register(\n\t\t\t[cron.auditorStorageService],\n\t\t);\n\t\tconst storage = registered[\n\t\t\tcron.auditorStorageService.serviceName\n\t\t] as AuditStorage;\n\t\tauditor = new DefaultAuditor({\n\t\t\tactor: { id: 'system', type: 'system' },\n\t\t\tstorage,\n\t\t\tmetadata: { function: cron.type },\n\t\t});\n\t}\n\n\tconst logger = cron.logger;\n\tconst requestId = `cron-${Date.now()}`;\n\n\treturn runWithRequestContext(\n\t\t{\n\t\t\tlogger,\n\t\t\trequestId,\n\t\t\tstartTime: Date.now(),\n\t\t\toperation: `cron ${cron.schedule ?? 'manual'}`,\n\t\t},\n\t\tasync () => {\n\t\t\tconst response = await cron.fn({\n\t\t\t\tinput: undefined,\n\t\t\t\tservices,\n\t\t\t\tlogger,\n\t\t\t\tdb,\n\t\t\t\tauditor,\n\t\t\t} as any);\n\t\t\tconst output = await cron.parseOutput(response);\n\n\t\t\tawait auditor?.flush();\n\t\t\t// The cron's output schema is erased by the `any` it is typed with here.\n\t\t\tawait publishEvents(\n\t\t\t\tlogger,\n\t\t\t\tserviceDiscovery,\n\t\t\t\tcron.events,\n\t\t\t\toutput as never,\n\t\t\t);\n\n\t\t\treturn output;\n\t\t},\n\t);\n}\n","import type { ScheduleExpression } from './Cron';\n\n/**\n * A schedule a cron runner can take, as standard five-field cron.\n *\n * `ScheduleExpression` has two spellings. `cron(m h dom mon dow)` is already\n * five-field cron and unwraps; `rate(n unit)` is an interval, and an interval\n * is not a schedule — it says how often, where cron says when.\n *\n * Most intervals still have an exact cron equivalent, because they divide their\n * unit evenly: `rate(5 minutes)` is every fifth minute of every hour, and that\n * is `*/5 * * * *` precisely. `rate(7 hours)` has none. There is no cron field\n * that means \"every seven hours\" — `*/7` in the hour field fires at 0, 7, 14\n * and 21 and then starts over at midnight, so the gap between the last firing\n * of one day and the first of the next is three hours rather than seven.\n *\n * Those are refused rather than rounded. A job that runs at the wrong hour is\n * far harder to notice than one that refused to build, and a schedule quietly\n * adjusted by the framework is a bug nobody goes looking for.\n */\nexport class UnrepresentableSchedule extends Error {\n\tconstructor(\n\t\treadonly schedule: string,\n\t\treason: string,\n\t) {\n\t\tsuper(\n\t\t\t`\\`${schedule}\\` has no exact cron equivalent: ${reason}.\\n\\n` +\n\t\t\t\t'Cron says *when*, not *how often*, so an interval is only exact when ' +\n\t\t\t\t'it divides its unit evenly.\\n' +\n\t\t\t\t'Write the schedule you mean instead — `cron(0 */6 * * *)` for every ' +\n\t\t\t\t'sixth hour, say — or pick an interval that divides: minutes into 60, ' +\n\t\t\t\t'hours into 24.',\n\t\t);\n\t\tthis.name = 'UnrepresentableSchedule';\n\t}\n}\n\n/** Units `rate(…)` accepts, singular or plural. */\nconst UNITS = ['minute', 'hour', 'day'] as const;\ntype Unit = (typeof UNITS)[number];\n\n/**\n * Standard five-field cron for a schedule expression.\n *\n * @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.\n */\nexport function toCronExpression(schedule: ScheduleExpression): string {\n\tconst cron = /^cron\\((.+)\\)$/.exec(schedule);\n\tif (cron?.[1]) return cron[1].trim();\n\n\tconst rate = /^rate\\(\\s*(\\d+)\\s+(\\w+?)s?\\s*\\)$/.exec(schedule);\n\tif (!rate) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t'it is neither `cron(…)` nor `rate(n unit)`',\n\t\t);\n\t}\n\n\tconst every = Number(rate[1]);\n\tconst unit = rate[2] as Unit;\n\t/* c8 ignore next */ if (!unit)\n\t\tthrow new UnrepresentableSchedule(schedule, 'no unit');\n\n\tif (!UNITS.includes(unit)) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t`\\`${unit}\\` is not one of ${UNITS.join(', ')}`,\n\t\t);\n\t}\n\n\tif (every < 1) {\n\t\tthrow new UnrepresentableSchedule(\n\t\t\tschedule,\n\t\t\t'an interval must be at least 1',\n\t\t);\n\t}\n\n\tswitch (unit) {\n\t\tcase 'minute':\n\t\t\tif (every === 1) return '* * * * *';\n\t\t\tif (60 % every !== 0) {\n\t\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\t\tschedule,\n\t\t\t\t\t`${every} does not divide 60, so the interval would reset at the top of each hour`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn `*/${every} * * * *`;\n\n\t\tcase 'hour':\n\t\t\tif (every === 1) return '0 * * * *';\n\t\t\tif (24 % every !== 0) {\n\t\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\t\tschedule,\n\t\t\t\t\t`${every} does not divide 24, so the interval would reset at midnight`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn `0 */${every} * * *`;\n\n\t\tcase 'day':\n\t\t\tif (every === 1) return '0 0 * * *';\n\t\t\t// `*/n` in day-of-month restarts on the 1st, so a 2-day interval fires\n\t\t\t// on the 1st and 3rd of a 31-day month and then again on the 1st — one\n\t\t\t// day later, not two. No month length makes that come out even.\n\t\t\tthrow new UnrepresentableSchedule(\n\t\t\t\tschedule,\n\t\t\t\t'day-of-month restarts every month, so no multi-day interval is even',\n\t\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;AAMA,MAAM,YAAY,KAAK,KAAK;;;;;;;;;;;;;;AAoB5B,SAAgB,kBACf,YACA,MACoB;CAGpB,qBAAqB,MAAM,YAAY,EAAE,IAAI,MAAM,CAAC;CAEpD,IAAI;CACJ,IAAI,UAAU;CAEd,MAAM,OAAO,OAAe;EAC3B,IAAI,SAAS;EACb,MAAM,QAAQ,KAAK,KAAK,IAAI;EAC5B,QAAQ,WACP,YAAY;GACX,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,IAAI,EAAE;GAClC,MAAM,KAAK;GACX,IAAI,UAAU,4BAAY,IAAI,KAAK,CAAC,CAAC;EACtC,GACA,KAAK,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,SAAS,CACvC;EAEA,MAAM,QAAQ;CACf;CAEA,IAAI,UAAU,4BAAY,IAAI,KAAK,CAAC,CAAC;CAErC,OAAO,EACN,OAAO;EACN,UAAU;EACV,aAAa,KAAK;CACnB,EACD;AACD;AAEA,SAAS,UAAU,YAAoB,MAAoB;CAC1D,OAAO,qBAAqB,MAAM,YAAY;EAC7C,IAAI;EACJ,aAAa;CACd,CAAC,CAAC,CACA,KAAK,CAAC,CACN,QAAQ;AACX;;;;;;;;;;;;;;AClDA,eAAsB,QACrB,MACA,kBACmB;CACnB,MAAM,WACL,KAAK,SAAS,SAAS,IACpB,MAAM,iBAAiB,SAAS,KAAK,QAAQ,IAC7C,CAAC;CAEL,MAAM,KAAK,KAAK,mBACZ,MAAM,iBAAiB,SAAS,CAAC,KAAK,eAAe,CAAC,EAAA,CACvD,KAAK,gBAAgB,eAErB,KAAA;CAGH,IAAI;CACJ,IAAI,KAAK,uBAAuB;EAC/B,MAAM,EAAE,mBAAmB,MAAM,OAAO;EAIxC,MAAM,WAAU,MAHkC,iBAAiB,SAClE,CAAC,KAAK,qBAAqB,CAC5B,EAAA,CAEC,KAAK,sBAAsB;EAE5B,UAAU,IAAI,eAAe;GAC5B,OAAO;IAAE,IAAI;IAAU,MAAM;GAAS;GACtC;GACA,UAAU,EAAE,UAAU,KAAK,KAAK;EACjC,CAAC;CACF;CAEA,MAAM,SAAS,KAAK;CACpB,MAAM,YAAY,QAAQ,KAAK,IAAI;CAEnC,OAAO,sBACN;EACC;EACA;EACA,WAAW,KAAK,IAAI;EACpB,WAAW,QAAQ,KAAK,YAAY;CACrC,GACA,YAAY;EACX,MAAM,WAAW,MAAM,KAAK,GAAG;GAC9B,OAAO,KAAA;GACP;GACA;GACA;GACA;EACD,CAAQ;EACR,MAAM,SAAS,MAAM,KAAK,YAAY,QAAQ;EAE9C,MAAM,SAAS,MAAM;EAErB,MAAM,cACL,QACA,kBACA,KAAK,QACL,MACD;EAEA,OAAO;CACR,CACD;AACD;;;;;;;;;;;;;;;;;;;;;AC/DA,IAAa,0BAAb,cAA6C,MAAM;CAExC;CADV,YACC,UACA,QACC;EACD,MACC,KAAK,SAAS,mCAAmC,OAAO;0JAMzD;EAVS,KAAA,WAAA;EAWT,KAAK,OAAO;CACb;AACD;;AAGA,MAAM,QAAQ;CAAC;CAAU;CAAQ;AAAK;;;;;;AAQtC,SAAgB,iBAAiB,UAAsC;CACtE,MAAM,OAAO,iBAAiB,KAAK,QAAQ;CAC3C,IAAI,OAAO,IAAI,OAAO,KAAK,EAAE,CAAC,KAAK;CAEnC,MAAM,OAAO,mCAAmC,KAAK,QAAQ;CAC7D,IAAI,CAAC,MACJ,MAAM,IAAI,wBACT,UACA,4CACD;CAGD,MAAM,QAAQ,OAAO,KAAK,EAAE;CAC5B,MAAM,OAAO,KAAK;sBACG,IAAI,CAAC,MACzB,MAAM,IAAI,wBAAwB,UAAU,SAAS;CAEtD,IAAI,CAAC,MAAM,SAAS,IAAI,GACvB,MAAM,IAAI,wBACT,UACA,KAAK,KAAK,mBAAmB,MAAM,KAAK,IAAI,GAC7C;CAGD,IAAI,QAAQ,GACX,MAAM,IAAI,wBACT,UACA,gCACD;CAGD,QAAQ,MAAR;EACC,KAAK;GACJ,IAAI,UAAU,GAAG,OAAO;GACxB,IAAI,KAAK,UAAU,GAClB,MAAM,IAAI,wBACT,UACA,GAAG,MAAM,yEACV;GAED,OAAO,KAAK,MAAM;EAEnB,KAAK;GACJ,IAAI,UAAU,GAAG,OAAO;GACxB,IAAI,KAAK,UAAU,GAClB,MAAM,IAAI,wBACT,UACA,GAAG,MAAM,6DACV;GAED,OAAO,OAAO,MAAM;EAErB,KAAK;GACJ,IAAI,UAAU,GAAG,OAAO;GAIxB,MAAM,IAAI,wBACT,UACA,qEACD;CACF;AACD"}
|
package/dist/database/kysely.cjs
CHANGED
|
@@ -1,181 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const pg = require_chunk.__toESM(require("pg"));
|
|
6
|
-
|
|
7
|
-
//#region src/database/kysely.ts
|
|
8
|
-
/** The schema a database uses when it does not say otherwise. */
|
|
9
|
-
const DEFAULT_SCHEMA = "app";
|
|
10
|
-
/**
|
|
11
|
-
* @typeParam DB - the database's schema.
|
|
12
|
-
* @typeParam TName - the canonical id. TypeScript has no partial
|
|
13
|
-
* type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
|
|
14
|
-
* this at its default and the service key widens to `string`. `db` still types
|
|
15
|
-
* through `.database()`, which infers from the service.
|
|
16
|
-
*/
|
|
17
|
-
var KyselyDatabase = class KyselyDatabase {
|
|
18
|
-
id;
|
|
19
|
-
service;
|
|
20
|
-
/**
|
|
21
|
-
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
22
|
-
* build publishes and the key the client reads cannot drift.
|
|
23
|
-
*/
|
|
24
|
-
config;
|
|
25
|
-
schemaName;
|
|
26
|
-
roles;
|
|
27
|
-
version;
|
|
28
|
-
derivedFrom;
|
|
29
|
-
constructor(id, options = {}, derivedFrom) {
|
|
30
|
-
this.options = options;
|
|
31
|
-
const canonical = (0, __geekmidas_manifest.canonicalId)(id);
|
|
32
|
-
this.id = canonical;
|
|
33
|
-
this.config = {
|
|
34
|
-
url: (0, __geekmidas_manifest.provideKey)(canonical, "url"),
|
|
35
|
-
ownerUrl: (0, __geekmidas_manifest.provideKey)(canonical, "ownerUrl")
|
|
36
|
-
};
|
|
37
|
-
this.schemaName = options.schema ?? DEFAULT_SCHEMA;
|
|
38
|
-
this.roles = options.roles ?? true;
|
|
39
|
-
this.version = options.version ?? __geekmidas_manifest.DEFAULT_POSTGRES_VERSION;
|
|
40
|
-
this.derivedFrom = derivedFrom;
|
|
41
|
-
this.service = {
|
|
42
|
-
serviceName: (0, __geekmidas_manifest.serviceKey)(canonical),
|
|
43
|
-
register: (registerOptions) => this.connect(registerOptions)
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
declare() {
|
|
47
|
-
if (this.derivedFrom) {
|
|
48
|
-
const { kind, of, schema } = this.derivedFrom;
|
|
49
|
-
return [kind === "database-schema" ? {
|
|
50
|
-
kind,
|
|
51
|
-
id: this.id,
|
|
52
|
-
of,
|
|
53
|
-
schema: schema ?? this.schemaName,
|
|
54
|
-
provides: [this.config.url]
|
|
55
|
-
} : {
|
|
56
|
-
kind,
|
|
57
|
-
id: this.id,
|
|
58
|
-
of,
|
|
59
|
-
provides: [this.config.url]
|
|
60
|
-
}];
|
|
61
|
-
}
|
|
62
|
-
return [{
|
|
63
|
-
kind: "database",
|
|
64
|
-
id: this.id,
|
|
65
|
-
engine: "postgres",
|
|
66
|
-
schema: this.schemaName,
|
|
67
|
-
version: this.version,
|
|
68
|
-
provides: [this.config.url],
|
|
69
|
-
...this.roles ? {} : { roles: false }
|
|
70
|
-
}];
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* A read-only endpoint on this database.
|
|
74
|
-
*
|
|
75
|
-
* Read-only is enforced by the reader role's grants rather than by which
|
|
76
|
-
* endpoint it resolves to, so falling back to the writer where no replica
|
|
77
|
-
* exists is safe rather than a silently writable connection behind a name
|
|
78
|
-
* that says reader. There is no `writer()`: the database *is* the writer, so
|
|
79
|
-
* a replica can never be reached by accident.
|
|
80
|
-
*
|
|
81
|
-
* The return type is narrower than this class on purpose — see
|
|
82
|
-
* {@link ReadOnlyDatabase}.
|
|
83
|
-
*/
|
|
84
|
-
reader() {
|
|
85
|
-
return new KyselyDatabase(`${this.id}Reader`, this.options, {
|
|
86
|
-
kind: "database-reader",
|
|
87
|
-
of: this.id
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* A cache that lives in this database.
|
|
92
|
-
*
|
|
93
|
-
* The same strengthening `schema()` is over a second database: `new
|
|
94
|
-
* Cache('Sessions')` says the app caches and leaves where to the deployment,
|
|
95
|
-
* while this says it caches *here* — which is a fact about the application
|
|
96
|
-
* and so belongs in its code.
|
|
97
|
-
*
|
|
98
|
-
* What it buys beyond being explicit: the table's schema and the role that
|
|
99
|
-
* reaches it come from this database rather than from a second convention,
|
|
100
|
-
* and the backend no longer has to guess which database "the database" meant
|
|
101
|
-
* when an app declares two.
|
|
102
|
-
*
|
|
103
|
-
* A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
|
|
104
|
-
* is a key/value store, not a query builder, and typing it as the parent
|
|
105
|
-
* would be a convenience that lies.
|
|
106
|
-
*/
|
|
107
|
-
cache(id = `${this.id}Cache`, options = {}) {
|
|
108
|
-
return new require_cache.Cache(id, {
|
|
109
|
-
of: this.id,
|
|
110
|
-
...options.table ? { table: options.table } : {}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* A second schema in this database, with its own role(s) and its own URL —
|
|
115
|
-
* so this database's role holds no grant on those tables at all.
|
|
116
|
-
*
|
|
117
|
-
* Typed separately because a tenant has its own tables: the point is that
|
|
118
|
-
* `auth.selectFrom('sessions')` type-checks and
|
|
119
|
-
* `orders.selectFrom('sessions')` does not.
|
|
120
|
-
*/
|
|
121
|
-
schema(id, options = {}) {
|
|
122
|
-
return new KyselyDatabase(id, options, {
|
|
123
|
-
kind: "database-schema",
|
|
124
|
-
of: this.id,
|
|
125
|
-
schema: options.schema ?? id.toLowerCase()
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* A connection as the *owner* role — the one that may create, alter and drop.
|
|
130
|
-
*
|
|
131
|
-
* A `Service` rather than part of the construct, and deliberately so: a
|
|
132
|
-
* construct is what `.dependsOn()` accepts, and nothing should be able to
|
|
133
|
-
* depend on this. A migrator asks for it by name; a handler cannot ask at
|
|
134
|
-
* all, which is the security property the role split exists for.
|
|
135
|
-
*
|
|
136
|
-
* Falls back to the runtime URL where no owner URL was published — the
|
|
137
|
-
* `roles: false` downgrade, where there is only one credential and it is the
|
|
138
|
-
* cluster master's.
|
|
139
|
-
*/
|
|
140
|
-
get owner() {
|
|
141
|
-
return {
|
|
142
|
-
serviceName: `${(0, __geekmidas_manifest.serviceKey)(this.id)}Owner`,
|
|
143
|
-
register: (options) => this.connect(options, { owner: true })
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
async connect(options, as = {}) {
|
|
147
|
-
const { url, ownerUrl } = options.envParser.create((get) => ({
|
|
148
|
-
url: get(this.config.url).string(),
|
|
149
|
-
ownerUrl: get(this.config.ownerUrl).string().optional()
|
|
150
|
-
})).parse();
|
|
151
|
-
const { schema: _schema, roles: _roles,...kysely$1 } = this.options;
|
|
152
|
-
return new kysely.Kysely({
|
|
153
|
-
...kysely$1,
|
|
154
|
-
dialect: new kysely.PostgresDialect({ pool: pool(as.owner ? ownerUrl ?? url : url) })
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* A pool for one URL, with its schema actually on the search path.
|
|
160
|
-
*
|
|
161
|
-
* `?search_path=` is not a libpq parameter — a URL carrying it connects
|
|
162
|
-
* happily and then resolves every unqualified name against `public`, which is
|
|
163
|
-
* how a schema tenant silently writes its tables into the database it was
|
|
164
|
-
* separated from. Postgres takes it as a startup option instead, so the URL
|
|
165
|
-
* keeps the readable form the target derives and this turns it into the thing
|
|
166
|
-
* the server understands.
|
|
167
|
-
*/
|
|
168
|
-
function pool(url) {
|
|
169
|
-
const parsed = new URL(url);
|
|
170
|
-
const searchPath = parsed.searchParams.get("search_path");
|
|
171
|
-
if (!searchPath) return new pg.default.Pool({ connectionString: url });
|
|
172
|
-
parsed.searchParams.delete("search_path");
|
|
173
|
-
return new pg.default.Pool({
|
|
174
|
-
connectionString: parsed.toString(),
|
|
175
|
-
options: `-c search_path=${searchPath}`
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
//#endregion
|
|
180
|
-
exports.KyselyDatabase = KyselyDatabase;
|
|
181
|
-
//# sourceMappingURL=kysely.cjs.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_kysely = require("../kysely-BRzzawr2.cjs");
|
|
3
|
+
exports.KyselyDatabase = require_kysely.KyselyDatabase;
|
|
4
|
+
exports.closeDatabasePools = require_kysely.closeDatabasePools;
|
|
@@ -1,152 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Service } from "@geekmidas/services";
|
|
4
|
-
import { ConstructName, Declaration, PostgresVersion } from "@geekmidas/manifest";
|
|
5
|
-
import { Kysely, KyselyConfig } from "kysely";
|
|
6
|
-
|
|
7
|
-
//#region src/database/kysely.d.ts
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Everything Kysely takes, plus what this construct declares.
|
|
11
|
-
*
|
|
12
|
-
* `dialect` is omitted because the construct owns it — it is built from the one
|
|
13
|
-
* URL the adapter supplied, which is the whole point of the construct. The rest
|
|
14
|
-
* of `KyselyConfig` (`plugins`, `log`) is the app's business and passes
|
|
15
|
-
* straight through, so anything Kysely adds later arrives without being
|
|
16
|
-
* tracked here.
|
|
17
|
-
*/
|
|
18
|
-
interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {
|
|
19
|
-
/**
|
|
20
|
-
* The schema, pinned on both roles' `search_path`.
|
|
21
|
-
*
|
|
22
|
-
* Defaults to `app` — the role the schema plays, rather than a restatement
|
|
23
|
-
* of the database's own name, which reads correctly beside `auth` and
|
|
24
|
-
* `pgboss` and keeps the application off `public`.
|
|
25
|
-
*/
|
|
26
|
-
schema?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Provision the owner/runtime role split. Defaults to on.
|
|
29
|
-
*
|
|
30
|
-
* Off falls back to the cluster's master credential in both URLs, giving up
|
|
31
|
-
* the DDL/DML split and putting credentials that can drop a table into the
|
|
32
|
-
* function's environment. A deliberate downgrade, not a default.
|
|
33
|
-
*/
|
|
34
|
-
roles?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* The Postgres major version to provision.
|
|
37
|
-
*
|
|
38
|
-
* Declared here so one statement reaches both targets. It was previously
|
|
39
|
-
* set in two unrelated places — a container tag locally, nothing at all on
|
|
40
|
-
* AWS (so Aurora chose) — which is how local came to run 18 while deployed
|
|
41
|
-
* ran 17.7 with nothing recording the difference.
|
|
42
|
-
*
|
|
43
|
-
* Defaults to {@link DEFAULT_POSTGRES_VERSION}.
|
|
44
|
-
*/
|
|
45
|
-
version?: PostgresVersion;
|
|
46
|
-
}
|
|
47
|
-
/** What makes a construct derived rather than a database in its own right. */
|
|
48
|
-
interface DerivedFrom {
|
|
49
|
-
kind: 'database-reader' | 'database-schema';
|
|
50
|
-
of: string;
|
|
51
|
-
schema?: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @typeParam DB - the database's schema.
|
|
55
|
-
* @typeParam TName - the canonical id. TypeScript has no partial
|
|
56
|
-
* type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
|
|
57
|
-
* this at its default and the service key widens to `string`. `db` still types
|
|
58
|
-
* through `.database()`, which infers from the service.
|
|
59
|
-
*/
|
|
60
|
-
declare class KyselyDatabase<DB = unknown, TName extends string = string> implements Construct<TName, Kysely<DB>> {
|
|
61
|
-
private readonly options;
|
|
62
|
-
readonly id: TName;
|
|
63
|
-
readonly service: Service<Uncapitalize<TName>, Kysely<DB>>;
|
|
64
|
-
/**
|
|
65
|
-
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
66
|
-
* build publishes and the key the client reads cannot drift.
|
|
67
|
-
*/
|
|
68
|
-
private readonly config;
|
|
69
|
-
private readonly schemaName;
|
|
70
|
-
private readonly roles;
|
|
71
|
-
private readonly version;
|
|
72
|
-
private readonly derivedFrom?;
|
|
73
|
-
constructor(id: ConstructName<TName>, options?: KyselyDatabaseOptions, derivedFrom?: DerivedFrom);
|
|
74
|
-
declare(): Declaration[];
|
|
75
|
-
/**
|
|
76
|
-
* A read-only endpoint on this database.
|
|
77
|
-
*
|
|
78
|
-
* Read-only is enforced by the reader role's grants rather than by which
|
|
79
|
-
* endpoint it resolves to, so falling back to the writer where no replica
|
|
80
|
-
* exists is safe rather than a silently writable connection behind a name
|
|
81
|
-
* that says reader. There is no `writer()`: the database *is* the writer, so
|
|
82
|
-
* a replica can never be reached by accident.
|
|
83
|
-
*
|
|
84
|
-
* The return type is narrower than this class on purpose — see
|
|
85
|
-
* {@link ReadOnlyDatabase}.
|
|
86
|
-
*/
|
|
87
|
-
reader(): ReadOnlyDatabase<DB, `${TName}Reader`>;
|
|
88
|
-
/**
|
|
89
|
-
* A cache that lives in this database.
|
|
90
|
-
*
|
|
91
|
-
* The same strengthening `schema()` is over a second database: `new
|
|
92
|
-
* Cache('Sessions')` says the app caches and leaves where to the deployment,
|
|
93
|
-
* while this says it caches *here* — which is a fact about the application
|
|
94
|
-
* and so belongs in its code.
|
|
95
|
-
*
|
|
96
|
-
* What it buys beyond being explicit: the table's schema and the role that
|
|
97
|
-
* reaches it come from this database rather than from a second convention,
|
|
98
|
-
* and the backend no longer has to guess which database "the database" meant
|
|
99
|
-
* when an app declares two.
|
|
100
|
-
*
|
|
101
|
-
* A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
|
|
102
|
-
* is a key/value store, not a query builder, and typing it as the parent
|
|
103
|
-
* would be a convenience that lies.
|
|
104
|
-
*/
|
|
105
|
-
cache<TCache extends string = `${TName}Cache`>(id?: ConstructName<TCache>, options?: {
|
|
106
|
-
table?: string;
|
|
107
|
-
}): Cache<TCache>;
|
|
108
|
-
/**
|
|
109
|
-
* A second schema in this database, with its own role(s) and its own URL —
|
|
110
|
-
* so this database's role holds no grant on those tables at all.
|
|
111
|
-
*
|
|
112
|
-
* Typed separately because a tenant has its own tables: the point is that
|
|
113
|
-
* `auth.selectFrom('sessions')` type-checks and
|
|
114
|
-
* `orders.selectFrom('sessions')` does not.
|
|
115
|
-
*/
|
|
116
|
-
schema<TenantDB, TTenant extends string>(id: ConstructName<TTenant>, options?: KyselyDatabaseOptions): KyselyDatabase<TenantDB, TTenant>;
|
|
117
|
-
/**
|
|
118
|
-
* A connection as the *owner* role — the one that may create, alter and drop.
|
|
119
|
-
*
|
|
120
|
-
* A `Service` rather than part of the construct, and deliberately so: a
|
|
121
|
-
* construct is what `.dependsOn()` accepts, and nothing should be able to
|
|
122
|
-
* depend on this. A migrator asks for it by name; a handler cannot ask at
|
|
123
|
-
* all, which is the security property the role split exists for.
|
|
124
|
-
*
|
|
125
|
-
* Falls back to the runtime URL where no owner URL was published — the
|
|
126
|
-
* `roles: false` downgrade, where there is only one credential and it is the
|
|
127
|
-
* cluster master's.
|
|
128
|
-
*/
|
|
129
|
-
get owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>>;
|
|
130
|
-
private connect;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* A database you may read through, and derive nothing from.
|
|
134
|
-
*
|
|
135
|
-
* A reader is terminal in the graph, and this is that fact in the type system.
|
|
136
|
-
* `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`
|
|
137
|
-
* parent, and there is no reader of a reader — so `orders.reader().cache(…)`
|
|
138
|
-
* has always been illegal, but it type-checked and failed later at
|
|
139
|
-
* `assertDerivations`. That is a long way round to learn that a read-only
|
|
140
|
-
* endpoint cannot own a table something writes to.
|
|
141
|
-
*
|
|
142
|
-
* Omitting the three deriving methods rather than making them throw keeps the
|
|
143
|
-
* failure where it costs least: the editor, on the line that wrote it.
|
|
144
|
-
*
|
|
145
|
-
* The result is deliberately not assignable back to `KyselyDatabase` — a
|
|
146
|
-
* reader is not one, and anything that genuinely needs the writer should say
|
|
147
|
-
* so.
|
|
148
|
-
*/
|
|
149
|
-
type ReadOnlyDatabase<DB, TName extends string> = Omit<KyselyDatabase<DB, TName>, 'reader' | 'cache' | 'schema'>;
|
|
150
|
-
//#endregion
|
|
151
|
-
export { KyselyDatabase, KyselyDatabaseOptions, ReadOnlyDatabase };
|
|
152
|
-
//# sourceMappingURL=kysely.d.cts.map
|
|
1
|
+
import { i as closeDatabasePools, n as KyselyDatabaseOptions, r as ReadOnlyDatabase, t as KyselyDatabase } from "../kysely-BEm5sDlU.cjs";
|
|
2
|
+
export { KyselyDatabase, KyselyDatabaseOptions, ReadOnlyDatabase, closeDatabasePools };
|
|
@@ -1,152 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { ConstructName, Declaration, PostgresVersion } from "@geekmidas/manifest";
|
|
4
|
-
import { Service } from "@geekmidas/services";
|
|
5
|
-
import { Kysely, KyselyConfig } from "kysely";
|
|
6
|
-
|
|
7
|
-
//#region src/database/kysely.d.ts
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Everything Kysely takes, plus what this construct declares.
|
|
11
|
-
*
|
|
12
|
-
* `dialect` is omitted because the construct owns it — it is built from the one
|
|
13
|
-
* URL the adapter supplied, which is the whole point of the construct. The rest
|
|
14
|
-
* of `KyselyConfig` (`plugins`, `log`) is the app's business and passes
|
|
15
|
-
* straight through, so anything Kysely adds later arrives without being
|
|
16
|
-
* tracked here.
|
|
17
|
-
*/
|
|
18
|
-
interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {
|
|
19
|
-
/**
|
|
20
|
-
* The schema, pinned on both roles' `search_path`.
|
|
21
|
-
*
|
|
22
|
-
* Defaults to `app` — the role the schema plays, rather than a restatement
|
|
23
|
-
* of the database's own name, which reads correctly beside `auth` and
|
|
24
|
-
* `pgboss` and keeps the application off `public`.
|
|
25
|
-
*/
|
|
26
|
-
schema?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Provision the owner/runtime role split. Defaults to on.
|
|
29
|
-
*
|
|
30
|
-
* Off falls back to the cluster's master credential in both URLs, giving up
|
|
31
|
-
* the DDL/DML split and putting credentials that can drop a table into the
|
|
32
|
-
* function's environment. A deliberate downgrade, not a default.
|
|
33
|
-
*/
|
|
34
|
-
roles?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* The Postgres major version to provision.
|
|
37
|
-
*
|
|
38
|
-
* Declared here so one statement reaches both targets. It was previously
|
|
39
|
-
* set in two unrelated places — a container tag locally, nothing at all on
|
|
40
|
-
* AWS (so Aurora chose) — which is how local came to run 18 while deployed
|
|
41
|
-
* ran 17.7 with nothing recording the difference.
|
|
42
|
-
*
|
|
43
|
-
* Defaults to {@link DEFAULT_POSTGRES_VERSION}.
|
|
44
|
-
*/
|
|
45
|
-
version?: PostgresVersion;
|
|
46
|
-
}
|
|
47
|
-
/** What makes a construct derived rather than a database in its own right. */
|
|
48
|
-
interface DerivedFrom {
|
|
49
|
-
kind: 'database-reader' | 'database-schema';
|
|
50
|
-
of: string;
|
|
51
|
-
schema?: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @typeParam DB - the database's schema.
|
|
55
|
-
* @typeParam TName - the canonical id. TypeScript has no partial
|
|
56
|
-
* type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
|
|
57
|
-
* this at its default and the service key widens to `string`. `db` still types
|
|
58
|
-
* through `.database()`, which infers from the service.
|
|
59
|
-
*/
|
|
60
|
-
declare class KyselyDatabase<DB = unknown, TName extends string = string> implements Construct<TName, Kysely<DB>> {
|
|
61
|
-
private readonly options;
|
|
62
|
-
readonly id: TName;
|
|
63
|
-
readonly service: Service<Uncapitalize<TName>, Kysely<DB>>;
|
|
64
|
-
/**
|
|
65
|
-
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
66
|
-
* build publishes and the key the client reads cannot drift.
|
|
67
|
-
*/
|
|
68
|
-
private readonly config;
|
|
69
|
-
private readonly schemaName;
|
|
70
|
-
private readonly roles;
|
|
71
|
-
private readonly version;
|
|
72
|
-
private readonly derivedFrom?;
|
|
73
|
-
constructor(id: ConstructName<TName>, options?: KyselyDatabaseOptions, derivedFrom?: DerivedFrom);
|
|
74
|
-
declare(): Declaration[];
|
|
75
|
-
/**
|
|
76
|
-
* A read-only endpoint on this database.
|
|
77
|
-
*
|
|
78
|
-
* Read-only is enforced by the reader role's grants rather than by which
|
|
79
|
-
* endpoint it resolves to, so falling back to the writer where no replica
|
|
80
|
-
* exists is safe rather than a silently writable connection behind a name
|
|
81
|
-
* that says reader. There is no `writer()`: the database *is* the writer, so
|
|
82
|
-
* a replica can never be reached by accident.
|
|
83
|
-
*
|
|
84
|
-
* The return type is narrower than this class on purpose — see
|
|
85
|
-
* {@link ReadOnlyDatabase}.
|
|
86
|
-
*/
|
|
87
|
-
reader(): ReadOnlyDatabase<DB, `${TName}Reader`>;
|
|
88
|
-
/**
|
|
89
|
-
* A cache that lives in this database.
|
|
90
|
-
*
|
|
91
|
-
* The same strengthening `schema()` is over a second database: `new
|
|
92
|
-
* Cache('Sessions')` says the app caches and leaves where to the deployment,
|
|
93
|
-
* while this says it caches *here* — which is a fact about the application
|
|
94
|
-
* and so belongs in its code.
|
|
95
|
-
*
|
|
96
|
-
* What it buys beyond being explicit: the table's schema and the role that
|
|
97
|
-
* reaches it come from this database rather than from a second convention,
|
|
98
|
-
* and the backend no longer has to guess which database "the database" meant
|
|
99
|
-
* when an app declares two.
|
|
100
|
-
*
|
|
101
|
-
* A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
|
|
102
|
-
* is a key/value store, not a query builder, and typing it as the parent
|
|
103
|
-
* would be a convenience that lies.
|
|
104
|
-
*/
|
|
105
|
-
cache<TCache extends string = `${TName}Cache`>(id?: ConstructName<TCache>, options?: {
|
|
106
|
-
table?: string;
|
|
107
|
-
}): Cache<TCache>;
|
|
108
|
-
/**
|
|
109
|
-
* A second schema in this database, with its own role(s) and its own URL —
|
|
110
|
-
* so this database's role holds no grant on those tables at all.
|
|
111
|
-
*
|
|
112
|
-
* Typed separately because a tenant has its own tables: the point is that
|
|
113
|
-
* `auth.selectFrom('sessions')` type-checks and
|
|
114
|
-
* `orders.selectFrom('sessions')` does not.
|
|
115
|
-
*/
|
|
116
|
-
schema<TenantDB, TTenant extends string>(id: ConstructName<TTenant>, options?: KyselyDatabaseOptions): KyselyDatabase<TenantDB, TTenant>;
|
|
117
|
-
/**
|
|
118
|
-
* A connection as the *owner* role — the one that may create, alter and drop.
|
|
119
|
-
*
|
|
120
|
-
* A `Service` rather than part of the construct, and deliberately so: a
|
|
121
|
-
* construct is what `.dependsOn()` accepts, and nothing should be able to
|
|
122
|
-
* depend on this. A migrator asks for it by name; a handler cannot ask at
|
|
123
|
-
* all, which is the security property the role split exists for.
|
|
124
|
-
*
|
|
125
|
-
* Falls back to the runtime URL where no owner URL was published — the
|
|
126
|
-
* `roles: false` downgrade, where there is only one credential and it is the
|
|
127
|
-
* cluster master's.
|
|
128
|
-
*/
|
|
129
|
-
get owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>>;
|
|
130
|
-
private connect;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* A database you may read through, and derive nothing from.
|
|
134
|
-
*
|
|
135
|
-
* A reader is terminal in the graph, and this is that fact in the type system.
|
|
136
|
-
* `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`
|
|
137
|
-
* parent, and there is no reader of a reader — so `orders.reader().cache(…)`
|
|
138
|
-
* has always been illegal, but it type-checked and failed later at
|
|
139
|
-
* `assertDerivations`. That is a long way round to learn that a read-only
|
|
140
|
-
* endpoint cannot own a table something writes to.
|
|
141
|
-
*
|
|
142
|
-
* Omitting the three deriving methods rather than making them throw keeps the
|
|
143
|
-
* failure where it costs least: the editor, on the line that wrote it.
|
|
144
|
-
*
|
|
145
|
-
* The result is deliberately not assignable back to `KyselyDatabase` — a
|
|
146
|
-
* reader is not one, and anything that genuinely needs the writer should say
|
|
147
|
-
* so.
|
|
148
|
-
*/
|
|
149
|
-
type ReadOnlyDatabase<DB, TName extends string> = Omit<KyselyDatabase<DB, TName>, 'reader' | 'cache' | 'schema'>;
|
|
150
|
-
//#endregion
|
|
151
|
-
export { KyselyDatabase, KyselyDatabaseOptions, ReadOnlyDatabase };
|
|
152
|
-
//# sourceMappingURL=kysely.d.mts.map
|
|
1
|
+
import { i as closeDatabasePools, n as KyselyDatabaseOptions, r as ReadOnlyDatabase, t as KyselyDatabase } from "../kysely-CjuvdXEV.mjs";
|
|
2
|
+
export { KyselyDatabase, KyselyDatabaseOptions, ReadOnlyDatabase, closeDatabasePools };
|