@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,236 @@
1
+ import { UnprocessableEntityError } from '@geekmidas/errors';
2
+ import { ConsoleLogger } from '@geekmidas/logger/console';
3
+ import { describe, expect, it, vi } from 'vitest';
4
+ import { z } from 'zod';
5
+ import { e } from '../EndpointFactory';
6
+ import { TestEndpointAdaptor } from '../TestEndpointAdaptor';
7
+
8
+ describe('TestEndpointAdaptor', () => {
9
+ const mockServices = {};
10
+ const logger = new ConsoleLogger();
11
+
12
+ describe('request', () => {
13
+ it('should handle simple endpoint without schemas', async () => {
14
+ const endpoint = e
15
+ .get('/test')
16
+ .output(z.object({ message: z.string() }))
17
+ .handle(() => ({ message: 'Hello World' }));
18
+
19
+ const adapter = new TestEndpointAdaptor(endpoint);
20
+
21
+ const result = await adapter.request({
22
+ services: mockServices,
23
+ headers: { host: 'example.com' },
24
+ });
25
+
26
+ expect(result).toEqual({ message: 'Hello World' });
27
+ });
28
+
29
+ it('should handle endpoint with body schema', async () => {
30
+ const endpoint = e
31
+ .post('/users')
32
+ .body(z.object({ name: z.string(), email: z.string().email() }))
33
+ .output(z.object({ id: z.string(), name: z.string() }))
34
+ .handle(async ({ body }) => ({
35
+ id: 'user-123',
36
+ name: body.name,
37
+ }));
38
+
39
+ const adapter = new TestEndpointAdaptor(endpoint);
40
+
41
+ const result = await adapter.request({
42
+ body: { name: 'John Doe', email: 'john@example.com' },
43
+ services: mockServices,
44
+ headers: { host: 'example.com', 'content-type': 'application/json' },
45
+ });
46
+
47
+ expect(result).toEqual({ id: 'user-123', name: 'John Doe' });
48
+ });
49
+
50
+ it('should handle endpoint with params schema', async () => {
51
+ const endpoint = e
52
+ .get('/users/:id')
53
+ .params(z.object({ id: z.string() }))
54
+ .output(z.object({ id: z.string(), found: z.boolean() }))
55
+ .handle(async ({ params }) => ({
56
+ id: params.id,
57
+ found: true,
58
+ }));
59
+
60
+ const adapter = new TestEndpointAdaptor(endpoint);
61
+
62
+ const result = await adapter.request({
63
+ params: { id: 'user-456' },
64
+ services: mockServices,
65
+ headers: { host: 'example.com' },
66
+ });
67
+
68
+ expect(result).toEqual({ id: 'user-456', found: true });
69
+ });
70
+
71
+ it('should handle endpoint with query schema', async () => {
72
+ const endpoint = e
73
+ .get('/search')
74
+ .query(z.object({ q: z.string(), page: z.coerce.number().default(1) }))
75
+ .output(z.object({ query: z.string(), page: z.number() }))
76
+ .handle(async ({ query }) => ({
77
+ query: query.q,
78
+ page: query.page,
79
+ }));
80
+
81
+ const adapter = new TestEndpointAdaptor(endpoint);
82
+
83
+ const result = await adapter.request({
84
+ query: { q: 'test search', page: 2 },
85
+ services: mockServices,
86
+ headers: { host: 'example.com' },
87
+ });
88
+
89
+ expect(result).toEqual({ query: 'test search', page: 2 });
90
+ });
91
+
92
+ it('should handle endpoint with all schemas', async () => {
93
+ const endpoint = e
94
+ .put('/users/:id')
95
+ .params(z.object({ id: z.string() }))
96
+ .body(z.object({ name: z.string(), email: z.string().email() }))
97
+ .query(z.object({ notify: z.coerce.boolean().default(false) }))
98
+ .output(
99
+ z.object({
100
+ id: z.string(),
101
+ updated: z.boolean(),
102
+ notified: z.boolean(),
103
+ }),
104
+ )
105
+ .handle(async ({ params, body, query }) => ({
106
+ id: params.id,
107
+ updated: true,
108
+ notified: query.notify,
109
+ }));
110
+
111
+ const adapter = new TestEndpointAdaptor(endpoint);
112
+
113
+ const result = await adapter.request({
114
+ body: { name: 'Jane Doe', email: 'jane@example.com' },
115
+ query: { notify: true },
116
+ params: { id: 'user-789' },
117
+ services: mockServices,
118
+ headers: { host: 'example.com' },
119
+ });
120
+
121
+ expect(result).toEqual({
122
+ id: 'user-789',
123
+ updated: true,
124
+ notified: true,
125
+ });
126
+ });
127
+
128
+ it('should throw validation error for invalid body', async () => {
129
+ const endpoint = e
130
+ .post('/users')
131
+ .body(z.object({ name: z.string(), age: z.number().min(18) }))
132
+ .handle(async ({ body }) => ({ id: '123' }));
133
+
134
+ const adapter = new TestEndpointAdaptor(endpoint);
135
+
136
+ await expect(
137
+ adapter.request({
138
+ body: { name: 'John', age: 15 },
139
+ services: mockServices,
140
+ headers: { host: 'example.com' },
141
+ }),
142
+ ).rejects.toThrow(UnprocessableEntityError);
143
+ });
144
+
145
+ it('should handle headers correctly', async () => {
146
+ const endpoint = e
147
+ .get('/headers')
148
+ .output(z.object({ auth: z.string().optional(), host: z.string() }))
149
+ .handle(async ({ header }) => ({
150
+ auth: header('authorization'),
151
+ host: header('host') || 'unknown',
152
+ }));
153
+
154
+ const adapter = new TestEndpointAdaptor(endpoint);
155
+
156
+ const result = await adapter.request({
157
+ services: mockServices,
158
+ headers: {
159
+ host: 'api.example.com',
160
+ authorization: 'Bearer token123',
161
+ 'Content-Type': 'application/json',
162
+ },
163
+ });
164
+
165
+ expect(result).toEqual({
166
+ auth: 'Bearer token123',
167
+ host: 'api.example.com',
168
+ });
169
+ });
170
+
171
+ it('should handle session correctly', async () => {
172
+ const endpoint = e
173
+ .get('/profile')
174
+ .output(z.object({ userId: z.string() }))
175
+ .handle(async ({ session }) => ({
176
+ userId: (session as any).userId,
177
+ }));
178
+
179
+ // Mock getSession
180
+ endpoint.getSession = vi.fn().mockResolvedValue({ userId: 'user-123' });
181
+
182
+ const adapter = new TestEndpointAdaptor(endpoint);
183
+
184
+ const result = await adapter.request({
185
+ services: mockServices,
186
+ headers: { host: 'example.com' },
187
+ });
188
+
189
+ expect(result).toEqual({ userId: 'user-123' });
190
+ expect(endpoint.getSession).toHaveBeenCalledWith({
191
+ logger: expect.any(ConsoleLogger),
192
+ services: mockServices,
193
+ header: expect.any(Function),
194
+ });
195
+ });
196
+
197
+ it('should validate output schema', async () => {
198
+ const endpoint = e
199
+ .get('/invalid')
200
+ .output(z.object({ id: z.string(), count: z.number() }))
201
+ .handle(() => ({ id: '123', count: 'not-a-number' as any }));
202
+
203
+ const adapter = new TestEndpointAdaptor(endpoint);
204
+
205
+ await expect(
206
+ adapter.request({
207
+ services: mockServices,
208
+ headers: { host: 'example.com' },
209
+ }),
210
+ ).rejects.toThrow(UnprocessableEntityError);
211
+ });
212
+
213
+ it('should handle case-insensitive headers', async () => {
214
+ const endpoint = e
215
+ .get('/headers-case')
216
+ .output(z.object({ contentType: z.string().optional() }))
217
+ .handle(async ({ header }) => ({
218
+ contentType: header('CONTENT-TYPE'),
219
+ }));
220
+
221
+ const adapter = new TestEndpointAdaptor(endpoint);
222
+
223
+ const result = await adapter.request({
224
+ services: mockServices,
225
+ headers: {
226
+ host: 'example.com',
227
+ 'content-type': 'application/json',
228
+ },
229
+ });
230
+
231
+ expect(result).toEqual({
232
+ contentType: 'application/json',
233
+ });
234
+ });
235
+ });
236
+ });
@@ -0,0 +1,54 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`HonoEndpointAdaptor > addRoute > should return 422 for invalid body 1`] = `
4
+ [
5
+ {
6
+ "code": "too_small",
7
+ "inclusive": true,
8
+ "message": "Too small: expected string to have >=3 characters",
9
+ "minimum": 3,
10
+ "origin": "string",
11
+ "path": [
12
+ "name",
13
+ ],
14
+ },
15
+ {
16
+ "code": "invalid_type",
17
+ "expected": "number",
18
+ "message": "Invalid input: expected number, received string",
19
+ "path": [
20
+ "age",
21
+ ],
22
+ },
23
+ ]
24
+ `;
25
+
26
+ exports[`HonoEndpointAdaptor > addRoute > should return 422 for invalid path parameters 1`] = `
27
+ [
28
+ {
29
+ "code": "invalid_format",
30
+ "format": "uuid",
31
+ "message": "Invalid UUID",
32
+ "origin": "string",
33
+ "path": [
34
+ "id",
35
+ ],
36
+ "pattern": "/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/",
37
+ },
38
+ ]
39
+ `;
40
+
41
+ exports[`HonoEndpointAdaptor > addRoute > should return 422 for invalid query parameters 1`] = `
42
+ [
43
+ {
44
+ "code": "invalid_format",
45
+ "format": "regex",
46
+ "message": "Invalid string: must match pattern /^\\d+$/",
47
+ "origin": "string",
48
+ "path": [
49
+ "page",
50
+ ],
51
+ "pattern": "/^\\d+$/",
52
+ },
53
+ ]
54
+ `;
@@ -0,0 +1,88 @@
1
+ import { describe, expectTypeOf, it } from 'vitest';
2
+ import { z } from 'zod';
3
+ import { e } from '../EndpointFactory';
4
+
5
+ describe('Endpoint type inference', () => {
6
+ it('should not include body/params/query when not defined', () => {
7
+ const endpoint = e.get('/test').handle((ctx) => {
8
+ expectTypeOf(ctx).toHaveProperty('services');
9
+ expectTypeOf(ctx).toHaveProperty('logger');
10
+ expectTypeOf(ctx).toHaveProperty('header');
11
+ expectTypeOf(ctx).toHaveProperty('session');
12
+
13
+ // These should NOT exist
14
+ expectTypeOf(ctx).not.toHaveProperty('body');
15
+ expectTypeOf(ctx).not.toHaveProperty('params');
16
+ expectTypeOf(ctx).not.toHaveProperty('query');
17
+
18
+ return { success: true };
19
+ });
20
+ });
21
+
22
+ it('should include body when defined', () => {
23
+ const endpoint = e
24
+ .post('/test')
25
+ .body(z.object({ name: z.string() }))
26
+ .handle((ctx) => {
27
+ expectTypeOf(ctx).toHaveProperty('body');
28
+ expectTypeOf(ctx.body).toEqualTypeOf<{ name: string }>();
29
+
30
+ // These should NOT exist
31
+ expectTypeOf(ctx).not.toHaveProperty('params');
32
+ expectTypeOf(ctx).not.toHaveProperty('query');
33
+
34
+ return { success: true };
35
+ });
36
+ });
37
+
38
+ it('should include params when defined', () => {
39
+ const endpoint = e
40
+ .get('/test/:id')
41
+ .params(z.object({ id: z.string() }))
42
+ .handle((ctx) => {
43
+ expectTypeOf(ctx).toHaveProperty('params');
44
+ expectTypeOf(ctx.params).toEqualTypeOf<{ id: string }>();
45
+
46
+ // These should NOT exist
47
+ expectTypeOf(ctx).not.toHaveProperty('body');
48
+ expectTypeOf(ctx).not.toHaveProperty('query');
49
+
50
+ return { success: true };
51
+ });
52
+ });
53
+
54
+ it('should include query when defined', () => {
55
+ const endpoint = e
56
+ .get('/test')
57
+ .query(z.object({ filter: z.string() }))
58
+ .handle((ctx) => {
59
+ expectTypeOf(ctx).toHaveProperty('query');
60
+ expectTypeOf(ctx.query).toEqualTypeOf<{ filter: string }>();
61
+
62
+ // These should NOT exist
63
+ expectTypeOf(ctx).not.toHaveProperty('body');
64
+ expectTypeOf(ctx).not.toHaveProperty('params');
65
+
66
+ return { success: true };
67
+ });
68
+ });
69
+
70
+ it('should include all properties when all are defined', () => {
71
+ const endpoint = e
72
+ .post('/test/:id')
73
+ .body(z.object({ name: z.string() }))
74
+ .params(z.object({ id: z.string() }))
75
+ .query(z.object({ filter: z.string() }))
76
+ .handle((ctx) => {
77
+ expectTypeOf(ctx).toHaveProperty('body');
78
+ expectTypeOf(ctx).toHaveProperty('params');
79
+ expectTypeOf(ctx).toHaveProperty('query');
80
+
81
+ expectTypeOf(ctx.body).toEqualTypeOf<{ name: string }>();
82
+ expectTypeOf(ctx.params).toEqualTypeOf<{ id: string }>();
83
+ expectTypeOf(ctx.query).toEqualTypeOf<{ filter: string }>();
84
+
85
+ return { success: true };
86
+ });
87
+ });
88
+ });
@@ -0,0 +1,99 @@
1
+ import path from 'node:path';
2
+ import fg from 'fast-glob';
3
+ import { Endpoint } from './Endpoint';
4
+
5
+ import type { Service } from '@geekmidas/services';
6
+ import type { HttpMethod } from '../types';
7
+
8
+ // Re-export utility functions
9
+
10
+ /**
11
+ * Recursively finds the project root directory by looking for lock files.
12
+ * Traverses up the directory tree until it finds a package manager lock file.
13
+ *
14
+ * @param cwd - The current working directory to start searching from
15
+ * @returns Promise resolving to the absolute path of the project root
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const projectRoot = await getProjectRoot(process.cwd());
20
+ * console.log(`Project root: ${projectRoot}`);
21
+ * // Output: Project root: /Users/user/my-project
22
+ * ```
23
+ */
24
+ export async function getProjectRoot(cwd: string): Promise<string> {
25
+ if (cwd === '/') {
26
+ return cwd;
27
+ }
28
+
29
+ const stream = fg.stream(
30
+ ['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json', 'deno.lock'],
31
+ { dot: true, cwd },
32
+ );
33
+
34
+ let isRoot = false;
35
+
36
+ for await (const _ of stream) {
37
+ isRoot = true;
38
+ break;
39
+ }
40
+
41
+ if (isRoot) {
42
+ return cwd;
43
+ }
44
+
45
+ return getProjectRoot(path.resolve(cwd, '..'));
46
+ }
47
+
48
+ /**
49
+ * Discovers and imports all Endpoint instances from the specified route patterns.
50
+ * Uses fast-glob to find files matching the patterns and extracts exported Endpoints.
51
+ *
52
+ * @template TServices - Array of service types used by the endpoints
53
+ * @param routes - Array of glob patterns to match route files (e.g., ['src/routes/*.ts'])
54
+ * @param cwd - The current working directory to resolve paths from
55
+ * @returns Promise resolving to an array of Endpoint instances found in the matched files
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * // Find all endpoints in the routes directory
60
+ * const endpoints = await getEndpointsFromRoutes(
61
+ * ['src/routes/**\/*.ts'],
62
+ * process.cwd()
63
+ * );
64
+ *
65
+ * // Register endpoints with your server
66
+ * for (const endpoint of endpoints) {
67
+ * server.register(endpoint);
68
+ * }
69
+ * ```
70
+ *
71
+ * @remarks
72
+ * - Only exports that are valid Endpoint instances are included
73
+ * - Files are imported dynamically, so they must be valid ES modules
74
+ * - The function filters out non-Endpoint exports automatically
75
+ */
76
+ export async function getEndpointsFromRoutes<TServices extends Service[]>(
77
+ routes: string[],
78
+ cwd: string,
79
+ ): Promise<Endpoint<string, HttpMethod, any, any, TServices>[]> {
80
+ const stream = fg.stream(routes, { cwd });
81
+
82
+ const endpoints: Endpoint<string, HttpMethod, any, any, TServices>[] = [];
83
+
84
+ for await (const f of stream) {
85
+ // Resolve the absolute path for the route file
86
+ const routePath = path.resolve(cwd, f.toString());
87
+ // Dynamically import the route module
88
+ const route = await import(routePath);
89
+
90
+ // Filter exported values to find only Endpoint instances
91
+ const handlers = Object.values(route).filter((value) => {
92
+ return Endpoint.isEndpoint(value);
93
+ }) as unknown as Endpoint<string, HttpMethod, any, any, TServices>[];
94
+
95
+ endpoints.push(...handlers);
96
+ }
97
+
98
+ return endpoints;
99
+ }
@@ -0,0 +1,5 @@
1
+ import { EndpointFactory } from './EndpointFactory';
2
+
3
+ export { Endpoint, type EndpointOutput } from './Endpoint';
4
+
5
+ export const e = new EndpointFactory();
@@ -0,0 +1,51 @@
1
+ import type { Context } from 'hono';
2
+
3
+ /**
4
+ * Parse Hono query parameters to handle arrays and nested objects
5
+ * Hono provides c.req.queries() for arrays, but we need to handle dot notation for objects
6
+ */
7
+ export function parseHonoQuery(c: Context): Record<string, any> {
8
+ const allParams = c.req.query();
9
+ const result: Record<string, any> = {};
10
+
11
+ // First, handle all query parameters
12
+ for (const [key, value] of Object.entries(allParams)) {
13
+ if (key.includes('.')) {
14
+ // Handle dot notation for objects
15
+ const parts = key.split('.');
16
+ let current = result;
17
+
18
+ // Navigate/create the nested structure
19
+ for (let i = 0; i < parts.length - 1; i++) {
20
+ const part = parts[i];
21
+ if (
22
+ !current[part] ||
23
+ typeof current[part] !== 'object' ||
24
+ Array.isArray(current[part])
25
+ ) {
26
+ current[part] = {};
27
+ }
28
+ current = current[part];
29
+ }
30
+
31
+ // Set the final value, checking for arrays in nested keys
32
+ const lastPart = parts[parts.length - 1];
33
+ const multipleValues = c.req.queries(key);
34
+ if (multipleValues && multipleValues.length > 1) {
35
+ current[lastPart] = multipleValues;
36
+ } else {
37
+ current[lastPart] = value;
38
+ }
39
+ } else {
40
+ // For regular keys, check if there are multiple values
41
+ const multipleValues = c.req.queries(key);
42
+ if (multipleValues && multipleValues.length > 1) {
43
+ result[key] = multipleValues;
44
+ } else {
45
+ result[key] = value;
46
+ }
47
+ }
48
+ }
49
+
50
+ return result;
51
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Parse query parameters from a flat object into a nested structure
3
+ * Handles arrays (multiple values with same key) and objects (dot notation)
4
+ *
5
+ * @example
6
+ * parseQueryParams({ 'tags': ['a', 'b'], 'filter.name': 'john' })
7
+ * // Returns: { tags: ['a', 'b'], filter: { name: 'john' } }
8
+ */
9
+ export function parseQueryParams(
10
+ queryParams: Record<string, string | string[] | undefined> | null,
11
+ ): Record<string, any> {
12
+ if (!queryParams) {
13
+ return {};
14
+ }
15
+
16
+ const result: Record<string, any> = {};
17
+
18
+ for (const [key, value] of Object.entries(queryParams)) {
19
+ if (value === undefined) {
20
+ continue;
21
+ }
22
+
23
+ // Check if the key contains dot notation
24
+ if (key.includes('.')) {
25
+ const parts = key.split('.');
26
+ let current = result;
27
+
28
+ // Navigate/create the nested structure
29
+ for (let i = 0; i < parts.length - 1; i++) {
30
+ const part = parts[i];
31
+ if (
32
+ !current[part] ||
33
+ typeof current[part] !== 'object' ||
34
+ Array.isArray(current[part])
35
+ ) {
36
+ current[part] = {};
37
+ }
38
+ current = current[part];
39
+ }
40
+
41
+ // Set the final value
42
+ const lastPart = parts[parts.length - 1];
43
+ current[lastPart] = value;
44
+ } else {
45
+ // Simple key, just assign the value
46
+ result[key] = value;
47
+ }
48
+ }
49
+
50
+ return result;
51
+ }