@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,432 @@
|
|
|
1
|
+
import type { Logger } from '@geekmidas/logger';
|
|
2
|
+
import type { Service } from '@geekmidas/services';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { ConstructType } from '../../Construct';
|
|
6
|
+
import { Subscriber, type SubscriberContext } from '../Subscriber';
|
|
7
|
+
|
|
8
|
+
import { SubscriberBuilder } from '../SubscriberBuilder';
|
|
9
|
+
|
|
10
|
+
import type { EventPublisher, PublishableMessage } from '@geekmidas/events';
|
|
11
|
+
|
|
12
|
+
// Define test event types
|
|
13
|
+
type UserEvent =
|
|
14
|
+
| PublishableMessage<
|
|
15
|
+
'user.created',
|
|
16
|
+
{ userId: string; email: string; name: string }
|
|
17
|
+
>
|
|
18
|
+
| PublishableMessage<
|
|
19
|
+
'user.updated',
|
|
20
|
+
{ userId: string; changes: Record<string, any> }
|
|
21
|
+
>
|
|
22
|
+
| PublishableMessage<'user.deleted', { userId: string; deletedAt: Date }>;
|
|
23
|
+
|
|
24
|
+
// Mock event publisher
|
|
25
|
+
class TestEventPublisher implements EventPublisher<UserEvent> {
|
|
26
|
+
async publish(events: UserEvent[]): Promise<void> {
|
|
27
|
+
void events;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Mock service for testing
|
|
32
|
+
const TestEventService: Service<'testEventPublisher', TestEventPublisher> = {
|
|
33
|
+
serviceName: 'testEventPublisher' as const,
|
|
34
|
+
register() {
|
|
35
|
+
return new TestEventPublisher();
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Mock logger
|
|
40
|
+
const mockLogger: Logger = {
|
|
41
|
+
debug: vi.fn(),
|
|
42
|
+
info: vi.fn(),
|
|
43
|
+
warn: vi.fn(),
|
|
44
|
+
error: vi.fn(),
|
|
45
|
+
fatal: vi.fn(),
|
|
46
|
+
trace: vi.fn(),
|
|
47
|
+
child: vi.fn(() => mockLogger),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
describe('Subscriber', () => {
|
|
51
|
+
describe('isSubscriber', () => {
|
|
52
|
+
it('should identify valid subscriber instances', () => {
|
|
53
|
+
const subscriber = new Subscriber(
|
|
54
|
+
async () => {},
|
|
55
|
+
30000,
|
|
56
|
+
['user.created'],
|
|
57
|
+
undefined,
|
|
58
|
+
[],
|
|
59
|
+
mockLogger,
|
|
60
|
+
TestEventService,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
expect(Subscriber.isSubscriber(subscriber)).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should reject non-subscriber objects', () => {
|
|
67
|
+
expect(Subscriber.isSubscriber({})).toBe(false);
|
|
68
|
+
expect(Subscriber.isSubscriber(null)).toBe(false);
|
|
69
|
+
expect(Subscriber.isSubscriber(undefined)).toBe(false);
|
|
70
|
+
expect(Subscriber.isSubscriber({ type: ConstructType.Endpoint })).toBe(
|
|
71
|
+
false,
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('constructor', () => {
|
|
77
|
+
it('should create a subscriber with correct type', () => {
|
|
78
|
+
const handler = vi.fn();
|
|
79
|
+
const subscriber = new Subscriber(
|
|
80
|
+
handler,
|
|
81
|
+
30000,
|
|
82
|
+
['user.created'],
|
|
83
|
+
undefined,
|
|
84
|
+
[],
|
|
85
|
+
mockLogger,
|
|
86
|
+
TestEventService,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(subscriber.type).toBe(ConstructType.Subscriber);
|
|
90
|
+
expect(subscriber.__IS_SUBSCRIBER__).toBe(true);
|
|
91
|
+
expect(subscriber.handler).toBe(handler);
|
|
92
|
+
expect(subscriber.timeout).toBe(30000);
|
|
93
|
+
expect(subscriber.subscribedEvents).toEqual(['user.created']);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should accept explicit timeout value', () => {
|
|
97
|
+
const subscriber = new Subscriber(
|
|
98
|
+
async () => {},
|
|
99
|
+
45000,
|
|
100
|
+
['user.created'],
|
|
101
|
+
undefined,
|
|
102
|
+
[],
|
|
103
|
+
mockLogger,
|
|
104
|
+
TestEventService,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
expect(subscriber.timeout).toBe(45000);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('SubscriberBuilder', () => {
|
|
113
|
+
describe('timeout', () => {
|
|
114
|
+
it('should set custom timeout', () => {
|
|
115
|
+
const subscriber = new SubscriberBuilder()
|
|
116
|
+
.publisher(TestEventService)
|
|
117
|
+
.timeout(60000)
|
|
118
|
+
.subscribe('user.created')
|
|
119
|
+
.handle(async () => {});
|
|
120
|
+
|
|
121
|
+
expect(subscriber.timeout).toBe(60000);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should use default timeout if not set', () => {
|
|
125
|
+
const subscriber = new SubscriberBuilder()
|
|
126
|
+
.publisher(TestEventService)
|
|
127
|
+
.subscribe('user.created')
|
|
128
|
+
.handle(async () => {});
|
|
129
|
+
|
|
130
|
+
expect(subscriber.timeout).toBe(30000);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('output', () => {
|
|
135
|
+
it('should set output schema', () => {
|
|
136
|
+
const outputSchema = z.object({
|
|
137
|
+
processed: z.number(),
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const subscriber = new SubscriberBuilder()
|
|
141
|
+
.publisher(TestEventService)
|
|
142
|
+
.output(outputSchema)
|
|
143
|
+
.subscribe('user.created')
|
|
144
|
+
.handle(async () => ({ processed: 1 }));
|
|
145
|
+
|
|
146
|
+
expect(subscriber.outputSchema).toBe(outputSchema);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('services', () => {
|
|
151
|
+
it('should register services', () => {
|
|
152
|
+
const mockService: Service<'test', { foo: string }> = {
|
|
153
|
+
serviceName: 'test' as const,
|
|
154
|
+
register() {
|
|
155
|
+
return { foo: 'bar' };
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const subscriber = new SubscriberBuilder()
|
|
160
|
+
.publisher(TestEventService)
|
|
161
|
+
.services([mockService])
|
|
162
|
+
.subscribe('user.created')
|
|
163
|
+
.handle(async () => {});
|
|
164
|
+
|
|
165
|
+
expect(subscriber.services).toEqual([mockService]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('should accumulate multiple service calls', () => {
|
|
169
|
+
const service1: Service<'service1', { a: string }> = {
|
|
170
|
+
serviceName: 'service1' as const,
|
|
171
|
+
register() {
|
|
172
|
+
return { a: 'a' };
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
const service2: Service<'service2', { b: string }> = {
|
|
176
|
+
serviceName: 'service2' as const,
|
|
177
|
+
register() {
|
|
178
|
+
return { b: 'b' };
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const subscriber = new SubscriberBuilder()
|
|
183
|
+
.publisher(TestEventService)
|
|
184
|
+
.services([service1])
|
|
185
|
+
.services([service2])
|
|
186
|
+
.subscribe('user.created')
|
|
187
|
+
.handle(async () => {});
|
|
188
|
+
|
|
189
|
+
expect(subscriber.services).toEqual([service1, service2]);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
describe('logger', () => {
|
|
194
|
+
it('should set custom logger', () => {
|
|
195
|
+
const customLogger: Logger = {
|
|
196
|
+
...mockLogger,
|
|
197
|
+
info: vi.fn(),
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const subscriber = new SubscriberBuilder()
|
|
201
|
+
.publisher(TestEventService)
|
|
202
|
+
.logger(customLogger)
|
|
203
|
+
.subscribe('user.created')
|
|
204
|
+
.handle(async () => {});
|
|
205
|
+
|
|
206
|
+
expect(subscriber.logger).toBe(customLogger);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('publisher', () => {
|
|
211
|
+
it('should set publisher service', () => {
|
|
212
|
+
const subscriber = new SubscriberBuilder()
|
|
213
|
+
.publisher(TestEventService)
|
|
214
|
+
.subscribe('user.created')
|
|
215
|
+
.handle(async () => {});
|
|
216
|
+
|
|
217
|
+
expect(subscriber.publisherService).toBe(TestEventService);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
describe('subscribe', () => {
|
|
222
|
+
it('should subscribe to single event', () => {
|
|
223
|
+
const subscriber = new SubscriberBuilder()
|
|
224
|
+
.publisher(TestEventService)
|
|
225
|
+
.subscribe('user.created')
|
|
226
|
+
.handle(async () => {});
|
|
227
|
+
|
|
228
|
+
expect(subscriber.subscribedEvents).toEqual(['user.created']);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('should subscribe to multiple events via chaining', () => {
|
|
232
|
+
const subscriber = new SubscriberBuilder()
|
|
233
|
+
.publisher(TestEventService)
|
|
234
|
+
.subscribe('user.created')
|
|
235
|
+
.subscribe('user.updated')
|
|
236
|
+
.subscribe('user.deleted')
|
|
237
|
+
.handle(async () => {});
|
|
238
|
+
|
|
239
|
+
expect(subscriber.subscribedEvents).toEqual([
|
|
240
|
+
'user.created',
|
|
241
|
+
'user.updated',
|
|
242
|
+
'user.deleted',
|
|
243
|
+
]);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('should subscribe to multiple events via array', () => {
|
|
247
|
+
const subscriber = new SubscriberBuilder()
|
|
248
|
+
.publisher(TestEventService)
|
|
249
|
+
.subscribe(['user.created', 'user.updated', 'user.deleted'])
|
|
250
|
+
.handle(async () => {});
|
|
251
|
+
|
|
252
|
+
expect(subscriber.subscribedEvents).toEqual([
|
|
253
|
+
'user.created',
|
|
254
|
+
'user.updated',
|
|
255
|
+
'user.deleted',
|
|
256
|
+
]);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('should mix array and single subscriptions', () => {
|
|
260
|
+
const subscriber = new SubscriberBuilder()
|
|
261
|
+
.publisher(TestEventService)
|
|
262
|
+
.subscribe(['user.created', 'user.updated'])
|
|
263
|
+
.subscribe('user.deleted')
|
|
264
|
+
.handle(async () => {});
|
|
265
|
+
|
|
266
|
+
expect(subscriber.subscribedEvents).toEqual([
|
|
267
|
+
'user.created',
|
|
268
|
+
'user.updated',
|
|
269
|
+
'user.deleted',
|
|
270
|
+
]);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe('handle', () => {
|
|
275
|
+
it('should create a subscriber instance', () => {
|
|
276
|
+
const handler = vi.fn(async () => {});
|
|
277
|
+
const subscriber = new SubscriberBuilder()
|
|
278
|
+
.publisher(TestEventService)
|
|
279
|
+
.subscribe('user.created')
|
|
280
|
+
.handle(handler);
|
|
281
|
+
|
|
282
|
+
expect(subscriber).toBeInstanceOf(Subscriber);
|
|
283
|
+
expect(subscriber.handler).toBe(handler);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('should pass context to handler', async () => {
|
|
287
|
+
const handler = vi.fn(
|
|
288
|
+
async ({ events, services, logger }: SubscriberContext<any, any>) => {
|
|
289
|
+
expect(events).toBeDefined();
|
|
290
|
+
expect(services).toBeDefined();
|
|
291
|
+
expect(logger).toBeDefined();
|
|
292
|
+
},
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
const subscriber = new SubscriberBuilder()
|
|
296
|
+
.publisher(TestEventService)
|
|
297
|
+
.subscribe('user.created')
|
|
298
|
+
.handle(handler);
|
|
299
|
+
|
|
300
|
+
// Simulate calling the handler
|
|
301
|
+
await subscriber.handler({
|
|
302
|
+
events: [
|
|
303
|
+
{
|
|
304
|
+
type: 'user.created',
|
|
305
|
+
payload: { userId: '1', email: 'test@example.com', name: 'Test' },
|
|
306
|
+
},
|
|
307
|
+
] as any,
|
|
308
|
+
services: {} as any,
|
|
309
|
+
logger: mockLogger,
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
expect(handler).toHaveBeenCalled();
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('should handle events with correct typing', async () => {
|
|
316
|
+
const handler = vi.fn(
|
|
317
|
+
async ({
|
|
318
|
+
events,
|
|
319
|
+
}: SubscriberContext<TestEventPublisher, ['user.created']>) => {
|
|
320
|
+
// Type assertions to verify correct typing
|
|
321
|
+
events.forEach((event) => {
|
|
322
|
+
if (event.type === 'user.created') {
|
|
323
|
+
expect(event.payload.userId).toBeDefined();
|
|
324
|
+
expect(event.payload.email).toBeDefined();
|
|
325
|
+
expect(event.payload.name).toBeDefined();
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
return { processed: events.length };
|
|
330
|
+
},
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
const outputSchema = z.object({ processed: z.number() });
|
|
334
|
+
|
|
335
|
+
const subscriber = new SubscriberBuilder()
|
|
336
|
+
.publisher(TestEventService)
|
|
337
|
+
.output(outputSchema)
|
|
338
|
+
.subscribe('user.created')
|
|
339
|
+
.handle(handler);
|
|
340
|
+
|
|
341
|
+
const result = await subscriber.handler({
|
|
342
|
+
events: [
|
|
343
|
+
{
|
|
344
|
+
type: 'user.created',
|
|
345
|
+
payload: {
|
|
346
|
+
userId: '123',
|
|
347
|
+
email: 'test@example.com',
|
|
348
|
+
name: 'Test User',
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
] as any,
|
|
352
|
+
services: {} as any,
|
|
353
|
+
logger: mockLogger,
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
expect(result).toEqual({ processed: 1 });
|
|
357
|
+
expect(handler).toHaveBeenCalled();
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('should handle batch of events', async () => {
|
|
361
|
+
const processedEvents: UserEvent[] = [];
|
|
362
|
+
const handler = vi.fn(async ({ events }) => {
|
|
363
|
+
processedEvents.push(...events);
|
|
364
|
+
return { count: events.length };
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
const subscriber = new SubscriberBuilder()
|
|
368
|
+
.publisher(TestEventService)
|
|
369
|
+
.subscribe(['user.created', 'user.updated'])
|
|
370
|
+
.handle(handler);
|
|
371
|
+
|
|
372
|
+
const testEvents = [
|
|
373
|
+
{
|
|
374
|
+
type: 'user.created' as const,
|
|
375
|
+
payload: { userId: '1', email: 'user1@test.com', name: 'User 1' },
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
type: 'user.created' as const,
|
|
379
|
+
payload: { userId: '2', email: 'user2@test.com', name: 'User 2' },
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
type: 'user.updated' as const,
|
|
383
|
+
payload: { userId: '1', changes: { name: 'Updated Name' } },
|
|
384
|
+
},
|
|
385
|
+
];
|
|
386
|
+
|
|
387
|
+
await subscriber.handler({
|
|
388
|
+
events: testEvents as any,
|
|
389
|
+
services: {} as any,
|
|
390
|
+
logger: mockLogger,
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
expect(handler).toHaveBeenCalled();
|
|
394
|
+
expect(processedEvents).toHaveLength(3);
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
describe('builder chaining', () => {
|
|
399
|
+
it('should support fluent builder pattern', () => {
|
|
400
|
+
const mockService: Service<'db', any> = {
|
|
401
|
+
serviceName: 'db' as const,
|
|
402
|
+
register() {
|
|
403
|
+
return {};
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
const customLogger = { ...mockLogger };
|
|
408
|
+
|
|
409
|
+
const subscriber = new SubscriberBuilder()
|
|
410
|
+
.timeout(45000)
|
|
411
|
+
.logger(customLogger)
|
|
412
|
+
.publisher(TestEventService)
|
|
413
|
+
.services([mockService])
|
|
414
|
+
.output(z.object({ success: z.boolean() }))
|
|
415
|
+
.subscribe('user.created')
|
|
416
|
+
.subscribe('user.updated')
|
|
417
|
+
.handle(async ({ events }) => {
|
|
418
|
+
return { success: events.length > 0 };
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
expect(subscriber.timeout).toBe(45000);
|
|
422
|
+
expect(subscriber.logger).toBe(customLogger);
|
|
423
|
+
expect(subscriber.publisherService).toBe(TestEventService);
|
|
424
|
+
expect(subscriber.services).toEqual([mockService]);
|
|
425
|
+
expect(subscriber.subscribedEvents).toEqual([
|
|
426
|
+
'user.created',
|
|
427
|
+
'user.updated',
|
|
428
|
+
]);
|
|
429
|
+
expect(subscriber.outputSchema).toBeDefined();
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
});
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type RemoveUndefined<T> = {
|
|
2
|
+
[K in keyof T as T[K] extends undefined ? never : K]: T[K];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export type HttpMethod =
|
|
6
|
+
| 'GET'
|
|
7
|
+
| 'POST'
|
|
8
|
+
| 'PUT'
|
|
9
|
+
| 'PATCH'
|
|
10
|
+
| 'DELETE'
|
|
11
|
+
| 'OPTIONS';
|
|
12
|
+
|
|
13
|
+
export type LowerHttpMethod<T extends HttpMethod> = Lowercase<T>;
|
package/tsdown.config.ts
ADDED