@geekmidas/constructs 0.0.10 → 0.0.12
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/dist/{AWSLambdaFunction-DhUb-Vs6.cjs → AWSLambdaFunction-DMxScuaw.cjs} +3 -3
- package/dist/{AWSLambdaFunction-DhUb-Vs6.cjs.map → AWSLambdaFunction-DMxScuaw.cjs.map} +1 -1
- package/dist/{AWSLambdaFunction-D5V3YVqv.d.cts → AWSLambdaFunction-DSB2oaFG.d.mts} +5 -5
- package/dist/{AWSLambdaFunction-D_V-ZQmS.mjs → AWSLambdaFunction-cL8A169J.mjs} +3 -3
- package/dist/{AWSLambdaFunction-D_V-ZQmS.mjs.map → AWSLambdaFunction-cL8A169J.mjs.map} +1 -1
- package/dist/{AWSLambdaFunction-DvZcnL8a.d.mts → AWSLambdaFunction-t6q2o8EL.d.cts} +5 -5
- package/dist/{AWSLambdaSubscriberAdaptor-J_pSz6pu.d.cts → AWSLambdaSubscriberAdaptor-Cknp_nn1.d.cts} +2 -2
- 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-D6kjKjSf.d.mts → AWSLambdaSubscriberAdaptor-DpHzp-AM.d.mts} +2 -2
- 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-DHcUetbw.mjs → AmazonApiGatewayEndpointAdaptor-CIEhW1TQ.mjs} +47 -16
- package/dist/AmazonApiGatewayEndpointAdaptor-CIEhW1TQ.mjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-BnNd8tCz.d.cts → AmazonApiGatewayEndpointAdaptor-CwItKPz2.d.cts} +6 -5
- package/dist/{AmazonApiGatewayEndpointAdaptor-DHBF_5jn.cjs → AmazonApiGatewayEndpointAdaptor-H8YvtfQm.cjs} +47 -16
- package/dist/AmazonApiGatewayEndpointAdaptor-H8YvtfQm.cjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-B7MKo8h3.d.mts → AmazonApiGatewayEndpointAdaptor-eDQgPNLH.d.mts} +7 -6
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-CmUxFoPx.cjs → AmazonApiGatewayV1EndpointAdaptor-0n71d3gq.cjs} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-CmUxFoPx.cjs.map → AmazonApiGatewayV1EndpointAdaptor-0n71d3gq.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-CsV6zyvn.mjs → AmazonApiGatewayV1EndpointAdaptor-B36zXLJ7.mjs} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-CsV6zyvn.mjs.map → AmazonApiGatewayV1EndpointAdaptor-B36zXLJ7.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-gO9OxdZl.d.mts → AmazonApiGatewayV1EndpointAdaptor-CnGVpA38.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-BC-a2tt3.d.cts → AmazonApiGatewayV1EndpointAdaptor-DaCvUL6y.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-D1uz4wNg.d.mts → AmazonApiGatewayV2EndpointAdaptor-BELz2ijs.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-_bFcbEa-.mjs → AmazonApiGatewayV2EndpointAdaptor-CE3wZEb8.mjs} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-_bFcbEa-.mjs.map → AmazonApiGatewayV2EndpointAdaptor-CE3wZEb8.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-zNFUPxSY.d.cts → AmazonApiGatewayV2EndpointAdaptor-DA1PH0nc.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-cZbaqiUi.cjs → AmazonApiGatewayV2EndpointAdaptor-DtU3Cb8F.cjs} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-cZbaqiUi.cjs.map → AmazonApiGatewayV2EndpointAdaptor-DtU3Cb8F.cjs.map} +1 -1
- package/dist/{Authorizer-Bbk9ziuG.d.mts → Authorizer-BRCVPz_O.d.mts} +1 -1
- package/dist/{Authorizer-iXsSB600.d.cts → Authorizer-DG54w1m2.d.cts} +1 -1
- package/dist/{BaseFunctionBuilder-BmsbV0BU.cjs → BaseFunctionBuilder-B8rT07QR.cjs} +7 -2
- package/dist/BaseFunctionBuilder-B8rT07QR.cjs.map +1 -0
- package/dist/{BaseFunctionBuilder-DCUtCdVL.mjs → BaseFunctionBuilder-CT7p10K1.mjs} +7 -2
- package/dist/BaseFunctionBuilder-CT7p10K1.mjs.map +1 -0
- package/dist/{BaseFunctionBuilder-C4ZJPkIZ.d.cts → BaseFunctionBuilder-Cf0op65o.d.cts} +7 -4
- package/dist/{BaseFunctionBuilder-CxBX0arJ.d.mts → BaseFunctionBuilder-DilipY1y.d.mts} +7 -4
- package/dist/{Construct-VEI7M3fs.cjs → Construct-BYSPikVm.cjs} +28 -10
- package/dist/Construct-BYSPikVm.cjs.map +1 -0
- package/dist/{Construct-C3hsQBy4.mjs → Construct-LWeB1rSQ.mjs} +28 -10
- package/dist/Construct-LWeB1rSQ.mjs.map +1 -0
- package/dist/{Construct-ci5u8Xnu.d.cts → Construct-ZPqE0vhn.d.mts} +9 -4
- package/dist/{Construct-zhmcmIdY.d.mts → Construct-dI_rgdSp.d.cts} +9 -4
- 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-ByNYsQDH.d.mts → Cron-6lOgKqSA.d.cts} +3 -3
- package/dist/{Cron-DkPL-Fms.d.cts → Cron-BH_07atD.d.mts} +3 -3
- package/dist/{Cron-Dfgr8F9d.cjs → Cron-Bnd-2pgE.cjs} +3 -3
- package/dist/{Cron-Dfgr8F9d.cjs.map → Cron-Bnd-2pgE.cjs.map} +1 -1
- package/dist/{Cron-wP6Ob48_.mjs → Cron-DNRjf2cp.mjs} +3 -3
- package/dist/{Cron-wP6Ob48_.mjs.map → Cron-DNRjf2cp.mjs.map} +1 -1
- package/dist/{CronBuilder-BknVTWLE.d.mts → CronBuilder-5oK2AL2n.d.cts} +5 -5
- package/dist/{CronBuilder-BqTTozUi.d.cts → CronBuilder-D2b4zY4l.d.mts} +5 -5
- package/dist/{CronBuilder-C27c5oqh.mjs → CronBuilder-DdR2TuQa.mjs} +5 -5
- package/dist/{CronBuilder-C27c5oqh.mjs.map → CronBuilder-DdR2TuQa.mjs.map} +1 -1
- package/dist/{CronBuilder-W1ZqCJ7m.cjs → CronBuilder-dtw4ZyH6.cjs} +5 -5
- package/dist/{CronBuilder-W1ZqCJ7m.cjs.map → CronBuilder-dtw4ZyH6.cjs.map} +1 -1
- package/dist/{Endpoint-C98BwZjA.mjs → Endpoint-B69TqESg.mjs} +15 -8
- package/dist/Endpoint-B69TqESg.mjs.map +1 -0
- package/dist/{Endpoint-BjpQmTek.cjs → Endpoint-B9PryZES.cjs} +15 -8
- package/dist/Endpoint-B9PryZES.cjs.map +1 -0
- package/dist/{Endpoint-zHPjZ35J.d.cts → Endpoint-Cs-MsYlY.d.cts} +80 -12
- package/dist/{Endpoint-C16whGI-.d.mts → Endpoint-DuZlyjd4.d.mts} +80 -12
- package/dist/EndpointBuilder-BrB-K1jO.d.mts +86 -0
- package/dist/EndpointBuilder-C-PHInEW.d.cts +86 -0
- package/dist/{EndpointBuilder-CCUx4vep.mjs → EndpointBuilder-DnVL-EU_.mjs} +47 -5
- package/dist/EndpointBuilder-DnVL-EU_.mjs.map +1 -0
- package/dist/{EndpointBuilder-D2Zu8i9b.cjs → EndpointBuilder-DofwCnWJ.cjs} +47 -5
- package/dist/EndpointBuilder-DofwCnWJ.cjs.map +1 -0
- package/dist/{EndpointFactory-KkyIOE62.d.cts → EndpointFactory-6zNpVSYp.d.mts} +12 -11
- package/dist/{EndpointFactory-C4YhgXOc.cjs → EndpointFactory-Ba9mx9MU.cjs} +3 -3
- package/dist/{EndpointFactory-C4YhgXOc.cjs.map → EndpointFactory-Ba9mx9MU.cjs.map} +1 -1
- package/dist/{EndpointFactory-VnSAdwdv.d.mts → EndpointFactory-e5WYVR6t.d.cts} +12 -11
- package/dist/{EndpointFactory-RAb2zcw0.mjs → EndpointFactory-pPaIGFHV.mjs} +3 -3
- package/dist/{EndpointFactory-RAb2zcw0.mjs.map → EndpointFactory-pPaIGFHV.mjs.map} +1 -1
- package/dist/{Function-BbLYIKLL.d.cts → Function-6EWabl_X.d.cts} +5 -4
- package/dist/{Function-1Fh6Tdkg.cjs → Function-CO-s2pB8.cjs} +6 -6
- package/dist/Function-CO-s2pB8.cjs.map +1 -0
- package/dist/{Function-D-QEfH7k.mjs → Function-COnc-tWM.mjs} +6 -6
- package/dist/Function-COnc-tWM.mjs.map +1 -0
- package/dist/{Function-DFRZZCC-.d.mts → Function-G3JPHMaY.d.mts} +5 -4
- package/dist/{FunctionBuilder-DdGjpiFT.d.cts → FunctionBuilder-B3fpp3hA.d.cts} +13 -11
- package/dist/{FunctionBuilder-DuktGyZc.d.mts → FunctionBuilder-ByaB_LQ4.d.mts} +13 -11
- package/dist/{FunctionBuilder-Bxyr1Pf9.mjs → FunctionBuilder-CMhLQ4dt.mjs} +11 -6
- package/dist/FunctionBuilder-CMhLQ4dt.mjs.map +1 -0
- package/dist/{FunctionBuilder-DcEFYgbn.cjs → FunctionBuilder-_hMwZUof.cjs} +11 -6
- package/dist/FunctionBuilder-_hMwZUof.cjs.map +1 -0
- package/dist/{FunctionExecutionWrapper-CRYi047B.d.cts → FunctionExecutionWrapper-Ci-ookJG.d.cts} +2 -2
- package/dist/{FunctionExecutionWrapper-DaR-dSLw.d.mts → FunctionExecutionWrapper-DHFMLrOl.d.mts} +2 -2
- package/dist/{FunctionExecutionWrapper-BL6PE6Dv.mjs → FunctionExecutionWrapper-i9v5L3Av.mjs} +2 -2
- package/dist/{FunctionExecutionWrapper-BL6PE6Dv.mjs.map → FunctionExecutionWrapper-i9v5L3Av.mjs.map} +1 -1
- package/dist/{FunctionExecutionWrapper-Ee-CE8Fz.cjs → FunctionExecutionWrapper-sxJNTpuc.cjs} +2 -2
- package/dist/{FunctionExecutionWrapper-Ee-CE8Fz.cjs.map → FunctionExecutionWrapper-sxJNTpuc.cjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-CY1mXTe6.d.mts → HonoEndpointAdaptor-BElil8O5.d.mts} +9 -8
- package/dist/{HonoEndpointAdaptor-DcvZdYzx.cjs → HonoEndpointAdaptor-Cw2if5cG.cjs} +51 -20
- package/dist/HonoEndpointAdaptor-Cw2if5cG.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-CyVPl4w2.mjs → HonoEndpointAdaptor-DAfnTFVS.mjs} +51 -20
- package/dist/HonoEndpointAdaptor-DAfnTFVS.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-CYvrXBe-.d.cts → HonoEndpointAdaptor-DSHl8ZCY.d.cts} +8 -7
- package/dist/{Subscriber-Cy28j8MS.d.cts → Subscriber-BhzqUzs-.d.cts} +2 -2
- package/dist/{Subscriber-CTczVFsF.mjs → Subscriber-CGb8LjZa.mjs} +2 -2
- package/dist/{Subscriber-CTczVFsF.mjs.map → Subscriber-CGb8LjZa.mjs.map} +1 -1
- package/dist/{Subscriber-BL30GpWp.cjs → Subscriber-D-FPWts6.cjs} +2 -2
- package/dist/{Subscriber-BL30GpWp.cjs.map → Subscriber-D-FPWts6.cjs.map} +1 -1
- package/dist/{Subscriber-g3IWM1_d.d.mts → Subscriber-s6yfjeOc.d.mts} +2 -2
- package/dist/{SubscriberBuilder-BzK8kc2a.d.cts → SubscriberBuilder-BCVkp-ga.d.cts} +2 -2
- package/dist/{SubscriberBuilder-CekL3BoP.mjs → SubscriberBuilder-BcAspHv9.mjs} +2 -2
- package/dist/{SubscriberBuilder-CekL3BoP.mjs.map → SubscriberBuilder-BcAspHv9.mjs.map} +1 -1
- package/dist/{SubscriberBuilder-D1hojYLa.cjs → SubscriberBuilder-BfE2cL1q.cjs} +2 -2
- package/dist/{SubscriberBuilder-D1hojYLa.cjs.map → SubscriberBuilder-BfE2cL1q.cjs.map} +1 -1
- package/dist/{SubscriberBuilder-YjQ7qIpQ.d.mts → SubscriberBuilder-aCua5_wA.d.mts} +2 -2
- package/dist/{TestEndpointAdaptor-C-ahwGW6.cjs → TestEndpointAdaptor-Bn1WRFph.cjs} +47 -18
- package/dist/TestEndpointAdaptor-Bn1WRFph.cjs.map +1 -0
- package/dist/{TestEndpointAdaptor-DGWuai69.d.mts → TestEndpointAdaptor-DnlAA_rm.d.mts} +7 -6
- package/dist/{TestEndpointAdaptor-B4z9G5Ap.mjs → TestEndpointAdaptor-DubQOJk_.mjs} +47 -18
- package/dist/TestEndpointAdaptor-DubQOJk_.mjs.map +1 -0
- package/dist/{TestEndpointAdaptor-uXliWYjS.d.cts → TestEndpointAdaptor-o-xtSyQ3.d.cts} +6 -5
- 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 +11 -11
- 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 +4 -4
- package/dist/functions/TestFunctionAdaptor.d.cts +2 -2
- package/dist/functions/TestFunctionAdaptor.d.mts +2 -2
- package/dist/functions/TestFunctionAdaptor.mjs +4 -4
- 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-BYqZAob8.mjs +8 -0
- package/dist/{functions-DD-00sWF.mjs.map → functions-BYqZAob8.mjs.map} +1 -1
- package/dist/{functions-BtgBiuC_.cjs → functions-D03lqK-r.cjs} +2 -2
- package/dist/{functions-BtgBiuC_.cjs.map → functions-D03lqK-r.cjs.map} +1 -1
- package/dist/{helpers-QM_FSjPY.cjs → helpers-BApRyhly.cjs} +2 -2
- package/dist/{helpers-QM_FSjPY.cjs.map → helpers-BApRyhly.cjs.map} +1 -1
- package/dist/{helpers-DtPeOhUV.mjs → helpers-BPDogwac.mjs} +2 -2
- package/dist/{helpers-DtPeOhUV.mjs.map → helpers-BPDogwac.mjs.map} +1 -1
- package/dist/index-CUg_hSq-.d.cts +9 -0
- package/dist/index-D-a7e2gv.d.mts +9 -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.d.cts +1 -1
- package/dist/publisher.d.mts +1 -1
- 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 +14 -10
- package/src/Construct.ts +31 -5
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +88 -19
- package/src/endpoints/Endpoint.ts +66 -13
- package/src/endpoints/EndpointBuilder.ts +183 -19
- package/src/endpoints/HonoEndpointAdaptor.ts +114 -33
- package/src/endpoints/TestEndpointAdaptor.ts +96 -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 +718 -0
- package/src/endpoints/__tests__/Endpoint.spec.ts +19 -0
- package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +424 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +685 -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 +678 -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 +339 -0
- package/src/functions/BaseFunctionBuilder.ts +50 -7
- package/src/functions/Function.ts +13 -9
- package/src/functions/FunctionBuilder.ts +78 -14
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +43 -2
- package/dist/AmazonApiGatewayEndpointAdaptor-DHBF_5jn.cjs.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-DHcUetbw.mjs.map +0 -1
- package/dist/BaseFunctionBuilder-BmsbV0BU.cjs.map +0 -1
- package/dist/BaseFunctionBuilder-DCUtCdVL.mjs.map +0 -1
- package/dist/Construct-C3hsQBy4.mjs.map +0 -1
- package/dist/Construct-VEI7M3fs.cjs.map +0 -1
- package/dist/Endpoint-BjpQmTek.cjs.map +0 -1
- package/dist/Endpoint-C98BwZjA.mjs.map +0 -1
- package/dist/EndpointBuilder-B5l7zQU1.d.cts +0 -55
- package/dist/EndpointBuilder-BzqR0xvt.d.mts +0 -55
- package/dist/EndpointBuilder-CCUx4vep.mjs.map +0 -1
- package/dist/EndpointBuilder-D2Zu8i9b.cjs.map +0 -1
- package/dist/Function-1Fh6Tdkg.cjs.map +0 -1
- package/dist/Function-D-QEfH7k.mjs.map +0 -1
- package/dist/FunctionBuilder-Bxyr1Pf9.mjs.map +0 -1
- package/dist/FunctionBuilder-DcEFYgbn.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-CyVPl4w2.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DcvZdYzx.cjs.map +0 -1
- package/dist/TestEndpointAdaptor-B4z9G5Ap.mjs.map +0 -1
- package/dist/TestEndpointAdaptor-C-ahwGW6.cjs.map +0 -1
- package/dist/functions-DD-00sWF.mjs +0 -8
- package/dist/index-CcmV3PKF.d.cts +0 -9
- package/dist/index-DQt3pQtF.d.mts +0 -9
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import type { AuditableAction } from '@geekmidas/audit';
|
|
2
|
+
import {
|
|
3
|
+
KyselyAuditStorage,
|
|
4
|
+
type AuditLogTable,
|
|
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 { Hono } from 'hono';
|
|
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 { Endpoint, type EndpointContext } from '../Endpoint';
|
|
32
|
+
import { HonoEndpoint } from '../HonoEndpointAdaptor';
|
|
33
|
+
import type { MappedAudit } from '../audit';
|
|
34
|
+
|
|
35
|
+
// Database schema
|
|
36
|
+
interface TestDatabase {
|
|
37
|
+
auditLogs: AuditLogTable;
|
|
38
|
+
users: {
|
|
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('HonoEndpoint Kysely Audit Integration', () => {
|
|
52
|
+
let db: Kysely<TestDatabase>;
|
|
53
|
+
let auditStorage: KyselyAuditStorage<TestDatabase>;
|
|
54
|
+
let mockLogger: Logger;
|
|
55
|
+
|
|
56
|
+
const createMockLogger = (): Logger => ({
|
|
57
|
+
debug: vi.fn(),
|
|
58
|
+
info: vi.fn(),
|
|
59
|
+
warn: vi.fn(),
|
|
60
|
+
error: vi.fn(),
|
|
61
|
+
fatal: vi.fn(),
|
|
62
|
+
trace: vi.fn(),
|
|
63
|
+
child: vi.fn(function (this: Logger) {
|
|
64
|
+
return this;
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const createServiceDiscovery = (logger: Logger) => {
|
|
69
|
+
const envParser = new EnvironmentParser({});
|
|
70
|
+
ServiceDiscovery.reset();
|
|
71
|
+
return ServiceDiscovery.getInstance(logger, envParser);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
beforeAll(async () => {
|
|
75
|
+
db = new Kysely<TestDatabase>({
|
|
76
|
+
dialect: new PostgresDialect({
|
|
77
|
+
pool: new pg.Pool({
|
|
78
|
+
...TEST_DATABASE_CONFIG,
|
|
79
|
+
database: 'postgres',
|
|
80
|
+
}),
|
|
81
|
+
}),
|
|
82
|
+
plugins: [new CamelCasePlugin()],
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Create audit_logs table
|
|
86
|
+
await db.schema
|
|
87
|
+
.createTable('auditLogs')
|
|
88
|
+
.ifNotExists()
|
|
89
|
+
.addColumn('id', 'varchar(32)', (col) => col.primaryKey())
|
|
90
|
+
.addColumn('type', 'varchar', (col) => col.notNull())
|
|
91
|
+
.addColumn('operation', 'varchar', (col) => col.notNull())
|
|
92
|
+
.addColumn('table', 'varchar')
|
|
93
|
+
.addColumn('entityId', 'varchar')
|
|
94
|
+
.addColumn('oldValues', 'jsonb')
|
|
95
|
+
.addColumn('newValues', 'jsonb')
|
|
96
|
+
.addColumn('payload', 'jsonb')
|
|
97
|
+
.addColumn('timestamp', 'timestamp', (col) =>
|
|
98
|
+
col.defaultTo(sql`now()`).notNull(),
|
|
99
|
+
)
|
|
100
|
+
.addColumn('actorId', 'varchar')
|
|
101
|
+
.addColumn('actorType', 'varchar')
|
|
102
|
+
.addColumn('actorData', 'jsonb')
|
|
103
|
+
.addColumn('metadata', 'jsonb')
|
|
104
|
+
.execute();
|
|
105
|
+
|
|
106
|
+
// Create users table
|
|
107
|
+
await db.schema
|
|
108
|
+
.createTable('users')
|
|
109
|
+
.ifNotExists()
|
|
110
|
+
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
111
|
+
.addColumn('name', 'varchar', (col) => col.notNull())
|
|
112
|
+
.addColumn('email', 'varchar', (col) => col.notNull().unique())
|
|
113
|
+
.execute();
|
|
114
|
+
|
|
115
|
+
auditStorage = new KyselyAuditStorage({
|
|
116
|
+
db,
|
|
117
|
+
tableName: 'auditLogs',
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
beforeEach(() => {
|
|
122
|
+
mockLogger = createMockLogger();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
afterEach(async () => {
|
|
126
|
+
await db.deleteFrom('auditLogs').execute();
|
|
127
|
+
await db.deleteFrom('users').execute();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
afterAll(async () => {
|
|
131
|
+
await db.schema.dropTable('auditLogs').ifExists().execute();
|
|
132
|
+
await db.schema.dropTable('users').ifExists().execute();
|
|
133
|
+
await db.destroy();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('declarative audits with real database', () => {
|
|
137
|
+
it('should write declarative audit to database on successful request', async () => {
|
|
138
|
+
const serviceDiscovery = createServiceDiscovery(mockLogger);
|
|
139
|
+
|
|
140
|
+
const auditStorageService: Service<
|
|
141
|
+
'auditStorage',
|
|
142
|
+
KyselyAuditStorage<TestDatabase>
|
|
143
|
+
> = {
|
|
144
|
+
serviceName: 'auditStorage' as const,
|
|
145
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
149
|
+
|
|
150
|
+
const audits: MappedAudit<TestAuditAction, typeof outputSchema>[] = [
|
|
151
|
+
{
|
|
152
|
+
type: 'user.created',
|
|
153
|
+
payload: (response) => ({
|
|
154
|
+
userId: response.id,
|
|
155
|
+
email: response.email,
|
|
156
|
+
}),
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
const endpoint = new Endpoint({
|
|
161
|
+
route: '/users',
|
|
162
|
+
method: 'POST',
|
|
163
|
+
fn: async () => {
|
|
164
|
+
return { id: 1, email: 'test@example.com' };
|
|
165
|
+
},
|
|
166
|
+
input: undefined,
|
|
167
|
+
output: outputSchema,
|
|
168
|
+
services: [],
|
|
169
|
+
logger: mockLogger,
|
|
170
|
+
timeout: undefined,
|
|
171
|
+
memorySize: undefined,
|
|
172
|
+
status: 201,
|
|
173
|
+
getSession: undefined,
|
|
174
|
+
authorize: undefined,
|
|
175
|
+
description: undefined,
|
|
176
|
+
events: [],
|
|
177
|
+
publisherService: undefined,
|
|
178
|
+
auditorStorageService: auditStorageService,
|
|
179
|
+
audits,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const adaptor = new HonoEndpoint(endpoint);
|
|
183
|
+
const app = new Hono();
|
|
184
|
+
HonoEndpoint.applyEventMiddleware(app, serviceDiscovery);
|
|
185
|
+
adaptor.addRoute(serviceDiscovery, app);
|
|
186
|
+
|
|
187
|
+
const response = await app.request('/users', {
|
|
188
|
+
method: 'POST',
|
|
189
|
+
body: JSON.stringify({}),
|
|
190
|
+
headers: { 'Content-Type': 'application/json' },
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
expect(response.status).toBe(201);
|
|
194
|
+
|
|
195
|
+
// Verify audit was written to the real database
|
|
196
|
+
const auditsInDb = await db
|
|
197
|
+
.selectFrom('auditLogs')
|
|
198
|
+
.selectAll()
|
|
199
|
+
.execute();
|
|
200
|
+
|
|
201
|
+
expect(auditsInDb).toHaveLength(1);
|
|
202
|
+
expect(auditsInDb[0].type).toBe('user.created');
|
|
203
|
+
expect(auditsInDb[0].payload).toEqual({
|
|
204
|
+
userId: 1,
|
|
205
|
+
email: 'test@example.com',
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('should not write audit when handler fails', async () => {
|
|
210
|
+
const serviceDiscovery = createServiceDiscovery(mockLogger);
|
|
211
|
+
|
|
212
|
+
const auditStorageService: Service<
|
|
213
|
+
'auditStorage',
|
|
214
|
+
KyselyAuditStorage<TestDatabase>
|
|
215
|
+
> = {
|
|
216
|
+
serviceName: 'auditStorage' as const,
|
|
217
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
221
|
+
|
|
222
|
+
const audits: MappedAudit<TestAuditAction, typeof outputSchema>[] = [
|
|
223
|
+
{
|
|
224
|
+
type: 'user.created',
|
|
225
|
+
payload: (response) => ({
|
|
226
|
+
userId: response.id,
|
|
227
|
+
email: response.email,
|
|
228
|
+
}),
|
|
229
|
+
},
|
|
230
|
+
];
|
|
231
|
+
|
|
232
|
+
const endpoint = new Endpoint({
|
|
233
|
+
route: '/users',
|
|
234
|
+
method: 'POST',
|
|
235
|
+
fn: async () => {
|
|
236
|
+
throw new Error('Handler failed');
|
|
237
|
+
},
|
|
238
|
+
input: undefined,
|
|
239
|
+
output: outputSchema,
|
|
240
|
+
services: [],
|
|
241
|
+
logger: mockLogger,
|
|
242
|
+
timeout: undefined,
|
|
243
|
+
memorySize: undefined,
|
|
244
|
+
status: 201,
|
|
245
|
+
getSession: undefined,
|
|
246
|
+
authorize: undefined,
|
|
247
|
+
description: undefined,
|
|
248
|
+
events: [],
|
|
249
|
+
publisherService: undefined,
|
|
250
|
+
auditorStorageService: auditStorageService,
|
|
251
|
+
audits,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
const adaptor = new HonoEndpoint(endpoint);
|
|
255
|
+
const app = new Hono();
|
|
256
|
+
HonoEndpoint.applyEventMiddleware(app, serviceDiscovery);
|
|
257
|
+
adaptor.addRoute(serviceDiscovery, app);
|
|
258
|
+
|
|
259
|
+
const response = await app.request('/users', {
|
|
260
|
+
method: 'POST',
|
|
261
|
+
body: JSON.stringify({}),
|
|
262
|
+
headers: { 'Content-Type': 'application/json' },
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
expect(response.status).toBe(500);
|
|
266
|
+
|
|
267
|
+
// Verify no audit was written
|
|
268
|
+
const auditsInDb = await db
|
|
269
|
+
.selectFrom('auditLogs')
|
|
270
|
+
.selectAll()
|
|
271
|
+
.execute();
|
|
272
|
+
|
|
273
|
+
expect(auditsInDb).toHaveLength(0);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe('manual audits with real database', () => {
|
|
278
|
+
it('should write manual audits from handler to database', async () => {
|
|
279
|
+
const serviceDiscovery = createServiceDiscovery(mockLogger);
|
|
280
|
+
|
|
281
|
+
const auditStorageService: Service<
|
|
282
|
+
'auditStorage',
|
|
283
|
+
KyselyAuditStorage<TestDatabase>
|
|
284
|
+
> = {
|
|
285
|
+
serviceName: 'auditStorage' as const,
|
|
286
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
290
|
+
|
|
291
|
+
const endpoint = new Endpoint({
|
|
292
|
+
route: '/users',
|
|
293
|
+
method: 'POST',
|
|
294
|
+
fn: async (
|
|
295
|
+
ctx: EndpointContext<undefined, [], Logger, unknown, TestAuditAction>,
|
|
296
|
+
) => {
|
|
297
|
+
// Manual audit in handler
|
|
298
|
+
if (ctx.auditor) {
|
|
299
|
+
ctx.auditor.audit('user.created', {
|
|
300
|
+
userId: 42,
|
|
301
|
+
email: 'manual@example.com',
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return { id: 42, email: 'manual@example.com' };
|
|
306
|
+
},
|
|
307
|
+
input: undefined,
|
|
308
|
+
output: outputSchema,
|
|
309
|
+
services: [],
|
|
310
|
+
logger: mockLogger,
|
|
311
|
+
timeout: undefined,
|
|
312
|
+
memorySize: undefined,
|
|
313
|
+
status: 201,
|
|
314
|
+
getSession: undefined,
|
|
315
|
+
authorize: undefined,
|
|
316
|
+
description: undefined,
|
|
317
|
+
events: [],
|
|
318
|
+
publisherService: undefined,
|
|
319
|
+
auditorStorageService: auditStorageService,
|
|
320
|
+
audits: [],
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
const adaptor = new HonoEndpoint(endpoint);
|
|
324
|
+
const app = new Hono();
|
|
325
|
+
HonoEndpoint.applyEventMiddleware(app, serviceDiscovery);
|
|
326
|
+
adaptor.addRoute(serviceDiscovery, app);
|
|
327
|
+
|
|
328
|
+
const response = await app.request('/users', {
|
|
329
|
+
method: 'POST',
|
|
330
|
+
body: JSON.stringify({}),
|
|
331
|
+
headers: { 'Content-Type': 'application/json' },
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
expect(response.status).toBe(201);
|
|
335
|
+
|
|
336
|
+
// Verify manual audit was written
|
|
337
|
+
const auditsInDb = await db
|
|
338
|
+
.selectFrom('auditLogs')
|
|
339
|
+
.selectAll()
|
|
340
|
+
.execute();
|
|
341
|
+
|
|
342
|
+
expect(auditsInDb).toHaveLength(1);
|
|
343
|
+
expect(auditsInDb[0].type).toBe('user.created');
|
|
344
|
+
expect(auditsInDb[0].payload).toEqual({
|
|
345
|
+
userId: 42,
|
|
346
|
+
email: 'manual@example.com',
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('should not write manual audit when handler fails after audit call', async () => {
|
|
351
|
+
const serviceDiscovery = createServiceDiscovery(mockLogger);
|
|
352
|
+
|
|
353
|
+
const auditStorageService: Service<
|
|
354
|
+
'auditStorage',
|
|
355
|
+
KyselyAuditStorage<TestDatabase>
|
|
356
|
+
> = {
|
|
357
|
+
serviceName: 'auditStorage' as const,
|
|
358
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
362
|
+
|
|
363
|
+
const endpoint = new Endpoint({
|
|
364
|
+
route: '/users',
|
|
365
|
+
method: 'POST',
|
|
366
|
+
fn: async (
|
|
367
|
+
ctx: EndpointContext<undefined, [], Logger, unknown, TestAuditAction>,
|
|
368
|
+
) => {
|
|
369
|
+
// Manual audit before failure
|
|
370
|
+
if (ctx.auditor) {
|
|
371
|
+
ctx.auditor.audit('user.created', {
|
|
372
|
+
userId: 99,
|
|
373
|
+
email: 'shouldnotexist@example.com',
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Fail after audit
|
|
378
|
+
throw new Error('Handler failed after audit');
|
|
379
|
+
},
|
|
380
|
+
input: undefined,
|
|
381
|
+
output: outputSchema,
|
|
382
|
+
services: [],
|
|
383
|
+
logger: mockLogger,
|
|
384
|
+
timeout: undefined,
|
|
385
|
+
memorySize: undefined,
|
|
386
|
+
status: 201,
|
|
387
|
+
getSession: undefined,
|
|
388
|
+
authorize: undefined,
|
|
389
|
+
description: undefined,
|
|
390
|
+
events: [],
|
|
391
|
+
publisherService: undefined,
|
|
392
|
+
auditorStorageService: auditStorageService,
|
|
393
|
+
audits: [],
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
const adaptor = new HonoEndpoint(endpoint);
|
|
397
|
+
const app = new Hono();
|
|
398
|
+
HonoEndpoint.applyEventMiddleware(app, serviceDiscovery);
|
|
399
|
+
adaptor.addRoute(serviceDiscovery, app);
|
|
400
|
+
|
|
401
|
+
const response = await app.request('/users', {
|
|
402
|
+
method: 'POST',
|
|
403
|
+
body: JSON.stringify({}),
|
|
404
|
+
headers: { 'Content-Type': 'application/json' },
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
expect(response.status).toBe(500);
|
|
408
|
+
|
|
409
|
+
// Verify no audit was written (transaction rolled back)
|
|
410
|
+
const auditsInDb = await db
|
|
411
|
+
.selectFrom('auditLogs')
|
|
412
|
+
.selectAll()
|
|
413
|
+
.execute();
|
|
414
|
+
|
|
415
|
+
expect(auditsInDb).toHaveLength(0);
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
describe('transactional consistency with real database', () => {
|
|
420
|
+
it('should commit both user insert and audit on success', async () => {
|
|
421
|
+
const serviceDiscovery = createServiceDiscovery(mockLogger);
|
|
422
|
+
|
|
423
|
+
const databaseService: Service<'database', Kysely<TestDatabase>> = {
|
|
424
|
+
serviceName: 'database' as const,
|
|
425
|
+
register: vi.fn().mockResolvedValue(db),
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const auditStorageService: Service<
|
|
429
|
+
'auditStorage',
|
|
430
|
+
KyselyAuditStorage<TestDatabase>
|
|
431
|
+
> = {
|
|
432
|
+
serviceName: 'auditStorage' as const,
|
|
433
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
437
|
+
|
|
438
|
+
const endpoint = new Endpoint({
|
|
439
|
+
route: '/users',
|
|
440
|
+
method: 'POST',
|
|
441
|
+
fn: async (
|
|
442
|
+
ctx: EndpointContext<
|
|
443
|
+
undefined,
|
|
444
|
+
[typeof databaseService],
|
|
445
|
+
Logger,
|
|
446
|
+
unknown,
|
|
447
|
+
TestAuditAction
|
|
448
|
+
>,
|
|
449
|
+
) => {
|
|
450
|
+
const database = ctx.services.database;
|
|
451
|
+
|
|
452
|
+
// Insert user
|
|
453
|
+
const user = await database
|
|
454
|
+
.insertInto('users')
|
|
455
|
+
.values({ name: 'Success User', email: 'success@example.com' })
|
|
456
|
+
.returningAll()
|
|
457
|
+
.executeTakeFirstOrThrow();
|
|
458
|
+
|
|
459
|
+
// Record audit
|
|
460
|
+
if (ctx.auditor) {
|
|
461
|
+
ctx.auditor.audit('user.created', {
|
|
462
|
+
userId: user.id,
|
|
463
|
+
email: user.email,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return { id: user.id, email: user.email };
|
|
468
|
+
},
|
|
469
|
+
input: undefined,
|
|
470
|
+
output: outputSchema,
|
|
471
|
+
services: [databaseService],
|
|
472
|
+
logger: mockLogger,
|
|
473
|
+
timeout: undefined,
|
|
474
|
+
memorySize: undefined,
|
|
475
|
+
status: 201,
|
|
476
|
+
getSession: undefined,
|
|
477
|
+
authorize: undefined,
|
|
478
|
+
description: undefined,
|
|
479
|
+
events: [],
|
|
480
|
+
publisherService: undefined,
|
|
481
|
+
auditorStorageService: auditStorageService,
|
|
482
|
+
audits: [],
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
const adaptor = new HonoEndpoint(endpoint);
|
|
486
|
+
const app = new Hono();
|
|
487
|
+
HonoEndpoint.applyEventMiddleware(app, serviceDiscovery);
|
|
488
|
+
adaptor.addRoute(serviceDiscovery, app);
|
|
489
|
+
|
|
490
|
+
const response = await app.request('/users', {
|
|
491
|
+
method: 'POST',
|
|
492
|
+
body: JSON.stringify({}),
|
|
493
|
+
headers: { 'Content-Type': 'application/json' },
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
expect(response.status).toBe(201);
|
|
497
|
+
|
|
498
|
+
// Verify user was created
|
|
499
|
+
const usersInDb = await db.selectFrom('users').selectAll().execute();
|
|
500
|
+
expect(usersInDb).toHaveLength(1);
|
|
501
|
+
expect(usersInDb[0].email).toBe('success@example.com');
|
|
502
|
+
|
|
503
|
+
// Verify audit was written
|
|
504
|
+
const auditsInDb = await db
|
|
505
|
+
.selectFrom('auditLogs')
|
|
506
|
+
.selectAll()
|
|
507
|
+
.execute();
|
|
508
|
+
expect(auditsInDb).toHaveLength(1);
|
|
509
|
+
expect(auditsInDb[0].type).toBe('user.created');
|
|
510
|
+
expect(auditsInDb[0].payload).toEqual({
|
|
511
|
+
userId: usersInDb[0].id,
|
|
512
|
+
email: 'success@example.com',
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
it('should handle combined declarative and manual audits', async () => {
|
|
517
|
+
const serviceDiscovery = createServiceDiscovery(mockLogger);
|
|
518
|
+
|
|
519
|
+
const auditStorageService: Service<
|
|
520
|
+
'auditStorage',
|
|
521
|
+
KyselyAuditStorage<TestDatabase>
|
|
522
|
+
> = {
|
|
523
|
+
serviceName: 'auditStorage' as const,
|
|
524
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
528
|
+
|
|
529
|
+
// Declarative audit
|
|
530
|
+
const audits: MappedAudit<TestAuditAction, typeof outputSchema>[] = [
|
|
531
|
+
{
|
|
532
|
+
type: 'user.created',
|
|
533
|
+
payload: (response) => ({
|
|
534
|
+
userId: response.id,
|
|
535
|
+
email: response.email,
|
|
536
|
+
}),
|
|
537
|
+
},
|
|
538
|
+
];
|
|
539
|
+
|
|
540
|
+
const endpoint = new Endpoint({
|
|
541
|
+
route: '/users',
|
|
542
|
+
method: 'POST',
|
|
543
|
+
fn: async (
|
|
544
|
+
ctx: EndpointContext<undefined, [], Logger, unknown, TestAuditAction>,
|
|
545
|
+
) => {
|
|
546
|
+
// Manual audit
|
|
547
|
+
if (ctx.auditor) {
|
|
548
|
+
ctx.auditor.audit('user.updated', {
|
|
549
|
+
userId: 100,
|
|
550
|
+
changes: ['verified'],
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return { id: 100, email: 'combined@example.com' };
|
|
555
|
+
},
|
|
556
|
+
input: undefined,
|
|
557
|
+
output: outputSchema,
|
|
558
|
+
services: [],
|
|
559
|
+
logger: mockLogger,
|
|
560
|
+
timeout: undefined,
|
|
561
|
+
memorySize: undefined,
|
|
562
|
+
status: 201,
|
|
563
|
+
getSession: undefined,
|
|
564
|
+
authorize: undefined,
|
|
565
|
+
description: undefined,
|
|
566
|
+
events: [],
|
|
567
|
+
publisherService: undefined,
|
|
568
|
+
auditorStorageService: auditStorageService,
|
|
569
|
+
audits,
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
const adaptor = new HonoEndpoint(endpoint);
|
|
573
|
+
const app = new Hono();
|
|
574
|
+
HonoEndpoint.applyEventMiddleware(app, serviceDiscovery);
|
|
575
|
+
adaptor.addRoute(serviceDiscovery, app);
|
|
576
|
+
|
|
577
|
+
const response = await app.request('/users', {
|
|
578
|
+
method: 'POST',
|
|
579
|
+
body: JSON.stringify({}),
|
|
580
|
+
headers: { 'Content-Type': 'application/json' },
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
expect(response.status).toBe(201);
|
|
584
|
+
|
|
585
|
+
// Verify both audits were written
|
|
586
|
+
const auditsInDb = await db
|
|
587
|
+
.selectFrom('auditLogs')
|
|
588
|
+
.selectAll()
|
|
589
|
+
.execute();
|
|
590
|
+
|
|
591
|
+
expect(auditsInDb).toHaveLength(2);
|
|
592
|
+
|
|
593
|
+
const auditTypes = auditsInDb.map((a) => a.type).sort();
|
|
594
|
+
expect(auditTypes).toEqual(['user.created', 'user.updated']);
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
describe('actor extraction with real database', () => {
|
|
599
|
+
it('should include actor information in audit records', async () => {
|
|
600
|
+
const serviceDiscovery = createServiceDiscovery(mockLogger);
|
|
601
|
+
|
|
602
|
+
const auditStorageService: Service<
|
|
603
|
+
'auditStorage',
|
|
604
|
+
KyselyAuditStorage<TestDatabase>
|
|
605
|
+
> = {
|
|
606
|
+
serviceName: 'auditStorage' as const,
|
|
607
|
+
register: vi.fn().mockResolvedValue(auditStorage),
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
const outputSchema = z.object({ id: z.number(), email: z.string() });
|
|
611
|
+
|
|
612
|
+
const audits: MappedAudit<TestAuditAction, typeof outputSchema>[] = [
|
|
613
|
+
{
|
|
614
|
+
type: 'user.created',
|
|
615
|
+
payload: (response) => ({
|
|
616
|
+
userId: response.id,
|
|
617
|
+
email: response.email,
|
|
618
|
+
}),
|
|
619
|
+
},
|
|
620
|
+
];
|
|
621
|
+
|
|
622
|
+
const endpoint = new Endpoint({
|
|
623
|
+
route: '/users',
|
|
624
|
+
method: 'POST',
|
|
625
|
+
fn: async () => {
|
|
626
|
+
return { id: 1, email: 'actor-test@example.com' };
|
|
627
|
+
},
|
|
628
|
+
input: undefined,
|
|
629
|
+
output: outputSchema,
|
|
630
|
+
services: [],
|
|
631
|
+
logger: mockLogger,
|
|
632
|
+
timeout: undefined,
|
|
633
|
+
memorySize: undefined,
|
|
634
|
+
status: 201,
|
|
635
|
+
getSession: undefined,
|
|
636
|
+
authorize: undefined,
|
|
637
|
+
description: undefined,
|
|
638
|
+
events: [],
|
|
639
|
+
publisherService: undefined,
|
|
640
|
+
auditorStorageService: auditStorageService,
|
|
641
|
+
audits,
|
|
642
|
+
actorExtractor: async ({ header }) => {
|
|
643
|
+
const userId = header('x-user-id');
|
|
644
|
+
return {
|
|
645
|
+
id: userId ?? 'anonymous',
|
|
646
|
+
type: userId ? 'user' : 'anonymous',
|
|
647
|
+
};
|
|
648
|
+
},
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
const adaptor = new HonoEndpoint(endpoint);
|
|
652
|
+
const app = new Hono();
|
|
653
|
+
HonoEndpoint.applyEventMiddleware(app, serviceDiscovery);
|
|
654
|
+
adaptor.addRoute(serviceDiscovery, app);
|
|
655
|
+
|
|
656
|
+
const response = await app.request('/users', {
|
|
657
|
+
method: 'POST',
|
|
658
|
+
body: JSON.stringify({}),
|
|
659
|
+
headers: {
|
|
660
|
+
'Content-Type': 'application/json',
|
|
661
|
+
'x-user-id': 'user-123',
|
|
662
|
+
},
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
expect(response.status).toBe(201);
|
|
666
|
+
|
|
667
|
+
// Verify actor was included in audit
|
|
668
|
+
const auditsInDb = await db
|
|
669
|
+
.selectFrom('auditLogs')
|
|
670
|
+
.selectAll()
|
|
671
|
+
.execute();
|
|
672
|
+
|
|
673
|
+
expect(auditsInDb).toHaveLength(1);
|
|
674
|
+
expect(auditsInDb[0].actorId).toBe('user-123');
|
|
675
|
+
expect(auditsInDb[0].actorType).toBe('user');
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
});
|
|
@@ -36,6 +36,7 @@ describe('HonoEndpoint OpenAPI Documentation', () => {
|
|
|
36
36
|
services: [],
|
|
37
37
|
logger,
|
|
38
38
|
timeout: undefined,
|
|
39
|
+
memorySize: undefined,
|
|
39
40
|
authorize: undefined,
|
|
40
41
|
getSession: undefined,
|
|
41
42
|
status: undefined,
|
|
@@ -140,6 +141,7 @@ describe('HonoEndpoint OpenAPI Documentation', () => {
|
|
|
140
141
|
services: [],
|
|
141
142
|
logger,
|
|
142
143
|
timeout: undefined,
|
|
144
|
+
memorySize: undefined,
|
|
143
145
|
authorize: undefined,
|
|
144
146
|
getSession: undefined,
|
|
145
147
|
status: undefined,
|
|
@@ -180,6 +182,7 @@ describe('HonoEndpoint OpenAPI Documentation', () => {
|
|
|
180
182
|
services: [],
|
|
181
183
|
logger,
|
|
182
184
|
timeout: undefined,
|
|
185
|
+
memorySize: undefined,
|
|
183
186
|
authorize: undefined,
|
|
184
187
|
getSession: undefined,
|
|
185
188
|
status: undefined,
|
|
@@ -218,6 +221,7 @@ describe('HonoEndpoint OpenAPI Documentation', () => {
|
|
|
218
221
|
services: [],
|
|
219
222
|
logger,
|
|
220
223
|
timeout: undefined,
|
|
224
|
+
memorySize: undefined,
|
|
221
225
|
authorize: undefined,
|
|
222
226
|
getSession: undefined,
|
|
223
227
|
status: undefined,
|