@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,308 @@
1
+ import type { Logger } from '@geekmidas/logger';
2
+ import type { RateLimitConfig } from '@geekmidas/rate-limit';
3
+ import type { Service } from '@geekmidas/services';
4
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
5
+ import uniqBy from 'lodash.uniqby';
6
+ import { ConstructType } from '../Construct';
7
+ import { BaseFunctionBuilder } from '../functions';
8
+ import { Endpoint, type EndpointSchemas } from './Endpoint';
9
+ import type {
10
+ AuthorizeFn,
11
+ EndpointHandler,
12
+ SessionFn,
13
+ SuccessStatus,
14
+ } from './Endpoint';
15
+
16
+ import type { EventPublisher, MappedEvent } from '@geekmidas/events';
17
+ import type { HttpMethod } from '../types';
18
+
19
+ export class EndpointBuilder<
20
+ TRoute extends string,
21
+ TMethod extends HttpMethod,
22
+ TInput extends EndpointSchemas = {},
23
+ TServices extends Service[] = [],
24
+ TLogger extends Logger = Logger,
25
+ OutSchema extends StandardSchemaV1 | undefined = undefined,
26
+ TSession = unknown,
27
+ TEventPublisher extends EventPublisher<any> | undefined = undefined,
28
+ TEventPublisherServiceName extends string = string,
29
+ > extends BaseFunctionBuilder<
30
+ TInput,
31
+ OutSchema,
32
+ TServices,
33
+ TLogger,
34
+ TEventPublisher,
35
+ TEventPublisherServiceName
36
+ > {
37
+ protected schemas: TInput = {} as TInput;
38
+ protected _description?: string;
39
+ protected _status?: SuccessStatus;
40
+ protected _tags?: string[];
41
+ _getSession: SessionFn<TServices, TLogger, TSession> = () => ({}) as TSession;
42
+ _authorize: AuthorizeFn<TServices, TLogger, TSession> = () => true;
43
+ _rateLimit?: RateLimitConfig;
44
+
45
+ constructor(
46
+ readonly route: TRoute,
47
+ readonly method: TMethod,
48
+ ) {
49
+ super(ConstructType.Endpoint);
50
+ }
51
+
52
+ // Internal setter for EndpointFactory to set default publisher
53
+ _setPublisher(
54
+ publisher: Service<TEventPublisherServiceName, TEventPublisher>,
55
+ ) {
56
+ this._publisher = publisher;
57
+ }
58
+
59
+ description(description: string): this {
60
+ this._description = description;
61
+ return this;
62
+ }
63
+
64
+ status(status: SuccessStatus): this {
65
+ this._status = status;
66
+ return this;
67
+ }
68
+
69
+ event<TEvent extends MappedEvent<TEventPublisher, OutSchema>>(
70
+ event: TEvent,
71
+ ): this {
72
+ this._events.push(event);
73
+ return this;
74
+ }
75
+
76
+ tags(tags: string[]): this {
77
+ this._tags = tags;
78
+ return this;
79
+ }
80
+
81
+ publisher<T extends EventPublisher<any>, TName extends string>(
82
+ publisher: Service<TName, T>,
83
+ ): EndpointBuilder<
84
+ TRoute,
85
+ TMethod,
86
+ TInput,
87
+ TServices,
88
+ TLogger,
89
+ OutSchema,
90
+ TSession,
91
+ T,
92
+ TName
93
+ > {
94
+ this._publisher = publisher as unknown as Service<
95
+ TEventPublisherServiceName,
96
+ TEventPublisher
97
+ >;
98
+
99
+ return this as unknown as EndpointBuilder<
100
+ TRoute,
101
+ TMethod,
102
+ TInput,
103
+ TServices,
104
+ TLogger,
105
+ OutSchema,
106
+ TSession,
107
+ T,
108
+ TName
109
+ >;
110
+ }
111
+
112
+ body<T extends StandardSchemaV1>(
113
+ schema: T,
114
+ ): EndpointBuilder<
115
+ TRoute,
116
+ TMethod,
117
+ Omit<TInput, 'body'> & { body: T },
118
+ TServices,
119
+ TLogger,
120
+ OutSchema,
121
+ TSession,
122
+ TEventPublisher
123
+ > {
124
+ this.schemas.body = schema as unknown as T;
125
+ // @ts-ignore
126
+ return this;
127
+ }
128
+
129
+ search<T extends StandardSchemaV1>(
130
+ schema: T,
131
+ ): EndpointBuilder<
132
+ TRoute,
133
+ TMethod,
134
+ Omit<TInput, 'query'> & { query: T },
135
+ TServices,
136
+ TLogger,
137
+ OutSchema,
138
+ TSession,
139
+ TEventPublisher
140
+ > {
141
+ this.schemas.query = schema as unknown as T;
142
+ // @ts-ignore
143
+ return this;
144
+ }
145
+
146
+ query<T extends StandardSchemaV1>(
147
+ schema: T,
148
+ ): EndpointBuilder<
149
+ TRoute,
150
+ TMethod,
151
+ Omit<TInput, 'query'> & { query: T },
152
+ TServices,
153
+ TLogger,
154
+ OutSchema,
155
+ TSession,
156
+ TEventPublisher
157
+ > {
158
+ return this.search(schema);
159
+ }
160
+
161
+ params<T extends StandardSchemaV1>(
162
+ schema: T,
163
+ ): EndpointBuilder<
164
+ TRoute,
165
+ TMethod,
166
+ Omit<TInput, 'params'> & { params: T },
167
+ TServices,
168
+ TLogger,
169
+ OutSchema,
170
+ TSession,
171
+ TEventPublisher
172
+ > {
173
+ this.schemas.params = schema as unknown as T;
174
+ // @ts-ignore
175
+ return this;
176
+ }
177
+
178
+ rateLimit(config: RateLimitConfig): this {
179
+ this._rateLimit = config;
180
+ return this;
181
+ }
182
+
183
+ services<T extends Service[]>(
184
+ services: T,
185
+ ): EndpointBuilder<
186
+ TRoute,
187
+ TMethod,
188
+ TInput,
189
+ [...TServices, ...T],
190
+ TLogger,
191
+ OutSchema,
192
+ TSession,
193
+ TEventPublisher,
194
+ TEventPublisherServiceName
195
+ > {
196
+ this._services = uniqBy(
197
+ [...this._services, ...services],
198
+ (s) => s.serviceName,
199
+ ) as TServices;
200
+
201
+ return this as unknown as EndpointBuilder<
202
+ TRoute,
203
+ TMethod,
204
+ TInput,
205
+ [...TServices, ...T],
206
+ TLogger,
207
+ OutSchema,
208
+ TSession,
209
+ TEventPublisher,
210
+ TEventPublisherServiceName
211
+ >;
212
+ }
213
+
214
+ logger<T extends Logger>(
215
+ logger: T,
216
+ ): EndpointBuilder<
217
+ TRoute,
218
+ TMethod,
219
+ TInput,
220
+ TServices,
221
+ T,
222
+ OutSchema,
223
+ TSession,
224
+ TEventPublisher,
225
+ TEventPublisherServiceName
226
+ > {
227
+ this._logger = logger as unknown as TLogger;
228
+
229
+ return this as unknown as EndpointBuilder<
230
+ TRoute,
231
+ TMethod,
232
+ TInput,
233
+ TServices,
234
+ T,
235
+ OutSchema,
236
+ TSession,
237
+ TEventPublisher,
238
+ TEventPublisherServiceName
239
+ >;
240
+ }
241
+
242
+ output<T extends StandardSchemaV1>(
243
+ schema: T,
244
+ ): EndpointBuilder<
245
+ TRoute,
246
+ TMethod,
247
+ TInput,
248
+ TServices,
249
+ TLogger,
250
+ T,
251
+ TSession,
252
+ TEventPublisher,
253
+ TEventPublisherServiceName
254
+ > {
255
+ this.outputSchema = schema as unknown as OutSchema;
256
+
257
+ return this as unknown as EndpointBuilder<
258
+ TRoute,
259
+ TMethod,
260
+ TInput,
261
+ TServices,
262
+ TLogger,
263
+ T,
264
+ TSession,
265
+ TEventPublisher,
266
+ TEventPublisherServiceName
267
+ >;
268
+ }
269
+
270
+ // EndpointBuilder doesn't have a generic input method - it uses body, query, params instead
271
+ input(_schema: any): any {
272
+ throw new Error(
273
+ 'EndpointBuilder does not support generic input. Use body(), query(), or params() instead.',
274
+ );
275
+ }
276
+
277
+ handle(
278
+ fn: EndpointHandler<TInput, TServices, TLogger, OutSchema, TSession>,
279
+ ): Endpoint<
280
+ TRoute,
281
+ TMethod,
282
+ TInput,
283
+ OutSchema,
284
+ TServices,
285
+ TLogger,
286
+ TSession,
287
+ TEventPublisher
288
+ > {
289
+ return new Endpoint({
290
+ fn,
291
+ method: this.method,
292
+ route: this.route,
293
+ description: this._description,
294
+ tags: this._tags,
295
+ input: this.schemas,
296
+ output: this.outputSchema,
297
+ services: this._services,
298
+ logger: this._logger,
299
+ timeout: this._timeout,
300
+ authorize: this._authorize,
301
+ status: this._status,
302
+ getSession: this._getSession,
303
+ rateLimit: this._rateLimit,
304
+ publisherService: this._publisher,
305
+ events: this._events,
306
+ });
307
+ }
308
+ }
@@ -0,0 +1,329 @@
1
+ import type { Logger } from '@geekmidas/logger';
2
+ import { ConsoleLogger } from '@geekmidas/logger/console';
3
+ import type { Service } from '@geekmidas/services';
4
+ import uniqBy from 'lodash.uniqby';
5
+ import type { AuthorizeFn, SessionFn } from './Endpoint';
6
+ import { EndpointBuilder } from './EndpointBuilder';
7
+
8
+ import type { EventPublisher, MappedEvent } from '@geekmidas/events';
9
+ import type { HttpMethod } from '../types';
10
+
11
+ const DEFAULT_LOGGER = new ConsoleLogger() as any;
12
+
13
+ export class EndpointFactory<
14
+ TServices extends Service[] = [],
15
+ TBasePath extends string = '',
16
+ TLogger extends Logger = Logger,
17
+ TSession = unknown,
18
+ TEventPublisher extends EventPublisher<any> | undefined = undefined,
19
+ TEventPublisherServiceName extends string = string,
20
+ > {
21
+ // @ts-ignore
22
+ private defaultServices: TServices;
23
+ private basePath: TBasePath = '' as TBasePath;
24
+ private defaultAuthorizeFn?: AuthorizeFn<TServices, TLogger, TSession>;
25
+ private defaultEventPublisher:
26
+ | Service<TEventPublisherServiceName, TEventPublisher>
27
+ | undefined;
28
+ private defaultSessionExtractor?: SessionFn<TServices, TLogger, TSession>;
29
+ private defaultLogger: TLogger = DEFAULT_LOGGER;
30
+
31
+ constructor({
32
+ basePath,
33
+ defaultAuthorizeFn,
34
+ defaultLogger,
35
+ defaultSessionExtractor,
36
+ // @ts-ignore
37
+ defaultServices = [] as TServices,
38
+ defaultEventPublisher,
39
+ }: EndpointFactoryOptions<
40
+ TServices,
41
+ TBasePath,
42
+ TLogger,
43
+ TSession,
44
+ TEventPublisher,
45
+ TEventPublisherServiceName
46
+ > = {}) {
47
+ // Initialize default services
48
+ this.defaultServices = uniqBy(
49
+ defaultServices,
50
+ (s) => s.serviceName,
51
+ ) as TServices;
52
+
53
+ this.basePath = basePath || ('' as TBasePath);
54
+ this.defaultAuthorizeFn = defaultAuthorizeFn;
55
+ this.defaultLogger = defaultLogger || (DEFAULT_LOGGER as TLogger);
56
+ this.defaultSessionExtractor = defaultSessionExtractor;
57
+ this.defaultEventPublisher = defaultEventPublisher;
58
+ }
59
+
60
+ static joinPaths<TBasePath extends string, P extends string>(
61
+ path: P,
62
+ basePath: TBasePath = '' as TBasePath,
63
+ ): JoinPaths<TBasePath, P> {
64
+ // Handle empty cases
65
+ if (!basePath && !path) return '/' as JoinPaths<TBasePath, P>;
66
+ if (!basePath)
67
+ return (path.startsWith('/') ? path : '/' + path) as JoinPaths<
68
+ TBasePath,
69
+ P
70
+ >;
71
+ if (!path)
72
+ return (
73
+ basePath.startsWith('/') ? basePath : '/' + basePath
74
+ ) as JoinPaths<TBasePath, P>;
75
+
76
+ const base = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
77
+ const segment = path.startsWith('/') ? path : '/' + path;
78
+
79
+ let result = base + segment;
80
+
81
+ // Ensure leading slash
82
+ if (!result.startsWith('/')) {
83
+ result = '/' + result;
84
+ }
85
+
86
+ // Normalize multiple slashes (except in the middle of the path where they might be intentional)
87
+ result = result.replace(/^\/+/g, '/');
88
+
89
+ // Remove trailing slash unless it's the root path "/"
90
+ if (result.length > 1 && result.endsWith('/')) {
91
+ result = result.slice(0, -1);
92
+ }
93
+
94
+ return result as JoinPaths<TBasePath, P>;
95
+ }
96
+
97
+ // Create a sub-router with a path prefix
98
+ route<TPath extends string>(
99
+ path: TPath,
100
+ ): EndpointFactory<
101
+ TServices,
102
+ JoinPaths<TBasePath, TPath>,
103
+ TLogger,
104
+ TSession,
105
+ TEventPublisher
106
+ > {
107
+ const newBasePath = EndpointFactory.joinPaths(path, this.basePath);
108
+ return new EndpointFactory({
109
+ defaultServices: this.defaultServices,
110
+ basePath: newBasePath,
111
+ defaultAuthorizeFn: this.defaultAuthorizeFn,
112
+ defaultLogger: this.defaultLogger,
113
+ defaultSessionExtractor: this.defaultSessionExtractor,
114
+ defaultEventPublisher: this.defaultEventPublisher,
115
+ });
116
+ }
117
+
118
+ // Create a new factory with authorization
119
+ authorize(
120
+ fn: AuthorizeFn<TServices, TLogger, TSession>,
121
+ ): EndpointFactory<TServices, TBasePath, TLogger, TSession, TEventPublisher> {
122
+ return new EndpointFactory({
123
+ defaultServices: this.defaultServices,
124
+ basePath: this.basePath,
125
+ defaultAuthorizeFn: fn,
126
+ defaultLogger: this.defaultLogger,
127
+ defaultSessionExtractor: this.defaultSessionExtractor,
128
+ defaultEventPublisher: this.defaultEventPublisher,
129
+ });
130
+ }
131
+
132
+ // Create a new factory with services
133
+ services<S extends Service[]>(
134
+ services: S,
135
+ ): EndpointFactory<
136
+ [...S, ...TServices],
137
+ TBasePath,
138
+ TLogger,
139
+ TSession,
140
+ TEventPublisher
141
+ > {
142
+ return new EndpointFactory<
143
+ [...S, ...TServices],
144
+ TBasePath,
145
+ TLogger,
146
+ TSession,
147
+ TEventPublisher
148
+ >({
149
+ defaultServices: [...services, ...this.defaultServices],
150
+ basePath: this.basePath,
151
+ defaultAuthorizeFn: this.defaultAuthorizeFn,
152
+ defaultLogger: this.defaultLogger,
153
+ defaultSessionExtractor: this.defaultSessionExtractor,
154
+ defaultEventPublisher: this.defaultEventPublisher,
155
+ });
156
+ }
157
+
158
+ logger<L extends Logger>(
159
+ logger: L,
160
+ ): EndpointFactory<TServices, TBasePath, L, TSession> {
161
+ return new EndpointFactory<TServices, TBasePath, L, TSession>({
162
+ defaultServices: this.defaultServices,
163
+ basePath: this.basePath,
164
+ defaultAuthorizeFn: this.defaultAuthorizeFn,
165
+ defaultLogger: logger,
166
+ defaultSessionExtractor: this.defaultSessionExtractor,
167
+ } as EndpointFactoryOptions<TServices, TBasePath, L, TSession>);
168
+ }
169
+
170
+ publisher<
171
+ T extends EventPublisher<any>,
172
+ TServiceName extends string = string,
173
+ >(
174
+ publisher: Service<TServiceName, T>,
175
+ ): EndpointFactory<TServices, TBasePath, TLogger, TSession, T> {
176
+ return new EndpointFactory<TServices, TBasePath, TLogger, TSession, T>({
177
+ defaultServices: this.defaultServices,
178
+ basePath: this.basePath,
179
+ defaultAuthorizeFn: this.defaultAuthorizeFn,
180
+ defaultLogger: this.defaultLogger,
181
+ defaultSessionExtractor: this.defaultSessionExtractor,
182
+ defaultEventPublisher: publisher,
183
+ });
184
+ }
185
+
186
+ session<T>(session: SessionFn<TServices, TLogger, T>) {
187
+ return new EndpointFactory<TServices, TBasePath, TLogger, T>({
188
+ defaultServices: this.defaultServices,
189
+ basePath: this.basePath,
190
+ // @ts-ignore
191
+ defaultAuthorizeFn: this.defaultAuthorizeFn,
192
+ defaultLogger: this.defaultLogger,
193
+ defaultSessionExtractor: session,
194
+ defaultEventPublisher: this.defaultEventPublisher as any,
195
+ });
196
+ }
197
+
198
+ private createBuilder<TMethod extends HttpMethod, TPath extends string>(
199
+ method: TMethod,
200
+ path: TPath,
201
+ ): EndpointBuilder<
202
+ JoinPaths<TBasePath, TPath>,
203
+ TMethod,
204
+ {},
205
+ TServices,
206
+ TLogger,
207
+ undefined,
208
+ TSession,
209
+ TEventPublisher
210
+ > {
211
+ const fullPath = EndpointFactory.joinPaths(path, this.basePath);
212
+ const builder = new EndpointBuilder<
213
+ JoinPaths<TBasePath, TPath>,
214
+ TMethod,
215
+ {},
216
+ TServices,
217
+ TLogger,
218
+ undefined,
219
+ TSession,
220
+ TEventPublisher
221
+ >(fullPath, method);
222
+
223
+ if (this.defaultAuthorizeFn) {
224
+ // @ts-ignore
225
+ builder._authorize = this.defaultAuthorizeFn;
226
+ }
227
+ if (this.defaultServices.length) {
228
+ builder._services = this.defaultServices as TServices;
229
+ }
230
+
231
+ if (this.defaultLogger) {
232
+ builder._logger = this.defaultLogger as TLogger;
233
+ }
234
+
235
+ if (this.defaultSessionExtractor) {
236
+ builder._getSession = this.defaultSessionExtractor as SessionFn<
237
+ TServices,
238
+ TLogger,
239
+ TSession
240
+ >;
241
+ }
242
+
243
+ if (this.defaultEventPublisher) {
244
+ builder._setPublisher(this.defaultEventPublisher);
245
+ }
246
+
247
+ return builder as unknown as EndpointBuilder<
248
+ JoinPaths<TBasePath, TPath>,
249
+ TMethod,
250
+ {},
251
+ TServices,
252
+ TLogger,
253
+ undefined,
254
+ TSession,
255
+ TEventPublisher,
256
+ TEventPublisherServiceName
257
+ >;
258
+ }
259
+
260
+ post<TPath extends string>(path: TPath) {
261
+ return this.createBuilder('POST', path);
262
+ }
263
+
264
+ get<TPath extends string>(path: TPath) {
265
+ return this.createBuilder('GET', path);
266
+ }
267
+
268
+ put<TPath extends string>(path: TPath) {
269
+ return this.createBuilder('PUT', path);
270
+ }
271
+
272
+ delete<TPath extends string>(path: TPath) {
273
+ return this.createBuilder('DELETE', path);
274
+ }
275
+
276
+ patch<TPath extends string>(path: TPath) {
277
+ return this.createBuilder('PATCH', path);
278
+ }
279
+
280
+ options<TPath extends string>(path: TPath) {
281
+ return this.createBuilder('OPTIONS', path);
282
+ }
283
+ }
284
+
285
+ export type RemoveTrailingSlash<T extends string> = T extends `${infer Rest}/`
286
+ ? Rest extends ''
287
+ ? T // Keep "/" as is
288
+ : Rest
289
+ : T;
290
+
291
+ export type JoinPaths<
292
+ TBasePath extends string,
293
+ TPath extends string,
294
+ > = RemoveTrailingSlash<
295
+ TBasePath extends ''
296
+ ? TPath
297
+ : TPath extends ''
298
+ ? TBasePath
299
+ : TBasePath extends '/'
300
+ ? TPath extends `/${string}`
301
+ ? TPath
302
+ : `/${TPath}`
303
+ : TBasePath extends `${infer Base}/`
304
+ ? TPath extends `/${infer Rest}`
305
+ ? `${Base}/${Rest}`
306
+ : `${Base}/${TPath}`
307
+ : TPath extends `/${infer Rest}`
308
+ ? `${TBasePath}/${Rest}`
309
+ : `${TBasePath}/${TPath}`
310
+ >;
311
+
312
+ export interface EndpointFactoryOptions<
313
+ TServices extends Service[] = [],
314
+ TBasePath extends string = '',
315
+ TLogger extends Logger = Logger,
316
+ TSession = unknown,
317
+ TEventPublisher extends EventPublisher<any> | undefined = undefined,
318
+ TEventPublisherServiceName extends string = string,
319
+ > {
320
+ defaultServices?: TServices;
321
+ basePath?: TBasePath;
322
+ defaultAuthorizeFn?: AuthorizeFn<TServices, TLogger, TSession>;
323
+ defaultLogger?: TLogger;
324
+ defaultSessionExtractor?: SessionFn<TServices, TLogger, TSession>;
325
+ defaultEventPublisher?: Service<TEventPublisherServiceName, TEventPublisher>;
326
+ defaultEvents?: MappedEvent<TEventPublisher, undefined>[];
327
+ }
328
+
329
+ export const e = new EndpointFactory();