@geekmidas/constructs 0.0.6 → 0.0.9
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/dist/{AWSLambdaFunction-qA5LqPsv.cjs → AWSLambdaFunction-CMLZ3GaC.cjs} +3 -3
- package/dist/{AWSLambdaFunction-qA5LqPsv.cjs.map → AWSLambdaFunction-CMLZ3GaC.cjs.map} +1 -1
- package/dist/{AWSLambdaFunction-CANc3Qo2.d.mts → AWSLambdaFunction-D5V3YVqv.d.cts} +5 -5
- package/dist/{AWSLambdaFunction-CwagvPG3.d.cts → AWSLambdaFunction-_J0MjixY.d.mts} +5 -5
- package/dist/{AWSLambdaFunction-DWIZYsCy.mjs → AWSLambdaFunction-egVcP17n.mjs} +3 -3
- package/dist/{AWSLambdaFunction-DWIZYsCy.mjs.map → AWSLambdaFunction-egVcP17n.mjs.map} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-QKVxR6qh.d.cts → AWSLambdaSubscriberAdaptor-DjG1ME3P.d.mts} +4 -4
- package/dist/{AWSLambdaSubscriberAdaptor-C6JYIZxn.d.mts → AWSLambdaSubscriberAdaptor-J_pSz6pu.d.cts} +4 -4
- package/dist/{AmazonApiGatewayEndpointAdaptor-BFhJ2Rpz.d.cts → AmazonApiGatewayEndpointAdaptor-BnNd8tCz.d.cts} +2 -2
- package/dist/{AmazonApiGatewayEndpointAdaptor-BrB3RfbI.d.mts → AmazonApiGatewayEndpointAdaptor-C-17dUai.d.mts} +2 -2
- package/dist/{AmazonApiGatewayEndpointAdaptor-Bmz6Cy1e.mjs → AmazonApiGatewayEndpointAdaptor-CQLjGSJe.mjs} +2 -2
- package/dist/{AmazonApiGatewayEndpointAdaptor-Bmz6Cy1e.mjs.map → AmazonApiGatewayEndpointAdaptor-CQLjGSJe.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayEndpointAdaptor-B8mozTcG.cjs → AmazonApiGatewayEndpointAdaptor-DPaV_5wG.cjs} +2 -2
- package/dist/{AmazonApiGatewayEndpointAdaptor-B8mozTcG.cjs.map → AmazonApiGatewayEndpointAdaptor-DPaV_5wG.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-Bd-o8ese.d.cts → AmazonApiGatewayV1EndpointAdaptor-BC-a2tt3.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-BtNXt0-4.d.mts → AmazonApiGatewayV1EndpointAdaptor-Cjud-a6p.d.mts} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-24g3dLn5.mjs → AmazonApiGatewayV1EndpointAdaptor-DEBcyZe0.mjs} +2 -2
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-24g3dLn5.mjs.map → AmazonApiGatewayV1EndpointAdaptor-DEBcyZe0.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-D4eZ-fx5.cjs → AmazonApiGatewayV1EndpointAdaptor-DkFcSRwT.cjs} +2 -2
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-D4eZ-fx5.cjs.map → AmazonApiGatewayV1EndpointAdaptor-DkFcSRwT.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-Cc40RThv.mjs → AmazonApiGatewayV2EndpointAdaptor-BB7t7LE2.mjs} +2 -2
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-Cc40RThv.mjs.map → AmazonApiGatewayV2EndpointAdaptor-BB7t7LE2.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-J6tACl-N.cjs → AmazonApiGatewayV2EndpointAdaptor-BQ21ry6s.cjs} +2 -2
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-J6tACl-N.cjs.map → AmazonApiGatewayV2EndpointAdaptor-BQ21ry6s.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DAJdtgek.d.mts → AmazonApiGatewayV2EndpointAdaptor-C31Xcwmc.d.mts} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DX-Uci5w.d.cts → AmazonApiGatewayV2EndpointAdaptor-zNFUPxSY.d.cts} +3 -3
- package/dist/Authorizer-Bbk9ziuG.d.mts +29 -0
- package/dist/Authorizer-iXsSB600.d.cts +29 -0
- package/dist/{BaseFunctionBuilder-DtO4Nwxm.cjs → BaseFunctionBuilder-B-kdtkzI.cjs} +2 -2
- package/dist/{BaseFunctionBuilder-DtO4Nwxm.cjs.map → BaseFunctionBuilder-B-kdtkzI.cjs.map} +1 -1
- package/dist/{BaseFunctionBuilder-5QCHkchp.d.cts → BaseFunctionBuilder-C4ZJPkIZ.d.cts} +2 -2
- package/dist/{BaseFunctionBuilder-Dda7AiID.d.mts → BaseFunctionBuilder-CxBX0arJ.d.mts} +2 -2
- package/dist/{BaseFunctionBuilder-BPE9JBbT.mjs → BaseFunctionBuilder-DOhEn5Ce.mjs} +2 -2
- package/dist/{BaseFunctionBuilder-BPE9JBbT.mjs.map → BaseFunctionBuilder-DOhEn5Ce.mjs.map} +1 -1
- package/dist/{Construct-BbKCIPQm.mjs → Construct-B-O9OBS1.mjs} +4 -2
- package/dist/Construct-B-O9OBS1.mjs.map +1 -0
- package/dist/{Construct-BSEs6uwW.cjs → Construct-BtfN2fcm.cjs} +4 -2
- package/dist/Construct-BtfN2fcm.cjs.map +1 -0
- package/dist/{Construct-Bm-PSO2V.d.cts → Construct-ci5u8Xnu.d.cts} +4 -2
- package/dist/{Construct-DdyYENBD.d.mts → Construct-zhmcmIdY.d.mts} +4 -2
- package/dist/Construct.cjs +1 -1
- package/dist/Construct.d.cts +1 -1
- package/dist/Construct.d.mts +1 -1
- package/dist/Construct.mjs +1 -1
- package/dist/{Cron-BxMXmn4t.d.cts → Cron-ByNYsQDH.d.mts} +4 -4
- package/dist/{Cron-z0RiwSnT.mjs → Cron-D8DPUXBd.mjs} +5 -5
- package/dist/Cron-D8DPUXBd.mjs.map +1 -0
- package/dist/{Cron-NDBlJhb3.d.mts → Cron-DkPL-Fms.d.cts} +4 -4
- package/dist/{Cron-D6MyCqby.cjs → Cron-sOrsPuQj.cjs} +5 -5
- package/dist/Cron-sOrsPuQj.cjs.map +1 -0
- package/dist/{CronBuilder-C6K5AbIO.d.cts → CronBuilder-BknVTWLE.d.mts} +6 -5
- package/dist/{CronBuilder-s5x8V8hH.d.mts → CronBuilder-BqTTozUi.d.cts} +6 -5
- package/dist/{CronBuilder-BLTgwOWp.mjs → CronBuilder-ChyrDobL.mjs} +10 -5
- package/dist/CronBuilder-ChyrDobL.mjs.map +1 -0
- package/dist/{CronBuilder-BOsYnZIm.cjs → CronBuilder-Kvz1GiUp.cjs} +10 -5
- package/dist/CronBuilder-Kvz1GiUp.cjs.map +1 -0
- package/dist/{Endpoint-COGAflGh.cjs → Endpoint-Bghj0fiL.cjs} +21 -12
- package/dist/Endpoint-Bghj0fiL.cjs.map +1 -0
- package/dist/{Endpoint-C7jPJzAH.d.mts → Endpoint-C16whGI-.d.mts} +45 -13
- package/dist/{Endpoint-DLLZvqoh.mjs → Endpoint-DCJz2VQ_.mjs} +21 -12
- package/dist/Endpoint-DCJz2VQ_.mjs.map +1 -0
- package/dist/{Endpoint-XUMNAXYy.d.cts → Endpoint-zHPjZ35J.d.cts} +45 -13
- package/dist/{EndpointBuilder-t6fVEKBH.d.cts → EndpointBuilder-B5l7zQU1.d.cts} +18 -12
- package/dist/{EndpointBuilder-DpmUw--c.mjs → EndpointBuilder-B6xIAruu.mjs} +28 -5
- package/dist/EndpointBuilder-B6xIAruu.mjs.map +1 -0
- package/dist/{EndpointBuilder-CFtWQhcv.d.mts → EndpointBuilder-BzqR0xvt.d.mts} +18 -12
- package/dist/{EndpointBuilder-DUE8ETVR.cjs → EndpointBuilder-i7-4ieP_.cjs} +28 -5
- package/dist/EndpointBuilder-i7-4ieP_.cjs.map +1 -0
- package/dist/{EndpointFactory-YAR24M2i.cjs → EndpointFactory-CYTBPu_G.cjs} +41 -10
- package/dist/EndpointFactory-CYTBPu_G.cjs.map +1 -0
- package/dist/{EndpointFactory-CuJUCyvZ.mjs → EndpointFactory-CYuT-nt-.mjs} +41 -10
- package/dist/EndpointFactory-CYuT-nt-.mjs.map +1 -0
- package/dist/{EndpointFactory-DInjHvFR.d.cts → EndpointFactory-KkyIOE62.d.cts} +28 -20
- package/dist/{EndpointFactory-DBRGrXAy.d.mts → EndpointFactory-VnSAdwdv.d.mts} +28 -20
- package/dist/{Function-CbO2NZx-.cjs → Function-BCEAZFyL.cjs} +4 -5
- package/dist/Function-BCEAZFyL.cjs.map +1 -0
- package/dist/{Function-BP58p9Mp.d.cts → Function-BbLYIKLL.d.cts} +3 -4
- package/dist/{Function-C5mW-38v.mjs → Function-CmfMIDoS.mjs} +4 -5
- package/dist/Function-CmfMIDoS.mjs.map +1 -0
- package/dist/{Function-C98H68DW.d.mts → Function-DFRZZCC-.d.mts} +3 -4
- package/dist/{FunctionBuilder-DuOeWCAl.cjs → FunctionBuilder-BqivB_cc.cjs} +11 -5
- package/dist/FunctionBuilder-BqivB_cc.cjs.map +1 -0
- package/dist/{FunctionBuilder-BS1KgxA_.d.cts → FunctionBuilder-DdGjpiFT.d.cts} +6 -4
- package/dist/{FunctionBuilder-DBwR7jg7.d.mts → FunctionBuilder-DuktGyZc.d.mts} +6 -4
- package/dist/{FunctionBuilder-CosgPmMl.mjs → FunctionBuilder-QvqvEyFa.mjs} +11 -5
- package/dist/FunctionBuilder-QvqvEyFa.mjs.map +1 -0
- package/dist/{FunctionExecutionWrapper-B0V7V8YS.d.mts → FunctionExecutionWrapper-CAHR74yI.d.mts} +2 -2
- package/dist/{FunctionExecutionWrapper-Bx-Dl-2a.d.cts → FunctionExecutionWrapper-CRYi047B.d.cts} +2 -2
- package/dist/{FunctionExecutionWrapper-XGrSAAPD.mjs → FunctionExecutionWrapper-JsZIHhcl.mjs} +2 -2
- package/dist/{FunctionExecutionWrapper-XGrSAAPD.mjs.map → FunctionExecutionWrapper-JsZIHhcl.mjs.map} +1 -1
- package/dist/{FunctionExecutionWrapper-CElXEjPe.cjs → FunctionExecutionWrapper-TJxf9p4v.cjs} +2 -2
- package/dist/{FunctionExecutionWrapper-CElXEjPe.cjs.map → FunctionExecutionWrapper-TJxf9p4v.cjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-BlT1rWHV.mjs → HonoEndpointAdaptor-8eYrSFRn.mjs} +33 -16
- package/dist/HonoEndpointAdaptor-8eYrSFRn.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-C9Xe2pRp.d.mts → HonoEndpointAdaptor-DAsZoX2a.d.mts} +5 -4
- package/dist/{HonoEndpointAdaptor-CGSqpnCD.d.cts → HonoEndpointAdaptor-lYw6EN1Q.d.cts} +5 -4
- package/dist/{HonoEndpointAdaptor-Ds433Q8w.cjs → HonoEndpointAdaptor-vWSpXdNp.cjs} +20 -3
- package/dist/HonoEndpointAdaptor-vWSpXdNp.cjs.map +1 -0
- package/dist/{Subscriber-G7EUI3yc.cjs → Subscriber-BdiqU7da.cjs} +2 -2
- package/dist/{Subscriber-G7EUI3yc.cjs.map → Subscriber-BdiqU7da.cjs.map} +1 -1
- package/dist/{Subscriber-BoFm12i_.d.cts → Subscriber-Cy28j8MS.d.cts} +2 -2
- package/dist/{Subscriber-BTwKnz3c.mjs → Subscriber-bJSqvjdK.mjs} +2 -2
- package/dist/{Subscriber-BTwKnz3c.mjs.map → Subscriber-bJSqvjdK.mjs.map} +1 -1
- package/dist/{Subscriber-BxH6n8zQ.d.mts → Subscriber-g3IWM1_d.d.mts} +2 -2
- package/dist/{SubscriberBuilder-BpSDPzBz.d.mts → SubscriberBuilder-BzK8kc2a.d.cts} +3 -3
- package/dist/{SubscriberBuilder-C1me_972.mjs → SubscriberBuilder-CyCyjT6L.mjs} +2 -2
- package/dist/{SubscriberBuilder-C1me_972.mjs.map → SubscriberBuilder-CyCyjT6L.mjs.map} +1 -1
- package/dist/{SubscriberBuilder-C6iZvuDe.cjs → SubscriberBuilder-JTJcIZYy.cjs} +2 -2
- package/dist/{SubscriberBuilder-C6iZvuDe.cjs.map → SubscriberBuilder-JTJcIZYy.cjs.map} +1 -1
- package/dist/{SubscriberBuilder-DgljKtYu.d.cts → SubscriberBuilder-YjQ7qIpQ.d.mts} +3 -3
- package/dist/{TestEndpointAdaptor-BG6fzAOx.mjs → TestEndpointAdaptor-BevV2LLd.mjs} +33 -7
- package/dist/TestEndpointAdaptor-BevV2LLd.mjs.map +1 -0
- package/dist/{TestEndpointAdaptor-Db0cm1fb.d.mts → TestEndpointAdaptor-DGWuai69.d.mts} +10 -4
- package/dist/{TestEndpointAdaptor-BaQaTy_1.cjs → TestEndpointAdaptor-DupnzEnS.cjs} +33 -7
- package/dist/TestEndpointAdaptor-DupnzEnS.cjs.map +1 -0
- package/dist/{TestEndpointAdaptor-v7A-7hTs.d.cts → TestEndpointAdaptor-uXliWYjS.d.cts} +10 -4
- package/dist/adaptors/aws.cjs +11 -11
- package/dist/adaptors/aws.d.cts +14 -13
- package/dist/adaptors/aws.d.mts +14 -13
- package/dist/adaptors/aws.mjs +11 -11
- package/dist/adaptors/hono.cjs +8 -8
- package/dist/adaptors/hono.d.cts +8 -7
- package/dist/adaptors/hono.d.mts +8 -7
- package/dist/adaptors/hono.mjs +8 -8
- package/dist/adaptors/testing.cjs +7 -7
- package/dist/adaptors/testing.d.cts +8 -7
- package/dist/adaptors/testing.d.mts +8 -7
- package/dist/adaptors/testing.mjs +7 -7
- package/dist/crons/Cron.cjs +6 -6
- package/dist/crons/Cron.d.cts +6 -6
- package/dist/crons/Cron.d.mts +6 -6
- package/dist/crons/Cron.mjs +6 -6
- package/dist/crons/CronBuilder.cjs +7 -7
- package/dist/crons/CronBuilder.d.cts +7 -7
- package/dist/crons/CronBuilder.d.mts +7 -7
- package/dist/crons/CronBuilder.mjs +7 -7
- package/dist/crons/index.cjs +7 -7
- package/dist/crons/index.d.cts +11 -11
- package/dist/crons/index.d.mts +7 -7
- package/dist/crons/index.mjs +7 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +7 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +8 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +8 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +7 -7
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +8 -8
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +9 -8
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +9 -8
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +8 -8
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +8 -8
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +9 -8
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +9 -8
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +8 -8
- package/dist/endpoints/Authorizer.cjs +15 -0
- package/dist/endpoints/Authorizer.cjs.map +1 -0
- package/dist/endpoints/Authorizer.d.cts +2 -0
- package/dist/endpoints/Authorizer.d.mts +2 -0
- package/dist/endpoints/Authorizer.mjs +14 -0
- package/dist/endpoints/Authorizer.mjs.map +1 -0
- package/dist/endpoints/Endpoint.cjs +6 -6
- package/dist/endpoints/Endpoint.d.cts +7 -6
- package/dist/endpoints/Endpoint.d.mts +7 -6
- package/dist/endpoints/Endpoint.mjs +6 -6
- package/dist/endpoints/EndpointBuilder.cjs +7 -7
- package/dist/endpoints/EndpointBuilder.d.cts +8 -7
- package/dist/endpoints/EndpointBuilder.d.mts +8 -7
- package/dist/endpoints/EndpointBuilder.mjs +7 -7
- package/dist/endpoints/EndpointFactory.cjs +8 -8
- package/dist/endpoints/EndpointFactory.d.cts +9 -8
- package/dist/endpoints/EndpointFactory.d.mts +9 -8
- package/dist/endpoints/EndpointFactory.mjs +8 -8
- package/dist/endpoints/HonoEndpointAdaptor.cjs +8 -8
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +8 -7
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +8 -7
- package/dist/endpoints/HonoEndpointAdaptor.mjs +8 -8
- package/dist/endpoints/TestEndpointAdaptor.cjs +7 -7
- package/dist/endpoints/TestEndpointAdaptor.d.cts +9 -8
- package/dist/endpoints/TestEndpointAdaptor.d.mts +9 -8
- package/dist/endpoints/TestEndpointAdaptor.mjs +7 -7
- package/dist/endpoints/helpers.cjs +7 -7
- package/dist/endpoints/helpers.d.cts +7 -6
- package/dist/endpoints/helpers.d.mts +7 -6
- package/dist/endpoints/helpers.mjs +7 -7
- package/dist/endpoints/index.cjs +8 -8
- package/dist/endpoints/index.d.cts +11 -10
- package/dist/endpoints/index.d.mts +11 -10
- package/dist/endpoints/index.mjs +8 -8
- package/dist/functions/AWSLambdaFunction.cjs +6 -6
- package/dist/functions/AWSLambdaFunction.d.cts +4 -4
- package/dist/functions/AWSLambdaFunction.d.mts +4 -4
- package/dist/functions/AWSLambdaFunction.mjs +6 -6
- package/dist/functions/BaseFunctionBuilder.cjs +2 -2
- package/dist/functions/BaseFunctionBuilder.d.cts +2 -2
- package/dist/functions/BaseFunctionBuilder.d.mts +2 -2
- package/dist/functions/BaseFunctionBuilder.mjs +2 -2
- package/dist/functions/Function.cjs +2 -2
- package/dist/functions/Function.d.cts +2 -2
- package/dist/functions/Function.d.mts +2 -2
- package/dist/functions/Function.mjs +2 -2
- package/dist/functions/FunctionBuilder.cjs +4 -4
- package/dist/functions/FunctionBuilder.d.cts +4 -4
- package/dist/functions/FunctionBuilder.d.mts +4 -4
- package/dist/functions/FunctionBuilder.mjs +4 -4
- package/dist/functions/FunctionExecutionWrapper.cjs +5 -5
- package/dist/functions/FunctionExecutionWrapper.d.cts +3 -3
- package/dist/functions/FunctionExecutionWrapper.d.mts +3 -3
- package/dist/functions/FunctionExecutionWrapper.mjs +5 -5
- package/dist/functions/TestFunctionAdaptor.cjs +4 -4
- package/dist/functions/TestFunctionAdaptor.d.cts +2 -2
- package/dist/functions/TestFunctionAdaptor.d.mts +2 -2
- package/dist/functions/TestFunctionAdaptor.mjs +4 -4
- package/dist/functions/index.cjs +5 -5
- package/dist/functions/index.d.cts +5 -5
- package/dist/functions/index.d.mts +5 -5
- package/dist/functions/index.mjs +5 -5
- package/dist/{functions-DVDb5wEA.cjs → functions-B9mEg9D9.cjs} +2 -2
- package/dist/{functions-DVDb5wEA.cjs.map → functions-B9mEg9D9.cjs.map} +1 -1
- package/dist/functions-DcQZSOHg.mjs +8 -0
- package/dist/{functions-mM-jcphA.mjs.map → functions-DcQZSOHg.mjs.map} +1 -1
- package/dist/{helpers-go4jiRvV.cjs → helpers-BJrzAmhb.cjs} +2 -2
- package/dist/{helpers-go4jiRvV.cjs.map → helpers-BJrzAmhb.cjs.map} +1 -1
- package/dist/{helpers-CM0U-4Vk.mjs → helpers-D_UKinz8.mjs} +2 -2
- package/dist/{helpers-CM0U-4Vk.mjs.map → helpers-D_UKinz8.mjs.map} +1 -1
- package/dist/index-DQt3pQtF.d.mts +9 -0
- package/dist/index-Dq-LQIwK.d.cts +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/publisher.d.cts +1 -1
- package/dist/publisher.d.mts +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.cts +3 -3
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +3 -3
- package/dist/subscribers/Subscriber.cjs +2 -2
- package/dist/subscribers/Subscriber.d.cts +2 -2
- package/dist/subscribers/Subscriber.d.mts +2 -2
- package/dist/subscribers/Subscriber.mjs +2 -2
- package/dist/subscribers/SubscriberBuilder.cjs +3 -3
- package/dist/subscribers/SubscriberBuilder.d.cts +3 -3
- package/dist/subscribers/SubscriberBuilder.d.mts +3 -3
- package/dist/subscribers/SubscriberBuilder.mjs +3 -3
- package/dist/subscribers/index.cjs +3 -3
- package/dist/subscribers/index.d.cts +5 -5
- package/dist/subscribers/index.d.mts +5 -5
- package/dist/subscribers/index.mjs +3 -3
- package/package.json +5 -5
- package/src/Construct.ts +2 -0
- package/src/crons/Cron.ts +2 -0
- package/src/crons/CronBuilder.ts +8 -0
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +227 -0
- package/src/endpoints/Authorizer.ts +34 -0
- package/src/endpoints/Endpoint.ts +67 -14
- package/src/endpoints/EndpointBuilder.ts +79 -12
- package/src/endpoints/EndpointFactory.ts +106 -27
- package/src/endpoints/HonoEndpointAdaptor.ts +29 -0
- package/src/endpoints/TestEndpointAdaptor.ts +75 -14
- package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +85 -0
- package/src/endpoints/__tests__/Endpoint.headers.spec.ts +187 -0
- package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +176 -0
- package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +259 -0
- package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +190 -0
- package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +155 -0
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +309 -42
- package/src/functions/Function.ts +12 -2
- package/src/functions/FunctionBuilder.ts +9 -0
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +160 -0
- package/dist/Construct-BSEs6uwW.cjs.map +0 -1
- package/dist/Construct-BbKCIPQm.mjs.map +0 -1
- package/dist/Cron-D6MyCqby.cjs.map +0 -1
- package/dist/Cron-z0RiwSnT.mjs.map +0 -1
- package/dist/CronBuilder-BLTgwOWp.mjs.map +0 -1
- package/dist/CronBuilder-BOsYnZIm.cjs.map +0 -1
- package/dist/Endpoint-COGAflGh.cjs.map +0 -1
- package/dist/Endpoint-DLLZvqoh.mjs.map +0 -1
- package/dist/EndpointBuilder-DUE8ETVR.cjs.map +0 -1
- package/dist/EndpointBuilder-DpmUw--c.mjs.map +0 -1
- package/dist/EndpointFactory-CuJUCyvZ.mjs.map +0 -1
- package/dist/EndpointFactory-YAR24M2i.cjs.map +0 -1
- package/dist/Function-C5mW-38v.mjs.map +0 -1
- package/dist/Function-CbO2NZx-.cjs.map +0 -1
- package/dist/FunctionBuilder-CosgPmMl.mjs.map +0 -1
- package/dist/FunctionBuilder-DuOeWCAl.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-BlT1rWHV.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-Ds433Q8w.cjs.map +0 -1
- package/dist/TestEndpointAdaptor-BG6fzAOx.mjs.map +0 -1
- package/dist/TestEndpointAdaptor-BaQaTy_1.cjs.map +0 -1
- package/dist/functions-mM-jcphA.mjs +0 -8
- package/dist/index-BXTN4mwI.d.mts +0 -9
- package/dist/index-BxApEwAF.d.cts +0 -9
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { EndpointFactory } from '../EndpointFactory';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
describe('EndpointFactory.authorizers', () => {
|
|
6
|
+
it('should create factory with available authorizers', () => {
|
|
7
|
+
const factory = new EndpointFactory().authorizers([
|
|
8
|
+
'iam',
|
|
9
|
+
'jwt-auth0',
|
|
10
|
+
'custom',
|
|
11
|
+
] as const);
|
|
12
|
+
|
|
13
|
+
const endpoint = factory
|
|
14
|
+
.get('/users')
|
|
15
|
+
.authorizer('iam')
|
|
16
|
+
.handle(async () => ({ success: true }));
|
|
17
|
+
|
|
18
|
+
expect(endpoint.authorizer).toEqual({ name: 'iam' });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should allow setting authorizer on individual endpoints', () => {
|
|
22
|
+
const factory = new EndpointFactory().authorizers(['iam', 'jwt'] as const);
|
|
23
|
+
|
|
24
|
+
const endpoint1 = factory
|
|
25
|
+
.post('/admin/users')
|
|
26
|
+
.authorizer('iam')
|
|
27
|
+
.body(z.object({ name: z.string() }))
|
|
28
|
+
.handle(async () => ({ success: true }));
|
|
29
|
+
|
|
30
|
+
const endpoint2 = factory
|
|
31
|
+
.get('/api/users')
|
|
32
|
+
.authorizer('jwt')
|
|
33
|
+
.handle(async () => ({ users: [] }));
|
|
34
|
+
|
|
35
|
+
expect(endpoint1.authorizer).toEqual({ name: 'iam' });
|
|
36
|
+
expect(endpoint2.authorizer).toEqual({ name: 'jwt' });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should throw error when using non-existent authorizer', () => {
|
|
40
|
+
const factory = new EndpointFactory().authorizers(['iam', 'jwt'] as const);
|
|
41
|
+
|
|
42
|
+
expect(() => {
|
|
43
|
+
factory
|
|
44
|
+
.post('/users')
|
|
45
|
+
// @ts-expect-error - testing invalid authorizer
|
|
46
|
+
.authorizer('invalid')
|
|
47
|
+
.handle(async () => ({ success: true }));
|
|
48
|
+
}).toThrow('Authorizer "invalid" not found in available authorizers: iam, jwt');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should allow endpoints without authorizers', () => {
|
|
52
|
+
const factory = new EndpointFactory().authorizers(['iam', 'jwt'] as const);
|
|
53
|
+
|
|
54
|
+
const endpoint = factory.get('/public').handle(async () => ({ success: true }));
|
|
55
|
+
|
|
56
|
+
expect(endpoint.authorizer).toBeUndefined();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should preserve authorizers when chaining factory methods', () => {
|
|
60
|
+
const factory = new EndpointFactory()
|
|
61
|
+
.authorizers(['iam', 'jwt', 'api-key'] as const)
|
|
62
|
+
.route('/api/v1');
|
|
63
|
+
|
|
64
|
+
const endpoint = factory
|
|
65
|
+
.get('/protected')
|
|
66
|
+
.authorizer('jwt')
|
|
67
|
+
.handle(async () => ({ data: 'protected' }));
|
|
68
|
+
|
|
69
|
+
expect(endpoint.authorizer).toEqual({ name: 'jwt' });
|
|
70
|
+
expect(endpoint.route).toBe('/api/v1/protected');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should work with services and authorizers together', () => {
|
|
74
|
+
const dbService = {
|
|
75
|
+
serviceName: 'database' as const,
|
|
76
|
+
register: async () => ({ query: async () => [] }),
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const factory = new EndpointFactory()
|
|
80
|
+
.services([dbService])
|
|
81
|
+
.authorizers(['iam'] as const);
|
|
82
|
+
|
|
83
|
+
const endpoint = factory
|
|
84
|
+
.post('/users')
|
|
85
|
+
.authorizer('iam')
|
|
86
|
+
.body(z.object({ name: z.string() }))
|
|
87
|
+
.handle(async ({ body, services }) => {
|
|
88
|
+
await services.database.query();
|
|
89
|
+
return { name: body.name };
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(endpoint.authorizer).toEqual({ name: 'iam' });
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should maintain type safety with authorizer names', () => {
|
|
96
|
+
const factory = new EndpointFactory().authorizers(['iam', 'jwt'] as const);
|
|
97
|
+
|
|
98
|
+
// This should compile with valid authorizer
|
|
99
|
+
factory.get('/test1').authorizer('iam').handle(async () => ({}));
|
|
100
|
+
|
|
101
|
+
// This should compile with valid authorizer
|
|
102
|
+
factory.get('/test2').authorizer('jwt').handle(async () => ({}));
|
|
103
|
+
|
|
104
|
+
// This should not compile with invalid authorizer (tested via TypeScript)
|
|
105
|
+
// factory.get('/test3').authorizer('invalid').handle(async () => ({}));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should allow creating endpoints without calling authorizer() method', () => {
|
|
109
|
+
const factory = new EndpointFactory().authorizers(['iam'] as const);
|
|
110
|
+
|
|
111
|
+
const endpoint1 = factory
|
|
112
|
+
.get('/public')
|
|
113
|
+
.handle(async () => ({ public: true }));
|
|
114
|
+
|
|
115
|
+
const endpoint2 = factory
|
|
116
|
+
.get('/protected')
|
|
117
|
+
.authorizer('iam')
|
|
118
|
+
.handle(async () => ({ protected: true }));
|
|
119
|
+
|
|
120
|
+
expect(endpoint1.authorizer).toBeUndefined();
|
|
121
|
+
expect(endpoint2.authorizer).toEqual({ name: 'iam' });
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should work with nested routes', () => {
|
|
125
|
+
const apiFactory = new EndpointFactory()
|
|
126
|
+
.authorizers(['iam', 'jwt'] as const)
|
|
127
|
+
.route('/api');
|
|
128
|
+
|
|
129
|
+
const v1Factory = apiFactory.route('/v1');
|
|
130
|
+
const adminFactory = v1Factory.route('/admin');
|
|
131
|
+
|
|
132
|
+
const endpoint = adminFactory
|
|
133
|
+
.delete('/users/:id')
|
|
134
|
+
.authorizer('iam')
|
|
135
|
+
.params(z.object({ id: z.string() }))
|
|
136
|
+
.handle(async () => ({ deleted: true }));
|
|
137
|
+
|
|
138
|
+
expect(endpoint.route).toBe('/api/v1/admin/users/:id');
|
|
139
|
+
expect(endpoint.authorizer).toEqual({ name: 'iam' });
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should work with all HTTP methods', () => {
|
|
143
|
+
const factory = new EndpointFactory().authorizers(['jwt'] as const);
|
|
144
|
+
|
|
145
|
+
const getEndpoint = factory.get('/users').authorizer('jwt').handle(async () => ({ users: [] }));
|
|
146
|
+
const postEndpoint = factory.post('/users').authorizer('jwt').handle(async () => ({ id: '1' }));
|
|
147
|
+
const putEndpoint = factory.put('/users/:id').authorizer('jwt').handle(async () => ({ updated: true }));
|
|
148
|
+
const patchEndpoint = factory.patch('/users/:id').authorizer('jwt').handle(async () => ({ patched: true }));
|
|
149
|
+
const deleteEndpoint = factory.delete('/users/:id').authorizer('jwt').handle(async () => ({ deleted: true }));
|
|
150
|
+
const optionsEndpoint = factory.options('/users').authorizer('jwt').handle(async () => ({}));
|
|
151
|
+
|
|
152
|
+
expect(getEndpoint.authorizer).toEqual({ name: 'jwt' });
|
|
153
|
+
expect(postEndpoint.authorizer).toEqual({ name: 'jwt' });
|
|
154
|
+
expect(putEndpoint.authorizer).toEqual({ name: 'jwt' });
|
|
155
|
+
expect(patchEndpoint.authorizer).toEqual({ name: 'jwt' });
|
|
156
|
+
expect(deleteEndpoint.authorizer).toEqual({ name: 'jwt' });
|
|
157
|
+
expect(optionsEndpoint.authorizer).toEqual({ name: 'jwt' });
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should work with output schemas', () => {
|
|
161
|
+
const factory = new EndpointFactory().authorizers(['iam'] as const);
|
|
162
|
+
|
|
163
|
+
const outputSchema = z.object({
|
|
164
|
+
id: z.string(),
|
|
165
|
+
name: z.string(),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const endpoint = factory
|
|
169
|
+
.get('/user')
|
|
170
|
+
.authorizer('iam')
|
|
171
|
+
.output(outputSchema)
|
|
172
|
+
.handle(async () => ({
|
|
173
|
+
id: '123',
|
|
174
|
+
name: 'John Doe',
|
|
175
|
+
}));
|
|
176
|
+
|
|
177
|
+
expect(endpoint.authorizer).toEqual({ name: 'iam' });
|
|
178
|
+
expect(endpoint.outputSchema).toBe(outputSchema);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should not throw error when no authorizers are configured', () => {
|
|
182
|
+
const factory = new EndpointFactory();
|
|
183
|
+
|
|
184
|
+
const endpoint = factory
|
|
185
|
+
.get('/test')
|
|
186
|
+
.handle(async () => ({ success: true }));
|
|
187
|
+
|
|
188
|
+
expect(endpoint.authorizer).toBeUndefined();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('should handle multiple authorizers with similar names', () => {
|
|
192
|
+
const factory = new EndpointFactory().authorizers([
|
|
193
|
+
'jwt-user',
|
|
194
|
+
'jwt-admin',
|
|
195
|
+
'jwt',
|
|
196
|
+
] as const);
|
|
197
|
+
|
|
198
|
+
const endpoint1 = factory.get('/user').authorizer('jwt-user').handle(async () => ({}));
|
|
199
|
+
const endpoint2 = factory.get('/admin').authorizer('jwt-admin').handle(async () => ({}));
|
|
200
|
+
const endpoint3 = factory.get('/api').authorizer('jwt').handle(async () => ({}));
|
|
201
|
+
|
|
202
|
+
expect(endpoint1.authorizer).toEqual({ name: 'jwt-user' });
|
|
203
|
+
expect(endpoint2.authorizer).toEqual({ name: 'jwt-admin' });
|
|
204
|
+
expect(endpoint3.authorizer).toEqual({ name: 'jwt' });
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('should support "none" to explicitly mark endpoint as having no authorizer', () => {
|
|
208
|
+
const factory = new EndpointFactory().authorizers(['iam', 'jwt'] as const);
|
|
209
|
+
|
|
210
|
+
const endpoint = factory
|
|
211
|
+
.get('/public')
|
|
212
|
+
.authorizer('none')
|
|
213
|
+
.handle(async () => ({ public: true }));
|
|
214
|
+
|
|
215
|
+
expect(endpoint.authorizer).toBeUndefined();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('should allow "none" to override default authorizer from factory', () => {
|
|
219
|
+
const factory = new EndpointFactory().authorizers(['iam', 'jwt'] as const);
|
|
220
|
+
|
|
221
|
+
// In the future, if we add default authorizer support at factory level,
|
|
222
|
+
// 'none' should override it
|
|
223
|
+
const endpoint = factory
|
|
224
|
+
.post('/public/signup')
|
|
225
|
+
.authorizer('none')
|
|
226
|
+
.body(z.object({ email: z.string() }))
|
|
227
|
+
.handle(async () => ({ success: true }));
|
|
228
|
+
|
|
229
|
+
expect(endpoint.authorizer).toBeUndefined();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('should allow "none" even when no authorizers are configured', () => {
|
|
233
|
+
const factory = new EndpointFactory();
|
|
234
|
+
|
|
235
|
+
const endpoint = factory
|
|
236
|
+
.get('/test')
|
|
237
|
+
.authorizer('none')
|
|
238
|
+
.handle(async () => ({ test: true }));
|
|
239
|
+
|
|
240
|
+
expect(endpoint.authorizer).toBeUndefined();
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('should work with "none" in combination with other endpoint methods', () => {
|
|
244
|
+
const factory = new EndpointFactory().authorizers(['iam'] as const);
|
|
245
|
+
|
|
246
|
+
const endpoint = factory
|
|
247
|
+
.post('/public/contact')
|
|
248
|
+
.authorizer('none')
|
|
249
|
+
.body(z.object({ message: z.string() }))
|
|
250
|
+
.output(z.object({ sent: z.boolean() }))
|
|
251
|
+
.description('Public contact form')
|
|
252
|
+
.tags(['public', 'contact'])
|
|
253
|
+
.handle(async () => ({ sent: true }));
|
|
254
|
+
|
|
255
|
+
expect(endpoint.authorizer).toBeUndefined();
|
|
256
|
+
expect(endpoint.description).toBe('Public contact form');
|
|
257
|
+
expect(endpoint.tags).toEqual(['public', 'contact']);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { ConsoleLogger } from '@geekmidas/logger/console';
|
|
3
|
+
import { EndpointFactory } from '../EndpointFactory';
|
|
4
|
+
import type { Service } from '@geekmidas/services';
|
|
5
|
+
|
|
6
|
+
const ServiceA = {
|
|
7
|
+
serviceName: 'a' as const,
|
|
8
|
+
async register() {
|
|
9
|
+
return { test: () => 'a' };
|
|
10
|
+
},
|
|
11
|
+
} satisfies Service<'a', any>;
|
|
12
|
+
|
|
13
|
+
const ServiceB = {
|
|
14
|
+
serviceName: 'b' as const,
|
|
15
|
+
async register() {
|
|
16
|
+
return { test: () => 'b' };
|
|
17
|
+
},
|
|
18
|
+
} satisfies Service<'b', any>;
|
|
19
|
+
|
|
20
|
+
describe('EndpointFactory - Reference Sharing Audit', () => {
|
|
21
|
+
describe('services array', () => {
|
|
22
|
+
it('should not share services array references between builders', () => {
|
|
23
|
+
const factory = new EndpointFactory().services([ServiceA, ServiceB]);
|
|
24
|
+
|
|
25
|
+
const builder1 = factory.post('/a');
|
|
26
|
+
const builder2 = factory.post('/b');
|
|
27
|
+
|
|
28
|
+
// Should not be the same reference
|
|
29
|
+
expect((builder1 as any)._services === (builder2 as any)._services).toBe(
|
|
30
|
+
false,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// But should have same content
|
|
34
|
+
expect((builder1 as any)._services).toEqual([ServiceA, ServiceB]);
|
|
35
|
+
expect((builder2 as any)._services).toEqual([ServiceA, ServiceB]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should not mutate factory services when builder adds services', () => {
|
|
39
|
+
const factory = new EndpointFactory().services([ServiceA]);
|
|
40
|
+
|
|
41
|
+
const builder = factory.post('/test');
|
|
42
|
+
const originalServices = (factory as any).defaultServices;
|
|
43
|
+
|
|
44
|
+
// Builder adds more services
|
|
45
|
+
builder.services([ServiceB]);
|
|
46
|
+
|
|
47
|
+
// Factory's defaultServices should be unchanged
|
|
48
|
+
expect((factory as any).defaultServices).toEqual(originalServices);
|
|
49
|
+
expect((factory as any).defaultServices.length).toBe(1);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('events array', () => {
|
|
54
|
+
it('should not share events array references between builders', () => {
|
|
55
|
+
const factory = new EndpointFactory();
|
|
56
|
+
|
|
57
|
+
const builder1 = factory.post('/a');
|
|
58
|
+
const builder2 = factory.post('/b');
|
|
59
|
+
|
|
60
|
+
// Each builder should have its own events array
|
|
61
|
+
expect((builder1 as any)._events === (builder2 as any)._events).toBe(
|
|
62
|
+
false,
|
|
63
|
+
);
|
|
64
|
+
expect((builder1 as any)._events).toEqual([]);
|
|
65
|
+
expect((builder2 as any)._events).toEqual([]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should not share events between builders even after adding events', () => {
|
|
69
|
+
const factory = new EndpointFactory();
|
|
70
|
+
|
|
71
|
+
const builder1 = factory.post('/a');
|
|
72
|
+
const builder2 = factory.post('/b');
|
|
73
|
+
|
|
74
|
+
// Add event to builder1
|
|
75
|
+
const mockEvent: any = { type: 'test', map: () => ({}) };
|
|
76
|
+
(builder1 as any)._events.push(mockEvent);
|
|
77
|
+
|
|
78
|
+
// builder2 should not have the event
|
|
79
|
+
expect((builder1 as any)._events.length).toBe(1);
|
|
80
|
+
expect((builder2 as any)._events.length).toBe(0);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('schemas object', () => {
|
|
85
|
+
it('should not share schemas object references between builders', () => {
|
|
86
|
+
const factory = new EndpointFactory();
|
|
87
|
+
|
|
88
|
+
const builder1 = factory.post('/a');
|
|
89
|
+
const builder2 = factory.post('/b');
|
|
90
|
+
|
|
91
|
+
// Each builder should have its own schemas object
|
|
92
|
+
expect((builder1 as any).schemas === (builder2 as any).schemas).toBe(
|
|
93
|
+
false,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should not share schemas between builders after setting schemas', () => {
|
|
98
|
+
const factory = new EndpointFactory();
|
|
99
|
+
const bodySchema: any = { '~standard': { validate: () => ({}) } };
|
|
100
|
+
|
|
101
|
+
const builder1 = factory.post('/a').body(bodySchema);
|
|
102
|
+
const builder2 = factory.post('/b');
|
|
103
|
+
|
|
104
|
+
// builder1 should have body schema, builder2 should not
|
|
105
|
+
expect((builder1 as any).schemas.body).toBeDefined();
|
|
106
|
+
expect((builder2 as any).schemas.body).toBeUndefined();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('logger (intentionally shared)', () => {
|
|
111
|
+
it('should share logger references between builders (by design)', () => {
|
|
112
|
+
const logger = new ConsoleLogger({ app: 'test' });
|
|
113
|
+
const factory = new EndpointFactory().logger(logger);
|
|
114
|
+
|
|
115
|
+
const builder1 = factory.post('/a');
|
|
116
|
+
const builder2 = factory.post('/b');
|
|
117
|
+
|
|
118
|
+
// Logger should be the same reference (it's a singleton service)
|
|
119
|
+
expect((builder1 as any)._logger === (builder2 as any)._logger).toBe(
|
|
120
|
+
true,
|
|
121
|
+
);
|
|
122
|
+
expect((builder1 as any)._logger).toBe(logger);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('authorize and session functions', () => {
|
|
127
|
+
it('should share authorize function reference (by design)', () => {
|
|
128
|
+
const authFn = async () => true;
|
|
129
|
+
const factory = new EndpointFactory().authorize(authFn);
|
|
130
|
+
|
|
131
|
+
const builder1 = factory.post('/a');
|
|
132
|
+
const builder2 = factory.post('/b');
|
|
133
|
+
|
|
134
|
+
// Function should be the same reference
|
|
135
|
+
expect((builder1 as any)._authorize === (builder2 as any)._authorize).toBe(
|
|
136
|
+
true,
|
|
137
|
+
);
|
|
138
|
+
expect((builder1 as any)._authorize).toBe(authFn);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should share session extractor function reference (by design)', () => {
|
|
142
|
+
const sessionFn = async () => ({ userId: '123' });
|
|
143
|
+
const factory = new EndpointFactory().session(sessionFn);
|
|
144
|
+
|
|
145
|
+
const builder1 = factory.post('/a');
|
|
146
|
+
const builder2 = factory.post('/b');
|
|
147
|
+
|
|
148
|
+
// Function should be the same reference
|
|
149
|
+
expect((builder1 as any)._getSession === (builder2 as any)._getSession).toBe(
|
|
150
|
+
true,
|
|
151
|
+
);
|
|
152
|
+
expect((builder1 as any)._getSession).toBe(sessionFn);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('complex nested factory chains', () => {
|
|
157
|
+
it('should maintain proper isolation through multiple factory layers', () => {
|
|
158
|
+
// Create base router
|
|
159
|
+
const base = new EndpointFactory().services([ServiceA]);
|
|
160
|
+
|
|
161
|
+
// Create auth router from base
|
|
162
|
+
const authRouter = base.authorize(async () => true);
|
|
163
|
+
|
|
164
|
+
// Create API v1 router from auth router
|
|
165
|
+
const v1Router = authRouter.route('/v1').services([ServiceB]);
|
|
166
|
+
|
|
167
|
+
// Create endpoints from different routers
|
|
168
|
+
const ep1 = base.get('/test').handle(() => ({}));
|
|
169
|
+
const ep2 = authRouter.get('/test').handle(() => ({}));
|
|
170
|
+
const ep3 = v1Router.get('/test').handle(() => ({}));
|
|
171
|
+
|
|
172
|
+
// Verify service isolation
|
|
173
|
+
expect(ep1.services.map((s) => s.serviceName)).toEqual(['a']);
|
|
174
|
+
expect(ep2.services.map((s) => s.serviceName)).toEqual(['a']);
|
|
175
|
+
expect(ep3.services.map((s) => s.serviceName)).toEqual(['b', 'a']);
|
|
176
|
+
|
|
177
|
+
// Verify they don't share internal arrays
|
|
178
|
+
const builder1 = base.get('/x');
|
|
179
|
+
const builder2 = authRouter.get('/x');
|
|
180
|
+
const builder3 = v1Router.get('/x');
|
|
181
|
+
|
|
182
|
+
expect((builder1 as any)._services === (builder2 as any)._services).toBe(
|
|
183
|
+
false,
|
|
184
|
+
);
|
|
185
|
+
expect((builder2 as any)._services === (builder3 as any)._services).toBe(
|
|
186
|
+
false,
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { EndpointFactory } from '../EndpointFactory';
|
|
3
|
+
import type { Service } from '@geekmidas/services';
|
|
4
|
+
|
|
5
|
+
const CacheService = {
|
|
6
|
+
serviceName: 'cache' as const,
|
|
7
|
+
async register() {
|
|
8
|
+
return { get: () => 'cached' };
|
|
9
|
+
},
|
|
10
|
+
} satisfies Service<'cache', any>;
|
|
11
|
+
|
|
12
|
+
const DatabaseService = {
|
|
13
|
+
serviceName: 'database' as const,
|
|
14
|
+
async register() {
|
|
15
|
+
return { query: () => 'result' };
|
|
16
|
+
},
|
|
17
|
+
} satisfies Service<'database', any>;
|
|
18
|
+
|
|
19
|
+
describe('EndpointFactory - State Isolation', () => {
|
|
20
|
+
it('should create independent endpoints with sequential factory.services() calls', () => {
|
|
21
|
+
const factory = new EndpointFactory();
|
|
22
|
+
|
|
23
|
+
const endpoint1 = factory
|
|
24
|
+
.services([CacheService, DatabaseService])
|
|
25
|
+
.post('/user')
|
|
26
|
+
.handle(() => ({}));
|
|
27
|
+
|
|
28
|
+
const endpoint2 = factory.services([CacheService]).get('/user').handle(() => ({}));
|
|
29
|
+
|
|
30
|
+
expect(endpoint1.services.map((s) => s.serviceName)).toEqual([
|
|
31
|
+
'cache',
|
|
32
|
+
'database',
|
|
33
|
+
]);
|
|
34
|
+
expect(endpoint2.services.map((s) => s.serviceName)).toEqual(['cache']);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should create independent builders from reused factory instance', () => {
|
|
38
|
+
const factory = new EndpointFactory().services([
|
|
39
|
+
CacheService,
|
|
40
|
+
DatabaseService,
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const builder1 = factory.post('/users');
|
|
44
|
+
const builder2 = factory.get('/users');
|
|
45
|
+
|
|
46
|
+
// Both should have the factory's default services
|
|
47
|
+
expect((builder1 as any)._services.map((s: any) => s.serviceName)).toEqual([
|
|
48
|
+
'cache',
|
|
49
|
+
'database',
|
|
50
|
+
]);
|
|
51
|
+
expect((builder2 as any)._services.map((s: any) => s.serviceName)).toEqual([
|
|
52
|
+
'cache',
|
|
53
|
+
'database',
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
// But they should not share the same array reference
|
|
57
|
+
expect((builder1 as any)._services === (builder2 as any)._services).toBe(
|
|
58
|
+
false,
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should not leak services between independent builder chains', () => {
|
|
63
|
+
const factory = new EndpointFactory();
|
|
64
|
+
|
|
65
|
+
const builder1 = factory.post('/api1').services([CacheService]);
|
|
66
|
+
const builder2 = factory.post('/api2').services([DatabaseService]);
|
|
67
|
+
|
|
68
|
+
expect((builder1 as any)._services.map((s: any) => s.serviceName)).toEqual([
|
|
69
|
+
'cache',
|
|
70
|
+
]);
|
|
71
|
+
expect((builder2 as any)._services.map((s: any) => s.serviceName)).toEqual([
|
|
72
|
+
'database',
|
|
73
|
+
]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should allow builder to add services without affecting other builders', () => {
|
|
77
|
+
const factory = new EndpointFactory().services([CacheService]);
|
|
78
|
+
|
|
79
|
+
const endpoint1 = factory
|
|
80
|
+
.post('/test')
|
|
81
|
+
.services([DatabaseService])
|
|
82
|
+
.handle(() => ({}));
|
|
83
|
+
|
|
84
|
+
const endpoint2 = factory.get('/test').handle(() => ({}));
|
|
85
|
+
|
|
86
|
+
expect(endpoint1.services.map((s) => s.serviceName)).toEqual([
|
|
87
|
+
'cache',
|
|
88
|
+
'database',
|
|
89
|
+
]);
|
|
90
|
+
expect(endpoint2.services.map((s) => s.serviceName)).toEqual(['cache']);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should support base router pattern with extended services', () => {
|
|
94
|
+
// Create a base router with default services
|
|
95
|
+
const r = new EndpointFactory().services([
|
|
96
|
+
CacheService,
|
|
97
|
+
DatabaseService,
|
|
98
|
+
]);
|
|
99
|
+
|
|
100
|
+
// Create endpoint with additional service
|
|
101
|
+
const getUsers = r.services([CacheService]).get('/users').handle(() => ({}));
|
|
102
|
+
|
|
103
|
+
// Create endpoint with just base services
|
|
104
|
+
const createUser = r.post('/users').handle(() => ({}));
|
|
105
|
+
|
|
106
|
+
// getUsers should have additional service (but deduplicated)
|
|
107
|
+
expect(getUsers.services.map((s) => s.serviceName)).toEqual([
|
|
108
|
+
'cache',
|
|
109
|
+
'database',
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
// createUser should only have base services
|
|
113
|
+
expect(createUser.services.map((s) => s.serviceName)).toEqual([
|
|
114
|
+
'cache',
|
|
115
|
+
'database',
|
|
116
|
+
]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should support base router pattern with truly additional services', () => {
|
|
120
|
+
const AdditionalService = {
|
|
121
|
+
serviceName: 'additional' as const,
|
|
122
|
+
async register() {
|
|
123
|
+
return { process: () => 'processed' };
|
|
124
|
+
},
|
|
125
|
+
} satisfies Service<'additional', any>;
|
|
126
|
+
|
|
127
|
+
// Create a base router with default services
|
|
128
|
+
const r = new EndpointFactory().services([
|
|
129
|
+
CacheService,
|
|
130
|
+
DatabaseService,
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
// Create endpoint with additional service
|
|
134
|
+
const getUsers = r
|
|
135
|
+
.services([AdditionalService])
|
|
136
|
+
.get('/users')
|
|
137
|
+
.handle(() => ({}));
|
|
138
|
+
|
|
139
|
+
// Create endpoint with just base services
|
|
140
|
+
const createUser = r.post('/users').handle(() => ({}));
|
|
141
|
+
|
|
142
|
+
// getUsers should have all three services
|
|
143
|
+
expect(getUsers.services.map((s) => s.serviceName)).toEqual([
|
|
144
|
+
'additional',
|
|
145
|
+
'cache',
|
|
146
|
+
'database',
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
// createUser should only have base services
|
|
150
|
+
expect(createUser.services.map((s) => s.serviceName)).toEqual([
|
|
151
|
+
'cache',
|
|
152
|
+
'database',
|
|
153
|
+
]);
|
|
154
|
+
});
|
|
155
|
+
});
|