@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rls-
|
|
1
|
+
{"version":3,"file":"rls-Cfb6w-tQ.cjs","names":[],"sources":["../src/endpoints/rls.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { CookieFn, HeaderFn } from './Endpoint';\n\n/**\n * RLS context - key-value pairs to set as PostgreSQL session variables.\n * Keys become `prefix.key` (e.g., `app.user_id`).\n */\nexport interface RlsContext {\n\t[key: string]: string | number | boolean | null | undefined;\n}\n\n/**\n * Function type for extracting RLS context from request context.\n *\n * @template TServices - Available service dependencies\n * @template TSession - Session data type\n * @template TLogger - Logger type\n *\n * @example\n * ```ts\n * const extractor: RlsContextExtractor<[], UserSession> = ({ session }) => ({\n * user_id: session.userId,\n * tenant_id: session.tenantId,\n * roles: session.roles.join(','),\n * });\n * ```\n */\nexport type RlsContextExtractor<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\n> = (ctx: {\n\tservices: ServiceRecord<TServices>;\n\tsession: TSession;\n\theader: HeaderFn;\n\tcookie: CookieFn;\n\tlogger: TLogger;\n}) => RlsContext | Promise<RlsContext>;\n\n/**\n * Configuration for RLS on an endpoint or factory.\n *\n * @template TServices - Available service dependencies\n * @template TSession - Session data type\n * @template TLogger - Logger type\n */\nexport interface RlsConfig<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\n> {\n\t/** Function to extract RLS context from request */\n\textractor: RlsContextExtractor<TServices, TSession, TLogger>;\n\t/** Prefix for PostgreSQL session variables (default: 'app') */\n\tprefix?: string;\n}\n\n/**\n * Symbol used to bypass RLS for an endpoint.\n */\nexport const RLS_BYPASS = Symbol.for('geekmidas.rls.bypass');\n\n/**\n * Type for RLS bypass marker.\n */\nexport type RlsBypass = typeof RLS_BYPASS;\n"],"mappings":";;;;;AA6DA,MAAa,aAAa,OAAO,IAAI,uBAAuB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../Subscriber-
|
|
3
|
-
import { AWSLambdaHandler, AWSLambdaSubscriber } from "../AWSLambdaSubscriberAdaptor-
|
|
1
|
+
import "../Construct-BjpXFNxy.mjs";
|
|
2
|
+
import "../Subscriber-9ObcUdcC.mjs";
|
|
3
|
+
import { AWSLambdaHandler, AWSLambdaSubscriber } from "../AWSLambdaSubscriberAdaptor-Cmx9OQGG.mjs";
|
|
4
4
|
export { AWSLambdaHandler, AWSLambdaSubscriber };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Subscriber, SubscriberContext, SubscriberHandler } from "../Subscriber-
|
|
1
|
+
import "../Construct-BjpXFNxy.mjs";
|
|
2
|
+
import { Subscriber, SubscriberContext, SubscriberHandler } from "../Subscriber-9ObcUdcC.mjs";
|
|
3
3
|
export { Subscriber, SubscriberContext, SubscriberHandler };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require('../Construct-BXG8cFSm.cjs');
|
|
2
|
-
require('../Subscriber-
|
|
3
|
-
const require_SubscriberBuilder = require('../SubscriberBuilder-
|
|
2
|
+
require('../Subscriber-BgspJeS4.cjs');
|
|
3
|
+
const require_SubscriberBuilder = require('../SubscriberBuilder-BtL22ZJ9.cjs');
|
|
4
4
|
|
|
5
5
|
exports.SubscriberBuilder = require_SubscriberBuilder.SubscriberBuilder;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../Subscriber-
|
|
3
|
-
import { SubscriberBuilder } from "../SubscriberBuilder-
|
|
1
|
+
import "../Construct-BjpXFNxy.mjs";
|
|
2
|
+
import "../Subscriber-9ObcUdcC.mjs";
|
|
3
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-DsfIkgTF.mjs";
|
|
4
4
|
export { SubscriberBuilder };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../Construct-CQ9zV58W.mjs";
|
|
2
|
-
import "../Subscriber-
|
|
3
|
-
import { SubscriberBuilder } from "../SubscriberBuilder-
|
|
2
|
+
import "../Subscriber-BH76wgkL.mjs";
|
|
3
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-B4md5wzs.mjs";
|
|
4
4
|
|
|
5
5
|
export { SubscriberBuilder };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
require('../publisher-lFQleddL.cjs');
|
|
2
|
-
const require_TestSubscriberAdaptor = require('../TestSubscriberAdaptor-
|
|
2
|
+
const require_TestSubscriberAdaptor = require('../TestSubscriberAdaptor-_69o1d0f.cjs');
|
|
3
3
|
|
|
4
4
|
exports.TestSubscriberAdaptor = require_TestSubscriberAdaptor.TestSubscriberAdaptor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../Construct-CX7HyFfT.cjs";
|
|
2
2
|
import "../Subscriber-1rDE7HuM.cjs";
|
|
3
|
-
import { TestSubscriberAdaptor, TestSubscriberRequest } from "../TestSubscriberAdaptor-
|
|
3
|
+
import { TestSubscriberAdaptor, TestSubscriberRequest } from "../TestSubscriberAdaptor-BknOLRQw.cjs";
|
|
4
4
|
export { TestSubscriberAdaptor, TestSubscriberRequest };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../Subscriber-
|
|
3
|
-
import { TestSubscriberAdaptor, TestSubscriberRequest } from "../TestSubscriberAdaptor-
|
|
1
|
+
import "../Construct-BjpXFNxy.mjs";
|
|
2
|
+
import "../Subscriber-9ObcUdcC.mjs";
|
|
3
|
+
import { TestSubscriberAdaptor, TestSubscriberRequest } from "../TestSubscriberAdaptor-BEyCFP9G.mjs";
|
|
4
4
|
export { TestSubscriberAdaptor, TestSubscriberRequest };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('../Construct-BXG8cFSm.cjs');
|
|
2
|
-
const require_Subscriber = require('../Subscriber-
|
|
3
|
-
const require_SubscriberBuilder = require('../SubscriberBuilder-
|
|
2
|
+
const require_Subscriber = require('../Subscriber-BgspJeS4.cjs');
|
|
3
|
+
const require_SubscriberBuilder = require('../SubscriberBuilder-BtL22ZJ9.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/subscribers/index.ts
|
|
6
6
|
const s = new require_SubscriberBuilder.SubscriberBuilder();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../Construct-CX7HyFfT.cjs";
|
|
2
2
|
import { Subscriber } from "../Subscriber-1rDE7HuM.cjs";
|
|
3
|
-
import { SubscriberBuilder } from "../SubscriberBuilder-
|
|
3
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-Be7WBbCL.cjs";
|
|
4
4
|
import * as _geekmidas_logger10 from "@geekmidas/logger";
|
|
5
5
|
|
|
6
6
|
//#region src/subscribers/index.d.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Subscriber } from "../Subscriber-
|
|
3
|
-
import { SubscriberBuilder } from "../SubscriberBuilder-
|
|
4
|
-
import * as
|
|
1
|
+
import "../Construct-BjpXFNxy.mjs";
|
|
2
|
+
import { Subscriber } from "../Subscriber-9ObcUdcC.mjs";
|
|
3
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-DsfIkgTF.mjs";
|
|
4
|
+
import * as _geekmidas_logger10 from "@geekmidas/logger";
|
|
5
5
|
|
|
6
6
|
//#region src/subscribers/index.d.ts
|
|
7
|
-
declare const s: SubscriberBuilder<[],
|
|
7
|
+
declare const s: SubscriberBuilder<[], _geekmidas_logger10.Logger, undefined, undefined, string, []>;
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/subscribers/index.ts"],"sourcesContent":[],"mappings":";;;;;;cAKa,GAAC,sBAA0B,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/subscribers/index.ts"],"sourcesContent":[],"mappings":";;;;;;cAKa,GAAC,sBAA0B,mBAAA,CAA1B,MAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../Construct-CQ9zV58W.mjs";
|
|
2
|
-
import { Subscriber } from "../Subscriber-
|
|
3
|
-
import { SubscriberBuilder } from "../SubscriberBuilder-
|
|
2
|
+
import { Subscriber } from "../Subscriber-BH76wgkL.mjs";
|
|
3
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-B4md5wzs.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/subscribers/index.ts
|
|
6
6
|
const s = new SubscriberBuilder();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-
|
|
1
|
+
{"version":3,"file":"telemetry-BJo1gcV1.d.mts","names":[],"sources":["../src/telemetry.ts"],"sourcesContent":[],"mappings":";;;;;;;AA6FmB,UAlFF,gBAAA,CAkFE;EAAgB;;;EAQgB,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;;;;UAhFlC,gBAAA;;;;;;;;WASP;;;;;UAMO,iBAAA;;;;;;;;;;;;YAcN;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BM,SAAA;;;;;;;0BAOQ,mBAAmB;;;;;;;oBAQzB,4BAA4B;;;;;;;sBAQ1B,yBAAyB"}
|
package/dist/telemetry.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Telemetry, TelemetryContext, TelemetryRequest, TelemetryResponse } from "./telemetry-
|
|
1
|
+
import { Telemetry, TelemetryContext, TelemetryRequest, TelemetryResponse } from "./telemetry-BJo1gcV1.mjs";
|
|
2
2
|
export { Telemetry, TelemetryContext, TelemetryRequest, TelemetryResponse };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-BqPOdHEm.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";KAAY,6BAAA,MACC,CADD,IACM,CADS,CACP,CADO,CAAA,SAAA,SAAA,GAAA,KAAA,GACwB,CADxB,GAC4B,CAD5B,CAC8B,CAD9B,CAAA,EAAA;AACd,KAGD,UAAA,GAHC,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,OAAA,GAAA,QAAA,GAAA,SAAA;AAAK,KAWN,eAXM,CAAA,UAWoB,UAXpB,CAAA,GAWkC,SAXlC,CAW4C,CAX5C,CAAA"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-
|
|
1
|
+
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-BqPOdHEm.mjs";
|
|
2
2
|
export { HttpMethod, LowerHttpMethod, RemoveUndefined };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/constructs",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -79,33 +79,35 @@
|
|
|
79
79
|
"better-auth": "~1.4.18",
|
|
80
80
|
"kysely": "~0.28.8",
|
|
81
81
|
"pg": "~8.16.3",
|
|
82
|
+
"msw": "~2.10.3",
|
|
82
83
|
"zod": "~4.1.13",
|
|
83
84
|
"@geekmidas/audit": "^2.0.0",
|
|
84
85
|
"@geekmidas/cache": "^1.1.0",
|
|
86
|
+
"@geekmidas/db": "^1.0.1",
|
|
85
87
|
"@geekmidas/envkit": "^1.0.4",
|
|
86
88
|
"@geekmidas/errors": "^1.0.0",
|
|
87
|
-
"@geekmidas/db": "^1.0.1",
|
|
88
|
-
"@geekmidas/rate-limit": "^2.0.0",
|
|
89
|
-
"@geekmidas/services": "^1.0.1",
|
|
90
|
-
"@geekmidas/testkit": "^1.0.5",
|
|
91
89
|
"@geekmidas/events": "^1.1.0",
|
|
90
|
+
"@geekmidas/logger": "^1.0.0",
|
|
91
|
+
"@geekmidas/rate-limit": "^2.0.0",
|
|
92
92
|
"@geekmidas/schema": "^1.0.0",
|
|
93
|
-
"@geekmidas/
|
|
93
|
+
"@geekmidas/services": "^1.0.1",
|
|
94
|
+
"@geekmidas/testkit": "^1.0.5"
|
|
94
95
|
},
|
|
95
96
|
"peerDependencies": {
|
|
96
97
|
"@middy/core": ">=6.3.1",
|
|
97
98
|
"@types/aws-lambda": ">=8.10.92",
|
|
98
99
|
"hono": ">=4.8.2",
|
|
100
|
+
"msw": ">=2.0.0",
|
|
101
|
+
"@geekmidas/db": "^1.0.1",
|
|
99
102
|
"@geekmidas/audit": "^2.0.0",
|
|
100
|
-
"@geekmidas/envkit": "^1.0.4",
|
|
101
103
|
"@geekmidas/cache": "^1.1.0",
|
|
104
|
+
"@geekmidas/envkit": "^1.0.4",
|
|
102
105
|
"@geekmidas/events": "^1.1.0",
|
|
103
|
-
"@geekmidas/
|
|
104
|
-
"@geekmidas/rate-limit": "^2.0.0",
|
|
105
|
-
"@geekmidas/db": "^1.0.1",
|
|
106
|
+
"@geekmidas/logger": "^1.0.0",
|
|
106
107
|
"@geekmidas/errors": "^1.0.0",
|
|
107
|
-
"@geekmidas/
|
|
108
|
-
"@geekmidas/
|
|
108
|
+
"@geekmidas/rate-limit": "^2.0.0",
|
|
109
|
+
"@geekmidas/schema": "^1.0.0",
|
|
110
|
+
"@geekmidas/services": "^1.0.1"
|
|
109
111
|
},
|
|
110
112
|
"peerDependenciesMeta": {
|
|
111
113
|
"@geekmidas/audit": {
|
|
@@ -146,6 +148,9 @@
|
|
|
146
148
|
},
|
|
147
149
|
"hono": {
|
|
148
150
|
"optional": true
|
|
151
|
+
},
|
|
152
|
+
"msw": {
|
|
153
|
+
"optional": true
|
|
149
154
|
}
|
|
150
155
|
},
|
|
151
156
|
"scripts": {
|
package/src/adaptors/testing.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export {
|
|
2
|
+
type CreateMswHandlersOptions,
|
|
3
|
+
type CreateMswHandlersResult,
|
|
4
|
+
createMswHandlers,
|
|
5
|
+
type RegisterContextOptions,
|
|
6
|
+
TEST_CONTEXT_HEADER,
|
|
7
|
+
} from '../endpoints/MswEndpointAdaptor';
|
|
1
8
|
export { TestEndpointAdaptor } from '../endpoints/TestEndpointAdaptor';
|
|
2
9
|
export { TestFunctionAdaptor } from '../functions/TestFunctionAdaptor';
|
|
3
10
|
export { TestSubscriberAdaptor } from '../subscribers/TestSubscriberAdaptor';
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { EnvironmentParser } from '@geekmidas/envkit';
|
|
2
|
+
import type { Service } from '@geekmidas/services';
|
|
3
|
+
import { ServiceDiscovery } from '@geekmidas/services';
|
|
4
|
+
import { Hono } from 'hono';
|
|
5
|
+
import { type HttpHandler, http } from 'msw';
|
|
6
|
+
import type { Endpoint } from './Endpoint';
|
|
7
|
+
import { HonoEndpoint } from './HonoEndpointAdaptor';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Header used to identify which test context a request belongs to.
|
|
11
|
+
* Each concurrent test registers its own context (services, db transaction, etc.)
|
|
12
|
+
* and the MSW handler looks it up by this header value.
|
|
13
|
+
*/
|
|
14
|
+
export const TEST_CONTEXT_HEADER = 'x-test-context-id';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Per-test context containing an isolated ServiceDiscovery instance.
|
|
18
|
+
* Registered in the context map and looked up per-request via the context ID header.
|
|
19
|
+
*/
|
|
20
|
+
export interface MswTestContext {
|
|
21
|
+
serviceDiscovery: ServiceDiscovery<any>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Options for creating MSW handlers from endpoint constructs.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { createMswHandlers, registerTestContext } from '@geekmidas/constructs/testing';
|
|
30
|
+
* import { setupServer } from 'msw/node';
|
|
31
|
+
*
|
|
32
|
+
* // Create handlers once (global)
|
|
33
|
+
* const { handlers, registerContext, removeContext } = createMswHandlers(
|
|
34
|
+
* [getUsers, createUser],
|
|
35
|
+
* { baseURL: 'http://localhost:3000' },
|
|
36
|
+
* );
|
|
37
|
+
* const server = setupServer(...handlers);
|
|
38
|
+
*
|
|
39
|
+
* // Per test: register an isolated context with its own services/transaction
|
|
40
|
+
* it('should list users', async ({ db }) => {
|
|
41
|
+
* const contextId = crypto.randomUUID();
|
|
42
|
+
* registerContext(contextId, {
|
|
43
|
+
* services: { database: db, auth: mockAuth },
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* const api = createApi({
|
|
47
|
+
* baseURL: 'http://localhost:3000',
|
|
48
|
+
* headers: { [TEST_CONTEXT_HEADER]: contextId },
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* const result = await api('GET /users');
|
|
52
|
+
* expect(result).toBeDefined();
|
|
53
|
+
*
|
|
54
|
+
* removeContext(contextId);
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export interface CreateMswHandlersOptions {
|
|
59
|
+
/** Base URL the client fetches from (e.g., 'http://localhost:3000') */
|
|
60
|
+
baseURL: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Options for registering a per-test context.
|
|
65
|
+
* Follows the same pattern as TestRequestAdaptor — services, database,
|
|
66
|
+
* publisher, and auditorStorage are provided explicitly.
|
|
67
|
+
*/
|
|
68
|
+
export interface RegisterContextOptions {
|
|
69
|
+
/** Service instances keyed by serviceName */
|
|
70
|
+
services?: Record<string, unknown>;
|
|
71
|
+
/** Database instance — required when endpoints use .database() */
|
|
72
|
+
database?: unknown;
|
|
73
|
+
/** Event publisher service definition */
|
|
74
|
+
publisher?: Service;
|
|
75
|
+
/** Audit storage instance — required when endpoints use .auditor() */
|
|
76
|
+
auditorStorage?: unknown;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const MSW_HTTP_METHODS = [
|
|
80
|
+
'get',
|
|
81
|
+
'post',
|
|
82
|
+
'put',
|
|
83
|
+
'patch',
|
|
84
|
+
'delete',
|
|
85
|
+
'options',
|
|
86
|
+
] as const;
|
|
87
|
+
|
|
88
|
+
type MswHttpMethod = (typeof MSW_HTTP_METHODS)[number];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Result of creating MSW handlers from endpoint constructs.
|
|
92
|
+
*/
|
|
93
|
+
export interface CreateMswHandlersResult {
|
|
94
|
+
/** MSW handlers to pass to setupServer() */
|
|
95
|
+
handlers: HttpHandler[];
|
|
96
|
+
/** Register an isolated context for a test */
|
|
97
|
+
registerContext: (id: string, options: RegisterContextOptions) => void;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Creates MSW HTTP handlers from endpoint constructs.
|
|
102
|
+
*
|
|
103
|
+
* Mounts endpoints on a Hono app and creates MSW handlers that intercept
|
|
104
|
+
* fetch requests and route them through `app.request()` — giving frontend
|
|
105
|
+
* tests full endpoint behavior (validation, auth, sessions) without HTTP.
|
|
106
|
+
*
|
|
107
|
+
* Each test registers its own isolated context via `registerContext()`,
|
|
108
|
+
* which is resolved per-request using the `x-test-context-id` header.
|
|
109
|
+
* This allows concurrent tests with their own transactions and services.
|
|
110
|
+
*
|
|
111
|
+
* @param endpoints - Array of endpoint constructs to create handlers for
|
|
112
|
+
* @param options - Configuration including baseURL
|
|
113
|
+
* @returns MSW handlers, the Hono app, and context management functions
|
|
114
|
+
*/
|
|
115
|
+
export function createMswHandlers(
|
|
116
|
+
endpoints: Endpoint<any, any, any, any, any, any>[],
|
|
117
|
+
options: CreateMswHandlersOptions,
|
|
118
|
+
): CreateMswHandlersResult {
|
|
119
|
+
const { baseURL } = options;
|
|
120
|
+
const contexts = new Map<string, MswTestContext>();
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Register an isolated context for a test.
|
|
124
|
+
* Creates a fresh ServiceDiscovery and pre-registers all provided services.
|
|
125
|
+
*/
|
|
126
|
+
function registerContext(id: string, ctxOptions: RegisterContextOptions) {
|
|
127
|
+
const envParser = new EnvironmentParser({});
|
|
128
|
+
const serviceDiscovery = new ServiceDiscovery(envParser);
|
|
129
|
+
|
|
130
|
+
const serviceDefs: Service[] = [];
|
|
131
|
+
|
|
132
|
+
// Register explicit services
|
|
133
|
+
if (ctxOptions.services) {
|
|
134
|
+
for (const [name, instance] of Object.entries(ctxOptions.services)) {
|
|
135
|
+
serviceDefs.push({
|
|
136
|
+
serviceName: name,
|
|
137
|
+
register: () => instance,
|
|
138
|
+
} as Service);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Register database service from endpoint metadata
|
|
143
|
+
if (ctxOptions.database !== undefined) {
|
|
144
|
+
for (const endpoint of endpoints) {
|
|
145
|
+
if (endpoint.databaseService) {
|
|
146
|
+
serviceDefs.push({
|
|
147
|
+
serviceName: endpoint.databaseService.serviceName,
|
|
148
|
+
register: () => ctxOptions.database,
|
|
149
|
+
} as Service);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Register publisher service
|
|
156
|
+
if (ctxOptions.publisher) {
|
|
157
|
+
serviceDefs.push(ctxOptions.publisher);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Register auditor storage service from endpoint metadata
|
|
161
|
+
if (ctxOptions.auditorStorage !== undefined) {
|
|
162
|
+
for (const endpoint of endpoints) {
|
|
163
|
+
if (endpoint.auditorStorageService) {
|
|
164
|
+
serviceDefs.push({
|
|
165
|
+
serviceName: endpoint.auditorStorageService.serviceName,
|
|
166
|
+
register: () => ctxOptions.auditorStorage,
|
|
167
|
+
} as Service);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (serviceDefs.length > 0) {
|
|
174
|
+
serviceDiscovery.register(serviceDefs);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
contexts.set(id, { serviceDiscovery });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Create a Hono app per-request that uses the correct ServiceDiscovery.
|
|
181
|
+
// We use a wrapper app that resolves the context from the header,
|
|
182
|
+
// then delegates to a context-specific Hono app.
|
|
183
|
+
const handlers: HttpHandler[] = [];
|
|
184
|
+
|
|
185
|
+
for (const endpoint of endpoints) {
|
|
186
|
+
const method = endpoint.method.toLowerCase() as MswHttpMethod;
|
|
187
|
+
if (!MSW_HTTP_METHODS.includes(method)) continue;
|
|
188
|
+
|
|
189
|
+
const mswUrl = `${baseURL}${endpoint.route}`;
|
|
190
|
+
const mswMethod = http[method];
|
|
191
|
+
|
|
192
|
+
handlers.push(
|
|
193
|
+
mswMethod(mswUrl, async ({ request }) => {
|
|
194
|
+
const contextId = request.headers.get(TEST_CONTEXT_HEADER);
|
|
195
|
+
const ctx = contextId ? contexts.get(contextId) : undefined;
|
|
196
|
+
|
|
197
|
+
if (!ctx) {
|
|
198
|
+
return new Response(
|
|
199
|
+
JSON.stringify({
|
|
200
|
+
error: 'Missing or unknown test context ID',
|
|
201
|
+
hint: `Set the '${TEST_CONTEXT_HEADER}' header to a registered context ID`,
|
|
202
|
+
}),
|
|
203
|
+
{ status: 500, headers: { 'content-type': 'application/json' } },
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Build a fresh Hono app with this context's ServiceDiscovery
|
|
208
|
+
const app = new Hono();
|
|
209
|
+
HonoEndpoint.addRoute(endpoint, ctx.serviceDiscovery as any, app);
|
|
210
|
+
|
|
211
|
+
const response = await app.request(request);
|
|
212
|
+
|
|
213
|
+
return new Response(response.body, {
|
|
214
|
+
status: response.status,
|
|
215
|
+
statusText: response.statusText,
|
|
216
|
+
headers: response.headers,
|
|
217
|
+
});
|
|
218
|
+
}),
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
handlers,
|
|
224
|
+
registerContext,
|
|
225
|
+
};
|
|
226
|
+
}
|