@geekmidas/constructs 10.0.0-alpha.99 → 10.0.0
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/CHANGELOG.md +437 -0
- package/README.md +193 -285
- package/dist/AWSScheduledFunction-BzGCUbkk.d.mts +117 -0
- package/dist/AWSScheduledFunction-BzGCUbkk.d.mts.map +1 -0
- package/dist/AWSScheduledFunction-C42adp8A.cjs +266 -0
- package/dist/AWSScheduledFunction-C42adp8A.cjs.map +1 -0
- package/dist/AWSScheduledFunction-CsNJhXQj.d.cts +117 -0
- package/dist/AWSScheduledFunction-CsNJhXQj.d.cts.map +1 -0
- package/dist/AWSScheduledFunction-KP6lqbsW.mjs +254 -0
- package/dist/AWSScheduledFunction-KP6lqbsW.mjs.map +1 -0
- package/dist/{Construct-B1vGBPme.mjs → Construct-BWF5HxaM.mjs} +37 -47
- package/dist/Construct-BWF5HxaM.mjs.map +1 -0
- package/dist/Construct-JlyQkBkv.d.cts +117 -0
- package/dist/Construct-JlyQkBkv.d.cts.map +1 -0
- package/dist/{Construct-DUSXuTHP.cjs → Construct-TGIM_E4o.cjs} +88 -67
- package/dist/Construct-TGIM_E4o.cjs.map +1 -0
- package/dist/Construct-pxwC6fDD.d.mts +117 -0
- package/dist/Construct-pxwC6fDD.d.mts.map +1 -0
- package/dist/{Endpoint-Du-NwPX2.d.mts → Endpoint-B0P_pEMr.d.mts} +85 -126
- package/dist/Endpoint-B0P_pEMr.d.mts.map +1 -0
- package/dist/{Endpoint-aCvBMPoH.d.cts → Endpoint-BLZ7r67m.d.cts} +84 -125
- package/dist/Endpoint-BLZ7r67m.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-PtPlbeKY.mjs → HonoEndpointAdaptor-BMVwx2cz.mjs} +69 -81
- package/dist/HonoEndpointAdaptor-BMVwx2cz.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-zVzVLJEO.cjs → HonoEndpointAdaptor-DPDsDi-D.cjs} +77 -92
- package/dist/HonoEndpointAdaptor-DPDsDi-D.cjs.map +1 -0
- package/dist/Queue-BL68oDJ-.d.mts +66 -0
- package/dist/Queue-BL68oDJ-.d.mts.map +1 -0
- package/dist/Queue-DxJ6btRE.d.cts +66 -0
- package/dist/Queue-DxJ6btRE.d.cts.map +1 -0
- package/dist/Subscriber-BpVhcGhX.d.cts +47 -0
- package/dist/Subscriber-BpVhcGhX.d.cts.map +1 -0
- package/dist/Subscriber-DF6xsBAJ.d.mts +47 -0
- package/dist/Subscriber-DF6xsBAJ.d.mts.map +1 -0
- package/dist/Topic-DJXoDeMP.d.cts +60 -0
- package/dist/Topic-DJXoDeMP.d.cts.map +1 -0
- package/dist/Topic-DxWQBgMN.d.mts +60 -0
- package/dist/Topic-DxWQBgMN.d.mts.map +1 -0
- package/dist/adaptors/aws.cjs +205 -355
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +48 -126
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +49 -127
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +178 -325
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +9 -3
- package/dist/adaptors/hono.d.cts +15 -7
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +17 -9
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +9 -2
- package/dist/adaptors/testing.cjs +209 -831
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +55 -351
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +53 -349
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +195 -798
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/{clone-UGJpvQnL.cjs → clone-I_WIpiFf.cjs} +8 -7
- package/dist/clone-I_WIpiFf.cjs.map +1 -0
- package/dist/{clone-EKNovYHu.mjs → clone-pdXxc0t3.mjs} +3 -3
- package/dist/clone-pdXxc0t3.mjs.map +1 -0
- package/dist/crons/index.cjs +66 -190
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +35 -70
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +32 -70
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +63 -184
- package/dist/crons/index.mjs.map +1 -1
- package/dist/endpoints/index.cjs +761 -19
- package/dist/endpoints/index.cjs.map +1 -0
- package/dist/endpoints/index.d.cts +322 -22
- package/dist/endpoints/index.d.cts.map +1 -1
- package/dist/endpoints/index.d.mts +321 -22
- package/dist/endpoints/index.d.mts.map +1 -1
- package/dist/endpoints/index.mjs +751 -6
- package/dist/endpoints/index.mjs.map +1 -0
- package/dist/functions/index.cjs +5 -2
- package/dist/functions/index.d.cts +3 -3
- package/dist/functions/index.d.mts +3 -3
- package/dist/functions/index.mjs +5 -2
- package/dist/{functions-BFizikJU.mjs → functions-EqTloHjo.mjs} +331 -425
- package/dist/functions-EqTloHjo.mjs.map +1 -0
- package/dist/{functions-CfzJG9hK.cjs → functions-SqtCDc9c.cjs} +370 -459
- package/dist/functions-SqtCDc9c.cjs.map +1 -0
- package/dist/index-C7iynzLI.d.mts +139 -0
- package/dist/index-C7iynzLI.d.mts.map +1 -0
- package/dist/index-D4dM_WDY.d.cts +142 -0
- package/dist/index-D4dM_WDY.d.cts.map +1 -0
- package/dist/index.cjs +3 -6
- package/dist/index.d.cts +4 -27
- package/dist/index.d.mts +4 -27
- package/dist/index.mjs +3 -3
- package/dist/{Endpoint-BG4UJ9oA.mjs → lazyAccessors-CCTK19xj.mjs} +1040 -914
- package/dist/lazyAccessors-CCTK19xj.mjs.map +1 -0
- package/dist/{Endpoint-BoUg8ocM.cjs → lazyAccessors-D04oftGw.cjs} +1127 -960
- package/dist/lazyAccessors-D04oftGw.cjs.map +1 -0
- package/dist/monitors/index.cjs +49 -0
- package/dist/monitors/index.cjs.map +1 -0
- package/dist/monitors/index.d.cts +45 -0
- package/dist/monitors/index.d.cts.map +1 -0
- package/dist/monitors/index.d.mts +45 -0
- package/dist/monitors/index.d.mts.map +1 -0
- package/dist/monitors/index.mjs +48 -0
- package/dist/monitors/index.mjs.map +1 -0
- package/dist/processAudits-BJZT5gmy.cjs +92 -0
- package/dist/processAudits-BJZT5gmy.cjs.map +1 -0
- package/dist/processAudits-CwyaaSQc.mjs +80 -0
- package/dist/processAudits-CwyaaSQc.mjs.map +1 -0
- package/dist/publisher-BZgcrVPy.cjs +53 -0
- package/dist/publisher-BZgcrVPy.cjs.map +1 -0
- package/dist/publisher-CnpeMv-r.mjs +41 -0
- package/dist/publisher-CnpeMv-r.mjs.map +1 -0
- package/dist/queue/index.cjs +114 -6
- package/dist/queue/index.cjs.map +1 -0
- package/dist/queue/index.d.cts +45 -3
- package/dist/queue/index.d.cts.map +1 -0
- package/dist/queue/index.d.mts +44 -3
- package/dist/queue/index.d.mts.map +1 -0
- package/dist/queue/index.mjs +112 -3
- package/dist/queue/index.mjs.map +1 -0
- package/dist/subscribers/index.cjs +80 -111
- package/dist/subscribers/index.cjs.map +1 -1
- package/dist/subscribers/index.d.cts +43 -46
- package/dist/subscribers/index.d.cts.map +1 -1
- package/dist/subscribers/index.d.mts +42 -46
- package/dist/subscribers/index.d.mts.map +1 -1
- package/dist/subscribers/index.mjs +78 -108
- package/dist/subscribers/index.mjs.map +1 -1
- package/dist/{lambdaTelemetry-8vnmVZQ5.d.cts → telemetry-C--EgYVr.d.mts} +7 -4
- package/dist/telemetry-C--EgYVr.d.mts.map +1 -0
- package/dist/{lambdaTelemetry-8vnmVZQ5.d.mts → telemetry-Dqx-D3F7.d.cts} +7 -4
- package/dist/telemetry-Dqx-D3F7.d.cts.map +1 -0
- package/dist/topic/index.cjs +91 -3
- package/dist/topic/index.cjs.map +1 -0
- package/dist/topic/index.d.cts +32 -2
- package/dist/topic/index.d.cts.map +1 -0
- package/dist/topic/index.d.mts +32 -2
- package/dist/topic/index.d.mts.map +1 -0
- package/dist/topic/index.mjs +89 -2
- package/dist/topic/index.mjs.map +1 -0
- package/dist/{types-DMuSQeLL.d.cts → types-BdAaYDvd.d.cts} +5 -3
- package/dist/types-BdAaYDvd.d.cts.map +1 -0
- package/dist/{types-DMuSQeLL.d.mts → types-DNngH0fX.d.mts} +5 -3
- package/dist/types-DNngH0fX.d.mts.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +0 -1
- package/package.json +55 -223
- package/src/Construct.ts +209 -0
- package/src/__benchmarks__/build-time-optimization.bench.ts +274 -0
- package/src/__benchmarks__/endpoint.bench.ts +494 -0
- package/src/__benchmarks__/fixtures.ts +241 -0
- package/src/__benchmarks__/hono-adaptor.bench.ts +533 -0
- package/src/__benchmarks__/hono-server.bench.ts +249 -0
- package/src/__benchmarks__/response-builder.bench.ts +428 -0
- package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +319 -0
- package/src/__benchmarks__/strategies/strategy-c-middleware.ts +530 -0
- package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +567 -0
- package/src/__tests__/Construct.environment.spec.ts +704 -0
- package/src/__tests__/builder-reuse.spec.ts +587 -0
- package/src/__tests__/monitor.spec.ts +636 -0
- package/src/__tests__/publisher.setting.spec.ts +508 -0
- package/src/__tests__/publisher.spec.ts +452 -0
- package/src/adaptors/aws.ts +6 -0
- package/src/adaptors/hono.ts +1 -0
- package/src/adaptors/testing.ts +11 -0
- package/src/clone.ts +38 -0
- package/src/crons/AWSScheduledFunction.ts +73 -0
- package/src/crons/Cron.ts +149 -0
- package/src/crons/CronBuilder.ts +261 -0
- package/src/crons/__tests__/AWSScheduledFunction.spec.ts +152 -0
- package/src/crons/__tests__/Cron.spec.ts +472 -0
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +273 -0
- package/src/crons/index.ts +12 -0
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +698 -0
- package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +105 -0
- package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +97 -0
- package/src/endpoints/Authorizer.ts +152 -0
- package/src/endpoints/Endpoint.ts +1287 -0
- package/src/endpoints/EndpointBuilder.ts +749 -0
- package/src/endpoints/EndpointFactory.ts +1179 -0
- package/src/endpoints/HonoEndpointAdaptor.ts +692 -0
- package/src/endpoints/MswEndpointAdaptor.ts +226 -0
- package/src/endpoints/TestEndpointAdaptor.ts +466 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +499 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +560 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +1304 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +626 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +732 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +296 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +951 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.responseType.spec.ts +111 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +307 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +629 -0
- package/src/endpoints/__tests__/Authorizer.spec.ts +286 -0
- package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +207 -0
- package/src/endpoints/__tests__/Endpoint.headers.spec.ts +187 -0
- package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +175 -0
- package/src/endpoints/__tests__/Endpoint.spec.ts +857 -0
- package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +451 -0
- package/src/endpoints/__tests__/EndpointBuilder.responseType.spec.ts +50 -0
- package/src/endpoints/__tests__/EndpointBuilder.spec.ts +531 -0
- package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +492 -0
- package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +509 -0
- package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +190 -0
- package/src/endpoints/__tests__/EndpointFactory.spec.ts +479 -0
- package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +155 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +703 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +632 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +577 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +1067 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +317 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.pgboss-publisher.spec.ts +289 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.responseType.spec.ts +128 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +1207 -0
- package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +211 -0
- package/src/endpoints/__tests__/ResponseBuilder.spec.ts +235 -0
- package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +602 -0
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +1044 -0
- package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +54 -0
- package/src/endpoints/__tests__/endpoint-types.test.ts +88 -0
- package/src/endpoints/__tests__/helpers.spec.ts +37 -0
- package/src/endpoints/__tests__/lazyAccessors.spec.ts +330 -0
- package/src/endpoints/__tests__/processAudits.spec.ts +631 -0
- package/src/endpoints/audit.ts +87 -0
- package/src/endpoints/helpers.ts +98 -0
- package/src/endpoints/index.ts +42 -0
- package/src/endpoints/lazyAccessors.ts +241 -0
- package/src/endpoints/parseHonoQuery.ts +16 -0
- package/src/endpoints/parseQueryParams.ts +32 -0
- package/src/endpoints/processAudits.ts +371 -0
- package/src/endpoints/rls.ts +67 -0
- package/src/functions/AWSLambdaFunction.ts +374 -0
- package/src/functions/BaseFunctionBuilder.ts +212 -0
- package/src/functions/Function.ts +238 -0
- package/src/functions/FunctionBuilder.ts +381 -0
- package/src/functions/FunctionExecutionWrapper.ts +216 -0
- package/src/functions/TestFunctionAdaptor.ts +252 -0
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +513 -0
- package/src/functions/__tests__/Function.audits.spec.ts +393 -0
- package/src/functions/__tests__/Function.spec.ts +477 -0
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +250 -0
- package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +480 -0
- package/src/functions/index.ts +12 -0
- package/src/index.ts +29 -0
- package/src/monitor.ts +145 -0
- package/src/monitors/heartbeat.ts +86 -0
- package/src/monitors/index.ts +6 -0
- package/src/publisher.ts +93 -0
- package/src/queue/AWSLambdaQueueAdaptor.ts +162 -0
- package/src/queue/Queue.ts +128 -0
- package/src/queue/QueueBuilder.ts +115 -0
- package/src/queue/TestQueueAdaptor.ts +63 -0
- package/src/queue/__tests__/QueueBuilder.spec.ts +137 -0
- package/src/queue/index.ts +12 -0
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +342 -0
- package/src/subscribers/Subscriber.ts +117 -0
- package/src/subscribers/SubscriberBuilder.ts +183 -0
- package/src/subscribers/TestSubscriberAdaptor.ts +133 -0
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +1018 -0
- package/src/subscribers/__tests__/Subscriber.spec.ts +430 -0
- package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +652 -0
- package/src/subscribers/index.ts +6 -0
- package/src/telemetry.ts +103 -0
- package/src/topic/Topic.ts +103 -0
- package/src/topic/TopicBuilder.ts +53 -0
- package/src/topic/__tests__/TopicBuilder.spec.ts +82 -0
- package/src/topic/index.ts +11 -0
- package/src/types.ts +13 -0
- package/test.ts +91 -0
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +35 -0
- package/dist/Construct-B1vGBPme.mjs.map +0 -1
- package/dist/Construct-BQALFCh2.d.cts +0 -230
- package/dist/Construct-BQALFCh2.d.cts.map +0 -1
- package/dist/Construct-DUSXuTHP.cjs.map +0 -1
- package/dist/Construct-QXnl3VqT.d.mts +0 -230
- package/dist/Construct-QXnl3VqT.d.mts.map +0 -1
- package/dist/Cron-DI3nKoic.d.cts +0 -45
- package/dist/Cron-DI3nKoic.d.cts.map +0 -1
- package/dist/Cron-uYAHPnp7.d.mts +0 -45
- package/dist/Cron-uYAHPnp7.d.mts.map +0 -1
- package/dist/CronBuilder-C0Ek1-RA.cjs +0 -121
- package/dist/CronBuilder-C0Ek1-RA.cjs.map +0 -1
- package/dist/CronBuilder-DaSUm2Na.d.mts +0 -47
- package/dist/CronBuilder-DaSUm2Na.d.mts.map +0 -1
- package/dist/CronBuilder-Dmix_Pen.mjs +0 -109
- package/dist/CronBuilder-Dmix_Pen.mjs.map +0 -1
- package/dist/CronBuilder-g1lZLWyG.d.cts +0 -47
- package/dist/CronBuilder-g1lZLWyG.d.cts.map +0 -1
- package/dist/Endpoint-BG4UJ9oA.mjs.map +0 -1
- package/dist/Endpoint-BoUg8ocM.cjs.map +0 -1
- package/dist/Endpoint-Du-NwPX2.d.mts.map +0 -1
- package/dist/Endpoint-aCvBMPoH.d.cts.map +0 -1
- package/dist/EndpointFactory-BDtsrEvJ.mjs +0 -791
- package/dist/EndpointFactory-BDtsrEvJ.mjs.map +0 -1
- package/dist/EndpointFactory-DJ7gXLpR.cjs +0 -833
- package/dist/EndpointFactory-DJ7gXLpR.cjs.map +0 -1
- package/dist/EndpointFactory-DMYdJCOj.d.mts +0 -363
- package/dist/EndpointFactory-DMYdJCOj.d.mts.map +0 -1
- package/dist/EndpointFactory-I7s1co3Y.d.cts +0 -363
- package/dist/EndpointFactory-I7s1co3Y.d.cts.map +0 -1
- package/dist/Function-DuqGcbOI.d.mts +0 -76
- package/dist/Function-DuqGcbOI.d.mts.map +0 -1
- package/dist/Function-Pu-1kKZz.d.cts +0 -76
- package/dist/Function-Pu-1kKZz.d.cts.map +0 -1
- package/dist/HonoEndpointAdaptor-PtPlbeKY.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-zVzVLJEO.cjs.map +0 -1
- package/dist/Queue-A3wfD0it.cjs +0 -109
- package/dist/Queue-A3wfD0it.cjs.map +0 -1
- package/dist/Queue-D6USGS4q.mjs +0 -104
- package/dist/Queue-D6USGS4q.mjs.map +0 -1
- package/dist/Queue-DlsHRzUp.d.mts +0 -105
- package/dist/Queue-DlsHRzUp.d.mts.map +0 -1
- package/dist/Queue-HPyi0e1i.d.cts +0 -105
- package/dist/Queue-HPyi0e1i.d.cts.map +0 -1
- package/dist/QueueBuilder-BjuF0UBl.cjs +0 -135
- package/dist/QueueBuilder-BjuF0UBl.cjs.map +0 -1
- package/dist/QueueBuilder-Cue73M4t.mjs +0 -118
- package/dist/QueueBuilder-Cue73M4t.mjs.map +0 -1
- package/dist/QueueBuilder-OSi6LkV9.d.cts +0 -75
- package/dist/QueueBuilder-OSi6LkV9.d.cts.map +0 -1
- package/dist/QueueBuilder-QHsnVt1P.d.mts +0 -75
- package/dist/QueueBuilder-QHsnVt1P.d.mts.map +0 -1
- package/dist/Subscriber-Bpp02cGr.d.cts +0 -61
- package/dist/Subscriber-Bpp02cGr.d.cts.map +0 -1
- package/dist/Subscriber-CtN9R48-.d.mts +0 -61
- package/dist/Subscriber-CtN9R48-.d.mts.map +0 -1
- package/dist/SubscriberBuilder-CDy4nHCz.mjs +0 -134
- package/dist/SubscriberBuilder-CDy4nHCz.mjs.map +0 -1
- package/dist/SubscriberBuilder-CuCMFpYW.d.mts +0 -67
- package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +0 -1
- package/dist/SubscriberBuilder-D_owVoHo.cjs +0 -145
- package/dist/SubscriberBuilder-D_owVoHo.cjs.map +0 -1
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts +0 -67
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +0 -1
- package/dist/Topic-D74b5cgs.mjs +0 -99
- package/dist/Topic-D74b5cgs.mjs.map +0 -1
- package/dist/Topic-GHxcU8AG.cjs +0 -104
- package/dist/Topic-GHxcU8AG.cjs.map +0 -1
- package/dist/auth-BMCJN30Y.d.cts +0 -268
- package/dist/auth-BMCJN30Y.d.cts.map +0 -1
- package/dist/auth-CcuceLYo.d.mts +0 -268
- package/dist/auth-CcuceLYo.d.mts.map +0 -1
- package/dist/auth.cjs +0 -433
- package/dist/auth.cjs.map +0 -1
- package/dist/auth.d.cts +0 -2
- package/dist/auth.d.mts +0 -2
- package/dist/auth.mjs +0 -426
- package/dist/auth.mjs.map +0 -1
- package/dist/cache-CXh6GIgb.d.mts +0 -44
- package/dist/cache-CXh6GIgb.d.mts.map +0 -1
- package/dist/cache-DnGDGly3.d.cts +0 -44
- package/dist/cache-DnGDGly3.d.cts.map +0 -1
- package/dist/cache.cjs +0 -69
- package/dist/cache.cjs.map +0 -1
- package/dist/cache.d.cts +0 -2
- package/dist/cache.d.mts +0 -2
- package/dist/cache.mjs +0 -68
- package/dist/cache.mjs.map +0 -1
- package/dist/cipher-C1lEFX63.mjs +0 -225
- package/dist/cipher-C1lEFX63.mjs.map +0 -1
- package/dist/cipher-CVxfwLjk.cjs +0 -332
- package/dist/cipher-CVxfwLjk.cjs.map +0 -1
- package/dist/clone-EKNovYHu.mjs.map +0 -1
- package/dist/clone-UGJpvQnL.cjs.map +0 -1
- package/dist/construct-interface-B1AfqRl4.d.cts +0 -162
- package/dist/construct-interface-B1AfqRl4.d.cts.map +0 -1
- package/dist/construct-interface-DluK3_da.d.mts +0 -162
- package/dist/construct-interface-DluK3_da.d.mts.map +0 -1
- package/dist/construct-interface.cjs +0 -114
- package/dist/construct-interface.cjs.map +0 -1
- package/dist/construct-interface.d.cts +0 -2
- package/dist/construct-interface.d.mts +0 -2
- package/dist/construct-interface.mjs +0 -107
- package/dist/construct-interface.mjs.map +0 -1
- package/dist/credential.cjs +0 -156
- package/dist/credential.cjs.map +0 -1
- package/dist/credential.d.cts +0 -86
- package/dist/credential.d.cts.map +0 -1
- package/dist/credential.d.mts +0 -86
- package/dist/credential.d.mts.map +0 -1
- package/dist/credential.mjs +0 -152
- package/dist/credential.mjs.map +0 -1
- package/dist/database/kysely.cjs +0 -4
- package/dist/database/kysely.d.cts +0 -2
- package/dist/database/kysely.d.mts +0 -2
- package/dist/database/kysely.mjs +0 -2
- package/dist/email.cjs +0 -72
- package/dist/email.cjs.map +0 -1
- package/dist/email.d.cts +0 -46
- package/dist/email.d.cts.map +0 -1
- package/dist/email.d.mts +0 -46
- package/dist/email.d.mts.map +0 -1
- package/dist/email.mjs +0 -71
- package/dist/email.mjs.map +0 -1
- package/dist/encryption.cjs +0 -96
- package/dist/encryption.cjs.map +0 -1
- package/dist/encryption.d.cts +0 -117
- package/dist/encryption.d.cts.map +0 -1
- package/dist/encryption.d.mts +0 -117
- package/dist/encryption.d.mts.map +0 -1
- package/dist/encryption.mjs +0 -83
- package/dist/encryption.mjs.map +0 -1
- package/dist/external-api-MJ8id87V.d.mts +0 -105
- package/dist/external-api-MJ8id87V.d.mts.map +0 -1
- package/dist/external-api-O107yzZJ.d.cts +0 -105
- package/dist/external-api-O107yzZJ.d.cts.map +0 -1
- package/dist/external-api.cjs +0 -142
- package/dist/external-api.cjs.map +0 -1
- package/dist/external-api.d.cts +0 -2
- package/dist/external-api.d.mts +0 -2
- package/dist/external-api.mjs +0 -139
- package/dist/external-api.mjs.map +0 -1
- package/dist/file-server.cjs +0 -186
- package/dist/file-server.cjs.map +0 -1
- package/dist/file-server.d.cts +0 -152
- package/dist/file-server.d.cts.map +0 -1
- package/dist/file-server.d.mts +0 -152
- package/dist/file-server.d.mts.map +0 -1
- package/dist/file-server.mjs +0 -184
- package/dist/file-server.mjs.map +0 -1
- package/dist/functions-BFizikJU.mjs.map +0 -1
- package/dist/functions-CfzJG9hK.cjs.map +0 -1
- package/dist/index-BuzRvKOQ.d.cts +0 -115
- package/dist/index-BuzRvKOQ.d.cts.map +0 -1
- package/dist/index-CTkKOer4.d.mts +0 -115
- package/dist/index-CTkKOer4.d.mts.map +0 -1
- package/dist/index-CeEtxDmK.d.cts +0 -79
- package/dist/index-CeEtxDmK.d.cts.map +0 -1
- package/dist/index-CeEtxDmK.d.mts +0 -79
- package/dist/index-CeEtxDmK.d.mts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/kms-B-Hm3d5r.cjs +0 -85
- package/dist/kms-B-Hm3d5r.cjs.map +0 -1
- package/dist/kms-BdUlMJEZ.mjs +0 -85
- package/dist/kms-BdUlMJEZ.mjs.map +0 -1
- package/dist/kysely-Bii4l6eP.mjs +0 -370
- package/dist/kysely-Bii4l6eP.mjs.map +0 -1
- package/dist/kysely-CO_Dk43W.cjs +0 -383
- package/dist/kysely-CO_Dk43W.cjs.map +0 -1
- package/dist/kysely-D0bpzgPs.d.cts +0 -175
- package/dist/kysely-D0bpzgPs.d.cts.map +0 -1
- package/dist/kysely-DUqC3Ie0.d.mts +0 -175
- package/dist/kysely-DUqC3Ie0.d.mts.map +0 -1
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +0 -1
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +0 -1
- package/dist/lazyAccessors-CFanua0O.mjs +0 -174
- package/dist/lazyAccessors-CFanua0O.mjs.map +0 -1
- package/dist/lazyAccessors-hJKGv8Ay.cjs +0 -221
- package/dist/lazyAccessors-hJKGv8Ay.cjs.map +0 -1
- package/dist/mobile-app.cjs +0 -73
- package/dist/mobile-app.cjs.map +0 -1
- package/dist/mobile-app.d.cts +0 -61
- package/dist/mobile-app.d.cts.map +0 -1
- package/dist/mobile-app.d.mts +0 -61
- package/dist/mobile-app.d.mts.map +0 -1
- package/dist/mobile-app.mjs +0 -72
- package/dist/mobile-app.mjs.map +0 -1
- package/dist/object-storage.cjs +0 -56
- package/dist/object-storage.cjs.map +0 -1
- package/dist/object-storage.d.cts +0 -32
- package/dist/object-storage.d.cts.map +0 -1
- package/dist/object-storage.d.mts +0 -32
- package/dist/object-storage.d.mts.map +0 -1
- package/dist/object-storage.mjs +0 -55
- package/dist/object-storage.mjs.map +0 -1
- package/dist/processAudits-BRRVVHUB.mjs +0 -131
- package/dist/processAudits-BRRVVHUB.mjs.map +0 -1
- package/dist/processAudits-DasOZjPl.cjs +0 -154
- package/dist/processAudits-DasOZjPl.cjs.map +0 -1
- package/dist/rest-api.cjs +0 -216
- package/dist/rest-api.cjs.map +0 -1
- package/dist/rest-api.d.cts +0 -241
- package/dist/rest-api.d.cts.map +0 -1
- package/dist/rest-api.d.mts +0 -241
- package/dist/rest-api.d.mts.map +0 -1
- package/dist/rest-api.mjs +0 -215
- package/dist/rest-api.mjs.map +0 -1
- package/dist/rolldown-runtime-y5ARvAq5.cjs +0 -35
- package/dist/runSubscriber-BHvJ8POr.mjs +0 -109
- package/dist/runSubscriber-BHvJ8POr.mjs.map +0 -1
- package/dist/runSubscriber-D8nLXIv1.cjs +0 -126
- package/dist/runSubscriber-D8nLXIv1.cjs.map +0 -1
- package/dist/shutdown-BMJmAhSt.cjs +0 -38
- package/dist/shutdown-BMJmAhSt.cjs.map +0 -1
- package/dist/shutdown-C7xa8x9S.mjs +0 -27
- package/dist/shutdown-C7xa8x9S.mjs.map +0 -1
- package/dist/site.cjs +0 -74
- package/dist/site.cjs.map +0 -1
- package/dist/site.d.cts +0 -104
- package/dist/site.d.cts.map +0 -1
- package/dist/site.d.mts +0 -104
- package/dist/site.d.mts.map +0 -1
- package/dist/site.mjs +0 -73
- package/dist/site.mjs.map +0 -1
- package/dist/stages-BSCF19o2.d.cts +0 -56
- package/dist/stages-BSCF19o2.d.cts.map +0 -1
- package/dist/stages-BSCF19o2.d.mts +0 -56
- package/dist/stages-BSCF19o2.d.mts.map +0 -1
- package/dist/surfaceEnv-CNimK76p.cjs +0 -56
- package/dist/surfaceEnv-CNimK76p.cjs.map +0 -1
- package/dist/surfaceEnv-wMT5QzgZ.mjs +0 -45
- package/dist/surfaceEnv-wMT5QzgZ.mjs.map +0 -1
- package/dist/telemetry-B48RLjyk.d.cts +0 -40
- package/dist/telemetry-B48RLjyk.d.cts.map +0 -1
- package/dist/telemetry-DRtT1_0A.d.mts +0 -40
- package/dist/telemetry-DRtT1_0A.d.mts.map +0 -1
- package/dist/telemetry.cjs +0 -56
- package/dist/telemetry.cjs.map +0 -1
- package/dist/telemetry.d.cts +0 -2
- package/dist/telemetry.d.mts +0 -2
- package/dist/telemetry.mjs +0 -55
- package/dist/telemetry.mjs.map +0 -1
- package/dist/tracing-CxaZ98IB.mjs +0 -110
- package/dist/tracing-CxaZ98IB.mjs.map +0 -1
- package/dist/tracing-DPMidF_r.cjs +0 -127
- package/dist/tracing-DPMidF_r.cjs.map +0 -1
- package/dist/types-DMuSQeLL.d.cts.map +0 -1
- package/dist/types-DMuSQeLL.d.mts.map +0 -1
- package/dist/worker.cjs +0 -191
- package/dist/worker.cjs.map +0 -1
- package/dist/worker.d.cts +0 -171
- package/dist/worker.d.cts.map +0 -1
- package/dist/worker.d.mts +0 -171
- package/dist/worker.d.mts.map +0 -1
- package/dist/worker.mjs +0 -190
- package/dist/worker.mjs.map +0 -1
|
@@ -1,66 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
let _geekmidas_errors = require("@geekmidas/errors");
|
|
17
|
-
let _geekmidas_envkit = require("@geekmidas/envkit");
|
|
18
|
-
let _geekmidas_services = require("@geekmidas/services");
|
|
19
|
-
let hono = require("hono");
|
|
20
|
-
let _geekmidas_audit = require("@geekmidas/audit");
|
|
21
|
-
let _geekmidas_testkit_context = require("@geekmidas/testkit/context");
|
|
22
|
-
let msw = require("msw");
|
|
23
|
-
let _geekmidas_testkit_browser = require("@geekmidas/testkit/browser");
|
|
24
|
-
let _geekmidas_testkit_faker = require("@geekmidas/testkit/faker");
|
|
25
|
-
let _geekmidas_testkit_mailbox = require("@geekmidas/testkit/mailbox");
|
|
26
|
-
let _geekmidas_testkit_transactions = require("@geekmidas/testkit/transactions");
|
|
27
|
-
let msw_node = require("msw/node");
|
|
28
|
-
let vitest = require("vitest");
|
|
29
|
-
let node_fs = require("node:fs");
|
|
30
|
-
let node_tls = require("node:tls");
|
|
31
|
-
node_tls = require_rolldown_runtime.__toESM(node_tls, 1);
|
|
32
|
-
let node_url = require("node:url");
|
|
33
|
-
//#region src/testing/peer.ts
|
|
1
|
+
const require_Construct = require('../Construct-TGIM_E4o.cjs');
|
|
2
|
+
const require_functions = require('../functions-SqtCDc9c.cjs');
|
|
3
|
+
require('../clone-I_WIpiFf.cjs');
|
|
4
|
+
const require_publisher = require('../publisher-BZgcrVPy.cjs');
|
|
5
|
+
const require_lazyAccessors = require('../lazyAccessors-D04oftGw.cjs');
|
|
6
|
+
const require_processAudits = require('../processAudits-BJZT5gmy.cjs');
|
|
7
|
+
const require_HonoEndpointAdaptor = require('../HonoEndpointAdaptor-DPDsDi-D.cjs');
|
|
8
|
+
const __geekmidas_errors = require_Construct.__toESM(require("@geekmidas/errors"));
|
|
9
|
+
const __geekmidas_services = require_Construct.__toESM(require("@geekmidas/services"));
|
|
10
|
+
const __geekmidas_audit = require_Construct.__toESM(require("@geekmidas/audit"));
|
|
11
|
+
const hono = require_Construct.__toESM(require("hono"));
|
|
12
|
+
const __geekmidas_envkit = require_Construct.__toESM(require("@geekmidas/envkit"));
|
|
13
|
+
const msw = require_Construct.__toESM(require("msw"));
|
|
14
|
+
|
|
15
|
+
//#region src/endpoints/MswEndpointAdaptor.ts
|
|
34
16
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* socket, no server — so the app's bindings have no peer to read. Deployed,
|
|
39
|
-
* every request has one, and what a surface trusts follows from it: the auth
|
|
40
|
-
* server honours `x-gkm-client-ip` only from an internal caller, a loopback
|
|
41
|
-
* or private peer with no `Origin` and no forwarding header. With no peer at
|
|
42
|
-
* all the header was dropped, and every test's session check became the same
|
|
43
|
-
* client to Better Auth's rate limiter.
|
|
44
|
-
*
|
|
45
|
-
* So an in-process dispatch says where it came from, the way
|
|
46
|
-
* `@hono/node-server` does: its bindings carry `incoming.socket.remoteAddress`.
|
|
47
|
-
* The address is loopback because that is the truth — the request came from
|
|
48
|
-
* this process. A browser's own address still travels in its
|
|
49
|
-
* `x-forwarded-for`, which makes it outside traffic exactly as it would be
|
|
50
|
-
* behind the stack's proxy.
|
|
51
|
-
*
|
|
52
|
-
* Only a test's dispatch passes these. A runtime with no socket of its own
|
|
53
|
-
* (Lambda, Bun) still has no peer, and a request with no peer is still not an
|
|
54
|
-
* internal caller's.
|
|
17
|
+
* Header used to identify which test context a request belongs to.
|
|
18
|
+
* Each concurrent test registers its own context (services, db transaction, etc.)
|
|
19
|
+
* and the MSW handler looks it up by this header value.
|
|
55
20
|
*/
|
|
56
|
-
|
|
57
|
-
const IN_PROCESS_PEER_ADDRESS = "127.0.0.1";
|
|
58
|
-
/** Bindings for `app.fetch(request, bindings)` from inside this process. */
|
|
59
|
-
function inProcessBindings() {
|
|
60
|
-
return { incoming: { socket: { remoteAddress: IN_PROCESS_PEER_ADDRESS } } };
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/endpoints/MswEndpointAdaptor.ts
|
|
21
|
+
const TEST_CONTEXT_HEADER = "x-test-context-id";
|
|
64
22
|
const MSW_HTTP_METHODS = [
|
|
65
23
|
"get",
|
|
66
24
|
"post",
|
|
@@ -92,8 +50,8 @@ function createMswHandlers(endpoints, options) {
|
|
|
92
50
|
* Creates a fresh ServiceDiscovery and pre-registers all provided services.
|
|
93
51
|
*/
|
|
94
52
|
function registerContext(id, ctxOptions) {
|
|
95
|
-
const envParser = new
|
|
96
|
-
const serviceDiscovery = new
|
|
53
|
+
const envParser = new __geekmidas_envkit.EnvironmentParser({});
|
|
54
|
+
const serviceDiscovery = new __geekmidas_services.ServiceDiscovery(envParser);
|
|
97
55
|
const serviceDefs = [];
|
|
98
56
|
if (ctxOptions.services) for (const [name, instance] of Object.entries(ctxOptions.services)) serviceDefs.push({
|
|
99
57
|
serviceName: name,
|
|
@@ -108,6 +66,7 @@ function createMswHandlers(endpoints, options) {
|
|
|
108
66
|
break;
|
|
109
67
|
}
|
|
110
68
|
}
|
|
69
|
+
if (ctxOptions.publisher) serviceDefs.push(ctxOptions.publisher);
|
|
111
70
|
if (ctxOptions.auditorStorage !== void 0) {
|
|
112
71
|
for (const endpoint of endpoints) if (endpoint.auditorStorageService) {
|
|
113
72
|
serviceDefs.push({
|
|
@@ -127,18 +86,18 @@ function createMswHandlers(endpoints, options) {
|
|
|
127
86
|
const mswUrl = `${baseURL}${endpoint.route}`;
|
|
128
87
|
const mswMethod = msw.http[method];
|
|
129
88
|
handlers.push(mswMethod(mswUrl, async ({ request }) => {
|
|
130
|
-
const contextId = request.headers.get(
|
|
89
|
+
const contextId = request.headers.get(TEST_CONTEXT_HEADER);
|
|
131
90
|
const ctx = contextId ? contexts.get(contextId) : void 0;
|
|
132
91
|
if (!ctx) return new Response(JSON.stringify({
|
|
133
92
|
error: "Missing or unknown test context ID",
|
|
134
|
-
hint: `Set the '${
|
|
93
|
+
hint: `Set the '${TEST_CONTEXT_HEADER}' header to a registered context ID`
|
|
135
94
|
}), {
|
|
136
95
|
status: 500,
|
|
137
96
|
headers: { "content-type": "application/json" }
|
|
138
97
|
});
|
|
139
98
|
const app = new hono.Hono();
|
|
140
99
|
require_HonoEndpointAdaptor.HonoEndpoint.addRoute(endpoint, ctx.serviceDiscovery, app);
|
|
141
|
-
const response = await app.request(request
|
|
100
|
+
const response = await app.request(request);
|
|
142
101
|
return new Response(response.body, {
|
|
143
102
|
status: response.status,
|
|
144
103
|
statusText: response.statusText,
|
|
@@ -151,6 +110,7 @@ function createMswHandlers(endpoints, options) {
|
|
|
151
110
|
registerContext
|
|
152
111
|
};
|
|
153
112
|
}
|
|
113
|
+
|
|
154
114
|
//#endregion
|
|
155
115
|
//#region src/endpoints/TestEndpointAdaptor.ts
|
|
156
116
|
/**
|
|
@@ -170,10 +130,8 @@ function serializeCookie(name, value, options) {
|
|
|
170
130
|
return cookieString;
|
|
171
131
|
}
|
|
172
132
|
var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
173
|
-
endpoint;
|
|
174
|
-
serviceDiscovery;
|
|
175
133
|
static getDefaultServiceDiscover(_endpoint) {
|
|
176
|
-
return
|
|
134
|
+
return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
|
|
177
135
|
}
|
|
178
136
|
constructor(endpoint, serviceDiscovery = TestEndpointAdaptor.getDefaultServiceDiscover(endpoint)) {
|
|
179
137
|
this.endpoint = endpoint;
|
|
@@ -194,129 +152,150 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
|
|
|
194
152
|
method: this.endpoint.method
|
|
195
153
|
});
|
|
196
154
|
const rawDb = ctx.database;
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
requestId,
|
|
201
|
-
startTime,
|
|
202
|
-
operation
|
|
203
|
-
}, async () => {
|
|
204
|
-
const session = await this.endpoint.getSession({
|
|
155
|
+
const monitor = await require_functions.startMonitors(this.endpoint, this.serviceDiscovery, logger);
|
|
156
|
+
try {
|
|
157
|
+
const response = await (0, __geekmidas_services.runWithRequestContext)({
|
|
205
158
|
logger,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
159
|
+
requestId,
|
|
160
|
+
startTime
|
|
161
|
+
}, async () => this.run(ctx, {
|
|
162
|
+
body,
|
|
163
|
+
query,
|
|
164
|
+
params,
|
|
212
165
|
header,
|
|
213
166
|
cookie,
|
|
214
|
-
services: ctx.services,
|
|
215
167
|
logger,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const { output, metadata } = await require_processAudits.executeWithAuditTransaction(auditContext, async (auditor) => {
|
|
258
|
-
const db = auditor?.getTransaction?.() ?? rawDb;
|
|
259
|
-
const responseBuilder = new require_Endpoint.ResponseBuilder();
|
|
260
|
-
const response = await this.endpoint.handler({
|
|
261
|
-
body,
|
|
262
|
-
query,
|
|
263
|
-
params,
|
|
264
|
-
session,
|
|
168
|
+
rawDb
|
|
169
|
+
}));
|
|
170
|
+
await monitor.settle(response.status);
|
|
171
|
+
return response;
|
|
172
|
+
} catch (error) {
|
|
173
|
+
await monitor.settle((0, __geekmidas_errors.wrapError)(error).statusCode, error);
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async run(ctx, { body, query, params, header, cookie, logger, rawDb }) {
|
|
178
|
+
const session = await this.endpoint.getSession({
|
|
179
|
+
logger,
|
|
180
|
+
services: ctx.services,
|
|
181
|
+
header,
|
|
182
|
+
cookie,
|
|
183
|
+
...rawDb !== void 0 && { db: rawDb }
|
|
184
|
+
});
|
|
185
|
+
const isAuthorized = await this.endpoint.authorize({
|
|
186
|
+
header,
|
|
187
|
+
cookie,
|
|
188
|
+
services: ctx.services,
|
|
189
|
+
logger,
|
|
190
|
+
session,
|
|
191
|
+
...rawDb !== void 0 && { db: rawDb },
|
|
192
|
+
body,
|
|
193
|
+
query,
|
|
194
|
+
params
|
|
195
|
+
});
|
|
196
|
+
if (!isAuthorized) {
|
|
197
|
+
logger.warn("Forbidden access attempt");
|
|
198
|
+
throw new __geekmidas_errors.ForbiddenError("Forbidden access to the endpoint", "You do not have permission to access this resource.");
|
|
199
|
+
}
|
|
200
|
+
const auditorStorage = ctx.auditorStorage;
|
|
201
|
+
let auditContext;
|
|
202
|
+
if (auditorStorage) {
|
|
203
|
+
let actor = {
|
|
204
|
+
id: "system",
|
|
205
|
+
type: "system"
|
|
206
|
+
};
|
|
207
|
+
if (this.endpoint.actorExtractor) try {
|
|
208
|
+
actor = await this.endpoint.actorExtractor({
|
|
265
209
|
services: ctx.services,
|
|
266
|
-
|
|
210
|
+
session,
|
|
267
211
|
header,
|
|
268
212
|
cookie,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
metadata,
|
|
281
|
-
responseBuilder
|
|
282
|
-
};
|
|
283
|
-
}, async (result, auditor) => {
|
|
284
|
-
if (!audits?.length) return;
|
|
285
|
-
for (const audit of audits) {
|
|
286
|
-
if (audit.when && !audit.when(result.output)) continue;
|
|
287
|
-
const payload = audit.payload(result.output);
|
|
288
|
-
const entityId = audit.entityId?.(result.output);
|
|
289
|
-
auditor.audit(audit.type, payload, {
|
|
290
|
-
table: audit.table,
|
|
291
|
-
entityId
|
|
292
|
-
});
|
|
213
|
+
logger
|
|
214
|
+
});
|
|
215
|
+
} catch (error) {
|
|
216
|
+
logger.error(error, "Failed to extract actor for audits");
|
|
217
|
+
}
|
|
218
|
+
const auditor = new __geekmidas_audit.DefaultAuditor({
|
|
219
|
+
actor,
|
|
220
|
+
storage: auditorStorage,
|
|
221
|
+
metadata: {
|
|
222
|
+
endpoint: this.endpoint.route,
|
|
223
|
+
method: this.endpoint.method
|
|
293
224
|
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
225
|
+
});
|
|
226
|
+
auditContext = {
|
|
227
|
+
auditor,
|
|
228
|
+
storage: auditorStorage
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
const audits = this.endpoint.audits;
|
|
232
|
+
if (!auditContext && audits?.length) logger.warn("No auditor storage service available");
|
|
233
|
+
const result = await require_processAudits.executeWithAuditTransaction(auditContext, async (auditor) => {
|
|
234
|
+
const trx = auditor?.getTransaction?.();
|
|
235
|
+
const db = trx ?? rawDb;
|
|
236
|
+
const responseBuilder = new require_lazyAccessors.ResponseBuilder();
|
|
237
|
+
const response = await this.endpoint.handler({
|
|
238
|
+
body,
|
|
239
|
+
query,
|
|
240
|
+
params,
|
|
241
|
+
session,
|
|
242
|
+
services: ctx.services,
|
|
243
|
+
logger,
|
|
244
|
+
header,
|
|
245
|
+
cookie,
|
|
246
|
+
auditor,
|
|
247
|
+
db
|
|
248
|
+
}, responseBuilder);
|
|
249
|
+
let data = response;
|
|
250
|
+
let metadata$1 = responseBuilder.getMetadata();
|
|
251
|
+
if (require_lazyAccessors.Endpoint.hasMetadata(response)) {
|
|
252
|
+
data = response.data;
|
|
253
|
+
metadata$1 = response.metadata;
|
|
301
254
|
}
|
|
255
|
+
const output$1 = await this.endpoint.parseOutput(data);
|
|
302
256
|
return {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
257
|
+
output: output$1,
|
|
258
|
+
metadata: metadata$1,
|
|
259
|
+
responseBuilder
|
|
306
260
|
};
|
|
307
|
-
})
|
|
261
|
+
}, async (result$1, auditor) => {
|
|
262
|
+
if (!audits?.length) return;
|
|
263
|
+
for (const audit of audits) {
|
|
264
|
+
if (audit.when && !audit.when(result$1.output)) continue;
|
|
265
|
+
const payload = audit.payload(result$1.output);
|
|
266
|
+
const entityId = audit.entityId?.(result$1.output);
|
|
267
|
+
auditor.audit(audit.type, payload, {
|
|
268
|
+
table: audit.table,
|
|
269
|
+
entityId
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}, { db: rawDb });
|
|
273
|
+
const { output, metadata } = result;
|
|
274
|
+
ctx.publisher && await this.serviceDiscovery.register([ctx.publisher]);
|
|
275
|
+
await require_publisher.publishConstructEvents(this.endpoint, output, this.serviceDiscovery);
|
|
276
|
+
const headers = { ...metadata.headers || {} };
|
|
277
|
+
if (metadata.cookies && metadata.cookies.size > 0) {
|
|
278
|
+
const setCookieValues = [];
|
|
279
|
+
for (const [name, cookie$1] of metadata.cookies.entries()) setCookieValues.push(serializeCookie(name, cookie$1.value, cookie$1.options));
|
|
280
|
+
headers["set-cookie"] = setCookieValues;
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
body: output,
|
|
284
|
+
status: metadata.status || 200,
|
|
285
|
+
headers
|
|
286
|
+
};
|
|
308
287
|
}
|
|
309
288
|
async request(ctx) {
|
|
310
|
-
|
|
289
|
+
const response = await this.fullRequest(ctx);
|
|
290
|
+
return response.body;
|
|
311
291
|
}
|
|
312
292
|
};
|
|
293
|
+
|
|
313
294
|
//#endregion
|
|
314
295
|
//#region src/functions/TestFunctionAdaptor.ts
|
|
315
296
|
var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
316
|
-
fn;
|
|
317
|
-
serviceDiscovery;
|
|
318
297
|
static getDefaultServiceDiscovery(_fn) {
|
|
319
|
-
return
|
|
298
|
+
return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
|
|
320
299
|
}
|
|
321
300
|
constructor(fn, serviceDiscovery = TestFunctionAdaptor.getDefaultServiceDiscovery(fn)) {
|
|
322
301
|
this.fn = fn;
|
|
@@ -330,12 +309,16 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
|
330
309
|
else services = await this.serviceDiscovery.register(this.fn.services);
|
|
331
310
|
let db;
|
|
332
311
|
if ("db" in ctx && ctx.db !== void 0) db = ctx.db;
|
|
333
|
-
else if (this.fn.databaseService)
|
|
312
|
+
else if (this.fn.databaseService) {
|
|
313
|
+
const dbServices = await this.serviceDiscovery.register([this.fn.databaseService]);
|
|
314
|
+
db = dbServices[this.fn.databaseService.serviceName];
|
|
315
|
+
}
|
|
334
316
|
let auditor;
|
|
335
317
|
if ("auditor" in ctx && ctx.auditor !== void 0) auditor = ctx.auditor;
|
|
336
318
|
else if (this.fn.auditorStorageService) {
|
|
337
|
-
const
|
|
338
|
-
|
|
319
|
+
const auditServices = await this.serviceDiscovery.register([this.fn.auditorStorageService]);
|
|
320
|
+
const storage = auditServices[this.fn.auditorStorageService.serviceName];
|
|
321
|
+
auditor = new __geekmidas_audit.DefaultAuditor({
|
|
339
322
|
actor: {
|
|
340
323
|
id: "system",
|
|
341
324
|
type: "system"
|
|
@@ -348,48 +331,64 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
|
348
331
|
});
|
|
349
332
|
}
|
|
350
333
|
const requestId = `test-${Date.now()}`;
|
|
351
|
-
|
|
334
|
+
const startTime = Date.now();
|
|
335
|
+
return (0, __geekmidas_services.runWithRequestContext)({
|
|
352
336
|
logger,
|
|
353
337
|
requestId,
|
|
354
|
-
startTime
|
|
338
|
+
startTime
|
|
355
339
|
}, async () => {
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
340
|
+
const monitor = await require_functions.startMonitors(this.fn, this.serviceDiscovery, logger);
|
|
341
|
+
try {
|
|
342
|
+
const output = await this.run({
|
|
343
|
+
parsedInput,
|
|
344
|
+
services,
|
|
345
|
+
logger,
|
|
346
|
+
db,
|
|
347
|
+
auditor
|
|
348
|
+
});
|
|
349
|
+
await monitor.success(output);
|
|
350
|
+
return output;
|
|
351
|
+
} catch (error) {
|
|
352
|
+
await monitor.failure(error);
|
|
353
|
+
throw error;
|
|
370
354
|
}
|
|
371
|
-
await require_functions.publishEvents(logger, this.serviceDiscovery, this.fn.events, output, services);
|
|
372
|
-
return output;
|
|
373
355
|
});
|
|
374
356
|
}
|
|
357
|
+
async run({ parsedInput, services, logger, db, auditor }) {
|
|
358
|
+
const response = await this.fn.fn({
|
|
359
|
+
input: parsedInput,
|
|
360
|
+
services,
|
|
361
|
+
logger,
|
|
362
|
+
db,
|
|
363
|
+
auditor
|
|
364
|
+
});
|
|
365
|
+
const output = await this.fn.parseOutput(response);
|
|
366
|
+
if (auditor) {
|
|
367
|
+
const records = auditor.getRecords();
|
|
368
|
+
if (records.length > 0) {
|
|
369
|
+
logger.debug({ auditCount: records.length }, "Flushing function audits");
|
|
370
|
+
await auditor.flush();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
await require_publisher.publishEvents(logger, this.serviceDiscovery, this.fn.events, output, this.fn.publisherService);
|
|
374
|
+
return output;
|
|
375
|
+
}
|
|
375
376
|
};
|
|
377
|
+
|
|
376
378
|
//#endregion
|
|
377
379
|
//#region src/queue/TestQueueAdaptor.ts
|
|
378
380
|
/**
|
|
379
381
|
* In-memory test driver for a {@link Queue} worker. Hand it a batch of messages
|
|
380
382
|
* and it registers the queue's services, runs the handler in a request context,
|
|
381
|
-
* and returns the handler result — no SQS/pg-boss required.
|
|
382
|
-
* database gets `db` registered from it, or the one the request passes.
|
|
383
|
+
* and returns the handler result — no SQS/pg-boss required.
|
|
383
384
|
*
|
|
384
385
|
* @example
|
|
385
386
|
* const adapter = new TestQueueAdaptor(ordersQueue);
|
|
386
387
|
* await adapter.invoke({ messages: [{ orderId: '123' }] });
|
|
387
388
|
*/
|
|
388
389
|
var TestQueueAdaptor = class TestQueueAdaptor {
|
|
389
|
-
queue;
|
|
390
|
-
serviceDiscovery;
|
|
391
390
|
static getDefaultServiceDiscovery() {
|
|
392
|
-
return
|
|
391
|
+
return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
|
|
393
392
|
}
|
|
394
393
|
constructor(queue, serviceDiscovery = TestQueueAdaptor.getDefaultServiceDiscovery()) {
|
|
395
394
|
this.queue = queue;
|
|
@@ -398,35 +397,25 @@ var TestQueueAdaptor = class TestQueueAdaptor {
|
|
|
398
397
|
async invoke(request) {
|
|
399
398
|
const logger = this.queue.logger.child({ test: true });
|
|
400
399
|
const services = request.services ?? await this.serviceDiscovery.register(this.queue.services);
|
|
401
|
-
const db = request.db !== void 0 ? request.db : await this.getDatabase();
|
|
402
400
|
const requestId = `test-${Date.now()}`;
|
|
403
401
|
const startTime = Date.now();
|
|
404
|
-
|
|
405
|
-
return (0, _geekmidas_services.runWithRequestContext)({
|
|
402
|
+
return (0, __geekmidas_services.runWithRequestContext)({
|
|
406
403
|
logger,
|
|
407
404
|
requestId,
|
|
408
|
-
startTime
|
|
409
|
-
operation
|
|
405
|
+
startTime
|
|
410
406
|
}, () => this.queue.handler({
|
|
411
407
|
messages: request.messages,
|
|
412
408
|
services,
|
|
413
|
-
logger
|
|
414
|
-
db
|
|
409
|
+
logger
|
|
415
410
|
}));
|
|
416
411
|
}
|
|
417
|
-
async getDatabase() {
|
|
418
|
-
const service = this.queue.databaseService;
|
|
419
|
-
if (!service) return void 0;
|
|
420
|
-
return (await this.serviceDiscovery.register([service]))[service.serviceName];
|
|
421
|
-
}
|
|
422
412
|
};
|
|
413
|
+
|
|
423
414
|
//#endregion
|
|
424
415
|
//#region src/subscribers/TestSubscriberAdaptor.ts
|
|
425
416
|
var TestSubscriberAdaptor = class TestSubscriberAdaptor {
|
|
426
|
-
subscriber;
|
|
427
|
-
serviceDiscovery;
|
|
428
417
|
static getDefaultServiceDiscovery() {
|
|
429
|
-
return
|
|
418
|
+
return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
|
|
430
419
|
}
|
|
431
420
|
constructor(subscriber, serviceDiscovery = TestSubscriberAdaptor.getDefaultServiceDiscovery()) {
|
|
432
421
|
this.subscriber = subscriber;
|
|
@@ -437,23 +426,19 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
|
|
|
437
426
|
let services;
|
|
438
427
|
if (request.services) services = request.services;
|
|
439
428
|
else services = await this.serviceDiscovery.register(this.subscriber.services);
|
|
440
|
-
const db = request.db !== void 0 ? request.db : await this.getDatabase();
|
|
441
429
|
const filteredEvents = this.filterEvents(request.events);
|
|
442
430
|
if (filteredEvents.length === 0) return { batchItemFailures: [] };
|
|
443
431
|
const requestId = `test-${Date.now()}`;
|
|
444
432
|
const startTime = Date.now();
|
|
445
|
-
|
|
446
|
-
return (0, _geekmidas_services.runWithRequestContext)({
|
|
433
|
+
return (0, __geekmidas_services.runWithRequestContext)({
|
|
447
434
|
logger,
|
|
448
435
|
requestId,
|
|
449
|
-
startTime
|
|
450
|
-
operation
|
|
436
|
+
startTime
|
|
451
437
|
}, async () => {
|
|
452
438
|
const result = await this.subscriber.handler({
|
|
453
439
|
events: filteredEvents,
|
|
454
440
|
services,
|
|
455
|
-
logger
|
|
456
|
-
db
|
|
441
|
+
logger
|
|
457
442
|
});
|
|
458
443
|
let output = result;
|
|
459
444
|
if (this.subscriber.outputSchema && result) {
|
|
@@ -461,628 +446,21 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
|
|
|
461
446
|
if (validationResult.issues) throw new Error("Subscriber output validation failed");
|
|
462
447
|
output = validationResult.value;
|
|
463
448
|
}
|
|
449
|
+
await require_publisher.publishEvents(logger, this.serviceDiscovery, this.subscriber.events, output, this.subscriber.publisherService);
|
|
464
450
|
return output;
|
|
465
451
|
});
|
|
466
452
|
}
|
|
467
|
-
async getDatabase() {
|
|
468
|
-
const service = this.subscriber.databaseService;
|
|
469
|
-
if (!service) return void 0;
|
|
470
|
-
return (await this.serviceDiscovery.register([service]))[service.serviceName];
|
|
471
|
-
}
|
|
472
453
|
filterEvents(events) {
|
|
473
454
|
if (!this.subscriber.subscribedEvents) return events;
|
|
474
455
|
return events.filter((event) => this.subscriber.subscribedEvents.includes(event.type));
|
|
475
456
|
}
|
|
476
457
|
};
|
|
458
|
+
|
|
477
459
|
//#endregion
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* The test manifest: what `gkm test` knows about an app, written down for the
|
|
481
|
-
* suite it starts.
|
|
482
|
-
*
|
|
483
|
-
* `gkm test` discovers the constructs, reconciles the test stage and resolves
|
|
484
|
-
* its environment — then, until this existed, threw all of it away and left a
|
|
485
|
-
* test to declare it again by hand. The manifest keeps it: which construct and
|
|
486
|
-
* endpoint is exported where, and the environment the test stage resolved,
|
|
487
|
-
* under the keys the constructs themselves derive. A feature test is built from
|
|
488
|
-
* it, so nothing a test says can drift from what the app declares.
|
|
489
|
-
*/
|
|
490
|
-
/** The environment variable `gkm test` names the manifest in. */
|
|
491
|
-
const TEST_MANIFEST_ENV = "GKM_TEST_MANIFEST";
|
|
492
|
-
/**
|
|
493
|
-
* Read a test manifest: from a path, a `file:` URL, or — given nothing — the
|
|
494
|
-
* one `gkm test` named in `GKM_TEST_MANIFEST`.
|
|
495
|
-
*/
|
|
496
|
-
function loadTestManifest(from) {
|
|
497
|
-
const location = from ?? process.env["GKM_TEST_MANIFEST"];
|
|
498
|
-
if (!location) throw new NoTestManifest();
|
|
499
|
-
trustLocalEdge();
|
|
500
|
-
const path = location instanceof URL || location.startsWith("file:") ? (0, node_url.fileURLToPath)(location) : location;
|
|
501
|
-
return JSON.parse((0, node_fs.readFileSync)(path, "utf-8"));
|
|
502
|
-
}
|
|
503
|
-
let trusted = false;
|
|
504
|
-
/**
|
|
505
|
-
* Trust the local edge's certificate authority in this thread.
|
|
506
|
-
*
|
|
507
|
-
* `NODE_EXTRA_CA_CERTS` does it for a process started with it — which a
|
|
508
|
-
* suite started by `gkm test` is, and one started by plain `vitest` or an
|
|
509
|
-
* editor is not: its setup only learns the path once Vitest is running, and a
|
|
510
|
-
* worker *thread* shares that process and keeps a TLS store of its own. Every
|
|
511
|
-
* feature test loads the manifest, so this is the one place each worker passes
|
|
512
|
-
* through.
|
|
513
|
-
*/
|
|
514
|
-
function trustLocalEdge() {
|
|
515
|
-
const certificate = process.env.NODE_EXTRA_CA_CERTS;
|
|
516
|
-
if (trusted || !certificate || !(0, node_fs.existsSync)(certificate)) return;
|
|
517
|
-
trusted = true;
|
|
518
|
-
node_tls.default.setDefaultCACertificates([...node_tls.default.getCACertificates("default"), (0, node_fs.readFileSync)(certificate, "utf-8")]);
|
|
519
|
-
}
|
|
520
|
-
/** A feature test ran without a manifest to build itself from. */
|
|
521
|
-
var NoTestManifest = class extends Error {
|
|
522
|
-
constructor() {
|
|
523
|
-
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}.`);
|
|
524
|
-
this.name = "NoTestManifest";
|
|
525
|
-
}
|
|
526
|
-
};
|
|
527
|
-
//#endregion
|
|
528
|
-
//#region src/testing/featureTest.ts
|
|
529
|
-
/**
|
|
530
|
-
* `featureTest`: an app, driven the way it runs deployed.
|
|
531
|
-
*
|
|
532
|
-
* A browser signs in and calls the API; the API calls the auth server; each
|
|
533
|
-
* over its URL, each database in its own transaction. Nothing runs as a server:
|
|
534
|
-
* every URL an app's constructs answer on is served in-process through MSW,
|
|
535
|
-
* from the real handler, for the test that made the request. Everything else
|
|
536
|
-
* with a real local equivalent — Postgres, Mailpit, MinIO — is used directly.
|
|
537
|
-
*
|
|
538
|
-
* It is built from the test manifest `gkm test` writes — the constructs and
|
|
539
|
-
* endpoints the app exports, and the environment the test stage resolved — so
|
|
540
|
-
* a test declares none of it. `gkm test` also generates the configured `it`
|
|
541
|
-
* and a `Browser` with a typed client per surface:
|
|
542
|
-
*
|
|
543
|
-
* ```ts
|
|
544
|
-
* import { it } from '#test';
|
|
545
|
-
*
|
|
546
|
-
* it('shows the signed-in user their profile', async ({ browser, mailbox }) => {
|
|
547
|
-
* await browser.auth.signIn.magicLink({ email: 'ada@shop.test' });
|
|
548
|
-
* await browser.visit((await mailbox('ada@shop.test').last()).link!);
|
|
549
|
-
* expect(await browser.api.get('/profile')).toMatchObject({ email: 'ada@shop.test' });
|
|
550
|
-
* });
|
|
551
|
-
* ```
|
|
552
|
-
*/
|
|
553
|
-
/** Every test in flight in this process, by id. */
|
|
554
|
-
const contexts = /* @__PURE__ */ new Map();
|
|
555
|
-
/** Databases already resolving to test transactions — patched once each. */
|
|
556
|
-
const bound = /* @__PURE__ */ new WeakSet();
|
|
557
|
-
function featureTest(options = {}) {
|
|
558
|
-
const manifest = options.manifest ?? loadTestManifest();
|
|
559
|
-
const BrowserClass = options.browser ?? _geekmidas_testkit_browser.Browser;
|
|
560
|
-
let app;
|
|
561
|
-
let factoryDatabases = [];
|
|
562
|
-
let owned = [];
|
|
563
|
-
let network;
|
|
564
|
-
let restoreFetch = () => {};
|
|
565
|
-
(0, vitest.beforeAll)(async () => {
|
|
566
|
-
app = await load(manifest, options.modules ?? {});
|
|
567
|
-
owned = ownDatabases(app, manifest);
|
|
568
|
-
factoryDatabases = databasesFor(options.factories ?? {}, owned);
|
|
569
|
-
for (const database of app.databases) bindToTests(database);
|
|
570
|
-
network = (0, msw_node.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)));
|
|
571
|
-
network.listen({ onUnhandledRequest(request, print) {
|
|
572
|
-
if (isLocal(new URL(request.url))) return;
|
|
573
|
-
print.error();
|
|
574
|
-
} });
|
|
575
|
-
const restoreStamp = (0, _geekmidas_testkit_context.installContextFetch)();
|
|
576
|
-
const stamped = globalThis.fetch;
|
|
577
|
-
globalThis.fetch = deliveringFetch(stamped, (id) => {
|
|
578
|
-
const state = contexts.get(id);
|
|
579
|
-
return state ? deliver(app, state, id) : Promise.resolve();
|
|
580
|
-
});
|
|
581
|
-
restoreFetch = () => {
|
|
582
|
-
globalThis.fetch = stamped;
|
|
583
|
-
restoreStamp();
|
|
584
|
-
};
|
|
585
|
-
});
|
|
586
|
-
(0, vitest.afterAll)(() => {
|
|
587
|
-
restoreFetch();
|
|
588
|
-
network?.close();
|
|
589
|
-
});
|
|
590
|
-
const run = (name, fn) => async () => {
|
|
591
|
-
const id = (0, node_crypto.randomUUID)();
|
|
592
|
-
_geekmidas_testkit_faker.faker.seed(seedOf(name));
|
|
593
|
-
const state = {
|
|
594
|
-
transactions: new _geekmidas_testkit_transactions.TransactionRegistry(),
|
|
595
|
-
discovery: new _geekmidas_services.ServiceDiscovery(app.envParser),
|
|
596
|
-
surfaces: /* @__PURE__ */ new Map(),
|
|
597
|
-
auth: /* @__PURE__ */ new Map(),
|
|
598
|
-
addresses: /* @__PURE__ */ new Set(),
|
|
599
|
-
published: /* @__PURE__ */ new Map(),
|
|
600
|
-
pending: [],
|
|
601
|
-
delivering: false
|
|
602
|
-
};
|
|
603
|
-
const readMail = app.readMail;
|
|
604
|
-
if (readMail) state.mailbox = (address) => {
|
|
605
|
-
state.addresses.add(address);
|
|
606
|
-
return readMail(address);
|
|
607
|
-
};
|
|
608
|
-
contexts.set(id, state);
|
|
609
|
-
await state.discovery.register(recorders(app.channels, state));
|
|
610
|
-
try {
|
|
611
|
-
await (0, _geekmidas_testkit_context.runInTestContext)(id, async () => {
|
|
612
|
-
const browser = new BrowserClass();
|
|
613
|
-
const restore = browser.install();
|
|
614
|
-
try {
|
|
615
|
-
const transaction = (database) => state.transactions.get(database.id, urlOf(database, app.envParser), database.clientConfig);
|
|
616
|
-
const db = { get: (name) => {
|
|
617
|
-
const database = owned.find((candidate) => candidate.service.serviceName === name);
|
|
618
|
-
if (!database) throw new UnknownDatabase(name, owned.map((candidate) => candidate.service.serviceName));
|
|
619
|
-
return transaction(database);
|
|
620
|
-
} };
|
|
621
|
-
const built = /* @__PURE__ */ new Map();
|
|
622
|
-
await fn({
|
|
623
|
-
browser,
|
|
624
|
-
db,
|
|
625
|
-
factories: { get: (name) => {
|
|
626
|
-
const database = factoryDatabases.find(([candidate]) => candidate === name)?.[1];
|
|
627
|
-
if (!database) throw new UnknownFactory(name, factoryDatabases.map(([candidate]) => candidate));
|
|
628
|
-
let factory = built.get(name);
|
|
629
|
-
if (!factory) {
|
|
630
|
-
factory = transaction(database).then(options.factories[name]);
|
|
631
|
-
built.set(name, factory);
|
|
632
|
-
}
|
|
633
|
-
return factory;
|
|
634
|
-
} },
|
|
635
|
-
faker: _geekmidas_testkit_faker.faker,
|
|
636
|
-
mailbox: (address) => {
|
|
637
|
-
if (!state.mailbox) throw new NoInbox();
|
|
638
|
-
return state.mailbox(address);
|
|
639
|
-
},
|
|
640
|
-
published: (channel) => [...state.published.get(channel.id) ?? []],
|
|
641
|
-
services: { get: (name) => resolveService(app, state, name) },
|
|
642
|
-
subscriber: (subscriber) => thenDeliver(new TestSubscriberAdaptor(subscriber, state.discovery), () => deliver(app, state, id)),
|
|
643
|
-
queue: (queue) => thenDeliver(new TestQueueAdaptor(queue, state.discovery), () => deliver(app, state, id))
|
|
644
|
-
});
|
|
645
|
-
} finally {
|
|
646
|
-
restore();
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
} finally {
|
|
650
|
-
contexts.delete(id);
|
|
651
|
-
await Promise.all([state.transactions.rollbackAll(), ...[...state.addresses].map((address) => app.readMail?.(address).clear())]);
|
|
652
|
-
}
|
|
653
|
-
};
|
|
654
|
-
const it = ((name, fn, timeout) => (0, vitest.test)(name, run(name, fn), timeout));
|
|
655
|
-
it.only = (name, fn, timeout) => vitest.test.only(name, run(name, fn), timeout);
|
|
656
|
-
it.skip = (name, fn, timeout) => vitest.test.skip(name, run(name, fn), timeout);
|
|
657
|
-
return it;
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* A test's faker seed, from its name: the same test draws the same data on
|
|
661
|
-
* every run, and two tests draw different data.
|
|
662
|
-
*/
|
|
663
|
-
function seedOf(name) {
|
|
664
|
-
let hash = 0;
|
|
665
|
-
for (const char of name) hash = Math.imul(hash, 31) + char.charCodeAt(0) | 0;
|
|
666
|
-
return hash >>> 0;
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* Import what the manifest points at.
|
|
670
|
-
*
|
|
671
|
-
* The same modules the app runs, so a construct here *is* the app's construct —
|
|
672
|
-
* the one its endpoints were built from — never a copy declared again.
|
|
673
|
-
*/
|
|
674
|
-
async function load(manifest, modules) {
|
|
675
|
-
const envParser = new _geekmidas_envkit.EnvironmentParser({ ...manifest.env });
|
|
676
|
-
const imported = async ({ file, export: name }) => (modules[file] ?? await import(file))[name];
|
|
677
|
-
const constructs = await Promise.all(Object.values(manifest.constructs).map(({ source }) => imported(source)));
|
|
678
|
-
const endpoints = (await Promise.all(manifest.endpoints.map(({ source }) => imported(source)))).filter((value) => require_Endpoint.Endpoint.isEndpoint(value));
|
|
679
|
-
const subscribers = (await Promise.all((manifest.subscribers ?? []).map(async ({ source }) => ({
|
|
680
|
-
name: source.export,
|
|
681
|
-
subscriber: await imported(source)
|
|
682
|
-
})))).filter((entry) => entry.subscriber?.__IS_SUBSCRIBER__ === true);
|
|
683
|
-
const unique = (values) => [...new Set(values)];
|
|
684
|
-
const databases = unique(constructs.filter((value) => value instanceof require_kysely.KyselyDatabase));
|
|
685
|
-
const auths = unique(constructs.filter((value) => value instanceof require_auth.BetterAuth));
|
|
686
|
-
const emails = unique(constructs.filter((value) => value instanceof require_email.Email));
|
|
687
|
-
const consumables = unique(constructs.filter(require_construct_interface.isConsumable));
|
|
688
|
-
const channels = unique(constructs.filter((value) => value instanceof require_Topic.Topic || value instanceof require_Queue.Queue));
|
|
689
|
-
const inbox = emails.map((email) => manifest.env[(0, _geekmidas_manifest.provideKey)(email.id, "inboxUrl")]).find(Boolean);
|
|
690
|
-
return {
|
|
691
|
-
envParser,
|
|
692
|
-
endpoints,
|
|
693
|
-
databases,
|
|
694
|
-
auths,
|
|
695
|
-
emails,
|
|
696
|
-
channels,
|
|
697
|
-
consumables,
|
|
698
|
-
subscribers,
|
|
699
|
-
...inbox ? { readMail: (0, _geekmidas_testkit_mailbox.createMailbox)({ inbox }) } : {}
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* A publisher that records rather than sends, under the name a topic or queue
|
|
704
|
-
* is injected by — `services.users` — which is also the one `.event(users, …)`
|
|
705
|
-
* publishes through.
|
|
706
|
-
*/
|
|
707
|
-
function recorders(channels, state) {
|
|
708
|
-
return channels.map((channel) => {
|
|
709
|
-
const publisher = { async publish(messages) {
|
|
710
|
-
const sent = messages.map(({ type, payload }) => ({
|
|
711
|
-
type,
|
|
712
|
-
payload
|
|
713
|
-
}));
|
|
714
|
-
state.published.set(channel.id, [...state.published.get(channel.id) ?? [], ...sent]);
|
|
715
|
-
state.pending.push({
|
|
716
|
-
channel,
|
|
717
|
-
messages: sent
|
|
718
|
-
});
|
|
719
|
-
} };
|
|
720
|
-
return {
|
|
721
|
-
serviceName: channel.service.serviceName,
|
|
722
|
-
register: () => publisher
|
|
723
|
-
};
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* The databases a test is handed: the app's own. A schema tenant an auth server
|
|
728
|
-
* owns is reached through that server, as the app reaches it, and a reader is
|
|
729
|
-
* the same database through a read-only role — neither is another database to
|
|
730
|
-
* test against.
|
|
731
|
-
*/
|
|
732
|
-
function ownDatabases(app, manifest) {
|
|
733
|
-
const owners = new Set(app.auths.map((auth) => auth.databaseId));
|
|
734
|
-
return app.databases.filter((database) => !owners.has(database.id) && manifest.constructs[database.id]?.kind !== "database-reader");
|
|
735
|
-
}
|
|
736
|
-
/** Each factory's database, found by the service name it is keyed by. */
|
|
737
|
-
function databasesFor(factories, databases) {
|
|
738
|
-
return Object.keys(factories).map((name) => {
|
|
739
|
-
const database = databases.find((candidate) => candidate.service.serviceName === name);
|
|
740
|
-
if (!database) throw new UnknownFactory(name, databases.map((candidate) => candidate.service.serviceName));
|
|
741
|
-
return [name, database];
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Make a database resolve, inside a test, to that test's transaction.
|
|
746
|
-
*
|
|
747
|
-
* Everything reaches a database through its service — an endpoint through
|
|
748
|
-
* service discovery, the auth server through its tenant directly — so this is
|
|
749
|
-
* the one place a test's connection can be handed over. Outside a test it is
|
|
750
|
-
* the database it always was.
|
|
751
|
-
*/
|
|
752
|
-
/** Rounds of delivery before a chain of consumers is called a loop. */
|
|
753
|
-
const MAX_DELIVERY_ROUNDS = 25;
|
|
754
|
-
/**
|
|
755
|
-
* Deliver what this test published, in-process, as the broker would — and
|
|
756
|
-
* keep delivering what the consumers publish in turn, until nothing is left.
|
|
757
|
-
*
|
|
758
|
-
* - A queue's messages go to its one consumer, as a batch.
|
|
759
|
-
* - A topic's events go to every subscriber that named their type, and only
|
|
760
|
-
* those: fan-out, as the filter policy (SNS) or the per-subscriber queue
|
|
761
|
-
* (pg-boss) does it.
|
|
762
|
-
* - Each payload is checked against the consumer's schema first. Turning an
|
|
763
|
-
* SNS envelope or an SQS record into `{ type, payload }` is each adaptor's
|
|
764
|
-
* job and tested there; what is tested here is what the handler is handed.
|
|
765
|
-
* - Consumers run as the server side of this test, so their databases are
|
|
766
|
-
* this test's transactions and their writes roll back with it.
|
|
767
|
-
* - A consumer that throws fails the test. Deployed, the message would be
|
|
768
|
-
* retried; here a retry would only hide the bug.
|
|
769
|
-
*/
|
|
770
|
-
async function deliver(app, state, id) {
|
|
771
|
-
if (state.delivering) return;
|
|
772
|
-
state.delivering = true;
|
|
773
|
-
try {
|
|
774
|
-
for (let round = 0; state.pending.length > 0; round++) {
|
|
775
|
-
if (round === MAX_DELIVERY_ROUNDS) throw new DeliveryDidNotSettle(MAX_DELIVERY_ROUNDS, [...new Set(state.pending.map(({ channel }) => channel.id))]);
|
|
776
|
-
for (const { channel, messages } of state.pending.splice(0)) if (channel instanceof require_Queue.Queue) await toQueue(channel, messages, state, id);
|
|
777
|
-
else await toSubscribers(channel, messages, app, state, id);
|
|
778
|
-
}
|
|
779
|
-
} finally {
|
|
780
|
-
state.delivering = false;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
async function toQueue(queue, messages, state, id) {
|
|
784
|
-
const payloads = [];
|
|
785
|
-
for (const message of messages) payloads.push(await accepted(queue.messageSchema, message, `queue '${queue.name}'`));
|
|
786
|
-
await (0, _geekmidas_testkit_context.runAsServer)(id, () => new TestQueueAdaptor(queue, state.discovery).invoke({ messages: payloads })).catch((error) => {
|
|
787
|
-
throw new DeliveryFailed(`queue '${queue.name}'`, messages, error);
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
async function toSubscribers(topic, messages, app, state, id) {
|
|
791
|
-
for (const { name, subscriber } of app.subscribers) {
|
|
792
|
-
if (subscriber.topicName !== topic.name) continue;
|
|
793
|
-
const named = messages.filter(({ type }) => (subscriber.subscribedEvents ?? []).includes(type));
|
|
794
|
-
if (named.length === 0) continue;
|
|
795
|
-
const consumer = `subscriber '${name}'`;
|
|
796
|
-
const events = [];
|
|
797
|
-
for (const message of named) {
|
|
798
|
-
const schema = topic.eventSchemas[message.type];
|
|
799
|
-
events.push({
|
|
800
|
-
type: message.type,
|
|
801
|
-
payload: await accepted(schema, message, consumer)
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
await (0, _geekmidas_testkit_context.runAsServer)(id, () => new TestSubscriberAdaptor(subscriber, state.discovery).invoke({ events })).catch((error) => {
|
|
805
|
-
throw new DeliveryFailed(consumer, named, error);
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
/** The payload, if the consumer's schema takes it — what the handler is handed. */
|
|
810
|
-
async function accepted(schema, message, consumer) {
|
|
811
|
-
const standard = schema?.["~standard"];
|
|
812
|
-
if (!standard) return message.payload;
|
|
813
|
-
const result = await standard.validate(message.payload);
|
|
814
|
-
if (result.issues) throw new MessageRejected(consumer, message, result.issues);
|
|
815
|
-
return result.value;
|
|
816
|
-
}
|
|
817
|
-
/** `fetch`, delivering what the test published once each of its requests answers. */
|
|
818
|
-
function deliveringFetch(inner, settle) {
|
|
819
|
-
return async (input, init) => {
|
|
820
|
-
const context = (0, _geekmidas_testkit_context.currentTestContext)();
|
|
821
|
-
const response = await inner(input, init);
|
|
822
|
-
if (context?.side === "client") await settle(context.id);
|
|
823
|
-
return response;
|
|
824
|
-
};
|
|
825
|
-
}
|
|
826
|
-
/** An adaptor whose `invoke` delivers what it published before returning. */
|
|
827
|
-
function thenDeliver(adaptor, settle) {
|
|
828
|
-
const invoke = adaptor.invoke.bind(adaptor);
|
|
829
|
-
adaptor.invoke = (async (...args) => {
|
|
830
|
-
const result = await invoke(...args);
|
|
831
|
-
await settle();
|
|
832
|
-
return result;
|
|
833
|
-
});
|
|
834
|
-
return adaptor;
|
|
835
|
-
}
|
|
836
|
-
function bindToTests(database) {
|
|
837
|
-
if (bound.has(database)) return;
|
|
838
|
-
bound.add(database);
|
|
839
|
-
const service = database.service;
|
|
840
|
-
const register = service.register;
|
|
841
|
-
service.register = (options) => {
|
|
842
|
-
const context = (0, _geekmidas_testkit_context.currentTestContext)();
|
|
843
|
-
const state = context && contexts.get(context.id);
|
|
844
|
-
if (!state) return register(options);
|
|
845
|
-
return state.transactions.get(database.id, urlOf(database, options.envParser), database.clientConfig);
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
function urlOf(database, envParser) {
|
|
849
|
-
return envParser.create((get) => ({ url: get((0, _geekmidas_manifest.provideKey)(database.id, "url")).string() })).parse().url;
|
|
850
|
-
}
|
|
851
|
-
/** Each surface's endpoints, served at its URL for the test that asked. */
|
|
852
|
-
function surfaceHandlers(endpoints, env) {
|
|
853
|
-
const bySurface = /* @__PURE__ */ new Map();
|
|
854
|
-
for (const endpoint of endpoints) {
|
|
855
|
-
const surface = endpoint.surface?.id;
|
|
856
|
-
if (!surface) continue;
|
|
857
|
-
bySurface.set(surface, [...bySurface.get(surface) ?? [], endpoint]);
|
|
858
|
-
}
|
|
859
|
-
return [...bySurface].flatMap(([surface, served]) => {
|
|
860
|
-
const base = env[(0, _geekmidas_manifest.provideKey)(surface, "url")];
|
|
861
|
-
if (!base) return [];
|
|
862
|
-
return msw.http.all(`${trim(base)}/*`, ({ request }) => serve(request, async (state) => {
|
|
863
|
-
let app = state.surfaces.get(surface);
|
|
864
|
-
if (!app) {
|
|
865
|
-
app = Promise.resolve().then(() => {
|
|
866
|
-
const hono$1 = new hono.Hono();
|
|
867
|
-
require_HonoEndpointAdaptor.HonoEndpoint.addRoutes(served, state.discovery, hono$1);
|
|
868
|
-
return hono$1;
|
|
869
|
-
});
|
|
870
|
-
state.surfaces.set(surface, app);
|
|
871
|
-
}
|
|
872
|
-
return (await app).fetch(request, inProcessBindings());
|
|
873
|
-
}));
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
/**
|
|
877
|
-
* An external API's app fake, answering at the URL the test stage resolved for
|
|
878
|
-
* it — so a handler that calls Polar calls the fake, and the test sets up
|
|
879
|
-
* nothing.
|
|
880
|
-
*
|
|
881
|
-
* Not per test, unlike a surface: a fake stands in for somebody else's server,
|
|
882
|
-
* which no test's transaction reaches. An image fake has no handler here — its
|
|
883
|
-
* container answers on localhost, which is let through.
|
|
884
|
-
*/
|
|
885
|
-
function fakeHandler(id, fake, env) {
|
|
886
|
-
const base = env[(0, _geekmidas_manifest.provideKey)(id, "url")];
|
|
887
|
-
if (fake.kind !== "app" || !base) return [];
|
|
888
|
-
return [msw.http.all(`${trim(base)}/*`, ({ request }) => fake.handler.fetch(request))];
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
* A construct's client for this test, by service name — through the test's own
|
|
892
|
-
* discovery, so a topic or queue is its recorder and a database its
|
|
893
|
-
* transaction, exactly as the test's endpoints get them.
|
|
894
|
-
*/
|
|
895
|
-
async function resolveService(app, state, name) {
|
|
896
|
-
const construct = app.consumables.find((candidate) => candidate.service.serviceName === name);
|
|
897
|
-
if (!construct) throw new UnknownService(name, app.consumables.map((candidate) => candidate.service.serviceName));
|
|
898
|
-
return (await state.discovery.register([construct.service]))[name];
|
|
899
|
-
}
|
|
900
|
-
/** An auth server, served at its URL, on the transaction of the test that asked. */
|
|
901
|
-
function authHandler(auth, env, envParser) {
|
|
902
|
-
const base = trim(env[(0, _geekmidas_manifest.provideKey)(auth.id, "url")] ?? "");
|
|
903
|
-
return msw.http.all(`${base}/*`, ({ request }) => serve(request, async (state) => {
|
|
904
|
-
let app = state.auth.get(auth);
|
|
905
|
-
if (!app) {
|
|
906
|
-
app = auth.server({
|
|
907
|
-
envParser,
|
|
908
|
-
context: _geekmidas_services.serviceContext
|
|
909
|
-
}).then(({ app }) => app);
|
|
910
|
-
state.auth.set(auth, app);
|
|
911
|
-
}
|
|
912
|
-
return (await app).fetch(request, inProcessBindings());
|
|
913
|
-
}));
|
|
914
|
-
}
|
|
915
|
-
/** Handle a request as the server side of the test it was made for. */
|
|
916
|
-
async function serve(request, handle) {
|
|
917
|
-
const id = (0, _geekmidas_testkit_context.testContextOf)(request);
|
|
918
|
-
const state = id ? contexts.get(id) : void 0;
|
|
919
|
-
if (!id || !state) throw new UnknownTestContext(request.url, id);
|
|
920
|
-
return (0, _geekmidas_testkit_context.runAsServer)(id, () => handle(state));
|
|
921
|
-
}
|
|
922
|
-
function trim(url) {
|
|
923
|
-
return url.replace(/\/$/, "");
|
|
924
|
-
}
|
|
925
|
-
function isLocal(url) {
|
|
926
|
-
return url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname.endsWith(".localhost");
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* Sign a test's browser in the way a person does: ask the auth server for a
|
|
930
|
-
* magic link, open the email it sent, follow the link.
|
|
931
|
-
*
|
|
932
|
-
* What the generated `browser.signIn(email)` calls. The address's mail is
|
|
933
|
-
* cleared first — so the link is this request's, not one an earlier test left
|
|
934
|
-
* — and cleared again after the test, like any address a test reads. Returns
|
|
935
|
-
* the session the auth server then reports, as better-auth hands it back.
|
|
936
|
-
*/
|
|
937
|
-
async function signInWithMagicLink(browser, auth, email = freshAddress()) {
|
|
938
|
-
const context = (0, _geekmidas_testkit_context.currentTestContext)();
|
|
939
|
-
const state = context && contexts.get(context.id);
|
|
940
|
-
if (!state) throw new UnknownTestContext("signIn", context?.id);
|
|
941
|
-
if (!state.mailbox) throw new NoInbox();
|
|
942
|
-
const inbox = state.mailbox(email);
|
|
943
|
-
await inbox.clear();
|
|
944
|
-
const requested = await auth.signIn.magicLink({ email });
|
|
945
|
-
if (requested.error) throw new SignInFailed(email, `the auth server refused the magic link: ${requested.error.message ?? "no reason given"}`);
|
|
946
|
-
const mail = await inbox.last();
|
|
947
|
-
if (!mail.link) throw new SignInFailed(email, "its email held no link");
|
|
948
|
-
await browser.visit(mail.link);
|
|
949
|
-
const { data } = await auth.getSession();
|
|
950
|
-
if (!data) throw new SignInFailed(email, "the auth server reported no session after the link was opened");
|
|
951
|
-
return data;
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* An address nobody else signs in as — what `browser.signIn()` uses when the
|
|
955
|
-
* test does not care who it is.
|
|
956
|
-
*
|
|
957
|
-
* Unique rather than only seeded: tests in other files run at the same time,
|
|
958
|
-
* against the same Mailpit and the same unique columns, and a seeded address
|
|
959
|
-
* repeats wherever two tests share a name. The readable half is the seeded
|
|
960
|
-
* faker's, so a failure still names somebody.
|
|
961
|
-
*/
|
|
962
|
-
function freshAddress() {
|
|
963
|
-
return `${_geekmidas_testkit_faker.faker.internet.username().toLowerCase().replace(/[^a-z0-9]/g, "")}.${(0, node_crypto.randomUUID)().slice(0, 8)}@example.test`;
|
|
964
|
-
}
|
|
965
|
-
/** `browser.signIn` finished without a session. */
|
|
966
|
-
var SignInFailed = class extends Error {
|
|
967
|
-
email;
|
|
968
|
-
reason;
|
|
969
|
-
constructor(email, reason) {
|
|
970
|
-
super(`Signing ${email} in failed: ${reason}.`);
|
|
971
|
-
this.email = email;
|
|
972
|
-
this.reason = reason;
|
|
973
|
-
this.name = "SignInFailed";
|
|
974
|
-
}
|
|
975
|
-
};
|
|
976
|
-
/** A request reached an in-process server without a test to belong to. */
|
|
977
|
-
var UnknownTestContext = class extends Error {
|
|
978
|
-
url;
|
|
979
|
-
id;
|
|
980
|
-
constructor(url, id) {
|
|
981
|
-
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.`);
|
|
982
|
-
this.url = url;
|
|
983
|
-
this.id = id;
|
|
984
|
-
this.name = "UnknownTestContext";
|
|
985
|
-
}
|
|
986
|
-
};
|
|
987
|
-
/** `mailbox` was used in an app that declares no Email construct. */
|
|
988
|
-
var NoInbox = class extends Error {
|
|
989
|
-
constructor() {
|
|
990
|
-
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.");
|
|
991
|
-
this.name = "NoInbox";
|
|
992
|
-
}
|
|
993
|
-
};
|
|
994
|
-
/** `db.get(name)` named no database the test is handed. */
|
|
995
|
-
var UnknownDatabase = class extends Error {
|
|
996
|
-
database;
|
|
997
|
-
known;
|
|
998
|
-
constructor(database, known) {
|
|
999
|
-
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.");
|
|
1000
|
-
this.database = database;
|
|
1001
|
-
this.known = known;
|
|
1002
|
-
this.name = "UnknownDatabase";
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
/** A factory keyed by a service name no database the app declares has. */
|
|
1006
|
-
var UnknownFactory = class extends Error {
|
|
1007
|
-
factory;
|
|
1008
|
-
known;
|
|
1009
|
-
constructor(factory, known) {
|
|
1010
|
-
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.`);
|
|
1011
|
-
this.factory = factory;
|
|
1012
|
-
this.known = known;
|
|
1013
|
-
this.name = "UnknownFactory";
|
|
1014
|
-
}
|
|
1015
|
-
};
|
|
1016
|
-
/** A published message the consumer's own schema refuses. */
|
|
1017
|
-
var MessageRejected = class extends Error {
|
|
1018
|
-
consumer;
|
|
1019
|
-
published;
|
|
1020
|
-
issues;
|
|
1021
|
-
constructor(consumer, published, issues) {
|
|
1022
|
-
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.`);
|
|
1023
|
-
this.consumer = consumer;
|
|
1024
|
-
this.published = published;
|
|
1025
|
-
this.issues = issues;
|
|
1026
|
-
this.name = "MessageRejected";
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
/** A consumer that threw while handling what the test published. */
|
|
1030
|
-
var DeliveryFailed = class extends Error {
|
|
1031
|
-
consumer;
|
|
1032
|
-
messages;
|
|
1033
|
-
cause;
|
|
1034
|
-
constructor(consumer, messages, cause) {
|
|
1035
|
-
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 });
|
|
1036
|
-
this.consumer = consumer;
|
|
1037
|
-
this.messages = messages;
|
|
1038
|
-
this.cause = cause;
|
|
1039
|
-
this.name = "DeliveryFailed";
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
/** Consumers that kept publishing to each other without settling. */
|
|
1043
|
-
var DeliveryDidNotSettle = class extends Error {
|
|
1044
|
-
rounds;
|
|
1045
|
-
channels;
|
|
1046
|
-
constructor(rounds, channels) {
|
|
1047
|
-
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.`);
|
|
1048
|
-
this.rounds = rounds;
|
|
1049
|
-
this.channels = channels;
|
|
1050
|
-
this.name = "DeliveryDidNotSettle";
|
|
1051
|
-
}
|
|
1052
|
-
};
|
|
1053
|
-
/** `services.get(name)` for a name no construct of the app is served by. */
|
|
1054
|
-
var UnknownService = class extends Error {
|
|
1055
|
-
serviceName;
|
|
1056
|
-
available;
|
|
1057
|
-
constructor(serviceName, available) {
|
|
1058
|
-
super(`The app declares no construct served as '${serviceName}'. Its services are: ${available.join(", ") || "none"}.`);
|
|
1059
|
-
this.serviceName = serviceName;
|
|
1060
|
-
this.available = available;
|
|
1061
|
-
this.name = "UnknownService";
|
|
1062
|
-
}
|
|
1063
|
-
};
|
|
1064
|
-
//#endregion
|
|
1065
|
-
exports.DeliveryDidNotSettle = DeliveryDidNotSettle;
|
|
1066
|
-
exports.DeliveryFailed = DeliveryFailed;
|
|
1067
|
-
exports.IN_PROCESS_PEER_ADDRESS = IN_PROCESS_PEER_ADDRESS;
|
|
1068
|
-
exports.MessageRejected = MessageRejected;
|
|
1069
|
-
exports.NoInbox = NoInbox;
|
|
1070
|
-
exports.NoTestManifest = NoTestManifest;
|
|
1071
|
-
exports.SignInFailed = SignInFailed;
|
|
1072
|
-
exports.TEST_CONTEXT_HEADER = _geekmidas_testkit_context.TEST_CONTEXT_HEADER;
|
|
1073
|
-
exports.TEST_MANIFEST_ENV = TEST_MANIFEST_ENV;
|
|
460
|
+
exports.TEST_CONTEXT_HEADER = TEST_CONTEXT_HEADER;
|
|
1074
461
|
exports.TestEndpointAdaptor = TestEndpointAdaptor;
|
|
1075
462
|
exports.TestFunctionAdaptor = TestFunctionAdaptor;
|
|
1076
463
|
exports.TestQueueAdaptor = TestQueueAdaptor;
|
|
1077
464
|
exports.TestSubscriberAdaptor = TestSubscriberAdaptor;
|
|
1078
|
-
exports.UnknownDatabase = UnknownDatabase;
|
|
1079
|
-
exports.UnknownFactory = UnknownFactory;
|
|
1080
|
-
exports.UnknownService = UnknownService;
|
|
1081
|
-
exports.UnknownTestContext = UnknownTestContext;
|
|
1082
465
|
exports.createMswHandlers = createMswHandlers;
|
|
1083
|
-
exports.featureTest = featureTest;
|
|
1084
|
-
exports.inProcessBindings = inProcessBindings;
|
|
1085
|
-
exports.loadTestManifest = loadTestManifest;
|
|
1086
|
-
exports.signInWithMagicLink = signInWithMagicLink;
|
|
1087
|
-
|
|
1088
466
|
//# sourceMappingURL=testing.cjs.map
|