@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,26 @@
|
|
|
1
|
+
import "../Construct-Bm-PSO2V.cjs";
|
|
2
|
+
import { Function } from "../Function-BP58p9Mp.cjs";
|
|
3
|
+
import { EventPublisher } from "@geekmidas/events";
|
|
4
|
+
import { Logger } from "@geekmidas/logger";
|
|
5
|
+
import { Service, ServiceDiscovery, ServiceRecord } from "@geekmidas/services";
|
|
6
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
|
+
import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "@geekmidas/schema";
|
|
8
|
+
|
|
9
|
+
//#region src/functions/TestFunctionAdaptor.d.ts
|
|
10
|
+
declare class TestFunctionAdaptor<TInput extends StandardSchemaV1 | undefined = undefined, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string> {
|
|
11
|
+
private readonly fn;
|
|
12
|
+
private serviceDiscovery;
|
|
13
|
+
static getDefaultServiceDiscovery<TInput extends ComposableStandardSchema | undefined = undefined, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string>(fn: Function<TInput, TServices, TLogger, TOutSchema, any, TEventPublisher, TEventPublisherServiceName>): ServiceDiscovery<any, Logger>;
|
|
14
|
+
constructor(fn: Function<TInput, TServices, TLogger, TOutSchema, any, TEventPublisher, TEventPublisherServiceName>, serviceDiscovery?: ServiceDiscovery<any, any>);
|
|
15
|
+
invoke(ctx: TestFunctionRequest<TInput, TServices, TEventPublisher, TEventPublisherServiceName>): Promise<InferStandardSchema<TOutSchema>>;
|
|
16
|
+
}
|
|
17
|
+
type TestFunctionRequest<TInput extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string> = {
|
|
18
|
+
input: InferComposableStandardSchema<TInput>;
|
|
19
|
+
services: ServiceRecord<TServices>;
|
|
20
|
+
publisher?: Service<TEventPublisherServiceName, TEventPublisher>;
|
|
21
|
+
} & InferComposableStandardSchema<{
|
|
22
|
+
input: TInput;
|
|
23
|
+
}>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { TestFunctionAdaptor, TestFunctionRequest };
|
|
26
|
+
//# sourceMappingURL=TestFunctionAdaptor.d.cts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "../Construct-DIguIyw4.mjs";
|
|
2
|
+
import { Function } from "../Function-BsBxc2wA.mjs";
|
|
3
|
+
import { Service, ServiceDiscovery, ServiceRecord } from "@geekmidas/services";
|
|
4
|
+
import { EventPublisher } from "@geekmidas/events";
|
|
5
|
+
import { Logger } from "@geekmidas/logger";
|
|
6
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
|
+
import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "@geekmidas/schema";
|
|
8
|
+
|
|
9
|
+
//#region src/functions/TestFunctionAdaptor.d.ts
|
|
10
|
+
declare class TestFunctionAdaptor<TInput extends StandardSchemaV1 | undefined = undefined, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string> {
|
|
11
|
+
private readonly fn;
|
|
12
|
+
private serviceDiscovery;
|
|
13
|
+
static getDefaultServiceDiscovery<TInput extends ComposableStandardSchema | undefined = undefined, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string>(fn: Function<TInput, TServices, TLogger, TOutSchema, any, TEventPublisher, TEventPublisherServiceName>): ServiceDiscovery<any, Logger>;
|
|
14
|
+
constructor(fn: Function<TInput, TServices, TLogger, TOutSchema, any, TEventPublisher, TEventPublisherServiceName>, serviceDiscovery?: ServiceDiscovery<any, any>);
|
|
15
|
+
invoke(ctx: TestFunctionRequest<TInput, TServices, TEventPublisher, TEventPublisherServiceName>): Promise<InferStandardSchema<TOutSchema>>;
|
|
16
|
+
}
|
|
17
|
+
type TestFunctionRequest<TInput extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string> = {
|
|
18
|
+
input: InferComposableStandardSchema<TInput>;
|
|
19
|
+
services: ServiceRecord<TServices>;
|
|
20
|
+
publisher?: Service<TEventPublisherServiceName, TEventPublisher>;
|
|
21
|
+
} & InferComposableStandardSchema<{
|
|
22
|
+
input: TInput;
|
|
23
|
+
}>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { TestFunctionAdaptor, TestFunctionRequest };
|
|
26
|
+
//# sourceMappingURL=TestFunctionAdaptor.d.mts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "../Construct-BbKCIPQm.mjs";
|
|
2
|
+
import { publishEvents } from "../publisher-Bw4770Hi.mjs";
|
|
3
|
+
import "../Function-C5mW-38v.mjs";
|
|
4
|
+
import "../BaseFunctionBuilder-BPE9JBbT.mjs";
|
|
5
|
+
import { FunctionBuilder } from "../FunctionBuilder-CosgPmMl.mjs";
|
|
6
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
7
|
+
import { ServiceDiscovery } from "@geekmidas/services";
|
|
8
|
+
|
|
9
|
+
//#region src/functions/TestFunctionAdaptor.ts
|
|
10
|
+
var TestFunctionAdaptor = class TestFunctionAdaptor {
|
|
11
|
+
static getDefaultServiceDiscovery(fn) {
|
|
12
|
+
return ServiceDiscovery.getInstance(fn.logger, new EnvironmentParser({}));
|
|
13
|
+
}
|
|
14
|
+
constructor(fn, serviceDiscovery = TestFunctionAdaptor.getDefaultServiceDiscovery(fn)) {
|
|
15
|
+
this.fn = fn;
|
|
16
|
+
this.serviceDiscovery = serviceDiscovery;
|
|
17
|
+
}
|
|
18
|
+
async invoke(ctx) {
|
|
19
|
+
const parsedInput = await FunctionBuilder.parseComposableStandardSchema(ctx.input, this.fn.input);
|
|
20
|
+
const logger = this.fn.logger.child({ test: true });
|
|
21
|
+
let services;
|
|
22
|
+
if (ctx.services) services = ctx.services;
|
|
23
|
+
else services = await this.serviceDiscovery.register(this.fn.services);
|
|
24
|
+
const response = await this.fn["fn"]({
|
|
25
|
+
input: parsedInput,
|
|
26
|
+
services,
|
|
27
|
+
logger
|
|
28
|
+
});
|
|
29
|
+
const output = await this.fn.parseOutput(response);
|
|
30
|
+
await publishEvents(logger, this.serviceDiscovery, this.fn.events, output, this.fn.publisherService);
|
|
31
|
+
return output;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { TestFunctionAdaptor };
|
|
37
|
+
//# sourceMappingURL=TestFunctionAdaptor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestFunctionAdaptor.mjs","names":["fn: Function<\n TInput,\n TServices,\n TLogger,\n TOutSchema,\n any,\n TEventPublisher,\n TEventPublisherServiceName\n >","serviceDiscovery: ServiceDiscovery<\n any,\n any\n >","ctx: TestFunctionRequest<\n TInput,\n TServices,\n TEventPublisher,\n TEventPublisherServiceName\n >","services: ServiceRecord<TServices>"],"sources":["../../src/functions/TestFunctionAdaptor.ts"],"sourcesContent":["import { EnvironmentParser } from '@geekmidas/envkit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type {\n ComposableStandardSchema,\n InferComposableStandardSchema,\n InferStandardSchema,\n} from '@geekmidas/schema';\nimport {\n type Service,\n ServiceDiscovery,\n type ServiceRecord,\n} from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { publishEvents } from '../publisher';\nimport type { Function } from './Function';\nimport { FunctionBuilder } from './FunctionBuilder';\n\nexport class TestFunctionAdaptor<\n TInput extends StandardSchemaV1 | undefined = undefined,\n TOutSchema extends StandardSchemaV1 | undefined = undefined,\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TEventPublisher extends EventPublisher<any> | undefined = undefined,\n TEventPublisherServiceName extends string = string,\n> {\n static getDefaultServiceDiscovery<\n TInput extends ComposableStandardSchema | undefined = undefined,\n TOutSchema extends StandardSchemaV1 | undefined = undefined,\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n TEventPublisher extends EventPublisher<any> | undefined = undefined,\n TEventPublisherServiceName extends string = string,\n >(\n fn: Function<\n TInput,\n TServices,\n TLogger,\n TOutSchema,\n any,\n TEventPublisher,\n TEventPublisherServiceName\n >,\n ) {\n return ServiceDiscovery.getInstance(fn.logger, new EnvironmentParser({}));\n }\n\n constructor(\n private readonly fn: Function<\n TInput,\n TServices,\n TLogger,\n TOutSchema,\n any,\n TEventPublisher,\n TEventPublisherServiceName\n >,\n private serviceDiscovery: ServiceDiscovery<\n any,\n any\n > = TestFunctionAdaptor.getDefaultServiceDiscovery(fn),\n ) {}\n\n async invoke(\n ctx: TestFunctionRequest<\n TInput,\n TServices,\n TEventPublisher,\n TEventPublisherServiceName\n >,\n ): Promise<InferStandardSchema<TOutSchema>> {\n // Parse input if schema is provided\n\n const parsedInput = await FunctionBuilder.parseComposableStandardSchema(\n ctx.input,\n this.fn.input,\n );\n\n // Create logger with context\n const logger = this.fn.logger.child({\n test: true,\n }) as TLogger;\n\n // Register services (use provided services or register from function)\n let services: ServiceRecord<TServices>;\n if (ctx.services) {\n services = ctx.services;\n } else {\n services = await this.serviceDiscovery.register(this.fn.services);\n }\n\n // Execute the function\n const response = await this.fn['fn']({\n input: parsedInput,\n services,\n logger,\n });\n\n // Parse output if schema is provided\n const output = await this.fn.parseOutput(response);\n\n // Register publisher service if provided in context\n\n await publishEvents(\n logger,\n this.serviceDiscovery,\n this.fn.events,\n output,\n this.fn.publisherService,\n );\n\n return output;\n }\n}\n\nexport type TestFunctionRequest<\n TInput extends StandardSchemaV1 | undefined = undefined,\n TServices extends Service[] = [],\n TEventPublisher extends EventPublisher<any> | undefined = undefined,\n TEventPublisherServiceName extends string = string,\n> = {\n input: InferComposableStandardSchema<TInput>;\n services: ServiceRecord<TServices>;\n publisher?: Service<TEventPublisherServiceName, TEventPublisher>;\n} & InferComposableStandardSchema<{ input: TInput }>;\n"],"mappings":";;;;;;;;;AAkBA,IAAa,sBAAb,MAAa,oBAOX;CACA,OAAO,2BAQLA,IASA;AACA,SAAO,iBAAiB,YAAY,GAAG,QAAQ,IAAI,kBAAkB,CAAE,GAAE;CAC1E;CAED,YACmBA,IASTC,mBAGJ,oBAAoB,2BAA2B,GAAG,EACtD;EAbiB;EAST;CAIN;CAEJ,MAAM,OACJC,KAM0C;EAG1C,MAAM,cAAc,MAAM,gBAAgB,8BACxC,IAAI,OACJ,KAAK,GAAG,MACT;EAGD,MAAM,SAAS,KAAK,GAAG,OAAO,MAAM,EAClC,MAAM,KACP,EAAC;EAGF,IAAIC;AACJ,MAAI,IAAI,SACN,YAAW,IAAI;MAEf,YAAW,MAAM,KAAK,iBAAiB,SAAS,KAAK,GAAG,SAAS;EAInE,MAAM,WAAW,MAAM,KAAK,GAAG,MAAM;GACnC,OAAO;GACP;GACA;EACD,EAAC;EAGF,MAAM,SAAS,MAAM,KAAK,GAAG,YAAY,SAAS;AAIlD,QAAM,cACJ,QACA,KAAK,kBACL,KAAK,GAAG,QACR,QACA,KAAK,GAAG,iBACT;AAED,SAAO;CACR;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require('../Construct-BSEs6uwW.cjs');
|
|
2
|
+
const require_Function = require('../Function-CbO2NZx-.cjs');
|
|
3
|
+
const require_BaseFunctionBuilder = require('../BaseFunctionBuilder-DtO4Nwxm.cjs');
|
|
4
|
+
const require_FunctionBuilder = require('../FunctionBuilder-DuOeWCAl.cjs');
|
|
5
|
+
const require_functions = require('../functions-DVDb5wEA.cjs');
|
|
6
|
+
|
|
7
|
+
exports.BaseFunctionBuilder = require_BaseFunctionBuilder.BaseFunctionBuilder;
|
|
8
|
+
exports.Function = require_Function.Function;
|
|
9
|
+
exports.FunctionBuilder = require_FunctionBuilder.FunctionBuilder;
|
|
10
|
+
exports.f = require_functions.f;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "../Construct-Bm-PSO2V.cjs";
|
|
2
|
+
import { Function, FunctionContext, FunctionHandler } from "../Function-BP58p9Mp.cjs";
|
|
3
|
+
import { BaseFunctionBuilder } from "../BaseFunctionBuilder-5QCHkchp.cjs";
|
|
4
|
+
import { FunctionBuilder } from "../FunctionBuilder-BS1KgxA_.cjs";
|
|
5
|
+
import { f } from "../index-Fg3N3EKD.cjs";
|
|
6
|
+
export { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "../Construct-DIguIyw4.mjs";
|
|
2
|
+
import { Function, FunctionContext, FunctionHandler } from "../Function-BsBxc2wA.mjs";
|
|
3
|
+
import { BaseFunctionBuilder } from "../BaseFunctionBuilder-BFPVGnKi.mjs";
|
|
4
|
+
import { FunctionBuilder } from "../FunctionBuilder-C-PfPN3r.mjs";
|
|
5
|
+
import { f } from "../index-CuGR4L7O.mjs";
|
|
6
|
+
export { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "../Construct-BbKCIPQm.mjs";
|
|
2
|
+
import { Function } from "../Function-C5mW-38v.mjs";
|
|
3
|
+
import { BaseFunctionBuilder } from "../BaseFunctionBuilder-BPE9JBbT.mjs";
|
|
4
|
+
import { FunctionBuilder } from "../FunctionBuilder-CosgPmMl.mjs";
|
|
5
|
+
import { f } from "../functions-mM-jcphA.mjs";
|
|
6
|
+
|
|
7
|
+
export { BaseFunctionBuilder, Function, FunctionBuilder, f };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_FunctionBuilder = require('./FunctionBuilder-DuOeWCAl.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/functions/index.ts
|
|
4
|
+
const f = new require_FunctionBuilder.FunctionBuilder();
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
Object.defineProperty(exports, 'f', {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return f;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=functions-DVDb5wEA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions-DVDb5wEA.cjs","names":["FunctionBuilder"],"sources":["../src/functions/index.ts"],"sourcesContent":["export {\n Function,\n type FunctionContext,\n type FunctionHandler,\n} from './Function';\nexport { BaseFunctionBuilder } from './BaseFunctionBuilder';\nimport { FunctionBuilder } from './FunctionBuilder';\nexport { FunctionBuilder } from './FunctionBuilder';\n\nexport const f = new FunctionBuilder();\n"],"mappings":";;;AASA,MAAa,IAAI,IAAIA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions-mM-jcphA.mjs","names":[],"sources":["../src/functions/index.ts"],"sourcesContent":["export {\n Function,\n type FunctionContext,\n type FunctionHandler,\n} from './Function';\nexport { BaseFunctionBuilder } from './BaseFunctionBuilder';\nimport { FunctionBuilder } from './FunctionBuilder';\nexport { FunctionBuilder } from './FunctionBuilder';\n\nexport const f = new FunctionBuilder();\n"],"mappings":";;;AASA,MAAa,IAAI,IAAI"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_Endpoint = require('./Endpoint-BaHC9y4Z.cjs');
|
|
3
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
|
+
const fast_glob = require_chunk.__toESM(require("fast-glob"));
|
|
5
|
+
|
|
6
|
+
//#region src/endpoints/helpers.ts
|
|
7
|
+
/**
|
|
8
|
+
* Recursively finds the project root directory by looking for lock files.
|
|
9
|
+
* Traverses up the directory tree until it finds a package manager lock file.
|
|
10
|
+
*
|
|
11
|
+
* @param cwd - The current working directory to start searching from
|
|
12
|
+
* @returns Promise resolving to the absolute path of the project root
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const projectRoot = await getProjectRoot(process.cwd());
|
|
17
|
+
* console.log(`Project root: ${projectRoot}`);
|
|
18
|
+
* // Output: Project root: /Users/user/my-project
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
async function getProjectRoot(cwd) {
|
|
22
|
+
if (cwd === "/") return cwd;
|
|
23
|
+
const stream = fast_glob.default.stream([
|
|
24
|
+
"yarn.lock",
|
|
25
|
+
"pnpm-lock.yaml",
|
|
26
|
+
"package-lock.json",
|
|
27
|
+
"deno.lock"
|
|
28
|
+
], {
|
|
29
|
+
dot: true,
|
|
30
|
+
cwd
|
|
31
|
+
});
|
|
32
|
+
let isRoot = false;
|
|
33
|
+
for await (const _ of stream) {
|
|
34
|
+
isRoot = true;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
if (isRoot) return cwd;
|
|
38
|
+
return getProjectRoot(node_path.default.resolve(cwd, ".."));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Discovers and imports all Endpoint instances from the specified route patterns.
|
|
42
|
+
* Uses fast-glob to find files matching the patterns and extracts exported Endpoints.
|
|
43
|
+
*
|
|
44
|
+
* @template TServices - Array of service types used by the endpoints
|
|
45
|
+
* @param routes - Array of glob patterns to match route files (e.g., ['src/routes/*.ts'])
|
|
46
|
+
* @param cwd - The current working directory to resolve paths from
|
|
47
|
+
* @returns Promise resolving to an array of Endpoint instances found in the matched files
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // Find all endpoints in the routes directory
|
|
52
|
+
* const endpoints = await getEndpointsFromRoutes(
|
|
53
|
+
* ['src/routes/**\/*.ts'],
|
|
54
|
+
* process.cwd()
|
|
55
|
+
* );
|
|
56
|
+
*
|
|
57
|
+
* // Register endpoints with your server
|
|
58
|
+
* for (const endpoint of endpoints) {
|
|
59
|
+
* server.register(endpoint);
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* - Only exports that are valid Endpoint instances are included
|
|
65
|
+
* - Files are imported dynamically, so they must be valid ES modules
|
|
66
|
+
* - The function filters out non-Endpoint exports automatically
|
|
67
|
+
*/
|
|
68
|
+
async function getEndpointsFromRoutes(routes, cwd) {
|
|
69
|
+
const stream = fast_glob.default.stream(routes, { cwd });
|
|
70
|
+
const endpoints = [];
|
|
71
|
+
for await (const f of stream) {
|
|
72
|
+
const routePath = node_path.default.resolve(cwd, f.toString());
|
|
73
|
+
const route = await import(routePath);
|
|
74
|
+
const handlers = Object.values(route).filter((value) => {
|
|
75
|
+
return require_Endpoint.Endpoint.isEndpoint(value);
|
|
76
|
+
});
|
|
77
|
+
endpoints.push(...handlers);
|
|
78
|
+
}
|
|
79
|
+
return endpoints;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
Object.defineProperty(exports, 'getEndpointsFromRoutes', {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () {
|
|
86
|
+
return getEndpointsFromRoutes;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, 'getProjectRoot', {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return getProjectRoot;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=helpers-BeGM4pP_.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-BeGM4pP_.cjs","names":["cwd: string","routes: string[]","endpoints: Endpoint<string, HttpMethod, any, any, TServices>[]"],"sources":["../src/endpoints/helpers.ts"],"sourcesContent":["import path from 'node:path';\nimport fg from 'fast-glob';\nimport { Endpoint } from './Endpoint';\n\nimport type { Service } from '@geekmidas/services';\nimport type { HttpMethod } from '../types';\n\n// Re-export utility functions\n\n/**\n * Recursively finds the project root directory by looking for lock files.\n * Traverses up the directory tree until it finds a package manager lock file.\n *\n * @param cwd - The current working directory to start searching from\n * @returns Promise resolving to the absolute path of the project root\n *\n * @example\n * ```typescript\n * const projectRoot = await getProjectRoot(process.cwd());\n * console.log(`Project root: ${projectRoot}`);\n * // Output: Project root: /Users/user/my-project\n * ```\n */\nexport async function getProjectRoot(cwd: string): Promise<string> {\n if (cwd === '/') {\n return cwd;\n }\n\n const stream = fg.stream(\n ['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json', 'deno.lock'],\n { dot: true, cwd },\n );\n\n let isRoot = false;\n\n for await (const _ of stream) {\n isRoot = true;\n break;\n }\n\n if (isRoot) {\n return cwd;\n }\n\n return getProjectRoot(path.resolve(cwd, '..'));\n}\n\n/**\n * Discovers and imports all Endpoint instances from the specified route patterns.\n * Uses fast-glob to find files matching the patterns and extracts exported Endpoints.\n *\n * @template TServices - Array of service types used by the endpoints\n * @param routes - Array of glob patterns to match route files (e.g., ['src/routes/*.ts'])\n * @param cwd - The current working directory to resolve paths from\n * @returns Promise resolving to an array of Endpoint instances found in the matched files\n *\n * @example\n * ```typescript\n * // Find all endpoints in the routes directory\n * const endpoints = await getEndpointsFromRoutes(\n * ['src/routes/**\\/*.ts'],\n * process.cwd()\n * );\n *\n * // Register endpoints with your server\n * for (const endpoint of endpoints) {\n * server.register(endpoint);\n * }\n * ```\n *\n * @remarks\n * - Only exports that are valid Endpoint instances are included\n * - Files are imported dynamically, so they must be valid ES modules\n * - The function filters out non-Endpoint exports automatically\n */\nexport async function getEndpointsFromRoutes<TServices extends Service[]>(\n routes: string[],\n cwd: string,\n): Promise<Endpoint<string, HttpMethod, any, any, TServices>[]> {\n const stream = fg.stream(routes, { cwd });\n\n const endpoints: Endpoint<string, HttpMethod, any, any, TServices>[] = [];\n\n for await (const f of stream) {\n // Resolve the absolute path for the route file\n const routePath = path.resolve(cwd, f.toString());\n // Dynamically import the route module\n const route = await import(routePath);\n\n // Filter exported values to find only Endpoint instances\n const handlers = Object.values(route).filter((value) => {\n return Endpoint.isEndpoint(value);\n }) as unknown as Endpoint<string, HttpMethod, any, any, TServices>[];\n\n endpoints.push(...handlers);\n }\n\n return endpoints;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,eAAeA,KAA8B;AACjE,KAAI,QAAQ,IACV,QAAO;CAGT,MAAM,SAAS,kBAAG,OAChB;EAAC;EAAa;EAAkB;EAAqB;CAAY,GACjE;EAAE,KAAK;EAAM;CAAK,EACnB;CAED,IAAI,SAAS;AAEb,YAAW,MAAM,KAAK,QAAQ;AAC5B,WAAS;AACT;CACD;AAED,KAAI,OACF,QAAO;AAGT,QAAO,eAAe,kBAAK,QAAQ,KAAK,KAAK,CAAC;AAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BD,eAAsB,uBACpBC,QACAD,KAC8D;CAC9D,MAAM,SAAS,kBAAG,OAAO,QAAQ,EAAE,IAAK,EAAC;CAEzC,MAAME,YAAiE,CAAE;AAEzE,YAAW,MAAM,KAAK,QAAQ;EAE5B,MAAM,YAAY,kBAAK,QAAQ,KAAK,EAAE,UAAU,CAAC;EAEjD,MAAM,QAAQ,MAAM,OAAO;EAG3B,MAAM,WAAW,OAAO,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU;AACtD,UAAO,0BAAS,WAAW,MAAM;EAClC,EAAC;AAEF,YAAU,KAAK,GAAG,SAAS;CAC5B;AAED,QAAO;AACR"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Endpoint } from "./Endpoint-ierdM62O.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fg from "fast-glob";
|
|
4
|
+
|
|
5
|
+
//#region src/endpoints/helpers.ts
|
|
6
|
+
/**
|
|
7
|
+
* Recursively finds the project root directory by looking for lock files.
|
|
8
|
+
* Traverses up the directory tree until it finds a package manager lock file.
|
|
9
|
+
*
|
|
10
|
+
* @param cwd - The current working directory to start searching from
|
|
11
|
+
* @returns Promise resolving to the absolute path of the project root
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const projectRoot = await getProjectRoot(process.cwd());
|
|
16
|
+
* console.log(`Project root: ${projectRoot}`);
|
|
17
|
+
* // Output: Project root: /Users/user/my-project
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
async function getProjectRoot(cwd) {
|
|
21
|
+
if (cwd === "/") return cwd;
|
|
22
|
+
const stream = fg.stream([
|
|
23
|
+
"yarn.lock",
|
|
24
|
+
"pnpm-lock.yaml",
|
|
25
|
+
"package-lock.json",
|
|
26
|
+
"deno.lock"
|
|
27
|
+
], {
|
|
28
|
+
dot: true,
|
|
29
|
+
cwd
|
|
30
|
+
});
|
|
31
|
+
let isRoot = false;
|
|
32
|
+
for await (const _ of stream) {
|
|
33
|
+
isRoot = true;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (isRoot) return cwd;
|
|
37
|
+
return getProjectRoot(path.resolve(cwd, ".."));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Discovers and imports all Endpoint instances from the specified route patterns.
|
|
41
|
+
* Uses fast-glob to find files matching the patterns and extracts exported Endpoints.
|
|
42
|
+
*
|
|
43
|
+
* @template TServices - Array of service types used by the endpoints
|
|
44
|
+
* @param routes - Array of glob patterns to match route files (e.g., ['src/routes/*.ts'])
|
|
45
|
+
* @param cwd - The current working directory to resolve paths from
|
|
46
|
+
* @returns Promise resolving to an array of Endpoint instances found in the matched files
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Find all endpoints in the routes directory
|
|
51
|
+
* const endpoints = await getEndpointsFromRoutes(
|
|
52
|
+
* ['src/routes/**\/*.ts'],
|
|
53
|
+
* process.cwd()
|
|
54
|
+
* );
|
|
55
|
+
*
|
|
56
|
+
* // Register endpoints with your server
|
|
57
|
+
* for (const endpoint of endpoints) {
|
|
58
|
+
* server.register(endpoint);
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* - Only exports that are valid Endpoint instances are included
|
|
64
|
+
* - Files are imported dynamically, so they must be valid ES modules
|
|
65
|
+
* - The function filters out non-Endpoint exports automatically
|
|
66
|
+
*/
|
|
67
|
+
async function getEndpointsFromRoutes(routes, cwd) {
|
|
68
|
+
const stream = fg.stream(routes, { cwd });
|
|
69
|
+
const endpoints = [];
|
|
70
|
+
for await (const f of stream) {
|
|
71
|
+
const routePath = path.resolve(cwd, f.toString());
|
|
72
|
+
const route = await import(routePath);
|
|
73
|
+
const handlers = Object.values(route).filter((value) => {
|
|
74
|
+
return Endpoint.isEndpoint(value);
|
|
75
|
+
});
|
|
76
|
+
endpoints.push(...handlers);
|
|
77
|
+
}
|
|
78
|
+
return endpoints;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
export { getEndpointsFromRoutes, getProjectRoot };
|
|
83
|
+
//# sourceMappingURL=helpers-DbpO95aE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-DbpO95aE.mjs","names":["cwd: string","routes: string[]","endpoints: Endpoint<string, HttpMethod, any, any, TServices>[]"],"sources":["../src/endpoints/helpers.ts"],"sourcesContent":["import path from 'node:path';\nimport fg from 'fast-glob';\nimport { Endpoint } from './Endpoint';\n\nimport type { Service } from '@geekmidas/services';\nimport type { HttpMethod } from '../types';\n\n// Re-export utility functions\n\n/**\n * Recursively finds the project root directory by looking for lock files.\n * Traverses up the directory tree until it finds a package manager lock file.\n *\n * @param cwd - The current working directory to start searching from\n * @returns Promise resolving to the absolute path of the project root\n *\n * @example\n * ```typescript\n * const projectRoot = await getProjectRoot(process.cwd());\n * console.log(`Project root: ${projectRoot}`);\n * // Output: Project root: /Users/user/my-project\n * ```\n */\nexport async function getProjectRoot(cwd: string): Promise<string> {\n if (cwd === '/') {\n return cwd;\n }\n\n const stream = fg.stream(\n ['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json', 'deno.lock'],\n { dot: true, cwd },\n );\n\n let isRoot = false;\n\n for await (const _ of stream) {\n isRoot = true;\n break;\n }\n\n if (isRoot) {\n return cwd;\n }\n\n return getProjectRoot(path.resolve(cwd, '..'));\n}\n\n/**\n * Discovers and imports all Endpoint instances from the specified route patterns.\n * Uses fast-glob to find files matching the patterns and extracts exported Endpoints.\n *\n * @template TServices - Array of service types used by the endpoints\n * @param routes - Array of glob patterns to match route files (e.g., ['src/routes/*.ts'])\n * @param cwd - The current working directory to resolve paths from\n * @returns Promise resolving to an array of Endpoint instances found in the matched files\n *\n * @example\n * ```typescript\n * // Find all endpoints in the routes directory\n * const endpoints = await getEndpointsFromRoutes(\n * ['src/routes/**\\/*.ts'],\n * process.cwd()\n * );\n *\n * // Register endpoints with your server\n * for (const endpoint of endpoints) {\n * server.register(endpoint);\n * }\n * ```\n *\n * @remarks\n * - Only exports that are valid Endpoint instances are included\n * - Files are imported dynamically, so they must be valid ES modules\n * - The function filters out non-Endpoint exports automatically\n */\nexport async function getEndpointsFromRoutes<TServices extends Service[]>(\n routes: string[],\n cwd: string,\n): Promise<Endpoint<string, HttpMethod, any, any, TServices>[]> {\n const stream = fg.stream(routes, { cwd });\n\n const endpoints: Endpoint<string, HttpMethod, any, any, TServices>[] = [];\n\n for await (const f of stream) {\n // Resolve the absolute path for the route file\n const routePath = path.resolve(cwd, f.toString());\n // Dynamically import the route module\n const route = await import(routePath);\n\n // Filter exported values to find only Endpoint instances\n const handlers = Object.values(route).filter((value) => {\n return Endpoint.isEndpoint(value);\n }) as unknown as Endpoint<string, HttpMethod, any, any, TServices>[];\n\n endpoints.push(...handlers);\n }\n\n return endpoints;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,eAAeA,KAA8B;AACjE,KAAI,QAAQ,IACV,QAAO;CAGT,MAAM,SAAS,GAAG,OAChB;EAAC;EAAa;EAAkB;EAAqB;CAAY,GACjE;EAAE,KAAK;EAAM;CAAK,EACnB;CAED,IAAI,SAAS;AAEb,YAAW,MAAM,KAAK,QAAQ;AAC5B,WAAS;AACT;CACD;AAED,KAAI,OACF,QAAO;AAGT,QAAO,eAAe,KAAK,QAAQ,KAAK,KAAK,CAAC;AAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BD,eAAsB,uBACpBC,QACAD,KAC8D;CAC9D,MAAM,SAAS,GAAG,OAAO,QAAQ,EAAE,IAAK,EAAC;CAEzC,MAAME,YAAiE,CAAE;AAEzE,YAAW,MAAM,KAAK,QAAQ;EAE5B,MAAM,YAAY,KAAK,QAAQ,KAAK,EAAE,UAAU,CAAC;EAEjD,MAAM,QAAQ,MAAM,OAAO;EAG3B,MAAM,WAAW,OAAO,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU;AACtD,UAAO,SAAS,WAAW,MAAM;EAClC,EAAC;AAEF,YAAU,KAAK,GAAG,SAAS;CAC5B;AAED,QAAO;AACR"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionBuilder } from "./FunctionBuilder-C-PfPN3r.mjs";
|
|
2
|
+
import * as _geekmidas_logger8 from "@geekmidas/logger";
|
|
3
|
+
import * as _geekmidas_schema7 from "@geekmidas/schema";
|
|
4
|
+
|
|
5
|
+
//#region src/functions/index.d.ts
|
|
6
|
+
declare const f: FunctionBuilder<_geekmidas_schema7.ComposableStandardSchema, undefined, [], _geekmidas_logger8.Logger, undefined, string>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { f };
|
|
9
|
+
//# sourceMappingURL=index-CuGR4L7O.d.mts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionBuilder } from "./FunctionBuilder-BS1KgxA_.cjs";
|
|
2
|
+
import * as _geekmidas_logger7 from "@geekmidas/logger";
|
|
3
|
+
import * as _geekmidas_schema6 from "@geekmidas/schema";
|
|
4
|
+
|
|
5
|
+
//#region src/functions/index.d.ts
|
|
6
|
+
declare const f: FunctionBuilder<_geekmidas_schema6.ComposableStandardSchema, undefined, [], _geekmidas_logger7.Logger, undefined, string>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { f };
|
|
9
|
+
//# sourceMappingURL=index-Fg3N3EKD.d.cts.map
|
package/dist/index.cjs
ADDED
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Construct, ConstructType } from "./Construct-Bm-PSO2V.cjs";
|
|
2
|
+
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-Bp9ysFXd.cjs";
|
|
3
|
+
import { Service, ServiceRecord } from "@geekmidas/services";
|
|
4
|
+
export { Construct, ConstructType, HttpMethod, LowerHttpMethod, RemoveUndefined, Service, ServiceRecord };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Construct, ConstructType } from "./Construct-DIguIyw4.mjs";
|
|
2
|
+
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-DBKNYvsW.mjs";
|
|
3
|
+
import { Service, ServiceRecord } from "@geekmidas/services";
|
|
4
|
+
export { Construct, ConstructType, HttpMethod, LowerHttpMethod, RemoveUndefined, Service, ServiceRecord };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/endpoints/parseHonoQuery.ts
|
|
3
|
+
/**
|
|
4
|
+
* Parse Hono query parameters to handle arrays and nested objects
|
|
5
|
+
* Hono provides c.req.queries() for arrays, but we need to handle dot notation for objects
|
|
6
|
+
*/
|
|
7
|
+
function parseHonoQuery(c) {
|
|
8
|
+
const allParams = c.req.query();
|
|
9
|
+
const result = {};
|
|
10
|
+
for (const [key, value] of Object.entries(allParams)) if (key.includes(".")) {
|
|
11
|
+
const parts = key.split(".");
|
|
12
|
+
let current = result;
|
|
13
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
14
|
+
const part = parts[i];
|
|
15
|
+
if (!current[part] || typeof current[part] !== "object" || Array.isArray(current[part])) current[part] = {};
|
|
16
|
+
current = current[part];
|
|
17
|
+
}
|
|
18
|
+
const lastPart = parts[parts.length - 1];
|
|
19
|
+
const multipleValues = c.req.queries(key);
|
|
20
|
+
if (multipleValues && multipleValues.length > 1) current[lastPart] = multipleValues;
|
|
21
|
+
else current[lastPart] = value;
|
|
22
|
+
} else {
|
|
23
|
+
const multipleValues = c.req.queries(key);
|
|
24
|
+
if (multipleValues && multipleValues.length > 1) result[key] = multipleValues;
|
|
25
|
+
else result[key] = value;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
Object.defineProperty(exports, 'parseHonoQuery', {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return parseHonoQuery;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=parseHonoQuery-DopC24vB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseHonoQuery-DopC24vB.cjs","names":["c: Context","result: Record<string, any>"],"sources":["../src/endpoints/parseHonoQuery.ts"],"sourcesContent":["import type { Context } from 'hono';\n\n/**\n * Parse Hono query parameters to handle arrays and nested objects\n * Hono provides c.req.queries() for arrays, but we need to handle dot notation for objects\n */\nexport function parseHonoQuery(c: Context): Record<string, any> {\n const allParams = c.req.query();\n const result: Record<string, any> = {};\n\n // First, handle all query parameters\n for (const [key, value] of Object.entries(allParams)) {\n if (key.includes('.')) {\n // Handle dot notation for objects\n const parts = key.split('.');\n let current = result;\n\n // Navigate/create the nested structure\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (\n !current[part] ||\n typeof current[part] !== 'object' ||\n Array.isArray(current[part])\n ) {\n current[part] = {};\n }\n current = current[part];\n }\n\n // Set the final value, checking for arrays in nested keys\n const lastPart = parts[parts.length - 1];\n const multipleValues = c.req.queries(key);\n if (multipleValues && multipleValues.length > 1) {\n current[lastPart] = multipleValues;\n } else {\n current[lastPart] = value;\n }\n } else {\n // For regular keys, check if there are multiple values\n const multipleValues = c.req.queries(key);\n if (multipleValues && multipleValues.length > 1) {\n result[key] = multipleValues;\n } else {\n result[key] = value;\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;AAMA,SAAgB,eAAeA,GAAiC;CAC9D,MAAM,YAAY,EAAE,IAAI,OAAO;CAC/B,MAAMC,SAA8B,CAAE;AAGtC,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,UAAU,CAClD,KAAI,IAAI,SAAS,IAAI,EAAE;EAErB,MAAM,QAAQ,IAAI,MAAM,IAAI;EAC5B,IAAI,UAAU;AAGd,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;GACzC,MAAM,OAAO,MAAM;AACnB,QACG,QAAQ,gBACF,QAAQ,UAAU,YACzB,MAAM,QAAQ,QAAQ,MAAM,CAE5B,SAAQ,QAAQ,CAAE;AAEpB,aAAU,QAAQ;EACnB;EAGD,MAAM,WAAW,MAAM,MAAM,SAAS;EACtC,MAAM,iBAAiB,EAAE,IAAI,QAAQ,IAAI;AACzC,MAAI,kBAAkB,eAAe,SAAS,EAC5C,SAAQ,YAAY;MAEpB,SAAQ,YAAY;CAEvB,OAAM;EAEL,MAAM,iBAAiB,EAAE,IAAI,QAAQ,IAAI;AACzC,MAAI,kBAAkB,eAAe,SAAS,EAC5C,QAAO,OAAO;MAEd,QAAO,OAAO;CAEjB;AAGH,QAAO;AACR"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/endpoints/parseHonoQuery.ts
|
|
2
|
+
/**
|
|
3
|
+
* Parse Hono query parameters to handle arrays and nested objects
|
|
4
|
+
* Hono provides c.req.queries() for arrays, but we need to handle dot notation for objects
|
|
5
|
+
*/
|
|
6
|
+
function parseHonoQuery(c) {
|
|
7
|
+
const allParams = c.req.query();
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const [key, value] of Object.entries(allParams)) if (key.includes(".")) {
|
|
10
|
+
const parts = key.split(".");
|
|
11
|
+
let current = result;
|
|
12
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
13
|
+
const part = parts[i];
|
|
14
|
+
if (!current[part] || typeof current[part] !== "object" || Array.isArray(current[part])) current[part] = {};
|
|
15
|
+
current = current[part];
|
|
16
|
+
}
|
|
17
|
+
const lastPart = parts[parts.length - 1];
|
|
18
|
+
const multipleValues = c.req.queries(key);
|
|
19
|
+
if (multipleValues && multipleValues.length > 1) current[lastPart] = multipleValues;
|
|
20
|
+
else current[lastPart] = value;
|
|
21
|
+
} else {
|
|
22
|
+
const multipleValues = c.req.queries(key);
|
|
23
|
+
if (multipleValues && multipleValues.length > 1) result[key] = multipleValues;
|
|
24
|
+
else result[key] = value;
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { parseHonoQuery };
|
|
31
|
+
//# sourceMappingURL=parseHonoQuery-znDKBhdE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseHonoQuery-znDKBhdE.mjs","names":["c: Context","result: Record<string, any>"],"sources":["../src/endpoints/parseHonoQuery.ts"],"sourcesContent":["import type { Context } from 'hono';\n\n/**\n * Parse Hono query parameters to handle arrays and nested objects\n * Hono provides c.req.queries() for arrays, but we need to handle dot notation for objects\n */\nexport function parseHonoQuery(c: Context): Record<string, any> {\n const allParams = c.req.query();\n const result: Record<string, any> = {};\n\n // First, handle all query parameters\n for (const [key, value] of Object.entries(allParams)) {\n if (key.includes('.')) {\n // Handle dot notation for objects\n const parts = key.split('.');\n let current = result;\n\n // Navigate/create the nested structure\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (\n !current[part] ||\n typeof current[part] !== 'object' ||\n Array.isArray(current[part])\n ) {\n current[part] = {};\n }\n current = current[part];\n }\n\n // Set the final value, checking for arrays in nested keys\n const lastPart = parts[parts.length - 1];\n const multipleValues = c.req.queries(key);\n if (multipleValues && multipleValues.length > 1) {\n current[lastPart] = multipleValues;\n } else {\n current[lastPart] = value;\n }\n } else {\n // For regular keys, check if there are multiple values\n const multipleValues = c.req.queries(key);\n if (multipleValues && multipleValues.length > 1) {\n result[key] = multipleValues;\n } else {\n result[key] = value;\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;AAMA,SAAgB,eAAeA,GAAiC;CAC9D,MAAM,YAAY,EAAE,IAAI,OAAO;CAC/B,MAAMC,SAA8B,CAAE;AAGtC,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,UAAU,CAClD,KAAI,IAAI,SAAS,IAAI,EAAE;EAErB,MAAM,QAAQ,IAAI,MAAM,IAAI;EAC5B,IAAI,UAAU;AAGd,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;GACzC,MAAM,OAAO,MAAM;AACnB,QACG,QAAQ,gBACF,QAAQ,UAAU,YACzB,MAAM,QAAQ,QAAQ,MAAM,CAE5B,SAAQ,QAAQ,CAAE;AAEpB,aAAU,QAAQ;EACnB;EAGD,MAAM,WAAW,MAAM,MAAM,SAAS;EACtC,MAAM,iBAAiB,EAAE,IAAI,QAAQ,IAAI;AACzC,MAAI,kBAAkB,eAAe,SAAS,EAC5C,SAAQ,YAAY;MAEpB,SAAQ,YAAY;CAEvB,OAAM;EAEL,MAAM,iBAAiB,EAAE,IAAI,QAAQ,IAAI;AACzC,MAAI,kBAAkB,eAAe,SAAS,EAC5C,QAAO,OAAO;MAEd,QAAO,OAAO;CAEjB;AAGH,QAAO;AACR"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/endpoints/parseQueryParams.ts
|
|
2
|
+
/**
|
|
3
|
+
* Parse query parameters from a flat object into a nested structure
|
|
4
|
+
* Handles arrays (multiple values with same key) and objects (dot notation)
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* parseQueryParams({ 'tags': ['a', 'b'], 'filter.name': 'john' })
|
|
8
|
+
* // Returns: { tags: ['a', 'b'], filter: { name: 'john' } }
|
|
9
|
+
*/
|
|
10
|
+
function parseQueryParams(queryParams) {
|
|
11
|
+
if (!queryParams) return {};
|
|
12
|
+
const result = {};
|
|
13
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
14
|
+
if (value === void 0) continue;
|
|
15
|
+
if (key.includes(".")) {
|
|
16
|
+
const parts = key.split(".");
|
|
17
|
+
let current = result;
|
|
18
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
19
|
+
const part = parts[i];
|
|
20
|
+
if (!current[part] || typeof current[part] !== "object" || Array.isArray(current[part])) current[part] = {};
|
|
21
|
+
current = current[part];
|
|
22
|
+
}
|
|
23
|
+
const lastPart = parts[parts.length - 1];
|
|
24
|
+
current[lastPart] = value;
|
|
25
|
+
} else result[key] = value;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { parseQueryParams };
|
|
32
|
+
//# sourceMappingURL=parseQueryParams-BJaRh3OB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseQueryParams-BJaRh3OB.mjs","names":["queryParams: Record<string, string | string[] | undefined> | null","result: Record<string, any>"],"sources":["../src/endpoints/parseQueryParams.ts"],"sourcesContent":["/**\n * Parse query parameters from a flat object into a nested structure\n * Handles arrays (multiple values with same key) and objects (dot notation)\n *\n * @example\n * parseQueryParams({ 'tags': ['a', 'b'], 'filter.name': 'john' })\n * // Returns: { tags: ['a', 'b'], filter: { name: 'john' } }\n */\nexport function parseQueryParams(\n queryParams: Record<string, string | string[] | undefined> | null,\n): Record<string, any> {\n if (!queryParams) {\n return {};\n }\n\n const result: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(queryParams)) {\n if (value === undefined) {\n continue;\n }\n\n // Check if the key contains dot notation\n if (key.includes('.')) {\n const parts = key.split('.');\n let current = result;\n\n // Navigate/create the nested structure\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (\n !current[part] ||\n typeof current[part] !== 'object' ||\n Array.isArray(current[part])\n ) {\n current[part] = {};\n }\n current = current[part];\n }\n\n // Set the final value\n const lastPart = parts[parts.length - 1];\n current[lastPart] = value;\n } else {\n // Simple key, just assign the value\n result[key] = value;\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,iBACdA,aACqB;AACrB,MAAK,YACH,QAAO,CAAE;CAGX,MAAMC,SAA8B,CAAE;AAEtC,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,YAAY,EAAE;AACtD,MAAI,iBACF;AAIF,MAAI,IAAI,SAAS,IAAI,EAAE;GACrB,MAAM,QAAQ,IAAI,MAAM,IAAI;GAC5B,IAAI,UAAU;AAGd,QAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;IACzC,MAAM,OAAO,MAAM;AACnB,SACG,QAAQ,gBACF,QAAQ,UAAU,YACzB,MAAM,QAAQ,QAAQ,MAAM,CAE5B,SAAQ,QAAQ,CAAE;AAEpB,cAAU,QAAQ;GACnB;GAGD,MAAM,WAAW,MAAM,MAAM,SAAS;AACtC,WAAQ,YAAY;EACrB,MAEC,QAAO,OAAO;CAEjB;AAED,QAAO;AACR"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/endpoints/parseQueryParams.ts
|
|
3
|
+
/**
|
|
4
|
+
* Parse query parameters from a flat object into a nested structure
|
|
5
|
+
* Handles arrays (multiple values with same key) and objects (dot notation)
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* parseQueryParams({ 'tags': ['a', 'b'], 'filter.name': 'john' })
|
|
9
|
+
* // Returns: { tags: ['a', 'b'], filter: { name: 'john' } }
|
|
10
|
+
*/
|
|
11
|
+
function parseQueryParams(queryParams) {
|
|
12
|
+
if (!queryParams) return {};
|
|
13
|
+
const result = {};
|
|
14
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
15
|
+
if (value === void 0) continue;
|
|
16
|
+
if (key.includes(".")) {
|
|
17
|
+
const parts = key.split(".");
|
|
18
|
+
let current = result;
|
|
19
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
20
|
+
const part = parts[i];
|
|
21
|
+
if (!current[part] || typeof current[part] !== "object" || Array.isArray(current[part])) current[part] = {};
|
|
22
|
+
current = current[part];
|
|
23
|
+
}
|
|
24
|
+
const lastPart = parts[parts.length - 1];
|
|
25
|
+
current[lastPart] = value;
|
|
26
|
+
} else result[key] = value;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
Object.defineProperty(exports, 'parseQueryParams', {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return parseQueryParams;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=parseQueryParams-BzPop4I1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseQueryParams-BzPop4I1.cjs","names":["queryParams: Record<string, string | string[] | undefined> | null","result: Record<string, any>"],"sources":["../src/endpoints/parseQueryParams.ts"],"sourcesContent":["/**\n * Parse query parameters from a flat object into a nested structure\n * Handles arrays (multiple values with same key) and objects (dot notation)\n *\n * @example\n * parseQueryParams({ 'tags': ['a', 'b'], 'filter.name': 'john' })\n * // Returns: { tags: ['a', 'b'], filter: { name: 'john' } }\n */\nexport function parseQueryParams(\n queryParams: Record<string, string | string[] | undefined> | null,\n): Record<string, any> {\n if (!queryParams) {\n return {};\n }\n\n const result: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(queryParams)) {\n if (value === undefined) {\n continue;\n }\n\n // Check if the key contains dot notation\n if (key.includes('.')) {\n const parts = key.split('.');\n let current = result;\n\n // Navigate/create the nested structure\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (\n !current[part] ||\n typeof current[part] !== 'object' ||\n Array.isArray(current[part])\n ) {\n current[part] = {};\n }\n current = current[part];\n }\n\n // Set the final value\n const lastPart = parts[parts.length - 1];\n current[lastPart] = value;\n } else {\n // Simple key, just assign the value\n result[key] = value;\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,iBACdA,aACqB;AACrB,MAAK,YACH,QAAO,CAAE;CAGX,MAAMC,SAA8B,CAAE;AAEtC,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,YAAY,EAAE;AACtD,MAAI,iBACF;AAIF,MAAI,IAAI,SAAS,IAAI,EAAE;GACrB,MAAM,QAAQ,IAAI,MAAM,IAAI;GAC5B,IAAI,UAAU;AAGd,QAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;IACzC,MAAM,OAAO,MAAM;AACnB,SACG,QAAQ,gBACF,QAAQ,UAAU,YACzB,MAAM,QAAQ,QAAQ,MAAM,CAE5B,SAAQ,QAAQ,CAAE;AAEpB,cAAU,QAAQ;GACnB;GAGD,MAAM,WAAW,MAAM,MAAM,SAAS;AACtC,WAAQ,YAAY;EACrB,MAEC,QAAO,OAAO;CAEjB;AAED,QAAO;AACR"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/publisher.ts
|
|
2
|
+
async function publishEvents(logger, serviceDiscovery, ev = [], response, publisherService) {
|
|
3
|
+
try {
|
|
4
|
+
if (!ev?.length) {
|
|
5
|
+
logger.debug("No events to publish");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (!publisherService) {
|
|
9
|
+
logger.warn("No publisher service available");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const services = await serviceDiscovery.register([publisherService]);
|
|
13
|
+
const publisher = services[publisherService.serviceName];
|
|
14
|
+
const events = [];
|
|
15
|
+
for (const { when, payload, type,...e } of ev) {
|
|
16
|
+
logger.debug({ event: type }, "Processing event");
|
|
17
|
+
const resolvedPayload = await payload(response);
|
|
18
|
+
const event = {
|
|
19
|
+
...e,
|
|
20
|
+
type,
|
|
21
|
+
payload: resolvedPayload
|
|
22
|
+
};
|
|
23
|
+
if (!when || when(response)) events.push(event);
|
|
24
|
+
}
|
|
25
|
+
if (events.length) {
|
|
26
|
+
logger.debug({ eventCount: ev.length }, "Publishing events");
|
|
27
|
+
await publisher.publish(events).catch((err) => {
|
|
28
|
+
logger.error(err, "Failed to publish events");
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
logger.error(error, "Something went wrong publishing events");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function publishConstructEvents(construct, response, serviceDiscovery, logger = construct.logger) {
|
|
36
|
+
return publishEvents(logger, serviceDiscovery, construct.events, response, construct.publisherService);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { publishConstructEvents, publishEvents };
|
|
41
|
+
//# sourceMappingURL=publisher-Bw4770Hi.mjs.map
|