@geekmidas/constructs 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +448 -0
- package/dist/AWSLambdaFunction-B-Oxr8qt.d.cts +30 -0
- package/dist/{AWSLambdaFunction-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-Bf9JSWzI.d.cts} +12 -12
- 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-Cgk1R0oO.d.mts} +12 -12
- 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-DSHl8ZCY.d.cts → HonoEndpointAdaptor-B34kNobH.d.cts} +7 -7
- package/dist/{HonoEndpointAdaptor-BElil8O5.d.mts → HonoEndpointAdaptor-BDpi32mH.d.mts} +7 -7
- package/dist/{HonoEndpointAdaptor-Cw2if5cG.cjs → HonoEndpointAdaptor-CfLRHHFw.cjs} +8 -4
- package/dist/HonoEndpointAdaptor-CfLRHHFw.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-DAfnTFVS.mjs → HonoEndpointAdaptor-DuyE06nH.mjs} +8 -4
- package/dist/HonoEndpointAdaptor-DuyE06nH.mjs.map +1 -0
- 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-Bomy7R9z.d.mts +10 -0
- package/dist/index-DRYfZHb3.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 +6 -6
- 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-CUg_hSq-.d.cts +0 -9
- package/dist/index-D-a7e2gv.d.mts +0 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuditableAction, Auditor
|
|
1
|
+
import type { AuditStorage, AuditableAction, Auditor } from '@geekmidas/audit';
|
|
2
2
|
import type {
|
|
3
3
|
EventPublisher,
|
|
4
4
|
ExtractPublisherMessage,
|
|
@@ -27,8 +27,8 @@ import type { OpenAPIV3_1 } from 'openapi-types';
|
|
|
27
27
|
import { ConstructType } from '../Construct';
|
|
28
28
|
import { Function, type FunctionHandler } from '../functions';
|
|
29
29
|
import type { HttpMethod, LowerHttpMethod, RemoveUndefined } from '../types';
|
|
30
|
-
import type { ActorExtractor, MappedAudit } from './audit';
|
|
31
30
|
import type { Authorizer } from './Authorizer';
|
|
31
|
+
import type { ActorExtractor, MappedAudit } from './audit';
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Represents an HTTP endpoint that can handle requests with type-safe input/output validation,
|
|
@@ -71,16 +71,29 @@ export class Endpoint<
|
|
|
71
71
|
string,
|
|
72
72
|
unknown
|
|
73
73
|
>,
|
|
74
|
+
TDatabase = undefined,
|
|
75
|
+
TDatabaseServiceName extends string = string,
|
|
74
76
|
> extends Function<
|
|
75
77
|
TInput,
|
|
76
78
|
TServices,
|
|
77
79
|
TLogger,
|
|
78
80
|
OutSchema,
|
|
79
|
-
FunctionHandler<TInput, TServices, TLogger, OutSchema>,
|
|
80
81
|
TEventPublisher,
|
|
81
82
|
TEventPublisherServiceName,
|
|
82
83
|
TAuditStorage,
|
|
83
|
-
TAuditStorageServiceName
|
|
84
|
+
TAuditStorageServiceName,
|
|
85
|
+
TDatabase,
|
|
86
|
+
TDatabaseServiceName,
|
|
87
|
+
TAuditAction,
|
|
88
|
+
FunctionHandler<
|
|
89
|
+
TInput,
|
|
90
|
+
TServices,
|
|
91
|
+
TLogger,
|
|
92
|
+
OutSchema,
|
|
93
|
+
TDatabase,
|
|
94
|
+
TAuditStorage,
|
|
95
|
+
TAuditAction
|
|
96
|
+
>
|
|
84
97
|
> {
|
|
85
98
|
operationId?: string;
|
|
86
99
|
/** The route path pattern with parameter placeholders */
|
|
@@ -108,13 +121,18 @@ export class Endpoint<
|
|
|
108
121
|
public actorExtractor?: ActorExtractor<TServices, TSession, TLogger>;
|
|
109
122
|
/** Declarative audit definitions */
|
|
110
123
|
public audits: MappedAudit<TAuditAction, OutSchema>[] = [];
|
|
124
|
+
/** Database service for this endpoint */
|
|
125
|
+
public databaseService?: Service<TDatabaseServiceName, TDatabase>;
|
|
111
126
|
/** The endpoint handler function */
|
|
112
127
|
private endpointFn!: EndpointHandler<
|
|
113
128
|
TInput,
|
|
114
129
|
TServices,
|
|
115
130
|
TLogger,
|
|
116
131
|
OutSchema,
|
|
117
|
-
TSession
|
|
132
|
+
TSession,
|
|
133
|
+
TDatabase,
|
|
134
|
+
TAuditStorage,
|
|
135
|
+
TAuditAction
|
|
118
136
|
>;
|
|
119
137
|
|
|
120
138
|
/**
|
|
@@ -321,7 +339,15 @@ export class Endpoint<
|
|
|
321
339
|
}
|
|
322
340
|
|
|
323
341
|
handler = (
|
|
324
|
-
ctx: EndpointContext<
|
|
342
|
+
ctx: EndpointContext<
|
|
343
|
+
TInput,
|
|
344
|
+
TServices,
|
|
345
|
+
TLogger,
|
|
346
|
+
TSession,
|
|
347
|
+
TAuditAction,
|
|
348
|
+
TDatabase,
|
|
349
|
+
TAuditStorage
|
|
350
|
+
>,
|
|
325
351
|
response: ResponseBuilder,
|
|
326
352
|
): OutSchema extends StandardSchemaV1
|
|
327
353
|
?
|
|
@@ -339,18 +365,28 @@ export class Endpoint<
|
|
|
339
365
|
response.header(key, value);
|
|
340
366
|
}
|
|
341
367
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
368
|
+
// Build context object, conditionally including auditor and db
|
|
369
|
+
const handlerCtx = {
|
|
370
|
+
...this.refineInput(ctx),
|
|
371
|
+
services: ctx.services,
|
|
372
|
+
logger: ctx.logger,
|
|
373
|
+
header: ctx.header,
|
|
374
|
+
cookie: ctx.cookie,
|
|
375
|
+
session: ctx.session,
|
|
376
|
+
// These are conditionally present based on configuration
|
|
377
|
+
...('auditor' in ctx && { auditor: ctx.auditor }),
|
|
378
|
+
...('db' in ctx && { db: ctx.db }),
|
|
379
|
+
} as EndpointContext<
|
|
380
|
+
TInput,
|
|
381
|
+
TServices,
|
|
382
|
+
TLogger,
|
|
383
|
+
TSession,
|
|
384
|
+
TAuditAction,
|
|
385
|
+
TDatabase,
|
|
386
|
+
TAuditStorage
|
|
387
|
+
>;
|
|
388
|
+
|
|
389
|
+
return this.endpointFn(handlerCtx, response);
|
|
354
390
|
};
|
|
355
391
|
|
|
356
392
|
/**
|
|
@@ -556,6 +592,7 @@ export class Endpoint<
|
|
|
556
592
|
auditorStorageService,
|
|
557
593
|
actorExtractor,
|
|
558
594
|
audits,
|
|
595
|
+
databaseService,
|
|
559
596
|
}: EndpointOptions<
|
|
560
597
|
TRoute,
|
|
561
598
|
TMethod,
|
|
@@ -569,7 +606,9 @@ export class Endpoint<
|
|
|
569
606
|
TEventPublisherServiceName,
|
|
570
607
|
TAuditStorage,
|
|
571
608
|
TAuditStorageServiceName,
|
|
572
|
-
TAuditAction
|
|
609
|
+
TAuditAction,
|
|
610
|
+
TDatabase,
|
|
611
|
+
TDatabaseServiceName
|
|
573
612
|
>) {
|
|
574
613
|
super(
|
|
575
614
|
fn as unknown as FunctionHandler<TInput, TServices, TLogger, OutSchema>,
|
|
@@ -615,6 +654,10 @@ export class Endpoint<
|
|
|
615
654
|
if (audits) {
|
|
616
655
|
this.audits = audits;
|
|
617
656
|
}
|
|
657
|
+
|
|
658
|
+
if (databaseService) {
|
|
659
|
+
this.databaseService = databaseService;
|
|
660
|
+
}
|
|
618
661
|
}
|
|
619
662
|
}
|
|
620
663
|
|
|
@@ -672,13 +715,24 @@ export interface EndpointOptions<
|
|
|
672
715
|
string,
|
|
673
716
|
unknown
|
|
674
717
|
>,
|
|
718
|
+
TDatabase = undefined,
|
|
719
|
+
TDatabaseServiceName extends string = string,
|
|
675
720
|
> {
|
|
676
721
|
/** The route path with parameter placeholders */
|
|
677
722
|
route: TRoute;
|
|
678
723
|
/** The HTTP method for this endpoint */
|
|
679
724
|
method: TMethod;
|
|
680
725
|
/** The handler function that implements the endpoint logic */
|
|
681
|
-
fn: EndpointHandler<
|
|
726
|
+
fn: EndpointHandler<
|
|
727
|
+
TInput,
|
|
728
|
+
TServices,
|
|
729
|
+
TLogger,
|
|
730
|
+
TOutput,
|
|
731
|
+
TSession,
|
|
732
|
+
TDatabase,
|
|
733
|
+
TAuditStorage,
|
|
734
|
+
TAuditAction
|
|
735
|
+
>;
|
|
682
736
|
/** Optional authorization check function */
|
|
683
737
|
authorize: AuthorizeFn<TServices, TLogger, TSession> | undefined;
|
|
684
738
|
/** Optional description for documentation */
|
|
@@ -719,6 +773,8 @@ export interface EndpointOptions<
|
|
|
719
773
|
actorExtractor?: ActorExtractor<TServices, TSession, TLogger>;
|
|
720
774
|
/** Declarative audit definitions */
|
|
721
775
|
audits?: MappedAudit<TAuditAction, OutSchema>[];
|
|
776
|
+
/** Database service for this endpoint */
|
|
777
|
+
databaseService?: Service<TDatabaseServiceName, TDatabase>;
|
|
722
778
|
}
|
|
723
779
|
|
|
724
780
|
/**
|
|
@@ -968,6 +1024,62 @@ export class ResponseBuilder {
|
|
|
968
1024
|
}
|
|
969
1025
|
}
|
|
970
1026
|
|
|
1027
|
+
/**
|
|
1028
|
+
* Base context properties that are always available
|
|
1029
|
+
*/
|
|
1030
|
+
type BaseEndpointContext<
|
|
1031
|
+
TServices extends Service[] = [],
|
|
1032
|
+
TLogger extends Logger = Logger,
|
|
1033
|
+
TSession = unknown,
|
|
1034
|
+
> = {
|
|
1035
|
+
/** Injected service instances */
|
|
1036
|
+
services: ServiceRecord<TServices>;
|
|
1037
|
+
/** Logger instance for this request */
|
|
1038
|
+
logger: TLogger;
|
|
1039
|
+
/** Function to retrieve request headers */
|
|
1040
|
+
header: HeaderFn;
|
|
1041
|
+
/** Function to retrieve request cookies */
|
|
1042
|
+
cookie: CookieFn;
|
|
1043
|
+
/** Session data extracted by getSession */
|
|
1044
|
+
session: TSession;
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Conditional auditor context - only present when audit storage is configured
|
|
1049
|
+
*/
|
|
1050
|
+
type AuditorContext<
|
|
1051
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
1052
|
+
string,
|
|
1053
|
+
unknown
|
|
1054
|
+
>,
|
|
1055
|
+
TAuditStorage = undefined,
|
|
1056
|
+
> = TAuditStorage extends undefined
|
|
1057
|
+
? {}
|
|
1058
|
+
: {
|
|
1059
|
+
/**
|
|
1060
|
+
* Auditor instance for recording audit events.
|
|
1061
|
+
* Only present when audit storage is configured on the endpoint.
|
|
1062
|
+
* When a transactional database is used for audit storage,
|
|
1063
|
+
* the auditor is pre-configured with the transaction context.
|
|
1064
|
+
*/
|
|
1065
|
+
auditor: Auditor<TAuditAction>;
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Conditional database context - only present when database service is configured
|
|
1070
|
+
*/
|
|
1071
|
+
type DatabaseContext<TDatabase = undefined> = TDatabase extends undefined
|
|
1072
|
+
? {}
|
|
1073
|
+
: {
|
|
1074
|
+
/**
|
|
1075
|
+
* Database instance for this request.
|
|
1076
|
+
* When audit storage is configured and uses the same database,
|
|
1077
|
+
* this will be the transaction for ACID compliance.
|
|
1078
|
+
* Otherwise, it's the raw database connection.
|
|
1079
|
+
*/
|
|
1080
|
+
db: TDatabase;
|
|
1081
|
+
};
|
|
1082
|
+
|
|
971
1083
|
/**
|
|
972
1084
|
* The execution context provided to endpoint handlers.
|
|
973
1085
|
* Contains all parsed input data, services, logger, headers, cookies, and session.
|
|
@@ -976,6 +1088,9 @@ export class ResponseBuilder {
|
|
|
976
1088
|
* @template TServices - Available service dependencies
|
|
977
1089
|
* @template TLogger - Logger type
|
|
978
1090
|
* @template TSession - Session data type
|
|
1091
|
+
* @template TAuditAction - Audit action types (when auditor is configured)
|
|
1092
|
+
* @template TDatabase - Database type (when database service is configured)
|
|
1093
|
+
* @template TAuditStorage - Audit storage type (determines if auditor is present)
|
|
979
1094
|
*/
|
|
980
1095
|
export type EndpointContext<
|
|
981
1096
|
Input extends EndpointSchemas | undefined = undefined,
|
|
@@ -986,25 +1101,12 @@ export type EndpointContext<
|
|
|
986
1101
|
string,
|
|
987
1102
|
unknown
|
|
988
1103
|
>,
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
header: HeaderFn;
|
|
996
|
-
/** Function to retrieve request cookies */
|
|
997
|
-
cookie: CookieFn;
|
|
998
|
-
/** Session data extracted by getSession */
|
|
999
|
-
session: TSession;
|
|
1000
|
-
/**
|
|
1001
|
-
* Auditor instance for recording audit events.
|
|
1002
|
-
* Only present when audit storage is configured on the endpoint.
|
|
1003
|
-
* When a transactional database is used for audit storage,
|
|
1004
|
-
* the auditor is pre-configured with the transaction context.
|
|
1005
|
-
*/
|
|
1006
|
-
auditor?: Auditor<TAuditAction>;
|
|
1007
|
-
} & InferComposableStandardSchema<Input>;
|
|
1104
|
+
TDatabase = undefined,
|
|
1105
|
+
TAuditStorage = undefined,
|
|
1106
|
+
> = BaseEndpointContext<TServices, TLogger, TSession> &
|
|
1107
|
+
InferComposableStandardSchema<Input> &
|
|
1108
|
+
AuditorContext<TAuditAction, TAuditStorage> &
|
|
1109
|
+
DatabaseContext<TDatabase>;
|
|
1008
1110
|
|
|
1009
1111
|
/**
|
|
1010
1112
|
* Handler function type for endpoint implementations.
|
|
@@ -1041,8 +1143,22 @@ export type EndpointHandler<
|
|
|
1041
1143
|
TLogger extends Logger = Logger,
|
|
1042
1144
|
OutSchema extends StandardSchemaV1 | undefined = undefined,
|
|
1043
1145
|
TSession = unknown,
|
|
1146
|
+
TDatabase = undefined,
|
|
1147
|
+
TAuditStorage = undefined,
|
|
1148
|
+
TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
|
|
1149
|
+
string,
|
|
1150
|
+
unknown
|
|
1151
|
+
>,
|
|
1044
1152
|
> = (
|
|
1045
|
-
ctx: EndpointContext<
|
|
1153
|
+
ctx: EndpointContext<
|
|
1154
|
+
TInput,
|
|
1155
|
+
TServices,
|
|
1156
|
+
TLogger,
|
|
1157
|
+
TSession,
|
|
1158
|
+
TAuditAction,
|
|
1159
|
+
TDatabase,
|
|
1160
|
+
TAuditStorage
|
|
1161
|
+
>,
|
|
1046
1162
|
response: ResponseBuilder,
|
|
1047
1163
|
) => OutSchema extends StandardSchemaV1
|
|
1048
1164
|
?
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuditStorage, AuditableAction } from '@geekmidas/audit';
|
|
2
2
|
import type { EventPublisher, MappedEvent } from '@geekmidas/events';
|
|
3
3
|
import type { Logger } from '@geekmidas/logger';
|
|
4
4
|
import type { RateLimitConfig } from '@geekmidas/rate-limit';
|
|
@@ -8,7 +8,6 @@ import uniqBy from 'lodash.uniqby';
|
|
|
8
8
|
import { ConstructType } from '../Construct';
|
|
9
9
|
import { BaseFunctionBuilder } from '../functions';
|
|
10
10
|
import type { HttpMethod } from '../types';
|
|
11
|
-
import type { ActorExtractor, MappedAudit } from './audit';
|
|
12
11
|
import type { Authorizer } from './Authorizer';
|
|
13
12
|
import { Endpoint, type EndpointSchemas } from './Endpoint';
|
|
14
13
|
import type {
|
|
@@ -17,6 +16,7 @@ import type {
|
|
|
17
16
|
SessionFn,
|
|
18
17
|
SuccessStatus,
|
|
19
18
|
} from './Endpoint';
|
|
19
|
+
import type { ActorExtractor, MappedAudit } from './audit';
|
|
20
20
|
|
|
21
21
|
export class EndpointBuilder<
|
|
22
22
|
TRoute extends string,
|
|
@@ -35,6 +35,8 @@ export class EndpointBuilder<
|
|
|
35
35
|
string,
|
|
36
36
|
unknown
|
|
37
37
|
>,
|
|
38
|
+
TDatabase = undefined,
|
|
39
|
+
TDatabaseServiceName extends string = string,
|
|
38
40
|
> extends BaseFunctionBuilder<
|
|
39
41
|
TInput,
|
|
40
42
|
OutSchema,
|
|
@@ -57,6 +59,7 @@ export class EndpointBuilder<
|
|
|
57
59
|
_authorizerName?: TAuthorizers[number];
|
|
58
60
|
_actorExtractor?: ActorExtractor<TServices, TSession, TLogger>;
|
|
59
61
|
_audits: MappedAudit<TAuditAction, OutSchema>[] = [];
|
|
62
|
+
_databaseService?: Service<TDatabaseServiceName, TDatabase>;
|
|
60
63
|
|
|
61
64
|
constructor(
|
|
62
65
|
readonly route: TRoute,
|
|
@@ -237,7 +240,10 @@ export class EndpointBuilder<
|
|
|
237
240
|
TEventPublisherServiceName,
|
|
238
241
|
TAuthorizers,
|
|
239
242
|
TAuditStorage,
|
|
240
|
-
TAuditStorageServiceName
|
|
243
|
+
TAuditStorageServiceName,
|
|
244
|
+
TAuditAction,
|
|
245
|
+
TDatabase,
|
|
246
|
+
TDatabaseServiceName
|
|
241
247
|
> {
|
|
242
248
|
// Special case: 'none' explicitly marks endpoint as having no authorizer
|
|
243
249
|
if (name === 'none') {
|
|
@@ -250,7 +256,9 @@ export class EndpointBuilder<
|
|
|
250
256
|
(a) => a.name === name,
|
|
251
257
|
);
|
|
252
258
|
if (!authorizerExists && this._availableAuthorizers.length > 0) {
|
|
253
|
-
const available = this._availableAuthorizers
|
|
259
|
+
const available = this._availableAuthorizers
|
|
260
|
+
.map((a) => a.name)
|
|
261
|
+
.join(', ');
|
|
254
262
|
throw new Error(
|
|
255
263
|
`Authorizer "${name as string}" not found in available authorizers: ${available}`,
|
|
256
264
|
);
|
|
@@ -273,7 +281,10 @@ export class EndpointBuilder<
|
|
|
273
281
|
TEventPublisherServiceName,
|
|
274
282
|
TAuthorizers,
|
|
275
283
|
TAuditStorage,
|
|
276
|
-
TAuditStorageServiceName
|
|
284
|
+
TAuditStorageServiceName,
|
|
285
|
+
TAuditAction,
|
|
286
|
+
TDatabase,
|
|
287
|
+
TDatabaseServiceName
|
|
277
288
|
> {
|
|
278
289
|
this._services = uniqBy(
|
|
279
290
|
[...this._services, ...services],
|
|
@@ -292,7 +303,10 @@ export class EndpointBuilder<
|
|
|
292
303
|
TEventPublisherServiceName,
|
|
293
304
|
TAuthorizers,
|
|
294
305
|
TAuditStorage,
|
|
295
|
-
TAuditStorageServiceName
|
|
306
|
+
TAuditStorageServiceName,
|
|
307
|
+
TAuditAction,
|
|
308
|
+
TDatabase,
|
|
309
|
+
TDatabaseServiceName
|
|
296
310
|
>;
|
|
297
311
|
}
|
|
298
312
|
|
|
@@ -310,7 +324,10 @@ export class EndpointBuilder<
|
|
|
310
324
|
TEventPublisherServiceName,
|
|
311
325
|
TAuthorizers,
|
|
312
326
|
TAuditStorage,
|
|
313
|
-
TAuditStorageServiceName
|
|
327
|
+
TAuditStorageServiceName,
|
|
328
|
+
TAuditAction,
|
|
329
|
+
TDatabase,
|
|
330
|
+
TDatabaseServiceName
|
|
314
331
|
> {
|
|
315
332
|
this._logger = logger as unknown as TLogger;
|
|
316
333
|
|
|
@@ -326,7 +343,10 @@ export class EndpointBuilder<
|
|
|
326
343
|
TEventPublisherServiceName,
|
|
327
344
|
TAuthorizers,
|
|
328
345
|
TAuditStorage,
|
|
329
|
-
TAuditStorageServiceName
|
|
346
|
+
TAuditStorageServiceName,
|
|
347
|
+
TAuditAction,
|
|
348
|
+
TDatabase,
|
|
349
|
+
TDatabaseServiceName
|
|
330
350
|
>;
|
|
331
351
|
}
|
|
332
352
|
|
|
@@ -344,7 +364,10 @@ export class EndpointBuilder<
|
|
|
344
364
|
TEventPublisherServiceName,
|
|
345
365
|
TAuthorizers,
|
|
346
366
|
TAuditStorage,
|
|
347
|
-
TAuditStorageServiceName
|
|
367
|
+
TAuditStorageServiceName,
|
|
368
|
+
TAuditAction,
|
|
369
|
+
TDatabase,
|
|
370
|
+
TDatabaseServiceName
|
|
348
371
|
> {
|
|
349
372
|
this.outputSchema = schema as unknown as OutSchema;
|
|
350
373
|
|
|
@@ -360,7 +383,10 @@ export class EndpointBuilder<
|
|
|
360
383
|
TEventPublisherServiceName,
|
|
361
384
|
TAuthorizers,
|
|
362
385
|
TAuditStorage,
|
|
363
|
-
TAuditStorageServiceName
|
|
386
|
+
TAuditStorageServiceName,
|
|
387
|
+
TAuditAction,
|
|
388
|
+
TDatabase,
|
|
389
|
+
TDatabaseServiceName
|
|
364
390
|
>;
|
|
365
391
|
}
|
|
366
392
|
|
|
@@ -383,7 +409,9 @@ export class EndpointBuilder<
|
|
|
383
409
|
TAuthorizers,
|
|
384
410
|
T,
|
|
385
411
|
TName,
|
|
386
|
-
TAuditAction
|
|
412
|
+
TAuditAction,
|
|
413
|
+
TDatabase,
|
|
414
|
+
TDatabaseServiceName
|
|
387
415
|
> {
|
|
388
416
|
this._auditorStorage = storage as unknown as Service<
|
|
389
417
|
TAuditStorageServiceName,
|
|
@@ -403,7 +431,9 @@ export class EndpointBuilder<
|
|
|
403
431
|
TAuthorizers,
|
|
404
432
|
T,
|
|
405
433
|
TName,
|
|
406
|
-
TAuditAction
|
|
434
|
+
TAuditAction,
|
|
435
|
+
TDatabase,
|
|
436
|
+
TDatabaseServiceName
|
|
407
437
|
>;
|
|
408
438
|
}
|
|
409
439
|
|
|
@@ -426,7 +456,9 @@ export class EndpointBuilder<
|
|
|
426
456
|
TAuthorizers,
|
|
427
457
|
TAuditStorage,
|
|
428
458
|
TAuditStorageServiceName,
|
|
429
|
-
TAuditAction
|
|
459
|
+
TAuditAction,
|
|
460
|
+
TDatabase,
|
|
461
|
+
TDatabaseServiceName
|
|
430
462
|
> {
|
|
431
463
|
this._actorExtractor = extractor;
|
|
432
464
|
return this;
|
|
@@ -464,7 +496,9 @@ export class EndpointBuilder<
|
|
|
464
496
|
TAuthorizers,
|
|
465
497
|
TAuditStorage,
|
|
466
498
|
TAuditStorageServiceName,
|
|
467
|
-
T
|
|
499
|
+
T,
|
|
500
|
+
TDatabase,
|
|
501
|
+
TDatabaseServiceName
|
|
468
502
|
> {
|
|
469
503
|
this._audits = audits as unknown as MappedAudit<TAuditAction, OutSchema>[];
|
|
470
504
|
return this as unknown as EndpointBuilder<
|
|
@@ -480,7 +514,67 @@ export class EndpointBuilder<
|
|
|
480
514
|
TAuthorizers,
|
|
481
515
|
TAuditStorage,
|
|
482
516
|
TAuditStorageServiceName,
|
|
483
|
-
T
|
|
517
|
+
T,
|
|
518
|
+
TDatabase,
|
|
519
|
+
TDatabaseServiceName
|
|
520
|
+
>;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Set the database service for this endpoint.
|
|
525
|
+
* The database will be available in the handler context as `db`.
|
|
526
|
+
* When audit storage is configured and uses the same database,
|
|
527
|
+
* `db` will automatically be the transaction for ACID compliance.
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* ```typescript
|
|
531
|
+
* .database(databaseService)
|
|
532
|
+
* .handle(async ({ db }) => {
|
|
533
|
+
* // db is the raw database or transaction (when auditor uses same db)
|
|
534
|
+
* return await db.selectFrom('users').selectAll().execute();
|
|
535
|
+
* })
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
538
|
+
database<T, TName extends string>(
|
|
539
|
+
service: Service<TName, T>,
|
|
540
|
+
): EndpointBuilder<
|
|
541
|
+
TRoute,
|
|
542
|
+
TMethod,
|
|
543
|
+
TInput,
|
|
544
|
+
TServices,
|
|
545
|
+
TLogger,
|
|
546
|
+
OutSchema,
|
|
547
|
+
TSession,
|
|
548
|
+
TEventPublisher,
|
|
549
|
+
TEventPublisherServiceName,
|
|
550
|
+
TAuthorizers,
|
|
551
|
+
TAuditStorage,
|
|
552
|
+
TAuditStorageServiceName,
|
|
553
|
+
TAuditAction,
|
|
554
|
+
T,
|
|
555
|
+
TName
|
|
556
|
+
> {
|
|
557
|
+
this._databaseService = service as unknown as Service<
|
|
558
|
+
TDatabaseServiceName,
|
|
559
|
+
TDatabase
|
|
560
|
+
>;
|
|
561
|
+
|
|
562
|
+
return this as unknown as EndpointBuilder<
|
|
563
|
+
TRoute,
|
|
564
|
+
TMethod,
|
|
565
|
+
TInput,
|
|
566
|
+
TServices,
|
|
567
|
+
TLogger,
|
|
568
|
+
OutSchema,
|
|
569
|
+
TSession,
|
|
570
|
+
TEventPublisher,
|
|
571
|
+
TEventPublisherServiceName,
|
|
572
|
+
TAuthorizers,
|
|
573
|
+
TAuditStorage,
|
|
574
|
+
TAuditStorageServiceName,
|
|
575
|
+
TAuditAction,
|
|
576
|
+
T,
|
|
577
|
+
TName
|
|
484
578
|
>;
|
|
485
579
|
}
|
|
486
580
|
|
|
@@ -492,7 +586,16 @@ export class EndpointBuilder<
|
|
|
492
586
|
}
|
|
493
587
|
|
|
494
588
|
handle(
|
|
495
|
-
fn: EndpointHandler<
|
|
589
|
+
fn: EndpointHandler<
|
|
590
|
+
TInput,
|
|
591
|
+
TServices,
|
|
592
|
+
TLogger,
|
|
593
|
+
OutSchema,
|
|
594
|
+
TSession,
|
|
595
|
+
TDatabase,
|
|
596
|
+
TAuditStorage,
|
|
597
|
+
TAuditAction
|
|
598
|
+
>,
|
|
496
599
|
): Endpoint<
|
|
497
600
|
TRoute,
|
|
498
601
|
TMethod,
|
|
@@ -505,7 +608,9 @@ export class EndpointBuilder<
|
|
|
505
608
|
TEventPublisherServiceName,
|
|
506
609
|
TAuditStorage,
|
|
507
610
|
TAuditStorageServiceName,
|
|
508
|
-
TAuditAction
|
|
611
|
+
TAuditAction,
|
|
612
|
+
TDatabase,
|
|
613
|
+
TDatabaseServiceName
|
|
509
614
|
> {
|
|
510
615
|
// Find authorizer metadata if name is set
|
|
511
616
|
const authorizer = this._authorizerName
|
|
@@ -534,6 +639,7 @@ export class EndpointBuilder<
|
|
|
534
639
|
auditorStorageService: this._auditorStorage,
|
|
535
640
|
actorExtractor: this._actorExtractor,
|
|
536
641
|
audits: this._audits,
|
|
642
|
+
databaseService: this._databaseService,
|
|
537
643
|
});
|
|
538
644
|
}
|
|
539
645
|
}
|
|
@@ -264,7 +264,11 @@ export class EndpointFactory<
|
|
|
264
264
|
>,
|
|
265
265
|
defaultLogger: logger,
|
|
266
266
|
defaultSessionExtractor: this
|
|
267
|
-
.defaultSessionExtractor as unknown as SessionFn<
|
|
267
|
+
.defaultSessionExtractor as unknown as SessionFn<
|
|
268
|
+
TServices,
|
|
269
|
+
L,
|
|
270
|
+
TSession
|
|
271
|
+
>,
|
|
268
272
|
defaultEventPublisher: this.defaultEventPublisher,
|
|
269
273
|
availableAuthorizers: this.availableAuthorizers,
|
|
270
274
|
defaultAuthorizerName: this.defaultAuthorizerName,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuditStorage, AuditableAction } from '@geekmidas/audit';
|
|
2
2
|
import type { EnvironmentParser } from '@geekmidas/envkit';
|
|
3
3
|
import type { EventPublisher } from '@geekmidas/events';
|
|
4
4
|
import type { Logger } from '@geekmidas/logger';
|
|
@@ -20,7 +20,6 @@ import { getEndpointsFromRoutes } from './helpers';
|
|
|
20
20
|
import { parseHonoQuery } from './parseHonoQuery';
|
|
21
21
|
|
|
22
22
|
import { wrapError } from '@geekmidas/errors';
|
|
23
|
-
import type { InferStandardSchema } from '@geekmidas/schema';
|
|
24
23
|
import {
|
|
25
24
|
type Service,
|
|
26
25
|
ServiceDiscovery,
|
|
@@ -67,6 +66,8 @@ export class HonoEndpoint<
|
|
|
67
66
|
string,
|
|
68
67
|
unknown
|
|
69
68
|
>,
|
|
69
|
+
TDatabase = undefined,
|
|
70
|
+
TDatabaseServiceName extends string = string,
|
|
70
71
|
> {
|
|
71
72
|
constructor(
|
|
72
73
|
private readonly endpoint: Endpoint<
|
|
@@ -81,7 +82,9 @@ export class HonoEndpoint<
|
|
|
81
82
|
TEventPublisherServiceName,
|
|
82
83
|
TAuditStorage,
|
|
83
84
|
TAuditStorageServiceName,
|
|
84
|
-
TAuditAction
|
|
85
|
+
TAuditAction,
|
|
86
|
+
TDatabase,
|
|
87
|
+
TDatabaseServiceName
|
|
85
88
|
>,
|
|
86
89
|
) {}
|
|
87
90
|
|
|
@@ -241,6 +244,8 @@ export class HonoEndpoint<
|
|
|
241
244
|
string,
|
|
242
245
|
unknown
|
|
243
246
|
>,
|
|
247
|
+
TDatabase = undefined,
|
|
248
|
+
TDatabaseServiceName extends string = string,
|
|
244
249
|
>(
|
|
245
250
|
endpoint: Endpoint<
|
|
246
251
|
TRoute,
|
|
@@ -254,7 +259,9 @@ export class HonoEndpoint<
|
|
|
254
259
|
TEventPublisherServiceName,
|
|
255
260
|
TAuditStorage,
|
|
256
261
|
TAuditStorageServiceName,
|
|
257
|
-
TAuditAction
|
|
262
|
+
TAuditAction,
|
|
263
|
+
TDatabase,
|
|
264
|
+
TDatabaseServiceName
|
|
258
265
|
>,
|
|
259
266
|
serviceDiscovery: ServiceDiscovery<ServiceRecord<TServices>, TLogger>,
|
|
260
267
|
app: Hono,
|
|
@@ -356,10 +363,29 @@ export class HonoEndpoint<
|
|
|
356
363
|
logger.warn('No auditor storage service available');
|
|
357
364
|
}
|
|
358
365
|
|
|
366
|
+
// Resolve database service if configured
|
|
367
|
+
const rawDb = endpoint.databaseService
|
|
368
|
+
? await serviceDiscovery
|
|
369
|
+
.register([endpoint.databaseService])
|
|
370
|
+
.then(
|
|
371
|
+
(s) =>
|
|
372
|
+
s[endpoint.databaseService!.serviceName as keyof typeof s],
|
|
373
|
+
)
|
|
374
|
+
: undefined;
|
|
375
|
+
|
|
359
376
|
// Execute handler with automatic audit transaction support
|
|
360
377
|
const result = await executeWithAuditTransaction(
|
|
361
378
|
auditContext,
|
|
362
379
|
async (auditor) => {
|
|
380
|
+
// Use audit transaction as db only if the storage uses the same database service
|
|
381
|
+
const sameDatabase =
|
|
382
|
+
auditContext?.storage?.databaseServiceName &&
|
|
383
|
+
auditContext.storage.databaseServiceName ===
|
|
384
|
+
endpoint.databaseService?.serviceName;
|
|
385
|
+
const db = sameDatabase
|
|
386
|
+
? (auditor?.getTransaction?.() ?? rawDb)
|
|
387
|
+
: rawDb;
|
|
388
|
+
|
|
363
389
|
const responseBuilder = new ResponseBuilder();
|
|
364
390
|
const response = await endpoint.handler(
|
|
365
391
|
{
|
|
@@ -372,11 +398,15 @@ export class HonoEndpoint<
|
|
|
372
398
|
header,
|
|
373
399
|
cookie,
|
|
374
400
|
auditor,
|
|
401
|
+
db,
|
|
375
402
|
} as unknown as EndpointContext<
|
|
376
403
|
TInput,
|
|
377
404
|
TServices,
|
|
378
405
|
TLogger,
|
|
379
|
-
TSession
|
|
406
|
+
TSession,
|
|
407
|
+
TAuditAction,
|
|
408
|
+
TDatabase,
|
|
409
|
+
TAuditStorage
|
|
380
410
|
>,
|
|
381
411
|
responseBuilder,
|
|
382
412
|
);
|