@geekmidas/constructs 0.0.1
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 +614 -0
- package/dist/AWSLambdaFunction-CpHFE2m6.d.mts +27 -0
- package/dist/AWSLambdaFunction-CwagvPG3.d.cts +27 -0
- package/dist/AWSLambdaFunction-DWIZYsCy.mjs +79 -0
- package/dist/AWSLambdaFunction-DWIZYsCy.mjs.map +1 -0
- package/dist/AWSLambdaFunction-qA5LqPsv.cjs +85 -0
- package/dist/AWSLambdaFunction-qA5LqPsv.cjs.map +1 -0
- package/dist/AWSLambdaSubscriberAdaptor-C1wQuucQ.d.mts +32 -0
- package/dist/AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs +138 -0
- package/dist/AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs.map +1 -0
- package/dist/AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs +132 -0
- package/dist/AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs.map +1 -0
- package/dist/AWSLambdaSubscriberAdaptor-QKVxR6qh.d.cts +32 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-BoBh7vvD.d.mts +61 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs +124 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs.map +1 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-DtzgQ9Vb.d.cts +61 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-i74DEUbc.cjs +130 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-i74DEUbc.cjs.map +1 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-CLmBDYsl.mjs +42 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-CLmBDYsl.mjs.map +1 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-EhMd1YqV.d.mts +21 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-GkMAUPL5.cjs +47 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-GkMAUPL5.cjs.map +1 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-Gw-j61qM.d.cts +21 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-3RqegmJC.mjs +41 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-3RqegmJC.mjs.map +1 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-LUlpwmUW.d.cts +21 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-YlFoFSS9.cjs +46 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-YlFoFSS9.cjs.map +1 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-zfd1gqXA.d.mts +21 -0
- package/dist/BaseFunctionBuilder-5QCHkchp.d.cts +31 -0
- package/dist/BaseFunctionBuilder-BFPVGnKi.d.mts +31 -0
- package/dist/BaseFunctionBuilder-BPE9JBbT.mjs +56 -0
- package/dist/BaseFunctionBuilder-BPE9JBbT.mjs.map +1 -0
- package/dist/BaseFunctionBuilder-DtO4Nwxm.cjs +62 -0
- package/dist/BaseFunctionBuilder-DtO4Nwxm.cjs.map +1 -0
- package/dist/Construct-BSEs6uwW.cjs +75 -0
- package/dist/Construct-BSEs6uwW.cjs.map +1 -0
- package/dist/Construct-BbKCIPQm.mjs +63 -0
- package/dist/Construct-BbKCIPQm.mjs.map +1 -0
- package/dist/Construct-Bm-PSO2V.d.cts +42 -0
- package/dist/Construct-DIguIyw4.d.mts +42 -0
- package/dist/Construct.cjs +4 -0
- package/dist/Construct.d.cts +2 -0
- package/dist/Construct.d.mts +2 -0
- package/dist/Construct.mjs +3 -0
- package/dist/Cron-Bgs6EQOb.mjs +20 -0
- package/dist/Cron-Bgs6EQOb.mjs.map +1 -0
- package/dist/Cron-DQiCj3ef.cjs +25 -0
- package/dist/Cron-DQiCj3ef.cjs.map +1 -0
- package/dist/Cron-FpAw03k6.d.mts +25 -0
- package/dist/Cron-ztnK6zgU.d.cts +25 -0
- package/dist/CronBuilder-B2clNQSP.d.mts +24 -0
- package/dist/CronBuilder-Cje9K8lZ.d.cts +24 -0
- package/dist/CronBuilder-DIBqJkh_.cjs +60 -0
- package/dist/CronBuilder-DIBqJkh_.cjs.map +1 -0
- package/dist/CronBuilder-DecAvvcn.mjs +54 -0
- package/dist/CronBuilder-DecAvvcn.mjs.map +1 -0
- package/dist/Endpoint-BaHC9y4Z.cjs +291 -0
- package/dist/Endpoint-BaHC9y4Z.cjs.map +1 -0
- package/dist/Endpoint-C7z9YJHK.d.cts +405 -0
- package/dist/Endpoint-DCn53Vd8.d.mts +405 -0
- package/dist/Endpoint-ierdM62O.mjs +279 -0
- package/dist/Endpoint-ierdM62O.mjs.map +1 -0
- package/dist/EndpointBuilder-BHFSpbPR.cjs +107 -0
- package/dist/EndpointBuilder-BHFSpbPR.cjs.map +1 -0
- package/dist/EndpointBuilder-BLUsoK3l.mjs +101 -0
- package/dist/EndpointBuilder-BLUsoK3l.mjs.map +1 -0
- package/dist/EndpointBuilder-Bfnb2oJr.d.mts +49 -0
- package/dist/EndpointBuilder-CP9RGwZH.d.cts +49 -0
- package/dist/EndpointFactory-BYdDVCNj.mjs +127 -0
- package/dist/EndpointFactory-BYdDVCNj.mjs.map +1 -0
- package/dist/EndpointFactory-CNtMXgIh.d.mts +52 -0
- package/dist/EndpointFactory-CXX4E6Gx.cjs +139 -0
- package/dist/EndpointFactory-CXX4E6Gx.cjs.map +1 -0
- package/dist/EndpointFactory-D2zgWbXZ.d.cts +52 -0
- package/dist/Function-BP58p9Mp.d.cts +59 -0
- package/dist/Function-BsBxc2wA.d.mts +59 -0
- package/dist/Function-C5mW-38v.mjs +72 -0
- package/dist/Function-C5mW-38v.mjs.map +1 -0
- package/dist/Function-CbO2NZx-.cjs +84 -0
- package/dist/Function-CbO2NZx-.cjs.map +1 -0
- package/dist/FunctionBuilder-BS1KgxA_.d.cts +24 -0
- package/dist/FunctionBuilder-C-PfPN3r.d.mts +24 -0
- package/dist/FunctionBuilder-CosgPmMl.mjs +53 -0
- package/dist/FunctionBuilder-CosgPmMl.mjs.map +1 -0
- package/dist/FunctionBuilder-DuOeWCAl.cjs +59 -0
- package/dist/FunctionBuilder-DuOeWCAl.cjs.map +1 -0
- package/dist/FunctionExecutionWrapper-Bx-Dl-2a.d.cts +24 -0
- package/dist/FunctionExecutionWrapper-CElXEjPe.cjs +42 -0
- package/dist/FunctionExecutionWrapper-CElXEjPe.cjs.map +1 -0
- package/dist/FunctionExecutionWrapper-DvglBBjE.d.mts +24 -0
- package/dist/FunctionExecutionWrapper-XGrSAAPD.mjs +36 -0
- package/dist/FunctionExecutionWrapper-XGrSAAPD.mjs.map +1 -0
- package/dist/HonoEndpointAdaptor-B0IO1zj2.d.mts +41 -0
- package/dist/HonoEndpointAdaptor-B4snrp7v.cjs +154 -0
- package/dist/HonoEndpointAdaptor-B4snrp7v.cjs.map +1 -0
- package/dist/HonoEndpointAdaptor-B6lW9Q1k.d.cts +41 -0
- package/dist/HonoEndpointAdaptor-D-M4-6Tf.mjs +148 -0
- package/dist/HonoEndpointAdaptor-D-M4-6Tf.mjs.map +1 -0
- package/dist/Subscriber-BoFm12i_.d.cts +33 -0
- package/dist/Subscriber-BwuCaC9G.mjs +28 -0
- package/dist/Subscriber-BwuCaC9G.mjs.map +1 -0
- package/dist/Subscriber-THGsj7Iy.d.mts +33 -0
- package/dist/Subscriber-iMRFG7ba.cjs +34 -0
- package/dist/Subscriber-iMRFG7ba.cjs.map +1 -0
- package/dist/SubscriberBuilder-CiPxgnKT.d.mts +26 -0
- package/dist/SubscriberBuilder-Dhz0C_t-.mjs +54 -0
- package/dist/SubscriberBuilder-Dhz0C_t-.mjs.map +1 -0
- package/dist/SubscriberBuilder-DuIgxuzc.d.cts +26 -0
- package/dist/SubscriberBuilder-wthr-FL9.cjs +60 -0
- package/dist/SubscriberBuilder-wthr-FL9.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +19 -0
- package/dist/adaptors/aws.d.cts +15 -0
- package/dist/adaptors/aws.d.mts +15 -0
- package/dist/adaptors/aws.mjs +16 -0
- package/dist/adaptors/hono.cjs +12 -0
- package/dist/adaptors/hono.d.cts +9 -0
- package/dist/adaptors/hono.d.mts +9 -0
- package/dist/adaptors/hono.mjs +12 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/crons/Cron.cjs +8 -0
- package/dist/crons/Cron.d.cts +7 -0
- package/dist/crons/Cron.d.mts +7 -0
- package/dist/crons/Cron.mjs +8 -0
- package/dist/crons/CronBuilder.cjs +9 -0
- package/dist/crons/CronBuilder.d.cts +8 -0
- package/dist/crons/CronBuilder.d.mts +8 -0
- package/dist/crons/CronBuilder.mjs +9 -0
- package/dist/crons/index.cjs +16 -0
- package/dist/crons/index.cjs.map +1 -0
- package/dist/crons/index.d.cts +16 -0
- package/dist/crons/index.d.mts +16 -0
- package/dist/crons/index.mjs +14 -0
- package/dist/crons/index.mjs.map +1 -0
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +10 -0
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +9 -0
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +9 -0
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +10 -0
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +12 -0
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +10 -0
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +10 -0
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +12 -0
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +12 -0
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +10 -0
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +10 -0
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +12 -0
- package/dist/endpoints/Endpoint.cjs +9 -0
- package/dist/endpoints/Endpoint.d.cts +8 -0
- package/dist/endpoints/Endpoint.d.mts +8 -0
- package/dist/endpoints/Endpoint.mjs +8 -0
- package/dist/endpoints/EndpointBuilder.cjs +9 -0
- package/dist/endpoints/EndpointBuilder.d.cts +9 -0
- package/dist/endpoints/EndpointBuilder.d.mts +9 -0
- package/dist/endpoints/EndpointBuilder.mjs +9 -0
- package/dist/endpoints/EndpointFactory.cjs +11 -0
- package/dist/endpoints/EndpointFactory.d.cts +10 -0
- package/dist/endpoints/EndpointFactory.d.mts +10 -0
- package/dist/endpoints/EndpointFactory.mjs +10 -0
- package/dist/endpoints/HonoEndpointAdaptor.cjs +12 -0
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +9 -0
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -0
- package/dist/endpoints/HonoEndpointAdaptor.mjs +12 -0
- package/dist/endpoints/TestEndpointAdaptor.cjs +54 -0
- package/dist/endpoints/TestEndpointAdaptor.cjs.map +1 -0
- package/dist/endpoints/TestEndpointAdaptor.d.cts +29 -0
- package/dist/endpoints/TestEndpointAdaptor.d.mts +29 -0
- package/dist/endpoints/TestEndpointAdaptor.mjs +53 -0
- package/dist/endpoints/TestEndpointAdaptor.mjs.map +1 -0
- package/dist/endpoints/helpers.cjs +10 -0
- package/dist/endpoints/helpers.d.cts +58 -0
- package/dist/endpoints/helpers.d.mts +58 -0
- package/dist/endpoints/helpers.mjs +9 -0
- package/dist/endpoints/index.cjs +16 -0
- package/dist/endpoints/index.cjs.map +1 -0
- package/dist/endpoints/index.d.cts +16 -0
- package/dist/endpoints/index.d.mts +16 -0
- package/dist/endpoints/index.mjs +15 -0
- package/dist/endpoints/index.mjs.map +1 -0
- package/dist/endpoints/parseHonoQuery.cjs +3 -0
- package/dist/endpoints/parseHonoQuery.d.cts +12 -0
- package/dist/endpoints/parseHonoQuery.d.mts +12 -0
- package/dist/endpoints/parseHonoQuery.mjs +3 -0
- package/dist/endpoints/parseQueryParams.cjs +3 -0
- package/dist/endpoints/parseQueryParams.d.cts +13 -0
- package/dist/endpoints/parseQueryParams.d.mts +13 -0
- package/dist/endpoints/parseQueryParams.mjs +3 -0
- package/dist/functions/AWSLambdaFunction.cjs +9 -0
- package/dist/functions/AWSLambdaFunction.d.cts +5 -0
- package/dist/functions/AWSLambdaFunction.d.mts +5 -0
- package/dist/functions/AWSLambdaFunction.mjs +9 -0
- package/dist/functions/BaseFunctionBuilder.cjs +4 -0
- package/dist/functions/BaseFunctionBuilder.d.cts +3 -0
- package/dist/functions/BaseFunctionBuilder.d.mts +3 -0
- package/dist/functions/BaseFunctionBuilder.mjs +4 -0
- package/dist/functions/Function.cjs +5 -0
- package/dist/functions/Function.d.cts +3 -0
- package/dist/functions/Function.d.mts +3 -0
- package/dist/functions/Function.mjs +4 -0
- package/dist/functions/FunctionBuilder.cjs +6 -0
- package/dist/functions/FunctionBuilder.d.cts +5 -0
- package/dist/functions/FunctionBuilder.d.mts +5 -0
- package/dist/functions/FunctionBuilder.mjs +6 -0
- package/dist/functions/FunctionExecutionWrapper.cjs +8 -0
- package/dist/functions/FunctionExecutionWrapper.d.cts +4 -0
- package/dist/functions/FunctionExecutionWrapper.d.mts +4 -0
- package/dist/functions/FunctionExecutionWrapper.mjs +8 -0
- package/dist/functions/TestFunctionAdaptor.cjs +38 -0
- package/dist/functions/TestFunctionAdaptor.cjs.map +1 -0
- package/dist/functions/TestFunctionAdaptor.d.cts +26 -0
- package/dist/functions/TestFunctionAdaptor.d.mts +26 -0
- package/dist/functions/TestFunctionAdaptor.mjs +37 -0
- package/dist/functions/TestFunctionAdaptor.mjs.map +1 -0
- package/dist/functions/index.cjs +10 -0
- package/dist/functions/index.d.cts +6 -0
- package/dist/functions/index.d.mts +6 -0
- package/dist/functions/index.mjs +7 -0
- package/dist/functions-DVDb5wEA.cjs +13 -0
- package/dist/functions-DVDb5wEA.cjs.map +1 -0
- package/dist/functions-mM-jcphA.mjs +8 -0
- package/dist/functions-mM-jcphA.mjs.map +1 -0
- package/dist/helpers-BeGM4pP_.cjs +95 -0
- package/dist/helpers-BeGM4pP_.cjs.map +1 -0
- package/dist/helpers-DbpO95aE.mjs +83 -0
- package/dist/helpers-DbpO95aE.mjs.map +1 -0
- package/dist/index-CuGR4L7O.d.mts +9 -0
- package/dist/index-Fg3N3EKD.d.cts +9 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +3 -0
- package/dist/parseHonoQuery-DopC24vB.cjs +37 -0
- package/dist/parseHonoQuery-DopC24vB.cjs.map +1 -0
- package/dist/parseHonoQuery-znDKBhdE.mjs +31 -0
- package/dist/parseHonoQuery-znDKBhdE.mjs.map +1 -0
- package/dist/parseQueryParams-BJaRh3OB.mjs +32 -0
- package/dist/parseQueryParams-BJaRh3OB.mjs.map +1 -0
- package/dist/parseQueryParams-BzPop4I1.cjs +38 -0
- package/dist/parseQueryParams-BzPop4I1.cjs.map +1 -0
- package/dist/publisher-Bw4770Hi.mjs +41 -0
- package/dist/publisher-Bw4770Hi.mjs.map +1 -0
- package/dist/publisher-lFQleddL.cjs +53 -0
- package/dist/publisher-lFQleddL.cjs.map +1 -0
- package/dist/publisher.cjs +4 -0
- package/dist/publisher.d.cts +13 -0
- package/dist/publisher.d.mts +13 -0
- package/dist/publisher.mjs +3 -0
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +3 -0
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.cts +4 -0
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +4 -0
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +3 -0
- package/dist/subscribers/Subscriber.cjs +4 -0
- package/dist/subscribers/Subscriber.d.cts +3 -0
- package/dist/subscribers/Subscriber.d.mts +3 -0
- package/dist/subscribers/Subscriber.mjs +4 -0
- package/dist/subscribers/SubscriberBuilder.cjs +5 -0
- package/dist/subscribers/SubscriberBuilder.d.cts +4 -0
- package/dist/subscribers/SubscriberBuilder.d.mts +4 -0
- package/dist/subscribers/SubscriberBuilder.mjs +5 -0
- package/dist/subscribers/index.cjs +12 -0
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +10 -0
- package/dist/subscribers/index.d.mts +10 -0
- package/dist/subscribers/index.mjs +10 -0
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/types-Bp9ysFXd.d.cts +7 -0
- package/dist/types-DBKNYvsW.d.mts +7 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +0 -0
- package/package.json +91 -0
- package/src/Construct.ts +98 -0
- package/src/__tests__/Construct.environment.spec.ts +360 -0
- package/src/__tests__/publisher.setting.spec.ts +511 -0
- package/src/__tests__/publisher.spec.ts +454 -0
- package/src/adaptors/aws.ts +4 -0
- package/src/adaptors/hono.ts +1 -0
- package/src/crons/Cron.ts +137 -0
- package/src/crons/CronBuilder.ts +192 -0
- package/src/crons/__tests__/Cron.spec.ts +464 -0
- package/src/crons/index.ts +11 -0
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +315 -0
- package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +101 -0
- package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +95 -0
- package/src/endpoints/Endpoint.ts +771 -0
- package/src/endpoints/EndpointBuilder.ts +308 -0
- package/src/endpoints/EndpointFactory.ts +329 -0
- package/src/endpoints/HonoEndpointAdaptor.ts +365 -0
- package/src/endpoints/TestEndpointAdaptor.ts +130 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +553 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +927 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +721 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +296 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +441 -0
- package/src/endpoints/__tests__/Endpoint.spec.ts +800 -0
- package/src/endpoints/__tests__/EndpointBuilder.spec.ts +488 -0
- package/src/endpoints/__tests__/EndpointFactory.spec.ts +479 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +569 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +313 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +1078 -0
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +236 -0
- package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +54 -0
- package/src/endpoints/__tests__/endpoint-types.test.ts +88 -0
- package/src/endpoints/helpers.ts +99 -0
- package/src/endpoints/index.ts +5 -0
- package/src/endpoints/parseHonoQuery.ts +51 -0
- package/src/endpoints/parseQueryParams.ts +51 -0
- package/src/functions/AWSLambdaFunction.ts +222 -0
- package/src/functions/BaseFunctionBuilder.ts +110 -0
- package/src/functions/Function.ts +160 -0
- package/src/functions/FunctionBuilder.ts +182 -0
- package/src/functions/FunctionExecutionWrapper.ts +86 -0
- package/src/functions/TestFunctionAdaptor.ts +125 -0
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +376 -0
- package/src/functions/__tests__/Function.spec.ts +402 -0
- package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +398 -0
- package/src/functions/index.ts +10 -0
- package/src/index.ts +14 -0
- package/src/publisher.ts +83 -0
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +269 -0
- package/src/subscribers/Subscriber.ts +112 -0
- package/src/subscribers/SubscriberBuilder.ts +150 -0
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +623 -0
- package/src/subscribers/__tests__/Subscriber.spec.ts +432 -0
- package/src/subscribers/index.ts +5 -0
- package/src/types.ts +13 -0
- package/tsdown.config.ts +3 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { publishConstructEvents } from "./publisher-Bw4770Hi.mjs";
|
|
2
|
+
import { Endpoint } from "./Endpoint-ierdM62O.mjs";
|
|
3
|
+
import set from "lodash.set";
|
|
4
|
+
import { UnauthorizedError, UnprocessableEntityError, wrapError } from "@geekmidas/errors";
|
|
5
|
+
import middy from "@middy/core";
|
|
6
|
+
import { ServiceDiscovery } from "@geekmidas/services";
|
|
7
|
+
|
|
8
|
+
//#region src/endpoints/AmazonApiGatewayEndpointAdaptor.ts
|
|
9
|
+
var AmazonApiGatewayEndpoint = class {
|
|
10
|
+
constructor(envParser, endpoint) {
|
|
11
|
+
this.envParser = envParser;
|
|
12
|
+
this.endpoint = endpoint;
|
|
13
|
+
}
|
|
14
|
+
error() {
|
|
15
|
+
return { onError: (req) => {
|
|
16
|
+
(req.event.logger || this.endpoint.logger).error(req.error || {}, "Error processing request");
|
|
17
|
+
const wrappedError = wrapError(req.error);
|
|
18
|
+
req.response = {
|
|
19
|
+
statusCode: wrappedError.statusCode,
|
|
20
|
+
body: wrappedError.body
|
|
21
|
+
};
|
|
22
|
+
} };
|
|
23
|
+
}
|
|
24
|
+
input() {
|
|
25
|
+
return { before: async (req) => {
|
|
26
|
+
try {
|
|
27
|
+
const { body, query, params } = this.getInput(req.event);
|
|
28
|
+
const headers = req.event.headers;
|
|
29
|
+
const header = Endpoint.createHeaders(headers);
|
|
30
|
+
set(req.event, "body", await this.endpoint.parseInput(body, "body"));
|
|
31
|
+
set(req.event, "query", await this.endpoint.parseInput(query, "query"));
|
|
32
|
+
set(req.event, "params", await this.endpoint.parseInput(params, "params"));
|
|
33
|
+
set(req.event, "header", header);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error && typeof error === "object" && Array.isArray(error)) throw new UnprocessableEntityError("Validation failed", error);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
} };
|
|
39
|
+
}
|
|
40
|
+
logger() {
|
|
41
|
+
return { before: (req) => {
|
|
42
|
+
req.event.logger = this.endpoint.logger.child({
|
|
43
|
+
route: this.endpoint.route,
|
|
44
|
+
host: req.event.headers?.host,
|
|
45
|
+
method: this.endpoint.method,
|
|
46
|
+
...this.getLoggerContext(req.event, req.context)
|
|
47
|
+
});
|
|
48
|
+
} };
|
|
49
|
+
}
|
|
50
|
+
services() {
|
|
51
|
+
return { before: async (req) => {
|
|
52
|
+
const logger = req.event.logger;
|
|
53
|
+
const serviceDiscovery = ServiceDiscovery.getInstance(logger, this.envParser);
|
|
54
|
+
const services = await serviceDiscovery.register(this.endpoint.services);
|
|
55
|
+
req.event.services = services;
|
|
56
|
+
} };
|
|
57
|
+
}
|
|
58
|
+
authorize() {
|
|
59
|
+
return { before: async (req) => {
|
|
60
|
+
const logger = req.event.logger;
|
|
61
|
+
const services = req.event.services;
|
|
62
|
+
const header = req.event.header;
|
|
63
|
+
const session = req.event.session;
|
|
64
|
+
const isAuthorized = await this.endpoint.authorize({
|
|
65
|
+
header,
|
|
66
|
+
services,
|
|
67
|
+
logger,
|
|
68
|
+
session
|
|
69
|
+
});
|
|
70
|
+
if (!isAuthorized) {
|
|
71
|
+
logger.warn("Unauthorized access attempt");
|
|
72
|
+
throw new UnauthorizedError("Unauthorized access to the endpoint", "You do not have permission to access this resource.");
|
|
73
|
+
}
|
|
74
|
+
} };
|
|
75
|
+
}
|
|
76
|
+
session() {
|
|
77
|
+
return { before: async (req) => {
|
|
78
|
+
const logger = req.event.logger;
|
|
79
|
+
const services = req.event.services;
|
|
80
|
+
req.event.session = await this.endpoint.getSession({
|
|
81
|
+
logger,
|
|
82
|
+
services,
|
|
83
|
+
header: req.event.header
|
|
84
|
+
});
|
|
85
|
+
} };
|
|
86
|
+
}
|
|
87
|
+
events() {
|
|
88
|
+
return { after: async (req) => {
|
|
89
|
+
const event = req.event;
|
|
90
|
+
const response = event.__response;
|
|
91
|
+
const statusCode = req.response?.statusCode ?? this.endpoint.status;
|
|
92
|
+
if (Endpoint.isSuccessStatus(statusCode)) {
|
|
93
|
+
const logger = event.logger;
|
|
94
|
+
const serviceDiscovery = ServiceDiscovery.getInstance(logger, this.envParser);
|
|
95
|
+
await publishConstructEvents(this.endpoint, response, serviceDiscovery, logger);
|
|
96
|
+
}
|
|
97
|
+
} };
|
|
98
|
+
}
|
|
99
|
+
async _handler(event) {
|
|
100
|
+
const input = this.endpoint.refineInput(event);
|
|
101
|
+
const response = await this.endpoint.handler({
|
|
102
|
+
header: event.header,
|
|
103
|
+
logger: event.logger,
|
|
104
|
+
services: event.services,
|
|
105
|
+
session: event.session,
|
|
106
|
+
...input
|
|
107
|
+
});
|
|
108
|
+
const output = await this.endpoint.parseOutput(response);
|
|
109
|
+
const body = output ? JSON.stringify(output) : void 0;
|
|
110
|
+
event.__response = response;
|
|
111
|
+
return {
|
|
112
|
+
statusCode: this.endpoint.status,
|
|
113
|
+
body
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
get handler() {
|
|
117
|
+
const handler = this._handler.bind(this);
|
|
118
|
+
return middy(handler).use(this.logger()).use(this.error()).use(this.services()).use(this.input()).use(this.session()).use(this.authorize()).use(this.events());
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
export { AmazonApiGatewayEndpoint };
|
|
124
|
+
//# sourceMappingURL=AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs","names":["envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName\n >","event: Event<TEvent, TInput, TServices, TLogger, TSession>"],"sources":["../src/endpoints/AmazonApiGatewayEndpointAdaptor.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { HttpMethod } from '../types';\nimport { Endpoint, type EndpointSchemas } from './Endpoint';\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport middy, { type MiddlewareObj } from '@middy/core';\nimport type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n Context,\n} from 'aws-lambda';\nimport set from 'lodash.set';\n\nimport {\n UnauthorizedError,\n UnprocessableEntityError,\n wrapError,\n} from '@geekmidas/errors';\nimport type { EventPublisher } from '@geekmidas/events';\nimport {\n type Service,\n ServiceDiscovery,\n type ServiceRecord,\n} from '@geekmidas/services';\n\nimport type {\n InferComposableStandardSchema,\n InferStandardSchema,\n} from '@geekmidas/schema';\nimport { publishConstructEvents } from '../publisher';\n\n// Helper function to publish events\n\nexport abstract class AmazonApiGatewayEndpoint<\n THandler extends\n | AmazonApiGatewayV1EndpointHandler\n | AmazonApiGatewayV2EndpointHandler,\n TEvent extends HandlerEvent<THandler>,\n TRoute extends string,\n TMethod extends HttpMethod,\n TInput extends EndpointSchemas = {},\n TOutSchema extends StandardSchemaV1 | undefined = undefined,\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TSession = unknown,\n TEventPublisher extends EventPublisher<any> | undefined = undefined,\n TEventPublisherServiceName extends string = string,\n> {\n constructor(\n protected envParser: EnvironmentParser<{}>,\n protected readonly endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName\n >,\n ) {}\n\n private error(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n onError: (req) => {\n (req.event.logger || this.endpoint.logger).error(\n req.error || {},\n 'Error processing request',\n );\n const wrappedError = wrapError(req.error);\n\n // Set the response with the proper status code from the HttpError\n req.response = {\n statusCode: wrappedError.statusCode,\n body: wrappedError.body,\n };\n },\n };\n }\n abstract getInput(e: TEvent): GetInputResponse;\n\n private input(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: async (req) => {\n try {\n const { body, query, params } = this.getInput(req.event);\n const headers = req.event.headers as Record<string, string>;\n const header = Endpoint.createHeaders(headers);\n\n set(req.event, 'body', await this.endpoint.parseInput(body, 'body'));\n\n set(\n req.event,\n 'query',\n await this.endpoint.parseInput(query, 'query'),\n );\n set(\n req.event,\n 'params',\n await this.endpoint.parseInput(params, 'params'),\n );\n set(req.event, 'header', header);\n } catch (error) {\n // Convert validation errors to 422 Unprocessable Entity\n if (error && typeof error === 'object' && Array.isArray(error)) {\n throw new UnprocessableEntityError('Validation failed', error);\n }\n throw error;\n }\n },\n };\n }\n\n abstract getLoggerContext(data: TEvent, context: Context): LoggerContext;\n\n private logger(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: (req) => {\n req.event.logger = this.endpoint.logger.child({\n route: this.endpoint.route,\n host: req.event.headers?.host,\n method: this.endpoint.method,\n ...this.getLoggerContext(req.event, req.context),\n }) as TLogger;\n },\n };\n }\n private services(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: async (req) => {\n const logger = req.event.logger as TLogger;\n const serviceDiscovery = ServiceDiscovery.getInstance<\n ServiceRecord<TServices>,\n TLogger\n >(logger, this.envParser);\n\n const services = await serviceDiscovery.register(\n this.endpoint.services,\n );\n\n req.event.services = services;\n },\n };\n }\n\n private authorize(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: async (req) => {\n const logger = req.event.logger as TLogger;\n const services = req.event.services;\n const header = req.event.header;\n const session = req.event.session as TSession;\n\n const isAuthorized = await this.endpoint.authorize({\n header,\n services,\n logger,\n session,\n });\n\n if (!isAuthorized) {\n logger.warn('Unauthorized access attempt');\n throw new UnauthorizedError(\n 'Unauthorized access to the endpoint',\n 'You do not have permission to access this resource.',\n );\n }\n },\n };\n }\n\n private session(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: async (req) => {\n const logger = req.event.logger as TLogger;\n const services = req.event.services;\n req.event.session = (await this.endpoint.getSession({\n logger,\n services,\n header: req.event.header,\n })) as TSession;\n },\n };\n }\n\n private events(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n after: async (req) => {\n const event = req.event;\n const response = (event as any)\n .__response as InferStandardSchema<TOutSchema>;\n const statusCode = req.response?.statusCode ?? this.endpoint.status;\n\n // Only publish events on successful responses (2xx status codes)\n if (Endpoint.isSuccessStatus(statusCode)) {\n const logger = event.logger as TLogger;\n const serviceDiscovery = ServiceDiscovery.getInstance<\n ServiceRecord<TServices>,\n TLogger\n >(logger, this.envParser);\n await publishConstructEvents(\n this.endpoint,\n response,\n serviceDiscovery,\n logger,\n );\n }\n },\n };\n }\n\n private async _handler(\n event: Event<TEvent, TInput, TServices, TLogger, TSession>,\n ) {\n const input = this.endpoint.refineInput(event);\n\n const response = await this.endpoint.handler({\n header: event.header,\n logger: event.logger,\n services: event.services,\n session: event.session,\n ...input,\n });\n\n const output = await this.endpoint.parseOutput(response);\n\n const body = output ? JSON.stringify(output) : undefined;\n\n // Store response for middleware access\n (event as any).__response = response;\n\n return {\n statusCode: this.endpoint.status,\n body,\n };\n }\n\n get handler() {\n const handler = this._handler.bind(this);\n return middy(handler)\n .use(this.logger())\n .use(this.error())\n .use(this.services())\n .use(this.input())\n .use(this.session())\n .use(this.authorize())\n .use(this.events()) as unknown as THandler;\n }\n}\n\nexport type Event<\n TEvent extends APIGatewayProxyEvent | APIGatewayProxyEventV2,\n TInput extends EndpointSchemas = {},\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TSession = unknown,\n> = {\n services: ServiceRecord<TServices>;\n logger: TLogger;\n header(key: string): string | undefined;\n session: TSession;\n} & TEvent &\n InferComposableStandardSchema<TInput>;\n\ntype Middleware<\n TEvent extends APIGatewayProxyEvent | APIGatewayProxyEventV2,\n TInput extends EndpointSchemas = {},\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TSession = unknown,\n> = MiddlewareObj<Event<TEvent, TInput, TServices, TLogger, TSession>>;\n\nexport type AmazonApiGatewayEndpointHandlerResponse = {\n statusCode: number;\n body: string | undefined;\n};\n\nexport type LoggerContext = {\n fn: {\n name: string;\n version: string;\n };\n req: {\n id: string | undefined;\n awsRequestId: string;\n path: string;\n ip: string | undefined;\n userAgent: string | undefined;\n };\n};\n\nexport type GetInputResponse = {\n body: any;\n query: any;\n params: any;\n};\n\nexport type AmazonApiGatewayV1EndpointHandler = (\n event: APIGatewayProxyEvent,\n context: Context,\n) => Promise<AmazonApiGatewayEndpointHandlerResponse>;\n\nexport type AmazonApiGatewayV2EndpointHandler = (\n event: APIGatewayProxyEventV2,\n context: Context,\n) => Promise<AmazonApiGatewayEndpointHandlerResponse>;\n\nexport type HandlerEvent<T extends Function> = T extends (\n event: infer E,\n context: Context,\n) => any\n ? E\n : never;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { HttpMethod } from "./types-Bp9ysFXd.cjs";
|
|
2
|
+
import { Endpoint, EndpointSchemas } from "./Endpoint-C7z9YJHK.cjs";
|
|
3
|
+
import { EventPublisher } from "@geekmidas/events";
|
|
4
|
+
import { Logger } from "@geekmidas/logger";
|
|
5
|
+
import { Service, ServiceRecord } from "@geekmidas/services";
|
|
6
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
|
+
import { InferComposableStandardSchema } from "@geekmidas/schema";
|
|
8
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
9
|
+
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, Context } from "aws-lambda";
|
|
10
|
+
|
|
11
|
+
//#region src/endpoints/AmazonApiGatewayEndpointAdaptor.d.ts
|
|
12
|
+
declare abstract class AmazonApiGatewayEndpoint<THandler extends AmazonApiGatewayV1EndpointHandler | AmazonApiGatewayV2EndpointHandler, TEvent extends HandlerEvent<THandler>, TRoute extends string, TMethod extends HttpMethod, TInput extends EndpointSchemas = {}, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TSession = unknown, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string> {
|
|
13
|
+
protected envParser: EnvironmentParser<{}>;
|
|
14
|
+
protected readonly endpoint: Endpoint<TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher, TEventPublisherServiceName>;
|
|
15
|
+
constructor(envParser: EnvironmentParser<{}>, endpoint: Endpoint<TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher, TEventPublisherServiceName>);
|
|
16
|
+
private error;
|
|
17
|
+
abstract getInput(e: TEvent): GetInputResponse;
|
|
18
|
+
private input;
|
|
19
|
+
abstract getLoggerContext(data: TEvent, context: Context): LoggerContext;
|
|
20
|
+
private logger;
|
|
21
|
+
private services;
|
|
22
|
+
private authorize;
|
|
23
|
+
private session;
|
|
24
|
+
private events;
|
|
25
|
+
private _handler;
|
|
26
|
+
get handler(): THandler;
|
|
27
|
+
}
|
|
28
|
+
type Event<TEvent extends APIGatewayProxyEvent | APIGatewayProxyEventV2, TInput extends EndpointSchemas = {}, TServices extends Service[] = [], TLogger extends Logger = Logger, TSession = unknown> = {
|
|
29
|
+
services: ServiceRecord<TServices>;
|
|
30
|
+
logger: TLogger;
|
|
31
|
+
header(key: string): string | undefined;
|
|
32
|
+
session: TSession;
|
|
33
|
+
} & TEvent & InferComposableStandardSchema<TInput>;
|
|
34
|
+
type AmazonApiGatewayEndpointHandlerResponse = {
|
|
35
|
+
statusCode: number;
|
|
36
|
+
body: string | undefined;
|
|
37
|
+
};
|
|
38
|
+
type LoggerContext = {
|
|
39
|
+
fn: {
|
|
40
|
+
name: string;
|
|
41
|
+
version: string;
|
|
42
|
+
};
|
|
43
|
+
req: {
|
|
44
|
+
id: string | undefined;
|
|
45
|
+
awsRequestId: string;
|
|
46
|
+
path: string;
|
|
47
|
+
ip: string | undefined;
|
|
48
|
+
userAgent: string | undefined;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type GetInputResponse = {
|
|
52
|
+
body: any;
|
|
53
|
+
query: any;
|
|
54
|
+
params: any;
|
|
55
|
+
};
|
|
56
|
+
type AmazonApiGatewayV1EndpointHandler = (event: APIGatewayProxyEvent, context: Context) => Promise<AmazonApiGatewayEndpointHandlerResponse>;
|
|
57
|
+
type AmazonApiGatewayV2EndpointHandler = (event: APIGatewayProxyEventV2, context: Context) => Promise<AmazonApiGatewayEndpointHandlerResponse>;
|
|
58
|
+
type HandlerEvent<T extends Function> = T extends ((event: infer E, context: Context) => any) ? E : never;
|
|
59
|
+
//#endregion
|
|
60
|
+
export { AmazonApiGatewayEndpoint, AmazonApiGatewayEndpointHandlerResponse, AmazonApiGatewayV1EndpointHandler, AmazonApiGatewayV2EndpointHandler, Event, GetInputResponse, HandlerEvent, LoggerContext };
|
|
61
|
+
//# sourceMappingURL=AmazonApiGatewayEndpointAdaptor-DtzgQ9Vb.d.cts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_publisher = require('./publisher-lFQleddL.cjs');
|
|
3
|
+
const require_Endpoint = require('./Endpoint-BaHC9y4Z.cjs');
|
|
4
|
+
const lodash_set = require_chunk.__toESM(require("lodash.set"));
|
|
5
|
+
const __geekmidas_errors = require_chunk.__toESM(require("@geekmidas/errors"));
|
|
6
|
+
const __middy_core = require_chunk.__toESM(require("@middy/core"));
|
|
7
|
+
const __geekmidas_services = require_chunk.__toESM(require("@geekmidas/services"));
|
|
8
|
+
|
|
9
|
+
//#region src/endpoints/AmazonApiGatewayEndpointAdaptor.ts
|
|
10
|
+
var AmazonApiGatewayEndpoint = class {
|
|
11
|
+
constructor(envParser, endpoint) {
|
|
12
|
+
this.envParser = envParser;
|
|
13
|
+
this.endpoint = endpoint;
|
|
14
|
+
}
|
|
15
|
+
error() {
|
|
16
|
+
return { onError: (req) => {
|
|
17
|
+
(req.event.logger || this.endpoint.logger).error(req.error || {}, "Error processing request");
|
|
18
|
+
const wrappedError = (0, __geekmidas_errors.wrapError)(req.error);
|
|
19
|
+
req.response = {
|
|
20
|
+
statusCode: wrappedError.statusCode,
|
|
21
|
+
body: wrappedError.body
|
|
22
|
+
};
|
|
23
|
+
} };
|
|
24
|
+
}
|
|
25
|
+
input() {
|
|
26
|
+
return { before: async (req) => {
|
|
27
|
+
try {
|
|
28
|
+
const { body, query, params } = this.getInput(req.event);
|
|
29
|
+
const headers = req.event.headers;
|
|
30
|
+
const header = require_Endpoint.Endpoint.createHeaders(headers);
|
|
31
|
+
(0, lodash_set.default)(req.event, "body", await this.endpoint.parseInput(body, "body"));
|
|
32
|
+
(0, lodash_set.default)(req.event, "query", await this.endpoint.parseInput(query, "query"));
|
|
33
|
+
(0, lodash_set.default)(req.event, "params", await this.endpoint.parseInput(params, "params"));
|
|
34
|
+
(0, lodash_set.default)(req.event, "header", header);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (error && typeof error === "object" && Array.isArray(error)) throw new __geekmidas_errors.UnprocessableEntityError("Validation failed", error);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
} };
|
|
40
|
+
}
|
|
41
|
+
logger() {
|
|
42
|
+
return { before: (req) => {
|
|
43
|
+
req.event.logger = this.endpoint.logger.child({
|
|
44
|
+
route: this.endpoint.route,
|
|
45
|
+
host: req.event.headers?.host,
|
|
46
|
+
method: this.endpoint.method,
|
|
47
|
+
...this.getLoggerContext(req.event, req.context)
|
|
48
|
+
});
|
|
49
|
+
} };
|
|
50
|
+
}
|
|
51
|
+
services() {
|
|
52
|
+
return { before: async (req) => {
|
|
53
|
+
const logger = req.event.logger;
|
|
54
|
+
const serviceDiscovery = __geekmidas_services.ServiceDiscovery.getInstance(logger, this.envParser);
|
|
55
|
+
const services = await serviceDiscovery.register(this.endpoint.services);
|
|
56
|
+
req.event.services = services;
|
|
57
|
+
} };
|
|
58
|
+
}
|
|
59
|
+
authorize() {
|
|
60
|
+
return { before: async (req) => {
|
|
61
|
+
const logger = req.event.logger;
|
|
62
|
+
const services = req.event.services;
|
|
63
|
+
const header = req.event.header;
|
|
64
|
+
const session = req.event.session;
|
|
65
|
+
const isAuthorized = await this.endpoint.authorize({
|
|
66
|
+
header,
|
|
67
|
+
services,
|
|
68
|
+
logger,
|
|
69
|
+
session
|
|
70
|
+
});
|
|
71
|
+
if (!isAuthorized) {
|
|
72
|
+
logger.warn("Unauthorized access attempt");
|
|
73
|
+
throw new __geekmidas_errors.UnauthorizedError("Unauthorized access to the endpoint", "You do not have permission to access this resource.");
|
|
74
|
+
}
|
|
75
|
+
} };
|
|
76
|
+
}
|
|
77
|
+
session() {
|
|
78
|
+
return { before: async (req) => {
|
|
79
|
+
const logger = req.event.logger;
|
|
80
|
+
const services = req.event.services;
|
|
81
|
+
req.event.session = await this.endpoint.getSession({
|
|
82
|
+
logger,
|
|
83
|
+
services,
|
|
84
|
+
header: req.event.header
|
|
85
|
+
});
|
|
86
|
+
} };
|
|
87
|
+
}
|
|
88
|
+
events() {
|
|
89
|
+
return { after: async (req) => {
|
|
90
|
+
const event = req.event;
|
|
91
|
+
const response = event.__response;
|
|
92
|
+
const statusCode = req.response?.statusCode ?? this.endpoint.status;
|
|
93
|
+
if (require_Endpoint.Endpoint.isSuccessStatus(statusCode)) {
|
|
94
|
+
const logger = event.logger;
|
|
95
|
+
const serviceDiscovery = __geekmidas_services.ServiceDiscovery.getInstance(logger, this.envParser);
|
|
96
|
+
await require_publisher.publishConstructEvents(this.endpoint, response, serviceDiscovery, logger);
|
|
97
|
+
}
|
|
98
|
+
} };
|
|
99
|
+
}
|
|
100
|
+
async _handler(event) {
|
|
101
|
+
const input = this.endpoint.refineInput(event);
|
|
102
|
+
const response = await this.endpoint.handler({
|
|
103
|
+
header: event.header,
|
|
104
|
+
logger: event.logger,
|
|
105
|
+
services: event.services,
|
|
106
|
+
session: event.session,
|
|
107
|
+
...input
|
|
108
|
+
});
|
|
109
|
+
const output = await this.endpoint.parseOutput(response);
|
|
110
|
+
const body = output ? JSON.stringify(output) : void 0;
|
|
111
|
+
event.__response = response;
|
|
112
|
+
return {
|
|
113
|
+
statusCode: this.endpoint.status,
|
|
114
|
+
body
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
get handler() {
|
|
118
|
+
const handler = this._handler.bind(this);
|
|
119
|
+
return (0, __middy_core.default)(handler).use(this.logger()).use(this.error()).use(this.services()).use(this.input()).use(this.session()).use(this.authorize()).use(this.events());
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
Object.defineProperty(exports, 'AmazonApiGatewayEndpoint', {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () {
|
|
127
|
+
return AmazonApiGatewayEndpoint;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=AmazonApiGatewayEndpointAdaptor-i74DEUbc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AmazonApiGatewayEndpointAdaptor-i74DEUbc.cjs","names":["envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName\n >","UnprocessableEntityError","UnauthorizedError","event: Event<TEvent, TInput, TServices, TLogger, TSession>"],"sources":["../src/endpoints/AmazonApiGatewayEndpointAdaptor.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { HttpMethod } from '../types';\nimport { Endpoint, type EndpointSchemas } from './Endpoint';\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport middy, { type MiddlewareObj } from '@middy/core';\nimport type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n Context,\n} from 'aws-lambda';\nimport set from 'lodash.set';\n\nimport {\n UnauthorizedError,\n UnprocessableEntityError,\n wrapError,\n} from '@geekmidas/errors';\nimport type { EventPublisher } from '@geekmidas/events';\nimport {\n type Service,\n ServiceDiscovery,\n type ServiceRecord,\n} from '@geekmidas/services';\n\nimport type {\n InferComposableStandardSchema,\n InferStandardSchema,\n} from '@geekmidas/schema';\nimport { publishConstructEvents } from '../publisher';\n\n// Helper function to publish events\n\nexport abstract class AmazonApiGatewayEndpoint<\n THandler extends\n | AmazonApiGatewayV1EndpointHandler\n | AmazonApiGatewayV2EndpointHandler,\n TEvent extends HandlerEvent<THandler>,\n TRoute extends string,\n TMethod extends HttpMethod,\n TInput extends EndpointSchemas = {},\n TOutSchema extends StandardSchemaV1 | undefined = undefined,\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TSession = unknown,\n TEventPublisher extends EventPublisher<any> | undefined = undefined,\n TEventPublisherServiceName extends string = string,\n> {\n constructor(\n protected envParser: EnvironmentParser<{}>,\n protected readonly endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName\n >,\n ) {}\n\n private error(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n onError: (req) => {\n (req.event.logger || this.endpoint.logger).error(\n req.error || {},\n 'Error processing request',\n );\n const wrappedError = wrapError(req.error);\n\n // Set the response with the proper status code from the HttpError\n req.response = {\n statusCode: wrappedError.statusCode,\n body: wrappedError.body,\n };\n },\n };\n }\n abstract getInput(e: TEvent): GetInputResponse;\n\n private input(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: async (req) => {\n try {\n const { body, query, params } = this.getInput(req.event);\n const headers = req.event.headers as Record<string, string>;\n const header = Endpoint.createHeaders(headers);\n\n set(req.event, 'body', await this.endpoint.parseInput(body, 'body'));\n\n set(\n req.event,\n 'query',\n await this.endpoint.parseInput(query, 'query'),\n );\n set(\n req.event,\n 'params',\n await this.endpoint.parseInput(params, 'params'),\n );\n set(req.event, 'header', header);\n } catch (error) {\n // Convert validation errors to 422 Unprocessable Entity\n if (error && typeof error === 'object' && Array.isArray(error)) {\n throw new UnprocessableEntityError('Validation failed', error);\n }\n throw error;\n }\n },\n };\n }\n\n abstract getLoggerContext(data: TEvent, context: Context): LoggerContext;\n\n private logger(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: (req) => {\n req.event.logger = this.endpoint.logger.child({\n route: this.endpoint.route,\n host: req.event.headers?.host,\n method: this.endpoint.method,\n ...this.getLoggerContext(req.event, req.context),\n }) as TLogger;\n },\n };\n }\n private services(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: async (req) => {\n const logger = req.event.logger as TLogger;\n const serviceDiscovery = ServiceDiscovery.getInstance<\n ServiceRecord<TServices>,\n TLogger\n >(logger, this.envParser);\n\n const services = await serviceDiscovery.register(\n this.endpoint.services,\n );\n\n req.event.services = services;\n },\n };\n }\n\n private authorize(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: async (req) => {\n const logger = req.event.logger as TLogger;\n const services = req.event.services;\n const header = req.event.header;\n const session = req.event.session as TSession;\n\n const isAuthorized = await this.endpoint.authorize({\n header,\n services,\n logger,\n session,\n });\n\n if (!isAuthorized) {\n logger.warn('Unauthorized access attempt');\n throw new UnauthorizedError(\n 'Unauthorized access to the endpoint',\n 'You do not have permission to access this resource.',\n );\n }\n },\n };\n }\n\n private session(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n before: async (req) => {\n const logger = req.event.logger as TLogger;\n const services = req.event.services;\n req.event.session = (await this.endpoint.getSession({\n logger,\n services,\n header: req.event.header,\n })) as TSession;\n },\n };\n }\n\n private events(): Middleware<TEvent, TInput, TServices, TLogger> {\n return {\n after: async (req) => {\n const event = req.event;\n const response = (event as any)\n .__response as InferStandardSchema<TOutSchema>;\n const statusCode = req.response?.statusCode ?? this.endpoint.status;\n\n // Only publish events on successful responses (2xx status codes)\n if (Endpoint.isSuccessStatus(statusCode)) {\n const logger = event.logger as TLogger;\n const serviceDiscovery = ServiceDiscovery.getInstance<\n ServiceRecord<TServices>,\n TLogger\n >(logger, this.envParser);\n await publishConstructEvents(\n this.endpoint,\n response,\n serviceDiscovery,\n logger,\n );\n }\n },\n };\n }\n\n private async _handler(\n event: Event<TEvent, TInput, TServices, TLogger, TSession>,\n ) {\n const input = this.endpoint.refineInput(event);\n\n const response = await this.endpoint.handler({\n header: event.header,\n logger: event.logger,\n services: event.services,\n session: event.session,\n ...input,\n });\n\n const output = await this.endpoint.parseOutput(response);\n\n const body = output ? JSON.stringify(output) : undefined;\n\n // Store response for middleware access\n (event as any).__response = response;\n\n return {\n statusCode: this.endpoint.status,\n body,\n };\n }\n\n get handler() {\n const handler = this._handler.bind(this);\n return middy(handler)\n .use(this.logger())\n .use(this.error())\n .use(this.services())\n .use(this.input())\n .use(this.session())\n .use(this.authorize())\n .use(this.events()) as unknown as THandler;\n }\n}\n\nexport type Event<\n TEvent extends APIGatewayProxyEvent | APIGatewayProxyEventV2,\n TInput extends EndpointSchemas = {},\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TSession = unknown,\n> = {\n services: ServiceRecord<TServices>;\n logger: TLogger;\n header(key: string): string | undefined;\n session: TSession;\n} & TEvent &\n InferComposableStandardSchema<TInput>;\n\ntype Middleware<\n TEvent extends APIGatewayProxyEvent | APIGatewayProxyEventV2,\n TInput extends EndpointSchemas = {},\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TSession = unknown,\n> = MiddlewareObj<Event<TEvent, TInput, TServices, TLogger, TSession>>;\n\nexport type AmazonApiGatewayEndpointHandlerResponse = {\n statusCode: number;\n body: string | undefined;\n};\n\nexport type LoggerContext = {\n fn: {\n name: string;\n version: string;\n };\n req: {\n id: string | undefined;\n awsRequestId: string;\n path: string;\n ip: string | undefined;\n userAgent: string | undefined;\n };\n};\n\nexport type GetInputResponse = {\n body: any;\n query: any;\n params: any;\n};\n\nexport type AmazonApiGatewayV1EndpointHandler = (\n event: APIGatewayProxyEvent,\n context: Context,\n) => Promise<AmazonApiGatewayEndpointHandlerResponse>;\n\nexport type AmazonApiGatewayV2EndpointHandler = (\n event: APIGatewayProxyEventV2,\n context: Context,\n) => Promise<AmazonApiGatewayEndpointHandlerResponse>;\n\nexport type HandlerEvent<T extends Function> = T extends (\n event: infer E,\n context: Context,\n) => any\n ? E\n : never;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AmazonApiGatewayEndpoint } from "./AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs";
|
|
2
|
+
import { parseQueryParams } from "./parseQueryParams-BJaRh3OB.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts
|
|
5
|
+
var AmazonApiGatewayV1Endpoint = class extends AmazonApiGatewayEndpoint {
|
|
6
|
+
getInput(e) {
|
|
7
|
+
const multiValueParams = e.multiValueQueryStringParameters || {};
|
|
8
|
+
const singleValueParams = e.queryStringParameters || {};
|
|
9
|
+
const mergedParams = {};
|
|
10
|
+
for (const [key, value] of Object.entries(singleValueParams)) if (value !== void 0) mergedParams[key] = value;
|
|
11
|
+
for (const [key, values] of Object.entries(multiValueParams)) if (values && values.length > 1) mergedParams[key] = values;
|
|
12
|
+
return {
|
|
13
|
+
body: e.body ? JSON.parse(e.body) : void 0,
|
|
14
|
+
query: parseQueryParams(mergedParams),
|
|
15
|
+
params: e.pathParameters || {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
getLoggerContext(data, context) {
|
|
19
|
+
return {
|
|
20
|
+
fn: {
|
|
21
|
+
name: context.functionName,
|
|
22
|
+
version: context.functionVersion
|
|
23
|
+
},
|
|
24
|
+
req: {
|
|
25
|
+
id: data.requestContext.requestId,
|
|
26
|
+
awsRequestId: context.awsRequestId,
|
|
27
|
+
ip: data.requestContext.identity.sourceIp,
|
|
28
|
+
userAgent: data.requestContext.identity.userAgent || void 0,
|
|
29
|
+
path: data.requestContext.path
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
constructor(envParser, endpoint) {
|
|
34
|
+
super(envParser, endpoint);
|
|
35
|
+
this.envParser = envParser;
|
|
36
|
+
this.endpoint = endpoint;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { AmazonApiGatewayV1Endpoint };
|
|
42
|
+
//# sourceMappingURL=AmazonApiGatewayV1EndpointAdaptor-CLmBDYsl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AmazonApiGatewayV1EndpointAdaptor-CLmBDYsl.mjs","names":["e: APIGatewayProxyEvent","mergedParams: Record<string, string | string[]>","data: APIGatewayProxyEvent","context: Context","envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher\n >"],"sources":["../src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { HttpMethod } from '../types';\nimport type { Endpoint, EndpointSchemas } from './Endpoint';\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { APIGatewayProxyEvent, Context } from 'aws-lambda';\n\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Service } from '@geekmidas/services';\nimport {\n AmazonApiGatewayEndpoint,\n type AmazonApiGatewayV1EndpointHandler,\n type GetInputResponse,\n type LoggerContext,\n} from './AmazonApiGatewayEndpointAdaptor';\nimport { parseQueryParams } from './parseQueryParams';\n\nexport class AmazonApiGatewayV1Endpoint<\n TRoute extends string,\n TMethod extends HttpMethod,\n TInput extends EndpointSchemas = {},\n TOutSchema extends StandardSchemaV1 | undefined = undefined,\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TSession = unknown,\n TEventPublisher extends EventPublisher<any> | undefined = undefined,\n> extends AmazonApiGatewayEndpoint<\n AmazonApiGatewayV1EndpointHandler,\n APIGatewayProxyEvent,\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher\n> {\n getInput(e: APIGatewayProxyEvent): GetInputResponse {\n // For arrays, AWS API Gateway V1 provides multiValueQueryStringParameters\n const multiValueParams = e.multiValueQueryStringParameters || {};\n const singleValueParams = e.queryStringParameters || {};\n\n // Merge single and multi-value parameters\n const mergedParams: Record<string, string | string[]> = {};\n\n // Add single value parameters\n for (const [key, value] of Object.entries(singleValueParams)) {\n if (value !== undefined) {\n mergedParams[key] = value;\n }\n }\n\n // Override with multi-value parameters where applicable\n for (const [key, values] of Object.entries(multiValueParams)) {\n if (values && values.length > 1) {\n mergedParams[key] = values;\n }\n }\n\n return {\n body: e.body ? JSON.parse(e.body) : undefined,\n query: parseQueryParams(mergedParams),\n params: e.pathParameters || {},\n };\n }\n getLoggerContext(\n data: APIGatewayProxyEvent,\n context: Context,\n ): LoggerContext {\n return {\n fn: {\n name: context.functionName,\n version: context.functionVersion,\n },\n req: {\n id: data.requestContext.requestId,\n awsRequestId: context.awsRequestId,\n ip: data.requestContext.identity.sourceIp,\n userAgent: data.requestContext.identity.userAgent || undefined,\n path: data.requestContext.path,\n },\n };\n }\n constructor(\n protected envParser: EnvironmentParser<{}>,\n protected readonly endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher\n >,\n ) {\n super(envParser, endpoint);\n }\n}\n"],"mappings":";;;;AAkBA,IAAa,6BAAb,cASU,yBAWR;CACA,SAASA,GAA2C;EAElD,MAAM,mBAAmB,EAAE,mCAAmC,CAAE;EAChE,MAAM,oBAAoB,EAAE,yBAAyB,CAAE;EAGvD,MAAMC,eAAkD,CAAE;AAG1D,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,kBAAkB,CAC1D,KAAI,iBACF,cAAa,OAAO;AAKxB,OAAK,MAAM,CAAC,KAAK,OAAO,IAAI,OAAO,QAAQ,iBAAiB,CAC1D,KAAI,UAAU,OAAO,SAAS,EAC5B,cAAa,OAAO;AAIxB,SAAO;GACL,MAAM,EAAE,OAAO,KAAK,MAAM,EAAE,KAAK;GACjC,OAAO,iBAAiB,aAAa;GACrC,QAAQ,EAAE,kBAAkB,CAAE;EAC/B;CACF;CACD,iBACEC,MACAC,SACe;AACf,SAAO;GACL,IAAI;IACF,MAAM,QAAQ;IACd,SAAS,QAAQ;GAClB;GACD,KAAK;IACH,IAAI,KAAK,eAAe;IACxB,cAAc,QAAQ;IACtB,IAAI,KAAK,eAAe,SAAS;IACjC,WAAW,KAAK,eAAe,SAAS;IACxC,MAAM,KAAK,eAAe;GAC3B;EACF;CACF;CACD,YACYC,WACSC,UAUnB;AACA,QAAM,WAAW,SAAS;EAZhB;EACS;CAYpB;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HttpMethod } from "./types-DBKNYvsW.mjs";
|
|
2
|
+
import { Endpoint, EndpointSchemas } from "./Endpoint-DCn53Vd8.mjs";
|
|
3
|
+
import { AmazonApiGatewayEndpoint, AmazonApiGatewayV1EndpointHandler, GetInputResponse, LoggerContext } from "./AmazonApiGatewayEndpointAdaptor-BoBh7vvD.mjs";
|
|
4
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
5
|
+
import { Service } from "@geekmidas/services";
|
|
6
|
+
import { EventPublisher } from "@geekmidas/events";
|
|
7
|
+
import { Logger } from "@geekmidas/logger";
|
|
8
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
9
|
+
import { APIGatewayProxyEvent, Context } from "aws-lambda";
|
|
10
|
+
|
|
11
|
+
//#region src/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.ts
|
|
12
|
+
declare class AmazonApiGatewayV1Endpoint<TRoute extends string, TMethod extends HttpMethod, TInput extends EndpointSchemas = {}, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TSession = unknown, TEventPublisher extends EventPublisher<any> | undefined = undefined> extends AmazonApiGatewayEndpoint<AmazonApiGatewayV1EndpointHandler, APIGatewayProxyEvent, TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher> {
|
|
13
|
+
protected envParser: EnvironmentParser<{}>;
|
|
14
|
+
protected readonly endpoint: Endpoint<TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher>;
|
|
15
|
+
getInput(e: APIGatewayProxyEvent): GetInputResponse;
|
|
16
|
+
getLoggerContext(data: APIGatewayProxyEvent, context: Context): LoggerContext;
|
|
17
|
+
constructor(envParser: EnvironmentParser<{}>, endpoint: Endpoint<TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher>);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { AmazonApiGatewayV1Endpoint };
|
|
21
|
+
//# sourceMappingURL=AmazonApiGatewayV1EndpointAdaptor-EhMd1YqV.d.mts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const require_AmazonApiGatewayEndpointAdaptor = require('./AmazonApiGatewayEndpointAdaptor-i74DEUbc.cjs');
|
|
2
|
+
const require_parseQueryParams = require('./parseQueryParams-BzPop4I1.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts
|
|
5
|
+
var AmazonApiGatewayV1Endpoint = class extends require_AmazonApiGatewayEndpointAdaptor.AmazonApiGatewayEndpoint {
|
|
6
|
+
getInput(e) {
|
|
7
|
+
const multiValueParams = e.multiValueQueryStringParameters || {};
|
|
8
|
+
const singleValueParams = e.queryStringParameters || {};
|
|
9
|
+
const mergedParams = {};
|
|
10
|
+
for (const [key, value] of Object.entries(singleValueParams)) if (value !== void 0) mergedParams[key] = value;
|
|
11
|
+
for (const [key, values] of Object.entries(multiValueParams)) if (values && values.length > 1) mergedParams[key] = values;
|
|
12
|
+
return {
|
|
13
|
+
body: e.body ? JSON.parse(e.body) : void 0,
|
|
14
|
+
query: require_parseQueryParams.parseQueryParams(mergedParams),
|
|
15
|
+
params: e.pathParameters || {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
getLoggerContext(data, context) {
|
|
19
|
+
return {
|
|
20
|
+
fn: {
|
|
21
|
+
name: context.functionName,
|
|
22
|
+
version: context.functionVersion
|
|
23
|
+
},
|
|
24
|
+
req: {
|
|
25
|
+
id: data.requestContext.requestId,
|
|
26
|
+
awsRequestId: context.awsRequestId,
|
|
27
|
+
ip: data.requestContext.identity.sourceIp,
|
|
28
|
+
userAgent: data.requestContext.identity.userAgent || void 0,
|
|
29
|
+
path: data.requestContext.path
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
constructor(envParser, endpoint) {
|
|
34
|
+
super(envParser, endpoint);
|
|
35
|
+
this.envParser = envParser;
|
|
36
|
+
this.endpoint = endpoint;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
Object.defineProperty(exports, 'AmazonApiGatewayV1Endpoint', {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () {
|
|
44
|
+
return AmazonApiGatewayV1Endpoint;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=AmazonApiGatewayV1EndpointAdaptor-GkMAUPL5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AmazonApiGatewayV1EndpointAdaptor-GkMAUPL5.cjs","names":["AmazonApiGatewayEndpoint","e: APIGatewayProxyEvent","mergedParams: Record<string, string | string[]>","data: APIGatewayProxyEvent","context: Context","envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher\n >"],"sources":["../src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { HttpMethod } from '../types';\nimport type { Endpoint, EndpointSchemas } from './Endpoint';\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { APIGatewayProxyEvent, Context } from 'aws-lambda';\n\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Service } from '@geekmidas/services';\nimport {\n AmazonApiGatewayEndpoint,\n type AmazonApiGatewayV1EndpointHandler,\n type GetInputResponse,\n type LoggerContext,\n} from './AmazonApiGatewayEndpointAdaptor';\nimport { parseQueryParams } from './parseQueryParams';\n\nexport class AmazonApiGatewayV1Endpoint<\n TRoute extends string,\n TMethod extends HttpMethod,\n TInput extends EndpointSchemas = {},\n TOutSchema extends StandardSchemaV1 | undefined = undefined,\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TSession = unknown,\n TEventPublisher extends EventPublisher<any> | undefined = undefined,\n> extends AmazonApiGatewayEndpoint<\n AmazonApiGatewayV1EndpointHandler,\n APIGatewayProxyEvent,\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher\n> {\n getInput(e: APIGatewayProxyEvent): GetInputResponse {\n // For arrays, AWS API Gateway V1 provides multiValueQueryStringParameters\n const multiValueParams = e.multiValueQueryStringParameters || {};\n const singleValueParams = e.queryStringParameters || {};\n\n // Merge single and multi-value parameters\n const mergedParams: Record<string, string | string[]> = {};\n\n // Add single value parameters\n for (const [key, value] of Object.entries(singleValueParams)) {\n if (value !== undefined) {\n mergedParams[key] = value;\n }\n }\n\n // Override with multi-value parameters where applicable\n for (const [key, values] of Object.entries(multiValueParams)) {\n if (values && values.length > 1) {\n mergedParams[key] = values;\n }\n }\n\n return {\n body: e.body ? JSON.parse(e.body) : undefined,\n query: parseQueryParams(mergedParams),\n params: e.pathParameters || {},\n };\n }\n getLoggerContext(\n data: APIGatewayProxyEvent,\n context: Context,\n ): LoggerContext {\n return {\n fn: {\n name: context.functionName,\n version: context.functionVersion,\n },\n req: {\n id: data.requestContext.requestId,\n awsRequestId: context.awsRequestId,\n ip: data.requestContext.identity.sourceIp,\n userAgent: data.requestContext.identity.userAgent || undefined,\n path: data.requestContext.path,\n },\n };\n }\n constructor(\n protected envParser: EnvironmentParser<{}>,\n protected readonly endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher\n >,\n ) {\n super(envParser, endpoint);\n }\n}\n"],"mappings":";;;;AAkBA,IAAa,6BAAb,cASUA,iEAWR;CACA,SAASC,GAA2C;EAElD,MAAM,mBAAmB,EAAE,mCAAmC,CAAE;EAChE,MAAM,oBAAoB,EAAE,yBAAyB,CAAE;EAGvD,MAAMC,eAAkD,CAAE;AAG1D,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,kBAAkB,CAC1D,KAAI,iBACF,cAAa,OAAO;AAKxB,OAAK,MAAM,CAAC,KAAK,OAAO,IAAI,OAAO,QAAQ,iBAAiB,CAC1D,KAAI,UAAU,OAAO,SAAS,EAC5B,cAAa,OAAO;AAIxB,SAAO;GACL,MAAM,EAAE,OAAO,KAAK,MAAM,EAAE,KAAK;GACjC,OAAO,0CAAiB,aAAa;GACrC,QAAQ,EAAE,kBAAkB,CAAE;EAC/B;CACF;CACD,iBACEC,MACAC,SACe;AACf,SAAO;GACL,IAAI;IACF,MAAM,QAAQ;IACd,SAAS,QAAQ;GAClB;GACD,KAAK;IACH,IAAI,KAAK,eAAe;IACxB,cAAc,QAAQ;IACtB,IAAI,KAAK,eAAe,SAAS;IACjC,WAAW,KAAK,eAAe,SAAS;IACxC,MAAM,KAAK,eAAe;GAC3B;EACF;CACF;CACD,YACYC,WACSC,UAUnB;AACA,QAAM,WAAW,SAAS;EAZhB;EACS;CAYpB;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HttpMethod } from "./types-Bp9ysFXd.cjs";
|
|
2
|
+
import { Endpoint, EndpointSchemas } from "./Endpoint-C7z9YJHK.cjs";
|
|
3
|
+
import { AmazonApiGatewayEndpoint, AmazonApiGatewayV1EndpointHandler, GetInputResponse, LoggerContext } from "./AmazonApiGatewayEndpointAdaptor-DtzgQ9Vb.cjs";
|
|
4
|
+
import { EventPublisher } from "@geekmidas/events";
|
|
5
|
+
import { Logger } from "@geekmidas/logger";
|
|
6
|
+
import { Service } from "@geekmidas/services";
|
|
7
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
8
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
9
|
+
import { APIGatewayProxyEvent, Context } from "aws-lambda";
|
|
10
|
+
|
|
11
|
+
//#region src/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.ts
|
|
12
|
+
declare class AmazonApiGatewayV1Endpoint<TRoute extends string, TMethod extends HttpMethod, TInput extends EndpointSchemas = {}, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TSession = unknown, TEventPublisher extends EventPublisher<any> | undefined = undefined> extends AmazonApiGatewayEndpoint<AmazonApiGatewayV1EndpointHandler, APIGatewayProxyEvent, TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher> {
|
|
13
|
+
protected envParser: EnvironmentParser<{}>;
|
|
14
|
+
protected readonly endpoint: Endpoint<TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher>;
|
|
15
|
+
getInput(e: APIGatewayProxyEvent): GetInputResponse;
|
|
16
|
+
getLoggerContext(data: APIGatewayProxyEvent, context: Context): LoggerContext;
|
|
17
|
+
constructor(envParser: EnvironmentParser<{}>, endpoint: Endpoint<TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher>);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { AmazonApiGatewayV1Endpoint };
|
|
21
|
+
//# sourceMappingURL=AmazonApiGatewayV1EndpointAdaptor-Gw-j61qM.d.cts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AmazonApiGatewayEndpoint } from "./AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs";
|
|
2
|
+
import { parseQueryParams } from "./parseQueryParams-BJaRh3OB.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts
|
|
5
|
+
var AmazonApiGatewayV2Endpoint = class extends AmazonApiGatewayEndpoint {
|
|
6
|
+
getInput(e) {
|
|
7
|
+
const queryParams = e.queryStringParameters || {};
|
|
8
|
+
const processedParams = {};
|
|
9
|
+
for (const [key, value] of Object.entries(queryParams)) if (value !== void 0) if (value.includes(",") && !value.includes("\"")) processedParams[key] = value.split(",").map((v) => v.trim());
|
|
10
|
+
else processedParams[key] = value;
|
|
11
|
+
return {
|
|
12
|
+
body: e.body ? JSON.parse(e.body) : void 0,
|
|
13
|
+
query: parseQueryParams(processedParams),
|
|
14
|
+
params: e.pathParameters || {}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
getLoggerContext(event, context) {
|
|
18
|
+
return {
|
|
19
|
+
fn: {
|
|
20
|
+
name: context.functionName,
|
|
21
|
+
version: context.functionVersion
|
|
22
|
+
},
|
|
23
|
+
req: {
|
|
24
|
+
id: event.requestContext.requestId,
|
|
25
|
+
awsRequestId: context.awsRequestId,
|
|
26
|
+
ip: event.requestContext.http.sourceIp,
|
|
27
|
+
userAgent: event.requestContext.http.userAgent || void 0,
|
|
28
|
+
path: event.requestContext.http.path
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
constructor(envParser, endpoint) {
|
|
33
|
+
super(envParser, endpoint);
|
|
34
|
+
this.envParser = envParser;
|
|
35
|
+
this.endpoint = endpoint;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { AmazonApiGatewayV2Endpoint };
|
|
41
|
+
//# sourceMappingURL=AmazonApiGatewayV2EndpointAdaptor-3RqegmJC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AmazonApiGatewayV2EndpointAdaptor-3RqegmJC.mjs","names":["e: APIGatewayProxyEventV2","processedParams: Record<string, string | string[]>","event: APIGatewayProxyEventV2","context: Context","envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher\n >"],"sources":["../src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { HttpMethod } from '../types';\nimport type { Endpoint, EndpointSchemas } from './Endpoint';\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Service } from '@geekmidas/services';\nimport type { APIGatewayProxyEventV2, Context } from 'aws-lambda';\nimport {\n AmazonApiGatewayEndpoint,\n type AmazonApiGatewayV2EndpointHandler,\n type GetInputResponse,\n type LoggerContext,\n} from './AmazonApiGatewayEndpointAdaptor';\nimport { parseQueryParams } from './parseQueryParams';\n\nexport class AmazonApiGatewayV2Endpoint<\n TRoute extends string,\n TMethod extends HttpMethod,\n TInput extends EndpointSchemas = {},\n TOutSchema extends StandardSchemaV1 | undefined = undefined,\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TSession = unknown,\n TEventPublisher extends EventPublisher<any> | undefined = undefined,\n> extends AmazonApiGatewayEndpoint<\n AmazonApiGatewayV2EndpointHandler,\n APIGatewayProxyEventV2,\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher\n> {\n getInput(e: APIGatewayProxyEventV2): GetInputResponse {\n // API Gateway V2 handles arrays as comma-separated values\n const queryParams = e.queryStringParameters || {};\n const processedParams: Record<string, string | string[]> = {};\n\n for (const [key, value] of Object.entries(queryParams)) {\n if (value !== undefined) {\n // Check if value contains comma and could be an array\n // Be careful not to split values that legitimately contain commas\n if (value.includes(',') && !value.includes('\"')) {\n processedParams[key] = value.split(',').map((v) => v.trim());\n } else {\n processedParams[key] = value;\n }\n }\n }\n\n return {\n body: e.body ? JSON.parse(e.body) : undefined,\n query: parseQueryParams(processedParams),\n params: e.pathParameters || {},\n };\n }\n getLoggerContext(\n event: APIGatewayProxyEventV2,\n context: Context,\n ): LoggerContext {\n return {\n fn: {\n name: context.functionName,\n version: context.functionVersion,\n },\n req: {\n id: event.requestContext.requestId,\n awsRequestId: context.awsRequestId,\n ip: event.requestContext.http.sourceIp,\n userAgent: event.requestContext.http.userAgent || undefined,\n path: event.requestContext.http.path,\n },\n };\n }\n constructor(\n protected envParser: EnvironmentParser<{}>,\n protected readonly endpoint: Endpoint<\n TRoute,\n TMethod,\n TInput,\n TOutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher\n >,\n ) {\n super(envParser, endpoint);\n }\n}\n"],"mappings":";;;;AAiBA,IAAa,6BAAb,cASU,yBAWR;CACA,SAASA,GAA6C;EAEpD,MAAM,cAAc,EAAE,yBAAyB,CAAE;EACjD,MAAMC,kBAAqD,CAAE;AAE7D,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,YAAY,CACpD,KAAI,iBAGF,KAAI,MAAM,SAAS,IAAI,KAAK,MAAM,SAAS,KAAI,CAC7C,iBAAgB,OAAO,MAAM,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;MAE5D,iBAAgB,OAAO;AAK7B,SAAO;GACL,MAAM,EAAE,OAAO,KAAK,MAAM,EAAE,KAAK;GACjC,OAAO,iBAAiB,gBAAgB;GACxC,QAAQ,EAAE,kBAAkB,CAAE;EAC/B;CACF;CACD,iBACEC,OACAC,SACe;AACf,SAAO;GACL,IAAI;IACF,MAAM,QAAQ;IACd,SAAS,QAAQ;GAClB;GACD,KAAK;IACH,IAAI,MAAM,eAAe;IACzB,cAAc,QAAQ;IACtB,IAAI,MAAM,eAAe,KAAK;IAC9B,WAAW,MAAM,eAAe,KAAK;IACrC,MAAM,MAAM,eAAe,KAAK;GACjC;EACF;CACF;CACD,YACYC,WACSC,UAUnB;AACA,QAAM,WAAW,SAAS;EAZhB;EACS;CAYpB;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HttpMethod } from "./types-Bp9ysFXd.cjs";
|
|
2
|
+
import { Endpoint, EndpointSchemas } from "./Endpoint-C7z9YJHK.cjs";
|
|
3
|
+
import { AmazonApiGatewayEndpoint, AmazonApiGatewayV2EndpointHandler, GetInputResponse, LoggerContext } from "./AmazonApiGatewayEndpointAdaptor-DtzgQ9Vb.cjs";
|
|
4
|
+
import { EventPublisher } from "@geekmidas/events";
|
|
5
|
+
import { Logger } from "@geekmidas/logger";
|
|
6
|
+
import { Service } from "@geekmidas/services";
|
|
7
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
8
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
9
|
+
import { APIGatewayProxyEventV2, Context } from "aws-lambda";
|
|
10
|
+
|
|
11
|
+
//#region src/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.ts
|
|
12
|
+
declare class AmazonApiGatewayV2Endpoint<TRoute extends string, TMethod extends HttpMethod, TInput extends EndpointSchemas = {}, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TSession = unknown, TEventPublisher extends EventPublisher<any> | undefined = undefined> extends AmazonApiGatewayEndpoint<AmazonApiGatewayV2EndpointHandler, APIGatewayProxyEventV2, TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher> {
|
|
13
|
+
protected envParser: EnvironmentParser<{}>;
|
|
14
|
+
protected readonly endpoint: Endpoint<TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher>;
|
|
15
|
+
getInput(e: APIGatewayProxyEventV2): GetInputResponse;
|
|
16
|
+
getLoggerContext(event: APIGatewayProxyEventV2, context: Context): LoggerContext;
|
|
17
|
+
constructor(envParser: EnvironmentParser<{}>, endpoint: Endpoint<TRoute, TMethod, TInput, TOutSchema, TServices, TLogger, TSession, TEventPublisher>);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { AmazonApiGatewayV2Endpoint };
|
|
21
|
+
//# sourceMappingURL=AmazonApiGatewayV2EndpointAdaptor-LUlpwmUW.d.cts.map
|