@geekmidas/constructs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/README.md +614 -0
  2. package/dist/AWSLambdaFunction-CpHFE2m6.d.mts +27 -0
  3. package/dist/AWSLambdaFunction-CwagvPG3.d.cts +27 -0
  4. package/dist/AWSLambdaFunction-DWIZYsCy.mjs +79 -0
  5. package/dist/AWSLambdaFunction-DWIZYsCy.mjs.map +1 -0
  6. package/dist/AWSLambdaFunction-qA5LqPsv.cjs +85 -0
  7. package/dist/AWSLambdaFunction-qA5LqPsv.cjs.map +1 -0
  8. package/dist/AWSLambdaSubscriberAdaptor-C1wQuucQ.d.mts +32 -0
  9. package/dist/AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs +138 -0
  10. package/dist/AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs.map +1 -0
  11. package/dist/AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs +132 -0
  12. package/dist/AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs.map +1 -0
  13. package/dist/AWSLambdaSubscriberAdaptor-QKVxR6qh.d.cts +32 -0
  14. package/dist/AmazonApiGatewayEndpointAdaptor-BoBh7vvD.d.mts +61 -0
  15. package/dist/AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs +124 -0
  16. package/dist/AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs.map +1 -0
  17. package/dist/AmazonApiGatewayEndpointAdaptor-DtzgQ9Vb.d.cts +61 -0
  18. package/dist/AmazonApiGatewayEndpointAdaptor-i74DEUbc.cjs +130 -0
  19. package/dist/AmazonApiGatewayEndpointAdaptor-i74DEUbc.cjs.map +1 -0
  20. package/dist/AmazonApiGatewayV1EndpointAdaptor-CLmBDYsl.mjs +42 -0
  21. package/dist/AmazonApiGatewayV1EndpointAdaptor-CLmBDYsl.mjs.map +1 -0
  22. package/dist/AmazonApiGatewayV1EndpointAdaptor-EhMd1YqV.d.mts +21 -0
  23. package/dist/AmazonApiGatewayV1EndpointAdaptor-GkMAUPL5.cjs +47 -0
  24. package/dist/AmazonApiGatewayV1EndpointAdaptor-GkMAUPL5.cjs.map +1 -0
  25. package/dist/AmazonApiGatewayV1EndpointAdaptor-Gw-j61qM.d.cts +21 -0
  26. package/dist/AmazonApiGatewayV2EndpointAdaptor-3RqegmJC.mjs +41 -0
  27. package/dist/AmazonApiGatewayV2EndpointAdaptor-3RqegmJC.mjs.map +1 -0
  28. package/dist/AmazonApiGatewayV2EndpointAdaptor-LUlpwmUW.d.cts +21 -0
  29. package/dist/AmazonApiGatewayV2EndpointAdaptor-YlFoFSS9.cjs +46 -0
  30. package/dist/AmazonApiGatewayV2EndpointAdaptor-YlFoFSS9.cjs.map +1 -0
  31. package/dist/AmazonApiGatewayV2EndpointAdaptor-zfd1gqXA.d.mts +21 -0
  32. package/dist/BaseFunctionBuilder-5QCHkchp.d.cts +31 -0
  33. package/dist/BaseFunctionBuilder-BFPVGnKi.d.mts +31 -0
  34. package/dist/BaseFunctionBuilder-BPE9JBbT.mjs +56 -0
  35. package/dist/BaseFunctionBuilder-BPE9JBbT.mjs.map +1 -0
  36. package/dist/BaseFunctionBuilder-DtO4Nwxm.cjs +62 -0
  37. package/dist/BaseFunctionBuilder-DtO4Nwxm.cjs.map +1 -0
  38. package/dist/Construct-BSEs6uwW.cjs +75 -0
  39. package/dist/Construct-BSEs6uwW.cjs.map +1 -0
  40. package/dist/Construct-BbKCIPQm.mjs +63 -0
  41. package/dist/Construct-BbKCIPQm.mjs.map +1 -0
  42. package/dist/Construct-Bm-PSO2V.d.cts +42 -0
  43. package/dist/Construct-DIguIyw4.d.mts +42 -0
  44. package/dist/Construct.cjs +4 -0
  45. package/dist/Construct.d.cts +2 -0
  46. package/dist/Construct.d.mts +2 -0
  47. package/dist/Construct.mjs +3 -0
  48. package/dist/Cron-Bgs6EQOb.mjs +20 -0
  49. package/dist/Cron-Bgs6EQOb.mjs.map +1 -0
  50. package/dist/Cron-DQiCj3ef.cjs +25 -0
  51. package/dist/Cron-DQiCj3ef.cjs.map +1 -0
  52. package/dist/Cron-FpAw03k6.d.mts +25 -0
  53. package/dist/Cron-ztnK6zgU.d.cts +25 -0
  54. package/dist/CronBuilder-B2clNQSP.d.mts +24 -0
  55. package/dist/CronBuilder-Cje9K8lZ.d.cts +24 -0
  56. package/dist/CronBuilder-DIBqJkh_.cjs +60 -0
  57. package/dist/CronBuilder-DIBqJkh_.cjs.map +1 -0
  58. package/dist/CronBuilder-DecAvvcn.mjs +54 -0
  59. package/dist/CronBuilder-DecAvvcn.mjs.map +1 -0
  60. package/dist/Endpoint-BaHC9y4Z.cjs +291 -0
  61. package/dist/Endpoint-BaHC9y4Z.cjs.map +1 -0
  62. package/dist/Endpoint-C7z9YJHK.d.cts +405 -0
  63. package/dist/Endpoint-DCn53Vd8.d.mts +405 -0
  64. package/dist/Endpoint-ierdM62O.mjs +279 -0
  65. package/dist/Endpoint-ierdM62O.mjs.map +1 -0
  66. package/dist/EndpointBuilder-BHFSpbPR.cjs +107 -0
  67. package/dist/EndpointBuilder-BHFSpbPR.cjs.map +1 -0
  68. package/dist/EndpointBuilder-BLUsoK3l.mjs +101 -0
  69. package/dist/EndpointBuilder-BLUsoK3l.mjs.map +1 -0
  70. package/dist/EndpointBuilder-Bfnb2oJr.d.mts +49 -0
  71. package/dist/EndpointBuilder-CP9RGwZH.d.cts +49 -0
  72. package/dist/EndpointFactory-BYdDVCNj.mjs +127 -0
  73. package/dist/EndpointFactory-BYdDVCNj.mjs.map +1 -0
  74. package/dist/EndpointFactory-CNtMXgIh.d.mts +52 -0
  75. package/dist/EndpointFactory-CXX4E6Gx.cjs +139 -0
  76. package/dist/EndpointFactory-CXX4E6Gx.cjs.map +1 -0
  77. package/dist/EndpointFactory-D2zgWbXZ.d.cts +52 -0
  78. package/dist/Function-BP58p9Mp.d.cts +59 -0
  79. package/dist/Function-BsBxc2wA.d.mts +59 -0
  80. package/dist/Function-C5mW-38v.mjs +72 -0
  81. package/dist/Function-C5mW-38v.mjs.map +1 -0
  82. package/dist/Function-CbO2NZx-.cjs +84 -0
  83. package/dist/Function-CbO2NZx-.cjs.map +1 -0
  84. package/dist/FunctionBuilder-BS1KgxA_.d.cts +24 -0
  85. package/dist/FunctionBuilder-C-PfPN3r.d.mts +24 -0
  86. package/dist/FunctionBuilder-CosgPmMl.mjs +53 -0
  87. package/dist/FunctionBuilder-CosgPmMl.mjs.map +1 -0
  88. package/dist/FunctionBuilder-DuOeWCAl.cjs +59 -0
  89. package/dist/FunctionBuilder-DuOeWCAl.cjs.map +1 -0
  90. package/dist/FunctionExecutionWrapper-Bx-Dl-2a.d.cts +24 -0
  91. package/dist/FunctionExecutionWrapper-CElXEjPe.cjs +42 -0
  92. package/dist/FunctionExecutionWrapper-CElXEjPe.cjs.map +1 -0
  93. package/dist/FunctionExecutionWrapper-DvglBBjE.d.mts +24 -0
  94. package/dist/FunctionExecutionWrapper-XGrSAAPD.mjs +36 -0
  95. package/dist/FunctionExecutionWrapper-XGrSAAPD.mjs.map +1 -0
  96. package/dist/HonoEndpointAdaptor-B0IO1zj2.d.mts +41 -0
  97. package/dist/HonoEndpointAdaptor-B4snrp7v.cjs +154 -0
  98. package/dist/HonoEndpointAdaptor-B4snrp7v.cjs.map +1 -0
  99. package/dist/HonoEndpointAdaptor-B6lW9Q1k.d.cts +41 -0
  100. package/dist/HonoEndpointAdaptor-D-M4-6Tf.mjs +148 -0
  101. package/dist/HonoEndpointAdaptor-D-M4-6Tf.mjs.map +1 -0
  102. package/dist/Subscriber-BoFm12i_.d.cts +33 -0
  103. package/dist/Subscriber-BwuCaC9G.mjs +28 -0
  104. package/dist/Subscriber-BwuCaC9G.mjs.map +1 -0
  105. package/dist/Subscriber-THGsj7Iy.d.mts +33 -0
  106. package/dist/Subscriber-iMRFG7ba.cjs +34 -0
  107. package/dist/Subscriber-iMRFG7ba.cjs.map +1 -0
  108. package/dist/SubscriberBuilder-CiPxgnKT.d.mts +26 -0
  109. package/dist/SubscriberBuilder-Dhz0C_t-.mjs +54 -0
  110. package/dist/SubscriberBuilder-Dhz0C_t-.mjs.map +1 -0
  111. package/dist/SubscriberBuilder-DuIgxuzc.d.cts +26 -0
  112. package/dist/SubscriberBuilder-wthr-FL9.cjs +60 -0
  113. package/dist/SubscriberBuilder-wthr-FL9.cjs.map +1 -0
  114. package/dist/adaptors/aws.cjs +19 -0
  115. package/dist/adaptors/aws.d.cts +15 -0
  116. package/dist/adaptors/aws.d.mts +15 -0
  117. package/dist/adaptors/aws.mjs +16 -0
  118. package/dist/adaptors/hono.cjs +12 -0
  119. package/dist/adaptors/hono.d.cts +9 -0
  120. package/dist/adaptors/hono.d.mts +9 -0
  121. package/dist/adaptors/hono.mjs +12 -0
  122. package/dist/chunk-CUT6urMc.cjs +30 -0
  123. package/dist/crons/Cron.cjs +8 -0
  124. package/dist/crons/Cron.d.cts +7 -0
  125. package/dist/crons/Cron.d.mts +7 -0
  126. package/dist/crons/Cron.mjs +8 -0
  127. package/dist/crons/CronBuilder.cjs +9 -0
  128. package/dist/crons/CronBuilder.d.cts +8 -0
  129. package/dist/crons/CronBuilder.d.mts +8 -0
  130. package/dist/crons/CronBuilder.mjs +9 -0
  131. package/dist/crons/index.cjs +16 -0
  132. package/dist/crons/index.cjs.map +1 -0
  133. package/dist/crons/index.d.cts +16 -0
  134. package/dist/crons/index.d.mts +16 -0
  135. package/dist/crons/index.mjs +14 -0
  136. package/dist/crons/index.mjs.map +1 -0
  137. package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +10 -0
  138. package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +9 -0
  139. package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +9 -0
  140. package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +10 -0
  141. package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +12 -0
  142. package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +10 -0
  143. package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +10 -0
  144. package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +12 -0
  145. package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +12 -0
  146. package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +10 -0
  147. package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +10 -0
  148. package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +12 -0
  149. package/dist/endpoints/Endpoint.cjs +9 -0
  150. package/dist/endpoints/Endpoint.d.cts +8 -0
  151. package/dist/endpoints/Endpoint.d.mts +8 -0
  152. package/dist/endpoints/Endpoint.mjs +8 -0
  153. package/dist/endpoints/EndpointBuilder.cjs +9 -0
  154. package/dist/endpoints/EndpointBuilder.d.cts +9 -0
  155. package/dist/endpoints/EndpointBuilder.d.mts +9 -0
  156. package/dist/endpoints/EndpointBuilder.mjs +9 -0
  157. package/dist/endpoints/EndpointFactory.cjs +11 -0
  158. package/dist/endpoints/EndpointFactory.d.cts +10 -0
  159. package/dist/endpoints/EndpointFactory.d.mts +10 -0
  160. package/dist/endpoints/EndpointFactory.mjs +10 -0
  161. package/dist/endpoints/HonoEndpointAdaptor.cjs +12 -0
  162. package/dist/endpoints/HonoEndpointAdaptor.d.cts +9 -0
  163. package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -0
  164. package/dist/endpoints/HonoEndpointAdaptor.mjs +12 -0
  165. package/dist/endpoints/TestEndpointAdaptor.cjs +54 -0
  166. package/dist/endpoints/TestEndpointAdaptor.cjs.map +1 -0
  167. package/dist/endpoints/TestEndpointAdaptor.d.cts +29 -0
  168. package/dist/endpoints/TestEndpointAdaptor.d.mts +29 -0
  169. package/dist/endpoints/TestEndpointAdaptor.mjs +53 -0
  170. package/dist/endpoints/TestEndpointAdaptor.mjs.map +1 -0
  171. package/dist/endpoints/helpers.cjs +10 -0
  172. package/dist/endpoints/helpers.d.cts +58 -0
  173. package/dist/endpoints/helpers.d.mts +58 -0
  174. package/dist/endpoints/helpers.mjs +9 -0
  175. package/dist/endpoints/index.cjs +16 -0
  176. package/dist/endpoints/index.cjs.map +1 -0
  177. package/dist/endpoints/index.d.cts +16 -0
  178. package/dist/endpoints/index.d.mts +16 -0
  179. package/dist/endpoints/index.mjs +15 -0
  180. package/dist/endpoints/index.mjs.map +1 -0
  181. package/dist/endpoints/parseHonoQuery.cjs +3 -0
  182. package/dist/endpoints/parseHonoQuery.d.cts +12 -0
  183. package/dist/endpoints/parseHonoQuery.d.mts +12 -0
  184. package/dist/endpoints/parseHonoQuery.mjs +3 -0
  185. package/dist/endpoints/parseQueryParams.cjs +3 -0
  186. package/dist/endpoints/parseQueryParams.d.cts +13 -0
  187. package/dist/endpoints/parseQueryParams.d.mts +13 -0
  188. package/dist/endpoints/parseQueryParams.mjs +3 -0
  189. package/dist/functions/AWSLambdaFunction.cjs +9 -0
  190. package/dist/functions/AWSLambdaFunction.d.cts +5 -0
  191. package/dist/functions/AWSLambdaFunction.d.mts +5 -0
  192. package/dist/functions/AWSLambdaFunction.mjs +9 -0
  193. package/dist/functions/BaseFunctionBuilder.cjs +4 -0
  194. package/dist/functions/BaseFunctionBuilder.d.cts +3 -0
  195. package/dist/functions/BaseFunctionBuilder.d.mts +3 -0
  196. package/dist/functions/BaseFunctionBuilder.mjs +4 -0
  197. package/dist/functions/Function.cjs +5 -0
  198. package/dist/functions/Function.d.cts +3 -0
  199. package/dist/functions/Function.d.mts +3 -0
  200. package/dist/functions/Function.mjs +4 -0
  201. package/dist/functions/FunctionBuilder.cjs +6 -0
  202. package/dist/functions/FunctionBuilder.d.cts +5 -0
  203. package/dist/functions/FunctionBuilder.d.mts +5 -0
  204. package/dist/functions/FunctionBuilder.mjs +6 -0
  205. package/dist/functions/FunctionExecutionWrapper.cjs +8 -0
  206. package/dist/functions/FunctionExecutionWrapper.d.cts +4 -0
  207. package/dist/functions/FunctionExecutionWrapper.d.mts +4 -0
  208. package/dist/functions/FunctionExecutionWrapper.mjs +8 -0
  209. package/dist/functions/TestFunctionAdaptor.cjs +38 -0
  210. package/dist/functions/TestFunctionAdaptor.cjs.map +1 -0
  211. package/dist/functions/TestFunctionAdaptor.d.cts +26 -0
  212. package/dist/functions/TestFunctionAdaptor.d.mts +26 -0
  213. package/dist/functions/TestFunctionAdaptor.mjs +37 -0
  214. package/dist/functions/TestFunctionAdaptor.mjs.map +1 -0
  215. package/dist/functions/index.cjs +10 -0
  216. package/dist/functions/index.d.cts +6 -0
  217. package/dist/functions/index.d.mts +6 -0
  218. package/dist/functions/index.mjs +7 -0
  219. package/dist/functions-DVDb5wEA.cjs +13 -0
  220. package/dist/functions-DVDb5wEA.cjs.map +1 -0
  221. package/dist/functions-mM-jcphA.mjs +8 -0
  222. package/dist/functions-mM-jcphA.mjs.map +1 -0
  223. package/dist/helpers-BeGM4pP_.cjs +95 -0
  224. package/dist/helpers-BeGM4pP_.cjs.map +1 -0
  225. package/dist/helpers-DbpO95aE.mjs +83 -0
  226. package/dist/helpers-DbpO95aE.mjs.map +1 -0
  227. package/dist/index-CuGR4L7O.d.mts +9 -0
  228. package/dist/index-Fg3N3EKD.d.cts +9 -0
  229. package/dist/index.cjs +4 -0
  230. package/dist/index.d.cts +4 -0
  231. package/dist/index.d.mts +4 -0
  232. package/dist/index.mjs +3 -0
  233. package/dist/parseHonoQuery-DopC24vB.cjs +37 -0
  234. package/dist/parseHonoQuery-DopC24vB.cjs.map +1 -0
  235. package/dist/parseHonoQuery-znDKBhdE.mjs +31 -0
  236. package/dist/parseHonoQuery-znDKBhdE.mjs.map +1 -0
  237. package/dist/parseQueryParams-BJaRh3OB.mjs +32 -0
  238. package/dist/parseQueryParams-BJaRh3OB.mjs.map +1 -0
  239. package/dist/parseQueryParams-BzPop4I1.cjs +38 -0
  240. package/dist/parseQueryParams-BzPop4I1.cjs.map +1 -0
  241. package/dist/publisher-Bw4770Hi.mjs +41 -0
  242. package/dist/publisher-Bw4770Hi.mjs.map +1 -0
  243. package/dist/publisher-lFQleddL.cjs +53 -0
  244. package/dist/publisher-lFQleddL.cjs.map +1 -0
  245. package/dist/publisher.cjs +4 -0
  246. package/dist/publisher.d.cts +13 -0
  247. package/dist/publisher.d.mts +13 -0
  248. package/dist/publisher.mjs +3 -0
  249. package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +3 -0
  250. package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.cts +4 -0
  251. package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +4 -0
  252. package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +3 -0
  253. package/dist/subscribers/Subscriber.cjs +4 -0
  254. package/dist/subscribers/Subscriber.d.cts +3 -0
  255. package/dist/subscribers/Subscriber.d.mts +3 -0
  256. package/dist/subscribers/Subscriber.mjs +4 -0
  257. package/dist/subscribers/SubscriberBuilder.cjs +5 -0
  258. package/dist/subscribers/SubscriberBuilder.d.cts +4 -0
  259. package/dist/subscribers/SubscriberBuilder.d.mts +4 -0
  260. package/dist/subscribers/SubscriberBuilder.mjs +5 -0
  261. package/dist/subscribers/index.cjs +12 -0
  262. package/dist/subscribers/index.cjs.map +1 -0
  263. package/dist/subscribers/index.d.cts +10 -0
  264. package/dist/subscribers/index.d.mts +10 -0
  265. package/dist/subscribers/index.mjs +10 -0
  266. package/dist/subscribers/index.mjs.map +1 -0
  267. package/dist/types-Bp9ysFXd.d.cts +7 -0
  268. package/dist/types-DBKNYvsW.d.mts +7 -0
  269. package/dist/types.cjs +0 -0
  270. package/dist/types.d.cts +2 -0
  271. package/dist/types.d.mts +2 -0
  272. package/dist/types.mjs +0 -0
  273. package/package.json +91 -0
  274. package/src/Construct.ts +98 -0
  275. package/src/__tests__/Construct.environment.spec.ts +360 -0
  276. package/src/__tests__/publisher.setting.spec.ts +511 -0
  277. package/src/__tests__/publisher.spec.ts +454 -0
  278. package/src/adaptors/aws.ts +4 -0
  279. package/src/adaptors/hono.ts +1 -0
  280. package/src/crons/Cron.ts +137 -0
  281. package/src/crons/CronBuilder.ts +192 -0
  282. package/src/crons/__tests__/Cron.spec.ts +464 -0
  283. package/src/crons/index.ts +11 -0
  284. package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +315 -0
  285. package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +101 -0
  286. package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +95 -0
  287. package/src/endpoints/Endpoint.ts +771 -0
  288. package/src/endpoints/EndpointBuilder.ts +308 -0
  289. package/src/endpoints/EndpointFactory.ts +329 -0
  290. package/src/endpoints/HonoEndpointAdaptor.ts +365 -0
  291. package/src/endpoints/TestEndpointAdaptor.ts +130 -0
  292. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +553 -0
  293. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +927 -0
  294. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +721 -0
  295. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +296 -0
  296. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +441 -0
  297. package/src/endpoints/__tests__/Endpoint.spec.ts +800 -0
  298. package/src/endpoints/__tests__/EndpointBuilder.spec.ts +488 -0
  299. package/src/endpoints/__tests__/EndpointFactory.spec.ts +479 -0
  300. package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +569 -0
  301. package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +313 -0
  302. package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +1078 -0
  303. package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +236 -0
  304. package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +54 -0
  305. package/src/endpoints/__tests__/endpoint-types.test.ts +88 -0
  306. package/src/endpoints/helpers.ts +99 -0
  307. package/src/endpoints/index.ts +5 -0
  308. package/src/endpoints/parseHonoQuery.ts +51 -0
  309. package/src/endpoints/parseQueryParams.ts +51 -0
  310. package/src/functions/AWSLambdaFunction.ts +222 -0
  311. package/src/functions/BaseFunctionBuilder.ts +110 -0
  312. package/src/functions/Function.ts +160 -0
  313. package/src/functions/FunctionBuilder.ts +182 -0
  314. package/src/functions/FunctionExecutionWrapper.ts +86 -0
  315. package/src/functions/TestFunctionAdaptor.ts +125 -0
  316. package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +376 -0
  317. package/src/functions/__tests__/Function.spec.ts +402 -0
  318. package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +398 -0
  319. package/src/functions/index.ts +10 -0
  320. package/src/index.ts +14 -0
  321. package/src/publisher.ts +83 -0
  322. package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +269 -0
  323. package/src/subscribers/Subscriber.ts +112 -0
  324. package/src/subscribers/SubscriberBuilder.ts +150 -0
  325. package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +623 -0
  326. package/src/subscribers/__tests__/Subscriber.spec.ts +432 -0
  327. package/src/subscribers/index.ts +5 -0
  328. package/src/types.ts +13 -0
  329. package/tsdown.config.ts +3 -0
@@ -0,0 +1,771 @@
1
+ import type { Logger } from '@geekmidas/logger';
2
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
3
+ import pick from 'lodash.pick';
4
+ import set from 'lodash.set';
5
+ import type { OpenAPIV3_1 } from 'openapi-types';
6
+
7
+ import type { Service, ServiceRecord } from '@geekmidas/services';
8
+ import { ConstructType } from '../Construct';
9
+ import {
10
+ Function,
11
+ type FunctionContext,
12
+ type FunctionHandler,
13
+ } from '../functions';
14
+
15
+ import type {
16
+ EventPublisher,
17
+ ExtractPublisherMessage,
18
+ MappedEvent,
19
+ } from '@geekmidas/events';
20
+ import type { RateLimitConfig } from '@geekmidas/rate-limit';
21
+ import type {
22
+ InferComposableStandardSchema,
23
+ InferStandardSchema,
24
+ } from '@geekmidas/schema';
25
+ import {
26
+ convertSchemaWithComponents,
27
+ convertStandardSchemaToJsonSchema,
28
+ } from '@geekmidas/schema/conversion';
29
+ import {
30
+ type ComponentCollector,
31
+ type OpenApiSchemaOptions,
32
+ buildOpenApiSchema,
33
+ } from '@geekmidas/schema/openapi';
34
+ import type { HttpMethod, LowerHttpMethod, RemoveUndefined } from '../types';
35
+
36
+ /**
37
+ * Represents an HTTP endpoint that can handle requests with type-safe input/output validation,
38
+ * dependency injection, session management, and authorization.
39
+ *
40
+ * @template TRoute - The route path string with parameter placeholders (e.g., '/users/:id')
41
+ * @template TMethod - The HTTP method (GET, POST, PUT, DELETE, PATCH)
42
+ * @template TInput - The input schema definition for body, query, and path parameters
43
+ * @template OutSchema - The output schema for response validation
44
+ * @template TServices - Array of service dependencies to inject
45
+ * @template TLogger - The logger instance type
46
+ * @template TSession - The session data type
47
+ *
48
+ * @extends Function - Base function construct for handler execution
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const endpoint = new Endpoint({
53
+ * route: '/users/:id',
54
+ * method: 'GET',
55
+ * input: { params: userIdSchema },
56
+ * output: userSchema,
57
+ * fn: async ({ params }) => getUserById(params.id)
58
+ * });
59
+ * ```
60
+ */
61
+ export class Endpoint<
62
+ TRoute extends string,
63
+ TMethod extends HttpMethod,
64
+ TInput extends EndpointSchemas = {},
65
+ OutSchema extends StandardSchemaV1 | undefined = undefined,
66
+ TServices extends Service[] = [],
67
+ TLogger extends Logger = Logger,
68
+ TSession = unknown,
69
+ TEventPublisher extends EventPublisher<any> | undefined = undefined,
70
+ TEventPublisherServiceName extends string = string,
71
+ > extends Function<
72
+ TInput,
73
+ TServices,
74
+ TLogger,
75
+ OutSchema,
76
+ FunctionHandler<TInput, TServices, TLogger, OutSchema>,
77
+ TEventPublisher,
78
+ TEventPublisherServiceName
79
+ > {
80
+ operationId?: string;
81
+ /** The route path pattern with parameter placeholders */
82
+ route: TRoute;
83
+ /** The HTTP method for this endpoint */
84
+ method: TMethod;
85
+ /** Optional description for OpenAPI documentation */
86
+ description?: string;
87
+ /** Optional tags for OpenAPI documentation */
88
+ tags?: string[];
89
+ /** The HTTP success status code to return (default: 200) */
90
+ public readonly status: SuccessStatus;
91
+ /** Function to extract session data from the request context */
92
+ public getSession: SessionFn<TServices, TLogger, TSession> = () =>
93
+ ({}) as TSession;
94
+ /** Function to determine if the request is authorized */
95
+ public authorize: AuthorizeFn<TServices, TLogger, TSession> = () => true;
96
+ /** Optional rate limiting configuration */
97
+ public rateLimit?: RateLimitConfig;
98
+
99
+ /**
100
+ * Builds a complete OpenAPI 3.1 schema from an array of endpoints.
101
+ *
102
+ * @param endpoints - Array of endpoint instances to document
103
+ * @param options - Optional configuration for OpenAPI generation
104
+ * @returns OpenAPI 3.1 specification object
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const schema = await Endpoint.buildOpenApiSchema([
109
+ * getUserEndpoint,
110
+ * createUserEndpoint
111
+ * ], {
112
+ * title: 'User API',
113
+ * version: '1.0.0'
114
+ * });
115
+ * ```
116
+ */
117
+ static async buildOpenApiSchema(
118
+ endpoints: Endpoint<any, any, any, any, any, any>[],
119
+ options?: OpenApiSchemaOptions,
120
+ ) {
121
+ return buildOpenApiSchema(endpoints, options);
122
+ }
123
+
124
+ /**
125
+ * Gets the full path including HTTP method and route.
126
+ * @returns Formatted string like 'GET /users/{id}'
127
+ */
128
+ get fullPath() {
129
+ return `${this.method} ${this._path}` as const;
130
+ }
131
+
132
+ /**
133
+ * Parses and validates input data for a specific input type (body, query, params).
134
+ *
135
+ * @param input - The raw input data to validate
136
+ * @param key - The input type key ('body', 'query', or 'params')
137
+ * @returns The validated input data for the specified key
138
+ * @throws {UnprocessableEntityError} When validation fails
139
+ */
140
+ async parseInput<K extends keyof TInput>(
141
+ input: unknown,
142
+ key: K,
143
+ ): Promise<InferComposableStandardSchema<TInput[K]>> {
144
+ const schema = this.input?.[key];
145
+ return Endpoint.parseSchema(schema as StandardSchemaV1, input) as Promise<
146
+ InferComposableStandardSchema<TInput[K]>
147
+ >;
148
+ }
149
+
150
+ /**
151
+ * Parses and validates the request body against the body schema.
152
+ *
153
+ * @param body - The raw request body to validate
154
+ * @returns The validated body data
155
+ * @throws {UnprocessableEntityError} When body validation fails
156
+ */
157
+ async parseBody(body: unknown): Promise<InferStandardSchema<TInput['body']>> {
158
+ return this.parseInput(body, 'body') as Promise<
159
+ InferStandardSchema<TInput['body']>
160
+ >;
161
+ }
162
+
163
+ static isSuccessStatus(status: number): boolean {
164
+ return status >= 200 && status < 300;
165
+ }
166
+
167
+ /**
168
+ * Creates a case-insensitive header lookup function from a headers object.
169
+ *
170
+ * @param headers - Object containing header key-value pairs
171
+ * @returns Function to retrieve header values by case-insensitive key
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const headerFn = Endpoint.createHeaders({ 'Content-Type': 'application/json' });
176
+ * headerFn('content-type'); // Returns 'application/json'
177
+ * ```
178
+ */
179
+ static createHeaders(headers: Record<string, string>): HeaderFn {
180
+ const headerMap = new Map<string, string>();
181
+ for (const [k, v] of Object.entries(headers)) {
182
+ const key = k.toLowerCase();
183
+ headerMap.set(key, v);
184
+ }
185
+
186
+ return function get(key: string): string | undefined {
187
+ return headerMap.get(key.toLowerCase());
188
+ };
189
+ }
190
+
191
+ /**
192
+ * Extracts and refines input data from the endpoint context.
193
+ *
194
+ * @param ctx - The endpoint execution context
195
+ * @returns Object containing only the input data (body, query, params)
196
+ * @internal
197
+ */
198
+ refineInput(
199
+ ctx: EndpointContext<TInput, TServices, TLogger, TSession>,
200
+ ): InferComposableStandardSchema<TInput> {
201
+ const input = pick(ctx, [
202
+ 'body',
203
+ 'query',
204
+ 'params',
205
+ ]) as InferComposableStandardSchema<TInput>;
206
+
207
+ return input;
208
+ }
209
+
210
+ handler: EndpointHandler<TInput, TServices, TLogger, OutSchema, TSession> = (
211
+ ctx: EndpointContext<TInput, TServices, TLogger, TSession>,
212
+ ): OutSchema extends StandardSchemaV1
213
+ ? InferStandardSchema<OutSchema> | Promise<InferStandardSchema<OutSchema>>
214
+ : void | Promise<void> => {
215
+ return this.fn({
216
+ ...this.refineInput(ctx),
217
+ services: ctx.services,
218
+ logger: ctx.logger,
219
+ header: ctx.header,
220
+ session: ctx.session,
221
+ } as unknown as FunctionContext<TInput, TServices, TLogger>);
222
+ };
223
+
224
+ /**
225
+ * Type guard to check if an object is an Endpoint instance.
226
+ *
227
+ * @param obj - The object to check
228
+ * @returns True if the object is an Endpoint
229
+ */
230
+ static isEndpoint(obj: any): obj is Endpoint<any, any, any, any> {
231
+ return Boolean(
232
+ obj &&
233
+ (obj as Function).__IS_FUNCTION__ === true &&
234
+ obj.type === ConstructType.Endpoint,
235
+ );
236
+ }
237
+
238
+ /**
239
+ * Converts Express-style route params to OpenAPI format.
240
+ * @returns Route with ':param' converted to '{param}'
241
+ * @internal
242
+ */
243
+ get _path() {
244
+ return this.route.replace(/:(\w+)/g, '{$1}') as ConvertRouteParams<TRoute>;
245
+ }
246
+
247
+ /**
248
+ * Generates OpenAPI 3.1 schema for this endpoint.
249
+ *
250
+ * @returns OpenAPI route definition with operation details
251
+ */
252
+ async toOpenApi3Route(
253
+ componentCollector?: ComponentCollector,
254
+ ): Promise<EndpointOpenApiSchema<TRoute, TMethod>> {
255
+ const operation: OpenAPIV3_1.OperationObject = {
256
+ operationId: this.operationId,
257
+ ...(this.description && { description: this.description }),
258
+ ...(this.tags && this.tags.length > 0 && { tags: this.tags }),
259
+ responses: {
260
+ '200': {
261
+ description: 'Successful response',
262
+ } as OpenAPIV3_1.ResponseObject,
263
+ },
264
+ };
265
+
266
+ // Add response schema
267
+ if (this.outputSchema) {
268
+ const responseSchema = await convertSchemaWithComponents(
269
+ this.outputSchema,
270
+ componentCollector,
271
+ );
272
+ if (responseSchema) {
273
+ set(
274
+ operation,
275
+ ['responses', '200', 'content', 'application/json', 'schema'],
276
+ responseSchema,
277
+ );
278
+ }
279
+ }
280
+
281
+ // Separate path and query parameters
282
+ const pathParameters: OpenAPIV3_1.ParameterObject[] = [];
283
+ const queryParameters: OpenAPIV3_1.ParameterObject[] = [];
284
+
285
+ // Since the EndpointBuilder doesn't have body/search/params methods yet,
286
+ // and the input is a composite type, we need to check if input exists
287
+ // and has the expected shape
288
+ if (this.input && typeof this.input === 'object') {
289
+ // Add request body for methods that support it
290
+ if (
291
+ ['POST', 'PUT', 'PATCH'].includes(this.method) &&
292
+ 'body' in this.input &&
293
+ this.input.body
294
+ ) {
295
+ const bodySchema = await convertSchemaWithComponents(
296
+ this.input.body as StandardSchemaV1,
297
+ componentCollector,
298
+ );
299
+ if (bodySchema) {
300
+ set(operation, ['requestBody'], {
301
+ required: true,
302
+ content: {
303
+ 'application/json': {
304
+ schema: bodySchema,
305
+ },
306
+ },
307
+ });
308
+ }
309
+ }
310
+
311
+ // Add path parameters
312
+ if ('params' in this.input && this.input.params) {
313
+ const paramsSchema = await convertStandardSchemaToJsonSchema(
314
+ this.input.params as StandardSchemaV1,
315
+ );
316
+ if (
317
+ paramsSchema &&
318
+ paramsSchema.type === 'object' &&
319
+ paramsSchema.properties
320
+ ) {
321
+ for (const [name, schema] of Object.entries(
322
+ paramsSchema.properties,
323
+ )) {
324
+ pathParameters.push({
325
+ name,
326
+ in: 'path',
327
+ required: paramsSchema.required?.includes(name) ?? true,
328
+ schema: schema as any,
329
+ });
330
+ }
331
+ }
332
+ }
333
+
334
+ // Add query parameters
335
+ if ('query' in this.input && this.input.query) {
336
+ const querySchema = await convertStandardSchemaToJsonSchema(
337
+ this.input.query,
338
+ );
339
+ if (
340
+ querySchema &&
341
+ querySchema.type === 'object' &&
342
+ querySchema.properties
343
+ ) {
344
+ for (const [name, schema] of Object.entries(querySchema.properties)) {
345
+ queryParameters.push({
346
+ name,
347
+ in: 'query',
348
+ required: querySchema.required?.includes(name) ?? false,
349
+ schema: schema as any,
350
+ });
351
+ }
352
+ }
353
+ }
354
+ }
355
+
356
+ // Only add query parameters to the operation
357
+ if (queryParameters.length > 0) {
358
+ operation.parameters = queryParameters;
359
+ }
360
+
361
+ // Build the route object with path parameters at the route level
362
+ const routeObject: any = {};
363
+ if (pathParameters.length > 0) {
364
+ routeObject.parameters = pathParameters;
365
+ }
366
+ routeObject[this.method.toLowerCase()] = operation;
367
+
368
+ return {
369
+ [this._path]: routeObject,
370
+ } as EndpointOpenApiSchema<TRoute, TMethod>;
371
+ }
372
+
373
+ /**
374
+ * Creates a new Endpoint instance.
375
+ *
376
+ * @param options - Configuration options for the endpoint
377
+ * @param options.fn - The handler function to execute
378
+ * @param options.method - HTTP method
379
+ * @param options.route - Route path with parameter placeholders
380
+ * @param options.description - Optional description for documentation
381
+ * @param options.input - Input schemas for validation
382
+ * @param options.logger - Logger instance
383
+ * @param options.output - Output schema for response validation
384
+ * @param options.services - Service dependencies
385
+ * @param options.timeout - Execution timeout in milliseconds
386
+ * @param options.getSession - Session extraction function
387
+ * @param options.authorize - Authorization check function
388
+ * @param options.status - Success HTTP status code (default: 200)
389
+ */
390
+ constructor({
391
+ fn,
392
+ method,
393
+ route,
394
+ description,
395
+ tags,
396
+ input,
397
+ logger,
398
+ output: outputSchema,
399
+ services,
400
+ timeout,
401
+ getSession,
402
+ authorize,
403
+ rateLimit,
404
+ status = SuccessStatus.OK,
405
+ publisherService,
406
+ events,
407
+ }: EndpointOptions<
408
+ TRoute,
409
+ TMethod,
410
+ TInput,
411
+ OutSchema,
412
+ TServices,
413
+ TLogger,
414
+ TSession,
415
+ OutSchema,
416
+ TEventPublisher,
417
+ TEventPublisherServiceName
418
+ >) {
419
+ super(
420
+ fn as unknown as FunctionHandler<TInput, TServices, TLogger, OutSchema>,
421
+ timeout,
422
+ ConstructType.Endpoint,
423
+ input,
424
+ outputSchema,
425
+ services,
426
+ logger,
427
+ publisherService,
428
+ events,
429
+ );
430
+
431
+ this.route = route;
432
+ this.method = method;
433
+ this.description = description;
434
+ this.tags = tags;
435
+ this.status = status;
436
+ if (getSession) {
437
+ this.getSession = getSession;
438
+ }
439
+
440
+ if (authorize) {
441
+ this.authorize = authorize;
442
+ }
443
+
444
+ if (rateLimit) {
445
+ this.rateLimit = rateLimit;
446
+ }
447
+ }
448
+ }
449
+
450
+ /**
451
+ * Defines the input schema structure for an endpoint.
452
+ *
453
+ * @template TBody - Schema for request body validation
454
+ * @template TSearch - Schema for query string validation
455
+ * @template TParams - Schema for URL path parameters validation
456
+ *
457
+ * @example
458
+ * ```typescript
459
+ * type UserInput = EndpointInput<
460
+ * typeof createUserBodySchema,
461
+ * typeof userQuerySchema,
462
+ * typeof userParamsSchema
463
+ * >;
464
+ * ```
465
+ */
466
+ export type EndpointInput<
467
+ TBody extends StandardSchemaV1 | undefined = undefined,
468
+ TSearch extends StandardSchemaV1 | undefined = undefined,
469
+ TParams extends StandardSchemaV1 | undefined = undefined,
470
+ > = RemoveUndefined<{
471
+ body: TBody;
472
+ search: TSearch;
473
+ params: TParams;
474
+ }>;
475
+
476
+ /**
477
+ * Configuration options for creating an Endpoint instance.
478
+ *
479
+ * @template TRoute - The route path string
480
+ * @template TMethod - The HTTP method
481
+ * @template TInput - Input schema definitions
482
+ * @template TOutput - Output schema definition
483
+ * @template TServices - Service dependencies array
484
+ * @template TLogger - Logger type
485
+ * @template TSession - Session data type
486
+ */
487
+ export interface EndpointOptions<
488
+ TRoute extends string,
489
+ TMethod extends HttpMethod,
490
+ TInput extends EndpointSchemas = {},
491
+ TOutput extends StandardSchemaV1 | undefined = undefined,
492
+ TServices extends Service[] = [],
493
+ TLogger extends Logger = Logger,
494
+ TSession = unknown,
495
+ OutSchema extends StandardSchemaV1 | undefined = undefined,
496
+ TEventPublisher extends EventPublisher<any> | undefined = undefined,
497
+ TEventPublisherServiceName extends string = string,
498
+ > {
499
+ /** The route path with parameter placeholders */
500
+ route: TRoute;
501
+ /** The HTTP method for this endpoint */
502
+ method: TMethod;
503
+ /** The handler function that implements the endpoint logic */
504
+ fn: EndpointHandler<TInput, TServices, TLogger, TOutput, TSession>;
505
+ /** Optional authorization check function */
506
+ authorize: AuthorizeFn<TServices, TLogger, TSession> | undefined;
507
+ /** Optional description for documentation */
508
+ description: string | undefined;
509
+ /** Optional tags for OpenAPI documentation */
510
+ tags?: string[];
511
+ /** Optional execution timeout in milliseconds */
512
+ timeout: number | undefined;
513
+ /** Input validation schemas */
514
+ input: TInput | undefined;
515
+ /** Output validation schema */
516
+ output: TOutput | undefined;
517
+ /** Service dependencies to inject */
518
+ services: TServices;
519
+ /** Logger instance */
520
+ logger: TLogger;
521
+ /** Optional session extraction function */
522
+ getSession: SessionFn<TServices, TLogger, TSession> | undefined;
523
+ /** Optional rate limiting configuration */
524
+ rateLimit?: RateLimitConfig;
525
+ /** Success HTTP status code */
526
+ status: SuccessStatus | undefined;
527
+ /**
528
+ * Event publisher service for publishing events from this endpoint
529
+ */
530
+ publisherService?: Service<TEventPublisherServiceName, TEventPublisher>;
531
+
532
+ events?: MappedEvent<TEventPublisher, OutSchema>[];
533
+ }
534
+
535
+ /**
536
+ * Defines the possible input schema types for an endpoint.
537
+ * Each property represents a different part of the HTTP request.
538
+ */
539
+ export type EndpointSchemas = Partial<{
540
+ /** Schema for URL path parameters (e.g., /users/:id) */
541
+ params: StandardSchemaV1;
542
+ /** Schema for query string parameters */
543
+ query: StandardSchemaV1;
544
+ /** Schema for request body (POST, PUT, PATCH) */
545
+ body: StandardSchemaV1;
546
+ }>;
547
+
548
+ export type AuthorizeContext<
549
+ TServices extends Service[] = [],
550
+ TLogger extends Logger = Logger,
551
+ TSession = unknown,
552
+ > = {
553
+ services: ServiceRecord<TServices>;
554
+ logger: TLogger;
555
+ header: HeaderFn;
556
+ session: TSession;
557
+ };
558
+ /**
559
+ * Function type for endpoint authorization checks.
560
+ *
561
+ * @template TServices - Available service dependencies
562
+ * @template TLogger - Logger type
563
+ * @template TSession - Session data type
564
+ *
565
+ * @param ctx - Context containing services, logger, headers, and session
566
+ * @returns Boolean indicating if the request is authorized
567
+ *
568
+ * @example
569
+ * ```typescript
570
+ * const authorize: AuthorizeFn = ({ session }) => {
571
+ * return session.userId !== undefined;
572
+ * };
573
+ * ```
574
+ */
575
+ export type AuthorizeFn<
576
+ TServices extends Service[] = [],
577
+ TLogger extends Logger = Logger,
578
+ TSession = unknown,
579
+ > = (
580
+ ctx: AuthorizeContext<TServices, TLogger, TSession>,
581
+ ) => Promise<boolean> | boolean;
582
+
583
+ export type SessionContext<
584
+ TServices extends Service[] = [],
585
+ TLogger extends Logger = Logger,
586
+ > = {
587
+ services: ServiceRecord<TServices>;
588
+ logger: TLogger;
589
+ header: HeaderFn;
590
+ };
591
+ /**
592
+ * Function type for extracting session data from a request.
593
+ *
594
+ * @template TServices - Available service dependencies
595
+ * @template TLogger - Logger type
596
+ * @template TSession - Session data type to extract
597
+ *
598
+ * @param ctx - Context containing services, logger, and headers
599
+ * @returns The extracted session data
600
+ *
601
+ * @example
602
+ * ```typescript
603
+ * const getSession: SessionFn<Services, Logger, UserSession> = async ({ header, services }) => {
604
+ * const token = header('authorization');
605
+ * return await services.auth.verifyToken(token);
606
+ * };
607
+ * ```
608
+ */
609
+ export type SessionFn<
610
+ TServices extends Service[] = [],
611
+ TLogger extends Logger = Logger,
612
+ TSession = unknown,
613
+ > = (ctx: SessionContext<TServices, TLogger>) => Promise<TSession> | TSession;
614
+
615
+ /**
616
+ * Utility type that converts Express-style route parameters to OpenAPI format.
617
+ * Transforms ':param' syntax to '{param}' syntax.
618
+ *
619
+ * @template T - The route string to convert
620
+ *
621
+ * @example
622
+ * ```typescript
623
+ * type Route1 = ConvertRouteParams<'/users/:id'>; // '/users/{id}'
624
+ * type Route2 = ConvertRouteParams<'/users/:userId/posts/:postId'>; // '/users/{userId}/posts/{postId}'
625
+ * ```
626
+ */
627
+ export type ConvertRouteParams<T extends string> =
628
+ T extends `${infer Start}:${infer Param}/${infer Rest}`
629
+ ? `${Start}{${Param}}/${ConvertRouteParams<Rest>}`
630
+ : T extends `${infer Start}:${infer Param}`
631
+ ? `${Start}{${Param}}`
632
+ : T;
633
+
634
+ /**
635
+ * Type representing the OpenAPI schema structure for an endpoint.
636
+ *
637
+ * @template TRoute - The route path
638
+ * @template TMethod - The HTTP method
639
+ *
640
+ * @example
641
+ * ```typescript
642
+ * type Schema = EndpointOpenApiSchema<'/users/:id', 'GET'>;
643
+ * // Results in: { '/users/{id}': { get: OperationObject, parameters?: ParameterObject[] } }
644
+ * ```
645
+ */
646
+ export type EndpointOpenApiSchema<
647
+ TRoute extends string,
648
+ TMethod extends HttpMethod,
649
+ > = {
650
+ [key in ConvertRouteParams<TRoute>]: {
651
+ [key in LowerHttpMethod<TMethod>]: OpenAPIV3_1.OperationObject<{}>;
652
+ } & {
653
+ parameters?: OpenAPIV3_1.ParameterObject[];
654
+ };
655
+ };
656
+
657
+ export type SingleHeaderFn = (key: string) => string | undefined;
658
+ export type MultiHeaderFn = () => EndpointHeaders;
659
+ /**
660
+ * Type representing HTTP headers as a Map.
661
+ */
662
+ export type EndpointHeaders = Map<string, string>;
663
+
664
+ /**
665
+ * Function type for retrieving HTTP header values.
666
+ *
667
+ * @param key - The header name (case-insensitive)
668
+ * @returns The header value or undefined if not found
669
+ */
670
+ export type HeaderFn = SingleHeaderFn;
671
+
672
+ /**
673
+ * The execution context provided to endpoint handlers.
674
+ * Contains all parsed input data, services, logger, headers, and session.
675
+ *
676
+ * @template Input - The input schemas (body, query, params)
677
+ * @template TServices - Available service dependencies
678
+ * @template TLogger - Logger type
679
+ * @template TSession - Session data type
680
+ */
681
+ export type EndpointContext<
682
+ Input extends EndpointSchemas | undefined = undefined,
683
+ TServices extends Service[] = [],
684
+ TLogger extends Logger = Logger,
685
+ TSession = unknown,
686
+ > = {
687
+ /** Injected service instances */
688
+ services: ServiceRecord<TServices>;
689
+ /** Logger instance for this request */
690
+ logger: TLogger;
691
+ /** Function to retrieve request headers */
692
+ header: HeaderFn;
693
+ /** Session data extracted by getSession */
694
+ session: TSession;
695
+ } & InferComposableStandardSchema<Input>;
696
+
697
+ /**
698
+ * Handler function type for endpoint implementations.
699
+ *
700
+ * @template TInput - Input schemas for validation
701
+ * @template TServices - Available service dependencies
702
+ * @template TLogger - Logger type
703
+ * @template OutSchema - Output schema for response validation
704
+ * @template TSession - Session data type
705
+ *
706
+ * @param ctx - The endpoint execution context
707
+ * @returns The response data (validated if OutSchema is provided)
708
+ *
709
+ * @example
710
+ * ```typescript
711
+ * const handler: EndpointHandler<Input, [UserService], Logger, UserSchema> =
712
+ * async ({ params, services }) => {
713
+ * return await services.users.findById(params.id);
714
+ * };
715
+ * ```
716
+ */
717
+ export type EndpointHandler<
718
+ TInput extends EndpointSchemas | undefined = undefined,
719
+ TServices extends Service[] = [],
720
+ TLogger extends Logger = Logger,
721
+ OutSchema extends StandardSchemaV1 | undefined = undefined,
722
+ TSession = unknown,
723
+ > = (
724
+ ctx: EndpointContext<TInput, TServices, TLogger, TSession>,
725
+ ) => OutSchema extends StandardSchemaV1
726
+ ? InferStandardSchema<OutSchema> | Promise<InferStandardSchema<OutSchema>>
727
+ : any | Promise<any>;
728
+
729
+ /**
730
+ * HTTP success status codes that can be returned by endpoints.
731
+ */
732
+ export enum SuccessStatus {
733
+ /** Standard response for successful HTTP requests */
734
+ OK = 200,
735
+ /** Request has been fulfilled and resulted in a new resource being created */
736
+ Created = 201,
737
+ /** Request has been accepted for processing, but processing is not complete */
738
+ Accepted = 202,
739
+ /** Server successfully processed the request but is not returning any content */
740
+ NoContent = 204,
741
+ /** Server successfully processed the request and is not returning any content, client should reset the document view */
742
+ ResetContent = 205,
743
+ /** Server is delivering only part of the resource due to a range header */
744
+ PartialContent = 206,
745
+ }
746
+
747
+ export type EndpointOutput<T> = T extends Endpoint<
748
+ any,
749
+ any,
750
+ any,
751
+ infer OutSchema,
752
+ any,
753
+ any,
754
+ any,
755
+ any
756
+ >
757
+ ? InferStandardSchema<OutSchema>
758
+ : never;
759
+
760
+ export type EndpointEvent<T> = T extends Endpoint<
761
+ any,
762
+ any,
763
+ any,
764
+ any,
765
+ any,
766
+ any,
767
+ any,
768
+ infer TEventPublisher
769
+ >
770
+ ? ExtractPublisherMessage<TEventPublisher>
771
+ : never;