@geekmidas/constructs 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +448 -0
- package/dist/AWSLambdaFunction-B-Oxr8qt.d.cts +30 -0
- package/dist/{AWSLambdaFunction-DcI_77u8.cjs → AWSLambdaFunction-C-fuCLA3.cjs} +28 -5
- package/dist/AWSLambdaFunction-C-fuCLA3.cjs.map +1 -0
- package/dist/AWSLambdaFunction-CAm9r5ZX.d.mts +30 -0
- package/dist/{AWSLambdaFunction-BTSGYZSx.mjs → AWSLambdaFunction-H65WfXLt.mjs} +28 -5
- package/dist/AWSLambdaFunction-H65WfXLt.mjs.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-mLOpS63x.d.mts → AWSLambdaSubscriberAdaptor-Cknp_nn1.d.cts} +4 -4
- package/dist/{AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs → AWSLambdaSubscriberAdaptor-CyFh7MN8.mjs} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs.map → AWSLambdaSubscriberAdaptor-CyFh7MN8.mjs.map} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-DX5NFdWf.d.cts → AWSLambdaSubscriberAdaptor-DpHzp-AM.d.mts} +4 -4
- package/dist/{AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs → AWSLambdaSubscriberAdaptor-Dum5bkw3.cjs} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs.map → AWSLambdaSubscriberAdaptor-Dum5bkw3.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayEndpointAdaptor-CATWBIJo.d.mts → AmazonApiGatewayEndpointAdaptor-4hPy5vty.d.mts} +9 -8
- package/dist/{AmazonApiGatewayEndpointAdaptor-vi0D3dWg.mjs → AmazonApiGatewayEndpointAdaptor-C6Jk5HSy.mjs} +51 -16
- package/dist/AmazonApiGatewayEndpointAdaptor-C6Jk5HSy.mjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-BTqB3c1_.cjs → AmazonApiGatewayEndpointAdaptor-CI9L7Ucn.cjs} +51 -16
- package/dist/AmazonApiGatewayEndpointAdaptor-CI9L7Ucn.cjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-BwtDtS-i.d.cts → AmazonApiGatewayEndpointAdaptor-ro0RMLzr.d.cts} +8 -7
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-D2_u_zR6.mjs → AmazonApiGatewayV1EndpointAdaptor-BMy8DdNJ.mjs} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-D2_u_zR6.mjs.map → AmazonApiGatewayV1EndpointAdaptor-BMy8DdNJ.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-B1AVk2MM.d.cts → AmazonApiGatewayV1EndpointAdaptor-BWJWKqQT.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-nwrtG5L9.cjs → AmazonApiGatewayV1EndpointAdaptor-DYL1bCBS.cjs} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-nwrtG5L9.cjs.map → AmazonApiGatewayV1EndpointAdaptor-DYL1bCBS.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-2Rd0LLz4.d.mts → AmazonApiGatewayV1EndpointAdaptor-hyR-WwyP.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DoWAJ9oN.mjs → AmazonApiGatewayV2EndpointAdaptor-BU5wQMOe.mjs} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DoWAJ9oN.mjs.map → AmazonApiGatewayV2EndpointAdaptor-BU5wQMOe.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-FSIdXYV6.cjs → AmazonApiGatewayV2EndpointAdaptor-CPLCMeaN.cjs} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-FSIdXYV6.cjs.map → AmazonApiGatewayV2EndpointAdaptor-CPLCMeaN.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DmY_QfjO.d.cts → AmazonApiGatewayV2EndpointAdaptor-D1Irdggp.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-cBDfwdBx.d.mts → AmazonApiGatewayV2EndpointAdaptor-DX3SuI5S.d.mts} +4 -4
- package/dist/{Authorizer-Bbk9ziuG.d.mts → Authorizer-BTmly8ps.d.cts} +1 -1
- package/dist/{Authorizer-iXsSB600.d.cts → Authorizer-pmPvIVgv.d.mts} +1 -1
- package/dist/{BaseFunctionBuilder-DSqF1r3a.mjs → BaseFunctionBuilder-B5gkW0Kt.mjs} +16 -2
- package/dist/BaseFunctionBuilder-B5gkW0Kt.mjs.map +1 -0
- package/dist/{BaseFunctionBuilder-bTDKP7bd.cjs → BaseFunctionBuilder-C5Se7pdL.cjs} +16 -2
- package/dist/BaseFunctionBuilder-C5Se7pdL.cjs.map +1 -0
- package/dist/{BaseFunctionBuilder-DOcm1heZ.d.mts → BaseFunctionBuilder-CbDnPZpD.d.mts} +13 -4
- package/dist/{BaseFunctionBuilder-hWNVKXQB.d.cts → BaseFunctionBuilder-DUZMbEr3.d.cts} +13 -4
- package/dist/{Construct-XCGKof_O.cjs → Construct-BYSPikVm.cjs} +8 -3
- package/dist/Construct-BYSPikVm.cjs.map +1 -0
- package/dist/{Construct-rZQg2yus.mjs → Construct-LWeB1rSQ.mjs} +8 -3
- package/dist/Construct-LWeB1rSQ.mjs.map +1 -0
- package/dist/{Construct-iDmbkZ3o.d.mts → Construct-ZPqE0vhn.d.mts} +5 -3
- package/dist/{Construct-zc8BkRSp.d.cts → Construct-dI_rgdSp.d.cts} +5 -3
- package/dist/Construct.cjs +1 -1
- package/dist/Construct.d.cts +1 -1
- package/dist/Construct.d.mts +1 -1
- package/dist/Construct.mjs +1 -1
- package/dist/{Cron-CYIhd0VE.cjs → Cron-Bi3QOge_.cjs} +5 -5
- package/dist/Cron-Bi3QOge_.cjs.map +1 -0
- package/dist/{Cron-D5HGEt6g.d.mts → Cron-COdfP0Jd.d.cts} +5 -5
- package/dist/{Cron-DbJNPTbP.d.cts → Cron-D8cn_ahj.d.mts} +5 -5
- package/dist/{Cron-BnO1uXhh.mjs → Cron-Dy_HW2Vv.mjs} +5 -5
- package/dist/Cron-Dy_HW2Vv.mjs.map +1 -0
- package/dist/{CronBuilder-BxKwHCdJ.mjs → CronBuilder-Bl3A2Zp4.mjs} +15 -6
- package/dist/CronBuilder-Bl3A2Zp4.mjs.map +1 -0
- package/dist/{CronBuilder-D-546XtP.d.cts → CronBuilder-DntF6H3A.d.cts} +17 -12
- package/dist/{CronBuilder-vRiZb1_N.d.mts → CronBuilder-DoMnSs_0.d.mts} +17 -12
- package/dist/{CronBuilder-D_3AiPFO.cjs → CronBuilder-Dv_w7Yri.cjs} +15 -6
- package/dist/CronBuilder-Dv_w7Yri.cjs.map +1 -0
- package/dist/{Endpoint-DqZkc6ft.d.mts → Endpoint-Bbs_sFvg.d.mts} +120 -23
- package/dist/{Endpoint-BpTSQn7W.d.cts → Endpoint-Bu8Phz6y.d.cts} +120 -23
- package/dist/{Endpoint-BdIGWw1H.cjs → Endpoint-DDpF7NO1.cjs} +22 -10
- package/dist/Endpoint-DDpF7NO1.cjs.map +1 -0
- package/dist/{Endpoint-ChzcIFdV.mjs → Endpoint-S6Yh2_PN.mjs} +22 -10
- package/dist/Endpoint-S6Yh2_PN.mjs.map +1 -0
- package/dist/EndpointBuilder-CPxmF_w7.d.cts +103 -0
- package/dist/EndpointBuilder-Csfyfjd7.d.mts +103 -0
- package/dist/{EndpointBuilder-dmMiNRm9.cjs → EndpointBuilder-DpGmObMb.cjs} +68 -5
- package/dist/EndpointBuilder-DpGmObMb.cjs.map +1 -0
- package/dist/{EndpointBuilder-yo40Qkf_.mjs → EndpointBuilder-aE2E6WTx.mjs} +68 -5
- package/dist/EndpointBuilder-aE2E6WTx.mjs.map +1 -0
- package/dist/{EndpointFactory-D_mmO7Gu.d.mts → EndpointFactory-Bf9JSWzI.d.cts} +12 -11
- package/dist/{EndpointFactory-CNbcr8u_.cjs → EndpointFactory-BfH6mjJ3.cjs} +3 -3
- package/dist/EndpointFactory-BfH6mjJ3.cjs.map +1 -0
- package/dist/{EndpointFactory-JPhk0Qom.d.cts → EndpointFactory-Cgk1R0oO.d.mts} +12 -11
- package/dist/{EndpointFactory-LD3upVQK.mjs → EndpointFactory-D4leYk1N.mjs} +3 -3
- package/dist/EndpointFactory-D4leYk1N.mjs.map +1 -0
- package/dist/{Function-DDaSfL_E.cjs → Function-DagDbeXo.cjs} +7 -6
- package/dist/Function-DagDbeXo.cjs.map +1 -0
- package/dist/{Function-Cl9fiR3a.mjs → Function-DfKsM5Kx.mjs} +7 -6
- package/dist/Function-DfKsM5Kx.mjs.map +1 -0
- package/dist/{Function-C-5_23Wi.d.mts → Function-V9M9UVHp.d.mts} +25 -7
- package/dist/{Function-CW-WcZTu.d.cts → Function-VI1TB3Mh.d.cts} +25 -7
- package/dist/{FunctionBuilder-vW12WFOw.mjs → FunctionBuilder-CVT7bG2o.mjs} +27 -6
- package/dist/FunctionBuilder-CVT7bG2o.mjs.map +1 -0
- package/dist/FunctionBuilder-CjVEFTYC.d.cts +38 -0
- package/dist/FunctionBuilder-D1ofSeMd.d.mts +38 -0
- package/dist/{FunctionBuilder-LQuBiqRc.cjs → FunctionBuilder-DXvG_XD-.cjs} +27 -6
- package/dist/FunctionBuilder-DXvG_XD-.cjs.map +1 -0
- package/dist/FunctionExecutionWrapper-Bubnr0zA.mjs +101 -0
- package/dist/FunctionExecutionWrapper-Bubnr0zA.mjs.map +1 -0
- package/dist/FunctionExecutionWrapper-CwtwYozd.d.cts +48 -0
- package/dist/FunctionExecutionWrapper-DkNycmOh.cjs +107 -0
- package/dist/FunctionExecutionWrapper-DkNycmOh.cjs.map +1 -0
- package/dist/FunctionExecutionWrapper-rhbIYT0Q.d.mts +48 -0
- package/dist/{HonoEndpointAdaptor-BVQtyvna.d.cts → HonoEndpointAdaptor-B34kNobH.d.cts} +8 -7
- package/dist/{HonoEndpointAdaptor-W-disJnm.d.mts → HonoEndpointAdaptor-BDpi32mH.d.mts} +9 -8
- package/dist/{HonoEndpointAdaptor-Bc61IS6Q.cjs → HonoEndpointAdaptor-CfLRHHFw.cjs} +55 -20
- package/dist/HonoEndpointAdaptor-CfLRHHFw.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-NR3h5gml.mjs → HonoEndpointAdaptor-DuyE06nH.mjs} +55 -20
- package/dist/HonoEndpointAdaptor-DuyE06nH.mjs.map +1 -0
- package/dist/{Subscriber-C2OPATI8.cjs → Subscriber-Bdh8rMSL.cjs} +2 -2
- package/dist/{Subscriber-C2OPATI8.cjs.map → Subscriber-Bdh8rMSL.cjs.map} +1 -1
- package/dist/{Subscriber-BVq3ST4C.d.cts → Subscriber-BhzqUzs-.d.cts} +2 -2
- package/dist/{Subscriber-BKftCzwT.mjs → Subscriber-CJOWwaw1.mjs} +2 -2
- package/dist/{Subscriber-BKftCzwT.mjs.map → Subscriber-CJOWwaw1.mjs.map} +1 -1
- package/dist/{Subscriber-BuHaqWo4.d.mts → Subscriber-s6yfjeOc.d.mts} +2 -2
- package/dist/{SubscriberBuilder-2asHtGbl.d.mts → SubscriberBuilder-BCVkp-ga.d.cts} +3 -3
- package/dist/{SubscriberBuilder-yDfpHPZE.mjs → SubscriberBuilder-BWQmiYd8.mjs} +2 -2
- package/dist/{SubscriberBuilder-yDfpHPZE.mjs.map → SubscriberBuilder-BWQmiYd8.mjs.map} +1 -1
- package/dist/{SubscriberBuilder-yikoQ8ND.cjs → SubscriberBuilder-DieD_60p.cjs} +2 -2
- package/dist/{SubscriberBuilder-yikoQ8ND.cjs.map → SubscriberBuilder-DieD_60p.cjs.map} +1 -1
- package/dist/{SubscriberBuilder-CHIRyNjy.d.cts → SubscriberBuilder-aCua5_wA.d.mts} +3 -3
- package/dist/{TestEndpointAdaptor-DpmNXp7G.mjs → TestEndpointAdaptor-BEyZa0Yg.mjs} +51 -18
- package/dist/TestEndpointAdaptor-BEyZa0Yg.mjs.map +1 -0
- package/dist/{TestEndpointAdaptor-DA1D6l-U.cjs → TestEndpointAdaptor-C8425RJ0.cjs} +51 -18
- package/dist/TestEndpointAdaptor-C8425RJ0.cjs.map +1 -0
- package/dist/{TestEndpointAdaptor-BrE5Rs4U.d.cts → TestEndpointAdaptor-H5To8PH7.d.cts} +6 -5
- package/dist/{TestEndpointAdaptor-B10J-cI-.d.mts → TestEndpointAdaptor-jxn68ayg.d.mts} +7 -6
- package/dist/adaptors/aws.cjs +14 -13
- package/dist/adaptors/aws.d.cts +14 -14
- package/dist/adaptors/aws.d.mts +15 -15
- package/dist/adaptors/aws.mjs +14 -13
- package/dist/adaptors/hono.cjs +10 -9
- package/dist/adaptors/hono.d.cts +8 -8
- package/dist/adaptors/hono.d.mts +9 -9
- package/dist/adaptors/hono.mjs +10 -9
- package/dist/adaptors/testing.cjs +8 -7
- package/dist/adaptors/testing.d.cts +8 -8
- package/dist/adaptors/testing.d.mts +9 -9
- package/dist/adaptors/testing.mjs +8 -7
- package/dist/crons/Cron.cjs +6 -6
- package/dist/crons/Cron.d.cts +6 -6
- package/dist/crons/Cron.d.mts +6 -6
- package/dist/crons/Cron.mjs +6 -6
- package/dist/crons/CronBuilder.cjs +7 -7
- package/dist/crons/CronBuilder.d.cts +7 -7
- package/dist/crons/CronBuilder.d.mts +7 -7
- package/dist/crons/CronBuilder.mjs +7 -7
- package/dist/crons/index.cjs +7 -7
- package/dist/crons/index.d.cts +11 -11
- package/dist/crons/index.d.mts +8 -8
- package/dist/crons/index.mjs +7 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +8 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +8 -8
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +8 -7
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +10 -9
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +9 -9
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +10 -10
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +10 -9
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +10 -9
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +9 -9
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +10 -10
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +10 -9
- package/dist/endpoints/Authorizer.d.cts +1 -1
- package/dist/endpoints/Authorizer.d.mts +1 -1
- package/dist/endpoints/Endpoint.cjs +6 -6
- package/dist/endpoints/Endpoint.d.cts +7 -7
- package/dist/endpoints/Endpoint.d.mts +8 -8
- package/dist/endpoints/Endpoint.mjs +6 -6
- package/dist/endpoints/EndpointBuilder.cjs +7 -7
- package/dist/endpoints/EndpointBuilder.d.cts +8 -8
- package/dist/endpoints/EndpointBuilder.d.mts +9 -9
- package/dist/endpoints/EndpointBuilder.mjs +7 -7
- package/dist/endpoints/EndpointFactory.cjs +8 -8
- package/dist/endpoints/EndpointFactory.d.cts +9 -9
- package/dist/endpoints/EndpointFactory.d.mts +10 -10
- package/dist/endpoints/EndpointFactory.mjs +8 -8
- package/dist/endpoints/HonoEndpointAdaptor.cjs +10 -9
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +8 -8
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/HonoEndpointAdaptor.mjs +10 -9
- package/dist/endpoints/TestEndpointAdaptor.cjs +8 -7
- package/dist/endpoints/TestEndpointAdaptor.d.cts +8 -8
- package/dist/endpoints/TestEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/TestEndpointAdaptor.mjs +8 -7
- package/dist/endpoints/audit.cjs +0 -0
- package/dist/endpoints/audit.d.cts +9 -0
- package/dist/endpoints/audit.d.mts +9 -0
- package/dist/endpoints/audit.mjs +0 -0
- package/dist/endpoints/helpers.cjs +7 -7
- package/dist/endpoints/helpers.d.cts +7 -7
- package/dist/endpoints/helpers.d.mts +8 -8
- package/dist/endpoints/helpers.mjs +7 -7
- package/dist/endpoints/index.cjs +8 -8
- package/dist/endpoints/index.cjs.map +1 -1
- package/dist/endpoints/index.d.cts +12 -12
- package/dist/endpoints/index.d.mts +13 -13
- package/dist/endpoints/index.mjs +8 -8
- package/dist/endpoints/index.mjs.map +1 -1
- package/dist/endpoints/parseHonoQuery.cjs +1 -1
- package/dist/endpoints/parseHonoQuery.mjs +1 -1
- package/dist/endpoints/parseQueryParams.cjs +1 -1
- package/dist/endpoints/parseQueryParams.mjs +1 -1
- package/dist/endpoints/processAudits.cjs +5 -0
- package/dist/endpoints/processAudits.d.cts +74 -0
- package/dist/endpoints/processAudits.d.mts +74 -0
- package/dist/endpoints/processAudits.mjs +3 -0
- package/dist/functions/AWSLambdaFunction.cjs +6 -6
- package/dist/functions/AWSLambdaFunction.d.cts +4 -4
- package/dist/functions/AWSLambdaFunction.d.mts +4 -4
- package/dist/functions/AWSLambdaFunction.mjs +6 -6
- package/dist/functions/BaseFunctionBuilder.cjs +2 -2
- package/dist/functions/BaseFunctionBuilder.d.cts +2 -2
- package/dist/functions/BaseFunctionBuilder.d.mts +2 -2
- package/dist/functions/BaseFunctionBuilder.mjs +2 -2
- package/dist/functions/Function.cjs +2 -2
- package/dist/functions/Function.d.cts +2 -2
- package/dist/functions/Function.d.mts +2 -2
- package/dist/functions/Function.mjs +2 -2
- package/dist/functions/FunctionBuilder.cjs +4 -4
- package/dist/functions/FunctionBuilder.d.cts +4 -4
- package/dist/functions/FunctionBuilder.d.mts +4 -4
- package/dist/functions/FunctionBuilder.mjs +4 -4
- package/dist/functions/FunctionExecutionWrapper.cjs +5 -5
- package/dist/functions/FunctionExecutionWrapper.d.cts +3 -3
- package/dist/functions/FunctionExecutionWrapper.d.mts +3 -3
- package/dist/functions/FunctionExecutionWrapper.mjs +5 -5
- package/dist/functions/TestFunctionAdaptor.cjs +38 -5
- package/dist/functions/TestFunctionAdaptor.cjs.map +1 -1
- package/dist/functions/TestFunctionAdaptor.d.cts +10 -7
- package/dist/functions/TestFunctionAdaptor.d.mts +10 -7
- package/dist/functions/TestFunctionAdaptor.mjs +38 -5
- package/dist/functions/TestFunctionAdaptor.mjs.map +1 -1
- package/dist/functions/index.cjs +5 -5
- package/dist/functions/index.d.cts +5 -5
- package/dist/functions/index.d.mts +5 -5
- package/dist/functions/index.mjs +5 -5
- package/dist/{functions-yg097ymU.cjs → functions-FCb-wWFC.cjs} +2 -2
- package/dist/{functions-yg097ymU.cjs.map → functions-FCb-wWFC.cjs.map} +1 -1
- package/dist/functions-JhRsNoAZ.mjs +8 -0
- package/dist/{functions-HCoZ4YKF.mjs.map → functions-JhRsNoAZ.mjs.map} +1 -1
- package/dist/{helpers-CHsIWAEx.mjs → helpers-2CLKTnRm.mjs} +2 -2
- package/dist/{helpers-CHsIWAEx.mjs.map → helpers-2CLKTnRm.mjs.map} +1 -1
- package/dist/{helpers-Cq6wjo7s.cjs → helpers-Khuhi_Qx.cjs} +2 -2
- package/dist/{helpers-Cq6wjo7s.cjs.map → helpers-Khuhi_Qx.cjs.map} +1 -1
- package/dist/index-Bomy7R9z.d.mts +10 -0
- package/dist/index-DRYfZHb3.d.cts +10 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{parseHonoQuery-DopC24vB.cjs → parseHonoQuery-CT8Cvin-.cjs} +1 -1
- package/dist/{parseHonoQuery-DopC24vB.cjs.map → parseHonoQuery-CT8Cvin-.cjs.map} +1 -1
- package/dist/{parseHonoQuery-znDKBhdE.mjs → parseHonoQuery-CwFKw2ua.mjs} +1 -1
- package/dist/{parseHonoQuery-znDKBhdE.mjs.map → parseHonoQuery-CwFKw2ua.mjs.map} +1 -1
- package/dist/{parseQueryParams-BJaRh3OB.mjs → parseQueryParams-CHINupbZ.mjs} +1 -1
- package/dist/{parseQueryParams-BJaRh3OB.mjs.map → parseQueryParams-CHINupbZ.mjs.map} +1 -1
- package/dist/{parseQueryParams-BzPop4I1.cjs → parseQueryParams-CwvXXwkW.cjs} +1 -1
- package/dist/{parseQueryParams-BzPop4I1.cjs.map → parseQueryParams-CwvXXwkW.cjs.map} +1 -1
- package/dist/processAudits-BFokHhCO.cjs +174 -0
- package/dist/processAudits-BFokHhCO.cjs.map +1 -0
- package/dist/processAudits-DfcB-X-4.mjs +156 -0
- package/dist/processAudits-DfcB-X-4.mjs.map +1 -0
- package/dist/publisher-Bw4770Hi.mjs.map +1 -1
- package/dist/publisher-lFQleddL.cjs.map +1 -1
- package/dist/publisher.d.cts +3 -2
- package/dist/publisher.d.mts +3 -2
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.cts +3 -3
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +3 -3
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +1 -1
- package/dist/subscribers/Subscriber.cjs +2 -2
- package/dist/subscribers/Subscriber.d.cts +2 -2
- package/dist/subscribers/Subscriber.d.mts +2 -2
- package/dist/subscribers/Subscriber.mjs +2 -2
- package/dist/subscribers/SubscriberBuilder.cjs +3 -3
- package/dist/subscribers/SubscriberBuilder.d.cts +3 -3
- package/dist/subscribers/SubscriberBuilder.d.mts +3 -3
- package/dist/subscribers/SubscriberBuilder.mjs +3 -3
- package/dist/subscribers/index.cjs +3 -3
- package/dist/subscribers/index.d.cts +5 -5
- package/dist/subscribers/index.d.mts +5 -5
- package/dist/subscribers/index.mjs +3 -3
- package/dist/{types-CVq20-fE.d.mts → types-DKf0juBf.d.mts} +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +15 -11
- package/src/Construct.ts +8 -0
- package/src/crons/Cron.ts +12 -3
- package/src/crons/CronBuilder.ts +85 -13
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +2 -2
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +112 -20
- package/src/endpoints/Endpoint.ts +208 -39
- package/src/endpoints/EndpointBuilder.ts +291 -21
- package/src/endpoints/EndpointFactory.ts +5 -1
- package/src/endpoints/HonoEndpointAdaptor.ts +144 -33
- package/src/endpoints/TestEndpointAdaptor.ts +116 -21
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +8 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +29 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +626 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +9 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +757 -0
- package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +3 -1
- package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +1 -1
- package/src/endpoints/__tests__/Endpoint.spec.ts +19 -0
- package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +448 -0
- package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +51 -14
- package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +8 -8
- package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +11 -11
- 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 +8 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +1063 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +4 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +25 -0
- package/src/endpoints/audit.ts +87 -0
- package/src/endpoints/index.ts +1 -0
- package/src/endpoints/processAudits.ts +348 -0
- package/src/functions/AWSLambdaFunction.ts +125 -12
- package/src/functions/BaseFunctionBuilder.ts +98 -7
- package/src/functions/Function.ts +83 -15
- package/src/functions/FunctionBuilder.ts +217 -17
- package/src/functions/FunctionExecutionWrapper.ts +133 -2
- package/src/functions/TestFunctionAdaptor.ts +94 -8
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +82 -0
- package/src/functions/__tests__/Function.audits.spec.ts +393 -0
- package/src/functions/__tests__/Function.spec.ts +76 -0
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +54 -7
- package/src/publisher.ts +12 -1
- package/dist/AWSLambdaFunction-BTSGYZSx.mjs.map +0 -1
- package/dist/AWSLambdaFunction-Bel0NFTl.d.mts +0 -27
- package/dist/AWSLambdaFunction-DcI_77u8.cjs.map +0 -1
- package/dist/AWSLambdaFunction-xyCenuD7.d.cts +0 -27
- package/dist/AmazonApiGatewayEndpointAdaptor-BTqB3c1_.cjs.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-vi0D3dWg.mjs.map +0 -1
- package/dist/BaseFunctionBuilder-DSqF1r3a.mjs.map +0 -1
- package/dist/BaseFunctionBuilder-bTDKP7bd.cjs.map +0 -1
- package/dist/Construct-XCGKof_O.cjs.map +0 -1
- package/dist/Construct-rZQg2yus.mjs.map +0 -1
- package/dist/Cron-BnO1uXhh.mjs.map +0 -1
- package/dist/Cron-CYIhd0VE.cjs.map +0 -1
- package/dist/CronBuilder-BxKwHCdJ.mjs.map +0 -1
- package/dist/CronBuilder-D_3AiPFO.cjs.map +0 -1
- package/dist/Endpoint-BdIGWw1H.cjs.map +0 -1
- package/dist/Endpoint-ChzcIFdV.mjs.map +0 -1
- package/dist/EndpointBuilder-Cx6pUcCn.d.mts +0 -55
- package/dist/EndpointBuilder-Xka8ULR1.d.cts +0 -55
- package/dist/EndpointBuilder-dmMiNRm9.cjs.map +0 -1
- package/dist/EndpointBuilder-yo40Qkf_.mjs.map +0 -1
- package/dist/EndpointFactory-CNbcr8u_.cjs.map +0 -1
- package/dist/EndpointFactory-LD3upVQK.mjs.map +0 -1
- package/dist/Function-Cl9fiR3a.mjs.map +0 -1
- package/dist/Function-DDaSfL_E.cjs.map +0 -1
- package/dist/FunctionBuilder-LQuBiqRc.cjs.map +0 -1
- package/dist/FunctionBuilder-fU1H7tFN.d.cts +0 -26
- package/dist/FunctionBuilder-udObIGV0.d.mts +0 -26
- package/dist/FunctionBuilder-vW12WFOw.mjs.map +0 -1
- package/dist/FunctionExecutionWrapper-BBIoHUt6.cjs +0 -42
- package/dist/FunctionExecutionWrapper-BBIoHUt6.cjs.map +0 -1
- package/dist/FunctionExecutionWrapper-DYBy9OP3.d.mts +0 -24
- package/dist/FunctionExecutionWrapper-Dtyhid1Q.mjs +0 -36
- package/dist/FunctionExecutionWrapper-Dtyhid1Q.mjs.map +0 -1
- package/dist/FunctionExecutionWrapper-Dwr2ZKzC.d.cts +0 -24
- package/dist/HonoEndpointAdaptor-Bc61IS6Q.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-NR3h5gml.mjs.map +0 -1
- package/dist/TestEndpointAdaptor-DA1D6l-U.cjs.map +0 -1
- package/dist/TestEndpointAdaptor-DpmNXp7G.mjs.map +0 -1
- package/dist/functions-HCoZ4YKF.mjs +0 -8
- package/dist/index-RtxMVjUZ.d.mts +0 -9
- package/dist/index-fiIGH95t.d.cts +0 -9
package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts
ADDED
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
import type { AuditableAction } from '@geekmidas/audit';
|
|
2
|
+
import {
|
|
3
|
+
type AuditLogTable,
|
|
4
|
+
KyselyAuditStorage,
|
|
5
|
+
} from '@geekmidas/audit/kysely';
|
|
6
|
+
import { EnvironmentParser } from '@geekmidas/envkit';
|
|
7
|
+
import type { Logger } from '@geekmidas/logger';
|
|
8
|
+
import type { Service } from '@geekmidas/services';
|
|
9
|
+
import { ServiceDiscovery } from '@geekmidas/services';
|
|
10
|
+
import { createMockContext, createMockV2Event } from '@geekmidas/testkit/aws';
|
|
11
|
+
import {
|
|
12
|
+
CamelCasePlugin,
|
|
13
|
+
type Generated,
|
|
14
|
+
Kysely,
|
|
15
|
+
PostgresDialect,
|
|
16
|
+
sql,
|
|
17
|
+
} from 'kysely';
|
|
18
|
+
import pg from 'pg';
|
|
19
|
+
import {
|
|
20
|
+
afterAll,
|
|
21
|
+
afterEach,
|
|
22
|
+
beforeAll,
|
|
23
|
+
beforeEach,
|
|
24
|
+
describe,
|
|
25
|
+
expect,
|
|
26
|
+
it,
|
|
27
|
+
vi,
|
|
28
|
+
} from 'vitest';
|
|
29
|
+
import { z } from 'zod';
|
|
30
|
+
import { TEST_DATABASE_CONFIG } from '../../../../testkit/test/globalSetup';
|
|
31
|
+
import { AmazonApiGatewayV2Endpoint } from '../AmazonApiGatewayV2EndpointAdaptor';
|
|
32
|
+
import { Endpoint, type EndpointContext } from '../Endpoint';
|
|
33
|
+
import type { MappedAudit } from '../audit';
|
|
34
|
+
|
|
35
|
+
// Database schema - use different table names to avoid conflicts with HonoEndpoint tests
|
|
36
|
+
interface TestDatabase {
|
|
37
|
+
awsAuditLogs: AuditLogTable;
|
|
38
|
+
awsUsers: {
|
|
39
|
+
id: Generated<number>;
|
|
40
|
+
name: string;
|
|
41
|
+
email: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Audit action types
|
|
46
|
+
type TestAuditAction =
|
|
47
|
+
| AuditableAction<'user.created', { userId: number; email: string }>
|
|
48
|
+
| AuditableAction<'user.updated', { userId: number; changes: string[] }>
|
|
49
|
+
| AuditableAction<'user.deleted', { userId: number }>;
|
|
50
|
+
|
|
51
|
+
describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
52
|
+
let db: Kysely<TestDatabase>;
|
|
53
|
+
let auditStorage: KyselyAuditStorage<TestDatabase>;
|
|
54
|
+
let mockLogger: Logger;
|
|
55
|
+
let envParser: EnvironmentParser<{}>;
|
|
56
|
+
|
|
57
|
+
const createMockLogger = (): Logger => ({
|
|
58
|
+
debug: vi.fn(),
|
|
59
|
+
info: vi.fn(),
|
|
60
|
+
warn: vi.fn(),
|
|
61
|
+
error: vi.fn(),
|
|
62
|
+
fatal: vi.fn(),
|
|
63
|
+
trace: vi.fn(),
|
|
64
|
+
child: vi.fn(function (this: Logger) {
|
|
65
|
+
return this;
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
beforeAll(async () => {
|
|
70
|
+
db = new Kysely<TestDatabase>({
|
|
71
|
+
dialect: new PostgresDialect({
|
|
72
|
+
pool: new pg.Pool({
|
|
73
|
+
...TEST_DATABASE_CONFIG,
|
|
74
|
+
database: 'postgres',
|
|
75
|
+
}),
|
|
76
|
+
}),
|
|
77
|
+
plugins: [new CamelCasePlugin()],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Create audit_logs table
|
|
81
|
+
await db.schema
|
|
82
|
+
.createTable('awsAuditLogs')
|
|
83
|
+
.ifNotExists()
|
|
84
|
+
.addColumn('id', 'varchar(32)', (col) => col.primaryKey())
|
|
85
|
+
.addColumn('type', 'varchar', (col) => col.notNull())
|
|
86
|
+
.addColumn('operation', 'varchar', (col) => col.notNull())
|
|
87
|
+
.addColumn('table', 'varchar')
|
|
88
|
+
.addColumn('entityId', 'varchar')
|
|
89
|
+
.addColumn('oldValues', 'jsonb')
|
|
90
|
+
.addColumn('newValues', 'jsonb')
|
|
91
|
+
.addColumn('payload', 'jsonb')
|
|
92
|
+
.addColumn('timestamp', 'timestamp', (col) =>
|
|
93
|
+
col.defaultTo(sql`now()`).notNull(),
|
|
94
|
+
)
|
|
95
|
+
.addColumn('actorId', 'varchar')
|
|
96
|
+
.addColumn('actorType', 'varchar')
|
|
97
|
+
.addColumn('actorData', 'jsonb')
|
|
98
|
+
.addColumn('metadata', 'jsonb')
|
|
99
|
+
.execute();
|
|
100
|
+
|
|
101
|
+
// Create users table
|
|
102
|
+
await db.schema
|
|
103
|
+
.createTable('awsUsers')
|
|
104
|
+
.ifNotExists()
|
|
105
|
+
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
106
|
+
.addColumn('name', 'varchar', (col) => col.notNull())
|
|
107
|
+
.addColumn('email', 'varchar', (col) => col.notNull().unique())
|
|
108
|
+
.execute();
|
|
109
|
+
|
|
110
|
+
auditStorage = new KyselyAuditStorage({
|
|
111
|
+
db,
|
|
112
|
+
tableName: 'awsAuditLogs',
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
beforeEach(() => {
|
|
117
|
+
mockLogger = createMockLogger();
|
|
118
|
+
envParser = new EnvironmentParser({});
|
|
119
|
+
ServiceDiscovery.reset();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
afterEach(async () => {
|
|
123
|
+
await db.deleteFrom('awsAuditLogs').execute();
|
|
124
|
+
await db.deleteFrom('awsUsers').execute();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
afterAll(async () => {
|
|
128
|
+
await db.schema.dropTable('awsAuditLogs').ifExists().execute();
|
|
129
|
+
await db.schema.dropTable('awsUsers').ifExists().execute();
|
|
130
|
+
await db.destroy();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('declarative audits with real database', () => {
|
|
134
|
+
it('should write declarative audit to database on successful request', async () => {
|
|
135
|
+
const auditStorageService: Service<
|
|
136
|
+
'auditStorage',
|
|
137
|
+
KyselyAuditStorage<TestDatabase>
|
|
138
|
+
> = {
|
|
139
|
+
serviceName: 'auditStorage' as const,
|
|
140
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
144
|
+
|
|
145
|
+
const audits: MappedAudit<TestAuditAction, typeof outputSchema>[] = [
|
|
146
|
+
{
|
|
147
|
+
type: 'user.created',
|
|
148
|
+
payload: (response) => ({
|
|
149
|
+
userId: response.id,
|
|
150
|
+
email: response.email,
|
|
151
|
+
}),
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
const endpoint = new Endpoint({
|
|
156
|
+
route: '/users',
|
|
157
|
+
method: 'POST',
|
|
158
|
+
fn: async () => {
|
|
159
|
+
return { id: 1, email: 'test@example.com' };
|
|
160
|
+
},
|
|
161
|
+
input: undefined,
|
|
162
|
+
output: outputSchema,
|
|
163
|
+
services: [],
|
|
164
|
+
logger: mockLogger,
|
|
165
|
+
timeout: undefined,
|
|
166
|
+
memorySize: undefined,
|
|
167
|
+
status: 201,
|
|
168
|
+
getSession: undefined,
|
|
169
|
+
authorize: undefined,
|
|
170
|
+
description: undefined,
|
|
171
|
+
events: [],
|
|
172
|
+
publisherService: undefined,
|
|
173
|
+
auditorStorageService: auditStorageService,
|
|
174
|
+
audits,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
178
|
+
envParser,
|
|
179
|
+
endpoint as any,
|
|
180
|
+
);
|
|
181
|
+
const handler = adapter.handler;
|
|
182
|
+
|
|
183
|
+
const event = createMockV2Event({
|
|
184
|
+
requestContext: {
|
|
185
|
+
...createMockV2Event().requestContext,
|
|
186
|
+
http: {
|
|
187
|
+
method: 'POST',
|
|
188
|
+
path: '/users',
|
|
189
|
+
protocol: 'HTTP/1.1',
|
|
190
|
+
sourceIp: '192.168.1.1',
|
|
191
|
+
userAgent: 'test-agent',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
body: JSON.stringify({}),
|
|
195
|
+
});
|
|
196
|
+
const context = createMockContext();
|
|
197
|
+
const response = await handler(event, context);
|
|
198
|
+
|
|
199
|
+
expect(response.statusCode).toBe(201);
|
|
200
|
+
|
|
201
|
+
// Verify audit was written to the real database
|
|
202
|
+
const auditsInDb = await db
|
|
203
|
+
.selectFrom('awsAuditLogs')
|
|
204
|
+
.selectAll()
|
|
205
|
+
.execute();
|
|
206
|
+
|
|
207
|
+
expect(auditsInDb).toHaveLength(1);
|
|
208
|
+
expect(auditsInDb[0].type).toBe('user.created');
|
|
209
|
+
expect(auditsInDb[0].payload).toEqual({
|
|
210
|
+
userId: 1,
|
|
211
|
+
email: 'test@example.com',
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should not write audit when handler fails', async () => {
|
|
216
|
+
const auditStorageService: Service<
|
|
217
|
+
'auditStorage',
|
|
218
|
+
KyselyAuditStorage<TestDatabase>
|
|
219
|
+
> = {
|
|
220
|
+
serviceName: 'auditStorage' as const,
|
|
221
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
225
|
+
|
|
226
|
+
const audits: MappedAudit<TestAuditAction, typeof outputSchema>[] = [
|
|
227
|
+
{
|
|
228
|
+
type: 'user.created',
|
|
229
|
+
payload: (response) => ({
|
|
230
|
+
userId: response.id,
|
|
231
|
+
email: response.email,
|
|
232
|
+
}),
|
|
233
|
+
},
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
const endpoint = new Endpoint({
|
|
237
|
+
route: '/users',
|
|
238
|
+
method: 'POST',
|
|
239
|
+
fn: async () => {
|
|
240
|
+
throw new Error('Handler failed');
|
|
241
|
+
},
|
|
242
|
+
input: undefined,
|
|
243
|
+
output: outputSchema,
|
|
244
|
+
services: [],
|
|
245
|
+
logger: mockLogger,
|
|
246
|
+
timeout: undefined,
|
|
247
|
+
memorySize: undefined,
|
|
248
|
+
status: 201,
|
|
249
|
+
getSession: undefined,
|
|
250
|
+
authorize: undefined,
|
|
251
|
+
description: undefined,
|
|
252
|
+
events: [],
|
|
253
|
+
publisherService: undefined,
|
|
254
|
+
auditorStorageService: auditStorageService,
|
|
255
|
+
audits,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
259
|
+
envParser,
|
|
260
|
+
endpoint as any,
|
|
261
|
+
);
|
|
262
|
+
const handler = adapter.handler;
|
|
263
|
+
|
|
264
|
+
const event = createMockV2Event({
|
|
265
|
+
requestContext: {
|
|
266
|
+
...createMockV2Event().requestContext,
|
|
267
|
+
http: {
|
|
268
|
+
method: 'POST',
|
|
269
|
+
path: '/users',
|
|
270
|
+
protocol: 'HTTP/1.1',
|
|
271
|
+
sourceIp: '192.168.1.1',
|
|
272
|
+
userAgent: 'test-agent',
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
body: JSON.stringify({}),
|
|
276
|
+
});
|
|
277
|
+
const context = createMockContext();
|
|
278
|
+
const response = await handler(event, context);
|
|
279
|
+
|
|
280
|
+
expect(response.statusCode).toBe(500);
|
|
281
|
+
|
|
282
|
+
// Verify no audit was written
|
|
283
|
+
const auditsInDb = await db
|
|
284
|
+
.selectFrom('awsAuditLogs')
|
|
285
|
+
.selectAll()
|
|
286
|
+
.execute();
|
|
287
|
+
|
|
288
|
+
expect(auditsInDb).toHaveLength(0);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
describe('manual audits with real database', () => {
|
|
293
|
+
it('should write manual audits from handler to database', async () => {
|
|
294
|
+
const auditStorageService: Service<
|
|
295
|
+
'auditStorage',
|
|
296
|
+
KyselyAuditStorage<TestDatabase>
|
|
297
|
+
> = {
|
|
298
|
+
serviceName: 'auditStorage' as const,
|
|
299
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
303
|
+
|
|
304
|
+
const endpoint = new Endpoint({
|
|
305
|
+
route: '/users',
|
|
306
|
+
method: 'POST',
|
|
307
|
+
fn: async (
|
|
308
|
+
ctx: EndpointContext<
|
|
309
|
+
undefined,
|
|
310
|
+
[],
|
|
311
|
+
Logger,
|
|
312
|
+
unknown,
|
|
313
|
+
TestAuditAction,
|
|
314
|
+
undefined,
|
|
315
|
+
KyselyAuditStorage<TestDatabase>
|
|
316
|
+
>,
|
|
317
|
+
) => {
|
|
318
|
+
// Manual audit in handler - auditor is guaranteed to exist when TAuditStorage is configured
|
|
319
|
+
ctx.auditor.audit('user.created', {
|
|
320
|
+
userId: 42,
|
|
321
|
+
email: 'manual@example.com',
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
return { id: 42, email: 'manual@example.com' };
|
|
325
|
+
},
|
|
326
|
+
input: undefined,
|
|
327
|
+
output: outputSchema,
|
|
328
|
+
services: [],
|
|
329
|
+
logger: mockLogger,
|
|
330
|
+
timeout: undefined,
|
|
331
|
+
memorySize: undefined,
|
|
332
|
+
status: 201,
|
|
333
|
+
getSession: undefined,
|
|
334
|
+
authorize: undefined,
|
|
335
|
+
description: undefined,
|
|
336
|
+
events: [],
|
|
337
|
+
publisherService: undefined,
|
|
338
|
+
auditorStorageService: auditStorageService,
|
|
339
|
+
audits: [],
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
343
|
+
envParser,
|
|
344
|
+
endpoint as any,
|
|
345
|
+
);
|
|
346
|
+
const handler = adapter.handler;
|
|
347
|
+
|
|
348
|
+
const event = createMockV2Event({
|
|
349
|
+
requestContext: {
|
|
350
|
+
...createMockV2Event().requestContext,
|
|
351
|
+
http: {
|
|
352
|
+
method: 'POST',
|
|
353
|
+
path: '/users',
|
|
354
|
+
protocol: 'HTTP/1.1',
|
|
355
|
+
sourceIp: '192.168.1.1',
|
|
356
|
+
userAgent: 'test-agent',
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
body: JSON.stringify({}),
|
|
360
|
+
});
|
|
361
|
+
const context = createMockContext();
|
|
362
|
+
const response = await handler(event, context);
|
|
363
|
+
|
|
364
|
+
expect(response.statusCode).toBe(201);
|
|
365
|
+
|
|
366
|
+
// Verify manual audit was written
|
|
367
|
+
const auditsInDb = await db
|
|
368
|
+
.selectFrom('awsAuditLogs')
|
|
369
|
+
.selectAll()
|
|
370
|
+
.execute();
|
|
371
|
+
|
|
372
|
+
expect(auditsInDb).toHaveLength(1);
|
|
373
|
+
expect(auditsInDb[0].type).toBe('user.created');
|
|
374
|
+
expect(auditsInDb[0].payload).toEqual({
|
|
375
|
+
userId: 42,
|
|
376
|
+
email: 'manual@example.com',
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it('should not write manual audit when handler fails after audit call', async () => {
|
|
381
|
+
const auditStorageService: Service<
|
|
382
|
+
'auditStorage',
|
|
383
|
+
KyselyAuditStorage<TestDatabase>
|
|
384
|
+
> = {
|
|
385
|
+
serviceName: 'auditStorage' as const,
|
|
386
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
390
|
+
|
|
391
|
+
const endpoint = new Endpoint({
|
|
392
|
+
route: '/users',
|
|
393
|
+
method: 'POST',
|
|
394
|
+
fn: async (
|
|
395
|
+
ctx: EndpointContext<
|
|
396
|
+
undefined,
|
|
397
|
+
[],
|
|
398
|
+
Logger,
|
|
399
|
+
unknown,
|
|
400
|
+
TestAuditAction,
|
|
401
|
+
undefined,
|
|
402
|
+
KyselyAuditStorage<TestDatabase>
|
|
403
|
+
>,
|
|
404
|
+
) => {
|
|
405
|
+
// Manual audit before failure - auditor is guaranteed to exist
|
|
406
|
+
ctx.auditor.audit('user.created', {
|
|
407
|
+
userId: 99,
|
|
408
|
+
email: 'shouldnotexist@example.com',
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
// Fail after audit
|
|
412
|
+
throw new Error('Handler failed after audit');
|
|
413
|
+
},
|
|
414
|
+
input: undefined,
|
|
415
|
+
output: outputSchema,
|
|
416
|
+
services: [],
|
|
417
|
+
logger: mockLogger,
|
|
418
|
+
timeout: undefined,
|
|
419
|
+
memorySize: undefined,
|
|
420
|
+
status: 201,
|
|
421
|
+
getSession: undefined,
|
|
422
|
+
authorize: undefined,
|
|
423
|
+
description: undefined,
|
|
424
|
+
events: [],
|
|
425
|
+
publisherService: undefined,
|
|
426
|
+
auditorStorageService: auditStorageService,
|
|
427
|
+
audits: [],
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
431
|
+
envParser,
|
|
432
|
+
endpoint as any,
|
|
433
|
+
);
|
|
434
|
+
const handler = adapter.handler;
|
|
435
|
+
|
|
436
|
+
const event = createMockV2Event({
|
|
437
|
+
requestContext: {
|
|
438
|
+
...createMockV2Event().requestContext,
|
|
439
|
+
http: {
|
|
440
|
+
method: 'POST',
|
|
441
|
+
path: '/users',
|
|
442
|
+
protocol: 'HTTP/1.1',
|
|
443
|
+
sourceIp: '192.168.1.1',
|
|
444
|
+
userAgent: 'test-agent',
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
body: JSON.stringify({}),
|
|
448
|
+
});
|
|
449
|
+
const context = createMockContext();
|
|
450
|
+
const response = await handler(event, context);
|
|
451
|
+
|
|
452
|
+
expect(response.statusCode).toBe(500);
|
|
453
|
+
|
|
454
|
+
// Verify no audit was written (transaction rolled back)
|
|
455
|
+
const auditsInDb = await db
|
|
456
|
+
.selectFrom('awsAuditLogs')
|
|
457
|
+
.selectAll()
|
|
458
|
+
.execute();
|
|
459
|
+
|
|
460
|
+
expect(auditsInDb).toHaveLength(0);
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
describe('transactional consistency with real database', () => {
|
|
465
|
+
it('should commit both user insert and audit on success', async () => {
|
|
466
|
+
const databaseService: Service<'database', Kysely<TestDatabase>> = {
|
|
467
|
+
serviceName: 'database' as const,
|
|
468
|
+
register: vi.fn().mockResolvedValue(db),
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
const auditStorageService: Service<
|
|
472
|
+
'auditStorage',
|
|
473
|
+
KyselyAuditStorage<TestDatabase>
|
|
474
|
+
> = {
|
|
475
|
+
serviceName: 'auditStorage' as const,
|
|
476
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
480
|
+
|
|
481
|
+
const endpoint = new Endpoint({
|
|
482
|
+
route: '/users',
|
|
483
|
+
method: 'POST',
|
|
484
|
+
fn: async (
|
|
485
|
+
ctx: EndpointContext<
|
|
486
|
+
undefined,
|
|
487
|
+
[typeof databaseService],
|
|
488
|
+
Logger,
|
|
489
|
+
unknown,
|
|
490
|
+
TestAuditAction,
|
|
491
|
+
undefined,
|
|
492
|
+
KyselyAuditStorage<TestDatabase>
|
|
493
|
+
>,
|
|
494
|
+
) => {
|
|
495
|
+
const database = ctx.services.database;
|
|
496
|
+
|
|
497
|
+
// Insert user
|
|
498
|
+
const user = await database
|
|
499
|
+
.insertInto('awsUsers')
|
|
500
|
+
.values({ name: 'Success User', email: 'success@example.com' })
|
|
501
|
+
.returningAll()
|
|
502
|
+
.executeTakeFirstOrThrow();
|
|
503
|
+
|
|
504
|
+
// Record audit - auditor is guaranteed to exist
|
|
505
|
+
ctx.auditor.audit('user.created', {
|
|
506
|
+
userId: user.id,
|
|
507
|
+
email: user.email,
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
return { id: user.id, email: user.email };
|
|
511
|
+
},
|
|
512
|
+
input: undefined,
|
|
513
|
+
output: outputSchema,
|
|
514
|
+
services: [databaseService],
|
|
515
|
+
logger: mockLogger,
|
|
516
|
+
timeout: undefined,
|
|
517
|
+
memorySize: undefined,
|
|
518
|
+
status: 201,
|
|
519
|
+
getSession: undefined,
|
|
520
|
+
authorize: undefined,
|
|
521
|
+
description: undefined,
|
|
522
|
+
events: [],
|
|
523
|
+
publisherService: undefined,
|
|
524
|
+
auditorStorageService: auditStorageService,
|
|
525
|
+
audits: [],
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
529
|
+
envParser,
|
|
530
|
+
endpoint as any,
|
|
531
|
+
);
|
|
532
|
+
const handler = adapter.handler;
|
|
533
|
+
|
|
534
|
+
const event = createMockV2Event({
|
|
535
|
+
requestContext: {
|
|
536
|
+
...createMockV2Event().requestContext,
|
|
537
|
+
http: {
|
|
538
|
+
method: 'POST',
|
|
539
|
+
path: '/users',
|
|
540
|
+
protocol: 'HTTP/1.1',
|
|
541
|
+
sourceIp: '192.168.1.1',
|
|
542
|
+
userAgent: 'test-agent',
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
body: JSON.stringify({}),
|
|
546
|
+
});
|
|
547
|
+
const context = createMockContext();
|
|
548
|
+
const response = await handler(event, context);
|
|
549
|
+
|
|
550
|
+
expect(response.statusCode).toBe(201);
|
|
551
|
+
|
|
552
|
+
// Verify user was created
|
|
553
|
+
const usersInDb = await db.selectFrom('awsUsers').selectAll().execute();
|
|
554
|
+
expect(usersInDb).toHaveLength(1);
|
|
555
|
+
expect(usersInDb[0].email).toBe('success@example.com');
|
|
556
|
+
|
|
557
|
+
// Verify audit was written
|
|
558
|
+
const auditsInDb = await db
|
|
559
|
+
.selectFrom('awsAuditLogs')
|
|
560
|
+
.selectAll()
|
|
561
|
+
.execute();
|
|
562
|
+
expect(auditsInDb).toHaveLength(1);
|
|
563
|
+
expect(auditsInDb[0].type).toBe('user.created');
|
|
564
|
+
expect(auditsInDb[0].payload).toEqual({
|
|
565
|
+
userId: usersInDb[0].id,
|
|
566
|
+
email: 'success@example.com',
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
it('should handle combined declarative and manual audits', async () => {
|
|
571
|
+
const auditStorageService: Service<
|
|
572
|
+
'auditStorage',
|
|
573
|
+
KyselyAuditStorage<TestDatabase>
|
|
574
|
+
> = {
|
|
575
|
+
serviceName: 'auditStorage' as const,
|
|
576
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
580
|
+
|
|
581
|
+
// Declarative audit
|
|
582
|
+
const audits: MappedAudit<TestAuditAction, typeof outputSchema>[] = [
|
|
583
|
+
{
|
|
584
|
+
type: 'user.created',
|
|
585
|
+
payload: (response) => ({
|
|
586
|
+
userId: response.id,
|
|
587
|
+
email: response.email,
|
|
588
|
+
}),
|
|
589
|
+
},
|
|
590
|
+
];
|
|
591
|
+
|
|
592
|
+
const endpoint = new Endpoint({
|
|
593
|
+
route: '/users',
|
|
594
|
+
method: 'POST',
|
|
595
|
+
fn: async (
|
|
596
|
+
ctx: EndpointContext<
|
|
597
|
+
undefined,
|
|
598
|
+
[],
|
|
599
|
+
Logger,
|
|
600
|
+
unknown,
|
|
601
|
+
TestAuditAction,
|
|
602
|
+
undefined,
|
|
603
|
+
KyselyAuditStorage<TestDatabase>
|
|
604
|
+
>,
|
|
605
|
+
) => {
|
|
606
|
+
// Manual audit - auditor is guaranteed to exist
|
|
607
|
+
ctx.auditor.audit('user.updated', {
|
|
608
|
+
userId: 100,
|
|
609
|
+
changes: ['verified'],
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
return { id: 100, email: 'combined@example.com' };
|
|
613
|
+
},
|
|
614
|
+
input: undefined,
|
|
615
|
+
output: outputSchema,
|
|
616
|
+
services: [],
|
|
617
|
+
logger: mockLogger,
|
|
618
|
+
timeout: undefined,
|
|
619
|
+
memorySize: undefined,
|
|
620
|
+
status: 201,
|
|
621
|
+
getSession: undefined,
|
|
622
|
+
authorize: undefined,
|
|
623
|
+
description: undefined,
|
|
624
|
+
events: [],
|
|
625
|
+
publisherService: undefined,
|
|
626
|
+
auditorStorageService: auditStorageService,
|
|
627
|
+
audits,
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
631
|
+
envParser,
|
|
632
|
+
endpoint as any,
|
|
633
|
+
);
|
|
634
|
+
const handler = adapter.handler;
|
|
635
|
+
|
|
636
|
+
const event = createMockV2Event({
|
|
637
|
+
requestContext: {
|
|
638
|
+
...createMockV2Event().requestContext,
|
|
639
|
+
http: {
|
|
640
|
+
method: 'POST',
|
|
641
|
+
path: '/users',
|
|
642
|
+
protocol: 'HTTP/1.1',
|
|
643
|
+
sourceIp: '192.168.1.1',
|
|
644
|
+
userAgent: 'test-agent',
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
body: JSON.stringify({}),
|
|
648
|
+
});
|
|
649
|
+
const context = createMockContext();
|
|
650
|
+
const response = await handler(event, context);
|
|
651
|
+
|
|
652
|
+
expect(response.statusCode).toBe(201);
|
|
653
|
+
|
|
654
|
+
// Verify both audits were written
|
|
655
|
+
const auditsInDb = await db
|
|
656
|
+
.selectFrom('awsAuditLogs')
|
|
657
|
+
.selectAll()
|
|
658
|
+
.execute();
|
|
659
|
+
|
|
660
|
+
expect(auditsInDb).toHaveLength(2);
|
|
661
|
+
|
|
662
|
+
const auditTypes = auditsInDb.map((a) => a.type).sort();
|
|
663
|
+
expect(auditTypes).toEqual(['user.created', 'user.updated']);
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
describe('actor extraction with real database', () => {
|
|
668
|
+
it('should include actor information in audit records', async () => {
|
|
669
|
+
const auditStorageService: Service<
|
|
670
|
+
'auditStorage',
|
|
671
|
+
KyselyAuditStorage<TestDatabase>
|
|
672
|
+
> = {
|
|
673
|
+
serviceName: 'auditStorage' as const,
|
|
674
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
678
|
+
|
|
679
|
+
const audits: MappedAudit<TestAuditAction, typeof outputSchema>[] = [
|
|
680
|
+
{
|
|
681
|
+
type: 'user.created',
|
|
682
|
+
payload: (response) => ({
|
|
683
|
+
userId: response.id,
|
|
684
|
+
email: response.email,
|
|
685
|
+
}),
|
|
686
|
+
},
|
|
687
|
+
];
|
|
688
|
+
|
|
689
|
+
const endpoint = new Endpoint({
|
|
690
|
+
route: '/users',
|
|
691
|
+
method: 'POST',
|
|
692
|
+
fn: async () => {
|
|
693
|
+
return { id: 1, email: 'actor-test@example.com' };
|
|
694
|
+
},
|
|
695
|
+
input: undefined,
|
|
696
|
+
output: outputSchema,
|
|
697
|
+
services: [],
|
|
698
|
+
logger: mockLogger,
|
|
699
|
+
timeout: undefined,
|
|
700
|
+
memorySize: undefined,
|
|
701
|
+
status: 201,
|
|
702
|
+
getSession: undefined,
|
|
703
|
+
authorize: undefined,
|
|
704
|
+
description: undefined,
|
|
705
|
+
events: [],
|
|
706
|
+
publisherService: undefined,
|
|
707
|
+
auditorStorageService: auditStorageService,
|
|
708
|
+
audits,
|
|
709
|
+
actorExtractor: async ({ header }) => {
|
|
710
|
+
const userId = header('x-user-id');
|
|
711
|
+
return {
|
|
712
|
+
id: userId ?? 'anonymous',
|
|
713
|
+
type: userId ? 'user' : 'anonymous',
|
|
714
|
+
};
|
|
715
|
+
},
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
719
|
+
envParser,
|
|
720
|
+
endpoint as any,
|
|
721
|
+
);
|
|
722
|
+
const handler = adapter.handler;
|
|
723
|
+
|
|
724
|
+
const event = createMockV2Event({
|
|
725
|
+
requestContext: {
|
|
726
|
+
...createMockV2Event().requestContext,
|
|
727
|
+
http: {
|
|
728
|
+
method: 'POST',
|
|
729
|
+
path: '/users',
|
|
730
|
+
protocol: 'HTTP/1.1',
|
|
731
|
+
sourceIp: '192.168.1.1',
|
|
732
|
+
userAgent: 'test-agent',
|
|
733
|
+
},
|
|
734
|
+
},
|
|
735
|
+
headers: {
|
|
736
|
+
'content-type': 'application/json',
|
|
737
|
+
'x-user-id': 'user-123',
|
|
738
|
+
},
|
|
739
|
+
body: JSON.stringify({}),
|
|
740
|
+
});
|
|
741
|
+
const context = createMockContext();
|
|
742
|
+
const response = await handler(event, context);
|
|
743
|
+
|
|
744
|
+
expect(response.statusCode).toBe(201);
|
|
745
|
+
|
|
746
|
+
// Verify actor was included in audit
|
|
747
|
+
const auditsInDb = await db
|
|
748
|
+
.selectFrom('awsAuditLogs')
|
|
749
|
+
.selectAll()
|
|
750
|
+
.execute();
|
|
751
|
+
|
|
752
|
+
expect(auditsInDb).toHaveLength(1);
|
|
753
|
+
expect(auditsInDb[0].actorId).toBe('user-123');
|
|
754
|
+
expect(auditsInDb[0].actorType).toBe('user');
|
|
755
|
+
});
|
|
756
|
+
});
|
|
757
|
+
});
|