@geekmidas/constructs 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +448 -0
- package/dist/AWSLambdaFunction-B-Oxr8qt.d.cts +30 -0
- package/dist/{AWSLambdaFunction-DMxScuaw.cjs → AWSLambdaFunction-C-fuCLA3.cjs} +28 -5
- package/dist/AWSLambdaFunction-C-fuCLA3.cjs.map +1 -0
- package/dist/AWSLambdaFunction-CAm9r5ZX.d.mts +30 -0
- package/dist/{AWSLambdaFunction-cL8A169J.mjs → AWSLambdaFunction-H65WfXLt.mjs} +28 -5
- package/dist/AWSLambdaFunction-H65WfXLt.mjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-eDQgPNLH.d.mts → AmazonApiGatewayEndpointAdaptor-4hPy5vty.d.mts} +4 -4
- package/dist/{AmazonApiGatewayEndpointAdaptor-CIEhW1TQ.mjs → AmazonApiGatewayEndpointAdaptor-C6Jk5HSy.mjs} +6 -2
- package/dist/AmazonApiGatewayEndpointAdaptor-C6Jk5HSy.mjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-H8YvtfQm.cjs → AmazonApiGatewayEndpointAdaptor-CI9L7Ucn.cjs} +6 -2
- package/dist/AmazonApiGatewayEndpointAdaptor-CI9L7Ucn.cjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-CwItKPz2.d.cts → AmazonApiGatewayEndpointAdaptor-ro0RMLzr.d.cts} +4 -4
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-B36zXLJ7.mjs → AmazonApiGatewayV1EndpointAdaptor-BMy8DdNJ.mjs} +2 -2
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-B36zXLJ7.mjs.map → AmazonApiGatewayV1EndpointAdaptor-BMy8DdNJ.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-DaCvUL6y.d.cts → AmazonApiGatewayV1EndpointAdaptor-BWJWKqQT.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-0n71d3gq.cjs → AmazonApiGatewayV1EndpointAdaptor-DYL1bCBS.cjs} +2 -2
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-0n71d3gq.cjs.map → AmazonApiGatewayV1EndpointAdaptor-DYL1bCBS.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-CnGVpA38.d.mts → AmazonApiGatewayV1EndpointAdaptor-hyR-WwyP.d.mts} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-CE3wZEb8.mjs → AmazonApiGatewayV2EndpointAdaptor-BU5wQMOe.mjs} +2 -2
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-CE3wZEb8.mjs.map → AmazonApiGatewayV2EndpointAdaptor-BU5wQMOe.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DtU3Cb8F.cjs → AmazonApiGatewayV2EndpointAdaptor-CPLCMeaN.cjs} +2 -2
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DtU3Cb8F.cjs.map → AmazonApiGatewayV2EndpointAdaptor-CPLCMeaN.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DA1PH0nc.d.cts → AmazonApiGatewayV2EndpointAdaptor-D1Irdggp.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-BELz2ijs.d.mts → AmazonApiGatewayV2EndpointAdaptor-DX3SuI5S.d.mts} +3 -3
- package/dist/{Authorizer-BRCVPz_O.d.mts → Authorizer-BTmly8ps.d.cts} +1 -1
- package/dist/{Authorizer-DG54w1m2.d.cts → Authorizer-pmPvIVgv.d.mts} +1 -1
- package/dist/{BaseFunctionBuilder-CT7p10K1.mjs → BaseFunctionBuilder-B5gkW0Kt.mjs} +10 -1
- package/dist/BaseFunctionBuilder-B5gkW0Kt.mjs.map +1 -0
- package/dist/{BaseFunctionBuilder-B8rT07QR.cjs → BaseFunctionBuilder-C5Se7pdL.cjs} +10 -1
- package/dist/BaseFunctionBuilder-C5Se7pdL.cjs.map +1 -0
- package/dist/{BaseFunctionBuilder-DilipY1y.d.mts → BaseFunctionBuilder-CbDnPZpD.d.mts} +10 -4
- package/dist/{BaseFunctionBuilder-Cf0op65o.d.cts → BaseFunctionBuilder-DUZMbEr3.d.cts} +10 -4
- package/dist/{Cron-Bnd-2pgE.cjs → Cron-Bi3QOge_.cjs} +4 -4
- package/dist/Cron-Bi3QOge_.cjs.map +1 -0
- package/dist/{Cron-6lOgKqSA.d.cts → Cron-COdfP0Jd.d.cts} +4 -4
- package/dist/{Cron-BH_07atD.d.mts → Cron-D8cn_ahj.d.mts} +4 -4
- package/dist/{Cron-DNRjf2cp.mjs → Cron-Dy_HW2Vv.mjs} +4 -4
- package/dist/Cron-Dy_HW2Vv.mjs.map +1 -0
- package/dist/{CronBuilder-DdR2TuQa.mjs → CronBuilder-Bl3A2Zp4.mjs} +13 -4
- package/dist/CronBuilder-Bl3A2Zp4.mjs.map +1 -0
- package/dist/{CronBuilder-5oK2AL2n.d.cts → CronBuilder-DntF6H3A.d.cts} +17 -12
- package/dist/{CronBuilder-D2b4zY4l.d.mts → CronBuilder-DoMnSs_0.d.mts} +17 -12
- package/dist/{CronBuilder-dtw4ZyH6.cjs → CronBuilder-Dv_w7Yri.cjs} +13 -4
- package/dist/CronBuilder-Dv_w7Yri.cjs.map +1 -0
- package/dist/{Endpoint-DuZlyjd4.d.mts → Endpoint-Bbs_sFvg.d.mts} +49 -20
- package/dist/{Endpoint-Cs-MsYlY.d.cts → Endpoint-Bu8Phz6y.d.cts} +49 -20
- package/dist/{Endpoint-B9PryZES.cjs → Endpoint-DDpF7NO1.cjs} +11 -6
- package/dist/Endpoint-DDpF7NO1.cjs.map +1 -0
- package/dist/{Endpoint-B69TqESg.mjs → Endpoint-S6Yh2_PN.mjs} +11 -6
- package/dist/Endpoint-S6Yh2_PN.mjs.map +1 -0
- package/dist/{EndpointBuilder-C-PHInEW.d.cts → EndpointBuilder-CPxmF_w7.d.cts} +30 -13
- package/dist/{EndpointBuilder-BrB-K1jO.d.mts → EndpointBuilder-Csfyfjd7.d.mts} +30 -13
- package/dist/{EndpointBuilder-DofwCnWJ.cjs → EndpointBuilder-DpGmObMb.cjs} +25 -4
- package/dist/EndpointBuilder-DpGmObMb.cjs.map +1 -0
- package/dist/{EndpointBuilder-DnVL-EU_.mjs → EndpointBuilder-aE2E6WTx.mjs} +25 -4
- package/dist/EndpointBuilder-aE2E6WTx.mjs.map +1 -0
- package/dist/{EndpointFactory-6zNpVSYp.d.mts → EndpointFactory-BU_R-9LH.d.mts} +10 -10
- package/dist/{EndpointFactory-Ba9mx9MU.cjs → EndpointFactory-BfH6mjJ3.cjs} +2 -2
- package/dist/EndpointFactory-BfH6mjJ3.cjs.map +1 -0
- package/dist/{EndpointFactory-e5WYVR6t.d.cts → EndpointFactory-D0Ql2Ofm.d.cts} +11 -11
- package/dist/{EndpointFactory-pPaIGFHV.mjs → EndpointFactory-D4leYk1N.mjs} +2 -2
- package/dist/EndpointFactory-D4leYk1N.mjs.map +1 -0
- package/dist/{Function-CO-s2pB8.cjs → Function-DagDbeXo.cjs} +3 -2
- package/dist/Function-DagDbeXo.cjs.map +1 -0
- package/dist/{Function-COnc-tWM.mjs → Function-DfKsM5Kx.mjs} +3 -2
- package/dist/Function-DfKsM5Kx.mjs.map +1 -0
- package/dist/{Function-G3JPHMaY.d.mts → Function-V9M9UVHp.d.mts} +24 -7
- package/dist/{Function-6EWabl_X.d.cts → Function-VI1TB3Mh.d.cts} +24 -7
- package/dist/{FunctionBuilder-CMhLQ4dt.mjs → FunctionBuilder-CVT7bG2o.mjs} +20 -4
- package/dist/FunctionBuilder-CVT7bG2o.mjs.map +1 -0
- package/dist/{FunctionBuilder-B3fpp3hA.d.cts → FunctionBuilder-CjVEFTYC.d.cts} +22 -12
- package/dist/{FunctionBuilder-ByaB_LQ4.d.mts → FunctionBuilder-D1ofSeMd.d.mts} +22 -12
- package/dist/{FunctionBuilder-_hMwZUof.cjs → FunctionBuilder-DXvG_XD-.cjs} +20 -4
- package/dist/FunctionBuilder-DXvG_XD-.cjs.map +1 -0
- package/dist/FunctionExecutionWrapper-Bubnr0zA.mjs +101 -0
- package/dist/FunctionExecutionWrapper-Bubnr0zA.mjs.map +1 -0
- package/dist/FunctionExecutionWrapper-CwtwYozd.d.cts +48 -0
- package/dist/FunctionExecutionWrapper-DkNycmOh.cjs +107 -0
- package/dist/FunctionExecutionWrapper-DkNycmOh.cjs.map +1 -0
- package/dist/FunctionExecutionWrapper-rhbIYT0Q.d.mts +48 -0
- package/dist/{HonoEndpointAdaptor-Cw2if5cG.cjs → HonoEndpointAdaptor-CfLRHHFw.cjs} +8 -4
- package/dist/HonoEndpointAdaptor-CfLRHHFw.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-BElil8O5.d.mts → HonoEndpointAdaptor-DANYfDu9.d.mts} +7 -7
- package/dist/{HonoEndpointAdaptor-DAfnTFVS.mjs → HonoEndpointAdaptor-DuyE06nH.mjs} +8 -4
- package/dist/HonoEndpointAdaptor-DuyE06nH.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-DSHl8ZCY.d.cts → HonoEndpointAdaptor-_uLz8Bak.d.cts} +7 -7
- package/dist/{Subscriber-D-FPWts6.cjs → Subscriber-Bdh8rMSL.cjs} +1 -1
- package/dist/{Subscriber-D-FPWts6.cjs.map → Subscriber-Bdh8rMSL.cjs.map} +1 -1
- package/dist/{Subscriber-CGb8LjZa.mjs → Subscriber-CJOWwaw1.mjs} +1 -1
- package/dist/{Subscriber-CGb8LjZa.mjs.map → Subscriber-CJOWwaw1.mjs.map} +1 -1
- package/dist/{SubscriberBuilder-BcAspHv9.mjs → SubscriberBuilder-BWQmiYd8.mjs} +2 -2
- package/dist/{SubscriberBuilder-BcAspHv9.mjs.map → SubscriberBuilder-BWQmiYd8.mjs.map} +1 -1
- package/dist/{SubscriberBuilder-BfE2cL1q.cjs → SubscriberBuilder-DieD_60p.cjs} +2 -2
- package/dist/{SubscriberBuilder-BfE2cL1q.cjs.map → SubscriberBuilder-DieD_60p.cjs.map} +1 -1
- package/dist/{TestEndpointAdaptor-DubQOJk_.mjs → TestEndpointAdaptor-BEyZa0Yg.mjs} +7 -3
- package/dist/TestEndpointAdaptor-BEyZa0Yg.mjs.map +1 -0
- package/dist/{TestEndpointAdaptor-Bn1WRFph.cjs → TestEndpointAdaptor-C8425RJ0.cjs} +7 -3
- package/dist/TestEndpointAdaptor-C8425RJ0.cjs.map +1 -0
- package/dist/{TestEndpointAdaptor-o-xtSyQ3.d.cts → TestEndpointAdaptor-H5To8PH7.d.cts} +2 -2
- package/dist/{TestEndpointAdaptor-DnlAA_rm.d.mts → TestEndpointAdaptor-jxn68ayg.d.mts} +2 -2
- package/dist/adaptors/aws.cjs +10 -10
- package/dist/adaptors/aws.d.cts +11 -11
- package/dist/adaptors/aws.d.mts +11 -11
- package/dist/adaptors/aws.mjs +10 -10
- package/dist/adaptors/hono.cjs +7 -7
- package/dist/adaptors/hono.d.cts +7 -7
- package/dist/adaptors/hono.d.mts +7 -7
- package/dist/adaptors/hono.mjs +7 -7
- package/dist/adaptors/testing.cjs +6 -6
- package/dist/adaptors/testing.d.cts +7 -7
- package/dist/adaptors/testing.d.mts +7 -7
- package/dist/adaptors/testing.mjs +6 -6
- package/dist/crons/Cron.cjs +5 -5
- package/dist/crons/Cron.d.cts +5 -5
- package/dist/crons/Cron.d.mts +5 -5
- package/dist/crons/Cron.mjs +5 -5
- package/dist/crons/CronBuilder.cjs +6 -6
- package/dist/crons/CronBuilder.d.cts +6 -6
- package/dist/crons/CronBuilder.d.mts +6 -6
- package/dist/crons/CronBuilder.mjs +6 -6
- package/dist/crons/index.cjs +6 -6
- package/dist/crons/index.d.cts +10 -10
- package/dist/crons/index.d.mts +10 -10
- package/dist/crons/index.mjs +6 -6
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +6 -6
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +7 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +7 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +6 -6
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +7 -7
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +8 -8
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +8 -8
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +7 -7
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +7 -7
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +8 -8
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +8 -8
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +7 -7
- package/dist/endpoints/Authorizer.d.cts +1 -1
- package/dist/endpoints/Authorizer.d.mts +1 -1
- package/dist/endpoints/Endpoint.cjs +5 -5
- package/dist/endpoints/Endpoint.d.cts +6 -6
- package/dist/endpoints/Endpoint.d.mts +6 -6
- package/dist/endpoints/Endpoint.mjs +5 -5
- package/dist/endpoints/EndpointBuilder.cjs +6 -6
- package/dist/endpoints/EndpointBuilder.d.cts +7 -7
- package/dist/endpoints/EndpointBuilder.d.mts +7 -7
- package/dist/endpoints/EndpointBuilder.mjs +6 -6
- package/dist/endpoints/EndpointFactory.cjs +7 -7
- package/dist/endpoints/EndpointFactory.d.cts +8 -8
- package/dist/endpoints/EndpointFactory.d.mts +8 -8
- package/dist/endpoints/EndpointFactory.mjs +7 -7
- package/dist/endpoints/HonoEndpointAdaptor.cjs +7 -7
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +7 -7
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +7 -7
- package/dist/endpoints/HonoEndpointAdaptor.mjs +7 -7
- package/dist/endpoints/TestEndpointAdaptor.cjs +6 -6
- package/dist/endpoints/TestEndpointAdaptor.d.cts +7 -7
- package/dist/endpoints/TestEndpointAdaptor.d.mts +7 -7
- package/dist/endpoints/TestEndpointAdaptor.mjs +6 -6
- package/dist/endpoints/audit.d.cts +6 -6
- package/dist/endpoints/audit.d.mts +6 -6
- package/dist/endpoints/helpers.cjs +6 -6
- package/dist/endpoints/helpers.d.cts +6 -6
- package/dist/endpoints/helpers.d.mts +6 -6
- package/dist/endpoints/helpers.mjs +6 -6
- package/dist/endpoints/index.cjs +7 -7
- package/dist/endpoints/index.d.cts +10 -10
- package/dist/endpoints/index.d.mts +10 -10
- package/dist/endpoints/index.mjs +7 -7
- package/dist/endpoints/processAudits.d.cts +7 -7
- package/dist/endpoints/processAudits.d.mts +7 -7
- package/dist/functions/AWSLambdaFunction.cjs +5 -5
- package/dist/functions/AWSLambdaFunction.d.cts +3 -3
- package/dist/functions/AWSLambdaFunction.d.mts +3 -3
- package/dist/functions/AWSLambdaFunction.mjs +5 -5
- package/dist/functions/BaseFunctionBuilder.cjs +1 -1
- package/dist/functions/BaseFunctionBuilder.d.cts +1 -1
- package/dist/functions/BaseFunctionBuilder.d.mts +1 -1
- package/dist/functions/BaseFunctionBuilder.mjs +1 -1
- package/dist/functions/Function.cjs +1 -1
- package/dist/functions/Function.d.cts +1 -1
- package/dist/functions/Function.d.mts +1 -1
- package/dist/functions/Function.mjs +1 -1
- package/dist/functions/FunctionBuilder.cjs +3 -3
- package/dist/functions/FunctionBuilder.d.cts +3 -3
- package/dist/functions/FunctionBuilder.d.mts +3 -3
- package/dist/functions/FunctionBuilder.mjs +3 -3
- package/dist/functions/FunctionExecutionWrapper.cjs +4 -4
- package/dist/functions/FunctionExecutionWrapper.d.cts +2 -2
- package/dist/functions/FunctionExecutionWrapper.d.mts +2 -2
- package/dist/functions/FunctionExecutionWrapper.mjs +4 -4
- package/dist/functions/TestFunctionAdaptor.cjs +37 -4
- package/dist/functions/TestFunctionAdaptor.cjs.map +1 -1
- package/dist/functions/TestFunctionAdaptor.d.cts +9 -6
- package/dist/functions/TestFunctionAdaptor.d.mts +9 -6
- package/dist/functions/TestFunctionAdaptor.mjs +37 -4
- package/dist/functions/TestFunctionAdaptor.mjs.map +1 -1
- package/dist/functions/index.cjs +4 -4
- package/dist/functions/index.d.cts +4 -4
- package/dist/functions/index.d.mts +4 -4
- package/dist/functions/index.mjs +4 -4
- package/dist/{functions-D03lqK-r.cjs → functions-FCb-wWFC.cjs} +2 -2
- package/dist/{functions-D03lqK-r.cjs.map → functions-FCb-wWFC.cjs.map} +1 -1
- package/dist/functions-JhRsNoAZ.mjs +8 -0
- package/dist/{functions-BYqZAob8.mjs.map → functions-JhRsNoAZ.mjs.map} +1 -1
- package/dist/{helpers-BPDogwac.mjs → helpers-2CLKTnRm.mjs} +2 -2
- package/dist/{helpers-BPDogwac.mjs.map → helpers-2CLKTnRm.mjs.map} +1 -1
- package/dist/{helpers-BApRyhly.cjs → helpers-Khuhi_Qx.cjs} +2 -2
- package/dist/{helpers-BApRyhly.cjs.map → helpers-Khuhi_Qx.cjs.map} +1 -1
- package/dist/{index-CUg_hSq-.d.cts → index-DRf5AP3P.d.mts} +4 -3
- package/dist/index-twsdbZWU.d.cts +10 -0
- package/dist/processAudits-BFokHhCO.cjs.map +1 -1
- package/dist/processAudits-DfcB-X-4.mjs.map +1 -1
- package/dist/publisher-Bw4770Hi.mjs.map +1 -1
- package/dist/publisher-lFQleddL.cjs.map +1 -1
- package/dist/publisher.d.cts +2 -1
- package/dist/publisher.d.mts +2 -1
- package/dist/subscribers/Subscriber.cjs +1 -1
- package/dist/subscribers/Subscriber.mjs +1 -1
- package/dist/subscribers/SubscriberBuilder.cjs +2 -2
- package/dist/subscribers/SubscriberBuilder.mjs +2 -2
- package/dist/subscribers/index.cjs +2 -2
- package/dist/subscribers/index.d.cts +2 -2
- package/dist/subscribers/index.d.mts +2 -2
- package/dist/subscribers/index.mjs +2 -2
- package/package.json +7 -7
- package/src/crons/Cron.ts +12 -3
- package/src/crons/CronBuilder.ts +85 -13
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +2 -2
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +29 -6
- package/src/endpoints/Endpoint.ts +156 -40
- package/src/endpoints/EndpointBuilder.ts +123 -17
- package/src/endpoints/EndpointFactory.ts +5 -1
- package/src/endpoints/HonoEndpointAdaptor.ts +35 -5
- package/src/endpoints/TestEndpointAdaptor.ts +22 -2
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +1 -1
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +2 -2
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +9 -9
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +79 -40
- package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +3 -1
- package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +1 -1
- package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +35 -11
- package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +51 -14
- package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +8 -8
- package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +11 -11
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +44 -26
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +10 -10
- package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +8 -8
- package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +446 -61
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +4 -4
- package/src/endpoints/audit.ts +1 -1
- package/src/endpoints/processAudits.ts +32 -23
- package/src/functions/AWSLambdaFunction.ts +125 -12
- package/src/functions/BaseFunctionBuilder.ts +51 -3
- package/src/functions/Function.ts +73 -9
- package/src/functions/FunctionBuilder.ts +153 -17
- package/src/functions/FunctionExecutionWrapper.ts +133 -2
- package/src/functions/TestFunctionAdaptor.ts +94 -8
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +82 -0
- package/src/functions/__tests__/Function.audits.spec.ts +393 -0
- package/src/functions/__tests__/Function.spec.ts +76 -0
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +11 -5
- package/src/publisher.ts +12 -1
- package/dist/AWSLambdaFunction-DMxScuaw.cjs.map +0 -1
- package/dist/AWSLambdaFunction-DSB2oaFG.d.mts +0 -27
- package/dist/AWSLambdaFunction-cL8A169J.mjs.map +0 -1
- package/dist/AWSLambdaFunction-t6q2o8EL.d.cts +0 -27
- package/dist/AmazonApiGatewayEndpointAdaptor-CIEhW1TQ.mjs.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-H8YvtfQm.cjs.map +0 -1
- package/dist/BaseFunctionBuilder-B8rT07QR.cjs.map +0 -1
- package/dist/BaseFunctionBuilder-CT7p10K1.mjs.map +0 -1
- package/dist/Cron-Bnd-2pgE.cjs.map +0 -1
- package/dist/Cron-DNRjf2cp.mjs.map +0 -1
- package/dist/CronBuilder-DdR2TuQa.mjs.map +0 -1
- package/dist/CronBuilder-dtw4ZyH6.cjs.map +0 -1
- package/dist/Endpoint-B69TqESg.mjs.map +0 -1
- package/dist/Endpoint-B9PryZES.cjs.map +0 -1
- package/dist/EndpointBuilder-DnVL-EU_.mjs.map +0 -1
- package/dist/EndpointBuilder-DofwCnWJ.cjs.map +0 -1
- package/dist/EndpointFactory-Ba9mx9MU.cjs.map +0 -1
- package/dist/EndpointFactory-pPaIGFHV.mjs.map +0 -1
- package/dist/Function-CO-s2pB8.cjs.map +0 -1
- package/dist/Function-COnc-tWM.mjs.map +0 -1
- package/dist/FunctionBuilder-CMhLQ4dt.mjs.map +0 -1
- package/dist/FunctionBuilder-_hMwZUof.cjs.map +0 -1
- package/dist/FunctionExecutionWrapper-Ci-ookJG.d.cts +0 -24
- package/dist/FunctionExecutionWrapper-DHFMLrOl.d.mts +0 -24
- package/dist/FunctionExecutionWrapper-i9v5L3Av.mjs +0 -36
- package/dist/FunctionExecutionWrapper-i9v5L3Av.mjs.map +0 -1
- package/dist/FunctionExecutionWrapper-sxJNTpuc.cjs +0 -42
- package/dist/FunctionExecutionWrapper-sxJNTpuc.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-Cw2if5cG.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DAfnTFVS.mjs.map +0 -1
- package/dist/TestEndpointAdaptor-Bn1WRFph.cjs.map +0 -1
- package/dist/TestEndpointAdaptor-DubQOJk_.mjs.map +0 -1
- package/dist/functions-BYqZAob8.mjs +0 -8
- package/dist/index-D-a7e2gv.d.mts +0 -9
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
AuditableAction,
|
|
3
2
|
AuditActor,
|
|
4
|
-
Auditor,
|
|
5
3
|
AuditStorage,
|
|
4
|
+
AuditableAction,
|
|
5
|
+
Auditor,
|
|
6
6
|
} from '@geekmidas/audit';
|
|
7
7
|
import { DefaultAuditor } from '@geekmidas/audit';
|
|
8
8
|
import { withAuditableTransaction } from '@geekmidas/audit/kysely';
|
|
@@ -10,7 +10,7 @@ import type { Logger } from '@geekmidas/logger';
|
|
|
10
10
|
import type { InferStandardSchema } from '@geekmidas/schema';
|
|
11
11
|
import type { Service, ServiceDiscovery } from '@geekmidas/services';
|
|
12
12
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
13
|
-
import type {
|
|
13
|
+
import type { CookieFn, Endpoint, HeaderFn } from './Endpoint';
|
|
14
14
|
import type { ActorExtractor, MappedAudit } from './audit';
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -68,7 +68,8 @@ export async function processEndpointAudits<
|
|
|
68
68
|
|
|
69
69
|
// If we have an existing auditor (from handler context), we need to flush
|
|
70
70
|
// any manual audits it collected, even if there are no declarative audits
|
|
71
|
-
const hasExistingRecords =
|
|
71
|
+
const hasExistingRecords =
|
|
72
|
+
existingAuditor && existingAuditor.getRecords().length > 0;
|
|
72
73
|
|
|
73
74
|
// Skip if no declarative audits and no existing records to flush
|
|
74
75
|
if (!audits?.length && !hasExistingRecords) {
|
|
@@ -105,7 +106,11 @@ export async function processEndpointAudits<
|
|
|
105
106
|
if (endpoint.actorExtractor) {
|
|
106
107
|
try {
|
|
107
108
|
actor = await (
|
|
108
|
-
endpoint.actorExtractor as ActorExtractor<
|
|
109
|
+
endpoint.actorExtractor as ActorExtractor<
|
|
110
|
+
TServices,
|
|
111
|
+
TSession,
|
|
112
|
+
TLogger
|
|
113
|
+
>
|
|
109
114
|
)({
|
|
110
115
|
services: ctx.services as any,
|
|
111
116
|
session: ctx.session,
|
|
@@ -136,7 +141,10 @@ export async function processEndpointAudits<
|
|
|
136
141
|
|
|
137
142
|
// Check when condition
|
|
138
143
|
if (audit.when && !audit.when(response as any)) {
|
|
139
|
-
logger.debug(
|
|
144
|
+
logger.debug(
|
|
145
|
+
{ audit: audit.type },
|
|
146
|
+
'Audit skipped due to when condition',
|
|
147
|
+
);
|
|
140
148
|
continue;
|
|
141
149
|
}
|
|
142
150
|
|
|
@@ -160,9 +168,10 @@ export async function processEndpointAudits<
|
|
|
160
168
|
const recordCount = auditor.getRecords().length;
|
|
161
169
|
if (recordCount > 0) {
|
|
162
170
|
// Check if auditor has a stored transaction (for logging purposes)
|
|
163
|
-
const trx =
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
const trx =
|
|
172
|
+
'getTransaction' in auditor
|
|
173
|
+
? (auditor as { getTransaction(): unknown }).getTransaction()
|
|
174
|
+
: undefined;
|
|
166
175
|
logger.debug(
|
|
167
176
|
{ auditCount: recordCount, hasTransaction: !!trx },
|
|
168
177
|
'Flushing audits',
|
|
@@ -210,6 +219,8 @@ export async function createAuditContext<
|
|
|
210
219
|
string,
|
|
211
220
|
unknown
|
|
212
221
|
>,
|
|
222
|
+
TDatabase = undefined,
|
|
223
|
+
TDatabaseServiceName extends string = string,
|
|
213
224
|
>(
|
|
214
225
|
endpoint: Endpoint<
|
|
215
226
|
any,
|
|
@@ -223,7 +234,9 @@ export async function createAuditContext<
|
|
|
223
234
|
any,
|
|
224
235
|
TAuditStorage,
|
|
225
236
|
TAuditStorageServiceName,
|
|
226
|
-
TAuditAction
|
|
237
|
+
TAuditAction,
|
|
238
|
+
TDatabase,
|
|
239
|
+
TDatabaseServiceName
|
|
227
240
|
>,
|
|
228
241
|
serviceDiscovery: ServiceDiscovery<any, any>,
|
|
229
242
|
logger: TLogger,
|
|
@@ -308,21 +321,17 @@ export async function executeWithAuditTransaction<
|
|
|
308
321
|
|
|
309
322
|
if (db) {
|
|
310
323
|
// Wrap in transaction - audits are atomic with handler operations
|
|
311
|
-
return withAuditableTransaction(
|
|
312
|
-
|
|
313
|
-
auditor as any,
|
|
314
|
-
async () => {
|
|
315
|
-
const response = await handler(auditor);
|
|
324
|
+
return withAuditableTransaction(db as any, auditor as any, async () => {
|
|
325
|
+
const response = await handler(auditor);
|
|
316
326
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
327
|
+
// Process declarative audits within the transaction
|
|
328
|
+
if (onComplete) {
|
|
329
|
+
await onComplete(response, auditor);
|
|
330
|
+
}
|
|
321
331
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
);
|
|
332
|
+
// Audits are flushed by withAuditableTransaction before commit
|
|
333
|
+
return response;
|
|
334
|
+
});
|
|
326
335
|
}
|
|
327
336
|
|
|
328
337
|
// No database - run handler and flush audits after
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AuditStorage, AuditableAction, Auditor } from '@geekmidas/audit';
|
|
1
2
|
import type { EnvironmentParser } from '@geekmidas/envkit';
|
|
2
3
|
import middy, { type MiddlewareObj } from '@middy/core';
|
|
3
4
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
@@ -26,10 +27,17 @@ type FunctionEvent<
|
|
|
26
27
|
TInput extends ComposableStandardSchema | undefined,
|
|
27
28
|
TServices extends Service[],
|
|
28
29
|
TLogger extends Logger,
|
|
30
|
+
TDatabase = undefined,
|
|
31
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
32
|
+
string,
|
|
33
|
+
unknown
|
|
34
|
+
>,
|
|
29
35
|
> = TEvent & {
|
|
30
36
|
parsedInput: InferComposableStandardSchema<TInput>;
|
|
31
37
|
services: ServiceRecord<TServices>;
|
|
32
38
|
logger: TLogger;
|
|
39
|
+
db: TDatabase | undefined;
|
|
40
|
+
auditor: Auditor<TAuditAction> | undefined;
|
|
33
41
|
};
|
|
34
42
|
|
|
35
43
|
type Middleware<
|
|
@@ -38,8 +46,13 @@ type Middleware<
|
|
|
38
46
|
TServices extends Service[],
|
|
39
47
|
TLogger extends Logger,
|
|
40
48
|
TOutSchema extends StandardSchemaV1 | undefined,
|
|
49
|
+
TDatabase = undefined,
|
|
50
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
51
|
+
string,
|
|
52
|
+
unknown
|
|
53
|
+
>,
|
|
41
54
|
> = MiddlewareObj<
|
|
42
|
-
FunctionEvent<TEvent, TInput, TServices, TLogger>,
|
|
55
|
+
FunctionEvent<TEvent, TInput, TServices, TLogger, TDatabase, TAuditAction>,
|
|
43
56
|
InferComposableStandardSchema<TOutSchema>,
|
|
44
57
|
Error,
|
|
45
58
|
Context
|
|
@@ -52,13 +65,26 @@ export class AWSLambdaFunction<
|
|
|
52
65
|
TLogger extends Logger = Logger,
|
|
53
66
|
TEventPublisher extends EventPublisher<any> | undefined = undefined,
|
|
54
67
|
TEventPublisherServiceName extends string = string,
|
|
68
|
+
TAuditStorage extends AuditStorage | undefined = undefined,
|
|
69
|
+
TAuditStorageServiceName extends string = string,
|
|
70
|
+
TDatabase = undefined,
|
|
71
|
+
TDatabaseServiceName extends string = string,
|
|
72
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
73
|
+
string,
|
|
74
|
+
unknown
|
|
75
|
+
>,
|
|
55
76
|
> extends FunctionExecutionWrapper<
|
|
56
77
|
TInput,
|
|
57
78
|
TOutSchema,
|
|
58
79
|
TServices,
|
|
59
80
|
TLogger,
|
|
60
81
|
TEventPublisher,
|
|
61
|
-
TEventPublisherServiceName
|
|
82
|
+
TEventPublisherServiceName,
|
|
83
|
+
TAuditStorage,
|
|
84
|
+
TAuditStorageServiceName,
|
|
85
|
+
TDatabase,
|
|
86
|
+
TDatabaseServiceName,
|
|
87
|
+
TAuditAction
|
|
62
88
|
> {
|
|
63
89
|
constructor(
|
|
64
90
|
envParser: EnvironmentParser<{}>,
|
|
@@ -67,9 +93,22 @@ export class AWSLambdaFunction<
|
|
|
67
93
|
TServices,
|
|
68
94
|
TLogger,
|
|
69
95
|
TOutSchema,
|
|
70
|
-
FunctionHandler<TInput, TServices, TLogger, TOutSchema>,
|
|
71
96
|
TEventPublisher,
|
|
72
|
-
TEventPublisherServiceName
|
|
97
|
+
TEventPublisherServiceName,
|
|
98
|
+
TAuditStorage,
|
|
99
|
+
TAuditStorageServiceName,
|
|
100
|
+
TDatabase,
|
|
101
|
+
TDatabaseServiceName,
|
|
102
|
+
TAuditAction,
|
|
103
|
+
FunctionHandler<
|
|
104
|
+
TInput,
|
|
105
|
+
TServices,
|
|
106
|
+
TLogger,
|
|
107
|
+
TOutSchema,
|
|
108
|
+
TDatabase,
|
|
109
|
+
TAuditStorage,
|
|
110
|
+
TAuditAction
|
|
111
|
+
>
|
|
73
112
|
>,
|
|
74
113
|
) {
|
|
75
114
|
super(envParser, fn);
|
|
@@ -80,7 +119,9 @@ export class AWSLambdaFunction<
|
|
|
80
119
|
TInput,
|
|
81
120
|
TServices,
|
|
82
121
|
TLogger,
|
|
83
|
-
TOutSchema
|
|
122
|
+
TOutSchema,
|
|
123
|
+
TDatabase,
|
|
124
|
+
TAuditAction
|
|
84
125
|
> {
|
|
85
126
|
return {
|
|
86
127
|
onError: (req) => {
|
|
@@ -98,7 +139,9 @@ export class AWSLambdaFunction<
|
|
|
98
139
|
TInput,
|
|
99
140
|
TServices,
|
|
100
141
|
TLogger,
|
|
101
|
-
TOutSchema
|
|
142
|
+
TOutSchema,
|
|
143
|
+
TDatabase,
|
|
144
|
+
TAuditAction
|
|
102
145
|
> {
|
|
103
146
|
return {
|
|
104
147
|
before: (req) => {},
|
|
@@ -107,7 +150,15 @@ export class AWSLambdaFunction<
|
|
|
107
150
|
|
|
108
151
|
private input<
|
|
109
152
|
TEvent extends { input: InferComposableStandardSchema<TInput> },
|
|
110
|
-
>(): Middleware<
|
|
153
|
+
>(): Middleware<
|
|
154
|
+
TEvent,
|
|
155
|
+
TInput,
|
|
156
|
+
TServices,
|
|
157
|
+
TLogger,
|
|
158
|
+
TOutSchema,
|
|
159
|
+
TDatabase,
|
|
160
|
+
TAuditAction
|
|
161
|
+
> {
|
|
111
162
|
return {
|
|
112
163
|
before: async (req) => {
|
|
113
164
|
try {
|
|
@@ -141,7 +192,9 @@ export class AWSLambdaFunction<
|
|
|
141
192
|
TInput,
|
|
142
193
|
TServices,
|
|
143
194
|
TLogger,
|
|
144
|
-
TOutSchema
|
|
195
|
+
TOutSchema,
|
|
196
|
+
TDatabase,
|
|
197
|
+
TAuditAction
|
|
145
198
|
> {
|
|
146
199
|
return {
|
|
147
200
|
before: (req) => {
|
|
@@ -166,7 +219,9 @@ export class AWSLambdaFunction<
|
|
|
166
219
|
TInput,
|
|
167
220
|
TServices,
|
|
168
221
|
TLogger,
|
|
169
|
-
TOutSchema
|
|
222
|
+
TOutSchema,
|
|
223
|
+
TDatabase,
|
|
224
|
+
TAuditAction
|
|
170
225
|
> {
|
|
171
226
|
return {
|
|
172
227
|
before: async (req) => {
|
|
@@ -175,12 +230,59 @@ export class AWSLambdaFunction<
|
|
|
175
230
|
};
|
|
176
231
|
}
|
|
177
232
|
|
|
233
|
+
private database<TEvent>(): Middleware<
|
|
234
|
+
TEvent,
|
|
235
|
+
TInput,
|
|
236
|
+
TServices,
|
|
237
|
+
TLogger,
|
|
238
|
+
TOutSchema,
|
|
239
|
+
TDatabase,
|
|
240
|
+
TAuditAction
|
|
241
|
+
> {
|
|
242
|
+
return {
|
|
243
|
+
before: async (req) => {
|
|
244
|
+
req.event.db = await this.getDatabase();
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private auditor<TEvent>(): Middleware<
|
|
250
|
+
TEvent,
|
|
251
|
+
TInput,
|
|
252
|
+
TServices,
|
|
253
|
+
TLogger,
|
|
254
|
+
TOutSchema,
|
|
255
|
+
TDatabase,
|
|
256
|
+
TAuditAction
|
|
257
|
+
> {
|
|
258
|
+
return {
|
|
259
|
+
before: async (req) => {
|
|
260
|
+
req.event.auditor = await this.createAuditor();
|
|
261
|
+
},
|
|
262
|
+
after: async (req) => {
|
|
263
|
+
// Flush any pending audits after successful execution
|
|
264
|
+
if (req.event.auditor) {
|
|
265
|
+
const records = req.event.auditor.getRecords();
|
|
266
|
+
if (records.length > 0) {
|
|
267
|
+
this.logger.debug(
|
|
268
|
+
{ auditCount: records.length },
|
|
269
|
+
'Flushing function audits',
|
|
270
|
+
);
|
|
271
|
+
await req.event.auditor.flush();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
178
278
|
private events<TEvent>(): Middleware<
|
|
179
279
|
TEvent,
|
|
180
280
|
TInput,
|
|
181
281
|
TServices,
|
|
182
282
|
TLogger,
|
|
183
|
-
TOutSchema
|
|
283
|
+
TOutSchema,
|
|
284
|
+
TDatabase,
|
|
285
|
+
TAuditAction
|
|
184
286
|
> {
|
|
185
287
|
return {
|
|
186
288
|
after: async (req) => {
|
|
@@ -192,14 +294,23 @@ export class AWSLambdaFunction<
|
|
|
192
294
|
}
|
|
193
295
|
|
|
194
296
|
private async _handler<TEvent>(
|
|
195
|
-
event: FunctionEvent<
|
|
297
|
+
event: FunctionEvent<
|
|
298
|
+
TEvent,
|
|
299
|
+
TInput,
|
|
300
|
+
TServices,
|
|
301
|
+
TLogger,
|
|
302
|
+
TDatabase,
|
|
303
|
+
TAuditAction
|
|
304
|
+
>,
|
|
196
305
|
) {
|
|
197
306
|
// Execute the function with the parsed context
|
|
198
307
|
const result = await this.fn['fn']({
|
|
199
308
|
input: event.parsedInput,
|
|
200
309
|
services: event.services,
|
|
201
310
|
logger: event.logger,
|
|
202
|
-
|
|
311
|
+
db: event.db,
|
|
312
|
+
auditor: event.auditor,
|
|
313
|
+
} as any);
|
|
203
314
|
|
|
204
315
|
// Parse output if schema is provided
|
|
205
316
|
const output = await this.fn.parseOutput(result);
|
|
@@ -216,6 +327,8 @@ export class AWSLambdaFunction<
|
|
|
216
327
|
.use(this.baseInput())
|
|
217
328
|
.use(this.error())
|
|
218
329
|
.use(this.services())
|
|
330
|
+
.use(this.database())
|
|
331
|
+
.use(this.auditor())
|
|
219
332
|
.use(this.input())
|
|
220
333
|
.use(this.events()) as unknown as AWSLambdaHandler;
|
|
221
334
|
}
|
|
@@ -22,6 +22,8 @@ export abstract class BaseFunctionBuilder<
|
|
|
22
22
|
TEventPublisherServiceName extends string = string,
|
|
23
23
|
TAuditStorage extends AuditStorage | undefined = undefined,
|
|
24
24
|
TAuditStorageServiceName extends string = string,
|
|
25
|
+
TDatabase = undefined,
|
|
26
|
+
TDatabaseServiceName extends string = string,
|
|
25
27
|
> {
|
|
26
28
|
protected inputSchema?: TInput;
|
|
27
29
|
protected outputSchema?: OutSchema;
|
|
@@ -33,6 +35,7 @@ export abstract class BaseFunctionBuilder<
|
|
|
33
35
|
protected _events: MappedEvent<TEventPublisher, OutSchema>[] = [];
|
|
34
36
|
protected _publisher?: Service<TEventPublisherServiceName, TEventPublisher>;
|
|
35
37
|
protected _auditorStorage?: Service<TAuditStorageServiceName, TAuditStorage>;
|
|
38
|
+
protected _databaseService?: Service<TDatabaseServiceName, TDatabase>;
|
|
36
39
|
|
|
37
40
|
static isStandardSchemaV1(s: unknown): s is StandardSchemaV1 {
|
|
38
41
|
const schema = (s as StandardSchemaV1)['~standard'];
|
|
@@ -103,7 +106,9 @@ export abstract class BaseFunctionBuilder<
|
|
|
103
106
|
T,
|
|
104
107
|
TName,
|
|
105
108
|
TAuditStorage,
|
|
106
|
-
TAuditStorageServiceName
|
|
109
|
+
TAuditStorageServiceName,
|
|
110
|
+
TDatabase,
|
|
111
|
+
TDatabaseServiceName
|
|
107
112
|
> {
|
|
108
113
|
this._publisher = publisher as unknown as Service<
|
|
109
114
|
TEventPublisherServiceName,
|
|
@@ -118,7 +123,9 @@ export abstract class BaseFunctionBuilder<
|
|
|
118
123
|
T,
|
|
119
124
|
TName,
|
|
120
125
|
TAuditStorage,
|
|
121
|
-
TAuditStorageServiceName
|
|
126
|
+
TAuditStorageServiceName,
|
|
127
|
+
TDatabase,
|
|
128
|
+
TDatabaseServiceName
|
|
122
129
|
>;
|
|
123
130
|
}
|
|
124
131
|
|
|
@@ -132,7 +139,9 @@ export abstract class BaseFunctionBuilder<
|
|
|
132
139
|
TEventPublisher,
|
|
133
140
|
TEventPublisherServiceName,
|
|
134
141
|
T,
|
|
135
|
-
TName
|
|
142
|
+
TName,
|
|
143
|
+
TDatabase,
|
|
144
|
+
TDatabaseServiceName
|
|
136
145
|
> {
|
|
137
146
|
this._auditorStorage = storage as unknown as Service<
|
|
138
147
|
TAuditStorageServiceName,
|
|
@@ -147,6 +156,45 @@ export abstract class BaseFunctionBuilder<
|
|
|
147
156
|
TEventPublisher,
|
|
148
157
|
TEventPublisherServiceName,
|
|
149
158
|
T,
|
|
159
|
+
TName,
|
|
160
|
+
TDatabase,
|
|
161
|
+
TDatabaseServiceName
|
|
162
|
+
>;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Set the database service for this function.
|
|
167
|
+
* The database will be available in the handler context as `db`.
|
|
168
|
+
*/
|
|
169
|
+
database<T, TName extends string>(
|
|
170
|
+
service: Service<TName, T>,
|
|
171
|
+
): BaseFunctionBuilder<
|
|
172
|
+
TInput,
|
|
173
|
+
OutSchema,
|
|
174
|
+
TServices,
|
|
175
|
+
TLogger,
|
|
176
|
+
TEventPublisher,
|
|
177
|
+
TEventPublisherServiceName,
|
|
178
|
+
TAuditStorage,
|
|
179
|
+
TAuditStorageServiceName,
|
|
180
|
+
T,
|
|
181
|
+
TName
|
|
182
|
+
> {
|
|
183
|
+
this._databaseService = service as unknown as Service<
|
|
184
|
+
TDatabaseServiceName,
|
|
185
|
+
TDatabase
|
|
186
|
+
>;
|
|
187
|
+
|
|
188
|
+
return this as unknown as BaseFunctionBuilder<
|
|
189
|
+
TInput,
|
|
190
|
+
OutSchema,
|
|
191
|
+
TServices,
|
|
192
|
+
TLogger,
|
|
193
|
+
TEventPublisher,
|
|
194
|
+
TEventPublisherServiceName,
|
|
195
|
+
TAuditStorage,
|
|
196
|
+
TAuditStorageServiceName,
|
|
197
|
+
T,
|
|
150
198
|
TName
|
|
151
199
|
>;
|
|
152
200
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuditStorage } from '@geekmidas/audit';
|
|
1
|
+
import type { AuditStorage, AuditableAction, Auditor } from '@geekmidas/audit';
|
|
2
2
|
import { UnprocessableEntityError } from '@geekmidas/errors';
|
|
3
3
|
import type { EventPublisher, MappedEvent } from '@geekmidas/events';
|
|
4
4
|
import type { Logger } from '@geekmidas/logger';
|
|
@@ -52,16 +52,33 @@ export class Function<
|
|
|
52
52
|
TServices extends Service[] = [],
|
|
53
53
|
TLogger extends Logger = Logger,
|
|
54
54
|
OutSchema extends StandardSchemaV1 | undefined = undefined,
|
|
55
|
-
Fn extends FunctionHandler<
|
|
56
|
-
TInput,
|
|
57
|
-
TServices,
|
|
58
|
-
TLogger,
|
|
59
|
-
OutSchema
|
|
60
|
-
> = FunctionHandler<TInput, TServices, TLogger, OutSchema>,
|
|
61
55
|
TEventPublisher extends EventPublisher<any> | undefined = undefined,
|
|
62
56
|
TEventPublisherServiceName extends string = string,
|
|
63
57
|
TAuditStorage extends AuditStorage | undefined = undefined,
|
|
64
58
|
TAuditStorageServiceName extends string = string,
|
|
59
|
+
TDatabase = undefined,
|
|
60
|
+
TDatabaseServiceName extends string = string,
|
|
61
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
62
|
+
string,
|
|
63
|
+
unknown
|
|
64
|
+
>,
|
|
65
|
+
Fn extends FunctionHandler<
|
|
66
|
+
TInput,
|
|
67
|
+
TServices,
|
|
68
|
+
TLogger,
|
|
69
|
+
OutSchema,
|
|
70
|
+
TDatabase,
|
|
71
|
+
TAuditStorage,
|
|
72
|
+
TAuditAction
|
|
73
|
+
> = FunctionHandler<
|
|
74
|
+
TInput,
|
|
75
|
+
TServices,
|
|
76
|
+
TLogger,
|
|
77
|
+
OutSchema,
|
|
78
|
+
TDatabase,
|
|
79
|
+
TAuditStorage,
|
|
80
|
+
TAuditAction
|
|
81
|
+
>,
|
|
65
82
|
> extends Construct<
|
|
66
83
|
TLogger,
|
|
67
84
|
TEventPublisherServiceName,
|
|
@@ -137,6 +154,7 @@ export class Function<
|
|
|
137
154
|
events: MappedEvent<TEventPublisher, OutSchema>[] = [],
|
|
138
155
|
memorySize?: number,
|
|
139
156
|
auditorStorageService?: Service<TAuditStorageServiceName, TAuditStorage>,
|
|
157
|
+
public databaseService?: Service<TDatabaseServiceName, TDatabase>,
|
|
140
158
|
) {
|
|
141
159
|
super(
|
|
142
160
|
type,
|
|
@@ -157,18 +175,64 @@ export type FunctionHandler<
|
|
|
157
175
|
TServices extends Service[] = [],
|
|
158
176
|
TLogger extends Logger = Logger,
|
|
159
177
|
OutSchema extends StandardSchemaV1 | undefined = undefined,
|
|
178
|
+
TDatabase = undefined,
|
|
179
|
+
TAuditStorage extends AuditStorage | undefined = undefined,
|
|
180
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
181
|
+
string,
|
|
182
|
+
unknown
|
|
183
|
+
>,
|
|
160
184
|
> = (
|
|
161
|
-
ctx: FunctionContext<
|
|
185
|
+
ctx: FunctionContext<
|
|
186
|
+
TInput,
|
|
187
|
+
TServices,
|
|
188
|
+
TLogger,
|
|
189
|
+
TDatabase,
|
|
190
|
+
TAuditStorage,
|
|
191
|
+
TAuditAction
|
|
192
|
+
>,
|
|
162
193
|
) => OutSchema extends StandardSchemaV1
|
|
163
194
|
? InferStandardSchema<OutSchema> | Promise<InferStandardSchema<OutSchema>>
|
|
164
195
|
: any | Promise<any>;
|
|
165
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Conditional type that adds `db` property only when TDatabase is configured.
|
|
199
|
+
*/
|
|
200
|
+
type DatabaseContext<TDatabase> = TDatabase extends undefined
|
|
201
|
+
? {}
|
|
202
|
+
: { db: TDatabase };
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Conditional auditor context - only present when audit storage is configured.
|
|
206
|
+
*/
|
|
207
|
+
type AuditorContext<
|
|
208
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
209
|
+
string,
|
|
210
|
+
unknown
|
|
211
|
+
>,
|
|
212
|
+
TAuditStorage = undefined,
|
|
213
|
+
> = TAuditStorage extends undefined
|
|
214
|
+
? {}
|
|
215
|
+
: {
|
|
216
|
+
/**
|
|
217
|
+
* Auditor instance for recording audit events.
|
|
218
|
+
* Only present when audit storage is configured on the function.
|
|
219
|
+
*/
|
|
220
|
+
auditor: Auditor<TAuditAction>;
|
|
221
|
+
};
|
|
222
|
+
|
|
166
223
|
export type FunctionContext<
|
|
167
224
|
Input extends ComposableStandardSchema | undefined = undefined,
|
|
168
225
|
TServices extends Service[] = [],
|
|
169
226
|
TLogger extends Logger = Logger,
|
|
227
|
+
TDatabase = undefined,
|
|
228
|
+
TAuditStorage extends AuditStorage | undefined = undefined,
|
|
229
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
230
|
+
string,
|
|
231
|
+
unknown
|
|
232
|
+
>,
|
|
170
233
|
> = {
|
|
171
234
|
services: ServiceRecord<TServices>;
|
|
172
235
|
logger: TLogger;
|
|
173
236
|
input: InferComposableStandardSchema<Input>;
|
|
174
|
-
}
|
|
237
|
+
} & DatabaseContext<TDatabase> &
|
|
238
|
+
AuditorContext<TAuditAction, TAuditStorage>;
|