@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
|
@@ -31,6 +31,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
31
31
|
services: [],
|
|
32
32
|
logger: mockLogger,
|
|
33
33
|
timeout: undefined,
|
|
34
|
+
memorySize: undefined,
|
|
34
35
|
status: undefined,
|
|
35
36
|
getSession: undefined,
|
|
36
37
|
authorize: undefined,
|
|
@@ -68,6 +69,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
68
69
|
services: [],
|
|
69
70
|
logger: mockLogger,
|
|
70
71
|
timeout: undefined,
|
|
72
|
+
memorySize: undefined,
|
|
71
73
|
status: undefined,
|
|
72
74
|
getSession: undefined,
|
|
73
75
|
authorize: undefined,
|
|
@@ -118,6 +120,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
118
120
|
services: [],
|
|
119
121
|
logger: mockLogger,
|
|
120
122
|
timeout: undefined,
|
|
123
|
+
memorySize: undefined,
|
|
121
124
|
status: undefined,
|
|
122
125
|
getSession: undefined,
|
|
123
126
|
authorize: undefined,
|
|
@@ -157,6 +160,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
157
160
|
services: [],
|
|
158
161
|
logger: mockLogger,
|
|
159
162
|
timeout: undefined,
|
|
163
|
+
memorySize: undefined,
|
|
160
164
|
status: undefined,
|
|
161
165
|
getSession: undefined,
|
|
162
166
|
authorize: undefined,
|
|
@@ -195,6 +199,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
195
199
|
services: [],
|
|
196
200
|
logger: mockLogger,
|
|
197
201
|
timeout: undefined,
|
|
202
|
+
memorySize: undefined,
|
|
198
203
|
status: undefined,
|
|
199
204
|
getSession: undefined,
|
|
200
205
|
authorize: undefined,
|
|
@@ -233,6 +238,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
233
238
|
services: [],
|
|
234
239
|
logger: mockLogger,
|
|
235
240
|
timeout: undefined,
|
|
241
|
+
memorySize: undefined,
|
|
236
242
|
status: undefined,
|
|
237
243
|
getSession: undefined,
|
|
238
244
|
authorize: undefined,
|
|
@@ -266,6 +272,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
266
272
|
services: [],
|
|
267
273
|
logger: mockLogger,
|
|
268
274
|
timeout: undefined,
|
|
275
|
+
memorySize: undefined,
|
|
269
276
|
status: undefined,
|
|
270
277
|
getSession: undefined,
|
|
271
278
|
authorize: undefined,
|
|
@@ -305,6 +312,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
305
312
|
services: [],
|
|
306
313
|
logger: mockLogger,
|
|
307
314
|
timeout: undefined,
|
|
315
|
+
memorySize: undefined,
|
|
308
316
|
status: undefined,
|
|
309
317
|
getSession: undefined,
|
|
310
318
|
authorize: undefined,
|
|
@@ -345,6 +353,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
345
353
|
services: [],
|
|
346
354
|
logger: mockLogger,
|
|
347
355
|
timeout: undefined,
|
|
356
|
+
memorySize: undefined,
|
|
348
357
|
status: undefined,
|
|
349
358
|
getSession: undefined,
|
|
350
359
|
authorize: undefined,
|
|
@@ -397,6 +406,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
397
406
|
services: [],
|
|
398
407
|
logger: mockLogger,
|
|
399
408
|
timeout: undefined,
|
|
409
|
+
memorySize: undefined,
|
|
400
410
|
status: undefined,
|
|
401
411
|
getSession: undefined,
|
|
402
412
|
authorize: undefined,
|
|
@@ -434,6 +444,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
434
444
|
services: [],
|
|
435
445
|
logger: mockLogger,
|
|
436
446
|
timeout: undefined,
|
|
447
|
+
memorySize: undefined,
|
|
437
448
|
status: undefined,
|
|
438
449
|
getSession: undefined,
|
|
439
450
|
authorize: undefined,
|
|
@@ -482,6 +493,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
482
493
|
services: [TestService],
|
|
483
494
|
logger: mockLogger,
|
|
484
495
|
timeout: undefined,
|
|
496
|
+
memorySize: undefined,
|
|
485
497
|
status: undefined,
|
|
486
498
|
getSession: undefined,
|
|
487
499
|
authorize: undefined,
|
|
@@ -523,6 +535,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
523
535
|
services: [],
|
|
524
536
|
logger: customLogger as Logger,
|
|
525
537
|
timeout: undefined,
|
|
538
|
+
memorySize: undefined,
|
|
526
539
|
status: undefined,
|
|
527
540
|
getSession: undefined,
|
|
528
541
|
authorize: undefined,
|
|
@@ -579,6 +592,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
579
592
|
services: [],
|
|
580
593
|
logger: mockLogger,
|
|
581
594
|
timeout: undefined,
|
|
595
|
+
memorySize: undefined,
|
|
582
596
|
status: undefined,
|
|
583
597
|
getSession: undefined,
|
|
584
598
|
authorize: undefined,
|
|
@@ -636,6 +650,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
636
650
|
services: [],
|
|
637
651
|
logger: mockLogger,
|
|
638
652
|
timeout: undefined,
|
|
653
|
+
memorySize: undefined,
|
|
639
654
|
authorize: undefined,
|
|
640
655
|
status: 200,
|
|
641
656
|
getSession: undefined,
|
|
@@ -690,6 +705,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
690
705
|
services: [],
|
|
691
706
|
logger: mockLogger,
|
|
692
707
|
timeout: undefined,
|
|
708
|
+
memorySize: undefined,
|
|
693
709
|
authorize: undefined,
|
|
694
710
|
status: 200,
|
|
695
711
|
getSession: undefined,
|
|
@@ -765,6 +781,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
765
781
|
services: [],
|
|
766
782
|
logger: mockLogger,
|
|
767
783
|
timeout: undefined,
|
|
784
|
+
memorySize: undefined,
|
|
768
785
|
status: undefined,
|
|
769
786
|
getSession: undefined,
|
|
770
787
|
authorize: undefined,
|
|
@@ -794,6 +811,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
794
811
|
services: [],
|
|
795
812
|
logger: mockLogger,
|
|
796
813
|
timeout: undefined,
|
|
814
|
+
memorySize: undefined,
|
|
797
815
|
status: undefined,
|
|
798
816
|
getSession: undefined,
|
|
799
817
|
authorize: undefined,
|
|
@@ -826,6 +844,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
826
844
|
services: [],
|
|
827
845
|
logger: mockLogger,
|
|
828
846
|
timeout: undefined,
|
|
847
|
+
memorySize: undefined,
|
|
829
848
|
status: undefined,
|
|
830
849
|
getSession: undefined,
|
|
831
850
|
authorize: undefined,
|
|
@@ -883,6 +902,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
883
902
|
return services.authService.isValidToken(token);
|
|
884
903
|
},
|
|
885
904
|
timeout: undefined,
|
|
905
|
+
memorySize: undefined,
|
|
886
906
|
status: undefined,
|
|
887
907
|
getSession: undefined,
|
|
888
908
|
description: undefined,
|
|
@@ -917,6 +937,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
917
937
|
services: [],
|
|
918
938
|
logger: mockLogger,
|
|
919
939
|
timeout: undefined,
|
|
940
|
+
memorySize: undefined,
|
|
920
941
|
status: undefined,
|
|
921
942
|
getSession: async ({ header }) => {
|
|
922
943
|
const token = header('authorization');
|
|
@@ -958,6 +979,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
958
979
|
services: [],
|
|
959
980
|
logger: mockLogger,
|
|
960
981
|
timeout: undefined,
|
|
982
|
+
memorySize: undefined,
|
|
961
983
|
status: undefined,
|
|
962
984
|
getSession: undefined,
|
|
963
985
|
authorize: async () => {
|
|
@@ -993,6 +1015,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
993
1015
|
services: [],
|
|
994
1016
|
logger: mockLogger,
|
|
995
1017
|
timeout: undefined,
|
|
1018
|
+
memorySize: undefined,
|
|
996
1019
|
status: 200,
|
|
997
1020
|
getSession: undefined,
|
|
998
1021
|
authorize: undefined,
|
|
@@ -1030,6 +1053,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
1030
1053
|
services: [],
|
|
1031
1054
|
logger: mockLogger,
|
|
1032
1055
|
timeout: undefined,
|
|
1056
|
+
memorySize: undefined,
|
|
1033
1057
|
status: 200,
|
|
1034
1058
|
getSession: undefined,
|
|
1035
1059
|
authorize: undefined,
|
|
@@ -1059,6 +1083,7 @@ describe('HonoEndpointAdaptor', () => {
|
|
|
1059
1083
|
services: [],
|
|
1060
1084
|
logger: mockLogger,
|
|
1061
1085
|
timeout: undefined,
|
|
1086
|
+
memorySize: undefined,
|
|
1062
1087
|
status: 200,
|
|
1063
1088
|
getSession: undefined,
|
|
1064
1089
|
authorize: undefined,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AuditableAction,
|
|
3
|
+
AuditActor,
|
|
4
|
+
AuditStorage,
|
|
5
|
+
ExtractAuditPayload,
|
|
6
|
+
ExtractAuditType,
|
|
7
|
+
} from '@geekmidas/audit';
|
|
8
|
+
import type { Logger } from '@geekmidas/logger';
|
|
9
|
+
import type { InferStandardSchema } from '@geekmidas/schema';
|
|
10
|
+
import type { Service, ServiceRecord } from '@geekmidas/services';
|
|
11
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
12
|
+
import type { CookieFn, HeaderFn } from './Endpoint';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Defines how to map an endpoint response to an audit record.
|
|
16
|
+
* Similar to MappedEvent for events.
|
|
17
|
+
*
|
|
18
|
+
* @template TAuditAction - Union of all allowed audit action types
|
|
19
|
+
* @template TOutput - The output schema of the endpoint
|
|
20
|
+
*/
|
|
21
|
+
export interface MappedAudit<
|
|
22
|
+
TAuditAction extends AuditableAction<string, unknown>,
|
|
23
|
+
TOutput extends StandardSchemaV1 | undefined,
|
|
24
|
+
TType extends ExtractAuditType<TAuditAction> = ExtractAuditType<TAuditAction>,
|
|
25
|
+
> {
|
|
26
|
+
/** The audit type (must be a valid type from TAuditAction) */
|
|
27
|
+
type: TType;
|
|
28
|
+
/** Function to extract payload from the endpoint response */
|
|
29
|
+
payload: (
|
|
30
|
+
response: TOutput extends StandardSchemaV1
|
|
31
|
+
? InferStandardSchema<TOutput>
|
|
32
|
+
: unknown,
|
|
33
|
+
) => ExtractAuditPayload<TAuditAction, TType>;
|
|
34
|
+
/** Optional condition to determine if audit should be recorded */
|
|
35
|
+
when?: (
|
|
36
|
+
response: TOutput extends StandardSchemaV1
|
|
37
|
+
? InferStandardSchema<TOutput>
|
|
38
|
+
: unknown,
|
|
39
|
+
) => boolean;
|
|
40
|
+
/** Optional function to extract entity ID for easier querying */
|
|
41
|
+
entityId?: (
|
|
42
|
+
response: TOutput extends StandardSchemaV1
|
|
43
|
+
? InferStandardSchema<TOutput>
|
|
44
|
+
: unknown,
|
|
45
|
+
) => string | Record<string, unknown>;
|
|
46
|
+
/** Optional table name for the audit record */
|
|
47
|
+
table?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Function type for extracting actor information from request context.
|
|
52
|
+
*
|
|
53
|
+
* @template TServices - Available service dependencies
|
|
54
|
+
* @template TSession - Session data type
|
|
55
|
+
* @template TLogger - Logger type
|
|
56
|
+
*/
|
|
57
|
+
export type ActorExtractor<
|
|
58
|
+
TServices extends Service[] = [],
|
|
59
|
+
TSession = unknown,
|
|
60
|
+
TLogger extends Logger = Logger,
|
|
61
|
+
> = (ctx: {
|
|
62
|
+
services: ServiceRecord<TServices>;
|
|
63
|
+
session: TSession;
|
|
64
|
+
header: HeaderFn;
|
|
65
|
+
cookie: CookieFn;
|
|
66
|
+
logger: TLogger;
|
|
67
|
+
}) => AuditActor | Promise<AuditActor>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Configuration for the auditor on an endpoint.
|
|
71
|
+
*/
|
|
72
|
+
export interface EndpointAuditorConfig<
|
|
73
|
+
TAuditStorage extends AuditStorage,
|
|
74
|
+
TAuditStorageServiceName extends string,
|
|
75
|
+
TServices extends Service[],
|
|
76
|
+
TSession,
|
|
77
|
+
TLogger extends Logger,
|
|
78
|
+
TAuditAction extends AuditableAction<string, unknown>,
|
|
79
|
+
TOutput extends StandardSchemaV1 | undefined,
|
|
80
|
+
> {
|
|
81
|
+
/** The audit storage service */
|
|
82
|
+
storageService: Service<TAuditStorageServiceName, TAuditStorage>;
|
|
83
|
+
/** Optional actor extractor function */
|
|
84
|
+
actorExtractor?: ActorExtractor<TServices, TSession, TLogger>;
|
|
85
|
+
/** Declarative audit definitions */
|
|
86
|
+
audits: MappedAudit<TAuditAction, TOutput>[];
|
|
87
|
+
}
|
package/src/endpoints/index.ts
CHANGED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AuditableAction,
|
|
3
|
+
AuditActor,
|
|
4
|
+
Auditor,
|
|
5
|
+
AuditStorage,
|
|
6
|
+
} from '@geekmidas/audit';
|
|
7
|
+
import { DefaultAuditor } from '@geekmidas/audit';
|
|
8
|
+
import { withAuditableTransaction } from '@geekmidas/audit/kysely';
|
|
9
|
+
import type { Logger } from '@geekmidas/logger';
|
|
10
|
+
import type { InferStandardSchema } from '@geekmidas/schema';
|
|
11
|
+
import type { Service, ServiceDiscovery } from '@geekmidas/services';
|
|
12
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
13
|
+
import type { Endpoint, CookieFn, HeaderFn } from './Endpoint';
|
|
14
|
+
import type { ActorExtractor, MappedAudit } from './audit';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Process declarative audit definitions after successful endpoint execution.
|
|
18
|
+
* Similar to publishConstructEvents for events.
|
|
19
|
+
*
|
|
20
|
+
* @param endpoint - The endpoint with audit configuration
|
|
21
|
+
* @param response - The handler response to generate audit payloads from
|
|
22
|
+
* @param serviceDiscovery - Service discovery for registering audit storage
|
|
23
|
+
* @param logger - Logger for debug/error messages
|
|
24
|
+
* @param ctx - Request context (session, headers, cookies, services)
|
|
25
|
+
* @param existingAuditor - Optional existing auditor instance (e.g., from handler context).
|
|
26
|
+
* If provided, uses this auditor (with its stored transaction).
|
|
27
|
+
* If not provided, creates a new auditor.
|
|
28
|
+
*/
|
|
29
|
+
export async function processEndpointAudits<
|
|
30
|
+
TServices extends Service[] = [],
|
|
31
|
+
TSession = unknown,
|
|
32
|
+
TLogger extends Logger = Logger,
|
|
33
|
+
OutSchema extends StandardSchemaV1 | undefined = undefined,
|
|
34
|
+
TAuditStorage extends AuditStorage | undefined = undefined,
|
|
35
|
+
TAuditStorageServiceName extends string = string,
|
|
36
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
37
|
+
string,
|
|
38
|
+
unknown
|
|
39
|
+
>,
|
|
40
|
+
>(
|
|
41
|
+
endpoint: Endpoint<
|
|
42
|
+
any,
|
|
43
|
+
any,
|
|
44
|
+
any,
|
|
45
|
+
OutSchema,
|
|
46
|
+
TServices,
|
|
47
|
+
TLogger,
|
|
48
|
+
TSession,
|
|
49
|
+
any,
|
|
50
|
+
any,
|
|
51
|
+
TAuditStorage,
|
|
52
|
+
TAuditStorageServiceName,
|
|
53
|
+
TAuditAction
|
|
54
|
+
>,
|
|
55
|
+
response: InferStandardSchema<OutSchema>,
|
|
56
|
+
serviceDiscovery: ServiceDiscovery<any, any>,
|
|
57
|
+
logger: TLogger,
|
|
58
|
+
ctx: {
|
|
59
|
+
session: TSession;
|
|
60
|
+
header: HeaderFn;
|
|
61
|
+
cookie: CookieFn;
|
|
62
|
+
services: Record<string, unknown>;
|
|
63
|
+
},
|
|
64
|
+
existingAuditor?: Auditor<TAuditAction>,
|
|
65
|
+
): Promise<void> {
|
|
66
|
+
try {
|
|
67
|
+
const audits = endpoint.audits as MappedAudit<TAuditAction, OutSchema>[];
|
|
68
|
+
|
|
69
|
+
// If we have an existing auditor (from handler context), we need to flush
|
|
70
|
+
// any manual audits it collected, even if there are no declarative audits
|
|
71
|
+
const hasExistingRecords = existingAuditor && existingAuditor.getRecords().length > 0;
|
|
72
|
+
|
|
73
|
+
// Skip if no declarative audits and no existing records to flush
|
|
74
|
+
if (!audits?.length && !hasExistingRecords) {
|
|
75
|
+
logger.debug('No audits to process');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// If no auditor storage service and we have things to process, warn
|
|
80
|
+
if (!endpoint.auditorStorageService) {
|
|
81
|
+
if (hasExistingRecords || audits?.length) {
|
|
82
|
+
logger.warn('No auditor storage service available');
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Get or create auditor
|
|
88
|
+
let auditor: Auditor<TAuditAction>;
|
|
89
|
+
|
|
90
|
+
if (existingAuditor) {
|
|
91
|
+
// Use existing auditor (preserves stored transaction and manual audits)
|
|
92
|
+
auditor = existingAuditor;
|
|
93
|
+
logger.debug('Using existing auditor from handler context');
|
|
94
|
+
} else {
|
|
95
|
+
// Create new auditor (backward compatibility)
|
|
96
|
+
const services = await serviceDiscovery.register([
|
|
97
|
+
endpoint.auditorStorageService,
|
|
98
|
+
]);
|
|
99
|
+
const storage = services[
|
|
100
|
+
endpoint.auditorStorageService.serviceName
|
|
101
|
+
] as AuditStorage;
|
|
102
|
+
|
|
103
|
+
// Extract actor if configured
|
|
104
|
+
let actor: AuditActor = { id: 'system', type: 'system' };
|
|
105
|
+
if (endpoint.actorExtractor) {
|
|
106
|
+
try {
|
|
107
|
+
actor = await (
|
|
108
|
+
endpoint.actorExtractor as ActorExtractor<TServices, TSession, TLogger>
|
|
109
|
+
)({
|
|
110
|
+
services: ctx.services as any,
|
|
111
|
+
session: ctx.session,
|
|
112
|
+
header: ctx.header,
|
|
113
|
+
cookie: ctx.cookie,
|
|
114
|
+
logger,
|
|
115
|
+
});
|
|
116
|
+
} catch (error) {
|
|
117
|
+
logger.error(error as Error, 'Failed to extract actor for audits');
|
|
118
|
+
// Continue with system actor
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
auditor = new DefaultAuditor<TAuditAction>({
|
|
123
|
+
actor,
|
|
124
|
+
storage,
|
|
125
|
+
metadata: {
|
|
126
|
+
endpoint: endpoint.route,
|
|
127
|
+
method: endpoint.method,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Process each declarative audit
|
|
133
|
+
if (audits?.length) {
|
|
134
|
+
for (const audit of audits) {
|
|
135
|
+
logger.debug({ audit: audit.type }, 'Processing declarative audit');
|
|
136
|
+
|
|
137
|
+
// Check when condition
|
|
138
|
+
if (audit.when && !audit.when(response as any)) {
|
|
139
|
+
logger.debug({ audit: audit.type }, 'Audit skipped due to when condition');
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Extract payload
|
|
144
|
+
const payload = audit.payload(response as any);
|
|
145
|
+
|
|
146
|
+
// Extract entityId if configured
|
|
147
|
+
const entityId = audit.entityId?.(response as any);
|
|
148
|
+
|
|
149
|
+
// Record the audit
|
|
150
|
+
auditor.audit(audit.type as any, payload as any, {
|
|
151
|
+
table: audit.table,
|
|
152
|
+
entityId,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Flush audits to storage
|
|
158
|
+
// Note: If existingAuditor has a stored transaction (via setTransaction),
|
|
159
|
+
// flush() will use it automatically
|
|
160
|
+
const recordCount = auditor.getRecords().length;
|
|
161
|
+
if (recordCount > 0) {
|
|
162
|
+
// Check if auditor has a stored transaction (for logging purposes)
|
|
163
|
+
const trx = 'getTransaction' in auditor
|
|
164
|
+
? (auditor as { getTransaction(): unknown }).getTransaction()
|
|
165
|
+
: undefined;
|
|
166
|
+
logger.debug(
|
|
167
|
+
{ auditCount: recordCount, hasTransaction: !!trx },
|
|
168
|
+
'Flushing audits',
|
|
169
|
+
);
|
|
170
|
+
await auditor.flush();
|
|
171
|
+
}
|
|
172
|
+
} catch (error) {
|
|
173
|
+
logger.error(error as Error, 'Failed to process audits');
|
|
174
|
+
// Don't rethrow - audit failures shouldn't fail the request
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Context for audit-aware handler execution.
|
|
180
|
+
*/
|
|
181
|
+
export interface AuditExecutionContext<
|
|
182
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
183
|
+
string,
|
|
184
|
+
unknown
|
|
185
|
+
>,
|
|
186
|
+
> {
|
|
187
|
+
/** The auditor instance for recording audits */
|
|
188
|
+
auditor: Auditor<TAuditAction>;
|
|
189
|
+
/** The audit storage instance */
|
|
190
|
+
storage: AuditStorage;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Create audit context for handler execution.
|
|
195
|
+
* Returns the auditor and storage for use in the handler.
|
|
196
|
+
*
|
|
197
|
+
* @param endpoint - The endpoint with audit configuration
|
|
198
|
+
* @param serviceDiscovery - Service discovery for getting audit storage
|
|
199
|
+
* @param logger - Logger for debug/error messages
|
|
200
|
+
* @param ctx - Request context for actor extraction
|
|
201
|
+
* @returns Audit context with auditor and storage, or undefined if not configured
|
|
202
|
+
*/
|
|
203
|
+
export async function createAuditContext<
|
|
204
|
+
TServices extends Service[] = [],
|
|
205
|
+
TSession = unknown,
|
|
206
|
+
TLogger extends Logger = Logger,
|
|
207
|
+
TAuditStorage extends AuditStorage | undefined = undefined,
|
|
208
|
+
TAuditStorageServiceName extends string = string,
|
|
209
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
210
|
+
string,
|
|
211
|
+
unknown
|
|
212
|
+
>,
|
|
213
|
+
>(
|
|
214
|
+
endpoint: Endpoint<
|
|
215
|
+
any,
|
|
216
|
+
any,
|
|
217
|
+
any,
|
|
218
|
+
any,
|
|
219
|
+
TServices,
|
|
220
|
+
TLogger,
|
|
221
|
+
TSession,
|
|
222
|
+
any,
|
|
223
|
+
any,
|
|
224
|
+
TAuditStorage,
|
|
225
|
+
TAuditStorageServiceName,
|
|
226
|
+
TAuditAction
|
|
227
|
+
>,
|
|
228
|
+
serviceDiscovery: ServiceDiscovery<any, any>,
|
|
229
|
+
logger: TLogger,
|
|
230
|
+
ctx: {
|
|
231
|
+
session: TSession;
|
|
232
|
+
header: HeaderFn;
|
|
233
|
+
cookie: CookieFn;
|
|
234
|
+
services: Record<string, unknown>;
|
|
235
|
+
},
|
|
236
|
+
): Promise<AuditExecutionContext<TAuditAction> | undefined> {
|
|
237
|
+
if (!endpoint.auditorStorageService) {
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const services = await serviceDiscovery.register([
|
|
242
|
+
endpoint.auditorStorageService,
|
|
243
|
+
]);
|
|
244
|
+
const storage = services[
|
|
245
|
+
endpoint.auditorStorageService.serviceName
|
|
246
|
+
] as AuditStorage;
|
|
247
|
+
|
|
248
|
+
// Extract actor if configured
|
|
249
|
+
let actor: AuditActor = { id: 'system', type: 'system' };
|
|
250
|
+
if (endpoint.actorExtractor) {
|
|
251
|
+
try {
|
|
252
|
+
actor = await (
|
|
253
|
+
endpoint.actorExtractor as ActorExtractor<TServices, TSession, TLogger>
|
|
254
|
+
)({
|
|
255
|
+
services: ctx.services as any,
|
|
256
|
+
session: ctx.session,
|
|
257
|
+
header: ctx.header,
|
|
258
|
+
cookie: ctx.cookie,
|
|
259
|
+
logger,
|
|
260
|
+
});
|
|
261
|
+
} catch (error) {
|
|
262
|
+
logger.error(error as Error, 'Failed to extract actor for audits');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const auditor = new DefaultAuditor<TAuditAction>({
|
|
267
|
+
actor,
|
|
268
|
+
storage,
|
|
269
|
+
metadata: {
|
|
270
|
+
endpoint: endpoint.route,
|
|
271
|
+
method: endpoint.method,
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return { auditor, storage };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Execute a handler with automatic audit transaction support.
|
|
280
|
+
* If the audit storage has a database (via getDatabase()), wraps execution
|
|
281
|
+
* in a transaction so audits are atomic with handler's database operations.
|
|
282
|
+
*
|
|
283
|
+
* @param auditContext - The audit context from createAuditContext
|
|
284
|
+
* @param handler - The handler function to execute (receives auditor)
|
|
285
|
+
* @param onComplete - Called after handler with response, to process declarative audits
|
|
286
|
+
* @returns The handler result
|
|
287
|
+
*/
|
|
288
|
+
export async function executeWithAuditTransaction<
|
|
289
|
+
T,
|
|
290
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
291
|
+
string,
|
|
292
|
+
unknown
|
|
293
|
+
>,
|
|
294
|
+
>(
|
|
295
|
+
auditContext: AuditExecutionContext<TAuditAction> | undefined,
|
|
296
|
+
handler: (auditor?: Auditor<TAuditAction>) => Promise<T>,
|
|
297
|
+
onComplete?: (response: T, auditor: Auditor<TAuditAction>) => Promise<void>,
|
|
298
|
+
): Promise<T> {
|
|
299
|
+
// No audit context - just run handler
|
|
300
|
+
if (!auditContext) {
|
|
301
|
+
return handler(undefined);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const { auditor, storage } = auditContext;
|
|
305
|
+
|
|
306
|
+
// Check if storage has a database for transactional execution
|
|
307
|
+
const db = storage.getDatabase?.();
|
|
308
|
+
|
|
309
|
+
if (db) {
|
|
310
|
+
// Wrap in transaction - audits are atomic with handler operations
|
|
311
|
+
return withAuditableTransaction(
|
|
312
|
+
db as any,
|
|
313
|
+
auditor as any,
|
|
314
|
+
async () => {
|
|
315
|
+
const response = await handler(auditor);
|
|
316
|
+
|
|
317
|
+
// Process declarative audits within the transaction
|
|
318
|
+
if (onComplete) {
|
|
319
|
+
await onComplete(response, auditor);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Audits are flushed by withAuditableTransaction before commit
|
|
323
|
+
return response;
|
|
324
|
+
},
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// No database - run handler and flush audits after
|
|
329
|
+
const response = await handler(auditor);
|
|
330
|
+
|
|
331
|
+
if (onComplete) {
|
|
332
|
+
await onComplete(response, auditor);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Flush audits (no transaction)
|
|
336
|
+
await auditor.flush();
|
|
337
|
+
|
|
338
|
+
return response;
|
|
339
|
+
}
|