@geekmidas/constructs 10.0.0-alpha.15 → 10.0.0-alpha.151
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 +222 -158
- package/dist/Construct-127M7yrl.d.cts +231 -0
- package/dist/Construct-127M7yrl.d.cts.map +1 -0
- package/dist/{Construct-BeYVu_QF.mjs → Construct-CGuc_Ijk.mjs} +8 -9
- package/dist/Construct-CGuc_Ijk.mjs.map +1 -0
- package/dist/{Construct-DqdlARxq.cjs → Construct-DorKS0Ua.cjs} +8 -9
- package/dist/Construct-DorKS0Ua.cjs.map +1 -0
- package/dist/Construct-DySlwh8o.d.mts +231 -0
- package/dist/Construct-DySlwh8o.d.mts.map +1 -0
- package/dist/{Cron-DKqnnTdH.d.cts → Cron-D8mB_cPX.d.mts} +16 -9
- package/dist/Cron-D8mB_cPX.d.mts.map +1 -0
- package/dist/{Cron-SyqS5oWJ.d.mts → Cron-D_sfaMGz.d.cts} +16 -9
- package/dist/Cron-D_sfaMGz.d.cts.map +1 -0
- package/dist/{CronBuilder-D_0HNBTr.mjs → CronBuilder-BJ5LoadF.mjs} +28 -11
- package/dist/CronBuilder-BJ5LoadF.mjs.map +1 -0
- package/dist/{CronBuilder-BdnI6lxF.cjs → CronBuilder-B_NSP-Y5.cjs} +27 -10
- package/dist/CronBuilder-B_NSP-Y5.cjs.map +1 -0
- package/dist/CronBuilder-C91MVLSr.d.cts +47 -0
- package/dist/CronBuilder-C91MVLSr.d.cts.map +1 -0
- package/dist/CronBuilder-Cmajva3g.d.mts +47 -0
- package/dist/CronBuilder-Cmajva3g.d.mts.map +1 -0
- package/dist/Endpoint-52z1P0Ue.cjs +581 -0
- package/dist/Endpoint-52z1P0Ue.cjs.map +1 -0
- package/dist/{Endpoint-DuT4TEEq.d.mts → Endpoint-BbHh3Qoc.d.mts} +124 -43
- package/dist/Endpoint-BbHh3Qoc.d.mts.map +1 -0
- package/dist/{Endpoint-C6yyHpRS.d.cts → Endpoint-YYwjqtS1.d.cts} +122 -41
- package/dist/Endpoint-YYwjqtS1.d.cts.map +1 -0
- package/dist/Endpoint-sUOU7uLx.mjs +552 -0
- package/dist/Endpoint-sUOU7uLx.mjs.map +1 -0
- package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
- package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
- package/dist/{EndpointFactory-CLvWuHyt.cjs → EndpointFactory-Cf_Cs1ym.cjs} +309 -51
- package/dist/EndpointFactory-Cf_Cs1ym.cjs.map +1 -0
- package/dist/{index-BPSZ_Lp_.d.cts → EndpointFactory-Hh1r6J_C.d.cts} +187 -104
- package/dist/EndpointFactory-Hh1r6J_C.d.cts.map +1 -0
- package/dist/{index-BoZ-iisU.d.mts → EndpointFactory-qcLzi4f-.d.mts} +188 -105
- package/dist/EndpointFactory-qcLzi4f-.d.mts.map +1 -0
- package/dist/Function-BIEsY0Hm.d.cts +76 -0
- package/dist/Function-BIEsY0Hm.d.cts.map +1 -0
- package/dist/Function-DfMzTGS4.d.mts +76 -0
- package/dist/Function-DfMzTGS4.d.mts.map +1 -0
- package/dist/{HonoEndpointAdaptor-92zavCsV.cjs → HonoEndpointAdaptor-BXBdb2Bt.cjs} +79 -31
- package/dist/HonoEndpointAdaptor-BXBdb2Bt.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-yYaU7jVJ.mjs → HonoEndpointAdaptor-DR3j7S35.mjs} +76 -28
- package/dist/HonoEndpointAdaptor-DR3j7S35.mjs.map +1 -0
- package/dist/ObjectSubscriberBuilder-Cv8C7yS1.d.mts +129 -0
- package/dist/ObjectSubscriberBuilder-Cv8C7yS1.d.mts.map +1 -0
- package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts +129 -0
- package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts.map +1 -0
- package/dist/ProcessorBuilder-CwfP-M33.d.mts +216 -0
- package/dist/ProcessorBuilder-CwfP-M33.d.mts.map +1 -0
- package/dist/ProcessorBuilder-_jdZlbfW.d.cts +216 -0
- package/dist/ProcessorBuilder-_jdZlbfW.d.cts.map +1 -0
- package/dist/{Queue-D9X6OoON.d.mts → Queue-BnK3UH8r.d.mts} +42 -41
- package/dist/Queue-BnK3UH8r.d.mts.map +1 -0
- package/dist/{Queue-DYPB2KWL.d.cts → Queue-C4rijiM7.d.cts} +43 -42
- package/dist/Queue-C4rijiM7.d.cts.map +1 -0
- package/dist/Queue-D4Iaidrs.cjs +109 -0
- package/dist/Queue-D4Iaidrs.cjs.map +1 -0
- package/dist/Queue-u8w8_HpE.mjs +104 -0
- package/dist/Queue-u8w8_HpE.mjs.map +1 -0
- package/dist/QueueBuilder-2wP5lEC8.mjs +118 -0
- package/dist/QueueBuilder-2wP5lEC8.mjs.map +1 -0
- package/dist/QueueBuilder-BxsZ9o5z.cjs +135 -0
- package/dist/QueueBuilder-BxsZ9o5z.cjs.map +1 -0
- package/dist/QueueBuilder-DmwFtLzQ.d.mts +75 -0
- package/dist/QueueBuilder-DmwFtLzQ.d.mts.map +1 -0
- package/dist/QueueBuilder-SQli59An.d.cts +75 -0
- package/dist/QueueBuilder-SQli59An.d.cts.map +1 -0
- package/dist/Subscriber-5rCX1Nph.d.cts +83 -0
- package/dist/Subscriber-5rCX1Nph.d.cts.map +1 -0
- package/dist/Subscriber-CW_Dl-YR.d.mts +83 -0
- package/dist/Subscriber-CW_Dl-YR.d.mts.map +1 -0
- package/dist/SubscriberBuilder-BL_GTcwh.mjs +237 -0
- package/dist/SubscriberBuilder-BL_GTcwh.mjs.map +1 -0
- package/dist/SubscriberBuilder-CWzKwX1p.cjs +260 -0
- package/dist/SubscriberBuilder-CWzKwX1p.cjs.map +1 -0
- package/dist/Topic-DN2gYJ-p.mjs +99 -0
- package/dist/Topic-DN2gYJ-p.mjs.map +1 -0
- package/dist/Topic-Dp9Q7Lj2.cjs +104 -0
- package/dist/Topic-Dp9Q7Lj2.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +134 -160
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +57 -48
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +58 -49
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +130 -157
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +1 -1
- package/dist/adaptors/hono.d.cts +5 -6
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +6 -7
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +1 -1
- package/dist/adaptors/testing.cjs +955 -38
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +437 -39
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +436 -38
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +929 -34
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-BqWz2JxC.d.cts +274 -0
- package/dist/auth-BqWz2JxC.d.cts.map +1 -0
- package/dist/auth-DnB9H9KL.d.mts +274 -0
- package/dist/auth-DnB9H9KL.d.mts.map +1 -0
- package/dist/auth.cjs +320 -21
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -104
- package/dist/auth.d.mts +2 -104
- package/dist/auth.mjs +316 -23
- package/dist/auth.mjs.map +1 -1
- package/dist/cache-CQjMNPrC.d.cts +44 -0
- package/dist/cache-CQjMNPrC.d.cts.map +1 -0
- package/dist/cache-e3tfMQ9g.d.mts +44 -0
- package/dist/cache-e3tfMQ9g.d.mts.map +1 -0
- package/dist/cache.d.cts +2 -43
- package/dist/cache.d.mts +2 -43
- package/dist/cipher-C1lEFX63.mjs +225 -0
- package/dist/cipher-C1lEFX63.mjs.map +1 -0
- package/dist/cipher-CVxfwLjk.cjs +332 -0
- package/dist/cipher-CVxfwLjk.cjs.map +1 -0
- package/dist/cipher-DSDxPRIp.d.cts +106 -0
- package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
- package/dist/cipher-DSDxPRIp.d.mts +106 -0
- package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
- package/dist/{construct-interface-DPlxfpoS.d.mts → construct-interface-CSA9VeWM.d.mts} +47 -8
- package/dist/construct-interface-CSA9VeWM.d.mts.map +1 -0
- package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-DugP0E5q.d.cts} +47 -8
- package/dist/construct-interface-DugP0E5q.d.cts.map +1 -0
- package/dist/construct-interface.cjs +38 -4
- package/dist/construct-interface.cjs.map +1 -1
- package/dist/construct-interface.d.cts +2 -2
- package/dist/construct-interface.d.mts +2 -2
- package/dist/construct-interface.mjs +37 -5
- package/dist/construct-interface.mjs.map +1 -1
- package/dist/credential-DYymbp_7.cjs +257 -0
- package/dist/credential-DYymbp_7.cjs.map +1 -0
- package/dist/credential-DfSAOOdY.mjs +222 -0
- package/dist/credential-DfSAOOdY.mjs.map +1 -0
- package/dist/credential.cjs +7 -129
- package/dist/credential.d.cts +2 -58
- package/dist/credential.d.mts +2 -58
- package/dist/credential.mjs +2 -128
- package/dist/crons/index.cjs +126 -1
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +43 -3
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +43 -3
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +125 -2
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +3 -194
- package/dist/database/kysely.d.cts +2 -149
- package/dist/database/kysely.d.mts +2 -149
- package/dist/database/kysely.mjs +2 -192
- package/dist/email.d.cts +1 -1
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +2 -2
- package/dist/email.d.mts.map +1 -1
- package/dist/encryption/kms.cjs +95 -0
- package/dist/encryption/kms.cjs.map +1 -0
- package/dist/encryption/kms.d.cts +7 -0
- package/dist/encryption/kms.d.cts.map +1 -0
- package/dist/encryption/kms.d.mts +7 -0
- package/dist/encryption/kms.d.mts.map +1 -0
- package/dist/encryption/kms.mjs +93 -0
- package/dist/encryption/kms.mjs.map +1 -0
- package/dist/encryption.cjs +116 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +37 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +37 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +101 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +32 -10
- package/dist/endpoints/index.d.cts +106 -3
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +106 -3
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -4
- package/dist/expire-C586zznE.d.cts +38 -0
- package/dist/expire-C586zznE.d.cts.map +1 -0
- package/dist/expire-C586zznE.d.mts +38 -0
- package/dist/expire-C586zznE.d.mts.map +1 -0
- package/dist/expire-CieftS01.cjs +67 -0
- package/dist/expire-CieftS01.cjs.map +1 -0
- package/dist/expire-CpzUAfr9.mjs +50 -0
- package/dist/expire-CpzUAfr9.mjs.map +1 -0
- package/dist/external-api.cjs +106 -0
- package/dist/external-api.cjs.map +1 -0
- package/dist/external-api.d.cts +2 -0
- package/dist/external-api.d.mts +2 -0
- package/dist/external-api.mjs +103 -0
- package/dist/external-api.mjs.map +1 -0
- package/dist/fake-BqhP8RRQ.d.mts +201 -0
- package/dist/fake-BqhP8RRQ.d.mts.map +1 -0
- package/dist/fake-DqieDYYA.d.cts +201 -0
- package/dist/fake-DqieDYYA.d.cts.map +1 -0
- package/dist/file-server.cjs +123 -30
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +115 -1
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +115 -1
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +122 -32
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +1 -1
- package/dist/functions/index.d.cts +2 -1
- package/dist/functions/index.d.mts +2 -1
- package/dist/functions/index.mjs +1 -1
- package/dist/{functions-C53GW2eQ.mjs → functions-BvIDQKAA.mjs} +117 -22
- package/dist/functions-BvIDQKAA.mjs.map +1 -0
- package/dist/{functions-B6qCvfmy.cjs → functions-DLF6-IK8.cjs} +122 -18
- package/dist/functions-DLF6-IK8.cjs.map +1 -0
- package/dist/inbox-CR3L1fOI.d.cts +195 -0
- package/dist/inbox-CR3L1fOI.d.cts.map +1 -0
- package/dist/inbox-CjxpLVkH.d.mts +195 -0
- package/dist/inbox-CjxpLVkH.d.mts.map +1 -0
- package/dist/inbox.cjs +291 -0
- package/dist/inbox.cjs.map +1 -0
- package/dist/inbox.d.cts +2 -0
- package/dist/inbox.d.mts +2 -0
- package/dist/inbox.mjs +283 -0
- package/dist/inbox.mjs.map +1 -0
- package/dist/index-DCkDQkwj.d.mts +115 -0
- package/dist/index-DCkDQkwj.d.mts.map +1 -0
- package/dist/index-DPTHa6Ud.d.cts +115 -0
- package/dist/index-DPTHa6Ud.d.cts.map +1 -0
- package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
- package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
- package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
- package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +26 -3
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +26 -3
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -2
- package/dist/kysely-CebjCWTl.d.cts +216 -0
- package/dist/kysely-CebjCWTl.d.cts.map +1 -0
- package/dist/kysely-Cs4uPO8k.mjs +371 -0
- package/dist/kysely-Cs4uPO8k.mjs.map +1 -0
- package/dist/kysely-CukArHJ0.cjs +384 -0
- package/dist/kysely-CukArHJ0.cjs.map +1 -0
- package/dist/kysely-DE4kADWD.d.mts +216 -0
- package/dist/kysely-DE4kADWD.d.mts.map +1 -0
- package/dist/{telemetry-DGcFlVpB.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +2 -2
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
- package/dist/{telemetry-DGcFlVpB.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +2 -2
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
- package/dist/mobile-app.cjs +74 -0
- package/dist/mobile-app.cjs.map +1 -0
- package/dist/mobile-app.d.cts +73 -0
- package/dist/mobile-app.d.cts.map +1 -0
- package/dist/mobile-app.d.mts +73 -0
- package/dist/mobile-app.d.mts.map +1 -0
- package/dist/mobile-app.mjs +73 -0
- package/dist/mobile-app.mjs.map +1 -0
- package/dist/object-storage.cjs +8 -1
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +10 -1
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +10 -1
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +7 -2
- package/dist/object-storage.mjs.map +1 -1
- package/dist/pattern-C1CEcglD.mjs +241 -0
- package/dist/pattern-C1CEcglD.mjs.map +1 -0
- package/dist/pattern-QFaUIr77.cjs +288 -0
- package/dist/pattern-QFaUIr77.cjs.map +1 -0
- package/dist/processors/index.cjs +214 -0
- package/dist/processors/index.cjs.map +1 -0
- package/dist/processors/index.d.cts +78 -0
- package/dist/processors/index.d.cts.map +1 -0
- package/dist/processors/index.d.mts +78 -0
- package/dist/processors/index.d.mts.map +1 -0
- package/dist/processors/index.mjs +193 -0
- package/dist/processors/index.mjs.map +1 -0
- package/dist/queue/index.cjs +5 -192
- package/dist/queue/index.d.cts +3 -53
- package/dist/queue/index.d.mts +3 -53
- package/dist/queue/index.mjs +3 -190
- package/dist/random-password.cjs +86 -0
- package/dist/random-password.cjs.map +1 -0
- package/dist/random-password.d.cts +30 -0
- package/dist/random-password.d.cts.map +1 -0
- package/dist/random-password.d.mts +30 -0
- package/dist/random-password.d.mts.map +1 -0
- package/dist/random-password.mjs +84 -0
- package/dist/random-password.mjs.map +1 -0
- package/dist/{lazyAccessors-BHtcqgz2.mjs → readRequestBody-BTIl3k-D.mjs} +99 -39
- package/dist/readRequestBody-BTIl3k-D.mjs.map +1 -0
- package/dist/{lazyAccessors-Dx9NLwJZ.cjs → readRequestBody-Dej_L3c4.cjs} +118 -46
- package/dist/readRequestBody-Dej_L3c4.cjs.map +1 -0
- package/dist/requestLogger-BZcXwdBs.cjs +207 -0
- package/dist/requestLogger-BZcXwdBs.cjs.map +1 -0
- package/dist/requestLogger-pA4gi3E1.mjs +178 -0
- package/dist/requestLogger-pA4gi3E1.mjs.map +1 -0
- package/dist/rest-api.cjs +85 -70
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +77 -59
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +77 -59
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +87 -72
- package/dist/rest-api.mjs.map +1 -1
- package/dist/runSubscriber-CC_2C9F2.cjs +133 -0
- package/dist/runSubscriber-CC_2C9F2.cjs.map +1 -0
- package/dist/runSubscriber-DyHWp_Lf.mjs +116 -0
- package/dist/runSubscriber-DyHWp_Lf.mjs.map +1 -0
- package/dist/shutdown-BMJmAhSt.cjs +38 -0
- package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
- package/dist/shutdown-C7xa8x9S.mjs +27 -0
- package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
- package/dist/site.cjs +85 -8
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +98 -2
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +98 -2
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +84 -11
- package/dist/site.mjs.map +1 -1
- package/dist/stages-DaTaoQei.d.cts +73 -0
- package/dist/stages-DaTaoQei.d.cts.map +1 -0
- package/dist/stages-DaTaoQei.d.mts +73 -0
- package/dist/stages-DaTaoQei.d.mts.map +1 -0
- package/dist/subscribers/index.cjs +134 -1
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +74 -3
- package/dist/subscribers/index.d.cts.map +1 -0
- package/dist/subscribers/index.d.mts +74 -3
- package/dist/subscribers/index.d.mts.map +1 -0
- package/dist/subscribers/index.mjs +132 -2
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/telemetry-C1oqncFY.d.cts +40 -0
- package/dist/telemetry-C1oqncFY.d.cts.map +1 -0
- package/dist/telemetry-CObow3Dn.d.mts +40 -0
- package/dist/telemetry-CObow3Dn.d.mts.map +1 -0
- package/dist/telemetry.cjs +56 -0
- package/dist/telemetry.cjs.map +1 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +55 -0
- package/dist/telemetry.mjs.map +1 -0
- package/dist/topic/index.cjs +2 -134
- package/dist/topic/index.d.cts +2 -3
- package/dist/topic/index.d.mts +2 -3
- package/dist/topic/index.mjs +2 -132
- package/dist/tracing-Bbj1uoFJ.mjs +127 -0
- package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
- package/dist/tracing-C0ooU0V2.cjs +150 -0
- package/dist/tracing-C0ooU0V2.cjs.map +1 -0
- package/dist/websocket-api.cjs +951 -0
- package/dist/websocket-api.cjs.map +1 -0
- package/dist/websocket-api.d.cts +556 -0
- package/dist/websocket-api.d.cts.map +1 -0
- package/dist/websocket-api.d.mts +556 -0
- package/dist/websocket-api.d.mts.map +1 -0
- package/dist/websocket-api.mjs +933 -0
- package/dist/websocket-api.mjs.map +1 -0
- package/dist/worker.cjs +174 -32
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +147 -47
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +147 -47
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +175 -33
- package/dist/worker.mjs.map +1 -1
- package/package.json +155 -44
- package/dist/Construct-BeYVu_QF.mjs.map +0 -1
- package/dist/Construct-DfbwIntp.d.cts +0 -115
- package/dist/Construct-DfbwIntp.d.cts.map +0 -1
- package/dist/Construct-DqdlARxq.cjs.map +0 -1
- package/dist/Construct-l5aOn_jv.d.mts +0 -115
- package/dist/Construct-l5aOn_jv.d.mts.map +0 -1
- package/dist/Cron-DKqnnTdH.d.cts.map +0 -1
- package/dist/Cron-SyqS5oWJ.d.mts.map +0 -1
- package/dist/CronBuilder-BdnI6lxF.cjs.map +0 -1
- package/dist/CronBuilder-CRGnDfTq.d.mts +0 -41
- package/dist/CronBuilder-CRGnDfTq.d.mts.map +0 -1
- package/dist/CronBuilder-D_0HNBTr.mjs.map +0 -1
- package/dist/CronBuilder-Df1q9PNy.d.cts +0 -41
- package/dist/CronBuilder-Df1q9PNy.d.cts.map +0 -1
- package/dist/Endpoint-BpZHtJ2W.cjs +0 -1689
- package/dist/Endpoint-BpZHtJ2W.cjs.map +0 -1
- package/dist/Endpoint-C6yyHpRS.d.cts.map +0 -1
- package/dist/Endpoint-DuT4TEEq.d.mts.map +0 -1
- package/dist/Endpoint-ONsly_dq.mjs +0 -1671
- package/dist/Endpoint-ONsly_dq.mjs.map +0 -1
- package/dist/EndpointFactory-Bm3aKRdV.mjs.map +0 -1
- package/dist/EndpointFactory-CLvWuHyt.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-92zavCsV.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-yYaU7jVJ.mjs.map +0 -1
- package/dist/Queue-D9X6OoON.d.mts.map +0 -1
- package/dist/Queue-DYPB2KWL.d.cts.map +0 -1
- package/dist/Subscriber-C4heaAyO.d.mts +0 -51
- package/dist/Subscriber-C4heaAyO.d.mts.map +0 -1
- package/dist/Subscriber-CotDUELC.d.cts +0 -51
- package/dist/Subscriber-CotDUELC.d.cts.map +0 -1
- package/dist/SubscriberBuilder-BEv0eoHy.d.cts +0 -59
- package/dist/SubscriberBuilder-BEv0eoHy.d.cts.map +0 -1
- package/dist/SubscriberBuilder-C0ZEtGDI.cjs +0 -125
- package/dist/SubscriberBuilder-C0ZEtGDI.cjs.map +0 -1
- package/dist/SubscriberBuilder-h7B_cHMr.mjs +0 -114
- package/dist/SubscriberBuilder-h7B_cHMr.mjs.map +0 -1
- package/dist/SubscriberBuilder-tyH5yTk5.d.mts +0 -59
- package/dist/SubscriberBuilder-tyH5yTk5.d.mts.map +0 -1
- package/dist/Topic-DEVGo0Dm.d.cts +0 -89
- package/dist/Topic-DEVGo0Dm.d.cts.map +0 -1
- package/dist/Topic-zk_6Gthr.d.mts +0 -89
- package/dist/Topic-zk_6Gthr.d.mts.map +0 -1
- package/dist/auth.d.cts.map +0 -1
- package/dist/auth.d.mts.map +0 -1
- package/dist/cache.d.cts.map +0 -1
- package/dist/cache.d.mts.map +0 -1
- package/dist/construct-interface-DPlxfpoS.d.mts.map +0 -1
- package/dist/construct-interface-DgXTJcOD.d.cts.map +0 -1
- package/dist/credential.cjs.map +0 -1
- package/dist/credential.d.cts.map +0 -1
- package/dist/credential.d.mts.map +0 -1
- package/dist/credential.mjs.map +0 -1
- package/dist/database/kysely.cjs.map +0 -1
- package/dist/database/kysely.d.cts.map +0 -1
- package/dist/database/kysely.d.mts.map +0 -1
- package/dist/database/kysely.mjs.map +0 -1
- package/dist/functions-B6qCvfmy.cjs.map +0 -1
- package/dist/functions-C53GW2eQ.mjs.map +0 -1
- package/dist/index-B2urf3YI.d.cts +0 -26
- package/dist/index-B2urf3YI.d.cts.map +0 -1
- package/dist/index-BPSZ_Lp_.d.cts.map +0 -1
- package/dist/index-BoZ-iisU.d.mts.map +0 -1
- package/dist/index-CdaU--_B.d.cts +0 -165
- package/dist/index-CdaU--_B.d.cts.map +0 -1
- package/dist/index-DMCDvnsM.d.mts +0 -26
- package/dist/index-DMCDvnsM.d.mts.map +0 -1
- package/dist/index-PQRWOQj4.d.mts +0 -165
- package/dist/index-PQRWOQj4.d.mts.map +0 -1
- package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
- package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
- package/dist/processAudits-BpRlPQMW.mjs +0 -77
- package/dist/processAudits-BpRlPQMW.mjs.map +0 -1
- package/dist/processAudits-D_2W5x8k.cjs +0 -88
- package/dist/processAudits-D_2W5x8k.cjs.map +0 -1
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts.map +0 -1
- package/dist/queue/index.d.mts.map +0 -1
- package/dist/queue/index.mjs.map +0 -1
- package/dist/telemetry-DGcFlVpB.d.cts.map +0 -1
- package/dist/telemetry-DGcFlVpB.d.mts.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
|
@@ -1,21 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
1
|
+
import { isConsumable } from "../construct-interface.mjs";
|
|
2
|
+
import { BetterAuth } from "../auth.mjs";
|
|
3
|
+
import { a as publishEvents, i as publishConstructEvents, t as FunctionBuilder } from "../functions-BvIDQKAA.mjs";
|
|
4
|
+
import { r as ResponseBuilder, t as Endpoint } from "../Endpoint-sUOU7uLx.mjs";
|
|
5
|
+
import { t as Queue } from "../Queue-u8w8_HpE.mjs";
|
|
6
|
+
import { Email } from "../email.mjs";
|
|
7
|
+
import { t as Topic } from "../Topic-DN2gYJ-p.mjs";
|
|
8
|
+
import { t as KyselyDatabase } from "../kysely-Cs4uPO8k.mjs";
|
|
9
|
+
import { f as createObjectHeaders, s as createCookieHeaderAccessor } from "../readRequestBody-BTIl3k-D.mjs";
|
|
10
|
+
import { t as HonoEndpoint } from "../HonoEndpointAdaptor-DR3j7S35.mjs";
|
|
11
|
+
import { i as executeWithAuditTransaction, n as enforceRateLimit, t as requestLogger } from "../requestLogger-pA4gi3E1.mjs";
|
|
12
|
+
import { INBOX_EVENT, WILDCARD_SUBDOMAIN, inboxRecipient, provideKey } from "@geekmidas/manifest";
|
|
13
|
+
import { randomUUID } from "node:crypto";
|
|
14
|
+
import { ServiceDiscovery, currentRequestContext, runWithRequestContext, serviceContext } from "@geekmidas/services";
|
|
6
15
|
import { ForbiddenError } from "@geekmidas/errors";
|
|
7
16
|
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
8
|
-
import { ServiceDiscovery, runWithRequestContext } from "@geekmidas/services";
|
|
9
17
|
import { Hono } from "hono";
|
|
10
18
|
import { DefaultAuditor } from "@geekmidas/audit";
|
|
19
|
+
import { TEST_CONTEXT_HEADER, currentTestContext, installContextFetch, runAsServer, runInTestContext, testContextOf } from "@geekmidas/testkit/context";
|
|
11
20
|
import { http } from "msw";
|
|
12
|
-
|
|
21
|
+
import { Browser } from "@geekmidas/testkit/browser";
|
|
22
|
+
import { faker } from "@geekmidas/testkit/faker";
|
|
23
|
+
import { createMailbox } from "@geekmidas/testkit/mailbox";
|
|
24
|
+
import { TransactionRegistry } from "@geekmidas/testkit/transactions";
|
|
25
|
+
import { setupServer } from "msw/node";
|
|
26
|
+
import { afterAll, beforeAll, test } from "vitest";
|
|
27
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
28
|
+
import tls from "node:tls";
|
|
29
|
+
import { fileURLToPath } from "node:url";
|
|
30
|
+
//#region src/testing/peer.ts
|
|
13
31
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
32
|
+
* The TCP peer a test's in-process requests arrive from.
|
|
33
|
+
*
|
|
34
|
+
* A feature test hands a request straight to a surface's Hono app — no
|
|
35
|
+
* socket, no server — so the app's bindings have no peer to read. Deployed,
|
|
36
|
+
* every request has one, and what a surface trusts follows from it: the auth
|
|
37
|
+
* server honours `x-gkm-client-ip` only from an internal caller, a loopback
|
|
38
|
+
* or private peer with no `Origin` and no forwarding header. With no peer at
|
|
39
|
+
* all the header was dropped, and every test's session check became the same
|
|
40
|
+
* client to Better Auth's rate limiter.
|
|
41
|
+
*
|
|
42
|
+
* So an in-process dispatch says where it came from, the way
|
|
43
|
+
* `@hono/node-server` does: its bindings carry `incoming.socket.remoteAddress`.
|
|
44
|
+
* The address is loopback because that is the truth — the request came from
|
|
45
|
+
* this process. A browser's own address still travels in its
|
|
46
|
+
* `x-forwarded-for`, which makes it outside traffic exactly as it would be
|
|
47
|
+
* behind the stack's proxy.
|
|
48
|
+
*
|
|
49
|
+
* Only a test's dispatch passes these. A runtime with no socket of its own
|
|
50
|
+
* (Lambda, Bun) still has no peer, and a request with no peer is still not an
|
|
51
|
+
* internal caller's.
|
|
17
52
|
*/
|
|
18
|
-
|
|
53
|
+
/** The address an in-process request presents as its peer. */
|
|
54
|
+
const IN_PROCESS_PEER_ADDRESS = "127.0.0.1";
|
|
55
|
+
/** Bindings for `app.fetch(request, bindings)` from inside this process. */
|
|
56
|
+
function inProcessBindings() {
|
|
57
|
+
return { incoming: { socket: { remoteAddress: IN_PROCESS_PEER_ADDRESS } } };
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/endpoints/MswEndpointAdaptor.ts
|
|
19
61
|
const MSW_HTTP_METHODS = [
|
|
20
62
|
"get",
|
|
21
63
|
"post",
|
|
@@ -63,7 +105,6 @@ function createMswHandlers(endpoints, options) {
|
|
|
63
105
|
break;
|
|
64
106
|
}
|
|
65
107
|
}
|
|
66
|
-
if (ctxOptions.publisher) serviceDefs.push(ctxOptions.publisher);
|
|
67
108
|
if (ctxOptions.auditorStorage !== void 0) {
|
|
68
109
|
for (const endpoint of endpoints) if (endpoint.auditorStorageService) {
|
|
69
110
|
serviceDefs.push({
|
|
@@ -94,7 +135,7 @@ function createMswHandlers(endpoints, options) {
|
|
|
94
135
|
});
|
|
95
136
|
const app = new Hono();
|
|
96
137
|
HonoEndpoint.addRoute(endpoint, ctx.serviceDiscovery, app);
|
|
97
|
-
const response = await app.request(request);
|
|
138
|
+
const response = await app.request(request, void 0, inProcessBindings());
|
|
98
139
|
return new Response(response.body, {
|
|
99
140
|
status: response.status,
|
|
100
141
|
statusText: response.statusText,
|
|
@@ -143,17 +184,17 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
143
184
|
const cookie = createCookieHeaderAccessor(ctx.headers.cookie);
|
|
144
185
|
const startTime = Date.now();
|
|
145
186
|
const requestId = ctx.requestId ?? ctx.headers["x-request-id"] ?? crypto.randomUUID();
|
|
146
|
-
|
|
187
|
+
let logger = requestLogger(this.endpoint, {
|
|
147
188
|
requestId,
|
|
148
|
-
|
|
149
|
-
host: ctx.headers.host,
|
|
150
|
-
method: this.endpoint.method
|
|
189
|
+
host: ctx.headers.host
|
|
151
190
|
});
|
|
152
191
|
const rawDb = ctx.database;
|
|
192
|
+
const operation = `${this.endpoint.method} ${this.endpoint.route}`;
|
|
153
193
|
return runWithRequestContext({
|
|
154
194
|
logger,
|
|
155
195
|
requestId,
|
|
156
|
-
startTime
|
|
196
|
+
startTime,
|
|
197
|
+
operation
|
|
157
198
|
}, async () => {
|
|
158
199
|
const session = await this.endpoint.getSession({
|
|
159
200
|
logger,
|
|
@@ -162,6 +203,7 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
162
203
|
cookie,
|
|
163
204
|
...rawDb !== void 0 && { db: rawDb }
|
|
164
205
|
});
|
|
206
|
+
logger = currentRequestContext()?.logger ?? logger;
|
|
165
207
|
if (!await this.endpoint.authorize({
|
|
166
208
|
header,
|
|
167
209
|
cookie,
|
|
@@ -176,6 +218,14 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
176
218
|
logger.warn("Forbidden access attempt");
|
|
177
219
|
throw new ForbiddenError("Forbidden access to the endpoint", "You do not have permission to access this resource.");
|
|
178
220
|
}
|
|
221
|
+
const rateLimitHeaders = this.endpoint.rateLimit ? await enforceRateLimit(this.endpoint.rateLimit, {
|
|
222
|
+
header,
|
|
223
|
+
services: ctx.services,
|
|
224
|
+
logger,
|
|
225
|
+
session,
|
|
226
|
+
path: this.endpoint.route,
|
|
227
|
+
method: this.endpoint.method
|
|
228
|
+
}) : {};
|
|
179
229
|
const auditorStorage = ctx.auditorStorage;
|
|
180
230
|
let auditContext;
|
|
181
231
|
if (auditorStorage) {
|
|
@@ -208,7 +258,7 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
208
258
|
}
|
|
209
259
|
const audits = this.endpoint.audits;
|
|
210
260
|
if (!auditContext && audits?.length) logger.warn("No auditor storage service available");
|
|
211
|
-
const { output, metadata } = await executeWithAuditTransaction(auditContext, async (auditor) => {
|
|
261
|
+
const { output, metadata, redirect } = await executeWithAuditTransaction(auditContext, async (auditor) => {
|
|
212
262
|
const db = auditor?.getTransaction?.() ?? rawDb;
|
|
213
263
|
const responseBuilder = new ResponseBuilder();
|
|
214
264
|
const response = await this.endpoint.handler({
|
|
@@ -229,13 +279,15 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
229
279
|
data = response.data;
|
|
230
280
|
metadata = response.metadata;
|
|
231
281
|
}
|
|
282
|
+
const redirect = Endpoint.isRedirectStatus(metadata.status ?? this.endpoint.status);
|
|
232
283
|
return {
|
|
233
|
-
output: await this.endpoint.parseOutput(data),
|
|
284
|
+
output: redirect ? void 0 : await this.endpoint.parseOutput(data),
|
|
234
285
|
metadata,
|
|
235
|
-
responseBuilder
|
|
286
|
+
responseBuilder,
|
|
287
|
+
redirect
|
|
236
288
|
};
|
|
237
289
|
}, async (result, auditor) => {
|
|
238
|
-
if (!audits?.length) return;
|
|
290
|
+
if (!audits?.length || result.redirect) return;
|
|
239
291
|
for (const audit of audits) {
|
|
240
292
|
if (audit.when && !audit.when(result.output)) continue;
|
|
241
293
|
const payload = audit.payload(result.output);
|
|
@@ -246,9 +298,11 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
246
298
|
});
|
|
247
299
|
}
|
|
248
300
|
}, { db: rawDb });
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
301
|
+
if (!redirect) await publishConstructEvents(this.endpoint, output, this.serviceDiscovery, this.endpoint.logger, ctx.services);
|
|
302
|
+
const headers = {
|
|
303
|
+
...rateLimitHeaders,
|
|
304
|
+
...metadata.headers || {}
|
|
305
|
+
};
|
|
252
306
|
if (metadata.cookies && metadata.cookies.size > 0) {
|
|
253
307
|
const setCookieValues = [];
|
|
254
308
|
for (const [name, cookie] of metadata.cookies.entries()) setCookieValues.push(serializeCookie(name, cookie.value, cookie.options));
|
|
@@ -256,7 +310,7 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
256
310
|
}
|
|
257
311
|
return {
|
|
258
312
|
body: output,
|
|
259
|
-
status: metadata.status
|
|
313
|
+
status: metadata.status ?? this.endpoint.status,
|
|
260
314
|
headers
|
|
261
315
|
};
|
|
262
316
|
});
|
|
@@ -323,7 +377,7 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
|
323
377
|
await auditor.flush();
|
|
324
378
|
}
|
|
325
379
|
}
|
|
326
|
-
await publishEvents(logger, this.serviceDiscovery, this.fn.events, output,
|
|
380
|
+
await publishEvents(logger, this.serviceDiscovery, this.fn.events, output, services);
|
|
327
381
|
return output;
|
|
328
382
|
});
|
|
329
383
|
}
|
|
@@ -333,7 +387,8 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
|
333
387
|
/**
|
|
334
388
|
* In-memory test driver for a {@link Queue} worker. Hand it a batch of messages
|
|
335
389
|
* and it registers the queue's services, runs the handler in a request context,
|
|
336
|
-
* and returns the handler result — no SQS/pg-boss required.
|
|
390
|
+
* and returns the handler result — no SQS/pg-boss required. A queue with a
|
|
391
|
+
* database gets `db` registered from it, or the one the request passes.
|
|
337
392
|
*
|
|
338
393
|
* @example
|
|
339
394
|
* const adapter = new TestQueueAdaptor(ordersQueue);
|
|
@@ -352,17 +407,27 @@ var TestQueueAdaptor = class TestQueueAdaptor {
|
|
|
352
407
|
async invoke(request) {
|
|
353
408
|
const logger = this.queue.logger.child({ test: true });
|
|
354
409
|
const services = request.services ?? await this.serviceDiscovery.register(this.queue.services);
|
|
410
|
+
const db = request.db !== void 0 ? request.db : await this.getDatabase();
|
|
355
411
|
const requestId = `test-${Date.now()}`;
|
|
412
|
+
const startTime = Date.now();
|
|
413
|
+
const operation = `queue ${this.queue.name}`;
|
|
356
414
|
return runWithRequestContext({
|
|
357
415
|
logger,
|
|
358
416
|
requestId,
|
|
359
|
-
startTime
|
|
417
|
+
startTime,
|
|
418
|
+
operation
|
|
360
419
|
}, () => this.queue.handler({
|
|
361
420
|
messages: request.messages,
|
|
362
421
|
services,
|
|
363
|
-
logger
|
|
422
|
+
logger,
|
|
423
|
+
db
|
|
364
424
|
}));
|
|
365
425
|
}
|
|
426
|
+
async getDatabase() {
|
|
427
|
+
const service = this.queue.databaseService;
|
|
428
|
+
if (!service) return void 0;
|
|
429
|
+
return (await this.serviceDiscovery.register([service]))[service.serviceName];
|
|
430
|
+
}
|
|
366
431
|
};
|
|
367
432
|
//#endregion
|
|
368
433
|
//#region src/subscribers/TestSubscriberAdaptor.ts
|
|
@@ -381,18 +446,23 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
|
|
|
381
446
|
let services;
|
|
382
447
|
if (request.services) services = request.services;
|
|
383
448
|
else services = await this.serviceDiscovery.register(this.subscriber.services);
|
|
449
|
+
const db = request.db !== void 0 ? request.db : await this.getDatabase();
|
|
384
450
|
const filteredEvents = this.filterEvents(request.events);
|
|
385
451
|
if (filteredEvents.length === 0) return { batchItemFailures: [] };
|
|
386
452
|
const requestId = `test-${Date.now()}`;
|
|
453
|
+
const startTime = Date.now();
|
|
454
|
+
const operation = `subscriber ${this.subscriber.topicName ?? "test"}`;
|
|
387
455
|
return runWithRequestContext({
|
|
388
456
|
logger,
|
|
389
457
|
requestId,
|
|
390
|
-
startTime
|
|
458
|
+
startTime,
|
|
459
|
+
operation
|
|
391
460
|
}, async () => {
|
|
392
461
|
const result = await this.subscriber.handler({
|
|
393
462
|
events: filteredEvents,
|
|
394
463
|
services,
|
|
395
|
-
logger
|
|
464
|
+
logger,
|
|
465
|
+
db
|
|
396
466
|
});
|
|
397
467
|
let output = result;
|
|
398
468
|
if (this.subscriber.outputSchema && result) {
|
|
@@ -400,16 +470,841 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
|
|
|
400
470
|
if (validationResult.issues) throw new Error("Subscriber output validation failed");
|
|
401
471
|
output = validationResult.value;
|
|
402
472
|
}
|
|
403
|
-
await publishEvents(logger, this.serviceDiscovery, this.subscriber.events, output, this.subscriber.publisherService);
|
|
404
473
|
return output;
|
|
405
474
|
});
|
|
406
475
|
}
|
|
476
|
+
async getDatabase() {
|
|
477
|
+
const service = this.subscriber.databaseService;
|
|
478
|
+
if (!service) return void 0;
|
|
479
|
+
return (await this.serviceDiscovery.register([service]))[service.serviceName];
|
|
480
|
+
}
|
|
407
481
|
filterEvents(events) {
|
|
408
482
|
if (!this.subscriber.subscribedEvents) return events;
|
|
409
483
|
return events.filter((event) => this.subscriber.subscribedEvents.includes(event.type));
|
|
410
484
|
}
|
|
411
485
|
};
|
|
412
486
|
//#endregion
|
|
413
|
-
|
|
487
|
+
//#region src/testing/manifest.ts
|
|
488
|
+
/**
|
|
489
|
+
* The test manifest: what `gkm test` knows about an app, written down for the
|
|
490
|
+
* suite it starts.
|
|
491
|
+
*
|
|
492
|
+
* `gkm test` discovers the constructs, reconciles the test stage and resolves
|
|
493
|
+
* its environment — then, until this existed, threw all of it away and left a
|
|
494
|
+
* test to declare it again by hand. The manifest keeps it: which construct and
|
|
495
|
+
* endpoint is exported where, and the environment the test stage resolved,
|
|
496
|
+
* under the keys the constructs themselves derive. A feature test is built from
|
|
497
|
+
* it, so nothing a test says can drift from what the app declares.
|
|
498
|
+
*/
|
|
499
|
+
/** The environment variable `gkm test` names the manifest in. */
|
|
500
|
+
const TEST_MANIFEST_ENV = "GKM_TEST_MANIFEST";
|
|
501
|
+
/**
|
|
502
|
+
* Read a test manifest: from a path, a `file:` URL, or — given nothing — the
|
|
503
|
+
* one `gkm test` named in `GKM_TEST_MANIFEST`.
|
|
504
|
+
*/
|
|
505
|
+
function loadTestManifest(from) {
|
|
506
|
+
const location = from ?? process.env["GKM_TEST_MANIFEST"];
|
|
507
|
+
if (!location) throw new NoTestManifest();
|
|
508
|
+
trustLocalEdge();
|
|
509
|
+
const path = location instanceof URL || location.startsWith("file:") ? fileURLToPath(location) : location;
|
|
510
|
+
return JSON.parse(readFileSync(path, "utf-8"));
|
|
511
|
+
}
|
|
512
|
+
let trusted = false;
|
|
513
|
+
/**
|
|
514
|
+
* Trust the local edge's certificate authority in this thread.
|
|
515
|
+
*
|
|
516
|
+
* `NODE_EXTRA_CA_CERTS` does it for a process started with it — which a
|
|
517
|
+
* suite started by `gkm test` is, and one started by plain `vitest` or an
|
|
518
|
+
* editor is not: its setup only learns the path once Vitest is running, and a
|
|
519
|
+
* worker *thread* shares that process and keeps a TLS store of its own. Every
|
|
520
|
+
* feature test loads the manifest, so this is the one place each worker passes
|
|
521
|
+
* through.
|
|
522
|
+
*/
|
|
523
|
+
function trustLocalEdge() {
|
|
524
|
+
const certificate = process.env.NODE_EXTRA_CA_CERTS;
|
|
525
|
+
if (trusted || !certificate || !existsSync(certificate)) return;
|
|
526
|
+
trusted = true;
|
|
527
|
+
tls.setDefaultCACertificates([...tls.getCACertificates("default"), readFileSync(certificate, "utf-8")]);
|
|
528
|
+
}
|
|
529
|
+
/** A feature test ran without a manifest to build itself from. */
|
|
530
|
+
var NoTestManifest = class extends Error {
|
|
531
|
+
constructor() {
|
|
532
|
+
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}.`);
|
|
533
|
+
this.name = "NoTestManifest";
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region src/testing/receive.ts
|
|
538
|
+
/** `mailbox.receive` named no recipient. */
|
|
539
|
+
var ReceiveNeedsRecipient = class extends Error {
|
|
540
|
+
constructor() {
|
|
541
|
+
super("mailbox.receive needs `to`: the envelope recipient routes the message to an inbox, and nothing else does.");
|
|
542
|
+
this.name = "ReceiveNeedsRecipient";
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
/** `mailbox.receive` was given fields and a raw message, or neither a sender nor raw. */
|
|
546
|
+
var ReceiveFieldsOrRaw = class extends Error {
|
|
547
|
+
reason;
|
|
548
|
+
constructor(reason) {
|
|
549
|
+
super(reason === "both" ? "mailbox.receive takes either a raw message or the fields to build one (subject, text, html, attachments, headers…), not both: the raw message already says them." : "mailbox.receive needs `from` when it builds the message — or a `raw` message, whose From: it uses.");
|
|
550
|
+
this.reason = reason;
|
|
551
|
+
this.name = "ReceiveFieldsOrRaw";
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
/** No declared inbox receives at the address `mailbox.receive` was given. */
|
|
555
|
+
var NoInboxForAddress = class extends Error {
|
|
556
|
+
address;
|
|
557
|
+
inboxes;
|
|
558
|
+
constructor(address, inboxes) {
|
|
559
|
+
super(inboxes.length === 0 ? `No inbox is declared, so nothing receives at '${address}'.` : `No inbox receives at '${address}'. ${inboxes.map((i) => `'${i}'`).join(", ")} take only their declared addresses on this stage's domain — as the deployed receipt rule does.`);
|
|
560
|
+
this.address = address;
|
|
561
|
+
this.inboxes = inboxes;
|
|
562
|
+
this.name = "NoInboxForAddress";
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
/** An inbox the test can receive for: no Mailpit to deliver to. */
|
|
566
|
+
var InboxNotLocal = class extends Error {
|
|
567
|
+
inbox;
|
|
568
|
+
constructor(inbox) {
|
|
569
|
+
super(`'${inbox}' has no ${provideKey(inbox, "smtpUrl")} in this test's environment, so there is no Mailpit to deliver to. Run it under \`gkm test\`, which resolves it.`);
|
|
570
|
+
this.inbox = inbox;
|
|
571
|
+
this.name = "InboxNotLocal";
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
/** Whether `value` is an inbox construct — by what it declares, so nothing imports one. */
|
|
575
|
+
function isInboxConstruct(value) {
|
|
576
|
+
const candidate = value;
|
|
577
|
+
return typeof candidate?.declare === "function" && typeof candidate.id === "string" && candidate.addressing !== void 0 && candidate.topic !== void 0 && candidate.declare().some((d) => d.kind === "inbox" && d.id === candidate.id);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Deliver `mail` to Mailpit and receive it: each inbox its envelope
|
|
581
|
+
* recipient is addressed to gets the receipt notification, through
|
|
582
|
+
* `publish`.
|
|
583
|
+
*/
|
|
584
|
+
async function receiveInTest(mail, inboxes, env, publish) {
|
|
585
|
+
if (!mail.to) throw new ReceiveNeedsRecipient();
|
|
586
|
+
const fields = mail;
|
|
587
|
+
const built = fields.subject !== void 0 || fields.text !== void 0 || fields.html !== void 0 || fields.attachments !== void 0 || fields.headers !== void 0 || fields.headerTo !== void 0 || fields.cc !== void 0 || fields.replyTo !== void 0;
|
|
588
|
+
if (mail.raw !== void 0 && built) throw new ReceiveFieldsOrRaw("both");
|
|
589
|
+
const addressed = inboxes.filter((inbox) => {
|
|
590
|
+
const domain = env[provideKey(inbox.id, "domain")];
|
|
591
|
+
return domain && inboxRecipient(mail.to, inbox.addressing, domain);
|
|
592
|
+
});
|
|
593
|
+
if (addressed.length === 0) throw new NoInboxForAddress(mail.to, inboxes.map((inbox) => inbox.id));
|
|
594
|
+
const { composeEmail, deliverRaw, parseEmail } = await import("@geekmidas/emailkit/inbound");
|
|
595
|
+
const { receiveMail } = await import("../inbox.mjs");
|
|
596
|
+
let raw;
|
|
597
|
+
let from;
|
|
598
|
+
if (mail.raw !== void 0) {
|
|
599
|
+
raw = mail.raw;
|
|
600
|
+
const sender = mail.from ?? (await parseEmail(raw)).from?.address;
|
|
601
|
+
if (!sender) throw new ReceiveFieldsOrRaw("no-sender");
|
|
602
|
+
from = sender;
|
|
603
|
+
} else {
|
|
604
|
+
if (!fields.from) throw new ReceiveFieldsOrRaw("no-sender");
|
|
605
|
+
from = fields.from;
|
|
606
|
+
raw = await composeEmail({
|
|
607
|
+
from: fields.from,
|
|
608
|
+
to: fields.headerTo ?? mail.to,
|
|
609
|
+
...fields.cc !== void 0 ? { cc: fields.cc } : {},
|
|
610
|
+
...fields.replyTo ? { replyTo: fields.replyTo } : {},
|
|
611
|
+
...fields.subject !== void 0 ? { subject: fields.subject } : {},
|
|
612
|
+
...fields.text !== void 0 ? { text: fields.text } : {},
|
|
613
|
+
...fields.html !== void 0 ? { html: fields.html } : {},
|
|
614
|
+
...fields.attachments ? { attachments: fields.attachments } : {},
|
|
615
|
+
...fields.headers ? { headers: fields.headers } : {}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
const smtp = env[provideKey(addressed[0].id, "smtpUrl")];
|
|
619
|
+
if (!smtp) throw new InboxNotLocal(addressed[0].id);
|
|
620
|
+
return receiveMail({
|
|
621
|
+
key: await deliverRaw(smtp, {
|
|
622
|
+
from,
|
|
623
|
+
to: [mail.to]
|
|
624
|
+
}, raw),
|
|
625
|
+
store: "mailpit",
|
|
626
|
+
from,
|
|
627
|
+
recipients: [mail.to],
|
|
628
|
+
...mail.verdicts ? { verdicts: mail.verdicts } : {}
|
|
629
|
+
}, addressed.map((inbox) => ({
|
|
630
|
+
id: inbox.id,
|
|
631
|
+
addressing: inbox.addressing,
|
|
632
|
+
domain: env[provideKey(inbox.id, "domain")],
|
|
633
|
+
publish: (notification) => publish(inbox, notification)
|
|
634
|
+
})));
|
|
635
|
+
}
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/testing/featureTest.ts
|
|
638
|
+
/**
|
|
639
|
+
* `featureTest`: an app, driven the way it runs deployed.
|
|
640
|
+
*
|
|
641
|
+
* A browser signs in and calls the API; the API calls the auth server; each
|
|
642
|
+
* over its URL, each database in its own transaction. Nothing runs as a server:
|
|
643
|
+
* every URL an app's constructs answer on is served in-process through MSW,
|
|
644
|
+
* from the real handler, for the test that made the request. Everything else
|
|
645
|
+
* with a real local equivalent — Postgres, Mailpit, MinIO — is used directly.
|
|
646
|
+
*
|
|
647
|
+
* It is built from the test manifest `gkm test` writes — the constructs and
|
|
648
|
+
* endpoints the app exports, and the environment the test stage resolved — so
|
|
649
|
+
* a test declares none of it. `gkm test` also generates the configured `it`
|
|
650
|
+
* and a `Browser` with a typed client per surface:
|
|
651
|
+
*
|
|
652
|
+
* ```ts
|
|
653
|
+
* import { it } from '#test';
|
|
654
|
+
*
|
|
655
|
+
* it('shows the signed-in user their profile', async ({ browser, mailbox }) => {
|
|
656
|
+
* await browser.auth.signIn.magicLink({ email: 'ada@shop.test' });
|
|
657
|
+
* await browser.visit((await mailbox('ada@shop.test').last()).link!);
|
|
658
|
+
* expect(await browser.api.get('/profile')).toMatchObject({ email: 'ada@shop.test' });
|
|
659
|
+
* });
|
|
660
|
+
* ```
|
|
661
|
+
*/
|
|
662
|
+
/** Every test in flight in this process, by id. */
|
|
663
|
+
const contexts = /* @__PURE__ */ new Map();
|
|
664
|
+
/** Databases already resolving to test transactions — patched once each. */
|
|
665
|
+
const bound = /* @__PURE__ */ new WeakSet();
|
|
666
|
+
function featureTest(options = {}) {
|
|
667
|
+
const manifest = options.manifest ?? loadTestManifest();
|
|
668
|
+
const BrowserClass = options.browser ?? Browser;
|
|
669
|
+
const site = wildcardSiteUrl(manifest);
|
|
670
|
+
let app;
|
|
671
|
+
let factoryDatabases = [];
|
|
672
|
+
let owned = [];
|
|
673
|
+
let network;
|
|
674
|
+
let restoreFetch = () => {};
|
|
675
|
+
beforeAll(async () => {
|
|
676
|
+
app = await load(manifest, options.modules ?? {});
|
|
677
|
+
owned = ownDatabases(app, manifest);
|
|
678
|
+
factoryDatabases = databasesFor(options.factories ?? {}, owned);
|
|
679
|
+
for (const database of app.databases) bindToTests(database);
|
|
680
|
+
network = setupServer(...surfaceHandlers(app.endpoints, manifest.env), ...app.auths.map((auth) => authHandler(auth, manifest.env, app.envParser)), ...Object.entries(options.fakes ?? {}).flatMap(([id, fake]) => fakeHandler(id, fake, manifest.env)));
|
|
681
|
+
network.listen({ onUnhandledRequest(request, print) {
|
|
682
|
+
if (isLocal(new URL(request.url))) return;
|
|
683
|
+
print.error();
|
|
684
|
+
} });
|
|
685
|
+
const restoreStamp = installContextFetch();
|
|
686
|
+
const stamped = globalThis.fetch;
|
|
687
|
+
globalThis.fetch = deliveringFetch(stamped, (id) => {
|
|
688
|
+
const state = contexts.get(id);
|
|
689
|
+
return state ? deliver(app, state, id) : Promise.resolve();
|
|
690
|
+
});
|
|
691
|
+
restoreFetch = () => {
|
|
692
|
+
globalThis.fetch = stamped;
|
|
693
|
+
restoreStamp();
|
|
694
|
+
};
|
|
695
|
+
});
|
|
696
|
+
afterAll(() => {
|
|
697
|
+
restoreFetch();
|
|
698
|
+
network?.close();
|
|
699
|
+
});
|
|
700
|
+
const run = (name, fn) => async () => {
|
|
701
|
+
const id = randomUUID();
|
|
702
|
+
faker.seed(seedOf(name));
|
|
703
|
+
const state = {
|
|
704
|
+
transactions: new TransactionRegistry(),
|
|
705
|
+
discovery: new ServiceDiscovery(app.envParser),
|
|
706
|
+
surfaces: /* @__PURE__ */ new Map(),
|
|
707
|
+
auth: /* @__PURE__ */ new Map(),
|
|
708
|
+
addresses: /* @__PURE__ */ new Set(),
|
|
709
|
+
published: /* @__PURE__ */ new Map(),
|
|
710
|
+
pending: [],
|
|
711
|
+
delivering: false
|
|
712
|
+
};
|
|
713
|
+
const readMail = app.readMail;
|
|
714
|
+
if (readMail) state.mailbox = (address) => {
|
|
715
|
+
state.addresses.add(address);
|
|
716
|
+
return readMail(address);
|
|
717
|
+
};
|
|
718
|
+
contexts.set(id, state);
|
|
719
|
+
await state.discovery.register(recorders(app.channels, state));
|
|
720
|
+
await state.discovery.register(watchers(app, state));
|
|
721
|
+
try {
|
|
722
|
+
await runInTestContext(id, async () => {
|
|
723
|
+
const browser = new BrowserClass(site ? { site } : {});
|
|
724
|
+
const restore = browser.install();
|
|
725
|
+
try {
|
|
726
|
+
const transaction = (database) => state.transactions.get(database.id, urlOf(database, app.envParser), database.clientConfig);
|
|
727
|
+
const db = { get: (name) => {
|
|
728
|
+
const database = owned.find((candidate) => candidate.service.serviceName === name);
|
|
729
|
+
if (!database) throw new UnknownDatabase(name, owned.map((candidate) => candidate.service.serviceName));
|
|
730
|
+
return transaction(database);
|
|
731
|
+
} };
|
|
732
|
+
const built = /* @__PURE__ */ new Map();
|
|
733
|
+
await fn({
|
|
734
|
+
browser,
|
|
735
|
+
db,
|
|
736
|
+
factories: { get: (name) => {
|
|
737
|
+
const database = factoryDatabases.find(([candidate]) => candidate === name)?.[1];
|
|
738
|
+
if (!database) throw new UnknownFactory(name, factoryDatabases.map(([candidate]) => candidate));
|
|
739
|
+
let factory = built.get(name);
|
|
740
|
+
if (!factory) {
|
|
741
|
+
factory = transaction(database).then(options.factories[name]);
|
|
742
|
+
built.set(name, factory);
|
|
743
|
+
}
|
|
744
|
+
return factory;
|
|
745
|
+
} },
|
|
746
|
+
faker,
|
|
747
|
+
mailbox: Object.assign((address) => {
|
|
748
|
+
if (!state.mailbox) throw new NoInbox();
|
|
749
|
+
return state.mailbox(address);
|
|
750
|
+
}, { receive: async (mail) => {
|
|
751
|
+
await receiveInTest(mail, app.inboxes, app.env, async (inbox, notification) => {
|
|
752
|
+
state.pending.push({
|
|
753
|
+
channel: inbox.topic,
|
|
754
|
+
messages: [{
|
|
755
|
+
type: INBOX_EVENT,
|
|
756
|
+
payload: notification
|
|
757
|
+
}]
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
await deliver(app, state, id);
|
|
761
|
+
} }),
|
|
762
|
+
published: (channel) => [...state.published.get(channel.id) ?? []],
|
|
763
|
+
services: { get: (name) => resolveService(app, state, name) },
|
|
764
|
+
subscriber: (subscriber) => thenDeliver(new TestSubscriberAdaptor(subscriber, state.discovery), () => deliver(app, state, id)),
|
|
765
|
+
queue: (queue) => thenDeliver(new TestQueueAdaptor(queue, state.discovery), () => deliver(app, state, id)),
|
|
766
|
+
objects: (bucket) => ({ emit: async (...events) => {
|
|
767
|
+
const watched = app.watched.find((candidate) => candidate.id === bucket.id);
|
|
768
|
+
if (!watched) throw new BucketNotWatched(bucket.id);
|
|
769
|
+
const name = bucketName(watched, app.envParser);
|
|
770
|
+
state.pending.push({
|
|
771
|
+
channel: watched,
|
|
772
|
+
messages: events.map(({ type, ...object }) => ({
|
|
773
|
+
type,
|
|
774
|
+
payload: {
|
|
775
|
+
bucket: name,
|
|
776
|
+
...object
|
|
777
|
+
}
|
|
778
|
+
}))
|
|
779
|
+
});
|
|
780
|
+
await deliver(app, state, id);
|
|
781
|
+
} })
|
|
782
|
+
});
|
|
783
|
+
} finally {
|
|
784
|
+
restore();
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
} finally {
|
|
788
|
+
contexts.delete(id);
|
|
789
|
+
await Promise.all([state.transactions.rollbackAll(), ...[...state.addresses].map((address) => app.readMail?.(address).clear())]);
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
const it = ((name, fn, timeout) => test(name, run(name, fn), timeout));
|
|
793
|
+
it.only = (name, fn, timeout) => test.only(name, run(name, fn), timeout);
|
|
794
|
+
it.skip = (name, fn, timeout) => test.skip(name, run(name, fn), timeout);
|
|
795
|
+
return it;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* A test's faker seed, from its name: the same test draws the same data on
|
|
799
|
+
* every run, and two tests draw different data.
|
|
800
|
+
*/
|
|
801
|
+
function seedOf(name) {
|
|
802
|
+
let hash = 0;
|
|
803
|
+
for (const char of name) hash = Math.imul(hash, 31) + char.charCodeAt(0) | 0;
|
|
804
|
+
return hash >>> 0;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Import what the manifest points at.
|
|
808
|
+
*
|
|
809
|
+
* The same modules the app runs, so a construct here *is* the app's construct —
|
|
810
|
+
* the one its endpoints were built from — never a copy declared again.
|
|
811
|
+
*/
|
|
812
|
+
async function load(manifest, modules) {
|
|
813
|
+
const envParser = new EnvironmentParser({ ...manifest.env });
|
|
814
|
+
const imported = async ({ file, export: name }) => (modules[file] ?? await import(file))[name];
|
|
815
|
+
const constructs = await Promise.all(Object.values(manifest.constructs).map(({ source }) => imported(source)));
|
|
816
|
+
const endpoints = (await Promise.all(manifest.endpoints.map(({ source }) => imported(source)))).filter((value) => Endpoint.isEndpoint(value));
|
|
817
|
+
const subscribers = (await Promise.all((manifest.subscribers ?? []).map(async ({ source }) => ({
|
|
818
|
+
name: source.export,
|
|
819
|
+
subscriber: await imported(source)
|
|
820
|
+
})))).filter((entry) => entry.subscriber?.__IS_SUBSCRIBER__ === true);
|
|
821
|
+
const unique = (values) => [...new Set(values)];
|
|
822
|
+
const databases = unique(constructs.filter((value) => value instanceof KyselyDatabase));
|
|
823
|
+
const auths = unique(constructs.filter((value) => value instanceof BetterAuth));
|
|
824
|
+
const emails = unique(constructs.filter((value) => value instanceof Email));
|
|
825
|
+
const consumables = unique(constructs.filter(isConsumable));
|
|
826
|
+
const channels = unique(constructs.filter((value) => value instanceof Topic || value instanceof Queue));
|
|
827
|
+
const watched = unique(constructs.filter((value) => isBucket(value) && subscribers.some(({ subscriber }) => subscriber.bucketName === value.id)));
|
|
828
|
+
const inboxes = unique(constructs.filter(isInboxConstruct));
|
|
829
|
+
const inbox = emails.map((email) => manifest.env[provideKey(email.id, "inboxUrl")]).find(Boolean);
|
|
830
|
+
return {
|
|
831
|
+
envParser,
|
|
832
|
+
endpoints,
|
|
833
|
+
databases,
|
|
834
|
+
auths,
|
|
835
|
+
emails,
|
|
836
|
+
channels,
|
|
837
|
+
watched,
|
|
838
|
+
inboxes,
|
|
839
|
+
env: manifest.env,
|
|
840
|
+
consumables,
|
|
841
|
+
subscribers,
|
|
842
|
+
...inbox ? { readMail: createMailbox({ inbox }) } : {}
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* A publisher that records rather than sends, under the name a topic or queue
|
|
847
|
+
* is injected by — `services.users` — which is also the one `.event(users, …)`
|
|
848
|
+
* publishes through.
|
|
849
|
+
*/
|
|
850
|
+
function recorders(channels, state) {
|
|
851
|
+
return channels.map((channel) => {
|
|
852
|
+
const publisher = { async publish(messages) {
|
|
853
|
+
const sent = messages.map(({ type, payload }) => ({
|
|
854
|
+
type,
|
|
855
|
+
payload
|
|
856
|
+
}));
|
|
857
|
+
state.published.set(channel.id, [...state.published.get(channel.id) ?? [], ...sent]);
|
|
858
|
+
state.pending.push({
|
|
859
|
+
channel,
|
|
860
|
+
messages: sent
|
|
861
|
+
});
|
|
862
|
+
} };
|
|
863
|
+
return {
|
|
864
|
+
serviceName: channel.service.serviceName,
|
|
865
|
+
register: () => publisher
|
|
866
|
+
};
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* The databases a test is handed: the app's own. A schema tenant an auth server
|
|
871
|
+
* owns is reached through that server, as the app reaches it, and a reader is
|
|
872
|
+
* the same database through a read-only role — neither is another database to
|
|
873
|
+
* test against.
|
|
874
|
+
*/
|
|
875
|
+
function ownDatabases(app, manifest) {
|
|
876
|
+
const owners = new Set(app.auths.map((auth) => auth.databaseId));
|
|
877
|
+
return app.databases.filter((database) => !owners.has(database.id) && manifest.constructs[database.id]?.kind !== "database-reader");
|
|
878
|
+
}
|
|
879
|
+
/** Each factory's database, found by the service name it is keyed by. */
|
|
880
|
+
function databasesFor(factories, databases) {
|
|
881
|
+
return Object.keys(factories).map((name) => {
|
|
882
|
+
const database = databases.find((candidate) => candidate.service.serviceName === name);
|
|
883
|
+
if (!database) throw new UnknownFactory(name, databases.map((candidate) => candidate.service.serviceName));
|
|
884
|
+
return [name, database];
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Make a database resolve, inside a test, to that test's transaction.
|
|
889
|
+
*
|
|
890
|
+
* Everything reaches a database through its service — an endpoint through
|
|
891
|
+
* service discovery, the auth server through its tenant directly — so this is
|
|
892
|
+
* the one place a test's connection can be handed over. Outside a test it is
|
|
893
|
+
* the database it always was.
|
|
894
|
+
*/
|
|
895
|
+
/** Rounds of delivery before a chain of consumers is called a loop. */
|
|
896
|
+
const MAX_DELIVERY_ROUNDS = 25;
|
|
897
|
+
/**
|
|
898
|
+
* Deliver what this test published, in-process, as the broker would — and
|
|
899
|
+
* keep delivering what the consumers publish in turn, until nothing is left.
|
|
900
|
+
*
|
|
901
|
+
* - A queue's messages go to its one consumer, as a batch.
|
|
902
|
+
* - A topic's events go to every subscriber that named their type, and only
|
|
903
|
+
* those: fan-out, as the filter policy (SNS) or the per-subscriber queue
|
|
904
|
+
* (pg-boss) does it.
|
|
905
|
+
* - Each payload is checked against the consumer's schema first. Turning an
|
|
906
|
+
* SNS envelope or an SQS record into `{ type, payload }` is each adaptor's
|
|
907
|
+
* job and tested there; what is tested here is what the handler is handed.
|
|
908
|
+
* - Consumers run as the server side of this test, so their databases are
|
|
909
|
+
* this test's transactions and their writes roll back with it.
|
|
910
|
+
* - A consumer that throws fails the test. Deployed, the message would be
|
|
911
|
+
* retried; here a retry would only hide the bug.
|
|
912
|
+
*/
|
|
913
|
+
async function deliver(app, state, id) {
|
|
914
|
+
if (state.delivering) return;
|
|
915
|
+
state.delivering = true;
|
|
916
|
+
try {
|
|
917
|
+
for (let round = 0; state.pending.length > 0; round++) {
|
|
918
|
+
if (round === MAX_DELIVERY_ROUNDS) throw new DeliveryDidNotSettle(MAX_DELIVERY_ROUNDS, [...new Set(state.pending.map(({ channel }) => channel.id))]);
|
|
919
|
+
for (const { channel, messages } of state.pending.splice(0)) if (channel instanceof Queue) await toQueue(channel, messages, state, id);
|
|
920
|
+
else if (channel instanceof Topic) await toSubscribers(channel, messages, app, state, id);
|
|
921
|
+
else await toObjectSubscribers(channel, messages, app, state, id);
|
|
922
|
+
}
|
|
923
|
+
} finally {
|
|
924
|
+
state.delivering = false;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
async function toQueue(queue, messages, state, id) {
|
|
928
|
+
const payloads = [];
|
|
929
|
+
for (const message of messages) payloads.push(await accepted(queue.messageSchema, message, `queue '${queue.name}'`));
|
|
930
|
+
await runAsServer(id, () => new TestQueueAdaptor(queue, state.discovery).invoke({ messages: payloads })).catch((error) => {
|
|
931
|
+
throw new DeliveryFailed(`queue '${queue.name}'`, messages, error);
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
async function toSubscribers(topic, messages, app, state, id) {
|
|
935
|
+
for (const { name, subscriber } of app.subscribers) {
|
|
936
|
+
if (subscriber.topicName !== topic.name) continue;
|
|
937
|
+
const named = messages.filter(({ type }) => (subscriber.subscribedEvents ?? []).includes(type));
|
|
938
|
+
if (named.length === 0) continue;
|
|
939
|
+
const consumer = `subscriber '${name}'`;
|
|
940
|
+
const events = [];
|
|
941
|
+
for (const message of named) {
|
|
942
|
+
const schema = topic.eventSchemas[message.type];
|
|
943
|
+
events.push({
|
|
944
|
+
type: message.type,
|
|
945
|
+
payload: await accepted(schema, message, consumer)
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
await runAsServer(id, () => new TestSubscriberAdaptor(subscriber, state.discovery).invoke({ events })).catch((error) => {
|
|
949
|
+
throw new DeliveryFailed(consumer, named, error);
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* A bucket's changes to each subscriber bound to it that named their type —
|
|
955
|
+
* the subscriber keeps the keys it watches, as it does deployed.
|
|
956
|
+
*/
|
|
957
|
+
async function toObjectSubscribers(bucket, messages, app, state, id) {
|
|
958
|
+
for (const { name, subscriber } of app.subscribers) {
|
|
959
|
+
if (subscriber.bucketName !== bucket.id) continue;
|
|
960
|
+
const named = messages.filter(({ type }) => (subscriber.subscribedEvents ?? []).includes(type));
|
|
961
|
+
if (named.length === 0) continue;
|
|
962
|
+
const consumer = `subscriber '${name}'`;
|
|
963
|
+
await runAsServer(id, () => new TestSubscriberAdaptor(subscriber, state.discovery).invoke({ events: named })).catch((error) => {
|
|
964
|
+
throw new DeliveryFailed(consumer, named, error);
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* A client for each watched bucket that reports what it writes: the real
|
|
970
|
+
* client — the test's MinIO — under the name the bucket is injected by, so
|
|
971
|
+
* an upload a handler makes reaches the bucket's subscribers as the storage
|
|
972
|
+
* would report it.
|
|
973
|
+
*/
|
|
974
|
+
function watchers(app, state) {
|
|
975
|
+
return app.watched.map((bucket) => ({
|
|
976
|
+
serviceName: bucket.service.serviceName,
|
|
977
|
+
register: async (options) => {
|
|
978
|
+
const client = await bucket.service.register(options);
|
|
979
|
+
const name = bucketName(bucket, app.envParser);
|
|
980
|
+
const report = async (message) => {
|
|
981
|
+
state.pending.push({
|
|
982
|
+
channel: bucket,
|
|
983
|
+
messages: [message]
|
|
984
|
+
});
|
|
985
|
+
const context = currentTestContext();
|
|
986
|
+
if (context?.side === "client") await deliver(app, state, context.id);
|
|
987
|
+
};
|
|
988
|
+
const watching = Object.create(client);
|
|
989
|
+
watching.upload = async (key, data, contentType) => {
|
|
990
|
+
await client.upload(key, data, contentType);
|
|
991
|
+
await report({
|
|
992
|
+
type: "object.created",
|
|
993
|
+
payload: {
|
|
994
|
+
bucket: name,
|
|
995
|
+
key,
|
|
996
|
+
size: byteLength(data)
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
};
|
|
1000
|
+
watching.delete = async (key) => {
|
|
1001
|
+
await client.delete(key);
|
|
1002
|
+
await report({
|
|
1003
|
+
type: "object.deleted",
|
|
1004
|
+
payload: {
|
|
1005
|
+
bucket: name,
|
|
1006
|
+
key
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
};
|
|
1010
|
+
return watching;
|
|
1011
|
+
}
|
|
1012
|
+
}));
|
|
1013
|
+
}
|
|
1014
|
+
/** The bucket's name as the storage knows it — the host of its URL. */
|
|
1015
|
+
function bucketName(bucket, envParser) {
|
|
1016
|
+
const { url } = envParser.create((get) => ({ url: get(provideKey(bucket.id, "url")).string() })).parse();
|
|
1017
|
+
try {
|
|
1018
|
+
return new URL(url).hostname || bucket.id;
|
|
1019
|
+
} catch {
|
|
1020
|
+
return bucket.id;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
function byteLength(data) {
|
|
1024
|
+
return typeof data === "string" ? Buffer.byteLength(data) : data.length;
|
|
1025
|
+
}
|
|
1026
|
+
/** An `ObjectStorage`, recognised by what it declares — never by importing it. */
|
|
1027
|
+
function isBucket(value) {
|
|
1028
|
+
const declare = value?.declare;
|
|
1029
|
+
return typeof declare === "function" && declare.call(value)[0]?.kind === "objects";
|
|
1030
|
+
}
|
|
1031
|
+
/** `objects(bucket)` named a bucket no subscriber in the app is bound to. */
|
|
1032
|
+
var BucketNotWatched = class extends Error {
|
|
1033
|
+
bucket;
|
|
1034
|
+
constructor(bucket) {
|
|
1035
|
+
super(`No subscriber is bound to '${bucket}', so nothing receives what is emitted on it. Bind one — worker.objects(${bucket.charAt(0).toLowerCase()}${bucket.slice(1)}) — or check the test manifest lists it.`);
|
|
1036
|
+
this.bucket = bucket;
|
|
1037
|
+
this.name = "BucketNotWatched";
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
/** The payload, if the consumer's schema takes it — what the handler is handed. */
|
|
1041
|
+
async function accepted(schema, message, consumer) {
|
|
1042
|
+
const standard = schema?.["~standard"];
|
|
1043
|
+
if (!standard) return message.payload;
|
|
1044
|
+
const result = await standard.validate(message.payload);
|
|
1045
|
+
if (result.issues) throw new MessageRejected(consumer, message, result.issues);
|
|
1046
|
+
return result.value;
|
|
1047
|
+
}
|
|
1048
|
+
/** `fetch`, delivering what the test published once each of its requests answers. */
|
|
1049
|
+
function deliveringFetch(inner, settle) {
|
|
1050
|
+
return async (input, init) => {
|
|
1051
|
+
const context = currentTestContext();
|
|
1052
|
+
const response = await inner(input, init);
|
|
1053
|
+
if (context?.side === "client") await settle(context.id);
|
|
1054
|
+
return response;
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
/** An adaptor whose `invoke` delivers what it published before returning. */
|
|
1058
|
+
function thenDeliver(adaptor, settle) {
|
|
1059
|
+
const invoke = adaptor.invoke.bind(adaptor);
|
|
1060
|
+
adaptor.invoke = (async (...args) => {
|
|
1061
|
+
const result = await invoke(...args);
|
|
1062
|
+
await settle();
|
|
1063
|
+
return result;
|
|
1064
|
+
});
|
|
1065
|
+
return adaptor;
|
|
1066
|
+
}
|
|
1067
|
+
function bindToTests(database) {
|
|
1068
|
+
if (bound.has(database)) return;
|
|
1069
|
+
bound.add(database);
|
|
1070
|
+
const service = database.service;
|
|
1071
|
+
const register = service.register;
|
|
1072
|
+
service.register = (options) => {
|
|
1073
|
+
const context = currentTestContext();
|
|
1074
|
+
const state = context && contexts.get(context.id);
|
|
1075
|
+
if (!state) return register(options);
|
|
1076
|
+
return state.transactions.get(database.id, urlOf(database, options.envParser), database.clientConfig);
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
function urlOf(database, envParser) {
|
|
1080
|
+
return envParser.create((get) => ({ url: get(provideKey(database.id, "url")).string() })).parse().url;
|
|
1081
|
+
}
|
|
1082
|
+
/** Each surface's endpoints, served at its URL for the test that asked. */
|
|
1083
|
+
function surfaceHandlers(endpoints, env) {
|
|
1084
|
+
const bySurface = /* @__PURE__ */ new Map();
|
|
1085
|
+
for (const endpoint of endpoints) {
|
|
1086
|
+
const surface = endpoint.surface?.id;
|
|
1087
|
+
if (!surface) continue;
|
|
1088
|
+
bySurface.set(surface, [...bySurface.get(surface) ?? [], endpoint]);
|
|
1089
|
+
}
|
|
1090
|
+
return [...bySurface].flatMap(([surface, served]) => {
|
|
1091
|
+
const base = env[provideKey(surface, "url")];
|
|
1092
|
+
if (!base) return [];
|
|
1093
|
+
return http.all(`${trim(base)}/*`, ({ request }) => serve(request, async (state) => {
|
|
1094
|
+
let app = state.surfaces.get(surface);
|
|
1095
|
+
if (!app) {
|
|
1096
|
+
app = Promise.resolve().then(() => {
|
|
1097
|
+
const hono = new Hono();
|
|
1098
|
+
HonoEndpoint.addRoutes(served, state.discovery, hono);
|
|
1099
|
+
return hono;
|
|
1100
|
+
});
|
|
1101
|
+
state.surfaces.set(surface, app);
|
|
1102
|
+
}
|
|
1103
|
+
return (await app).fetch(request, inProcessBindings());
|
|
1104
|
+
}));
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* An external API's app fake, answering at the URL the test stage resolved for
|
|
1109
|
+
* it — so a handler that calls Polar calls the fake, and the test sets up
|
|
1110
|
+
* nothing.
|
|
1111
|
+
*
|
|
1112
|
+
* Not per test, unlike a surface: a fake stands in for somebody else's server,
|
|
1113
|
+
* which no test's transaction reaches. An image fake has no handler here — its
|
|
1114
|
+
* container answers on localhost, which is let through.
|
|
1115
|
+
*/
|
|
1116
|
+
function fakeHandler(id, fake, env) {
|
|
1117
|
+
const base = env[provideKey(id, "url")];
|
|
1118
|
+
if (fake.kind !== "app" || !base) return [];
|
|
1119
|
+
return [http.all(`${trim(base)}/*`, ({ request }) => fake.handler.fetch(request))];
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* A construct's client for this test, by service name — through the test's own
|
|
1123
|
+
* discovery, so a topic or queue is its recorder and a database its
|
|
1124
|
+
* transaction, exactly as the test's endpoints get them.
|
|
1125
|
+
*/
|
|
1126
|
+
async function resolveService(app, state, name) {
|
|
1127
|
+
const construct = app.consumables.find((candidate) => candidate.service.serviceName === name);
|
|
1128
|
+
if (!construct) throw new UnknownService(name, app.consumables.map((candidate) => candidate.service.serviceName));
|
|
1129
|
+
return (await state.discovery.register([construct.service]))[name];
|
|
1130
|
+
}
|
|
1131
|
+
/** An auth server, served at its URL, on the transaction of the test that asked. */
|
|
1132
|
+
function authHandler(auth, env, envParser) {
|
|
1133
|
+
const base = trim(env[provideKey(auth.id, "url")] ?? "");
|
|
1134
|
+
return http.all(`${base}/*`, ({ request }) => serve(request, async (state) => {
|
|
1135
|
+
let app = state.auth.get(auth);
|
|
1136
|
+
if (!app) {
|
|
1137
|
+
app = auth.server({
|
|
1138
|
+
envParser,
|
|
1139
|
+
context: serviceContext
|
|
1140
|
+
}).then(({ app }) => app);
|
|
1141
|
+
state.auth.set(auth, app);
|
|
1142
|
+
}
|
|
1143
|
+
return (await app).fetch(request, inProcessBindings());
|
|
1144
|
+
}));
|
|
1145
|
+
}
|
|
1146
|
+
/** Handle a request as the server side of the test it was made for. */
|
|
1147
|
+
async function serve(request, handle) {
|
|
1148
|
+
const id = testContextOf(request);
|
|
1149
|
+
const state = id ? contexts.get(id) : void 0;
|
|
1150
|
+
if (!id || !state) throw new UnknownTestContext(request.url, id);
|
|
1151
|
+
return runAsServer(id, () => handle(state));
|
|
1152
|
+
}
|
|
1153
|
+
function trim(url) {
|
|
1154
|
+
return url.replace(/\/$/, "");
|
|
1155
|
+
}
|
|
1156
|
+
function isLocal(url) {
|
|
1157
|
+
return url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname.endsWith(".localhost");
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* The test stage's address for the app's site on every subdomain —
|
|
1161
|
+
* `https://*.test.shop.localhost:8443` — which `browser.on(slug)` puts a
|
|
1162
|
+
* tenant into, or `undefined` when the app declares none.
|
|
1163
|
+
*/
|
|
1164
|
+
function wildcardSiteUrl(manifest) {
|
|
1165
|
+
for (const [id, construct] of Object.entries(manifest.constructs)) {
|
|
1166
|
+
if (construct.kind !== "site") continue;
|
|
1167
|
+
const url = manifest.env[provideKey(id, "url")];
|
|
1168
|
+
if (url && new URL(url).hostname.startsWith(`${WILDCARD_SUBDOMAIN}.`)) return url;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Sign a test's browser in the way a person does: ask the auth server for a
|
|
1173
|
+
* magic link, open the email it sent, follow the link.
|
|
1174
|
+
*
|
|
1175
|
+
* What the generated `browser.signIn(email)` calls. The address's mail is
|
|
1176
|
+
* cleared first — so the link is this request's, not one an earlier test left
|
|
1177
|
+
* — and cleared again after the test, like any address a test reads. Returns
|
|
1178
|
+
* the session the auth server then reports, as better-auth hands it back.
|
|
1179
|
+
*/
|
|
1180
|
+
async function signInWithMagicLink(browser, auth, email = freshAddress()) {
|
|
1181
|
+
const context = currentTestContext();
|
|
1182
|
+
const state = context && contexts.get(context.id);
|
|
1183
|
+
if (!state) throw new UnknownTestContext("signIn", context?.id);
|
|
1184
|
+
if (!state.mailbox) throw new NoInbox();
|
|
1185
|
+
const inbox = state.mailbox(email);
|
|
1186
|
+
await inbox.clear();
|
|
1187
|
+
const requested = await auth.signIn.magicLink({ email });
|
|
1188
|
+
if (requested.error) throw new SignInFailed(email, `the auth server refused the magic link: ${requested.error.message ?? "no reason given"}`);
|
|
1189
|
+
const mail = await inbox.last();
|
|
1190
|
+
if (!mail.link) throw new SignInFailed(email, "its email held no link");
|
|
1191
|
+
await browser.visit(mail.link);
|
|
1192
|
+
const { data } = await auth.getSession();
|
|
1193
|
+
if (!data) throw new SignInFailed(email, "the auth server reported no session after the link was opened");
|
|
1194
|
+
return data;
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* An address nobody else signs in as — what `browser.signIn()` uses when the
|
|
1198
|
+
* test does not care who it is.
|
|
1199
|
+
*
|
|
1200
|
+
* Unique rather than only seeded: tests in other files run at the same time,
|
|
1201
|
+
* against the same Mailpit and the same unique columns, and a seeded address
|
|
1202
|
+
* repeats wherever two tests share a name. The readable half is the seeded
|
|
1203
|
+
* faker's, so a failure still names somebody.
|
|
1204
|
+
*/
|
|
1205
|
+
function freshAddress() {
|
|
1206
|
+
return `${faker.internet.username().toLowerCase().replace(/[^a-z0-9]/g, "")}.${randomUUID().slice(0, 8)}@example.test`;
|
|
1207
|
+
}
|
|
1208
|
+
/** `browser.signIn` finished without a session. */
|
|
1209
|
+
var SignInFailed = class extends Error {
|
|
1210
|
+
email;
|
|
1211
|
+
reason;
|
|
1212
|
+
constructor(email, reason) {
|
|
1213
|
+
super(`Signing ${email} in failed: ${reason}.`);
|
|
1214
|
+
this.email = email;
|
|
1215
|
+
this.reason = reason;
|
|
1216
|
+
this.name = "SignInFailed";
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
/** A request reached an in-process server without a test to belong to. */
|
|
1220
|
+
var UnknownTestContext = class extends Error {
|
|
1221
|
+
url;
|
|
1222
|
+
id;
|
|
1223
|
+
constructor(url, id) {
|
|
1224
|
+
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.`);
|
|
1225
|
+
this.url = url;
|
|
1226
|
+
this.id = id;
|
|
1227
|
+
this.name = "UnknownTestContext";
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
/** `mailbox` was used in an app that declares no Email construct. */
|
|
1231
|
+
var NoInbox = class extends Error {
|
|
1232
|
+
constructor() {
|
|
1233
|
+
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.");
|
|
1234
|
+
this.name = "NoInbox";
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
/** `db.get(name)` named no database the test is handed. */
|
|
1238
|
+
var UnknownDatabase = class extends Error {
|
|
1239
|
+
database;
|
|
1240
|
+
known;
|
|
1241
|
+
constructor(database, known) {
|
|
1242
|
+
super(`db.get('${database}') names no database of this app's. ` + (known.length > 0 ? `Its databases: ${known.join(", ")}. ` : "It declares no database of its own. ") + "A tenant an auth server owns is reached through that server, and a reader through the database it reads.");
|
|
1243
|
+
this.database = database;
|
|
1244
|
+
this.known = known;
|
|
1245
|
+
this.name = "UnknownDatabase";
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
/** A factory keyed by a service name no database the app declares has. */
|
|
1249
|
+
var UnknownFactory = class extends Error {
|
|
1250
|
+
factory;
|
|
1251
|
+
known;
|
|
1252
|
+
constructor(factory, known) {
|
|
1253
|
+
super(`There is a test factory for '${factory}', and no database this app declares is called that. ` + (known.length > 0 ? `Its databases: ${known.join(", ")}. ` : "It declares no database. ") + `Name the file after the database construct: test/factories/<construct>.ts.`);
|
|
1254
|
+
this.factory = factory;
|
|
1255
|
+
this.known = known;
|
|
1256
|
+
this.name = "UnknownFactory";
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
/** A published message the consumer's own schema refuses. */
|
|
1260
|
+
var MessageRejected = class extends Error {
|
|
1261
|
+
consumer;
|
|
1262
|
+
published;
|
|
1263
|
+
issues;
|
|
1264
|
+
constructor(consumer, published, issues) {
|
|
1265
|
+
super(`${consumer} refuses '${published.type}': ${issues.map((issue) => issue.message).join("; ")}. What is published must be what the consumer's schema takes — fix the producer, or the schema.`);
|
|
1266
|
+
this.consumer = consumer;
|
|
1267
|
+
this.published = published;
|
|
1268
|
+
this.issues = issues;
|
|
1269
|
+
this.name = "MessageRejected";
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
/** A consumer that threw while handling what the test published. */
|
|
1273
|
+
var DeliveryFailed = class extends Error {
|
|
1274
|
+
consumer;
|
|
1275
|
+
messages;
|
|
1276
|
+
cause;
|
|
1277
|
+
constructor(consumer, messages, cause) {
|
|
1278
|
+
super(`${consumer} failed handling ${messages.map(({ type }) => `'${type}'`).join(", ")}: ${cause?.message ?? String(cause)}. Deployed, the message would be retried; here the failure is the result.`, { cause });
|
|
1279
|
+
this.consumer = consumer;
|
|
1280
|
+
this.messages = messages;
|
|
1281
|
+
this.cause = cause;
|
|
1282
|
+
this.name = "DeliveryFailed";
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
/** Consumers that kept publishing to each other without settling. */
|
|
1286
|
+
var DeliveryDidNotSettle = class extends Error {
|
|
1287
|
+
rounds;
|
|
1288
|
+
channels;
|
|
1289
|
+
constructor(rounds, channels) {
|
|
1290
|
+
super(`Delivery did not settle after ${rounds} rounds — consumers are still publishing to ${channels.join(", ")}. A consumer that publishes to what triggers it loops forever deployed too.`);
|
|
1291
|
+
this.rounds = rounds;
|
|
1292
|
+
this.channels = channels;
|
|
1293
|
+
this.name = "DeliveryDidNotSettle";
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
/** `services.get(name)` for a name no construct of the app is served by. */
|
|
1297
|
+
var UnknownService = class extends Error {
|
|
1298
|
+
serviceName;
|
|
1299
|
+
available;
|
|
1300
|
+
constructor(serviceName, available) {
|
|
1301
|
+
super(`The app declares no construct served as '${serviceName}'. Its services are: ${available.join(", ") || "none"}.`);
|
|
1302
|
+
this.serviceName = serviceName;
|
|
1303
|
+
this.available = available;
|
|
1304
|
+
this.name = "UnknownService";
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
//#endregion
|
|
1308
|
+
export { DeliveryDidNotSettle, DeliveryFailed, IN_PROCESS_PEER_ADDRESS, InboxNotLocal, MessageRejected, NoInbox, NoInboxForAddress, NoTestManifest, ReceiveFieldsOrRaw, ReceiveNeedsRecipient, SignInFailed, TEST_CONTEXT_HEADER, TEST_MANIFEST_ENV, TestEndpointAdaptor, TestFunctionAdaptor, TestQueueAdaptor, TestSubscriberAdaptor, UnknownDatabase, UnknownFactory, UnknownService, UnknownTestContext, createMswHandlers, featureTest, inProcessBindings, loadTestManifest, signInWithMagicLink };
|
|
414
1309
|
|
|
415
1310
|
//# sourceMappingURL=testing.mjs.map
|