@geekmidas/constructs 10.0.0-alpha.2 → 10.0.0-alpha.21
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 +46 -3
- package/dist/{Construct-Ct8nalEi.d.mts → Construct-DTqYvkPG.d.cts} +11 -13
- package/dist/Construct-DTqYvkPG.d.cts.map +1 -0
- package/dist/{Construct-BD5neF7w.mjs → Construct-Detz65RA.mjs} +31 -29
- package/dist/Construct-Detz65RA.mjs.map +1 -0
- package/dist/{Construct-C0ijr2qp.d.cts → Construct-pVadmURD.d.mts} +10 -12
- package/dist/Construct-pVadmURD.d.mts.map +1 -0
- package/dist/{Construct-CyS3RpTL.cjs → Construct-yG9Sw-5p.cjs} +51 -43
- package/dist/Construct-yG9Sw-5p.cjs.map +1 -0
- package/dist/{Cron-ByxdOfpE.d.mts → Cron-AYpQq725.d.mts} +13 -6
- package/dist/Cron-AYpQq725.d.mts.map +1 -0
- package/dist/{Cron-Wqh464aO.d.cts → Cron-Bdcg9OAL.d.cts} +12 -5
- package/dist/Cron-Bdcg9OAL.d.cts.map +1 -0
- package/dist/{CronBuilder-BL0AP6fs.d.mts → CronBuilder-DR21m9h2.d.cts} +7 -10
- package/dist/CronBuilder-DR21m9h2.d.cts.map +1 -0
- package/dist/{CronBuilder-BqpEzMPQ.d.cts → CronBuilder-DeBnPVIT.d.mts} +7 -10
- package/dist/CronBuilder-DeBnPVIT.d.mts.map +1 -0
- package/dist/{CronBuilder-BmABazzH.mjs → CronBuilder-vkjuo1UP.mjs} +23 -15
- package/dist/CronBuilder-vkjuo1UP.mjs.map +1 -0
- package/dist/{CronBuilder-CkXPJiGO.cjs → CronBuilder-zdTdaT-e.cjs} +33 -25
- package/dist/CronBuilder-zdTdaT-e.cjs.map +1 -0
- package/dist/{Endpoint-2Wg7T7Cq.d.mts → Endpoint-BxkRWQ8G.d.mts} +63 -84
- package/dist/Endpoint-BxkRWQ8G.d.mts.map +1 -0
- package/dist/{Endpoint-BiaaMEn_.cjs → Endpoint-CtiPUpRX.cjs} +145 -131
- package/dist/Endpoint-CtiPUpRX.cjs.map +1 -0
- package/dist/{Endpoint-VIOpSo0S.mjs → Endpoint-DCr5tlbJ.mjs} +117 -109
- package/dist/Endpoint-DCr5tlbJ.mjs.map +1 -0
- package/dist/{Endpoint-CH9Fn1AD.d.cts → Endpoint-DbYQJgb-.d.cts} +61 -82
- package/dist/Endpoint-DbYQJgb-.d.cts.map +1 -0
- package/dist/{EndpointFactory-DTTCkGEL.mjs → EndpointFactory-Bs8pu-yY.mjs} +20 -29
- package/dist/EndpointFactory-Bs8pu-yY.mjs.map +1 -0
- package/dist/{index-BxHDdy6a.d.mts → EndpointFactory-DE6nKtFZ.d.cts} +12 -92
- package/dist/EndpointFactory-DE6nKtFZ.d.cts.map +1 -0
- package/dist/{index-V2nksZIJ.d.cts → EndpointFactory-T06kTFHg.d.mts} +12 -92
- package/dist/EndpointFactory-T06kTFHg.d.mts.map +1 -0
- package/dist/{EndpointFactory-ChxLZllA.cjs → EndpointFactory-vE2C1NG1.cjs} +57 -66
- package/dist/EndpointFactory-vE2C1NG1.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-NKQQQbBY.mjs → HonoEndpointAdaptor-Be6UdK0r.mjs} +40 -47
- package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs.map → HonoEndpointAdaptor-Be6UdK0r.mjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs → HonoEndpointAdaptor-C9aivwKl.cjs} +48 -52
- package/dist/HonoEndpointAdaptor-C9aivwKl.cjs.map +1 -0
- package/dist/{Queue-D7ZuwBhy.d.cts → Queue-Bhzi2WQC.d.cts} +8 -9
- package/dist/Queue-Bhzi2WQC.d.cts.map +1 -0
- package/dist/{Queue-gVGfi2Yk.d.mts → Queue-BoUA-e83.d.mts} +9 -10
- package/dist/Queue-BoUA-e83.d.mts.map +1 -0
- package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-CIO3pwji.d.mts} +7 -8
- package/dist/Subscriber-CIO3pwji.d.mts.map +1 -0
- package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-DQCaiOXF.d.cts} +7 -8
- package/dist/Subscriber-DQCaiOXF.d.cts.map +1 -0
- package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-B4YRTBng.mjs} +16 -10
- package/dist/SubscriberBuilder-B4YRTBng.mjs.map +1 -0
- package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2bCOuPT.cjs} +28 -23
- package/dist/SubscriberBuilder-C2bCOuPT.cjs.map +1 -0
- package/dist/{SubscriberBuilder-Dptmo-1A.d.mts → SubscriberBuilder-ChX5v948.d.cts} +8 -11
- package/dist/SubscriberBuilder-ChX5v948.d.cts.map +1 -0
- package/dist/{SubscriberBuilder-waNhzjSM.d.cts → SubscriberBuilder-Dbiaskfi.d.mts} +8 -11
- package/dist/SubscriberBuilder-Dbiaskfi.d.mts.map +1 -0
- package/dist/{Topic-19QeHBIR.d.cts → Topic-D6blllEn.d.cts} +5 -7
- package/dist/Topic-D6blllEn.d.cts.map +1 -0
- package/dist/{Topic-DuFeqkBh.d.mts → Topic-DVvheJ_-.d.mts} +6 -8
- package/dist/Topic-DVvheJ_-.d.mts.map +1 -0
- package/dist/adaptors/aws.cjs +87 -106
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +14 -27
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +16 -29
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +60 -81
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +3 -10
- package/dist/adaptors/hono.d.cts +5 -13
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +7 -15
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +2 -10
- package/dist/adaptors/testing.cjs +271 -82
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +62 -33
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +63 -34
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +249 -63
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-BlO8MUkR.d.cts +123 -0
- package/dist/auth-BlO8MUkR.d.cts.map +1 -0
- package/dist/auth-CHWIdcQO.d.mts +123 -0
- package/dist/auth-CHWIdcQO.d.mts.map +1 -0
- package/dist/auth.cjs +41 -16
- 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 +32 -8
- package/dist/auth.mjs.map +1 -1
- package/dist/{cache-BrRz3fEB.d.mts → cache-AgQUMma6.d.mts} +3 -6
- package/dist/cache-AgQUMma6.d.mts.map +1 -0
- package/dist/{cache-BtZY_tHe.d.cts → cache-obq0fOIM.d.cts} +3 -6
- package/dist/cache-obq0fOIM.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/{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-g5GM5pwR.d.mts → construct-interface-Clz7_BwB.d.mts} +15 -6
- package/dist/construct-interface-Clz7_BwB.d.mts.map +1 -0
- package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-DIaTNKax.d.cts} +15 -6
- package/dist/construct-interface-DIaTNKax.d.cts.map +1 -0
- package/dist/construct-interface.cjs +87 -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 +81 -2
- package/dist/construct-interface.mjs.map +1 -0
- package/dist/credential.cjs +43 -9
- package/dist/credential.cjs.map +1 -1
- package/dist/credential.d.cts +5 -8
- package/dist/credential.d.cts.map +1 -1
- package/dist/credential.d.mts +5 -8
- package/dist/credential.d.mts.map +1 -1
- package/dist/credential.mjs +36 -2
- package/dist/credential.mjs.map +1 -1
- package/dist/crons/index.cjs +68 -10
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +32 -14
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +32 -14
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +66 -10
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +28 -14
- package/dist/database/kysely.cjs.map +1 -1
- package/dist/database/kysely.d.cts +2 -152
- package/dist/database/kysely.d.mts +2 -152
- package/dist/database/kysely.mjs +16 -4
- package/dist/database/kysely.mjs.map +1 -1
- 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/endpoints/index.cjs +7 -10
- package/dist/endpoints/index.d.cts +60 -7
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +60 -7
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +5 -10
- package/dist/file-server.cjs +42 -10
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +6 -10
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +6 -10
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +34 -2
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +2 -6
- package/dist/functions/index.d.cts +2 -4
- package/dist/functions/index.d.mts +2 -4
- package/dist/functions/index.mjs +2 -6
- package/dist/{functions-Bd3TPxid.cjs → functions-VnOTEp74.cjs} +309 -264
- package/dist/functions-VnOTEp74.cjs.map +1 -0
- package/dist/{functions-Cxbo-pEd.mjs → functions-faoJOUmr.mjs} +282 -234
- package/dist/functions-faoJOUmr.mjs.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-JSf9xNIJ.d.cts → index-DU3Twmwh.d.mts} +19 -24
- package/dist/index-DU3Twmwh.d.mts.map +1 -0
- package/dist/index-fnpjXiA-.d.mts +26 -0
- package/dist/index-fnpjXiA-.d.mts.map +1 -0
- package/dist/{index-CubPzHd9.d.mts → index-nBQT1tAh.d.cts} +19 -24
- package/dist/index-nBQT1tAh.d.cts.map +1 -0
- package/dist/index-tE_119SX.d.cts +26 -0
- package/dist/index-tE_119SX.d.cts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -3
- package/dist/kysely-CXi49zc2.d.cts +150 -0
- package/dist/kysely-CXi49zc2.d.cts.map +1 -0
- package/dist/kysely-D3-G5b0j.d.mts +150 -0
- package/dist/kysely-D3-G5b0j.d.mts.map +1 -0
- package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-BHtcqgz2.mjs} +22 -25
- package/dist/lazyAccessors-BHtcqgz2.mjs.map +1 -0
- package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-Dx9NLwJZ.cjs} +72 -76
- package/dist/lazyAccessors-Dx9NLwJZ.cjs.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 +25 -21
- package/dist/queue/index.cjs.map +1 -1
- package/dist/queue/index.d.cts +8 -15
- package/dist/queue/index.d.cts.map +1 -1
- package/dist/queue/index.d.mts +8 -15
- package/dist/queue/index.d.mts.map +1 -1
- package/dist/queue/index.mjs +15 -11
- package/dist/queue/index.mjs.map +1 -1
- package/dist/rest-api.cjs +88 -62
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +62 -60
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +62 -60
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +80 -54
- package/dist/rest-api.mjs.map +1 -1
- package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
- package/dist/site.cjs +33 -9
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +11 -22
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +11 -22
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +29 -5
- package/dist/site.mjs.map +1 -1
- package/dist/subscribers/index.cjs +2 -11
- package/dist/subscribers/index.d.cts +3 -14
- package/dist/subscribers/index.d.mts +3 -14
- package/dist/subscribers/index.mjs +2 -11
- 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 +18 -20
- package/dist/topic/index.cjs.map +1 -1
- package/dist/topic/index.d.cts +3 -32
- package/dist/topic/index.d.mts +3 -32
- package/dist/topic/index.mjs +8 -10
- package/dist/topic/index.mjs.map +1 -1
- 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 +109 -35
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +87 -42
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +87 -42
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +104 -30
- package/dist/worker.mjs.map +1 -1
- package/package.json +59 -55
- package/dist/Construct-BD5neF7w.mjs.map +0 -1
- package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
- package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
- package/dist/Construct-CyS3RpTL.cjs.map +0 -1
- package/dist/Cron-ByxdOfpE.d.mts.map +0 -1
- package/dist/Cron-Wqh464aO.d.cts.map +0 -1
- package/dist/CronBuilder-BL0AP6fs.d.mts.map +0 -1
- package/dist/CronBuilder-BmABazzH.mjs.map +0 -1
- package/dist/CronBuilder-BqpEzMPQ.d.cts.map +0 -1
- package/dist/CronBuilder-CkXPJiGO.cjs.map +0 -1
- package/dist/Endpoint-2Wg7T7Cq.d.mts.map +0 -1
- package/dist/Endpoint-BiaaMEn_.cjs.map +0 -1
- package/dist/Endpoint-CH9Fn1AD.d.cts.map +0 -1
- package/dist/Endpoint-VIOpSo0S.mjs.map +0 -1
- package/dist/EndpointFactory-ChxLZllA.cjs.map +0 -1
- package/dist/EndpointFactory-DTTCkGEL.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-NKQQQbBY.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.map +0 -1
- package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
- package/dist/Topic-19QeHBIR.d.cts.map +0 -1
- 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.d.cts.map +0 -1
- package/dist/database/kysely.d.mts.map +0 -1
- package/dist/functions-Bd3TPxid.cjs.map +0 -1
- package/dist/functions-Cxbo-pEd.mjs.map +0 -1
- package/dist/index-BxHDdy6a.d.mts.map +0 -1
- package/dist/index-CubPzHd9.d.mts.map +0 -1
- package/dist/index-JSf9xNIJ.d.cts.map +0 -1
- package/dist/index-V2nksZIJ.d.cts.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/subscribers/index.cjs.map +0 -1
- package/dist/subscribers/index.d.cts.map +0 -1
- package/dist/subscribers/index.d.mts.map +0 -1
- package/dist/subscribers/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.d.cts.map +0 -1
- package/dist/topic/index.d.mts.map +0 -1
- package/dist/types-BlAkSuGI.d.cts.map +0 -1
- package/dist/types-aKksMEWL.d.mts.map +0 -1
package/dist/credential.d.cts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as StandardSchemaV1 } from "./index-CeEtxDmK.cjs";
|
|
2
|
+
import { r as Consumable } from "./construct-interface-DIaTNKax.cjs";
|
|
2
3
|
import { Service } from "@geekmidas/services";
|
|
3
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
4
|
import { ConstructName, Declaration } from "@geekmidas/manifest";
|
|
5
|
-
|
|
6
5
|
//#region src/credential.d.ts
|
|
7
|
-
|
|
8
6
|
/** What a credential's schema yields. */
|
|
9
7
|
type Value<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
|
|
10
|
-
interface CredentialOptions<TSchema extends StandardSchemaV1> {
|
|
8
|
+
export interface CredentialOptions<TSchema extends StandardSchemaV1> {
|
|
11
9
|
/**
|
|
12
10
|
* What the credential must look like.
|
|
13
11
|
*
|
|
@@ -27,7 +25,7 @@ interface CredentialOptions<TSchema extends StandardSchemaV1> {
|
|
|
27
25
|
*/
|
|
28
26
|
refresh?: boolean;
|
|
29
27
|
}
|
|
30
|
-
declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
|
|
28
|
+
export declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
|
|
31
29
|
private readonly options;
|
|
32
30
|
readonly id: TName;
|
|
33
31
|
readonly service: Service<Uncapitalize<TName>, Value<TSchema>>;
|
|
@@ -50,12 +48,11 @@ declare class Credential<TName extends string = string, TSchema extends Standard
|
|
|
50
48
|
private resolve;
|
|
51
49
|
}
|
|
52
50
|
/** A credential was set, and is not what its schema says it should be. */
|
|
53
|
-
declare class MalformedCredential extends Error {
|
|
51
|
+
export declare class MalformedCredential extends Error {
|
|
54
52
|
readonly id: string;
|
|
55
53
|
readonly key: string;
|
|
56
54
|
readonly issues: unknown;
|
|
57
55
|
constructor(id: string, key: string, issues: unknown);
|
|
58
56
|
}
|
|
59
57
|
//#endregion
|
|
60
|
-
export { Credential, CredentialOptions, MalformedCredential };
|
|
61
58
|
//# sourceMappingURL=credential.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential.d.cts","names":[],"sources":["../src/credential.ts"],"
|
|
1
|
+
{"version":3,"file":"credential.d.cts","names":[],"sources":["../src/credential.ts"],"mappings":";;;;;;KA6CK,MAAM,gBAAgB,oBAC1B,iBAAiB,YAAY;iBAEb,kBAAkB,gBAAgB;;;;;;;;EAQlD,QAAQ;;;;;;;;;;EAUR;;qBAGY,WACZ,+BACA,gBAAgB,mBAAmB,6BACvB,WAAW,OAAO,MAAM;mBA6BlB;WApBT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,MAAM;;;;;mBAMpC;;;;;;;;UAST;EAER,YACC,IAAI,cAAc,QACD,SAAS,kBAAkB;EAc7C,WAAW;UAUH;UAQM;;;qBA0CF,4BAA4B;WAE9B;WACA;WACA;EAHV,YACU,YACA,aACA"}
|
package/dist/credential.d.mts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as StandardSchemaV1 } from "./index-CeEtxDmK.mjs";
|
|
2
|
+
import { r as Consumable } from "./construct-interface-Clz7_BwB.mjs";
|
|
2
3
|
import { ConstructName, Declaration } from "@geekmidas/manifest";
|
|
3
4
|
import { Service } from "@geekmidas/services";
|
|
4
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
|
-
|
|
6
5
|
//#region src/credential.d.ts
|
|
7
|
-
|
|
8
6
|
/** What a credential's schema yields. */
|
|
9
7
|
type Value<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
|
|
10
|
-
interface CredentialOptions<TSchema extends StandardSchemaV1> {
|
|
8
|
+
export interface CredentialOptions<TSchema extends StandardSchemaV1> {
|
|
11
9
|
/**
|
|
12
10
|
* What the credential must look like.
|
|
13
11
|
*
|
|
@@ -27,7 +25,7 @@ interface CredentialOptions<TSchema extends StandardSchemaV1> {
|
|
|
27
25
|
*/
|
|
28
26
|
refresh?: boolean;
|
|
29
27
|
}
|
|
30
|
-
declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
|
|
28
|
+
export declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
|
|
31
29
|
private readonly options;
|
|
32
30
|
readonly id: TName;
|
|
33
31
|
readonly service: Service<Uncapitalize<TName>, Value<TSchema>>;
|
|
@@ -50,12 +48,11 @@ declare class Credential<TName extends string = string, TSchema extends Standard
|
|
|
50
48
|
private resolve;
|
|
51
49
|
}
|
|
52
50
|
/** A credential was set, and is not what its schema says it should be. */
|
|
53
|
-
declare class MalformedCredential extends Error {
|
|
51
|
+
export declare class MalformedCredential extends Error {
|
|
54
52
|
readonly id: string;
|
|
55
53
|
readonly key: string;
|
|
56
54
|
readonly issues: unknown;
|
|
57
55
|
constructor(id: string, key: string, issues: unknown);
|
|
58
56
|
}
|
|
59
57
|
//#endregion
|
|
60
|
-
export { Credential, CredentialOptions, MalformedCredential };
|
|
61
58
|
//# sourceMappingURL=credential.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential.d.mts","names":[],"sources":["../src/credential.ts"],"
|
|
1
|
+
{"version":3,"file":"credential.d.mts","names":[],"sources":["../src/credential.ts"],"mappings":";;;;;;KA6CK,MAAM,gBAAgB,oBAC1B,iBAAiB,YAAY;iBAEb,kBAAkB,gBAAgB;;;;;;;;EAQlD,QAAQ;;;;;;;;;;EAUR;;qBAGY,WACZ,+BACA,gBAAgB,mBAAmB,6BACvB,WAAW,OAAO,MAAM;mBA6BlB;WApBT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,MAAM;;;;;mBAMpC;;;;;;;;UAST;EAER,YACC,IAAI,cAAc,QACD,SAAS,kBAAkB;EAc7C,WAAW;UAUH;UAQM;;;qBA0CF,4BAA4B;WAE9B;WACA;WACA;EAHV,YACU,YACA,aACA"}
|
package/dist/credential.mjs
CHANGED
|
@@ -1,8 +1,39 @@
|
|
|
1
1
|
import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
2
2
|
import { parseSchema } from "@geekmidas/schema/parser";
|
|
3
|
-
|
|
4
3
|
//#region src/credential.ts
|
|
4
|
+
/**
|
|
5
|
+
* `Credential` — a third-party credential with a shape.
|
|
6
|
+
*
|
|
7
|
+
* The answer to the design's first open question, "where does `Secret` sit?".
|
|
8
|
+
* It sits beside a secret rather than replacing it, because the two differ by
|
|
9
|
+
* *lifecycle* and that is the only difference worth two kinds for: a secret is
|
|
10
|
+
* generated and rotated by the platform and is one opaque string, while a
|
|
11
|
+
* credential is issued by someone else, arrives with several fields, and is
|
|
12
|
+
* worth validating on the way in.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* export const stripe = new Credential('Stripe', {
|
|
16
|
+
* schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // in a handler — no await, already parsed and validated
|
|
20
|
+
* services.stripe.secretKey
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* **Nothing about it is async at the call site**, which is the part that looks
|
|
24
|
+
* like it should be hard and is not. `Service.register()` may return a promise
|
|
25
|
+
* and `ServiceDiscovery` awaits every one before a handler runs, so fetching a
|
|
26
|
+
* value and validating it — including when a StandardSchema's `~standard.validate`
|
|
27
|
+
* returns a promise of its own — both happen inside that existing seam.
|
|
28
|
+
*
|
|
29
|
+
* **One key holding JSON, not one key per field.** That is the shape a secret
|
|
30
|
+
* manager stores, and it is the only shape that works with an arbitrary
|
|
31
|
+
* StandardSchema: the spec has no introspection API, so enumerating a schema's
|
|
32
|
+
* fields means reaching into one library's internals (`.shape`) and being wrong
|
|
33
|
+
* for every other.
|
|
34
|
+
*/
|
|
5
35
|
var Credential = class {
|
|
36
|
+
options;
|
|
6
37
|
id;
|
|
7
38
|
service;
|
|
8
39
|
/**
|
|
@@ -72,6 +103,9 @@ function decode(raw) {
|
|
|
72
103
|
const JSON_SCHEME = "json:";
|
|
73
104
|
/** A credential was set, and is not what its schema says it should be. */
|
|
74
105
|
var MalformedCredential = class extends Error {
|
|
106
|
+
id;
|
|
107
|
+
key;
|
|
108
|
+
issues;
|
|
75
109
|
constructor(id, key, issues) {
|
|
76
110
|
super(`${key} is not a valid ${id} credential. It is validated where it is read, so this is the value that is set rather than the code that uses it: ${describe(issues)}`);
|
|
77
111
|
this.id = id;
|
|
@@ -88,7 +122,7 @@ function describe(issues) {
|
|
|
88
122
|
return path ? `${path}: ${issue.message}` : issue.message;
|
|
89
123
|
}).join("; ");
|
|
90
124
|
}
|
|
91
|
-
|
|
92
125
|
//#endregion
|
|
93
126
|
export { Credential, MalformedCredential };
|
|
127
|
+
|
|
94
128
|
//# sourceMappingURL=credential.mjs.map
|
package/dist/credential.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential.mjs","names":[
|
|
1
|
+
{"version":3,"file":"credential.mjs","names":[],"sources":["../src/credential.ts"],"sourcesContent":["/**\n * `Credential` — a third-party credential with a shape.\n *\n * The answer to the design's first open question, \"where does `Secret` sit?\".\n * It sits beside a secret rather than replacing it, because the two differ by\n * *lifecycle* and that is the only difference worth two kinds for: a secret is\n * generated and rotated by the platform and is one opaque string, while a\n * credential is issued by someone else, arrives with several fields, and is\n * worth validating on the way in.\n *\n * ```ts\n * export const stripe = new Credential('Stripe', {\n * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),\n * });\n *\n * // in a handler — no await, already parsed and validated\n * services.stripe.secretKey\n * ```\n *\n * **Nothing about it is async at the call site**, which is the part that looks\n * like it should be hard and is not. `Service.register()` may return a promise\n * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a\n * value and validating it — including when a StandardSchema's `~standard.validate`\n * returns a promise of its own — both happen inside that existing seam.\n *\n * **One key holding JSON, not one key per field.** That is the shape a secret\n * manager stores, and it is the only shape that works with an arbitrary\n * StandardSchema: the spec has no introspection API, so enumerating a schema's\n * fields means reaching into one library's internals (`.shape`) and being wrong\n * for every other.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport { parseSchema } from '@geekmidas/schema/parser';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\n\n/** What a credential's schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\nexport interface CredentialOptions<TSchema extends StandardSchemaV1> {\n\t/**\n\t * What the credential must look like.\n\t *\n\t * Validated at registration, so a malformed or half-set credential fails\n\t * when the process starts rather than on the first request that needs the\n\t * one field somebody forgot.\n\t */\n\tschema: TSchema;\n\t/**\n\t * Re-resolve on every registration instead of once per process.\n\t *\n\t * Off by default: a credential is resolved once and reused, because the\n\t * alternative is a fetch on every request. The cost of that default is that\n\t * a rotated credential needs a restart, which is the right trade for a value\n\t * that changes a few times a year — and this is the escape hatch for when it\n\t * is not.\n\t */\n\trefresh?: boolean;\n}\n\nexport class Credential<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n> implements Consumable<TName, Value<TSchema>>\n{\n\t// `Consumable` rather than `Construct`, and not by preference: `Construct`\n\t// types its service as `[TClient] extends [never] ? never : Service<…>` so\n\t// that a `Cron` cannot be depended on, and TypeScript cannot evaluate that\n\t// conditional while `TClient` is still a type parameter. Every construct\n\t// with a concrete client satisfies `Construct`; the first one whose client\n\t// is generic cannot. `Consumable` is the face `.dependsOn()` requires and\n\t// carries no conditional, so it is the honest annotation here.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Value<TSchema>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { credential: string };\n\n\t/**\n\t * The resolved value, held as the *promise* rather than the value.\n\t *\n\t * Caching the promise is what makes two concurrent registrations share one\n\t * resolution: caching the value would let both start before either finished,\n\t * which is a duplicated fetch every cold start rather than never.\n\t */\n\tprivate resolved?: Promise<Value<TSchema>>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CredentialOptions<TSchema>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = { credential: provideKey(canonical, 'credential') };\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\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'credential',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.credential],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\tif (this.options.refresh) return this.resolve(options);\n\n\t\tthis.resolved ??= this.resolve(options);\n\n\t\treturn this.resolved;\n\t}\n\n\tprivate async resolve(\n\t\toptions: ServiceRegisterOptions,\n\t): Promise<Value<TSchema>> {\n\t\tconst { raw } = options.envParser\n\t\t\t.create((get) => ({ raw: get(this.keys.credential).string() }))\n\t\t\t.parse();\n\n\t\ttry {\n\t\t\treturn await parseSchema(this.options.schema, decode(raw));\n\t\t} catch (issues) {\n\t\t\tthrow new MalformedCredential(this.id, this.keys.credential, issues);\n\t\t}\n\t}\n}\n\n/**\n * The raw environment value as the thing the schema should see.\n *\n * JSON when it is JSON, and the string itself when it is not — a credential\n * with a single opaque field is ordinary, and requiring `\"…\"` around it would\n * be ceremony that every operator setting one by hand would get wrong once.\n */\nfunction decode(raw: string): unknown {\n\tconst value = raw.startsWith(JSON_SCHEME)\n\t\t? raw.slice(JSON_SCHEME.length)\n\t\t: raw;\n\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n\n/**\n * The explicit form, for the case a credential legitimately *is* a JSON string\n * and must not be parsed into an object. Rare, and cheaper to support than to\n * explain.\n */\nconst JSON_SCHEME = 'json:';\n\n/** A credential was set, and is not what its schema says it should be. */\nexport class MalformedCredential extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly key: string,\n\t\treadonly issues: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${key} is not a valid ${id} credential. ` +\n\t\t\t\t`It is validated where it is read, so this is the value that is set ` +\n\t\t\t\t`rather than the code that uses it: ${describe(issues)}`,\n\t\t);\n\t\tthis.name = 'MalformedCredential';\n\t}\n}\n\n/** StandardSchema issues as one line. */\nfunction describe(issues: unknown): string {\n\tif (!Array.isArray(issues)) return String(issues);\n\n\treturn issues\n\t\t.map((issue: StandardSchemaV1.Issue) => {\n\t\t\tconst path = issue.path\n\t\t\t\t?.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\n\t\t\treturn path ? `${path}: ${issue.message}` : issue.message;\n\t\t})\n\t\t.join('; ');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,IAAa,aAAb,MAIA;CA4BmB;CApBlB;CACA;;;;;CAMA;;;;;;;;CASA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO,EAAE,YAAY,WAAW,WAAW,YAAY,EAAE;EAG9D,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,oBAAoB,KAAK,QAAQ,eAAe;EAC5D;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,UAAU;EAChC,CACD;CACD;CAEA,QAAgB,SAA0D;EACzE,IAAI,KAAK,QAAQ,SAAS,OAAO,KAAK,QAAQ,OAAO;EAErD,KAAK,aAAa,KAAK,QAAQ,OAAO;EAEtC,OAAO,KAAK;CACb;CAEA,MAAc,QACb,SAC0B;EAC1B,MAAM,EAAE,QAAQ,QAAQ,UACtB,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC9D,MAAM;EAER,IAAI;GACH,OAAO,MAAM,YAAY,KAAK,QAAQ,QAAQ,OAAO,GAAG,CAAC;EAC1D,SAAS,QAAQ;GAChB,MAAM,IAAI,oBAAoB,KAAK,IAAI,KAAK,KAAK,YAAY,MAAM;EACpE;CACD;AACD;;;;;;;;AASA,SAAS,OAAO,KAAsB;CACrC,MAAM,QAAQ,IAAI,WAAW,WAAW,IACrC,IAAI,MAAM,YAAY,MAAM,IAC5B;CAEH,IAAI;EACH,OAAO,KAAK,MAAM,KAAK;CACxB,QAAQ;EACP,OAAO;CACR;AACD;;;;;;AAOA,MAAM,cAAc;;AAGpB,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CACA;CACA;CAHV,YACC,IACA,KACA,QACC;EACD,MACC,GAAG,IAAI,kBAAkB,GAAG,qHAEW,SAAS,MAAM,GACvD;EARS,KAAA,KAAA;EACA,KAAA,MAAA;EACA,KAAA,SAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,SAAS,QAAyB;CAC1C,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO,OAAO,MAAM;CAEhD,OAAO,OACL,KAAK,UAAkC;EACvC,MAAM,OAAO,MAAM,MAChB,KAAK,YACN,OAAO,YAAY,WAAW,OAAO,QAAQ,GAAG,IAAI,OAAO,OAAO,CACnE,CAAC,CACA,KAAK,GAAG;EAEV,OAAO,OAAO,GAAG,KAAK,IAAI,MAAM,YAAY,MAAM;CACnD,CAAC,CAAC,CACD,KAAK,IAAI;AACZ"}
|
package/dist/crons/index.cjs
CHANGED
|
@@ -1,14 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
require(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_CronBuilder = require("../CronBuilder-zdTdaT-e.cjs");
|
|
3
|
+
//#region src/crons/schedule.ts
|
|
4
|
+
/**
|
|
5
|
+
* A schedule a cron runner can take, as standard five-field cron.
|
|
6
|
+
*
|
|
7
|
+
* `ScheduleExpression` has two spellings. `cron(m h dom mon dow)` is already
|
|
8
|
+
* five-field cron and unwraps; `rate(n unit)` is an interval, and an interval
|
|
9
|
+
* is not a schedule — it says how often, where cron says when.
|
|
10
|
+
*
|
|
11
|
+
* Most intervals still have an exact cron equivalent, because they divide their
|
|
12
|
+
* unit evenly: `rate(5 minutes)` is every fifth minute of every hour, and that
|
|
13
|
+
* is `*/5 * * * *` precisely. `rate(7 hours)` has none. There is no cron field
|
|
14
|
+
* that means "every seven hours" — `*/7` in the hour field fires at 0, 7, 14
|
|
15
|
+
* and 21 and then starts over at midnight, so the gap between the last firing
|
|
16
|
+
* of one day and the first of the next is three hours rather than seven.
|
|
17
|
+
*
|
|
18
|
+
* Those are refused rather than rounded. A job that runs at the wrong hour is
|
|
19
|
+
* far harder to notice than one that refused to build, and a schedule quietly
|
|
20
|
+
* adjusted by the framework is a bug nobody goes looking for.
|
|
21
|
+
*/
|
|
22
|
+
var UnrepresentableSchedule = class extends Error {
|
|
23
|
+
schedule;
|
|
24
|
+
constructor(schedule, reason) {
|
|
25
|
+
super(`\`${schedule}\` has no exact cron equivalent: ${reason}.\n\nCron says *when*, not *how often*, so an interval is only exact when it divides its unit evenly.
|
|
26
|
+
Write the schedule you mean instead — \`cron(0 */6 * * *)\` for every sixth hour, say — or pick an interval that divides: minutes into 60, hours into 24.`);
|
|
27
|
+
this.schedule = schedule;
|
|
28
|
+
this.name = "UnrepresentableSchedule";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
/** Units `rate(…)` accepts, singular or plural. */
|
|
32
|
+
const UNITS = [
|
|
33
|
+
"minute",
|
|
34
|
+
"hour",
|
|
35
|
+
"day"
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* Standard five-field cron for a schedule expression.
|
|
39
|
+
*
|
|
40
|
+
* @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.
|
|
41
|
+
*/
|
|
42
|
+
function toCronExpression(schedule) {
|
|
43
|
+
const cron = /^cron\((.+)\)$/.exec(schedule);
|
|
44
|
+
if (cron?.[1]) return cron[1].trim();
|
|
45
|
+
const rate = /^rate\(\s*(\d+)\s+(\w+?)s?\s*\)$/.exec(schedule);
|
|
46
|
+
if (!rate) throw new UnrepresentableSchedule(schedule, "it is neither `cron(…)` nor `rate(n unit)`");
|
|
47
|
+
const every = Number(rate[1]);
|
|
48
|
+
const unit = rate[2];
|
|
49
|
+
/* c8 ignore next */ if (!unit) throw new UnrepresentableSchedule(schedule, "no unit");
|
|
50
|
+
if (!UNITS.includes(unit)) throw new UnrepresentableSchedule(schedule, `\`${unit}\` is not one of ${UNITS.join(", ")}`);
|
|
51
|
+
if (every < 1) throw new UnrepresentableSchedule(schedule, "an interval must be at least 1");
|
|
52
|
+
switch (unit) {
|
|
53
|
+
case "minute":
|
|
54
|
+
if (every === 1) return "* * * * *";
|
|
55
|
+
if (60 % every !== 0) throw new UnrepresentableSchedule(schedule, `${every} does not divide 60, so the interval would reset at the top of each hour`);
|
|
56
|
+
return `*/${every} * * * *`;
|
|
57
|
+
case "hour":
|
|
58
|
+
if (every === 1) return "0 * * * *";
|
|
59
|
+
if (24 % every !== 0) throw new UnrepresentableSchedule(schedule, `${every} does not divide 24, so the interval would reset at midnight`);
|
|
60
|
+
return `0 */${every} * * *`;
|
|
61
|
+
case "day":
|
|
62
|
+
if (every === 1) return "0 0 * * *";
|
|
63
|
+
throw new UnrepresentableSchedule(schedule, "day-of-month restarts every month, so no multi-day interval is even");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
10
66
|
//#endregion
|
|
11
67
|
exports.Cron = require_CronBuilder.Cron;
|
|
12
68
|
exports.CronBuilder = require_CronBuilder.CronBuilder;
|
|
13
|
-
exports.
|
|
69
|
+
exports.UnrepresentableSchedule = UnrepresentableSchedule;
|
|
70
|
+
exports.toCronExpression = toCronExpression;
|
|
71
|
+
|
|
14
72
|
//# sourceMappingURL=index.cjs.map
|
package/dist/crons/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"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;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/crons/index.d.cts
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { i as ScheduleExpression, n as CronExpression, r as RateExpression, t as Cron } from "../Cron-Bdcg9OAL.cjs";
|
|
2
|
+
import { t as CronBuilder } from "../CronBuilder-DR21m9h2.cjs";
|
|
3
|
+
//#region src/crons/schedule.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A schedule a cron runner can take, as standard five-field cron.
|
|
6
|
+
*
|
|
7
|
+
* `ScheduleExpression` has two spellings. `cron(m h dom mon dow)` is already
|
|
8
|
+
* five-field cron and unwraps; `rate(n unit)` is an interval, and an interval
|
|
9
|
+
* is not a schedule — it says how often, where cron says when.
|
|
10
|
+
*
|
|
11
|
+
* Most intervals still have an exact cron equivalent, because they divide their
|
|
12
|
+
* unit evenly: `rate(5 minutes)` is every fifth minute of every hour, and that
|
|
13
|
+
* is `*/5 * * * *` precisely. `rate(7 hours)` has none. There is no cron field
|
|
14
|
+
* that means "every seven hours" — `*/7` in the hour field fires at 0, 7, 14
|
|
15
|
+
* and 21 and then starts over at midnight, so the gap between the last firing
|
|
16
|
+
* of one day and the first of the next is three hours rather than seven.
|
|
17
|
+
*
|
|
18
|
+
* Those are refused rather than rounded. A job that runs at the wrong hour is
|
|
19
|
+
* far harder to notice than one that refused to build, and a schedule quietly
|
|
20
|
+
* adjusted by the framework is a bug nobody goes looking for.
|
|
21
|
+
*/
|
|
22
|
+
export declare class UnrepresentableSchedule extends Error {
|
|
23
|
+
readonly schedule: string;
|
|
24
|
+
constructor(schedule: string, reason: string);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Standard five-field cron for a schedule expression.
|
|
28
|
+
*
|
|
29
|
+
* @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.
|
|
30
|
+
*/
|
|
31
|
+
export declare function toCronExpression(schedule: ScheduleExpression): string;
|
|
14
32
|
//#endregion
|
|
15
|
-
export { Cron, CronBuilder, CronExpression, RateExpression, ScheduleExpression
|
|
33
|
+
export { Cron, CronBuilder, type CronExpression, type RateExpression, type ScheduleExpression };
|
|
16
34
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/crons/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/crons/schedule.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAoBa,gCAAgC;WAElC;EADV,YACU,kBACT;;;;;;;wBAuBc,iBAAiB,UAAU"}
|
package/dist/crons/index.d.mts
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { i as ScheduleExpression, n as CronExpression, r as RateExpression, t as Cron } from "../Cron-AYpQq725.mjs";
|
|
2
|
+
import { t as CronBuilder } from "../CronBuilder-DeBnPVIT.mjs";
|
|
3
|
+
//#region src/crons/schedule.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A schedule a cron runner can take, as standard five-field cron.
|
|
6
|
+
*
|
|
7
|
+
* `ScheduleExpression` has two spellings. `cron(m h dom mon dow)` is already
|
|
8
|
+
* five-field cron and unwraps; `rate(n unit)` is an interval, and an interval
|
|
9
|
+
* is not a schedule — it says how often, where cron says when.
|
|
10
|
+
*
|
|
11
|
+
* Most intervals still have an exact cron equivalent, because they divide their
|
|
12
|
+
* unit evenly: `rate(5 minutes)` is every fifth minute of every hour, and that
|
|
13
|
+
* is `*/5 * * * *` precisely. `rate(7 hours)` has none. There is no cron field
|
|
14
|
+
* that means "every seven hours" — `*/7` in the hour field fires at 0, 7, 14
|
|
15
|
+
* and 21 and then starts over at midnight, so the gap between the last firing
|
|
16
|
+
* of one day and the first of the next is three hours rather than seven.
|
|
17
|
+
*
|
|
18
|
+
* Those are refused rather than rounded. A job that runs at the wrong hour is
|
|
19
|
+
* far harder to notice than one that refused to build, and a schedule quietly
|
|
20
|
+
* adjusted by the framework is a bug nobody goes looking for.
|
|
21
|
+
*/
|
|
22
|
+
export declare class UnrepresentableSchedule extends Error {
|
|
23
|
+
readonly schedule: string;
|
|
24
|
+
constructor(schedule: string, reason: string);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Standard five-field cron for a schedule expression.
|
|
28
|
+
*
|
|
29
|
+
* @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.
|
|
30
|
+
*/
|
|
31
|
+
export declare function toCronExpression(schedule: ScheduleExpression): string;
|
|
14
32
|
//#endregion
|
|
15
|
-
export { Cron, CronBuilder, CronExpression, RateExpression, ScheduleExpression
|
|
33
|
+
export { Cron, CronBuilder, type CronExpression, type RateExpression, type ScheduleExpression };
|
|
16
34
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/crons/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/crons/schedule.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAoBa,gCAAgC;WAElC;EADV,YACU,kBACT;;;;;;;wBAuBc,iBAAiB,UAAU"}
|
package/dist/crons/index.mjs
CHANGED
|
@@ -1,12 +1,68 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { n as Cron, t as CronBuilder } from "../CronBuilder-vkjuo1UP.mjs";
|
|
2
|
+
//#region src/crons/schedule.ts
|
|
3
|
+
/**
|
|
4
|
+
* A schedule a cron runner can take, as standard five-field cron.
|
|
5
|
+
*
|
|
6
|
+
* `ScheduleExpression` has two spellings. `cron(m h dom mon dow)` is already
|
|
7
|
+
* five-field cron and unwraps; `rate(n unit)` is an interval, and an interval
|
|
8
|
+
* is not a schedule — it says how often, where cron says when.
|
|
9
|
+
*
|
|
10
|
+
* Most intervals still have an exact cron equivalent, because they divide their
|
|
11
|
+
* unit evenly: `rate(5 minutes)` is every fifth minute of every hour, and that
|
|
12
|
+
* is `*/5 * * * *` precisely. `rate(7 hours)` has none. There is no cron field
|
|
13
|
+
* that means "every seven hours" — `*/7` in the hour field fires at 0, 7, 14
|
|
14
|
+
* and 21 and then starts over at midnight, so the gap between the last firing
|
|
15
|
+
* of one day and the first of the next is three hours rather than seven.
|
|
16
|
+
*
|
|
17
|
+
* Those are refused rather than rounded. A job that runs at the wrong hour is
|
|
18
|
+
* far harder to notice than one that refused to build, and a schedule quietly
|
|
19
|
+
* adjusted by the framework is a bug nobody goes looking for.
|
|
20
|
+
*/
|
|
21
|
+
var UnrepresentableSchedule = class extends Error {
|
|
22
|
+
schedule;
|
|
23
|
+
constructor(schedule, reason) {
|
|
24
|
+
super(`\`${schedule}\` has no exact cron equivalent: ${reason}.\n\nCron says *when*, not *how often*, so an interval is only exact when it divides its unit evenly.
|
|
25
|
+
Write the schedule you mean instead — \`cron(0 */6 * * *)\` for every sixth hour, say — or pick an interval that divides: minutes into 60, hours into 24.`);
|
|
26
|
+
this.schedule = schedule;
|
|
27
|
+
this.name = "UnrepresentableSchedule";
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/** Units `rate(…)` accepts, singular or plural. */
|
|
31
|
+
const UNITS = [
|
|
32
|
+
"minute",
|
|
33
|
+
"hour",
|
|
34
|
+
"day"
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Standard five-field cron for a schedule expression.
|
|
38
|
+
*
|
|
39
|
+
* @throws {UnrepresentableSchedule} when a `rate(…)` has no exact equivalent.
|
|
40
|
+
*/
|
|
41
|
+
function toCronExpression(schedule) {
|
|
42
|
+
const cron = /^cron\((.+)\)$/.exec(schedule);
|
|
43
|
+
if (cron?.[1]) return cron[1].trim();
|
|
44
|
+
const rate = /^rate\(\s*(\d+)\s+(\w+?)s?\s*\)$/.exec(schedule);
|
|
45
|
+
if (!rate) throw new UnrepresentableSchedule(schedule, "it is neither `cron(…)` nor `rate(n unit)`");
|
|
46
|
+
const every = Number(rate[1]);
|
|
47
|
+
const unit = rate[2];
|
|
48
|
+
/* c8 ignore next */ if (!unit) throw new UnrepresentableSchedule(schedule, "no unit");
|
|
49
|
+
if (!UNITS.includes(unit)) throw new UnrepresentableSchedule(schedule, `\`${unit}\` is not one of ${UNITS.join(", ")}`);
|
|
50
|
+
if (every < 1) throw new UnrepresentableSchedule(schedule, "an interval must be at least 1");
|
|
51
|
+
switch (unit) {
|
|
52
|
+
case "minute":
|
|
53
|
+
if (every === 1) return "* * * * *";
|
|
54
|
+
if (60 % every !== 0) throw new UnrepresentableSchedule(schedule, `${every} does not divide 60, so the interval would reset at the top of each hour`);
|
|
55
|
+
return `*/${every} * * * *`;
|
|
56
|
+
case "hour":
|
|
57
|
+
if (every === 1) return "0 * * * *";
|
|
58
|
+
if (24 % every !== 0) throw new UnrepresentableSchedule(schedule, `${every} does not divide 24, so the interval would reset at midnight`);
|
|
59
|
+
return `0 */${every} * * *`;
|
|
60
|
+
case "day":
|
|
61
|
+
if (every === 1) return "0 0 * * *";
|
|
62
|
+
throw new UnrepresentableSchedule(schedule, "day-of-month restarts every month, so no multi-day interval is even");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
10
65
|
//#endregion
|
|
11
|
-
export { Cron, CronBuilder,
|
|
66
|
+
export { Cron, CronBuilder, UnrepresentableSchedule, toCronExpression };
|
|
67
|
+
|
|
12
68
|
//# sourceMappingURL=index.mjs.map
|
package/dist/crons/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/crons/
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"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;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,10 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime-y5ARvAq5.cjs");
|
|
3
|
+
const require_cache = require("../cache.cjs");
|
|
4
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
5
|
+
let kysely = require("kysely");
|
|
6
|
+
let pg = require("pg");
|
|
7
|
+
pg = require_rolldown_runtime.__toESM(pg, 1);
|
|
7
8
|
//#region src/database/kysely.ts
|
|
9
|
+
/**
|
|
10
|
+
* `KyselyDatabase` — a declared Postgres database, typed by its schema.
|
|
11
|
+
*
|
|
12
|
+
* It declares a logical database, a schema, and the roles that reach it, and
|
|
13
|
+
* hands back a Kysely client built from the one URL the adapter supplied. It
|
|
14
|
+
* names no cloud: `--target=aws` fills that URL from RDS, local dev from the
|
|
15
|
+
* Postgres container.
|
|
16
|
+
*
|
|
17
|
+
* Transactions and RLS context are the execution wrapper's job — it opens the
|
|
18
|
+
* transaction and puts it in `ctx.db`. This construct does not resolve
|
|
19
|
+
* connections per request.
|
|
20
|
+
*/
|
|
8
21
|
/** The schema a database uses when it does not say otherwise. */
|
|
9
22
|
const DEFAULT_SCHEMA = "app";
|
|
10
23
|
/**
|
|
@@ -15,6 +28,7 @@ const DEFAULT_SCHEMA = "app";
|
|
|
15
28
|
* through `.database()`, which infers from the service.
|
|
16
29
|
*/
|
|
17
30
|
var KyselyDatabase = class KyselyDatabase {
|
|
31
|
+
options;
|
|
18
32
|
id;
|
|
19
33
|
service;
|
|
20
34
|
/**
|
|
@@ -28,18 +42,18 @@ var KyselyDatabase = class KyselyDatabase {
|
|
|
28
42
|
derivedFrom;
|
|
29
43
|
constructor(id, options = {}, derivedFrom) {
|
|
30
44
|
this.options = options;
|
|
31
|
-
const canonical = (0,
|
|
45
|
+
const canonical = (0, _geekmidas_manifest.canonicalId)(id);
|
|
32
46
|
this.id = canonical;
|
|
33
47
|
this.config = {
|
|
34
|
-
url: (0,
|
|
35
|
-
ownerUrl: (0,
|
|
48
|
+
url: (0, _geekmidas_manifest.provideKey)(canonical, "url"),
|
|
49
|
+
ownerUrl: (0, _geekmidas_manifest.provideKey)(canonical, "ownerUrl")
|
|
36
50
|
};
|
|
37
51
|
this.schemaName = options.schema ?? DEFAULT_SCHEMA;
|
|
38
52
|
this.roles = options.roles ?? true;
|
|
39
|
-
this.version = options.version ??
|
|
53
|
+
this.version = options.version ?? _geekmidas_manifest.DEFAULT_POSTGRES_VERSION;
|
|
40
54
|
this.derivedFrom = derivedFrom;
|
|
41
55
|
this.service = {
|
|
42
|
-
serviceName: (0,
|
|
56
|
+
serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
|
|
43
57
|
register: (registerOptions) => this.connect(registerOptions)
|
|
44
58
|
};
|
|
45
59
|
}
|
|
@@ -139,7 +153,7 @@ var KyselyDatabase = class KyselyDatabase {
|
|
|
139
153
|
*/
|
|
140
154
|
get owner() {
|
|
141
155
|
return {
|
|
142
|
-
serviceName: `${(0,
|
|
156
|
+
serviceName: `${(0, _geekmidas_manifest.serviceKey)(this.id)}Owner`,
|
|
143
157
|
register: (options) => this.connect(options, { owner: true })
|
|
144
158
|
};
|
|
145
159
|
}
|
|
@@ -148,7 +162,7 @@ var KyselyDatabase = class KyselyDatabase {
|
|
|
148
162
|
url: get(this.config.url).string(),
|
|
149
163
|
ownerUrl: get(this.config.ownerUrl).string().optional()
|
|
150
164
|
})).parse();
|
|
151
|
-
const { schema: _schema, roles: _roles
|
|
165
|
+
const { schema: _schema, roles: _roles, ...kysely$1 } = this.options;
|
|
152
166
|
return new kysely.Kysely({
|
|
153
167
|
...kysely$1,
|
|
154
168
|
dialect: new kysely.PostgresDialect({ pool: pool(as.owner ? ownerUrl ?? url : url) })
|
|
@@ -175,7 +189,7 @@ function pool(url) {
|
|
|
175
189
|
options: `-c search_path=${searchPath}`
|
|
176
190
|
});
|
|
177
191
|
}
|
|
178
|
-
|
|
179
192
|
//#endregion
|
|
180
193
|
exports.KyselyDatabase = KyselyDatabase;
|
|
194
|
+
|
|
181
195
|
//# sourceMappingURL=kysely.cjs.map
|