@geekmidas/constructs 10.0.0-alpha.3 → 10.0.0-alpha.30
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 +52 -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-B_iuyNxr.d.mts} +17 -6
- package/dist/Cron-B_iuyNxr.d.mts.map +1 -0
- package/dist/{Cron-Wqh464aO.d.cts → Cron-CA2oa2nC.d.cts} +16 -5
- package/dist/Cron-CA2oa2nC.d.cts.map +1 -0
- package/dist/{CronBuilder-BL0AP6fs.d.mts → CronBuilder-BIKCLWu7.d.mts} +7 -10
- package/dist/CronBuilder-BIKCLWu7.d.mts.map +1 -0
- package/dist/{CronBuilder-BmABazzH.mjs → CronBuilder-BRkzUOAs.mjs} +35 -17
- package/dist/CronBuilder-BRkzUOAs.mjs.map +1 -0
- package/dist/{CronBuilder-BqpEzMPQ.d.cts → CronBuilder-B_KqaodP.d.cts} +6 -9
- package/dist/CronBuilder-B_KqaodP.d.cts.map +1 -0
- package/dist/{CronBuilder-CkXPJiGO.cjs → CronBuilder-BbnT7tqo.cjs} +45 -27
- package/dist/CronBuilder-BbnT7tqo.cjs.map +1 -0
- package/dist/{Endpoint-2Wg7T7Cq.d.mts → Endpoint-BojvdQoh.d.mts} +63 -84
- package/dist/Endpoint-BojvdQoh.d.mts.map +1 -0
- package/dist/{Endpoint-VIOpSo0S.mjs → Endpoint-DO332Dnm.mjs} +117 -109
- package/dist/Endpoint-DO332Dnm.mjs.map +1 -0
- package/dist/{Endpoint-BiaaMEn_.cjs → Endpoint-QKuFg5gs.cjs} +145 -131
- package/dist/Endpoint-QKuFg5gs.cjs.map +1 -0
- package/dist/{Endpoint-CH9Fn1AD.d.cts → Endpoint-xNGuv2Fq.d.cts} +61 -82
- package/dist/Endpoint-xNGuv2Fq.d.cts.map +1 -0
- package/dist/{EndpointFactory-DTTCkGEL.mjs → EndpointFactory-B9HAjDAP.mjs} +26 -32
- package/dist/EndpointFactory-B9HAjDAP.mjs.map +1 -0
- package/dist/{EndpointFactory-ChxLZllA.cjs → EndpointFactory-BmO0WnXE.cjs} +63 -69
- package/dist/EndpointFactory-BmO0WnXE.cjs.map +1 -0
- package/dist/{index-BxHDdy6a.d.mts → EndpointFactory-CaYTrUOO.d.mts} +12 -92
- package/dist/EndpointFactory-CaYTrUOO.d.mts.map +1 -0
- package/dist/{index-V2nksZIJ.d.cts → EndpointFactory-DyT1yOJL.d.cts} +10 -90
- package/dist/EndpointFactory-DyT1yOJL.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-NKQQQbBY.mjs → HonoEndpointAdaptor-CiqAZ5Mt.mjs} +40 -47
- package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs.map → HonoEndpointAdaptor-CiqAZ5Mt.mjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs → HonoEndpointAdaptor-DoEQdC3r.cjs} +48 -52
- package/dist/HonoEndpointAdaptor-DoEQdC3r.cjs.map +1 -0
- package/dist/Queue-B7yRXQmL.cjs +124 -0
- package/dist/Queue-B7yRXQmL.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/Queue-DpKTLl6E.mjs +119 -0
- package/dist/Queue-DpKTLl6E.mjs.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-Dptmo-1A.d.mts → SubscriberBuilder-C2FRfd26.d.mts} +8 -11
- package/dist/SubscriberBuilder-C2FRfd26.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2bCOuPT.cjs} +28 -23
- package/dist/SubscriberBuilder-C2bCOuPT.cjs.map +1 -0
- package/dist/{SubscriberBuilder-waNhzjSM.d.cts → SubscriberBuilder-CjDGSTZc.d.cts} +7 -10
- package/dist/SubscriberBuilder-CjDGSTZc.d.cts.map +1 -0
- package/dist/Topic-Ct3Le8Wt.mjs +103 -0
- package/dist/Topic-Ct3Le8Wt.mjs.map +1 -0
- package/dist/Topic-D5rlM9wS.cjs +108 -0
- package/dist/Topic-D5rlM9wS.cjs.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 +396 -82
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +150 -33
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +151 -34
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +368 -63
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-Bmo1wSQF.d.cts +177 -0
- package/dist/auth-Bmo1wSQF.d.cts.map +1 -0
- package/dist/auth-CJ5dp7T7.d.mts +177 -0
- package/dist/auth-CJ5dp7T7.d.mts.map +1 -0
- package/dist/auth.cjs +113 -28
- 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 +103 -20
- package/dist/auth.mjs.map +1 -1
- package/dist/{cache-BrRz3fEB.d.mts → cache-B2s0b-ss.d.mts} +3 -6
- package/dist/cache-B2s0b-ss.d.mts.map +1 -0
- package/dist/{cache-BtZY_tHe.d.cts → cache-CYe2Kzjc.d.cts} +3 -6
- package/dist/cache-CYe2Kzjc.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-D2gesxos.d.mts} +28 -10
- package/dist/construct-interface-D2gesxos.d.mts.map +1 -0
- package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-DPusCUSQ.d.cts} +28 -10
- package/dist/construct-interface-DPusCUSQ.d.cts.map +1 -0
- package/dist/construct-interface.cjs +116 -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 +108 -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 +40 -15
- 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 +28 -5
- 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-DKN6aQWJ.cjs} +325 -268
- package/dist/functions-DKN6aQWJ.cjs.map +1 -0
- package/dist/{functions-Cxbo-pEd.mjs → functions-DlFm8HmH.mjs} +298 -238
- package/dist/functions-DlFm8HmH.mjs.map +1 -0
- package/dist/{index-JSf9xNIJ.d.cts → index-BI23K3wy.d.cts} +17 -22
- package/dist/index-BI23K3wy.d.cts.map +1 -0
- package/dist/index-CeEtxDmK.d.cts +79 -0
- package/dist/index-CeEtxDmK.d.cts.map +1 -0
- package/dist/index-CeEtxDmK.d.mts +79 -0
- package/dist/index-CeEtxDmK.d.mts.map +1 -0
- package/dist/index-fnpjXiA-.d.mts +26 -0
- package/dist/index-fnpjXiA-.d.mts.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-CubPzHd9.d.mts → index-yb3fXNyH.d.mts} +18 -23
- package/dist/index-yb3fXNyH.d.mts.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-CEVXacPN.d.cts +159 -0
- package/dist/kysely-CEVXacPN.d.cts.map +1 -0
- package/dist/kysely-mcTdPNhl.d.mts +159 -0
- package/dist/kysely-mcTdPNhl.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 +9 -118
- 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 +5 -114
- 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 +8 -107
- 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 +4 -103
- 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
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
require(
|
|
3
|
-
require(
|
|
4
|
-
const require_functions = require(
|
|
5
|
-
require(
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime-y5ARvAq5.cjs");
|
|
3
|
+
const require_auth = require("../auth.cjs");
|
|
4
|
+
const require_functions = require("../functions-DKN6aQWJ.cjs");
|
|
5
|
+
const require_Endpoint = require("../Endpoint-QKuFg5gs.cjs");
|
|
6
|
+
const require_email = require("../email.cjs");
|
|
7
|
+
const require_database_kysely = require("../database/kysely.cjs");
|
|
8
|
+
const require_lazyAccessors = require("../lazyAccessors-Dx9NLwJZ.cjs");
|
|
9
|
+
const require_Queue = require("../Queue-B7yRXQmL.cjs");
|
|
10
|
+
const require_Topic = require("../Topic-D5rlM9wS.cjs");
|
|
11
|
+
const require_HonoEndpointAdaptor = require("../HonoEndpointAdaptor-DoEQdC3r.cjs");
|
|
12
|
+
const require_processAudits = require("../processAudits-D_2W5x8k.cjs");
|
|
13
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
14
|
+
let _geekmidas_errors = require("@geekmidas/errors");
|
|
15
|
+
let _geekmidas_envkit = require("@geekmidas/envkit");
|
|
16
|
+
let _geekmidas_services = require("@geekmidas/services");
|
|
17
|
+
let hono = require("hono");
|
|
18
|
+
let _geekmidas_audit = require("@geekmidas/audit");
|
|
19
|
+
let _geekmidas_testkit_context = require("@geekmidas/testkit/context");
|
|
20
|
+
let msw = require("msw");
|
|
21
|
+
let node_crypto = require("node:crypto");
|
|
22
|
+
let _geekmidas_testkit_browser = require("@geekmidas/testkit/browser");
|
|
23
|
+
let _geekmidas_testkit_mailbox = require("@geekmidas/testkit/mailbox");
|
|
24
|
+
let _geekmidas_testkit_transactions = require("@geekmidas/testkit/transactions");
|
|
25
|
+
let msw_node = require("msw/node");
|
|
26
|
+
let vitest = require("vitest");
|
|
27
|
+
let node_fs = require("node:fs");
|
|
28
|
+
let node_tls = require("node:tls");
|
|
29
|
+
node_tls = require_rolldown_runtime.__toESM(node_tls, 1);
|
|
30
|
+
let node_url = require("node:url");
|
|
17
31
|
//#region src/endpoints/MswEndpointAdaptor.ts
|
|
18
|
-
/**
|
|
19
|
-
* Header used to identify which test context a request belongs to.
|
|
20
|
-
* Each concurrent test registers its own context (services, db transaction, etc.)
|
|
21
|
-
* and the MSW handler looks it up by this header value.
|
|
22
|
-
*/
|
|
23
|
-
const TEST_CONTEXT_HEADER = "x-test-context-id";
|
|
24
32
|
const MSW_HTTP_METHODS = [
|
|
25
33
|
"get",
|
|
26
34
|
"post",
|
|
@@ -52,8 +60,8 @@ function createMswHandlers(endpoints, options) {
|
|
|
52
60
|
* Creates a fresh ServiceDiscovery and pre-registers all provided services.
|
|
53
61
|
*/
|
|
54
62
|
function registerContext(id, ctxOptions) {
|
|
55
|
-
const envParser = new
|
|
56
|
-
const serviceDiscovery = new
|
|
63
|
+
const envParser = new _geekmidas_envkit.EnvironmentParser({});
|
|
64
|
+
const serviceDiscovery = new _geekmidas_services.ServiceDiscovery(envParser);
|
|
57
65
|
const serviceDefs = [];
|
|
58
66
|
if (ctxOptions.services) for (const [name, instance] of Object.entries(ctxOptions.services)) serviceDefs.push({
|
|
59
67
|
serviceName: name,
|
|
@@ -88,11 +96,11 @@ function createMswHandlers(endpoints, options) {
|
|
|
88
96
|
const mswUrl = `${baseURL}${endpoint.route}`;
|
|
89
97
|
const mswMethod = msw.http[method];
|
|
90
98
|
handlers.push(mswMethod(mswUrl, async ({ request }) => {
|
|
91
|
-
const contextId = request.headers.get(TEST_CONTEXT_HEADER);
|
|
99
|
+
const contextId = request.headers.get(_geekmidas_testkit_context.TEST_CONTEXT_HEADER);
|
|
92
100
|
const ctx = contextId ? contexts.get(contextId) : void 0;
|
|
93
101
|
if (!ctx) return new Response(JSON.stringify({
|
|
94
102
|
error: "Missing or unknown test context ID",
|
|
95
|
-
hint: `Set the '${TEST_CONTEXT_HEADER}' header to a registered context ID`
|
|
103
|
+
hint: `Set the '${_geekmidas_testkit_context.TEST_CONTEXT_HEADER}' header to a registered context ID`
|
|
96
104
|
}), {
|
|
97
105
|
status: 500,
|
|
98
106
|
headers: { "content-type": "application/json" }
|
|
@@ -112,7 +120,6 @@ function createMswHandlers(endpoints, options) {
|
|
|
112
120
|
registerContext
|
|
113
121
|
};
|
|
114
122
|
}
|
|
115
|
-
|
|
116
123
|
//#endregion
|
|
117
124
|
//#region src/endpoints/TestEndpointAdaptor.ts
|
|
118
125
|
/**
|
|
@@ -132,8 +139,10 @@ function serializeCookie(name, value, options) {
|
|
|
132
139
|
return cookieString;
|
|
133
140
|
}
|
|
134
141
|
var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
142
|
+
endpoint;
|
|
143
|
+
serviceDiscovery;
|
|
135
144
|
static getDefaultServiceDiscover(_endpoint) {
|
|
136
|
-
return
|
|
145
|
+
return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
|
|
137
146
|
}
|
|
138
147
|
constructor(endpoint, serviceDiscovery = TestEndpointAdaptor.getDefaultServiceDiscover(endpoint)) {
|
|
139
148
|
this.endpoint = endpoint;
|
|
@@ -154,7 +163,7 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
154
163
|
method: this.endpoint.method
|
|
155
164
|
});
|
|
156
165
|
const rawDb = ctx.database;
|
|
157
|
-
return (0,
|
|
166
|
+
return (0, _geekmidas_services.runWithRequestContext)({
|
|
158
167
|
logger,
|
|
159
168
|
requestId,
|
|
160
169
|
startTime
|
|
@@ -166,7 +175,7 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
166
175
|
cookie,
|
|
167
176
|
...rawDb !== void 0 && { db: rawDb }
|
|
168
177
|
});
|
|
169
|
-
|
|
178
|
+
if (!await this.endpoint.authorize({
|
|
170
179
|
header,
|
|
171
180
|
cookie,
|
|
172
181
|
services: ctx.services,
|
|
@@ -176,10 +185,9 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
176
185
|
body,
|
|
177
186
|
query,
|
|
178
187
|
params
|
|
179
|
-
})
|
|
180
|
-
if (!isAuthorized) {
|
|
188
|
+
})) {
|
|
181
189
|
logger.warn("Forbidden access attempt");
|
|
182
|
-
throw new
|
|
190
|
+
throw new _geekmidas_errors.ForbiddenError("Forbidden access to the endpoint", "You do not have permission to access this resource.");
|
|
183
191
|
}
|
|
184
192
|
const auditorStorage = ctx.auditorStorage;
|
|
185
193
|
let auditContext;
|
|
@@ -199,24 +207,22 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
199
207
|
} catch (error) {
|
|
200
208
|
logger.error(error, "Failed to extract actor for audits");
|
|
201
209
|
}
|
|
202
|
-
const auditor = new __geekmidas_audit.DefaultAuditor({
|
|
203
|
-
actor,
|
|
204
|
-
storage: auditorStorage,
|
|
205
|
-
metadata: {
|
|
206
|
-
endpoint: this.endpoint.route,
|
|
207
|
-
method: this.endpoint.method
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
210
|
auditContext = {
|
|
211
|
-
auditor
|
|
211
|
+
auditor: new _geekmidas_audit.DefaultAuditor({
|
|
212
|
+
actor,
|
|
213
|
+
storage: auditorStorage,
|
|
214
|
+
metadata: {
|
|
215
|
+
endpoint: this.endpoint.route,
|
|
216
|
+
method: this.endpoint.method
|
|
217
|
+
}
|
|
218
|
+
}),
|
|
212
219
|
storage: auditorStorage
|
|
213
220
|
};
|
|
214
221
|
}
|
|
215
222
|
const audits = this.endpoint.audits;
|
|
216
223
|
if (!auditContext && audits?.length) logger.warn("No auditor storage service available");
|
|
217
|
-
const
|
|
218
|
-
const
|
|
219
|
-
const db = trx ?? rawDb;
|
|
224
|
+
const { output, metadata } = await require_processAudits.executeWithAuditTransaction(auditContext, async (auditor) => {
|
|
225
|
+
const db = auditor?.getTransaction?.() ?? rawDb;
|
|
220
226
|
const responseBuilder = new require_Endpoint.ResponseBuilder();
|
|
221
227
|
const response = await this.endpoint.handler({
|
|
222
228
|
body,
|
|
@@ -231,36 +237,34 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
231
237
|
db
|
|
232
238
|
}, responseBuilder);
|
|
233
239
|
let data = response;
|
|
234
|
-
let metadata
|
|
240
|
+
let metadata = responseBuilder.getMetadata();
|
|
235
241
|
if (require_Endpoint.Endpoint.hasMetadata(response)) {
|
|
236
242
|
data = response.data;
|
|
237
|
-
metadata
|
|
243
|
+
metadata = response.metadata;
|
|
238
244
|
}
|
|
239
|
-
const output$1 = await this.endpoint.parseOutput(data);
|
|
240
245
|
return {
|
|
241
|
-
output:
|
|
242
|
-
metadata
|
|
246
|
+
output: await this.endpoint.parseOutput(data),
|
|
247
|
+
metadata,
|
|
243
248
|
responseBuilder
|
|
244
249
|
};
|
|
245
|
-
}, async (result
|
|
250
|
+
}, async (result, auditor) => {
|
|
246
251
|
if (!audits?.length) return;
|
|
247
252
|
for (const audit of audits) {
|
|
248
|
-
if (audit.when && !audit.when(result
|
|
249
|
-
const payload = audit.payload(result
|
|
250
|
-
const entityId = audit.entityId?.(result
|
|
253
|
+
if (audit.when && !audit.when(result.output)) continue;
|
|
254
|
+
const payload = audit.payload(result.output);
|
|
255
|
+
const entityId = audit.entityId?.(result.output);
|
|
251
256
|
auditor.audit(audit.type, payload, {
|
|
252
257
|
table: audit.table,
|
|
253
258
|
entityId
|
|
254
259
|
});
|
|
255
260
|
}
|
|
256
261
|
}, { db: rawDb });
|
|
257
|
-
const { output, metadata } = result;
|
|
258
262
|
ctx.publisher && await this.serviceDiscovery.register([ctx.publisher]);
|
|
259
263
|
await require_lazyAccessors.publishConstructEvents(this.endpoint, output, this.serviceDiscovery);
|
|
260
264
|
const headers = { ...metadata.headers || {} };
|
|
261
265
|
if (metadata.cookies && metadata.cookies.size > 0) {
|
|
262
266
|
const setCookieValues = [];
|
|
263
|
-
for (const [name, cookie
|
|
267
|
+
for (const [name, cookie] of metadata.cookies.entries()) setCookieValues.push(serializeCookie(name, cookie.value, cookie.options));
|
|
264
268
|
headers["set-cookie"] = setCookieValues;
|
|
265
269
|
}
|
|
266
270
|
return {
|
|
@@ -271,16 +275,16 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
271
275
|
});
|
|
272
276
|
}
|
|
273
277
|
async request(ctx) {
|
|
274
|
-
|
|
275
|
-
return response.body;
|
|
278
|
+
return (await this.fullRequest(ctx)).body;
|
|
276
279
|
}
|
|
277
280
|
};
|
|
278
|
-
|
|
279
281
|
//#endregion
|
|
280
282
|
//#region src/functions/TestFunctionAdaptor.ts
|
|
281
283
|
var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
284
|
+
fn;
|
|
285
|
+
serviceDiscovery;
|
|
282
286
|
static getDefaultServiceDiscovery(_fn) {
|
|
283
|
-
return
|
|
287
|
+
return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
|
|
284
288
|
}
|
|
285
289
|
constructor(fn, serviceDiscovery = TestFunctionAdaptor.getDefaultServiceDiscovery(fn)) {
|
|
286
290
|
this.fn = fn;
|
|
@@ -294,16 +298,12 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
|
294
298
|
else services = await this.serviceDiscovery.register(this.fn.services);
|
|
295
299
|
let db;
|
|
296
300
|
if ("db" in ctx && ctx.db !== void 0) db = ctx.db;
|
|
297
|
-
else if (this.fn.databaseService)
|
|
298
|
-
const dbServices = await this.serviceDiscovery.register([this.fn.databaseService]);
|
|
299
|
-
db = dbServices[this.fn.databaseService.serviceName];
|
|
300
|
-
}
|
|
301
|
+
else if (this.fn.databaseService) db = (await this.serviceDiscovery.register([this.fn.databaseService]))[this.fn.databaseService.serviceName];
|
|
301
302
|
let auditor;
|
|
302
303
|
if ("auditor" in ctx && ctx.auditor !== void 0) auditor = ctx.auditor;
|
|
303
304
|
else if (this.fn.auditorStorageService) {
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
auditor = new __geekmidas_audit.DefaultAuditor({
|
|
305
|
+
const storage = (await this.serviceDiscovery.register([this.fn.auditorStorageService]))[this.fn.auditorStorageService.serviceName];
|
|
306
|
+
auditor = new _geekmidas_audit.DefaultAuditor({
|
|
307
307
|
actor: {
|
|
308
308
|
id: "system",
|
|
309
309
|
type: "system"
|
|
@@ -316,11 +316,10 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
318
|
const requestId = `test-${Date.now()}`;
|
|
319
|
-
|
|
320
|
-
return (0, __geekmidas_services.runWithRequestContext)({
|
|
319
|
+
return (0, _geekmidas_services.runWithRequestContext)({
|
|
321
320
|
logger,
|
|
322
321
|
requestId,
|
|
323
|
-
startTime
|
|
322
|
+
startTime: Date.now()
|
|
324
323
|
}, async () => {
|
|
325
324
|
const response = await this.fn.fn({
|
|
326
325
|
input: parsedInput,
|
|
@@ -342,7 +341,6 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
|
342
341
|
});
|
|
343
342
|
}
|
|
344
343
|
};
|
|
345
|
-
|
|
346
344
|
//#endregion
|
|
347
345
|
//#region src/queue/TestQueueAdaptor.ts
|
|
348
346
|
/**
|
|
@@ -355,8 +353,10 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
|
355
353
|
* await adapter.invoke({ messages: [{ orderId: '123' }] });
|
|
356
354
|
*/
|
|
357
355
|
var TestQueueAdaptor = class TestQueueAdaptor {
|
|
356
|
+
queue;
|
|
357
|
+
serviceDiscovery;
|
|
358
358
|
static getDefaultServiceDiscovery() {
|
|
359
|
-
return
|
|
359
|
+
return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
|
|
360
360
|
}
|
|
361
361
|
constructor(queue, serviceDiscovery = TestQueueAdaptor.getDefaultServiceDiscovery()) {
|
|
362
362
|
this.queue = queue;
|
|
@@ -366,11 +366,10 @@ var TestQueueAdaptor = class TestQueueAdaptor {
|
|
|
366
366
|
const logger = this.queue.logger.child({ test: true });
|
|
367
367
|
const services = request.services ?? await this.serviceDiscovery.register(this.queue.services);
|
|
368
368
|
const requestId = `test-${Date.now()}`;
|
|
369
|
-
|
|
370
|
-
return (0, __geekmidas_services.runWithRequestContext)({
|
|
369
|
+
return (0, _geekmidas_services.runWithRequestContext)({
|
|
371
370
|
logger,
|
|
372
371
|
requestId,
|
|
373
|
-
startTime
|
|
372
|
+
startTime: Date.now()
|
|
374
373
|
}, () => this.queue.handler({
|
|
375
374
|
messages: request.messages,
|
|
376
375
|
services,
|
|
@@ -378,12 +377,13 @@ var TestQueueAdaptor = class TestQueueAdaptor {
|
|
|
378
377
|
}));
|
|
379
378
|
}
|
|
380
379
|
};
|
|
381
|
-
|
|
382
380
|
//#endregion
|
|
383
381
|
//#region src/subscribers/TestSubscriberAdaptor.ts
|
|
384
382
|
var TestSubscriberAdaptor = class TestSubscriberAdaptor {
|
|
383
|
+
subscriber;
|
|
384
|
+
serviceDiscovery;
|
|
385
385
|
static getDefaultServiceDiscovery() {
|
|
386
|
-
return
|
|
386
|
+
return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
|
|
387
387
|
}
|
|
388
388
|
constructor(subscriber, serviceDiscovery = TestSubscriberAdaptor.getDefaultServiceDiscovery()) {
|
|
389
389
|
this.subscriber = subscriber;
|
|
@@ -397,11 +397,10 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
|
|
|
397
397
|
const filteredEvents = this.filterEvents(request.events);
|
|
398
398
|
if (filteredEvents.length === 0) return { batchItemFailures: [] };
|
|
399
399
|
const requestId = `test-${Date.now()}`;
|
|
400
|
-
|
|
401
|
-
return (0, __geekmidas_services.runWithRequestContext)({
|
|
400
|
+
return (0, _geekmidas_services.runWithRequestContext)({
|
|
402
401
|
logger,
|
|
403
402
|
requestId,
|
|
404
|
-
startTime
|
|
403
|
+
startTime: Date.now()
|
|
405
404
|
}, async () => {
|
|
406
405
|
const result = await this.subscriber.handler({
|
|
407
406
|
events: filteredEvents,
|
|
@@ -423,12 +422,327 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
|
|
|
423
422
|
return events.filter((event) => this.subscriber.subscribedEvents.includes(event.type));
|
|
424
423
|
}
|
|
425
424
|
};
|
|
426
|
-
|
|
427
425
|
//#endregion
|
|
428
|
-
|
|
426
|
+
//#region src/testing/manifest.ts
|
|
427
|
+
/**
|
|
428
|
+
* The test manifest: what `gkm test` knows about an app, written down for the
|
|
429
|
+
* suite it starts.
|
|
430
|
+
*
|
|
431
|
+
* `gkm test` discovers the constructs, reconciles the test stage and resolves
|
|
432
|
+
* its environment — then, until this existed, threw all of it away and left a
|
|
433
|
+
* test to declare it again by hand. The manifest keeps it: which construct and
|
|
434
|
+
* endpoint is exported where, and the environment the test stage resolved,
|
|
435
|
+
* under the keys the constructs themselves derive. A feature test is built from
|
|
436
|
+
* it, so nothing a test says can drift from what the app declares.
|
|
437
|
+
*/
|
|
438
|
+
/** The environment variable `gkm test` names the manifest in. */
|
|
439
|
+
const TEST_MANIFEST_ENV = "GKM_TEST_MANIFEST";
|
|
440
|
+
/**
|
|
441
|
+
* Read a test manifest: from a path, a `file:` URL, or — given nothing — the
|
|
442
|
+
* one `gkm test` named in `GKM_TEST_MANIFEST`.
|
|
443
|
+
*/
|
|
444
|
+
function loadTestManifest(from) {
|
|
445
|
+
const location = from ?? process.env["GKM_TEST_MANIFEST"];
|
|
446
|
+
if (!location) throw new NoTestManifest();
|
|
447
|
+
trustLocalEdge();
|
|
448
|
+
const path = location instanceof URL || location.startsWith("file:") ? (0, node_url.fileURLToPath)(location) : location;
|
|
449
|
+
return JSON.parse((0, node_fs.readFileSync)(path, "utf-8"));
|
|
450
|
+
}
|
|
451
|
+
let trusted = false;
|
|
452
|
+
/**
|
|
453
|
+
* Trust the local edge's certificate authority in this thread.
|
|
454
|
+
*
|
|
455
|
+
* `NODE_EXTRA_CA_CERTS` does it for a process started with it — which a
|
|
456
|
+
* suite started by `gkm test` is, and one started by plain `vitest` or an
|
|
457
|
+
* editor is not: its setup only learns the path once Vitest is running, and a
|
|
458
|
+
* worker *thread* shares that process and keeps a TLS store of its own. Every
|
|
459
|
+
* feature test loads the manifest, so this is the one place each worker passes
|
|
460
|
+
* through.
|
|
461
|
+
*/
|
|
462
|
+
function trustLocalEdge() {
|
|
463
|
+
const certificate = process.env.NODE_EXTRA_CA_CERTS;
|
|
464
|
+
if (trusted || !certificate || !(0, node_fs.existsSync)(certificate)) return;
|
|
465
|
+
trusted = true;
|
|
466
|
+
node_tls.default.setDefaultCACertificates([...node_tls.default.getCACertificates("default"), (0, node_fs.readFileSync)(certificate, "utf-8")]);
|
|
467
|
+
}
|
|
468
|
+
/** A feature test ran without a manifest to build itself from. */
|
|
469
|
+
var NoTestManifest = class extends Error {
|
|
470
|
+
constructor() {
|
|
471
|
+
super(`No test manifest: run the suite with \`gkm test\`, or add \`globalSetup: ['@geekmidas/cli/vitest']\` to the root vitest config — either writes one and names it in ${TEST_MANIFEST_ENV}.`);
|
|
472
|
+
this.name = "NoTestManifest";
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/testing/featureTest.ts
|
|
477
|
+
/**
|
|
478
|
+
* `featureTest`: an app, driven the way it runs deployed.
|
|
479
|
+
*
|
|
480
|
+
* A browser signs in and calls the API; the API calls the auth server; each
|
|
481
|
+
* over its URL, each database in its own transaction. Nothing runs as a server:
|
|
482
|
+
* every URL an app's constructs answer on is served in-process through MSW,
|
|
483
|
+
* from the real handler, for the test that made the request. Everything else
|
|
484
|
+
* with a real local equivalent — Postgres, Mailpit, MinIO — is used directly.
|
|
485
|
+
*
|
|
486
|
+
* It is built from the test manifest `gkm test` writes — the constructs and
|
|
487
|
+
* endpoints the app exports, and the environment the test stage resolved — so
|
|
488
|
+
* a test declares none of it. `gkm test` also generates the configured `it`
|
|
489
|
+
* and a `Browser` with a typed client per surface:
|
|
490
|
+
*
|
|
491
|
+
* ```ts
|
|
492
|
+
* import { it } from '#test';
|
|
493
|
+
*
|
|
494
|
+
* it('shows the signed-in user their profile', async ({ browser, mailbox }) => {
|
|
495
|
+
* await browser.auth.signIn.magicLink({ email: 'ada@shop.test' });
|
|
496
|
+
* await browser.visit((await mailbox('ada@shop.test').last()).link!);
|
|
497
|
+
* expect(await browser.api.get('/profile')).toMatchObject({ email: 'ada@shop.test' });
|
|
498
|
+
* });
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
/** Every test in flight in this process, by id. */
|
|
502
|
+
const contexts = /* @__PURE__ */ new Map();
|
|
503
|
+
/** Databases already resolving to test transactions — patched once each. */
|
|
504
|
+
const bound = /* @__PURE__ */ new WeakSet();
|
|
505
|
+
function featureTest(options = {}) {
|
|
506
|
+
const manifest = options.manifest ?? loadTestManifest();
|
|
507
|
+
const BrowserClass = options.browser ?? _geekmidas_testkit_browser.Browser;
|
|
508
|
+
let app;
|
|
509
|
+
let network;
|
|
510
|
+
let restoreFetch = () => {};
|
|
511
|
+
(0, vitest.beforeAll)(async () => {
|
|
512
|
+
app = await load(manifest, options.database, options.modules ?? {});
|
|
513
|
+
for (const database of app.databases) bindToTests(database);
|
|
514
|
+
network = (0, msw_node.setupServer)(...surfaceHandlers(app.endpoints, manifest.env), ...app.auths.map((auth) => authHandler(auth, manifest.env, app.envParser)));
|
|
515
|
+
network.listen({ onUnhandledRequest(request, print) {
|
|
516
|
+
if (isLocal(new URL(request.url))) return;
|
|
517
|
+
print.error();
|
|
518
|
+
} });
|
|
519
|
+
restoreFetch = (0, _geekmidas_testkit_context.installContextFetch)();
|
|
520
|
+
});
|
|
521
|
+
(0, vitest.afterAll)(() => {
|
|
522
|
+
restoreFetch();
|
|
523
|
+
network?.close();
|
|
524
|
+
});
|
|
525
|
+
const run = (fn) => async () => {
|
|
526
|
+
const id = (0, node_crypto.randomUUID)();
|
|
527
|
+
const state = {
|
|
528
|
+
transactions: new _geekmidas_testkit_transactions.TransactionRegistry(),
|
|
529
|
+
discovery: new _geekmidas_services.ServiceDiscovery(app.envParser),
|
|
530
|
+
surfaces: /* @__PURE__ */ new Map(),
|
|
531
|
+
auth: /* @__PURE__ */ new Map(),
|
|
532
|
+
addresses: /* @__PURE__ */ new Set(),
|
|
533
|
+
published: /* @__PURE__ */ new Map()
|
|
534
|
+
};
|
|
535
|
+
contexts.set(id, state);
|
|
536
|
+
await state.discovery.register(recorders(app.channels, state));
|
|
537
|
+
try {
|
|
538
|
+
await (0, _geekmidas_testkit_context.runInTestContext)(id, async () => {
|
|
539
|
+
const browser = new BrowserClass();
|
|
540
|
+
const restore = browser.install();
|
|
541
|
+
try {
|
|
542
|
+
await fn({
|
|
543
|
+
browser,
|
|
544
|
+
db: app.database ? await state.transactions.get(app.database.id, urlOf(app.database, app.envParser), app.database.clientConfig) : void 0,
|
|
545
|
+
mailbox: (address) => {
|
|
546
|
+
if (!app.readMail) throw new NoInbox();
|
|
547
|
+
state.addresses.add(address);
|
|
548
|
+
return app.readMail(address);
|
|
549
|
+
},
|
|
550
|
+
published: (channel) => [...state.published.get(channel.id) ?? []],
|
|
551
|
+
subscriber: (subscriber) => new TestSubscriberAdaptor(subscriber, state.discovery),
|
|
552
|
+
queue: (queue) => new TestQueueAdaptor(queue, state.discovery)
|
|
553
|
+
});
|
|
554
|
+
} finally {
|
|
555
|
+
restore();
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
} finally {
|
|
559
|
+
contexts.delete(id);
|
|
560
|
+
await Promise.all([state.transactions.rollbackAll(), ...[...state.addresses].map((address) => app.readMail?.(address).clear())]);
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
const it = ((name, fn, timeout) => (0, vitest.test)(name, run(fn), timeout));
|
|
564
|
+
it.only = (name, fn, timeout) => vitest.test.only(name, run(fn), timeout);
|
|
565
|
+
it.skip = (name, fn, timeout) => vitest.test.skip(name, run(fn), timeout);
|
|
566
|
+
return it;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Import what the manifest points at.
|
|
570
|
+
*
|
|
571
|
+
* The same modules the app runs, so a construct here *is* the app's construct —
|
|
572
|
+
* the one its endpoints were built from — never a copy declared again.
|
|
573
|
+
*/
|
|
574
|
+
async function load(manifest, database, modules) {
|
|
575
|
+
const envParser = new _geekmidas_envkit.EnvironmentParser({ ...manifest.env });
|
|
576
|
+
const imported = async ({ file, export: name }) => (modules[file] ?? await import(file))[name];
|
|
577
|
+
const constructs = await Promise.all(Object.values(manifest.constructs).map(({ source }) => imported(source)));
|
|
578
|
+
const endpoints = (await Promise.all(manifest.endpoints.map(({ source }) => imported(source)))).filter((value) => require_Endpoint.Endpoint.isEndpoint(value));
|
|
579
|
+
const unique = (values) => [...new Set(values)];
|
|
580
|
+
const databases = unique(constructs.filter((value) => value instanceof require_database_kysely.KyselyDatabase));
|
|
581
|
+
const auths = unique(constructs.filter((value) => value instanceof require_auth.BetterAuth));
|
|
582
|
+
const emails = unique(constructs.filter((value) => value instanceof require_email.Email));
|
|
583
|
+
const channels = unique(constructs.filter((value) => value instanceof require_Topic.Topic || value instanceof require_Queue.Queue));
|
|
584
|
+
const inbox = emails.map((email) => manifest.env[(0, _geekmidas_manifest.provideKey)(email.id, "inboxUrl")]).find(Boolean);
|
|
585
|
+
return {
|
|
586
|
+
envParser,
|
|
587
|
+
endpoints,
|
|
588
|
+
databases,
|
|
589
|
+
auths,
|
|
590
|
+
emails,
|
|
591
|
+
channels,
|
|
592
|
+
database: databaseOf(databases, endpoints, database),
|
|
593
|
+
...inbox ? { readMail: (0, _geekmidas_testkit_mailbox.createMailbox)({ inbox }) } : {}
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* A publisher that records rather than sends, under every name a topic or
|
|
598
|
+
* queue is injected by — `users`, and the older `usersPublisher`.
|
|
599
|
+
*/
|
|
600
|
+
function recorders(channels, state) {
|
|
601
|
+
return channels.flatMap((channel) => {
|
|
602
|
+
const publisher = { async publish(messages) {
|
|
603
|
+
state.published.set(channel.id, [...state.published.get(channel.id) ?? [], ...messages.map(({ type, payload }) => ({
|
|
604
|
+
type,
|
|
605
|
+
payload
|
|
606
|
+
}))]);
|
|
607
|
+
} };
|
|
608
|
+
return [channel.service.serviceName, channel.publisher.serviceName].map((serviceName) => ({
|
|
609
|
+
serviceName,
|
|
610
|
+
register: () => publisher
|
|
611
|
+
}));
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* The database a test sees as `db`: the one named, or else the one the
|
|
616
|
+
* endpoints were given with `.database()` — found by the service they hold,
|
|
617
|
+
* which is the construct's own.
|
|
618
|
+
*/
|
|
619
|
+
function databaseOf(databases, endpoints, named) {
|
|
620
|
+
if (named) {
|
|
621
|
+
const found = databases.find(({ id }) => id === named);
|
|
622
|
+
if (!found) throw new UnknownDatabase(named, databases.map(({ id }) => id));
|
|
623
|
+
return found;
|
|
624
|
+
}
|
|
625
|
+
const services = new Set(endpoints.map((e) => e.databaseService).filter(Boolean));
|
|
626
|
+
return databases.find((database) => services.has(database.service));
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Make a database resolve, inside a test, to that test's transaction.
|
|
630
|
+
*
|
|
631
|
+
* Everything reaches a database through its service — an endpoint through
|
|
632
|
+
* service discovery, the auth server through its tenant directly — so this is
|
|
633
|
+
* the one place a test's connection can be handed over. Outside a test it is
|
|
634
|
+
* the database it always was.
|
|
635
|
+
*/
|
|
636
|
+
function bindToTests(database) {
|
|
637
|
+
if (bound.has(database)) return;
|
|
638
|
+
bound.add(database);
|
|
639
|
+
const service = database.service;
|
|
640
|
+
const register = service.register;
|
|
641
|
+
service.register = (options) => {
|
|
642
|
+
const context = (0, _geekmidas_testkit_context.currentTestContext)();
|
|
643
|
+
const state = context && contexts.get(context.id);
|
|
644
|
+
if (!state) return register(options);
|
|
645
|
+
return state.transactions.get(database.id, urlOf(database, options.envParser), database.clientConfig);
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function urlOf(database, envParser) {
|
|
649
|
+
return envParser.create((get) => ({ url: get((0, _geekmidas_manifest.provideKey)(database.id, "url")).string() })).parse().url;
|
|
650
|
+
}
|
|
651
|
+
/** Each surface's endpoints, served at its URL for the test that asked. */
|
|
652
|
+
function surfaceHandlers(endpoints, env) {
|
|
653
|
+
const bySurface = /* @__PURE__ */ new Map();
|
|
654
|
+
for (const endpoint of endpoints) {
|
|
655
|
+
const surface = endpoint.surface?.id;
|
|
656
|
+
if (!surface) continue;
|
|
657
|
+
bySurface.set(surface, [...bySurface.get(surface) ?? [], endpoint]);
|
|
658
|
+
}
|
|
659
|
+
return [...bySurface].flatMap(([surface, served]) => {
|
|
660
|
+
const base = env[(0, _geekmidas_manifest.provideKey)(surface, "url")];
|
|
661
|
+
if (!base) return [];
|
|
662
|
+
return msw.http.all(`${trim(base)}/*`, ({ request }) => serve(request, async (state) => {
|
|
663
|
+
let app = state.surfaces.get(surface);
|
|
664
|
+
if (!app) {
|
|
665
|
+
app = Promise.resolve().then(() => {
|
|
666
|
+
const hono$1 = new hono.Hono();
|
|
667
|
+
require_HonoEndpointAdaptor.HonoEndpoint.addRoutes(served, state.discovery, hono$1);
|
|
668
|
+
return hono$1;
|
|
669
|
+
});
|
|
670
|
+
state.surfaces.set(surface, app);
|
|
671
|
+
}
|
|
672
|
+
return (await app).fetch(request);
|
|
673
|
+
}));
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
/** An auth server, served at its URL, on the transaction of the test that asked. */
|
|
677
|
+
function authHandler(auth, env, envParser) {
|
|
678
|
+
const base = trim(env[(0, _geekmidas_manifest.provideKey)(auth.id, "url")] ?? "");
|
|
679
|
+
return msw.http.all(`${base}/*`, ({ request }) => serve(request, async (state) => {
|
|
680
|
+
let app = state.auth.get(auth);
|
|
681
|
+
if (!app) {
|
|
682
|
+
app = auth.server({
|
|
683
|
+
envParser,
|
|
684
|
+
context: _geekmidas_services.serviceContext
|
|
685
|
+
}).then(({ app }) => app);
|
|
686
|
+
state.auth.set(auth, app);
|
|
687
|
+
}
|
|
688
|
+
return (await app).fetch(request);
|
|
689
|
+
}));
|
|
690
|
+
}
|
|
691
|
+
/** Handle a request as the server side of the test it was made for. */
|
|
692
|
+
async function serve(request, handle) {
|
|
693
|
+
const id = (0, _geekmidas_testkit_context.testContextOf)(request);
|
|
694
|
+
const state = id ? contexts.get(id) : void 0;
|
|
695
|
+
if (!id || !state) throw new UnknownTestContext(request.url, id);
|
|
696
|
+
return (0, _geekmidas_testkit_context.runAsServer)(id, () => handle(state));
|
|
697
|
+
}
|
|
698
|
+
function trim(url) {
|
|
699
|
+
return url.replace(/\/$/, "");
|
|
700
|
+
}
|
|
701
|
+
function isLocal(url) {
|
|
702
|
+
return url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname.endsWith(".localhost");
|
|
703
|
+
}
|
|
704
|
+
/** A request reached an in-process server without a test to belong to. */
|
|
705
|
+
var UnknownTestContext = class extends Error {
|
|
706
|
+
url;
|
|
707
|
+
id;
|
|
708
|
+
constructor(url, id) {
|
|
709
|
+
super(id ? `${url} was requested for test ${id}, which is not running. A request that outlives its test — an un-awaited call — lands here.` : `${url} was requested outside any test. Make the request inside a featureTest, so it reaches that test's transactions.`);
|
|
710
|
+
this.url = url;
|
|
711
|
+
this.id = id;
|
|
712
|
+
this.name = "UnknownTestContext";
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
/** `mailbox` was used in an app that declares no Email construct. */
|
|
716
|
+
var NoInbox = class extends Error {
|
|
717
|
+
constructor() {
|
|
718
|
+
super("mailbox() reads the inbox of the app's Email construct, and none was found in featureTest's modules — or `gkm test` did not inject its <ID>_INBOX_URL.");
|
|
719
|
+
this.name = "NoInbox";
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
/** `featureTest({ database })` named a database the app does not declare. */
|
|
723
|
+
var UnknownDatabase = class extends Error {
|
|
724
|
+
id;
|
|
725
|
+
declared;
|
|
726
|
+
constructor(id, declared) {
|
|
727
|
+
super(`featureTest was asked for the database '${id}', and the app declares ${declared.length ? declared.map((d) => `'${d}'`).join(", ") : "none"}.`);
|
|
728
|
+
this.id = id;
|
|
729
|
+
this.declared = declared;
|
|
730
|
+
this.name = "UnknownDatabase";
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
//#endregion
|
|
734
|
+
exports.NoInbox = NoInbox;
|
|
735
|
+
exports.NoTestManifest = NoTestManifest;
|
|
736
|
+
exports.TEST_CONTEXT_HEADER = _geekmidas_testkit_context.TEST_CONTEXT_HEADER;
|
|
737
|
+
exports.TEST_MANIFEST_ENV = TEST_MANIFEST_ENV;
|
|
429
738
|
exports.TestEndpointAdaptor = TestEndpointAdaptor;
|
|
430
739
|
exports.TestFunctionAdaptor = TestFunctionAdaptor;
|
|
431
740
|
exports.TestQueueAdaptor = TestQueueAdaptor;
|
|
432
741
|
exports.TestSubscriberAdaptor = TestSubscriberAdaptor;
|
|
742
|
+
exports.UnknownDatabase = UnknownDatabase;
|
|
743
|
+
exports.UnknownTestContext = UnknownTestContext;
|
|
433
744
|
exports.createMswHandlers = createMswHandlers;
|
|
745
|
+
exports.featureTest = featureTest;
|
|
746
|
+
exports.loadTestManifest = loadTestManifest;
|
|
747
|
+
|
|
434
748
|
//# sourceMappingURL=testing.cjs.map
|