@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 {
|
|
1
|
+
import type { AuditStorage, AuditableAction } from '@geekmidas/audit';
|
|
2
2
|
import { EnvironmentParser } from '@geekmidas/envkit';
|
|
3
3
|
import type { EventPublisher } from '@geekmidas/events';
|
|
4
4
|
import type { Logger } from '@geekmidas/logger';
|
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
15
15
|
import { publishConstructEvents } from '../publisher';
|
|
16
16
|
import type { HttpMethod } from '../types';
|
|
17
|
-
import type { MappedAudit } from './audit';
|
|
18
17
|
import {
|
|
19
18
|
type CookieOptions,
|
|
20
19
|
Endpoint,
|
|
21
20
|
type EndpointSchemas,
|
|
22
21
|
ResponseBuilder,
|
|
23
22
|
} from './Endpoint';
|
|
23
|
+
import type { MappedAudit } from './audit';
|
|
24
24
|
import {
|
|
25
25
|
createAuditContext,
|
|
26
26
|
executeWithAuditTransaction,
|
|
@@ -195,10 +195,29 @@ export class TestEndpointAdaptor<
|
|
|
195
195
|
logger.warn('No auditor storage service available');
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
// Resolve database service if configured
|
|
199
|
+
const rawDb = this.endpoint.databaseService
|
|
200
|
+
? await this.serviceDiscovery
|
|
201
|
+
.register([this.endpoint.databaseService])
|
|
202
|
+
.then(
|
|
203
|
+
(s) =>
|
|
204
|
+
s[this.endpoint.databaseService!.serviceName as keyof typeof s],
|
|
205
|
+
)
|
|
206
|
+
: undefined;
|
|
207
|
+
|
|
198
208
|
// Execute handler with automatic audit transaction support
|
|
199
209
|
const result = await executeWithAuditTransaction(
|
|
200
210
|
auditContext,
|
|
201
211
|
async (auditor) => {
|
|
212
|
+
// Use audit transaction as db only if the storage uses the same database service
|
|
213
|
+
const sameDatabase =
|
|
214
|
+
auditContext?.storage?.databaseServiceName &&
|
|
215
|
+
auditContext.storage.databaseServiceName ===
|
|
216
|
+
this.endpoint.databaseService?.serviceName;
|
|
217
|
+
const db = sameDatabase
|
|
218
|
+
? (auditor?.getTransaction?.() ?? rawDb)
|
|
219
|
+
: rawDb;
|
|
220
|
+
|
|
202
221
|
const responseBuilder = new ResponseBuilder();
|
|
203
222
|
const response = await this.endpoint.handler(
|
|
204
223
|
{
|
|
@@ -211,6 +230,7 @@ export class TestEndpointAdaptor<
|
|
|
211
230
|
header,
|
|
212
231
|
cookie,
|
|
213
232
|
auditor,
|
|
233
|
+
db,
|
|
214
234
|
} as any,
|
|
215
235
|
responseBuilder,
|
|
216
236
|
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
AuditableAction,
|
|
3
2
|
AuditRecord,
|
|
4
3
|
AuditStorage,
|
|
4
|
+
AuditableAction,
|
|
5
5
|
} from '@geekmidas/audit';
|
|
6
6
|
import { EnvironmentParser } from '@geekmidas/envkit';
|
|
7
7
|
import type { Logger } from '@geekmidas/logger';
|
|
8
|
-
import {
|
|
8
|
+
import { type Service, ServiceDiscovery } from '@geekmidas/services';
|
|
9
9
|
import { createMockContext, createMockV2Event } from '@geekmidas/testkit/aws';
|
|
10
10
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
11
11
|
import { z } from 'zod';
|
|
@@ -76,7 +76,7 @@ describe('AmazonApiGatewayV2Endpoint Events', () => {
|
|
|
76
76
|
services: [],
|
|
77
77
|
logger: mockLogger,
|
|
78
78
|
timeout: undefined,
|
|
79
|
-
|
|
79
|
+
memorySize: undefined,
|
|
80
80
|
status: 200,
|
|
81
81
|
getSession: undefined,
|
|
82
82
|
authorize: undefined,
|
|
@@ -152,7 +152,7 @@ describe('AmazonApiGatewayV2Endpoint Events', () => {
|
|
|
152
152
|
services: [],
|
|
153
153
|
logger: mockLogger,
|
|
154
154
|
timeout: undefined,
|
|
155
|
-
|
|
155
|
+
memorySize: undefined,
|
|
156
156
|
status: 201,
|
|
157
157
|
getSession: undefined,
|
|
158
158
|
authorize: undefined,
|
|
@@ -242,7 +242,7 @@ describe('AmazonApiGatewayV2Endpoint Events', () => {
|
|
|
242
242
|
services: [],
|
|
243
243
|
logger: mockLogger,
|
|
244
244
|
timeout: undefined,
|
|
245
|
-
|
|
245
|
+
memorySize: undefined,
|
|
246
246
|
status: 200,
|
|
247
247
|
getSession: undefined,
|
|
248
248
|
authorize: undefined,
|
|
@@ -311,7 +311,7 @@ describe('AmazonApiGatewayV2Endpoint Events', () => {
|
|
|
311
311
|
services: [],
|
|
312
312
|
logger: mockLogger,
|
|
313
313
|
timeout: undefined,
|
|
314
|
-
|
|
314
|
+
memorySize: undefined,
|
|
315
315
|
status: 200,
|
|
316
316
|
getSession: undefined,
|
|
317
317
|
authorize: undefined,
|
|
@@ -371,7 +371,7 @@ describe('AmazonApiGatewayV2Endpoint Events', () => {
|
|
|
371
371
|
services: [],
|
|
372
372
|
logger: mockLogger,
|
|
373
373
|
timeout: undefined,
|
|
374
|
-
|
|
374
|
+
memorySize: undefined,
|
|
375
375
|
status: 200,
|
|
376
376
|
getSession: undefined,
|
|
377
377
|
authorize: undefined,
|
|
@@ -441,7 +441,7 @@ describe('AmazonApiGatewayV2Endpoint Events', () => {
|
|
|
441
441
|
services: [],
|
|
442
442
|
logger: mockLogger,
|
|
443
443
|
timeout: undefined,
|
|
444
|
-
|
|
444
|
+
memorySize: undefined,
|
|
445
445
|
status: 200,
|
|
446
446
|
getSession: undefined,
|
|
447
447
|
authorize: undefined,
|
|
@@ -522,7 +522,7 @@ describe('AmazonApiGatewayV2Endpoint Events', () => {
|
|
|
522
522
|
services: [],
|
|
523
523
|
logger: mockLogger,
|
|
524
524
|
timeout: undefined,
|
|
525
|
-
|
|
525
|
+
memorySize: undefined,
|
|
526
526
|
status: 201,
|
|
527
527
|
getSession: undefined,
|
|
528
528
|
authorize: undefined,
|
|
@@ -600,7 +600,7 @@ describe('AmazonApiGatewayV2Endpoint Events', () => {
|
|
|
600
600
|
services: [],
|
|
601
601
|
logger: mockLogger,
|
|
602
602
|
timeout: undefined,
|
|
603
|
-
|
|
603
|
+
memorySize: undefined,
|
|
604
604
|
status: 200,
|
|
605
605
|
getSession: undefined,
|
|
606
606
|
authorize: undefined,
|
|
@@ -678,7 +678,7 @@ describe('AmazonApiGatewayV2Endpoint Events', () => {
|
|
|
678
678
|
services: [],
|
|
679
679
|
logger: mockLogger,
|
|
680
680
|
timeout: undefined,
|
|
681
|
-
|
|
681
|
+
memorySize: undefined,
|
|
682
682
|
status: 200,
|
|
683
683
|
getSession: undefined,
|
|
684
684
|
authorize: undefined,
|
package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AuditableAction } from '@geekmidas/audit';
|
|
2
2
|
import {
|
|
3
|
-
KyselyAuditStorage,
|
|
4
3
|
type AuditLogTable,
|
|
4
|
+
KyselyAuditStorage,
|
|
5
5
|
} from '@geekmidas/audit/kysely';
|
|
6
6
|
import { EnvironmentParser } from '@geekmidas/envkit';
|
|
7
7
|
import type { Logger } from '@geekmidas/logger';
|
|
@@ -174,7 +174,10 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
174
174
|
audits,
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
177
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
178
|
+
envParser,
|
|
179
|
+
endpoint as any,
|
|
180
|
+
);
|
|
178
181
|
const handler = adapter.handler;
|
|
179
182
|
|
|
180
183
|
const event = createMockV2Event({
|
|
@@ -252,7 +255,10 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
252
255
|
audits,
|
|
253
256
|
});
|
|
254
257
|
|
|
255
|
-
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
258
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
259
|
+
envParser,
|
|
260
|
+
endpoint as any,
|
|
261
|
+
);
|
|
256
262
|
const handler = adapter.handler;
|
|
257
263
|
|
|
258
264
|
const event = createMockV2Event({
|
|
@@ -299,15 +305,21 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
299
305
|
route: '/users',
|
|
300
306
|
method: 'POST',
|
|
301
307
|
fn: async (
|
|
302
|
-
ctx: EndpointContext<
|
|
308
|
+
ctx: EndpointContext<
|
|
309
|
+
undefined,
|
|
310
|
+
[],
|
|
311
|
+
Logger,
|
|
312
|
+
unknown,
|
|
313
|
+
TestAuditAction,
|
|
314
|
+
undefined,
|
|
315
|
+
KyselyAuditStorage<TestDatabase>
|
|
316
|
+
>,
|
|
303
317
|
) => {
|
|
304
|
-
// Manual audit in handler
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
});
|
|
310
|
-
}
|
|
318
|
+
// Manual audit in handler - auditor is guaranteed to exist when TAuditStorage is configured
|
|
319
|
+
ctx.auditor.audit('user.created', {
|
|
320
|
+
userId: 42,
|
|
321
|
+
email: 'manual@example.com',
|
|
322
|
+
});
|
|
311
323
|
|
|
312
324
|
return { id: 42, email: 'manual@example.com' };
|
|
313
325
|
},
|
|
@@ -327,7 +339,10 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
327
339
|
audits: [],
|
|
328
340
|
});
|
|
329
341
|
|
|
330
|
-
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
342
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
343
|
+
envParser,
|
|
344
|
+
endpoint as any,
|
|
345
|
+
);
|
|
331
346
|
const handler = adapter.handler;
|
|
332
347
|
|
|
333
348
|
const event = createMockV2Event({
|
|
@@ -377,15 +392,21 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
377
392
|
route: '/users',
|
|
378
393
|
method: 'POST',
|
|
379
394
|
fn: async (
|
|
380
|
-
ctx: EndpointContext<
|
|
395
|
+
ctx: EndpointContext<
|
|
396
|
+
undefined,
|
|
397
|
+
[],
|
|
398
|
+
Logger,
|
|
399
|
+
unknown,
|
|
400
|
+
TestAuditAction,
|
|
401
|
+
undefined,
|
|
402
|
+
KyselyAuditStorage<TestDatabase>
|
|
403
|
+
>,
|
|
381
404
|
) => {
|
|
382
|
-
// Manual audit before failure
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
});
|
|
388
|
-
}
|
|
405
|
+
// Manual audit before failure - auditor is guaranteed to exist
|
|
406
|
+
ctx.auditor.audit('user.created', {
|
|
407
|
+
userId: 99,
|
|
408
|
+
email: 'shouldnotexist@example.com',
|
|
409
|
+
});
|
|
389
410
|
|
|
390
411
|
// Fail after audit
|
|
391
412
|
throw new Error('Handler failed after audit');
|
|
@@ -406,7 +427,10 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
406
427
|
audits: [],
|
|
407
428
|
});
|
|
408
429
|
|
|
409
|
-
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
430
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
431
|
+
envParser,
|
|
432
|
+
endpoint as any,
|
|
433
|
+
);
|
|
410
434
|
const handler = adapter.handler;
|
|
411
435
|
|
|
412
436
|
const event = createMockV2Event({
|
|
@@ -463,7 +487,9 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
463
487
|
[typeof databaseService],
|
|
464
488
|
Logger,
|
|
465
489
|
unknown,
|
|
466
|
-
TestAuditAction
|
|
490
|
+
TestAuditAction,
|
|
491
|
+
undefined,
|
|
492
|
+
KyselyAuditStorage<TestDatabase>
|
|
467
493
|
>,
|
|
468
494
|
) => {
|
|
469
495
|
const database = ctx.services.database;
|
|
@@ -475,13 +501,11 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
475
501
|
.returningAll()
|
|
476
502
|
.executeTakeFirstOrThrow();
|
|
477
503
|
|
|
478
|
-
// Record audit
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
});
|
|
484
|
-
}
|
|
504
|
+
// Record audit - auditor is guaranteed to exist
|
|
505
|
+
ctx.auditor.audit('user.created', {
|
|
506
|
+
userId: user.id,
|
|
507
|
+
email: user.email,
|
|
508
|
+
});
|
|
485
509
|
|
|
486
510
|
return { id: user.id, email: user.email };
|
|
487
511
|
},
|
|
@@ -501,7 +525,10 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
501
525
|
audits: [],
|
|
502
526
|
});
|
|
503
527
|
|
|
504
|
-
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
528
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
529
|
+
envParser,
|
|
530
|
+
endpoint as any,
|
|
531
|
+
);
|
|
505
532
|
const handler = adapter.handler;
|
|
506
533
|
|
|
507
534
|
const event = createMockV2Event({
|
|
@@ -566,15 +593,21 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
566
593
|
route: '/users',
|
|
567
594
|
method: 'POST',
|
|
568
595
|
fn: async (
|
|
569
|
-
ctx: EndpointContext<
|
|
596
|
+
ctx: EndpointContext<
|
|
597
|
+
undefined,
|
|
598
|
+
[],
|
|
599
|
+
Logger,
|
|
600
|
+
unknown,
|
|
601
|
+
TestAuditAction,
|
|
602
|
+
undefined,
|
|
603
|
+
KyselyAuditStorage<TestDatabase>
|
|
604
|
+
>,
|
|
570
605
|
) => {
|
|
571
|
-
// Manual audit
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
});
|
|
577
|
-
}
|
|
606
|
+
// Manual audit - auditor is guaranteed to exist
|
|
607
|
+
ctx.auditor.audit('user.updated', {
|
|
608
|
+
userId: 100,
|
|
609
|
+
changes: ['verified'],
|
|
610
|
+
});
|
|
578
611
|
|
|
579
612
|
return { id: 100, email: 'combined@example.com' };
|
|
580
613
|
},
|
|
@@ -594,7 +627,10 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
594
627
|
audits,
|
|
595
628
|
});
|
|
596
629
|
|
|
597
|
-
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
630
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
631
|
+
envParser,
|
|
632
|
+
endpoint as any,
|
|
633
|
+
);
|
|
598
634
|
const handler = adapter.handler;
|
|
599
635
|
|
|
600
636
|
const event = createMockV2Event({
|
|
@@ -679,7 +715,10 @@ describe('AmazonApiGatewayV2Endpoint Kysely Audit Integration', () => {
|
|
|
679
715
|
},
|
|
680
716
|
});
|
|
681
717
|
|
|
682
|
-
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
718
|
+
const adapter = new AmazonApiGatewayV2Endpoint(
|
|
719
|
+
envParser,
|
|
720
|
+
endpoint as any,
|
|
721
|
+
);
|
|
683
722
|
const handler = adapter.handler;
|
|
684
723
|
|
|
685
724
|
const event = createMockV2Event({
|
|
@@ -163,7 +163,9 @@ describe('Endpoint.createCookies', () => {
|
|
|
163
163
|
});
|
|
164
164
|
|
|
165
165
|
it('should preserve case in cookie names when getting all', () => {
|
|
166
|
-
const cookieFn = Endpoint.createCookies(
|
|
166
|
+
const cookieFn = Endpoint.createCookies(
|
|
167
|
+
'Session=abc; session=xyz; TOKEN=123',
|
|
168
|
+
);
|
|
167
169
|
|
|
168
170
|
const allCookies = cookieFn();
|
|
169
171
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { Endpoint } from '../Endpoint';
|
|
3
4
|
import { SuccessStatus } from '../Endpoint';
|
|
4
|
-
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
describe('Endpoint manifest fields', () => {
|
|
7
7
|
it('should store timeout and memorySize', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
AuditableAction,
|
|
3
2
|
AuditRecord,
|
|
4
3
|
AuditStorage,
|
|
4
|
+
AuditableAction,
|
|
5
5
|
} from '@geekmidas/audit';
|
|
6
6
|
import type { Service } from '@geekmidas/services';
|
|
7
7
|
import { describe, expect, it } from 'vitest';
|
|
@@ -130,7 +130,10 @@ describe('EndpointBuilder audit methods', () => {
|
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
it('should allow chaining auditor and actor in any order', () => {
|
|
133
|
-
const actorExtractor: ActorExtractor = () => ({
|
|
133
|
+
const actorExtractor: ActorExtractor = () => ({
|
|
134
|
+
id: '123',
|
|
135
|
+
type: 'user',
|
|
136
|
+
});
|
|
134
137
|
|
|
135
138
|
// auditor then actor
|
|
136
139
|
const endpoint1 = new EndpointBuilder('/users', 'POST')
|
|
@@ -207,7 +210,11 @@ describe('EndpointBuilder audit methods', () => {
|
|
|
207
210
|
.output(outputSchema)
|
|
208
211
|
.auditor(auditStorageService)
|
|
209
212
|
.audit<TestAuditAction>(audits)
|
|
210
|
-
.handle(async () => ({
|
|
213
|
+
.handle(async () => ({
|
|
214
|
+
id: '123',
|
|
215
|
+
email: 'test@test.com',
|
|
216
|
+
active: true,
|
|
217
|
+
}));
|
|
211
218
|
|
|
212
219
|
expect(endpoint.audits).toBe(audits);
|
|
213
220
|
});
|
|
@@ -273,7 +280,11 @@ describe('EndpointBuilder audit methods', () => {
|
|
|
273
280
|
const endpoint = new EndpointBuilder('/users', 'POST')
|
|
274
281
|
.output(outputSchema)
|
|
275
282
|
.audit<TestAuditAction>(audits)
|
|
276
|
-
.handle(async () => ({
|
|
283
|
+
.handle(async () => ({
|
|
284
|
+
id: '123',
|
|
285
|
+
email: 'test@test.com',
|
|
286
|
+
active: true,
|
|
287
|
+
}));
|
|
277
288
|
|
|
278
289
|
// Verify the when function works
|
|
279
290
|
const whenFn = endpoint.audits[0].when!;
|
|
@@ -321,20 +332,29 @@ describe('EndpointBuilder audit methods', () => {
|
|
|
321
332
|
userId: response.id,
|
|
322
333
|
email: response.email,
|
|
323
334
|
}),
|
|
324
|
-
entityId: (response) => ({
|
|
335
|
+
entityId: (response) => ({
|
|
336
|
+
userId: response.id,
|
|
337
|
+
orgId: response.orgId,
|
|
338
|
+
}),
|
|
325
339
|
},
|
|
326
340
|
];
|
|
327
341
|
|
|
328
342
|
const endpoint = new EndpointBuilder('/users', 'POST')
|
|
329
343
|
.output(outputSchema)
|
|
330
344
|
.audit<TestAuditAction>(audits)
|
|
331
|
-
.handle(async () => ({
|
|
345
|
+
.handle(async () => ({
|
|
346
|
+
id: '123',
|
|
347
|
+
orgId: 'org-1',
|
|
348
|
+
email: 'test@test.com',
|
|
349
|
+
}));
|
|
332
350
|
|
|
333
351
|
const entityIdFn = endpoint.audits[0].entityId!;
|
|
334
|
-
expect(entityIdFn({ id: 'u-1', orgId: 'o-1', email: 'a@b.com' })).toEqual(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
352
|
+
expect(entityIdFn({ id: 'u-1', orgId: 'o-1', email: 'a@b.com' })).toEqual(
|
|
353
|
+
{
|
|
354
|
+
userId: 'u-1',
|
|
355
|
+
orgId: 'o-1',
|
|
356
|
+
},
|
|
357
|
+
);
|
|
338
358
|
});
|
|
339
359
|
});
|
|
340
360
|
|
|
@@ -370,7 +390,11 @@ describe('EndpointBuilder audit methods', () => {
|
|
|
370
390
|
.auditor(auditStorageService)
|
|
371
391
|
.actor(actorExtractor)
|
|
372
392
|
.audit<TestAuditAction>(audits)
|
|
373
|
-
.handle(async () => ({
|
|
393
|
+
.handle(async () => ({
|
|
394
|
+
id: '123',
|
|
395
|
+
email: 'test@test.com',
|
|
396
|
+
active: true,
|
|
397
|
+
}));
|
|
374
398
|
|
|
375
399
|
expect(endpoint.auditorStorageService).toBe(auditStorageService);
|
|
376
400
|
expect(endpoint.actorExtractor).toBe(actorExtractor);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { EndpointFactory } from '../EndpointFactory';
|
|
3
2
|
import { z } from 'zod';
|
|
3
|
+
import { EndpointFactory } from '../EndpointFactory';
|
|
4
4
|
|
|
5
5
|
describe('EndpointFactory.authorizers', () => {
|
|
6
6
|
it('should create factory with available authorizers', () => {
|
|
@@ -45,13 +45,17 @@ describe('EndpointFactory.authorizers', () => {
|
|
|
45
45
|
// @ts-expect-error - testing invalid authorizer
|
|
46
46
|
.authorizer('invalid')
|
|
47
47
|
.handle(async () => ({ success: true }));
|
|
48
|
-
}).toThrow(
|
|
48
|
+
}).toThrow(
|
|
49
|
+
'Authorizer "invalid" not found in available authorizers: iam, jwt',
|
|
50
|
+
);
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
it('should allow endpoints without authorizers', () => {
|
|
52
54
|
const factory = new EndpointFactory().authorizers(['iam', 'jwt'] as const);
|
|
53
55
|
|
|
54
|
-
const endpoint = factory
|
|
56
|
+
const endpoint = factory
|
|
57
|
+
.get('/public')
|
|
58
|
+
.handle(async () => ({ success: true }));
|
|
55
59
|
|
|
56
60
|
expect(endpoint.authorizer).toBeUndefined();
|
|
57
61
|
});
|
|
@@ -96,10 +100,16 @@ describe('EndpointFactory.authorizers', () => {
|
|
|
96
100
|
const factory = new EndpointFactory().authorizers(['iam', 'jwt'] as const);
|
|
97
101
|
|
|
98
102
|
// This should compile with valid authorizer
|
|
99
|
-
factory
|
|
103
|
+
factory
|
|
104
|
+
.get('/test1')
|
|
105
|
+
.authorizer('iam')
|
|
106
|
+
.handle(async () => ({}));
|
|
100
107
|
|
|
101
108
|
// This should compile with valid authorizer
|
|
102
|
-
factory
|
|
109
|
+
factory
|
|
110
|
+
.get('/test2')
|
|
111
|
+
.authorizer('jwt')
|
|
112
|
+
.handle(async () => ({}));
|
|
103
113
|
|
|
104
114
|
// This should not compile with invalid authorizer (tested via TypeScript)
|
|
105
115
|
// factory.get('/test3').authorizer('invalid').handle(async () => ({}));
|
|
@@ -142,12 +152,30 @@ describe('EndpointFactory.authorizers', () => {
|
|
|
142
152
|
it('should work with all HTTP methods', () => {
|
|
143
153
|
const factory = new EndpointFactory().authorizers(['jwt'] as const);
|
|
144
154
|
|
|
145
|
-
const getEndpoint = factory
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
155
|
+
const getEndpoint = factory
|
|
156
|
+
.get('/users')
|
|
157
|
+
.authorizer('jwt')
|
|
158
|
+
.handle(async () => ({ users: [] }));
|
|
159
|
+
const postEndpoint = factory
|
|
160
|
+
.post('/users')
|
|
161
|
+
.authorizer('jwt')
|
|
162
|
+
.handle(async () => ({ id: '1' }));
|
|
163
|
+
const putEndpoint = factory
|
|
164
|
+
.put('/users/:id')
|
|
165
|
+
.authorizer('jwt')
|
|
166
|
+
.handle(async () => ({ updated: true }));
|
|
167
|
+
const patchEndpoint = factory
|
|
168
|
+
.patch('/users/:id')
|
|
169
|
+
.authorizer('jwt')
|
|
170
|
+
.handle(async () => ({ patched: true }));
|
|
171
|
+
const deleteEndpoint = factory
|
|
172
|
+
.delete('/users/:id')
|
|
173
|
+
.authorizer('jwt')
|
|
174
|
+
.handle(async () => ({ deleted: true }));
|
|
175
|
+
const optionsEndpoint = factory
|
|
176
|
+
.options('/users')
|
|
177
|
+
.authorizer('jwt')
|
|
178
|
+
.handle(async () => ({}));
|
|
151
179
|
|
|
152
180
|
expect(getEndpoint.authorizer).toEqual({ name: 'jwt' });
|
|
153
181
|
expect(postEndpoint.authorizer).toEqual({ name: 'jwt' });
|
|
@@ -195,9 +223,18 @@ describe('EndpointFactory.authorizers', () => {
|
|
|
195
223
|
'jwt',
|
|
196
224
|
] as const);
|
|
197
225
|
|
|
198
|
-
const endpoint1 = factory
|
|
199
|
-
|
|
200
|
-
|
|
226
|
+
const endpoint1 = factory
|
|
227
|
+
.get('/user')
|
|
228
|
+
.authorizer('jwt-user')
|
|
229
|
+
.handle(async () => ({}));
|
|
230
|
+
const endpoint2 = factory
|
|
231
|
+
.get('/admin')
|
|
232
|
+
.authorizer('jwt-admin')
|
|
233
|
+
.handle(async () => ({}));
|
|
234
|
+
const endpoint3 = factory
|
|
235
|
+
.get('/api')
|
|
236
|
+
.authorizer('jwt')
|
|
237
|
+
.handle(async () => ({}));
|
|
201
238
|
|
|
202
239
|
expect(endpoint1.authorizer).toEqual({ name: 'jwt-user' });
|
|
203
240
|
expect(endpoint2.authorizer).toEqual({ name: 'jwt-admin' });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
1
|
import { ConsoleLogger } from '@geekmidas/logger/console';
|
|
3
|
-
import { EndpointFactory } from '../EndpointFactory';
|
|
4
2
|
import type { Service } from '@geekmidas/services';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { EndpointFactory } from '../EndpointFactory';
|
|
5
5
|
|
|
6
6
|
const ServiceA = {
|
|
7
7
|
serviceName: 'a' as const,
|
|
@@ -132,9 +132,9 @@ describe('EndpointFactory - Reference Sharing Audit', () => {
|
|
|
132
132
|
const builder2 = factory.post('/b');
|
|
133
133
|
|
|
134
134
|
// Function should be the same reference
|
|
135
|
-
expect(
|
|
136
|
-
|
|
137
|
-
);
|
|
135
|
+
expect(
|
|
136
|
+
(builder1 as any)._authorize === (builder2 as any)._authorize,
|
|
137
|
+
).toBe(true);
|
|
138
138
|
expect((builder1 as any)._authorize).toBe(authFn);
|
|
139
139
|
});
|
|
140
140
|
|
|
@@ -146,9 +146,9 @@ describe('EndpointFactory - Reference Sharing Audit', () => {
|
|
|
146
146
|
const builder2 = factory.post('/b');
|
|
147
147
|
|
|
148
148
|
// Function should be the same reference
|
|
149
|
-
expect(
|
|
150
|
-
|
|
151
|
-
);
|
|
149
|
+
expect(
|
|
150
|
+
(builder1 as any)._getSession === (builder2 as any)._getSession,
|
|
151
|
+
).toBe(true);
|
|
152
152
|
expect((builder1 as any)._getSession).toBe(sessionFn);
|
|
153
153
|
});
|
|
154
154
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Service } from '@geekmidas/services';
|
|
1
2
|
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { EndpointFactory } from '../EndpointFactory';
|
|
3
|
-
import type { Service } from '@geekmidas/services';
|
|
4
4
|
|
|
5
5
|
const CacheService = {
|
|
6
6
|
serviceName: 'cache' as const,
|
|
@@ -25,7 +25,10 @@ describe('EndpointFactory - State Isolation', () => {
|
|
|
25
25
|
.post('/user')
|
|
26
26
|
.handle(() => ({}));
|
|
27
27
|
|
|
28
|
-
const endpoint2 = factory
|
|
28
|
+
const endpoint2 = factory
|
|
29
|
+
.services([CacheService])
|
|
30
|
+
.get('/user')
|
|
31
|
+
.handle(() => ({}));
|
|
29
32
|
|
|
30
33
|
expect(endpoint1.services.map((s) => s.serviceName)).toEqual([
|
|
31
34
|
'cache',
|
|
@@ -92,13 +95,13 @@ describe('EndpointFactory - State Isolation', () => {
|
|
|
92
95
|
|
|
93
96
|
it('should support base router pattern with extended services', () => {
|
|
94
97
|
// Create a base router with default services
|
|
95
|
-
const r = new EndpointFactory().services([
|
|
96
|
-
CacheService,
|
|
97
|
-
DatabaseService,
|
|
98
|
-
]);
|
|
98
|
+
const r = new EndpointFactory().services([CacheService, DatabaseService]);
|
|
99
99
|
|
|
100
100
|
// Create endpoint with additional service
|
|
101
|
-
const getUsers = r
|
|
101
|
+
const getUsers = r
|
|
102
|
+
.services([CacheService])
|
|
103
|
+
.get('/users')
|
|
104
|
+
.handle(() => ({}));
|
|
102
105
|
|
|
103
106
|
// Create endpoint with just base services
|
|
104
107
|
const createUser = r.post('/users').handle(() => ({}));
|
|
@@ -125,10 +128,7 @@ describe('EndpointFactory - State Isolation', () => {
|
|
|
125
128
|
} satisfies Service<'additional', any>;
|
|
126
129
|
|
|
127
130
|
// Create a base router with default services
|
|
128
|
-
const r = new EndpointFactory().services([
|
|
129
|
-
CacheService,
|
|
130
|
-
DatabaseService,
|
|
131
|
-
]);
|
|
131
|
+
const r = new EndpointFactory().services([CacheService, DatabaseService]);
|
|
132
132
|
|
|
133
133
|
// Create endpoint with additional service
|
|
134
134
|
const getUsers = r
|