@geekmidas/constructs 0.3.1 → 0.5.0
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-EPGY4s7i.cjs → AWSLambdaFunction-Ba1DcsW2.cjs} +6 -6
- package/dist/AWSLambdaFunction-Ba1DcsW2.cjs.map +1 -0
- package/dist/{AWSLambdaFunction-BdebRMUh.d.mts → AWSLambdaFunction-CKe73Qr0.d.cts} +6 -6
- package/dist/AWSLambdaFunction-CKe73Qr0.d.cts.map +1 -0
- package/dist/{AWSLambdaFunction-D0tEOTXQ.d.cts → AWSLambdaFunction-CuG3HNZx.d.mts} +6 -6
- package/dist/AWSLambdaFunction-CuG3HNZx.d.mts.map +1 -0
- package/dist/{AWSLambdaFunction-C54a1doJ.mjs → AWSLambdaFunction-DnMm4xvz.mjs} +6 -6
- package/dist/AWSLambdaFunction-DnMm4xvz.mjs.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-Dx-Ks1Jp.d.cts → AWSLambdaSubscriberAdaptor-B4HH-WuQ.d.mts} +4 -4
- package/dist/AWSLambdaSubscriberAdaptor-B4HH-WuQ.d.mts.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-BLfO612H.mjs → AWSLambdaSubscriberAdaptor-BD3FwGUb.mjs} +3 -3
- package/dist/AWSLambdaSubscriberAdaptor-BD3FwGUb.mjs.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-DrFAvHOp.d.mts → AWSLambdaSubscriberAdaptor-BEqQ96VJ.d.cts} +4 -4
- package/dist/AWSLambdaSubscriberAdaptor-BEqQ96VJ.d.cts.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-BNcYYZ-P.cjs → AWSLambdaSubscriberAdaptor-DQDnt1Xk.cjs} +3 -3
- package/dist/AWSLambdaSubscriberAdaptor-DQDnt1Xk.cjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-BT9JXihC.mjs → AmazonApiGatewayEndpointAdaptor-Bvy-Hgjf.mjs} +56 -14
- package/dist/AmazonApiGatewayEndpointAdaptor-Bvy-Hgjf.mjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-DNFvvdmW.cjs → AmazonApiGatewayEndpointAdaptor-Cpxluhfg.cjs} +55 -13
- package/dist/AmazonApiGatewayEndpointAdaptor-Cpxluhfg.cjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-qlKXuZxy.d.mts → AmazonApiGatewayEndpointAdaptor-DTgdZ8I1.d.mts} +52 -6
- package/dist/AmazonApiGatewayEndpointAdaptor-DTgdZ8I1.d.mts.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-DLqnYQ4E.d.cts → AmazonApiGatewayEndpointAdaptor-DsWnO6x9.d.cts} +51 -5
- package/dist/AmazonApiGatewayEndpointAdaptor-DsWnO6x9.d.cts.map +1 -0
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-DyUaJIhB.d.cts → AmazonApiGatewayV1EndpointAdaptor-7ELXUBFK.d.cts} +4 -4
- package/dist/AmazonApiGatewayV1EndpointAdaptor-7ELXUBFK.d.cts.map +1 -0
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-Ccl8B8kG.cjs → AmazonApiGatewayV1EndpointAdaptor-B8vIYYNh.cjs} +4 -4
- package/dist/AmazonApiGatewayV1EndpointAdaptor-B8vIYYNh.cjs.map +1 -0
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-CShQI8Gk.mjs → AmazonApiGatewayV1EndpointAdaptor-ByXGIju8.mjs} +4 -4
- package/dist/AmazonApiGatewayV1EndpointAdaptor-ByXGIju8.mjs.map +1 -0
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-MRUxs3Xi.d.mts → AmazonApiGatewayV1EndpointAdaptor-RWRmFPrN.d.mts} +5 -5
- package/dist/AmazonApiGatewayV1EndpointAdaptor-RWRmFPrN.d.mts.map +1 -0
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-D8-0Aab4.cjs → AmazonApiGatewayV2EndpointAdaptor-DIetspUm.cjs} +4 -4
- package/dist/AmazonApiGatewayV2EndpointAdaptor-DIetspUm.cjs.map +1 -0
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-lCRzGE4q.mjs → AmazonApiGatewayV2EndpointAdaptor-DWemCZvl.mjs} +4 -4
- package/dist/AmazonApiGatewayV2EndpointAdaptor-DWemCZvl.mjs.map +1 -0
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-M1-w0U5R.d.cts → AmazonApiGatewayV2EndpointAdaptor-D_uMTmuJ.d.cts} +4 -6
- package/dist/AmazonApiGatewayV2EndpointAdaptor-D_uMTmuJ.d.cts.map +1 -0
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-fuLM6M9k.d.mts → AmazonApiGatewayV2EndpointAdaptor-wnOMDv6o.d.mts} +5 -7
- package/dist/AmazonApiGatewayV2EndpointAdaptor-wnOMDv6o.d.mts.map +1 -0
- package/dist/{Authorizer-C0ge_tc8.cjs → Authorizer-BXxBee2P.cjs} +1 -1
- package/dist/Authorizer-BXxBee2P.cjs.map +1 -0
- package/dist/{Authorizer-r9U3y_ms.mjs → Authorizer-BgjU8-z6.mjs} +1 -1
- package/dist/Authorizer-BgjU8-z6.mjs.map +1 -0
- package/dist/{Authorizer-gWxYsGEp.d.mts → Authorizer-DCcYOx3h.d.mts} +1 -1
- package/dist/Authorizer-DCcYOx3h.d.mts.map +1 -0
- package/dist/{Authorizer-B-btowNd.d.cts → Authorizer-DWtwC8we.d.cts} +1 -1
- package/dist/Authorizer-DWtwC8we.d.cts.map +1 -0
- package/dist/{BaseFunctionBuilder-Czi1Jwza.mjs → BaseFunctionBuilder-0qlenb9z.mjs} +2 -2
- package/dist/BaseFunctionBuilder-0qlenb9z.mjs.map +1 -0
- package/dist/BaseFunctionBuilder-BAtutR6q.d.cts.map +1 -1
- package/dist/{BaseFunctionBuilder-DRY419e7.d.mts → BaseFunctionBuilder-CDfDWWAQ.d.mts} +2 -2
- package/dist/BaseFunctionBuilder-CDfDWWAQ.d.mts.map +1 -0
- package/dist/{BaseFunctionBuilder-MYG3C9ug.cjs → BaseFunctionBuilder-D7o93EGv.cjs} +2 -2
- package/dist/BaseFunctionBuilder-D7o93EGv.cjs.map +1 -0
- package/dist/{Construct-Ba5cMxib.cjs → Construct-BlnyYtJC.cjs} +31 -2
- package/dist/Construct-BlnyYtJC.cjs.map +1 -0
- package/dist/Construct-C4rPE67v.d.cts.map +1 -1
- package/dist/{Construct-DdyGHuag.mjs → Construct-D5dCvxZ3.mjs} +31 -2
- package/dist/Construct-D5dCvxZ3.mjs.map +1 -0
- package/dist/{Construct-XrijZFFh.d.mts → Construct-dZiwVo0q.d.mts} +1 -1
- package/dist/Construct-dZiwVo0q.d.mts.map +1 -0
- package/dist/Construct.cjs +1 -1
- package/dist/Construct.d.mts +1 -1
- package/dist/Construct.mjs +1 -1
- package/dist/{Cron-bDLcTvV5.d.cts → Cron-B6FnTu7k.d.cts} +2 -2
- package/dist/Cron-B6FnTu7k.d.cts.map +1 -0
- package/dist/{Cron-CGF4YAfM.cjs → Cron-BAPQetlC.cjs} +3 -3
- package/dist/Cron-BAPQetlC.cjs.map +1 -0
- package/dist/{Cron-BxhGs5up.mjs → Cron-CAk_ddH8.mjs} +3 -3
- package/dist/Cron-CAk_ddH8.mjs.map +1 -0
- package/dist/{Cron-cdjlSKNp.d.mts → Cron-D3bEljxQ.d.mts} +2 -2
- package/dist/Cron-D3bEljxQ.d.mts.map +1 -0
- package/dist/{CronBuilder-DKVXyE0Q.d.cts → CronBuilder-CA8euP0z.d.cts} +4 -4
- package/dist/CronBuilder-CA8euP0z.d.cts.map +1 -0
- package/dist/{CronBuilder-BC4m5-p1.d.mts → CronBuilder-DvdiKzhq.d.mts} +4 -4
- package/dist/CronBuilder-DvdiKzhq.d.mts.map +1 -0
- package/dist/{CronBuilder-CcxKRtVP.cjs → CronBuilder-DxXA5ymv.cjs} +4 -4
- package/dist/CronBuilder-DxXA5ymv.cjs.map +1 -0
- package/dist/{CronBuilder-d2jh-IB2.mjs → CronBuilder-e8TaHPYm.mjs} +4 -4
- package/dist/CronBuilder-e8TaHPYm.mjs.map +1 -0
- package/dist/{Endpoint-BPv9_-m_.d.cts → Endpoint-BOlbY5iq.d.cts} +3 -3
- package/dist/Endpoint-BOlbY5iq.d.cts.map +1 -0
- package/dist/{Endpoint-CuOEswxJ.mjs → Endpoint-BbdNmtlM.mjs} +6 -6
- package/dist/Endpoint-BbdNmtlM.mjs.map +1 -0
- package/dist/{Endpoint-BdwG75G_.d.mts → Endpoint-Dlv7nxgj.d.mts} +4 -4
- package/dist/Endpoint-Dlv7nxgj.d.mts.map +1 -0
- package/dist/{Endpoint-BVGZXFyV.cjs → Endpoint-DxvnlfXg.cjs} +6 -6
- package/dist/Endpoint-DxvnlfXg.cjs.map +1 -0
- package/dist/{EndpointBuilder-Cgj1P_ra.cjs → EndpointBuilder-40Iz5CjY.cjs} +6 -6
- package/dist/EndpointBuilder-40Iz5CjY.cjs.map +1 -0
- package/dist/{EndpointBuilder-DnCB1h1j.mjs → EndpointBuilder-BaVvhW9m.mjs} +6 -6
- package/dist/EndpointBuilder-BaVvhW9m.mjs.map +1 -0
- package/dist/{EndpointBuilder-DIy_m1bu.d.cts → EndpointBuilder-CFfWWjUa.d.cts} +3 -3
- package/dist/EndpointBuilder-CFfWWjUa.d.cts.map +1 -0
- package/dist/{EndpointBuilder-B3az942t.d.mts → EndpointBuilder-T_K2NLWw.d.mts} +5 -5
- package/dist/EndpointBuilder-T_K2NLWw.d.mts.map +1 -0
- package/dist/{EndpointFactory-CyPbm3AD.d.cts → EndpointFactory-ChzBVEM9.d.cts} +4 -4
- package/dist/EndpointFactory-ChzBVEM9.d.cts.map +1 -0
- package/dist/{EndpointFactory-CbdxPCIH.mjs → EndpointFactory-DfNjSgVG.mjs} +7 -7
- package/dist/EndpointFactory-DfNjSgVG.mjs.map +1 -0
- package/dist/{EndpointFactory-C-0nE6Jg.d.mts → EndpointFactory-GAL_tuPf.d.mts} +4 -4
- package/dist/EndpointFactory-GAL_tuPf.d.mts.map +1 -0
- package/dist/{EndpointFactory-CYj6BYok.cjs → EndpointFactory-r6jxPvQ8.cjs} +7 -7
- package/dist/EndpointFactory-r6jxPvQ8.cjs.map +1 -0
- package/dist/{Function-BVHqIDp9.mjs → Function-D8tBamM3.mjs} +3 -3
- package/dist/Function-D8tBamM3.mjs.map +1 -0
- package/dist/{Function-DN2G6OT5.d.mts → Function-DBmU3uGI.d.mts} +3 -3
- package/dist/Function-DBmU3uGI.d.mts.map +1 -0
- package/dist/{Function-Cf7f_kCz.d.cts → Function-PNW4HdNE.d.cts} +2 -2
- package/dist/Function-PNW4HdNE.d.cts.map +1 -0
- package/dist/{Function-DDZb1525.cjs → Function-iLKrUXuw.cjs} +3 -3
- package/dist/Function-iLKrUXuw.cjs.map +1 -0
- package/dist/{FunctionBuilder-DswJ-9sD.cjs → FunctionBuilder-BEpPgeho.cjs} +4 -4
- package/dist/FunctionBuilder-BEpPgeho.cjs.map +1 -0
- package/dist/{FunctionBuilder-Cxx8D2na.d.mts → FunctionBuilder-Bv4H2I1a.d.mts} +4 -4
- package/dist/FunctionBuilder-Bv4H2I1a.d.mts.map +1 -0
- package/dist/{FunctionBuilder-CrDYgfiI.mjs → FunctionBuilder-BwNF99AB.mjs} +4 -4
- package/dist/FunctionBuilder-BwNF99AB.mjs.map +1 -0
- package/dist/{FunctionBuilder-CJBzzXL3.d.cts → FunctionBuilder-DCqXIHaq.d.cts} +2 -2
- package/dist/FunctionBuilder-DCqXIHaq.d.cts.map +1 -0
- package/dist/{FunctionExecutionWrapper-CLDh7Z2_.mjs → FunctionExecutionWrapper-B__HE_B-.mjs} +3 -3
- package/dist/FunctionExecutionWrapper-B__HE_B-.mjs.map +1 -0
- package/dist/{FunctionExecutionWrapper-DF260Aaj.d.mts → FunctionExecutionWrapper-BclgIztn.d.cts} +5 -5
- package/dist/FunctionExecutionWrapper-BclgIztn.d.cts.map +1 -0
- package/dist/{FunctionExecutionWrapper-BYI2bGTL.cjs → FunctionExecutionWrapper-BjF6t9Hb.cjs} +3 -3
- package/dist/FunctionExecutionWrapper-BjF6t9Hb.cjs.map +1 -0
- package/dist/{FunctionExecutionWrapper-Qy8bmgFR.d.cts → FunctionExecutionWrapper-Dq21c6vt.d.mts} +5 -5
- package/dist/FunctionExecutionWrapper-Dq21c6vt.d.mts.map +1 -0
- package/dist/HonoEndpointAdaptor-C_ym_Sbr.mjs +251 -0
- package/dist/HonoEndpointAdaptor-C_ym_Sbr.mjs.map +1 -0
- package/dist/HonoEndpointAdaptor-DiQH0eTb.cjs +257 -0
- package/dist/HonoEndpointAdaptor-DiQH0eTb.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-Bqm6SEuP.d.cts → HonoEndpointAdaptor-Dkkemmbo.d.cts} +9 -4
- package/dist/HonoEndpointAdaptor-Dkkemmbo.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-CRe-ij5f.d.mts → HonoEndpointAdaptor-HukjdF6M.d.mts} +10 -5
- package/dist/HonoEndpointAdaptor-HukjdF6M.d.mts.map +1 -0
- package/dist/{Subscriber-COYMSevD.d.cts → Subscriber--zUjZDR6.d.cts} +1 -1
- package/dist/Subscriber--zUjZDR6.d.cts.map +1 -0
- package/dist/{Subscriber-ikctpU3I.d.mts → Subscriber-0Ac7cXID.d.mts} +2 -2
- package/dist/Subscriber-0Ac7cXID.d.mts.map +1 -0
- package/dist/{Subscriber-BmPf9GFb.mjs → Subscriber-BgZ8T-O2.mjs} +2 -2
- package/dist/Subscriber-BgZ8T-O2.mjs.map +1 -0
- package/dist/{Subscriber-BiHjVXtM.cjs → Subscriber-CoFmHMIM.cjs} +2 -2
- package/dist/Subscriber-CoFmHMIM.cjs.map +1 -0
- package/dist/{SubscriberBuilder-D_9zzllj.d.mts → SubscriberBuilder-D8cmUHee.d.mts} +2 -2
- package/dist/SubscriberBuilder-D8cmUHee.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-DJPEeYDJ.mjs → SubscriberBuilder-DWXWZBPo.mjs} +2 -2
- package/dist/SubscriberBuilder-DWXWZBPo.mjs.map +1 -0
- package/dist/{SubscriberBuilder-ivHAGIVi.d.cts → SubscriberBuilder-DciTqb-7.d.cts} +2 -2
- package/dist/SubscriberBuilder-DciTqb-7.d.cts.map +1 -0
- package/dist/{SubscriberBuilder-Cp1C-xtT.cjs → SubscriberBuilder-JlxhyqGp.cjs} +2 -2
- package/dist/SubscriberBuilder-JlxhyqGp.cjs.map +1 -0
- package/dist/{TestEndpointAdaptor-DB7bREhS.d.mts → TestEndpointAdaptor-Boijwbmz.d.mts} +4 -4
- package/dist/TestEndpointAdaptor-Boijwbmz.d.mts.map +1 -0
- package/dist/{TestEndpointAdaptor-C10xBI--.d.cts → TestEndpointAdaptor-DdwpRyNh.d.cts} +3 -3
- package/dist/TestEndpointAdaptor-DdwpRyNh.d.cts.map +1 -0
- package/dist/TestEndpointAdaptor-Dk75ExxE.cjs +176 -0
- package/dist/TestEndpointAdaptor-Dk75ExxE.cjs.map +1 -0
- package/dist/TestEndpointAdaptor-OiA2JLDp.mjs +170 -0
- package/dist/TestEndpointAdaptor-OiA2JLDp.mjs.map +1 -0
- package/dist/adaptors/aws.cjs +12 -12
- package/dist/adaptors/aws.d.cts +13 -12
- package/dist/adaptors/aws.d.mts +16 -15
- package/dist/adaptors/aws.mjs +12 -12
- package/dist/adaptors/hono.cjs +10 -9
- package/dist/adaptors/hono.d.cts +6 -6
- package/dist/adaptors/hono.d.mts +9 -9
- package/dist/adaptors/hono.mjs +10 -9
- package/dist/adaptors/testing.cjs +8 -7
- package/dist/adaptors/testing.d.cts +6 -6
- package/dist/adaptors/testing.d.mts +9 -9
- package/dist/adaptors/testing.mjs +8 -7
- package/dist/crons/Cron.cjs +6 -6
- package/dist/crons/Cron.d.cts +4 -4
- 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 +5 -5
- 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.cjs.map +1 -1
- package/dist/crons/index.d.cts +5 -5
- package/dist/crons/index.d.mts +7 -7
- package/dist/crons/index.mjs +7 -7
- package/dist/crons/index.mjs.map +1 -1
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +7 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +8 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +11 -10
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +7 -7
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +8 -8
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +8 -7
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +11 -10
- 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 +12 -11
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +8 -8
- package/dist/endpoints/Authorizer.cjs +1 -1
- package/dist/endpoints/Authorizer.d.cts +1 -1
- package/dist/endpoints/Authorizer.d.mts +1 -1
- package/dist/endpoints/Authorizer.mjs +1 -1
- package/dist/endpoints/Endpoint.cjs +6 -6
- package/dist/endpoints/Endpoint.d.cts +5 -5
- package/dist/endpoints/Endpoint.d.mts +8 -8
- package/dist/endpoints/Endpoint.mjs +6 -6
- package/dist/endpoints/EndpointBuilder.cjs +9 -9
- package/dist/endpoints/EndpointBuilder.d.cts +6 -6
- package/dist/endpoints/EndpointBuilder.d.mts +9 -9
- package/dist/endpoints/EndpointBuilder.mjs +9 -9
- package/dist/endpoints/EndpointFactory.cjs +10 -10
- package/dist/endpoints/EndpointFactory.d.cts +7 -7
- package/dist/endpoints/EndpointFactory.d.mts +10 -10
- package/dist/endpoints/EndpointFactory.mjs +10 -10
- package/dist/endpoints/HonoEndpointAdaptor.cjs +10 -9
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +6 -6
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/HonoEndpointAdaptor.mjs +10 -9
- package/dist/endpoints/TestEndpointAdaptor.cjs +8 -7
- package/dist/endpoints/TestEndpointAdaptor.d.cts +6 -6
- package/dist/endpoints/TestEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/TestEndpointAdaptor.mjs +8 -7
- package/dist/endpoints/audit.d.cts +5 -5
- package/dist/endpoints/audit.d.mts +8 -8
- package/dist/endpoints/helpers.cjs +7 -7
- package/dist/endpoints/helpers.d.cts +5 -5
- package/dist/endpoints/helpers.d.cts.map +1 -1
- package/dist/endpoints/helpers.d.mts +8 -8
- package/dist/endpoints/helpers.d.mts.map +1 -1
- package/dist/endpoints/helpers.mjs +7 -7
- package/dist/endpoints/index.cjs +20 -10
- package/dist/endpoints/index.cjs.map +1 -1
- package/dist/endpoints/index.d.cts +10 -8
- package/dist/endpoints/index.d.cts.map +1 -1
- package/dist/endpoints/index.d.mts +13 -11
- package/dist/endpoints/index.d.mts.map +1 -1
- package/dist/endpoints/index.mjs +13 -11
- package/dist/endpoints/index.mjs.map +1 -1
- package/dist/endpoints/lazyAccessors.cjs +10 -0
- package/dist/endpoints/lazyAccessors.d.cts +10 -0
- package/dist/endpoints/lazyAccessors.d.mts +10 -0
- package/dist/endpoints/lazyAccessors.mjs +3 -0
- package/dist/endpoints/parseHonoQuery.cjs +1 -1
- package/dist/endpoints/parseHonoQuery.mjs +1 -1
- package/dist/endpoints/parseQueryParams.d.cts.map +1 -1
- package/dist/endpoints/parseQueryParams.d.mts.map +1 -1
- package/dist/endpoints/processAudits.d.cts +5 -5
- package/dist/endpoints/processAudits.d.cts.map +1 -1
- package/dist/endpoints/processAudits.d.mts +8 -8
- package/dist/endpoints/processAudits.d.mts.map +1 -1
- package/dist/endpoints/rls.cjs +1 -1
- package/dist/endpoints/rls.d.cts +5 -5
- package/dist/endpoints/rls.d.mts +8 -8
- package/dist/endpoints/rls.mjs +1 -1
- package/dist/functions/AWSLambdaFunction.cjs +6 -6
- package/dist/functions/AWSLambdaFunction.d.cts +3 -3
- 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.mts +2 -2
- package/dist/functions/BaseFunctionBuilder.mjs +2 -2
- package/dist/functions/Function.cjs +2 -2
- package/dist/functions/Function.d.cts +1 -1
- 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 +2 -2
- 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 +2 -2
- package/dist/functions/FunctionExecutionWrapper.d.mts +3 -3
- package/dist/functions/FunctionExecutionWrapper.mjs +5 -5
- package/dist/functions/TestFunctionAdaptor.cjs +7 -7
- package/dist/functions/TestFunctionAdaptor.cjs.map +1 -1
- package/dist/functions/TestFunctionAdaptor.d.cts +2 -2
- package/dist/functions/TestFunctionAdaptor.d.cts.map +1 -1
- package/dist/functions/TestFunctionAdaptor.d.mts +3 -3
- package/dist/functions/TestFunctionAdaptor.d.mts.map +1 -1
- package/dist/functions/TestFunctionAdaptor.mjs +7 -7
- package/dist/functions/TestFunctionAdaptor.mjs.map +1 -1
- package/dist/functions/index.cjs +5 -5
- package/dist/functions/index.d.cts +3 -3
- package/dist/functions/index.d.mts +5 -5
- package/dist/functions/index.mjs +5 -5
- package/dist/{functions-fTid0RMK.cjs → functions-BkKXVeHm.cjs} +2 -2
- package/dist/functions-BkKXVeHm.cjs.map +1 -0
- package/dist/functions-C3A1vMRW.mjs +8 -0
- package/dist/functions-C3A1vMRW.mjs.map +1 -0
- package/dist/{helpers-BcP1tXAi.cjs → helpers-BelEzV4U.cjs} +2 -2
- package/dist/helpers-BelEzV4U.cjs.map +1 -0
- package/dist/{helpers-ByRTDO_m.mjs → helpers-DgsMFMUV.mjs} +2 -2
- package/dist/helpers-DgsMFMUV.mjs.map +1 -0
- package/dist/{index-SI4V0XwK.d.cts → index-CgAQHr3f.d.mts} +2 -2
- package/dist/index-CgAQHr3f.d.mts.map +1 -0
- package/dist/{index-BWzGIj06.d.mts → index-D0fp_IK1.d.cts} +2 -2
- package/dist/index-D0fp_IK1.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +1 -1
- package/dist/lazyAccessors-B-Jgkg2o.mjs +175 -0
- package/dist/lazyAccessors-B-Jgkg2o.mjs.map +1 -0
- package/dist/lazyAccessors-B2ILzU-j.d.mts +49 -0
- package/dist/lazyAccessors-B2ILzU-j.d.mts.map +1 -0
- package/dist/lazyAccessors-B8Hhras9.cjs +223 -0
- package/dist/lazyAccessors-B8Hhras9.cjs.map +1 -0
- package/dist/lazyAccessors-Bcpi06ed.d.cts +49 -0
- package/dist/lazyAccessors-Bcpi06ed.d.cts.map +1 -0
- package/dist/{parseHonoQuery-CZC5_97v.cjs → parseHonoQuery-D4MhxTRc.cjs} +1 -1
- package/dist/parseHonoQuery-D4MhxTRc.cjs.map +1 -0
- package/dist/{parseHonoQuery-DDgIkTO4.mjs → parseHonoQuery-DpK3sGPc.mjs} +1 -1
- package/dist/parseHonoQuery-DpK3sGPc.mjs.map +1 -0
- package/dist/parseQueryParams-BSNkjmZ9.cjs.map +1 -1
- package/dist/parseQueryParams-UMTRnRrW.mjs.map +1 -1
- package/dist/processAudits-CzHkPokQ.cjs.map +1 -1
- package/dist/processAudits-Dj8UGqcW.mjs.map +1 -1
- package/dist/publisher-Bw4770Hi.mjs.map +1 -1
- package/dist/publisher-C4BhHB5I.d.cts +16 -0
- package/dist/publisher-C4BhHB5I.d.cts.map +1 -0
- package/dist/publisher-NE-GnXL8.d.mts +16 -0
- package/dist/publisher-NE-GnXL8.d.mts.map +1 -0
- package/dist/publisher-lFQleddL.cjs.map +1 -1
- package/dist/publisher.d.cts +3 -16
- package/dist/publisher.d.mts +3 -16
- package/dist/{rls-CmJ7bRsz.cjs → rls-BrywnrQb.cjs} +1 -1
- package/dist/{rls-CmJ7bRsz.cjs.map → rls-BrywnrQb.cjs.map} +1 -1
- package/dist/{rls-Bf3FRwto.mjs → rls-C0cWOnk4.mjs} +1 -1
- package/dist/{rls-Bf3FRwto.mjs.map → rls-C0cWOnk4.mjs.map} +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.cts +2 -2
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +3 -3
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +1 -1
- package/dist/subscribers/Subscriber.cjs +2 -2
- package/dist/subscribers/Subscriber.d.cts +1 -1
- 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 +2 -2
- 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.cjs.map +1 -1
- package/dist/subscribers/index.d.cts +2 -2
- package/dist/subscribers/index.d.cts.map +1 -1
- package/dist/subscribers/index.d.mts +3 -3
- package/dist/subscribers/index.d.mts.map +1 -1
- package/dist/subscribers/index.mjs +3 -3
- package/dist/subscribers/index.mjs.map +1 -1
- package/dist/telemetry-BTaiRqPo.d.cts +95 -0
- package/dist/telemetry-BTaiRqPo.d.cts.map +1 -0
- package/dist/telemetry-yAHf5yDs.d.mts +95 -0
- package/dist/telemetry-yAHf5yDs.d.mts.map +1 -0
- package/dist/telemetry.cjs +0 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +0 -0
- package/dist/types-B5H3piDg.d.cts.map +1 -1
- package/dist/{types-DdIlpxAd.d.mts → types-Dw-iLd3Y.d.mts} +1 -1
- package/dist/types-Dw-iLd3Y.d.mts.map +1 -0
- package/dist/types.d.mts +1 -1
- package/package.json +18 -18
- package/src/Construct.ts +117 -86
- package/src/__benchmarks__/build-time-optimization.bench.ts +274 -0
- package/src/__benchmarks__/endpoint.bench.ts +375 -375
- package/src/__benchmarks__/fixtures.ts +241 -0
- package/src/__benchmarks__/hono-adaptor.bench.ts +533 -0
- package/src/__benchmarks__/hono-server.bench.ts +206 -206
- package/src/__benchmarks__/response-builder.bench.ts +428 -0
- package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +319 -0
- package/src/__benchmarks__/strategies/strategy-c-middleware.ts +530 -0
- package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +567 -0
- package/src/__tests__/Construct.environment.spec.ts +349 -350
- package/src/__tests__/publisher.setting.spec.ts +496 -499
- package/src/__tests__/publisher.spec.ts +440 -442
- package/src/crons/Cron.ts +117 -117
- package/src/crons/CronBuilder.ts +237 -238
- package/src/crons/__tests__/Cron.spec.ts +448 -448
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +214 -214
- package/src/crons/index.ts +4 -4
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +571 -463
- package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +86 -86
- package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +85 -81
- package/src/endpoints/Authorizer.ts +100 -100
- package/src/endpoints/Endpoint.ts +921 -937
- package/src/endpoints/EndpointBuilder.ts +703 -703
- package/src/endpoints/EndpointFactory.ts +1054 -1056
- package/src/endpoints/HonoEndpointAdaptor.ts +621 -548
- package/src/endpoints/TestEndpointAdaptor.ts +373 -354
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +499 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +541 -542
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +1172 -1174
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +599 -599
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +710 -710
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +280 -280
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +924 -730
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +307 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +408 -408
- package/src/endpoints/__tests__/Authorizer.spec.ts +286 -0
- package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +162 -162
- package/src/endpoints/__tests__/Endpoint.headers.spec.ts +182 -182
- package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +158 -159
- package/src/endpoints/__tests__/Endpoint.spec.ts +819 -822
- package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +427 -427
- package/src/endpoints/__tests__/EndpointBuilder.spec.ts +478 -478
- package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +426 -426
- package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +501 -501
- package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +177 -177
- package/src/endpoints/__tests__/EndpointFactory.spec.ts +471 -471
- package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +143 -143
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +663 -663
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +608 -608
- package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +561 -561
- package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +1036 -1036
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +278 -278
- package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +1093 -1093
- package/src/endpoints/__tests__/ResponseBuilder.spec.ts +230 -230
- package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +569 -569
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +841 -841
- package/src/endpoints/__tests__/endpoint-types.test.ts +68 -68
- package/src/endpoints/__tests__/helpers.spec.ts +37 -0
- package/src/endpoints/__tests__/lazyAccessors.spec.ts +330 -0
- package/src/endpoints/__tests__/processAudits.spec.ts +631 -0
- package/src/endpoints/audit.ts +51 -51
- package/src/endpoints/helpers.ts +34 -35
- package/src/endpoints/index.ts +33 -23
- package/src/endpoints/lazyAccessors.ts +241 -0
- package/src/endpoints/parseHonoQuery.ts +41 -41
- package/src/endpoints/parseQueryParams.ts +36 -36
- package/src/endpoints/processAudits.ts +269 -269
- package/src/endpoints/rls.ts +16 -16
- package/src/functions/AWSLambdaFunction.ts +294 -295
- package/src/functions/BaseFunctionBuilder.ts +185 -185
- package/src/functions/Function.ts +190 -190
- package/src/functions/FunctionBuilder.ts +353 -353
- package/src/functions/FunctionExecutionWrapper.ts +199 -200
- package/src/functions/TestFunctionAdaptor.ts +191 -191
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +424 -424
- package/src/functions/__tests__/Function.audits.spec.ts +364 -364
- package/src/functions/__tests__/Function.spec.ts +453 -454
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +179 -179
- package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +369 -369
- package/src/functions/index.ts +6 -4
- package/src/index.ts +13 -9
- package/src/publisher.ts +71 -72
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +244 -248
- package/src/subscribers/Subscriber.ts +82 -84
- package/src/subscribers/SubscriberBuilder.ts +129 -129
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +589 -589
- package/src/subscribers/__tests__/Subscriber.spec.ts +402 -404
- package/src/subscribers/index.ts +1 -0
- package/src/telemetry.ts +103 -0
- package/src/types.ts +7 -7
- package/test.ts +58 -59
- package/dist/AWSLambdaFunction-BdebRMUh.d.mts.map +0 -1
- package/dist/AWSLambdaFunction-C54a1doJ.mjs.map +0 -1
- package/dist/AWSLambdaFunction-D0tEOTXQ.d.cts.map +0 -1
- package/dist/AWSLambdaFunction-EPGY4s7i.cjs.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-BLfO612H.mjs.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-BNcYYZ-P.cjs.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-DrFAvHOp.d.mts.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-Dx-Ks1Jp.d.cts.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-BT9JXihC.mjs.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-DLqnYQ4E.d.cts.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-DNFvvdmW.cjs.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-qlKXuZxy.d.mts.map +0 -1
- package/dist/AmazonApiGatewayV1EndpointAdaptor-CShQI8Gk.mjs.map +0 -1
- package/dist/AmazonApiGatewayV1EndpointAdaptor-Ccl8B8kG.cjs.map +0 -1
- package/dist/AmazonApiGatewayV1EndpointAdaptor-DyUaJIhB.d.cts.map +0 -1
- package/dist/AmazonApiGatewayV1EndpointAdaptor-MRUxs3Xi.d.mts.map +0 -1
- package/dist/AmazonApiGatewayV2EndpointAdaptor-D8-0Aab4.cjs.map +0 -1
- package/dist/AmazonApiGatewayV2EndpointAdaptor-M1-w0U5R.d.cts.map +0 -1
- package/dist/AmazonApiGatewayV2EndpointAdaptor-fuLM6M9k.d.mts.map +0 -1
- package/dist/AmazonApiGatewayV2EndpointAdaptor-lCRzGE4q.mjs.map +0 -1
- package/dist/Authorizer-B-btowNd.d.cts.map +0 -1
- package/dist/Authorizer-C0ge_tc8.cjs.map +0 -1
- package/dist/Authorizer-gWxYsGEp.d.mts.map +0 -1
- package/dist/Authorizer-r9U3y_ms.mjs.map +0 -1
- package/dist/BaseFunctionBuilder-Czi1Jwza.mjs.map +0 -1
- package/dist/BaseFunctionBuilder-DRY419e7.d.mts.map +0 -1
- package/dist/BaseFunctionBuilder-MYG3C9ug.cjs.map +0 -1
- package/dist/Construct-Ba5cMxib.cjs.map +0 -1
- package/dist/Construct-DdyGHuag.mjs.map +0 -1
- package/dist/Construct-XrijZFFh.d.mts.map +0 -1
- package/dist/Cron-BxhGs5up.mjs.map +0 -1
- package/dist/Cron-CGF4YAfM.cjs.map +0 -1
- package/dist/Cron-bDLcTvV5.d.cts.map +0 -1
- package/dist/Cron-cdjlSKNp.d.mts.map +0 -1
- package/dist/CronBuilder-BC4m5-p1.d.mts.map +0 -1
- package/dist/CronBuilder-CcxKRtVP.cjs.map +0 -1
- package/dist/CronBuilder-DKVXyE0Q.d.cts.map +0 -1
- package/dist/CronBuilder-d2jh-IB2.mjs.map +0 -1
- package/dist/Endpoint-BPv9_-m_.d.cts.map +0 -1
- package/dist/Endpoint-BVGZXFyV.cjs.map +0 -1
- package/dist/Endpoint-BdwG75G_.d.mts.map +0 -1
- package/dist/Endpoint-CuOEswxJ.mjs.map +0 -1
- package/dist/EndpointBuilder-B3az942t.d.mts.map +0 -1
- package/dist/EndpointBuilder-Cgj1P_ra.cjs.map +0 -1
- package/dist/EndpointBuilder-DIy_m1bu.d.cts.map +0 -1
- package/dist/EndpointBuilder-DnCB1h1j.mjs.map +0 -1
- package/dist/EndpointFactory-C-0nE6Jg.d.mts.map +0 -1
- package/dist/EndpointFactory-CYj6BYok.cjs.map +0 -1
- package/dist/EndpointFactory-CbdxPCIH.mjs.map +0 -1
- package/dist/EndpointFactory-CyPbm3AD.d.cts.map +0 -1
- package/dist/Function-BVHqIDp9.mjs.map +0 -1
- package/dist/Function-Cf7f_kCz.d.cts.map +0 -1
- package/dist/Function-DDZb1525.cjs.map +0 -1
- package/dist/Function-DN2G6OT5.d.mts.map +0 -1
- package/dist/FunctionBuilder-CJBzzXL3.d.cts.map +0 -1
- package/dist/FunctionBuilder-CrDYgfiI.mjs.map +0 -1
- package/dist/FunctionBuilder-Cxx8D2na.d.mts.map +0 -1
- package/dist/FunctionBuilder-DswJ-9sD.cjs.map +0 -1
- package/dist/FunctionExecutionWrapper-BYI2bGTL.cjs.map +0 -1
- package/dist/FunctionExecutionWrapper-CLDh7Z2_.mjs.map +0 -1
- package/dist/FunctionExecutionWrapper-DF260Aaj.d.mts.map +0 -1
- package/dist/FunctionExecutionWrapper-Qy8bmgFR.d.cts.map +0 -1
- package/dist/HonoEndpointAdaptor-Bqm6SEuP.d.cts.map +0 -1
- package/dist/HonoEndpointAdaptor-CQe2FqMR.cjs +0 -234
- package/dist/HonoEndpointAdaptor-CQe2FqMR.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-CRe-ij5f.d.mts.map +0 -1
- package/dist/HonoEndpointAdaptor-Ce-2HBxn.mjs +0 -228
- package/dist/HonoEndpointAdaptor-Ce-2HBxn.mjs.map +0 -1
- package/dist/Subscriber-BiHjVXtM.cjs.map +0 -1
- package/dist/Subscriber-BmPf9GFb.mjs.map +0 -1
- package/dist/Subscriber-COYMSevD.d.cts.map +0 -1
- package/dist/Subscriber-ikctpU3I.d.mts.map +0 -1
- package/dist/SubscriberBuilder-Cp1C-xtT.cjs.map +0 -1
- package/dist/SubscriberBuilder-DJPEeYDJ.mjs.map +0 -1
- package/dist/SubscriberBuilder-D_9zzllj.d.mts.map +0 -1
- package/dist/SubscriberBuilder-ivHAGIVi.d.cts.map +0 -1
- package/dist/TestEndpointAdaptor-BXTofAKc.mjs +0 -163
- package/dist/TestEndpointAdaptor-BXTofAKc.mjs.map +0 -1
- package/dist/TestEndpointAdaptor-C10xBI--.d.cts.map +0 -1
- package/dist/TestEndpointAdaptor-D9IwhIYg.cjs +0 -169
- package/dist/TestEndpointAdaptor-D9IwhIYg.cjs.map +0 -1
- package/dist/TestEndpointAdaptor-DB7bREhS.d.mts.map +0 -1
- package/dist/functions-C6EK1xL6.mjs +0 -8
- package/dist/functions-C6EK1xL6.mjs.map +0 -1
- package/dist/functions-fTid0RMK.cjs.map +0 -1
- package/dist/helpers-BcP1tXAi.cjs.map +0 -1
- package/dist/helpers-ByRTDO_m.mjs.map +0 -1
- package/dist/index-BWzGIj06.d.mts.map +0 -1
- package/dist/index-SI4V0XwK.d.cts.map +0 -1
- package/dist/parseHonoQuery-CZC5_97v.cjs.map +0 -1
- package/dist/parseHonoQuery-DDgIkTO4.mjs.map +0 -1
- package/dist/publisher.d.cts.map +0 -1
- package/dist/publisher.d.mts.map +0 -1
- package/dist/types-DdIlpxAd.d.mts.map +0 -1
|
@@ -6,826 +6,823 @@ import { z } from 'zod/v4';
|
|
|
6
6
|
import { Endpoint } from '../Endpoint';
|
|
7
7
|
|
|
8
8
|
describe('Endpoint', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
expect(noTokenResult).toBe(false);
|
|
829
|
-
});
|
|
830
|
-
});
|
|
9
|
+
describe('toOpenApi3Route', () => {
|
|
10
|
+
it('should generate basic OpenAPI spec for GET endpoint', async () => {
|
|
11
|
+
const endpoint = new Endpoint({
|
|
12
|
+
route: '/users',
|
|
13
|
+
method: 'GET',
|
|
14
|
+
authorize: undefined,
|
|
15
|
+
description: 'Get all users',
|
|
16
|
+
fn: async () => [],
|
|
17
|
+
input: undefined,
|
|
18
|
+
status: undefined,
|
|
19
|
+
getSession: undefined,
|
|
20
|
+
output: undefined,
|
|
21
|
+
services: [],
|
|
22
|
+
logger: {} as any,
|
|
23
|
+
timeout: undefined,
|
|
24
|
+
memorySize: undefined,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const spec = await endpoint.toOpenApi3Route();
|
|
28
|
+
|
|
29
|
+
expect(spec).toEqual({
|
|
30
|
+
'/users': {
|
|
31
|
+
get: {
|
|
32
|
+
description: 'Get all users',
|
|
33
|
+
responses: {
|
|
34
|
+
'200': {
|
|
35
|
+
description: 'Successful response',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should include response schema when output is defined', async () => {
|
|
44
|
+
const outputSchema = z.object({
|
|
45
|
+
id: z.string(),
|
|
46
|
+
name: z.string(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const endpoint = new Endpoint({
|
|
50
|
+
route: '/users/:id',
|
|
51
|
+
method: 'GET',
|
|
52
|
+
description: 'Get user by ID',
|
|
53
|
+
fn: async () => ({ id: '1', name: 'John' }),
|
|
54
|
+
input: undefined,
|
|
55
|
+
output: outputSchema,
|
|
56
|
+
authorize: undefined,
|
|
57
|
+
services: [],
|
|
58
|
+
status: undefined,
|
|
59
|
+
getSession: undefined,
|
|
60
|
+
logger: {} as any,
|
|
61
|
+
timeout: undefined,
|
|
62
|
+
memorySize: undefined,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const spec = await endpoint.toOpenApi3Route();
|
|
66
|
+
const doc = spec['/users/{id}'];
|
|
67
|
+
expect(doc.get.responses?.['200']).toHaveProperty('content');
|
|
68
|
+
expect(
|
|
69
|
+
(doc.get.responses?.['200'] as any).content['application/json'].schema,
|
|
70
|
+
).toMatchObject({
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
id: { type: 'string' },
|
|
74
|
+
name: { type: 'string' },
|
|
75
|
+
},
|
|
76
|
+
required: ['id', 'name'],
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should include request body for POST endpoint', async () => {
|
|
81
|
+
const bodySchema = z.object({
|
|
82
|
+
name: z.string(),
|
|
83
|
+
email: z.string().email(),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const endpoint = new Endpoint({
|
|
87
|
+
route: '/users',
|
|
88
|
+
method: 'POST',
|
|
89
|
+
authorize: undefined,
|
|
90
|
+
description: 'Create a new user',
|
|
91
|
+
fn: async (ctx) => ({ id: '1', ...(ctx as any).body }),
|
|
92
|
+
input: {
|
|
93
|
+
body: bodySchema,
|
|
94
|
+
},
|
|
95
|
+
output: undefined,
|
|
96
|
+
status: undefined,
|
|
97
|
+
getSession: undefined,
|
|
98
|
+
services: [],
|
|
99
|
+
logger: {} as any,
|
|
100
|
+
timeout: undefined,
|
|
101
|
+
memorySize: undefined,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const spec = await endpoint.toOpenApi3Route();
|
|
105
|
+
|
|
106
|
+
expect(spec['/users']?.post).toHaveProperty('requestBody');
|
|
107
|
+
expect((spec['/users']?.post! as any).requestBody).toMatchObject({
|
|
108
|
+
required: true,
|
|
109
|
+
content: {
|
|
110
|
+
'application/json': {
|
|
111
|
+
schema: {
|
|
112
|
+
type: 'object',
|
|
113
|
+
properties: {
|
|
114
|
+
name: { type: 'string' },
|
|
115
|
+
email: { type: 'string', format: 'email' },
|
|
116
|
+
},
|
|
117
|
+
required: ['name', 'email'],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should include path parameters at route level', async () => {
|
|
125
|
+
const paramsSchema = z.object({
|
|
126
|
+
id: z.string(),
|
|
127
|
+
subId: z.string().optional(),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const endpoint = new Endpoint({
|
|
131
|
+
route: '/users/:id/items/:subId',
|
|
132
|
+
method: 'GET',
|
|
133
|
+
status: undefined,
|
|
134
|
+
authorize: undefined,
|
|
135
|
+
getSession: undefined,
|
|
136
|
+
description: 'Get user item',
|
|
137
|
+
fn: async (ctx) => ({
|
|
138
|
+
userId: (ctx as any).params.id,
|
|
139
|
+
itemId: (ctx as any).params.subId,
|
|
140
|
+
}),
|
|
141
|
+
input: {
|
|
142
|
+
params: paramsSchema,
|
|
143
|
+
},
|
|
144
|
+
output: undefined,
|
|
145
|
+
services: [],
|
|
146
|
+
logger: {} as any,
|
|
147
|
+
timeout: undefined,
|
|
148
|
+
memorySize: undefined,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const spec = await endpoint.toOpenApi3Route();
|
|
152
|
+
|
|
153
|
+
const doc = spec['/users/{id}/items/{subId}'];
|
|
154
|
+
|
|
155
|
+
// Path parameters should be at route level, not method level
|
|
156
|
+
expect(doc).toHaveProperty('parameters');
|
|
157
|
+
const parameters = doc.parameters;
|
|
158
|
+
|
|
159
|
+
expect(parameters).toHaveLength(2);
|
|
160
|
+
expect(parameters).toContainEqual({
|
|
161
|
+
name: 'id',
|
|
162
|
+
in: 'path',
|
|
163
|
+
required: true,
|
|
164
|
+
schema: { type: 'string' },
|
|
165
|
+
});
|
|
166
|
+
expect(parameters).toContainEqual({
|
|
167
|
+
name: 'subId',
|
|
168
|
+
in: 'path',
|
|
169
|
+
required: false,
|
|
170
|
+
schema: { type: 'string' },
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Method should not have path parameters
|
|
174
|
+
expect(doc.get.parameters).toBeUndefined();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should include query parameters', async () => {
|
|
178
|
+
const searchSchema = z.object({
|
|
179
|
+
page: z.number().optional(),
|
|
180
|
+
limit: z.number().optional(),
|
|
181
|
+
sort: z.enum(['asc', 'desc']),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const endpoint = new Endpoint({
|
|
185
|
+
route: '/users',
|
|
186
|
+
method: 'GET',
|
|
187
|
+
authorize: undefined,
|
|
188
|
+
description: 'List users with pagination',
|
|
189
|
+
fn: async (_ctx) => [],
|
|
190
|
+
input: {
|
|
191
|
+
query: searchSchema,
|
|
192
|
+
},
|
|
193
|
+
output: undefined,
|
|
194
|
+
services: [],
|
|
195
|
+
logger: {} as any,
|
|
196
|
+
timeout: undefined,
|
|
197
|
+
memorySize: undefined,
|
|
198
|
+
status: undefined,
|
|
199
|
+
getSession: undefined,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const spec = await endpoint.toOpenApi3Route();
|
|
203
|
+
|
|
204
|
+
expect(spec['/users']?.get).toHaveProperty('parameters');
|
|
205
|
+
const parameters = (spec['/users']?.get! as any).parameters;
|
|
206
|
+
|
|
207
|
+
expect(parameters).toHaveLength(3);
|
|
208
|
+
expect(parameters).toContainEqual({
|
|
209
|
+
name: 'page',
|
|
210
|
+
in: 'query',
|
|
211
|
+
required: false,
|
|
212
|
+
schema: { type: 'number' },
|
|
213
|
+
});
|
|
214
|
+
expect(parameters).toContainEqual({
|
|
215
|
+
name: 'limit',
|
|
216
|
+
in: 'query',
|
|
217
|
+
required: false,
|
|
218
|
+
schema: { type: 'number' },
|
|
219
|
+
});
|
|
220
|
+
expect(parameters).toContainEqual({
|
|
221
|
+
name: 'sort',
|
|
222
|
+
in: 'query',
|
|
223
|
+
required: true,
|
|
224
|
+
schema: { type: 'string', enum: ['asc', 'desc'] },
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('should handle PUT endpoint with body and params', async () => {
|
|
229
|
+
const bodySchema = z.object({
|
|
230
|
+
name: z.string(),
|
|
231
|
+
email: z.string().email(),
|
|
232
|
+
});
|
|
233
|
+
const paramsSchema = z.object({
|
|
234
|
+
id: z.string(),
|
|
235
|
+
});
|
|
236
|
+
const outputSchema = z.object({
|
|
237
|
+
id: z.string(),
|
|
238
|
+
name: z.string(),
|
|
239
|
+
email: z.string(),
|
|
240
|
+
updatedAt: z.string(),
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const endpoint = new Endpoint({
|
|
244
|
+
route: '/users/:id',
|
|
245
|
+
method: 'PUT',
|
|
246
|
+
description: 'Update user',
|
|
247
|
+
status: undefined,
|
|
248
|
+
getSession: undefined,
|
|
249
|
+
authorize: undefined,
|
|
250
|
+
fn: async (ctx) => ({
|
|
251
|
+
id: (ctx as any).params.id,
|
|
252
|
+
...(ctx as any).body,
|
|
253
|
+
updatedAt: new Date().toISOString(),
|
|
254
|
+
}),
|
|
255
|
+
input: {
|
|
256
|
+
body: bodySchema,
|
|
257
|
+
params: paramsSchema,
|
|
258
|
+
},
|
|
259
|
+
output: outputSchema,
|
|
260
|
+
services: [],
|
|
261
|
+
logger: {} as any,
|
|
262
|
+
timeout: undefined,
|
|
263
|
+
memorySize: undefined,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
const spec = await endpoint.toOpenApi3Route();
|
|
267
|
+
const doc = spec['/users/{id}'];
|
|
268
|
+
|
|
269
|
+
// Check request body
|
|
270
|
+
expect(doc.put).toHaveProperty('requestBody');
|
|
271
|
+
expect(
|
|
272
|
+
(doc.put as any).requestBody.content['application/json'].schema,
|
|
273
|
+
).toMatchObject({
|
|
274
|
+
type: 'object',
|
|
275
|
+
properties: {
|
|
276
|
+
name: { type: 'string' },
|
|
277
|
+
email: { type: 'string', format: 'email' },
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Check path parameters at route level
|
|
282
|
+
expect(doc).toHaveProperty('parameters');
|
|
283
|
+
expect(doc.parameters).toHaveLength(1);
|
|
284
|
+
expect(doc.parameters?.[0]).toEqual({
|
|
285
|
+
name: 'id',
|
|
286
|
+
in: 'path',
|
|
287
|
+
required: true,
|
|
288
|
+
schema: { type: 'string' },
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// Method should not have path parameters
|
|
292
|
+
expect((doc.put as any).parameters).toBeUndefined();
|
|
293
|
+
|
|
294
|
+
// Check response
|
|
295
|
+
expect(
|
|
296
|
+
(doc.put.responses?.['200'] as any).content['application/json'].schema,
|
|
297
|
+
).toMatchObject({
|
|
298
|
+
type: 'object',
|
|
299
|
+
properties: {
|
|
300
|
+
id: { type: 'string' },
|
|
301
|
+
name: { type: 'string' },
|
|
302
|
+
email: { type: 'string' },
|
|
303
|
+
updatedAt: { type: 'string' },
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('should handle endpoint without any schemas', async () => {
|
|
309
|
+
const endpoint = new Endpoint({
|
|
310
|
+
route: '/health',
|
|
311
|
+
method: 'GET',
|
|
312
|
+
authorize: undefined,
|
|
313
|
+
fn: async () => ({ status: 'ok' }),
|
|
314
|
+
status: undefined,
|
|
315
|
+
getSession: undefined,
|
|
316
|
+
input: undefined,
|
|
317
|
+
output: undefined,
|
|
318
|
+
services: [],
|
|
319
|
+
logger: {} as any,
|
|
320
|
+
timeout: undefined,
|
|
321
|
+
memorySize: undefined,
|
|
322
|
+
description: undefined,
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
const spec = await endpoint.toOpenApi3Route();
|
|
326
|
+
|
|
327
|
+
expect(spec).toEqual({
|
|
328
|
+
'/health': {
|
|
329
|
+
get: {
|
|
330
|
+
responses: {
|
|
331
|
+
'200': {
|
|
332
|
+
description: 'Successful response',
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it('should not include body for GET endpoint even if provided', async () => {
|
|
341
|
+
const bodySchema = z.object({ invalid: z.string() });
|
|
342
|
+
|
|
343
|
+
const endpoint = new Endpoint({
|
|
344
|
+
route: '/users',
|
|
345
|
+
method: 'GET',
|
|
346
|
+
status: undefined,
|
|
347
|
+
getSession: undefined,
|
|
348
|
+
authorize: undefined,
|
|
349
|
+
output: z.object({
|
|
350
|
+
users: z.array(z.object({ id: z.string(), name: z.string() })),
|
|
351
|
+
}),
|
|
352
|
+
fn: async () => ({
|
|
353
|
+
users: [],
|
|
354
|
+
}),
|
|
355
|
+
input: {
|
|
356
|
+
body: bodySchema,
|
|
357
|
+
},
|
|
358
|
+
services: [],
|
|
359
|
+
logger: {} as any,
|
|
360
|
+
timeout: undefined,
|
|
361
|
+
memorySize: undefined,
|
|
362
|
+
description: undefined,
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
const spec = await endpoint.toOpenApi3Route();
|
|
366
|
+
|
|
367
|
+
expect(spec['/users']?.get).not.toHaveProperty('requestBody');
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('should correctly separate path and query parameters', async () => {
|
|
371
|
+
const paramsSchema = z.object({
|
|
372
|
+
userId: z.string(),
|
|
373
|
+
itemId: z.string(),
|
|
374
|
+
});
|
|
375
|
+
const querySchema = z.object({
|
|
376
|
+
limit: z.number().optional(),
|
|
377
|
+
offset: z.number().optional(),
|
|
378
|
+
filter: z.string(),
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const endpoint = new Endpoint({
|
|
382
|
+
route: '/users/:userId/items/:itemId',
|
|
383
|
+
method: 'GET',
|
|
384
|
+
description: 'Get user item with pagination',
|
|
385
|
+
fn: async () => ({}),
|
|
386
|
+
input: {
|
|
387
|
+
params: paramsSchema,
|
|
388
|
+
query: querySchema,
|
|
389
|
+
},
|
|
390
|
+
output: undefined,
|
|
391
|
+
services: [],
|
|
392
|
+
logger: {} as any,
|
|
393
|
+
timeout: undefined,
|
|
394
|
+
memorySize: undefined,
|
|
395
|
+
status: undefined,
|
|
396
|
+
getSession: undefined,
|
|
397
|
+
authorize: undefined,
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
const spec = await endpoint.toOpenApi3Route();
|
|
401
|
+
const doc = spec['/users/{userId}/items/{itemId}'];
|
|
402
|
+
|
|
403
|
+
// Path parameters should be at route level
|
|
404
|
+
expect(doc.parameters).toBeDefined();
|
|
405
|
+
expect(doc.parameters).toHaveLength(2);
|
|
406
|
+
expect(doc.parameters).toContainEqual({
|
|
407
|
+
name: 'userId',
|
|
408
|
+
in: 'path',
|
|
409
|
+
required: true,
|
|
410
|
+
schema: { type: 'string' },
|
|
411
|
+
});
|
|
412
|
+
expect(doc.parameters).toContainEqual({
|
|
413
|
+
name: 'itemId',
|
|
414
|
+
in: 'path',
|
|
415
|
+
required: true,
|
|
416
|
+
schema: { type: 'string' },
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// Query parameters should be at method level
|
|
420
|
+
expect(doc.get.parameters).toBeDefined();
|
|
421
|
+
expect(doc.get.parameters).toHaveLength(3);
|
|
422
|
+
expect(doc.get.parameters).toContainEqual({
|
|
423
|
+
name: 'limit',
|
|
424
|
+
in: 'query',
|
|
425
|
+
required: false,
|
|
426
|
+
schema: { type: 'number' },
|
|
427
|
+
});
|
|
428
|
+
expect(doc.get.parameters).toContainEqual({
|
|
429
|
+
name: 'offset',
|
|
430
|
+
in: 'query',
|
|
431
|
+
required: false,
|
|
432
|
+
schema: { type: 'number' },
|
|
433
|
+
});
|
|
434
|
+
expect(doc.get.parameters).toContainEqual({
|
|
435
|
+
name: 'filter',
|
|
436
|
+
in: 'query',
|
|
437
|
+
required: true,
|
|
438
|
+
schema: { type: 'string' },
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
describe('authorize property', () => {
|
|
444
|
+
const mockLogger: Logger = {
|
|
445
|
+
debug: vi.fn(),
|
|
446
|
+
info: vi.fn(),
|
|
447
|
+
warn: vi.fn(),
|
|
448
|
+
error: vi.fn(),
|
|
449
|
+
fatal: vi.fn(),
|
|
450
|
+
trace: vi.fn(),
|
|
451
|
+
child: vi.fn(() => mockLogger),
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
const services = ServiceDiscovery.getInstance(new EnvironmentParser({}));
|
|
455
|
+
|
|
456
|
+
it('should have default authorize function that returns true', async () => {
|
|
457
|
+
const endpoint = new Endpoint({
|
|
458
|
+
route: '/test',
|
|
459
|
+
method: 'GET',
|
|
460
|
+
fn: async () => ({ success: true }),
|
|
461
|
+
input: undefined,
|
|
462
|
+
output: undefined,
|
|
463
|
+
services: [],
|
|
464
|
+
authorize: undefined,
|
|
465
|
+
logger: mockLogger,
|
|
466
|
+
timeout: undefined,
|
|
467
|
+
memorySize: undefined,
|
|
468
|
+
status: undefined,
|
|
469
|
+
getSession: undefined,
|
|
470
|
+
description: undefined,
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
const result = await endpoint.authorize({
|
|
474
|
+
header: vi.fn(),
|
|
475
|
+
services,
|
|
476
|
+
logger: mockLogger,
|
|
477
|
+
session: {},
|
|
478
|
+
cookie: vi.fn(),
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
expect(result).toBe(true);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it('should allow custom authorize function', async () => {
|
|
485
|
+
const endpoint = new Endpoint({
|
|
486
|
+
route: '/test',
|
|
487
|
+
method: 'GET',
|
|
488
|
+
fn: async () => ({ success: true }),
|
|
489
|
+
input: undefined,
|
|
490
|
+
output: undefined,
|
|
491
|
+
services: [],
|
|
492
|
+
logger: mockLogger,
|
|
493
|
+
authorize: undefined,
|
|
494
|
+
timeout: undefined,
|
|
495
|
+
memorySize: undefined,
|
|
496
|
+
status: undefined,
|
|
497
|
+
getSession: undefined,
|
|
498
|
+
description: undefined,
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
const customAuthFn = vi.fn().mockResolvedValue(false);
|
|
502
|
+
endpoint.authorize = customAuthFn;
|
|
503
|
+
|
|
504
|
+
const mockContext = {
|
|
505
|
+
header: vi.fn(),
|
|
506
|
+
services,
|
|
507
|
+
logger: mockLogger,
|
|
508
|
+
session: {},
|
|
509
|
+
cookie: vi.fn(),
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
const result = await endpoint.authorize(mockContext);
|
|
513
|
+
|
|
514
|
+
expect(result).toBe(false);
|
|
515
|
+
expect(customAuthFn).toHaveBeenCalledWith(mockContext);
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
it('should support synchronous authorize function', () => {
|
|
519
|
+
const endpoint = new Endpoint({
|
|
520
|
+
route: '/test',
|
|
521
|
+
method: 'GET',
|
|
522
|
+
fn: async () => ({ success: true }),
|
|
523
|
+
input: undefined,
|
|
524
|
+
output: undefined,
|
|
525
|
+
services: [],
|
|
526
|
+
logger: mockLogger,
|
|
527
|
+
timeout: undefined,
|
|
528
|
+
memorySize: undefined,
|
|
529
|
+
authorize: undefined,
|
|
530
|
+
status: undefined,
|
|
531
|
+
getSession: undefined,
|
|
532
|
+
description: undefined,
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
const syncAuthFn = vi.fn().mockReturnValue(true);
|
|
536
|
+
endpoint.authorize = syncAuthFn;
|
|
537
|
+
|
|
538
|
+
const mockContext = {
|
|
539
|
+
header: vi.fn(),
|
|
540
|
+
services,
|
|
541
|
+
logger: mockLogger,
|
|
542
|
+
session: {},
|
|
543
|
+
cookie: vi.fn(),
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
const result = endpoint.authorize(mockContext);
|
|
547
|
+
|
|
548
|
+
expect(result).toBe(true);
|
|
549
|
+
expect(syncAuthFn).toHaveBeenCalledWith(mockContext);
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
it('should receive header function in context', async () => {
|
|
553
|
+
const endpoint = new Endpoint({
|
|
554
|
+
route: '/test',
|
|
555
|
+
method: 'GET',
|
|
556
|
+
fn: async () => ({ success: true }),
|
|
557
|
+
input: undefined,
|
|
558
|
+
output: undefined,
|
|
559
|
+
services: [],
|
|
560
|
+
authorize: undefined,
|
|
561
|
+
logger: mockLogger,
|
|
562
|
+
timeout: undefined,
|
|
563
|
+
memorySize: undefined,
|
|
564
|
+
status: undefined,
|
|
565
|
+
getSession: undefined,
|
|
566
|
+
description: undefined,
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
const headerFn = vi.fn().mockReturnValue('Bearer token123');
|
|
570
|
+
|
|
571
|
+
endpoint.authorize = ({ header }) => {
|
|
572
|
+
return header('authorization') === 'Bearer token123';
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
const result = await endpoint.authorize({
|
|
576
|
+
header: headerFn,
|
|
577
|
+
services,
|
|
578
|
+
logger: mockLogger,
|
|
579
|
+
session: {},
|
|
580
|
+
cookie: vi.fn(),
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
expect(result).toBe(true);
|
|
584
|
+
expect(headerFn).toHaveBeenCalledWith('authorization');
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it('should receive services in context', async () => {
|
|
588
|
+
const TestService = {
|
|
589
|
+
serviceName: 'TestService' as const,
|
|
590
|
+
register() {
|
|
591
|
+
return {
|
|
592
|
+
validateUser(id: string) {
|
|
593
|
+
return id === 'valid';
|
|
594
|
+
},
|
|
595
|
+
};
|
|
596
|
+
},
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
await services.register([TestService]);
|
|
600
|
+
const endpoint = new Endpoint({
|
|
601
|
+
route: '/test',
|
|
602
|
+
method: 'GET',
|
|
603
|
+
fn: async () => ({ success: true }),
|
|
604
|
+
input: undefined,
|
|
605
|
+
output: undefined,
|
|
606
|
+
services: [TestService],
|
|
607
|
+
logger: mockLogger,
|
|
608
|
+
timeout: undefined,
|
|
609
|
+
memorySize: undefined,
|
|
610
|
+
status: undefined,
|
|
611
|
+
authorize: async ({ services }) => {
|
|
612
|
+
return services.TestService.validateUser('valid');
|
|
613
|
+
},
|
|
614
|
+
getSession: undefined,
|
|
615
|
+
description: undefined,
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
const result = await endpoint.authorize({
|
|
619
|
+
header: vi.fn(),
|
|
620
|
+
services: { TestService: TestService.register() },
|
|
621
|
+
logger: mockLogger,
|
|
622
|
+
session: {},
|
|
623
|
+
cookie: vi.fn(),
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
expect(result).toBe(true);
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
it('should receive logger in context', async () => {
|
|
630
|
+
const endpoint = new Endpoint({
|
|
631
|
+
route: '/test',
|
|
632
|
+
method: 'GET',
|
|
633
|
+
fn: async () => ({ success: true }),
|
|
634
|
+
input: undefined,
|
|
635
|
+
output: undefined,
|
|
636
|
+
authorize: undefined,
|
|
637
|
+
services: [],
|
|
638
|
+
logger: mockLogger,
|
|
639
|
+
timeout: undefined,
|
|
640
|
+
memorySize: undefined,
|
|
641
|
+
status: undefined,
|
|
642
|
+
getSession: undefined,
|
|
643
|
+
description: undefined,
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
const loggerSpy = vi.fn();
|
|
647
|
+
const testLogger = {
|
|
648
|
+
...mockLogger,
|
|
649
|
+
info: loggerSpy,
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
endpoint.authorize = ({ logger }) => {
|
|
653
|
+
logger.info('Authorization check');
|
|
654
|
+
return true;
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
const result = await endpoint.authorize({
|
|
658
|
+
header: vi.fn(),
|
|
659
|
+
services,
|
|
660
|
+
logger: testLogger,
|
|
661
|
+
cookie: vi.fn(),
|
|
662
|
+
session: {},
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
expect(result).toBe(true);
|
|
666
|
+
expect(loggerSpy).toHaveBeenCalledWith('Authorization check');
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
it('should receive session in context', async () => {
|
|
670
|
+
const endpoint = new Endpoint({
|
|
671
|
+
route: '/test',
|
|
672
|
+
method: 'GET',
|
|
673
|
+
fn: async () => ({ success: true }),
|
|
674
|
+
input: undefined,
|
|
675
|
+
output: undefined,
|
|
676
|
+
authorize: undefined,
|
|
677
|
+
services: [],
|
|
678
|
+
logger: mockLogger,
|
|
679
|
+
timeout: undefined,
|
|
680
|
+
memorySize: undefined,
|
|
681
|
+
status: undefined,
|
|
682
|
+
getSession: () => ({ role: 'admin' }),
|
|
683
|
+
description: undefined,
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
const mockSession = { userId: 'user123', role: 'admin' };
|
|
687
|
+
|
|
688
|
+
endpoint.authorize = ({ session }) => {
|
|
689
|
+
return session.role === 'admin';
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
const result = await endpoint.authorize({
|
|
693
|
+
header: vi.fn(),
|
|
694
|
+
services,
|
|
695
|
+
logger: mockLogger,
|
|
696
|
+
session: mockSession,
|
|
697
|
+
cookie: vi.fn(),
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
expect(result).toBe(true);
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
it('should handle authorize function that throws error', async () => {
|
|
704
|
+
const endpoint = new Endpoint({
|
|
705
|
+
route: '/test',
|
|
706
|
+
method: 'GET',
|
|
707
|
+
fn: async () => ({ success: true }),
|
|
708
|
+
input: undefined,
|
|
709
|
+
output: undefined,
|
|
710
|
+
services: [],
|
|
711
|
+
authorize: async () => {
|
|
712
|
+
throw new Error('Authorization failed');
|
|
713
|
+
},
|
|
714
|
+
|
|
715
|
+
logger: mockLogger,
|
|
716
|
+
timeout: undefined,
|
|
717
|
+
memorySize: undefined,
|
|
718
|
+
status: undefined,
|
|
719
|
+
getSession: undefined,
|
|
720
|
+
description: undefined,
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
await expect(() =>
|
|
724
|
+
endpoint.authorize({
|
|
725
|
+
header: vi.fn(),
|
|
726
|
+
services,
|
|
727
|
+
logger: mockLogger,
|
|
728
|
+
session: {},
|
|
729
|
+
cookie: vi.fn(),
|
|
730
|
+
}),
|
|
731
|
+
).rejects.toThrow('Authorization failed');
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
it('should handle async authorize function that throws error', async () => {
|
|
735
|
+
const endpoint = new Endpoint({
|
|
736
|
+
route: '/test',
|
|
737
|
+
method: 'GET',
|
|
738
|
+
fn: async () => ({ success: true }),
|
|
739
|
+
input: undefined,
|
|
740
|
+
output: undefined,
|
|
741
|
+
services: [],
|
|
742
|
+
logger: mockLogger,
|
|
743
|
+
timeout: undefined,
|
|
744
|
+
memorySize: undefined,
|
|
745
|
+
authorize: undefined,
|
|
746
|
+
status: undefined,
|
|
747
|
+
getSession: undefined,
|
|
748
|
+
description: undefined,
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
endpoint.authorize = async () => {
|
|
752
|
+
throw new Error('Async authorization failed');
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
await expect(
|
|
756
|
+
endpoint.authorize({
|
|
757
|
+
header: vi.fn(),
|
|
758
|
+
services,
|
|
759
|
+
logger: mockLogger,
|
|
760
|
+
session: {},
|
|
761
|
+
cookie: vi.fn(),
|
|
762
|
+
}),
|
|
763
|
+
).rejects.toThrow('Async authorization failed');
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
it('should work with complex authorization logic', async () => {
|
|
767
|
+
const endpoint = new Endpoint({
|
|
768
|
+
route: '/admin/users',
|
|
769
|
+
method: 'GET',
|
|
770
|
+
authorize: undefined,
|
|
771
|
+
fn: async () => ({ users: [] }),
|
|
772
|
+
input: undefined,
|
|
773
|
+
output: undefined,
|
|
774
|
+
services: [],
|
|
775
|
+
logger: mockLogger,
|
|
776
|
+
timeout: undefined,
|
|
777
|
+
memorySize: undefined,
|
|
778
|
+
status: undefined,
|
|
779
|
+
getSession: undefined,
|
|
780
|
+
description: undefined,
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
endpoint.authorize = async ({ header, session }) => {
|
|
784
|
+
// Simulate complex authorization logic
|
|
785
|
+
const token = header('authorization');
|
|
786
|
+
if (!token) return false;
|
|
787
|
+
|
|
788
|
+
const user = session as any;
|
|
789
|
+
if (!user?.role) return false;
|
|
790
|
+
|
|
791
|
+
return user.role === 'admin' || user.role === 'superuser';
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
// Test with admin role
|
|
795
|
+
const adminResult = await endpoint.authorize({
|
|
796
|
+
header: vi.fn().mockReturnValue('Bearer admin-token'),
|
|
797
|
+
services,
|
|
798
|
+
logger: mockLogger,
|
|
799
|
+
cookie: vi.fn(),
|
|
800
|
+
session: { userId: 'admin1', role: 'admin' },
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
expect(adminResult).toBe(true);
|
|
804
|
+
|
|
805
|
+
// Test with user role
|
|
806
|
+
const userResult = await endpoint.authorize({
|
|
807
|
+
header: vi.fn().mockReturnValue('Bearer user-token'),
|
|
808
|
+
services,
|
|
809
|
+
cookie: vi.fn(),
|
|
810
|
+
logger: mockLogger,
|
|
811
|
+
session: { userId: 'user1', role: 'user' },
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
expect(userResult).toBe(false);
|
|
815
|
+
|
|
816
|
+
// Test with no token
|
|
817
|
+
const noTokenResult = await endpoint.authorize({
|
|
818
|
+
header: vi.fn().mockReturnValue(undefined),
|
|
819
|
+
services,
|
|
820
|
+
logger: mockLogger,
|
|
821
|
+
session: { userId: 'user1', role: 'admin' },
|
|
822
|
+
cookie: vi.fn(),
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
expect(noTokenResult).toBe(false);
|
|
826
|
+
});
|
|
827
|
+
});
|
|
831
828
|
});
|