@geekmidas/constructs 3.0.6 → 3.0.7
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 +6 -0
- package/dist/{AWSLambdaFunction-BF1gJJjG.d.mts → AWSLambdaFunction-CC8gMZhz.d.mts} +3 -3
- package/dist/{AWSLambdaFunction-BF1gJJjG.d.mts.map → AWSLambdaFunction-CC8gMZhz.d.mts.map} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-OQvj2lKI.d.mts → AWSLambdaSubscriberAdaptor-Cmx9OQGG.d.mts} +2 -2
- package/dist/{AWSLambdaSubscriberAdaptor-OQvj2lKI.d.mts.map → AWSLambdaSubscriberAdaptor-Cmx9OQGG.d.mts.map} +1 -1
- package/dist/{AmazonApiGatewayEndpointAdaptor-Hi8Pbp2d.d.mts → AmazonApiGatewayEndpointAdaptor-DA0rS_1Y.d.mts} +4 -4
- package/dist/{AmazonApiGatewayEndpointAdaptor-Hi8Pbp2d.d.mts.map → AmazonApiGatewayEndpointAdaptor-DA0rS_1Y.d.mts.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-cpwJzU4W.d.mts → AmazonApiGatewayV1EndpointAdaptor-C7rJzNvG.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-cpwJzU4W.d.mts.map → AmazonApiGatewayV1EndpointAdaptor-C7rJzNvG.d.mts.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-LzH3hkB-.d.mts → AmazonApiGatewayV2EndpointAdaptor-d7NP-bZX.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-LzH3hkB-.d.mts.map → AmazonApiGatewayV2EndpointAdaptor-d7NP-bZX.d.mts.map} +1 -1
- package/dist/{Authorizer-Dx57psuM.cjs → Authorizer-BZ1LcZFt.cjs} +1 -1
- package/dist/{Authorizer-Dx57psuM.cjs.map → Authorizer-BZ1LcZFt.cjs.map} +1 -1
- package/dist/{Authorizer-DBsrDTuf.d.mts → Authorizer-C5_FC_Rq.d.mts} +1 -1
- package/dist/{Authorizer-DBsrDTuf.d.mts.map → Authorizer-C5_FC_Rq.d.mts.map} +1 -1
- package/dist/{Authorizer-4unKN3Xn.mjs → Authorizer-CZpg1Jqk.mjs} +1 -1
- package/dist/{Authorizer-4unKN3Xn.mjs.map → Authorizer-CZpg1Jqk.mjs.map} +1 -1
- package/dist/{BaseFunctionBuilder-CsvFjzA8.d.mts → BaseFunctionBuilder-Q5qIlF-F.d.mts} +2 -2
- package/dist/{BaseFunctionBuilder-CsvFjzA8.d.mts.map → BaseFunctionBuilder-Q5qIlF-F.d.mts.map} +1 -1
- package/dist/{Construct-C2SyofdS.d.mts → Construct-BjpXFNxy.d.mts} +1 -1
- package/dist/{Construct-C2SyofdS.d.mts.map → Construct-BjpXFNxy.d.mts.map} +1 -1
- package/dist/Construct.d.mts +1 -1
- package/dist/{Cron-CWxjO2Fg.d.mts → Cron-BljK1gsV.d.mts} +2 -2
- package/dist/{Cron-BDxW6fYg.d.cts.map → Cron-BljK1gsV.d.mts.map} +1 -1
- package/dist/{Cron-DEKZg5j4.cjs → Cron-C1vyfJ8B.cjs} +1 -1
- package/dist/{Cron-DEKZg5j4.cjs.map → Cron-C1vyfJ8B.cjs.map} +1 -1
- package/dist/{Cron-B3vrGuaD.mjs → Cron-CjWQEad0.mjs} +1 -1
- package/dist/{Cron-B3vrGuaD.mjs.map → Cron-CjWQEad0.mjs.map} +1 -1
- package/dist/{Cron-BDxW6fYg.d.cts → Cron-CllHkk3z.d.cts} +1 -1
- package/dist/{Cron-CWxjO2Fg.d.mts.map → Cron-CllHkk3z.d.cts.map} +1 -1
- package/dist/{CronBuilder-VXpyNfp2.mjs → CronBuilder-CAJFtnmZ.mjs} +2 -2
- package/dist/{CronBuilder-VXpyNfp2.mjs.map → CronBuilder-CAJFtnmZ.mjs.map} +1 -1
- package/dist/{CronBuilder-DJnXbDGK.d.mts → CronBuilder-CG54f9LM.d.mts} +4 -4
- package/dist/{CronBuilder-CginrW3H.d.cts.map → CronBuilder-CG54f9LM.d.mts.map} +1 -1
- package/dist/{CronBuilder-BHpY6w3b.cjs → CronBuilder-CSMd02lu.cjs} +2 -2
- package/dist/{CronBuilder-BHpY6w3b.cjs.map → CronBuilder-CSMd02lu.cjs.map} +1 -1
- package/dist/{CronBuilder-CginrW3H.d.cts → CronBuilder-i23l40xs.d.cts} +2 -2
- package/dist/{CronBuilder-DJnXbDGK.d.mts.map → CronBuilder-i23l40xs.d.cts.map} +1 -1
- package/dist/{Endpoint-DtFQFL63.d.mts → Endpoint-BET0JSZK.d.mts} +4 -4
- package/dist/{Endpoint-DtFQFL63.d.mts.map → Endpoint-BET0JSZK.d.mts.map} +1 -1
- package/dist/{EndpointBuilder-DIAsH97h.d.mts → EndpointBuilder-6kdrQyIh.d.mts} +5 -5
- package/dist/{EndpointBuilder-DIAsH97h.d.mts.map → EndpointBuilder-6kdrQyIh.d.mts.map} +1 -1
- package/dist/{EndpointBuilder-Dzqcm8Yv.d.cts → EndpointBuilder-CSwIguiR.d.cts} +1 -1
- package/dist/{EndpointBuilder-Dzqcm8Yv.d.cts.map → EndpointBuilder-CSwIguiR.d.cts.map} +1 -1
- package/dist/{EndpointBuilder-QdDf3x87.cjs → EndpointBuilder-EptJojG9.cjs} +3 -3
- package/dist/{EndpointBuilder-QdDf3x87.cjs.map → EndpointBuilder-EptJojG9.cjs.map} +1 -1
- package/dist/{EndpointBuilder-CMzbGG2c.mjs → EndpointBuilder-iDpnACRb.mjs} +3 -3
- package/dist/{EndpointBuilder-CMzbGG2c.mjs.map → EndpointBuilder-iDpnACRb.mjs.map} +1 -1
- package/dist/{EndpointFactory-pCuCu_1H.d.mts → EndpointFactory-CBagQW5j.d.mts} +4 -4
- package/dist/{EndpointFactory-pCuCu_1H.d.mts.map → EndpointFactory-CBagQW5j.d.mts.map} +1 -1
- package/dist/{EndpointFactory-AsfUsn-v.cjs → EndpointFactory-D2QxeaAh.cjs} +3 -3
- package/dist/{EndpointFactory-AsfUsn-v.cjs.map → EndpointFactory-D2QxeaAh.cjs.map} +1 -1
- package/dist/{EndpointFactory-C1rh407J.d.cts → EndpointFactory-DQYSH8XK.d.cts} +2 -2
- package/dist/{EndpointFactory-C1rh407J.d.cts.map → EndpointFactory-DQYSH8XK.d.cts.map} +1 -1
- package/dist/{EndpointFactory-CkPaFZA0.mjs → EndpointFactory-wgcqWod-.mjs} +3 -3
- package/dist/{EndpointFactory-CkPaFZA0.mjs.map → EndpointFactory-wgcqWod-.mjs.map} +1 -1
- package/dist/{Function-CZw1DRQ6.d.mts → Function-D74HrBnX.d.mts} +2 -2
- package/dist/{Function-CZw1DRQ6.d.mts.map → Function-D74HrBnX.d.mts.map} +1 -1
- package/dist/{FunctionBuilder-m5BNA2Ap.d.mts → FunctionBuilder-C_qPxC8g.d.mts} +4 -4
- package/dist/{FunctionBuilder-m5BNA2Ap.d.mts.map → FunctionBuilder-C_qPxC8g.d.mts.map} +1 -1
- package/dist/{FunctionExecutionWrapper-C7yYXIq-.d.mts → FunctionExecutionWrapper-xbTmBARx.d.mts} +2 -2
- package/dist/{FunctionExecutionWrapper-C7yYXIq-.d.mts.map → FunctionExecutionWrapper-xbTmBARx.d.mts.map} +1 -1
- package/dist/{HonoEndpointAdaptor-BXga7Jqh.d.mts → HonoEndpointAdaptor-C2deTEwW.d.mts} +5 -5
- package/dist/{HonoEndpointAdaptor-BXga7Jqh.d.mts.map → HonoEndpointAdaptor-C2deTEwW.d.mts.map} +1 -1
- package/dist/MswEndpointAdaptor-B41INCc7.mjs +108 -0
- package/dist/MswEndpointAdaptor-B41INCc7.mjs.map +1 -0
- package/dist/MswEndpointAdaptor-CA_fu6Wx.cjs +120 -0
- package/dist/MswEndpointAdaptor-CA_fu6Wx.cjs.map +1 -0
- package/dist/MswEndpointAdaptor-CXgYbOxw.d.mts +101 -0
- package/dist/MswEndpointAdaptor-CXgYbOxw.d.mts.map +1 -0
- package/dist/MswEndpointAdaptor-CsYvrQeB.d.cts +101 -0
- package/dist/MswEndpointAdaptor-CsYvrQeB.d.cts.map +1 -0
- package/dist/{Subscriber-BgB3RRxb.d.mts → Subscriber-9ObcUdcC.d.mts} +2 -2
- package/dist/{Subscriber-BgB3RRxb.d.mts.map → Subscriber-9ObcUdcC.d.mts.map} +1 -1
- package/dist/{Subscriber-BEhOdNQi.mjs → Subscriber-BH76wgkL.mjs} +1 -1
- package/dist/{Subscriber-BEhOdNQi.mjs.map → Subscriber-BH76wgkL.mjs.map} +1 -1
- package/dist/{Subscriber-Scz7hrV6.cjs → Subscriber-BgspJeS4.cjs} +1 -1
- package/dist/{Subscriber-Scz7hrV6.cjs.map → Subscriber-BgspJeS4.cjs.map} +1 -1
- package/dist/{SubscriberBuilder-DlUaG0Ej.mjs → SubscriberBuilder-B4md5wzs.mjs} +2 -2
- package/dist/{SubscriberBuilder-DlUaG0Ej.mjs.map → SubscriberBuilder-B4md5wzs.mjs.map} +1 -1
- package/dist/{SubscriberBuilder-B9uva8fZ.d.cts → SubscriberBuilder-Be7WBbCL.d.cts} +1 -1
- package/dist/{SubscriberBuilder-B9uva8fZ.d.cts.map → SubscriberBuilder-Be7WBbCL.d.cts.map} +1 -1
- package/dist/{SubscriberBuilder-B82h4v-S.cjs → SubscriberBuilder-BtL22ZJ9.cjs} +2 -2
- package/dist/{SubscriberBuilder-B82h4v-S.cjs.map → SubscriberBuilder-BtL22ZJ9.cjs.map} +1 -1
- package/dist/{SubscriberBuilder-DaQkh2Nt.d.mts → SubscriberBuilder-DsfIkgTF.d.mts} +2 -2
- package/dist/{SubscriberBuilder-DaQkh2Nt.d.mts.map → SubscriberBuilder-DsfIkgTF.d.mts.map} +1 -1
- package/dist/{TestEndpointAdaptor-G2T789bH.mjs → TestEndpointAdaptor-BFmgf7Fn.mjs} +1 -1
- package/dist/{TestEndpointAdaptor-G2T789bH.mjs.map → TestEndpointAdaptor-BFmgf7Fn.mjs.map} +1 -1
- package/dist/{TestEndpointAdaptor-DxXJoBBf.d.mts → TestEndpointAdaptor-C79Z-QS4.d.mts} +3 -3
- package/dist/{TestEndpointAdaptor-Clz_L8Xj.d.cts.map → TestEndpointAdaptor-C79Z-QS4.d.mts.map} +1 -1
- package/dist/{TestEndpointAdaptor-YlwOEisx.cjs → TestEndpointAdaptor-DYLDyAAC.cjs} +1 -1
- package/dist/{TestEndpointAdaptor-YlwOEisx.cjs.map → TestEndpointAdaptor-DYLDyAAC.cjs.map} +1 -1
- package/dist/{TestEndpointAdaptor-Clz_L8Xj.d.cts → TestEndpointAdaptor-pM8yskbb.d.cts} +1 -1
- package/dist/{TestEndpointAdaptor-DxXJoBBf.d.mts.map → TestEndpointAdaptor-pM8yskbb.d.cts.map} +1 -1
- package/dist/{TestFunctionAdaptor-CH6-gO_B.cjs → TestFunctionAdaptor-B859kIeb.cjs} +1 -1
- package/dist/{TestFunctionAdaptor-CH6-gO_B.cjs.map → TestFunctionAdaptor-B859kIeb.cjs.map} +1 -1
- package/dist/{TestFunctionAdaptor-DzT8GRdR.d.mts → TestFunctionAdaptor-C0A-VqnM.d.mts} +2 -2
- package/dist/{TestFunctionAdaptor-BHk2bDOV.d.cts.map → TestFunctionAdaptor-C0A-VqnM.d.mts.map} +1 -1
- package/dist/{TestFunctionAdaptor-C5CLuR-9.mjs → TestFunctionAdaptor-CqdSlhx1.mjs} +1 -1
- package/dist/{TestFunctionAdaptor-C5CLuR-9.mjs.map → TestFunctionAdaptor-CqdSlhx1.mjs.map} +1 -1
- package/dist/{TestFunctionAdaptor-BHk2bDOV.d.cts → TestFunctionAdaptor-Dbq55dKP.d.cts} +1 -1
- package/dist/{TestFunctionAdaptor-DzT8GRdR.d.mts.map → TestFunctionAdaptor-Dbq55dKP.d.cts.map} +1 -1
- package/dist/{TestSubscriberAdaptor-CPEiqSfE.d.mts → TestSubscriberAdaptor-BEyCFP9G.d.mts} +2 -2
- package/dist/{TestSubscriberAdaptor-CPEiqSfE.d.mts.map → TestSubscriberAdaptor-BEyCFP9G.d.mts.map} +1 -1
- package/dist/{TestSubscriberAdaptor-DQk5xzb0.d.cts → TestSubscriberAdaptor-BknOLRQw.d.cts} +1 -1
- package/dist/{TestSubscriberAdaptor-DQk5xzb0.d.cts.map → TestSubscriberAdaptor-BknOLRQw.d.cts.map} +1 -1
- package/dist/{TestSubscriberAdaptor-CwP3qNJ4.mjs → TestSubscriberAdaptor-CCcviuKa.mjs} +1 -1
- package/dist/{TestSubscriberAdaptor-CwP3qNJ4.mjs.map → TestSubscriberAdaptor-CCcviuKa.mjs.map} +1 -1
- package/dist/{TestSubscriberAdaptor-Dgxr_0vL.cjs → TestSubscriberAdaptor-_69o1d0f.cjs} +1 -1
- package/dist/{TestSubscriberAdaptor-Dgxr_0vL.cjs.map → TestSubscriberAdaptor-_69o1d0f.cjs.map} +1 -1
- package/dist/adaptors/aws.d.mts +16 -16
- package/dist/adaptors/hono.d.mts +9 -9
- package/dist/adaptors/testing.cjs +10 -4
- package/dist/adaptors/testing.d.cts +5 -4
- package/dist/adaptors/testing.d.mts +14 -13
- package/dist/adaptors/testing.mjs +8 -4
- package/dist/crons/Cron.cjs +1 -1
- package/dist/crons/Cron.d.cts +1 -1
- package/dist/crons/Cron.d.mts +6 -6
- package/dist/crons/Cron.mjs +1 -1
- package/dist/crons/CronBuilder.cjs +2 -2
- package/dist/crons/CronBuilder.d.cts +2 -2
- package/dist/crons/CronBuilder.d.mts +7 -7
- package/dist/crons/CronBuilder.mjs +2 -2
- package/dist/crons/index.cjs +2 -2
- package/dist/crons/index.d.cts +2 -2
- package/dist/crons/index.d.mts +11 -11
- package/dist/crons/index.mjs +2 -2
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +10 -10
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +11 -11
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +11 -11
- package/dist/endpoints/Authorizer.cjs +1 -1
- package/dist/endpoints/Authorizer.d.mts +1 -1
- package/dist/endpoints/Authorizer.mjs +1 -1
- package/dist/endpoints/Endpoint.d.mts +8 -8
- package/dist/endpoints/EndpointBuilder.cjs +3 -3
- package/dist/endpoints/EndpointBuilder.d.cts +1 -1
- package/dist/endpoints/EndpointBuilder.d.mts +9 -9
- package/dist/endpoints/EndpointBuilder.mjs +3 -3
- package/dist/endpoints/EndpointFactory.cjs +4 -4
- package/dist/endpoints/EndpointFactory.d.cts +2 -2
- package/dist/endpoints/EndpointFactory.d.mts +10 -10
- package/dist/endpoints/EndpointFactory.mjs +4 -4
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/MswEndpointAdaptor.cjs +16 -0
- package/dist/endpoints/MswEndpointAdaptor.d.cts +10 -0
- package/dist/endpoints/MswEndpointAdaptor.d.mts +10 -0
- package/dist/endpoints/MswEndpointAdaptor.mjs +15 -0
- package/dist/endpoints/TestEndpointAdaptor.cjs +1 -1
- package/dist/endpoints/TestEndpointAdaptor.d.cts +1 -1
- package/dist/endpoints/TestEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/TestEndpointAdaptor.mjs +1 -1
- package/dist/endpoints/audit.d.mts +8 -8
- package/dist/endpoints/helpers.d.mts +8 -8
- package/dist/endpoints/index.cjs +4 -4
- package/dist/endpoints/index.d.cts +4 -4
- package/dist/endpoints/index.d.mts +14 -14
- package/dist/endpoints/index.mjs +4 -4
- package/dist/endpoints/lazyAccessors.d.cts +1 -1
- package/dist/endpoints/lazyAccessors.d.mts +9 -9
- package/dist/endpoints/processAudits.d.mts +8 -8
- package/dist/endpoints/rls.cjs +1 -1
- package/dist/endpoints/rls.d.mts +8 -8
- package/dist/endpoints/rls.mjs +1 -1
- package/dist/functions/AWSLambdaFunction.d.mts +4 -4
- package/dist/functions/BaseFunctionBuilder.d.mts +2 -2
- package/dist/functions/Function.d.mts +2 -2
- package/dist/functions/FunctionBuilder.d.mts +4 -4
- package/dist/functions/FunctionExecutionWrapper.d.mts +3 -3
- package/dist/functions/TestFunctionAdaptor.cjs +1 -1
- package/dist/functions/TestFunctionAdaptor.d.cts +1 -1
- package/dist/functions/TestFunctionAdaptor.d.mts +3 -3
- package/dist/functions/TestFunctionAdaptor.mjs +1 -1
- package/dist/functions/index.d.mts +5 -5
- package/dist/index-Cg2UDz1r.d.mts +12 -0
- package/dist/{index-DQo_Csy7.d.mts.map → index-Cg2UDz1r.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/{lazyAccessors-C8AF1hNi.d.cts → lazyAccessors-Bxy5DBp4.d.cts} +1 -1
- package/dist/{lazyAccessors-Bled3FVc.d.mts.map → lazyAccessors-Bxy5DBp4.d.cts.map} +1 -1
- package/dist/{lazyAccessors-Bled3FVc.d.mts → lazyAccessors-CWFdtzSR.d.mts} +2 -2
- package/dist/{lazyAccessors-C8AF1hNi.d.cts.map → lazyAccessors-CWFdtzSR.d.mts.map} +1 -1
- package/dist/{publisher-BrzPGnm4.d.cts → publisher-BUDHcaz3.d.cts} +1 -1
- package/dist/{publisher-BrzPGnm4.d.cts.map → publisher-BUDHcaz3.d.cts.map} +1 -1
- package/dist/{publisher-CP4gpv-4.d.mts → publisher-DXglijK_.d.mts} +2 -2
- package/dist/{publisher-CP4gpv-4.d.mts.map → publisher-DXglijK_.d.mts.map} +1 -1
- package/dist/publisher.d.cts +1 -1
- package/dist/publisher.d.mts +2 -2
- package/dist/{rls-7XXX7DvY.mjs → rls-C0r4UKVm.mjs} +1 -1
- package/dist/{rls-7XXX7DvY.mjs.map → rls-C0r4UKVm.mjs.map} +1 -1
- package/dist/{rls-DxFqdIA0.cjs → rls-Cfb6w-tQ.cjs} +1 -1
- package/dist/{rls-DxFqdIA0.cjs.map → rls-Cfb6w-tQ.cjs.map} +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +3 -3
- package/dist/subscribers/Subscriber.cjs +1 -1
- package/dist/subscribers/Subscriber.d.mts +2 -2
- package/dist/subscribers/Subscriber.mjs +1 -1
- package/dist/subscribers/SubscriberBuilder.cjs +2 -2
- package/dist/subscribers/SubscriberBuilder.d.cts +1 -1
- package/dist/subscribers/SubscriberBuilder.d.mts +3 -3
- package/dist/subscribers/SubscriberBuilder.mjs +2 -2
- package/dist/subscribers/TestSubscriberAdaptor.cjs +1 -1
- package/dist/subscribers/TestSubscriberAdaptor.d.cts +1 -1
- package/dist/subscribers/TestSubscriberAdaptor.d.mts +3 -3
- package/dist/subscribers/TestSubscriberAdaptor.mjs +1 -1
- package/dist/subscribers/index.cjs +2 -2
- package/dist/subscribers/index.d.cts +1 -1
- package/dist/subscribers/index.d.mts +5 -5
- package/dist/subscribers/index.d.mts.map +1 -1
- package/dist/subscribers/index.mjs +2 -2
- package/dist/{telemetry-C-kNOW3C.d.mts → telemetry-BJo1gcV1.d.mts} +1 -1
- package/dist/{telemetry-C-kNOW3C.d.mts.map → telemetry-BJo1gcV1.d.mts.map} +1 -1
- package/dist/telemetry.d.mts +1 -1
- package/dist/{types-aFmq5cKh.d.mts → types-BqPOdHEm.d.mts} +1 -1
- package/dist/{types-aFmq5cKh.d.mts.map → types-BqPOdHEm.d.mts.map} +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +17 -12
- package/src/adaptors/testing.ts +7 -0
- package/src/endpoints/MswEndpointAdaptor.ts +226 -0
- package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +219 -0
- package/dist/index-DQo_Csy7.d.mts +0 -12
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { setupServer } from 'msw/node';
|
|
2
|
+
import {
|
|
3
|
+
afterAll,
|
|
4
|
+
afterEach,
|
|
5
|
+
beforeAll,
|
|
6
|
+
describe,
|
|
7
|
+
expect,
|
|
8
|
+
it,
|
|
9
|
+
vi,
|
|
10
|
+
} from 'vitest';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { e } from '../EndpointFactory';
|
|
13
|
+
import { createMswHandlers, TEST_CONTEXT_HEADER } from '../MswEndpointAdaptor';
|
|
14
|
+
|
|
15
|
+
const BASE_URL = 'http://localhost:3000';
|
|
16
|
+
|
|
17
|
+
// --- Services ---
|
|
18
|
+
|
|
19
|
+
interface UserDatabase {
|
|
20
|
+
listUsers(): { id: string; name: string }[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const DatabaseService = {
|
|
24
|
+
serviceName: 'database' as const,
|
|
25
|
+
register: () => ({ listUsers: () => [] }) as UserDatabase,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// --- Endpoints ---
|
|
29
|
+
|
|
30
|
+
const listUsers = e
|
|
31
|
+
.get('/users')
|
|
32
|
+
.services([DatabaseService])
|
|
33
|
+
.output(
|
|
34
|
+
z.object({
|
|
35
|
+
users: z.array(z.object({ id: z.string(), name: z.string() })),
|
|
36
|
+
}),
|
|
37
|
+
)
|
|
38
|
+
.handle(async ({ services }) => {
|
|
39
|
+
const users = services.database.listUsers();
|
|
40
|
+
return { users };
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const createUser = e
|
|
44
|
+
.post('/users')
|
|
45
|
+
.body(z.object({ name: z.string().min(1), email: z.string().email() }))
|
|
46
|
+
.output(z.object({ id: z.string(), name: z.string(), email: z.string() }))
|
|
47
|
+
.handle(async ({ body }) => ({
|
|
48
|
+
id: crypto.randomUUID(),
|
|
49
|
+
name: body.name,
|
|
50
|
+
email: body.email,
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
const getUser = e
|
|
54
|
+
.get('/users/:id')
|
|
55
|
+
.params(z.object({ id: z.string() }))
|
|
56
|
+
.output(z.object({ id: z.string(), name: z.string() }))
|
|
57
|
+
.handle(async ({ params }) => ({
|
|
58
|
+
id: params.id,
|
|
59
|
+
name: 'Test User',
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
const authorizedEndpoint = e
|
|
63
|
+
.get('/protected')
|
|
64
|
+
.output(z.object({ message: z.string() }))
|
|
65
|
+
.authorize(({ header }) => header('authorization') === 'Bearer valid-token')
|
|
66
|
+
.handle(async () => ({ message: 'secret' }));
|
|
67
|
+
|
|
68
|
+
// --- Setup ---
|
|
69
|
+
|
|
70
|
+
const { handlers, registerContext } = createMswHandlers(
|
|
71
|
+
[listUsers, createUser, getUser, authorizedEndpoint],
|
|
72
|
+
{ baseURL: BASE_URL },
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const server = setupServer(...handlers);
|
|
76
|
+
|
|
77
|
+
beforeAll(() => server.listen({ onUnhandledRequest: 'bypass' }));
|
|
78
|
+
afterEach(() => server.resetHandlers());
|
|
79
|
+
afterAll(() => server.close());
|
|
80
|
+
|
|
81
|
+
// --- Tests ---
|
|
82
|
+
|
|
83
|
+
describe('MswEndpointAdaptor', () => {
|
|
84
|
+
it('should handle a simple GET request', async () => {
|
|
85
|
+
const contextId = crypto.randomUUID();
|
|
86
|
+
registerContext(contextId, {
|
|
87
|
+
services: {
|
|
88
|
+
database: { listUsers: () => [{ id: '1', name: 'Alice' }] },
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const response = await fetch(`${BASE_URL}/users`, {
|
|
93
|
+
headers: { [TEST_CONTEXT_HEADER]: contextId },
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
expect(response.status).toBe(200);
|
|
97
|
+
const body = await response.json();
|
|
98
|
+
expect(body.users).toEqual([{ id: '1', name: 'Alice' }]);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should handle POST with body validation', async () => {
|
|
102
|
+
const contextId = crypto.randomUUID();
|
|
103
|
+
registerContext(contextId, {});
|
|
104
|
+
|
|
105
|
+
const response = await fetch(`${BASE_URL}/users`, {
|
|
106
|
+
method: 'POST',
|
|
107
|
+
headers: {
|
|
108
|
+
'content-type': 'application/json',
|
|
109
|
+
[TEST_CONTEXT_HEADER]: contextId,
|
|
110
|
+
},
|
|
111
|
+
body: JSON.stringify({ name: 'Bob', email: 'bob@example.com' }),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(response.status).toBe(200);
|
|
115
|
+
const body = await response.json();
|
|
116
|
+
expect(body.name).toBe('Bob');
|
|
117
|
+
expect(body.email).toBe('bob@example.com');
|
|
118
|
+
expect(body.id).toBeDefined();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should reject invalid body with 422', async () => {
|
|
122
|
+
const contextId = crypto.randomUUID();
|
|
123
|
+
registerContext(contextId, {});
|
|
124
|
+
|
|
125
|
+
const response = await fetch(`${BASE_URL}/users`, {
|
|
126
|
+
method: 'POST',
|
|
127
|
+
headers: {
|
|
128
|
+
'content-type': 'application/json',
|
|
129
|
+
[TEST_CONTEXT_HEADER]: contextId,
|
|
130
|
+
},
|
|
131
|
+
body: JSON.stringify({ name: '', email: 'not-an-email' }),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
expect(response.status).toBe(422);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should handle path params', async () => {
|
|
138
|
+
const contextId = crypto.randomUUID();
|
|
139
|
+
registerContext(contextId, {});
|
|
140
|
+
|
|
141
|
+
const response = await fetch(`${BASE_URL}/users/user-123`, {
|
|
142
|
+
headers: { [TEST_CONTEXT_HEADER]: contextId },
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
expect(response.status).toBe(200);
|
|
146
|
+
const body = await response.json();
|
|
147
|
+
expect(body.id).toBe('user-123');
|
|
148
|
+
expect(body.name).toBe('Test User');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('should return 401 when authorization fails', async () => {
|
|
152
|
+
const contextId = crypto.randomUUID();
|
|
153
|
+
registerContext(contextId, {});
|
|
154
|
+
|
|
155
|
+
const response = await fetch(`${BASE_URL}/protected`, {
|
|
156
|
+
headers: {
|
|
157
|
+
[TEST_CONTEXT_HEADER]: contextId,
|
|
158
|
+
authorization: 'Bearer wrong-token',
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
expect(response.status).toBe(401);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should return 200 when authorization passes', async () => {
|
|
166
|
+
const contextId = crypto.randomUUID();
|
|
167
|
+
registerContext(contextId, {});
|
|
168
|
+
|
|
169
|
+
const response = await fetch(`${BASE_URL}/protected`, {
|
|
170
|
+
headers: {
|
|
171
|
+
[TEST_CONTEXT_HEADER]: contextId,
|
|
172
|
+
authorization: 'Bearer valid-token',
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
expect(response.status).toBe(200);
|
|
177
|
+
const body = await response.json();
|
|
178
|
+
expect(body.message).toBe('secret');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should return 500 when context ID is missing', async () => {
|
|
182
|
+
const response = await fetch(`${BASE_URL}/users`);
|
|
183
|
+
|
|
184
|
+
expect(response.status).toBe(500);
|
|
185
|
+
const body = await response.json();
|
|
186
|
+
expect(body.error).toContain('Missing or unknown test context ID');
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should isolate concurrent contexts', async () => {
|
|
190
|
+
const contextA = crypto.randomUUID();
|
|
191
|
+
const contextB = crypto.randomUUID();
|
|
192
|
+
|
|
193
|
+
registerContext(contextA, {
|
|
194
|
+
services: {
|
|
195
|
+
database: { listUsers: () => [{ id: '1', name: 'From A' }] },
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
registerContext(contextB, {
|
|
199
|
+
services: {
|
|
200
|
+
database: { listUsers: () => [{ id: '2', name: 'From B' }] },
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const [responseA, responseB] = await Promise.all([
|
|
205
|
+
fetch(`${BASE_URL}/users`, {
|
|
206
|
+
headers: { [TEST_CONTEXT_HEADER]: contextA },
|
|
207
|
+
}),
|
|
208
|
+
fetch(`${BASE_URL}/users`, {
|
|
209
|
+
headers: { [TEST_CONTEXT_HEADER]: contextB },
|
|
210
|
+
}),
|
|
211
|
+
]);
|
|
212
|
+
|
|
213
|
+
const bodyA = await responseA.json();
|
|
214
|
+
const bodyB = await responseB.json();
|
|
215
|
+
|
|
216
|
+
expect(bodyA.users).toEqual([{ id: '1', name: 'From A' }]);
|
|
217
|
+
expect(bodyB.users).toEqual([{ id: '2', name: 'From B' }]);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FunctionBuilder } from "./FunctionBuilder-m5BNA2Ap.mjs";
|
|
2
|
-
import * as _geekmidas_audit5 from "@geekmidas/audit";
|
|
3
|
-
import * as _geekmidas_logger4 from "@geekmidas/logger";
|
|
4
|
-
import * as _geekmidas_schema3 from "@geekmidas/schema";
|
|
5
|
-
|
|
6
|
-
//#region src/functions/index.d.ts
|
|
7
|
-
declare const f: FunctionBuilder<_geekmidas_schema3.ComposableStandardSchema, undefined, [], _geekmidas_logger4.Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit5.AuditableAction<string, unknown>>;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { f };
|
|
12
|
-
//# sourceMappingURL=index-DQo_Csy7.d.mts.map
|