@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,296 @@
|
|
|
1
|
+
import { EnvironmentParser } from '@geekmidas/envkit';
|
|
2
|
+
import type { EventPublisher, PublishableMessage } from '@geekmidas/events';
|
|
3
|
+
import type { Logger } from '@geekmidas/logger';
|
|
4
|
+
import type { Service } from '@geekmidas/services';
|
|
5
|
+
import { createMockContext, createMockV2Event } from '@geekmidas/testkit/aws';
|
|
6
|
+
import { createMockLogger } from '@geekmidas/testkit/logger';
|
|
7
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { AmazonApiGatewayV2Endpoint } from '../AmazonApiGatewayV2EndpointAdaptor';
|
|
10
|
+
import { e } from '../EndpointFactory';
|
|
11
|
+
|
|
12
|
+
// Test event types
|
|
13
|
+
type TestEvent =
|
|
14
|
+
| PublishableMessage<'user.created', { userId: string; email: string }>
|
|
15
|
+
| PublishableMessage<'user.updated', { userId: string; changes: string[] }>;
|
|
16
|
+
|
|
17
|
+
describe('AmazonApiGatewayV2Endpoint Factory Publisher Pattern', () => {
|
|
18
|
+
let mockLogger: Logger;
|
|
19
|
+
let envParser: EnvironmentParser<{}>;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
vi.clearAllMocks();
|
|
23
|
+
mockLogger = createMockLogger();
|
|
24
|
+
envParser = new EnvironmentParser({});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should publish events when using factory.publisher() pattern', async () => {
|
|
28
|
+
// Create mock publisher exactly as user would
|
|
29
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
30
|
+
publish: vi.fn().mockResolvedValue(undefined),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const EventsService: Service<'EventsService', EventPublisher<TestEvent>> = {
|
|
34
|
+
serviceName: 'EventsService' as const,
|
|
35
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Create factory with publisher exactly as user described
|
|
39
|
+
const r = e.logger(mockLogger).services([]).publisher(EventsService);
|
|
40
|
+
|
|
41
|
+
// Create endpoint from factory
|
|
42
|
+
const endpoint = r
|
|
43
|
+
.post('/orders')
|
|
44
|
+
.body(z.object({ productId: z.string(), quantity: z.number() }))
|
|
45
|
+
.output(z.object({ orderId: z.string(), amount: z.number() }))
|
|
46
|
+
.event({
|
|
47
|
+
type: 'user.created',
|
|
48
|
+
payload: (response) => ({
|
|
49
|
+
userId: response.orderId,
|
|
50
|
+
email: `order-${response.orderId}@example.com`,
|
|
51
|
+
}),
|
|
52
|
+
})
|
|
53
|
+
.handle(async () => ({
|
|
54
|
+
orderId: 'order-123',
|
|
55
|
+
amount: 99.99,
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
// Verify publisher is set on endpoint
|
|
59
|
+
expect(endpoint.publisherService).toBeDefined();
|
|
60
|
+
expect(endpoint.publisherService?.serviceName).toBe('EventsService');
|
|
61
|
+
|
|
62
|
+
// Create adapter and test
|
|
63
|
+
const adapter = new AmazonApiGatewayV2Endpoint(envParser, endpoint);
|
|
64
|
+
const handler = adapter.handler;
|
|
65
|
+
|
|
66
|
+
const event = createMockV2Event({
|
|
67
|
+
requestContext: {
|
|
68
|
+
...createMockV2Event().requestContext,
|
|
69
|
+
http: {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
path: '/orders',
|
|
72
|
+
protocol: 'HTTP/1.1',
|
|
73
|
+
sourceIp: '127.0.0.1',
|
|
74
|
+
userAgent: 'test-agent',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify({ productId: 'prod-456', quantity: 2 }),
|
|
78
|
+
});
|
|
79
|
+
const context = createMockContext();
|
|
80
|
+
|
|
81
|
+
const response = await handler(event, context);
|
|
82
|
+
|
|
83
|
+
// Verify successful response
|
|
84
|
+
expect(response.statusCode).toBe(200);
|
|
85
|
+
expect(response.body).toBe(
|
|
86
|
+
JSON.stringify({ orderId: 'order-123', amount: 99.99 }),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Verify publisher was called correctly
|
|
90
|
+
expect(EventsService.register).toHaveBeenCalled();
|
|
91
|
+
expect(mockPublisher.publish).toHaveBeenCalledWith([
|
|
92
|
+
{
|
|
93
|
+
type: 'user.created',
|
|
94
|
+
payload: {
|
|
95
|
+
userId: 'order-123',
|
|
96
|
+
email: 'order-order-123@example.com',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should handle factory publisher with conditional events', async () => {
|
|
103
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
104
|
+
publish: vi.fn().mockResolvedValue(undefined),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const ConditionalEventsService: Service<
|
|
108
|
+
'ConditionalEventsService',
|
|
109
|
+
EventPublisher<TestEvent>
|
|
110
|
+
> = {
|
|
111
|
+
serviceName: 'ConditionalEventsService' as const,
|
|
112
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const factory = e.logger(mockLogger).publisher(ConditionalEventsService);
|
|
116
|
+
|
|
117
|
+
const endpoint = factory
|
|
118
|
+
.put('/orders/:id')
|
|
119
|
+
.params(z.object({ id: z.string() }))
|
|
120
|
+
.body(z.object({ status: z.enum(['pending', 'completed', 'cancelled']) }))
|
|
121
|
+
.output(
|
|
122
|
+
z.object({
|
|
123
|
+
orderId: z.string(),
|
|
124
|
+
status: z.string(),
|
|
125
|
+
isNew: z.boolean(),
|
|
126
|
+
}),
|
|
127
|
+
)
|
|
128
|
+
.event({
|
|
129
|
+
type: 'user.created',
|
|
130
|
+
payload: (response) => ({
|
|
131
|
+
userId: response.orderId,
|
|
132
|
+
email: `new-${response.orderId}@example.com`,
|
|
133
|
+
}),
|
|
134
|
+
when: (response) => response.isNew === true,
|
|
135
|
+
})
|
|
136
|
+
.event({
|
|
137
|
+
type: 'user.updated',
|
|
138
|
+
payload: (response) => ({
|
|
139
|
+
userId: response.orderId,
|
|
140
|
+
changes: ['status'],
|
|
141
|
+
}),
|
|
142
|
+
when: (response) => response.isNew === false,
|
|
143
|
+
})
|
|
144
|
+
.handle(async ({ params }) => ({
|
|
145
|
+
orderId: params.id,
|
|
146
|
+
status: 'completed',
|
|
147
|
+
isNew: false, // Existing order
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
const adapter = new AmazonApiGatewayV2Endpoint(envParser, endpoint);
|
|
151
|
+
const handler = adapter.handler;
|
|
152
|
+
|
|
153
|
+
const event = createMockV2Event({
|
|
154
|
+
requestContext: {
|
|
155
|
+
...createMockV2Event().requestContext,
|
|
156
|
+
http: {
|
|
157
|
+
method: 'PUT',
|
|
158
|
+
path: '/orders/order-789',
|
|
159
|
+
protocol: 'HTTP/1.1',
|
|
160
|
+
sourceIp: '127.0.0.1',
|
|
161
|
+
userAgent: 'test-agent',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
pathParameters: { id: 'order-789' },
|
|
165
|
+
body: JSON.stringify({ status: 'completed' }),
|
|
166
|
+
});
|
|
167
|
+
const context = createMockContext();
|
|
168
|
+
|
|
169
|
+
const response = await handler(event, context);
|
|
170
|
+
|
|
171
|
+
// Should succeed
|
|
172
|
+
expect(response.statusCode).toBe(200);
|
|
173
|
+
|
|
174
|
+
// Only user.updated should be published (isNew = false)
|
|
175
|
+
expect(mockPublisher.publish).toHaveBeenCalledWith([
|
|
176
|
+
{
|
|
177
|
+
type: 'user.updated',
|
|
178
|
+
payload: { userId: 'order-789', changes: ['status'] },
|
|
179
|
+
},
|
|
180
|
+
]);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should work with multiple factory publisher endpoints', async () => {
|
|
184
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
185
|
+
publish: vi.fn().mockResolvedValue(undefined),
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const SharedEventsService: Service<
|
|
189
|
+
'SharedEventsService',
|
|
190
|
+
EventPublisher<TestEvent>
|
|
191
|
+
> = {
|
|
192
|
+
serviceName: 'SharedEventsService' as const,
|
|
193
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// Create shared factory
|
|
197
|
+
const factory = e.logger(mockLogger).publisher(SharedEventsService);
|
|
198
|
+
|
|
199
|
+
// Create multiple endpoints from same factory
|
|
200
|
+
const createEndpoint = factory
|
|
201
|
+
.post('/orders')
|
|
202
|
+
.output(z.object({ orderId: z.string() }))
|
|
203
|
+
.event({
|
|
204
|
+
type: 'user.created',
|
|
205
|
+
payload: (response) => ({
|
|
206
|
+
userId: response.orderId,
|
|
207
|
+
email: 'create@example.com',
|
|
208
|
+
}),
|
|
209
|
+
})
|
|
210
|
+
.handle(async () => ({ orderId: 'create-order' }));
|
|
211
|
+
|
|
212
|
+
const updateEndpoint = factory
|
|
213
|
+
.put('/orders/:id')
|
|
214
|
+
.params(z.object({ id: z.string() }))
|
|
215
|
+
.output(z.object({ orderId: z.string() }))
|
|
216
|
+
.event({
|
|
217
|
+
type: 'user.updated',
|
|
218
|
+
payload: (response) => ({
|
|
219
|
+
userId: response.orderId,
|
|
220
|
+
changes: ['status'],
|
|
221
|
+
}),
|
|
222
|
+
})
|
|
223
|
+
.handle(async ({ params }) => ({ orderId: params.id }));
|
|
224
|
+
|
|
225
|
+
// Both endpoints should have the shared publisher
|
|
226
|
+
expect(createEndpoint.publisherService?.serviceName).toBe(
|
|
227
|
+
'SharedEventsService',
|
|
228
|
+
);
|
|
229
|
+
expect(updateEndpoint.publisherService?.serviceName).toBe(
|
|
230
|
+
'SharedEventsService',
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
// Test create endpoint
|
|
234
|
+
const createAdapter = new AmazonApiGatewayV2Endpoint(
|
|
235
|
+
envParser,
|
|
236
|
+
createEndpoint,
|
|
237
|
+
);
|
|
238
|
+
const createHandler = createAdapter.handler;
|
|
239
|
+
|
|
240
|
+
const createEvent = createMockV2Event({
|
|
241
|
+
requestContext: {
|
|
242
|
+
...createMockV2Event().requestContext,
|
|
243
|
+
http: {
|
|
244
|
+
method: 'POST',
|
|
245
|
+
path: '/orders',
|
|
246
|
+
protocol: 'HTTP/1.1',
|
|
247
|
+
sourceIp: '127.0.0.1',
|
|
248
|
+
userAgent: 'test-agent',
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
await createHandler(createEvent, createMockContext());
|
|
254
|
+
|
|
255
|
+
expect(mockPublisher.publish).toHaveBeenCalledWith([
|
|
256
|
+
{
|
|
257
|
+
type: 'user.created',
|
|
258
|
+
payload: { userId: 'create-order', email: 'create@example.com' },
|
|
259
|
+
},
|
|
260
|
+
]);
|
|
261
|
+
|
|
262
|
+
// Reset mock
|
|
263
|
+
vi.clearAllMocks();
|
|
264
|
+
(SharedEventsService.register as any).mockResolvedValue(mockPublisher);
|
|
265
|
+
|
|
266
|
+
// Test update endpoint
|
|
267
|
+
const updateAdapter = new AmazonApiGatewayV2Endpoint(
|
|
268
|
+
envParser,
|
|
269
|
+
updateEndpoint,
|
|
270
|
+
);
|
|
271
|
+
const updateHandler = updateAdapter.handler;
|
|
272
|
+
|
|
273
|
+
const updateEvent = createMockV2Event({
|
|
274
|
+
requestContext: {
|
|
275
|
+
...createMockV2Event().requestContext,
|
|
276
|
+
http: {
|
|
277
|
+
method: 'PUT',
|
|
278
|
+
path: '/orders/update-order',
|
|
279
|
+
protocol: 'HTTP/1.1',
|
|
280
|
+
sourceIp: '127.0.0.1',
|
|
281
|
+
userAgent: 'test-agent',
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
pathParameters: { id: 'update-order' },
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
await updateHandler(updateEvent, createMockContext());
|
|
288
|
+
|
|
289
|
+
expect(mockPublisher.publish).toHaveBeenCalledWith([
|
|
290
|
+
{
|
|
291
|
+
type: 'user.updated',
|
|
292
|
+
payload: { userId: 'update-order', changes: ['status'] },
|
|
293
|
+
},
|
|
294
|
+
]);
|
|
295
|
+
});
|
|
296
|
+
});
|