@geekmidas/constructs 0.0.11 → 0.0.13

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 (363) hide show
  1. package/README.md +448 -0
  2. package/dist/AWSLambdaFunction-B-Oxr8qt.d.cts +30 -0
  3. package/dist/{AWSLambdaFunction-DcI_77u8.cjs → AWSLambdaFunction-C-fuCLA3.cjs} +28 -5
  4. package/dist/AWSLambdaFunction-C-fuCLA3.cjs.map +1 -0
  5. package/dist/AWSLambdaFunction-CAm9r5ZX.d.mts +30 -0
  6. package/dist/{AWSLambdaFunction-BTSGYZSx.mjs → AWSLambdaFunction-H65WfXLt.mjs} +28 -5
  7. package/dist/AWSLambdaFunction-H65WfXLt.mjs.map +1 -0
  8. package/dist/{AWSLambdaSubscriberAdaptor-mLOpS63x.d.mts → AWSLambdaSubscriberAdaptor-Cknp_nn1.d.cts} +4 -4
  9. package/dist/{AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs → AWSLambdaSubscriberAdaptor-CyFh7MN8.mjs} +1 -1
  10. package/dist/{AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs.map → AWSLambdaSubscriberAdaptor-CyFh7MN8.mjs.map} +1 -1
  11. package/dist/{AWSLambdaSubscriberAdaptor-DX5NFdWf.d.cts → AWSLambdaSubscriberAdaptor-DpHzp-AM.d.mts} +4 -4
  12. package/dist/{AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs → AWSLambdaSubscriberAdaptor-Dum5bkw3.cjs} +1 -1
  13. package/dist/{AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs.map → AWSLambdaSubscriberAdaptor-Dum5bkw3.cjs.map} +1 -1
  14. package/dist/{AmazonApiGatewayEndpointAdaptor-CATWBIJo.d.mts → AmazonApiGatewayEndpointAdaptor-4hPy5vty.d.mts} +9 -8
  15. package/dist/{AmazonApiGatewayEndpointAdaptor-vi0D3dWg.mjs → AmazonApiGatewayEndpointAdaptor-C6Jk5HSy.mjs} +51 -16
  16. package/dist/AmazonApiGatewayEndpointAdaptor-C6Jk5HSy.mjs.map +1 -0
  17. package/dist/{AmazonApiGatewayEndpointAdaptor-BTqB3c1_.cjs → AmazonApiGatewayEndpointAdaptor-CI9L7Ucn.cjs} +51 -16
  18. package/dist/AmazonApiGatewayEndpointAdaptor-CI9L7Ucn.cjs.map +1 -0
  19. package/dist/{AmazonApiGatewayEndpointAdaptor-BwtDtS-i.d.cts → AmazonApiGatewayEndpointAdaptor-ro0RMLzr.d.cts} +8 -7
  20. package/dist/{AmazonApiGatewayV1EndpointAdaptor-D2_u_zR6.mjs → AmazonApiGatewayV1EndpointAdaptor-BMy8DdNJ.mjs} +3 -3
  21. package/dist/{AmazonApiGatewayV1EndpointAdaptor-D2_u_zR6.mjs.map → AmazonApiGatewayV1EndpointAdaptor-BMy8DdNJ.mjs.map} +1 -1
  22. package/dist/{AmazonApiGatewayV1EndpointAdaptor-B1AVk2MM.d.cts → AmazonApiGatewayV1EndpointAdaptor-BWJWKqQT.d.cts} +3 -3
  23. package/dist/{AmazonApiGatewayV1EndpointAdaptor-nwrtG5L9.cjs → AmazonApiGatewayV1EndpointAdaptor-DYL1bCBS.cjs} +3 -3
  24. package/dist/{AmazonApiGatewayV1EndpointAdaptor-nwrtG5L9.cjs.map → AmazonApiGatewayV1EndpointAdaptor-DYL1bCBS.cjs.map} +1 -1
  25. package/dist/{AmazonApiGatewayV1EndpointAdaptor-2Rd0LLz4.d.mts → AmazonApiGatewayV1EndpointAdaptor-hyR-WwyP.d.mts} +4 -4
  26. package/dist/{AmazonApiGatewayV2EndpointAdaptor-DoWAJ9oN.mjs → AmazonApiGatewayV2EndpointAdaptor-BU5wQMOe.mjs} +3 -3
  27. package/dist/{AmazonApiGatewayV2EndpointAdaptor-DoWAJ9oN.mjs.map → AmazonApiGatewayV2EndpointAdaptor-BU5wQMOe.mjs.map} +1 -1
  28. package/dist/{AmazonApiGatewayV2EndpointAdaptor-FSIdXYV6.cjs → AmazonApiGatewayV2EndpointAdaptor-CPLCMeaN.cjs} +3 -3
  29. package/dist/{AmazonApiGatewayV2EndpointAdaptor-FSIdXYV6.cjs.map → AmazonApiGatewayV2EndpointAdaptor-CPLCMeaN.cjs.map} +1 -1
  30. package/dist/{AmazonApiGatewayV2EndpointAdaptor-DmY_QfjO.d.cts → AmazonApiGatewayV2EndpointAdaptor-D1Irdggp.d.cts} +3 -3
  31. package/dist/{AmazonApiGatewayV2EndpointAdaptor-cBDfwdBx.d.mts → AmazonApiGatewayV2EndpointAdaptor-DX3SuI5S.d.mts} +4 -4
  32. package/dist/{Authorizer-Bbk9ziuG.d.mts → Authorizer-BTmly8ps.d.cts} +1 -1
  33. package/dist/{Authorizer-iXsSB600.d.cts → Authorizer-pmPvIVgv.d.mts} +1 -1
  34. package/dist/{BaseFunctionBuilder-DSqF1r3a.mjs → BaseFunctionBuilder-B5gkW0Kt.mjs} +16 -2
  35. package/dist/BaseFunctionBuilder-B5gkW0Kt.mjs.map +1 -0
  36. package/dist/{BaseFunctionBuilder-bTDKP7bd.cjs → BaseFunctionBuilder-C5Se7pdL.cjs} +16 -2
  37. package/dist/BaseFunctionBuilder-C5Se7pdL.cjs.map +1 -0
  38. package/dist/{BaseFunctionBuilder-DOcm1heZ.d.mts → BaseFunctionBuilder-CbDnPZpD.d.mts} +13 -4
  39. package/dist/{BaseFunctionBuilder-hWNVKXQB.d.cts → BaseFunctionBuilder-DUZMbEr3.d.cts} +13 -4
  40. package/dist/{Construct-XCGKof_O.cjs → Construct-BYSPikVm.cjs} +8 -3
  41. package/dist/Construct-BYSPikVm.cjs.map +1 -0
  42. package/dist/{Construct-rZQg2yus.mjs → Construct-LWeB1rSQ.mjs} +8 -3
  43. package/dist/Construct-LWeB1rSQ.mjs.map +1 -0
  44. package/dist/{Construct-iDmbkZ3o.d.mts → Construct-ZPqE0vhn.d.mts} +5 -3
  45. package/dist/{Construct-zc8BkRSp.d.cts → Construct-dI_rgdSp.d.cts} +5 -3
  46. package/dist/Construct.cjs +1 -1
  47. package/dist/Construct.d.cts +1 -1
  48. package/dist/Construct.d.mts +1 -1
  49. package/dist/Construct.mjs +1 -1
  50. package/dist/{Cron-CYIhd0VE.cjs → Cron-Bi3QOge_.cjs} +5 -5
  51. package/dist/Cron-Bi3QOge_.cjs.map +1 -0
  52. package/dist/{Cron-D5HGEt6g.d.mts → Cron-COdfP0Jd.d.cts} +5 -5
  53. package/dist/{Cron-DbJNPTbP.d.cts → Cron-D8cn_ahj.d.mts} +5 -5
  54. package/dist/{Cron-BnO1uXhh.mjs → Cron-Dy_HW2Vv.mjs} +5 -5
  55. package/dist/Cron-Dy_HW2Vv.mjs.map +1 -0
  56. package/dist/{CronBuilder-BxKwHCdJ.mjs → CronBuilder-Bl3A2Zp4.mjs} +15 -6
  57. package/dist/CronBuilder-Bl3A2Zp4.mjs.map +1 -0
  58. package/dist/{CronBuilder-D-546XtP.d.cts → CronBuilder-DntF6H3A.d.cts} +17 -12
  59. package/dist/{CronBuilder-vRiZb1_N.d.mts → CronBuilder-DoMnSs_0.d.mts} +17 -12
  60. package/dist/{CronBuilder-D_3AiPFO.cjs → CronBuilder-Dv_w7Yri.cjs} +15 -6
  61. package/dist/CronBuilder-Dv_w7Yri.cjs.map +1 -0
  62. package/dist/{Endpoint-DqZkc6ft.d.mts → Endpoint-Bbs_sFvg.d.mts} +120 -23
  63. package/dist/{Endpoint-BpTSQn7W.d.cts → Endpoint-Bu8Phz6y.d.cts} +120 -23
  64. package/dist/{Endpoint-BdIGWw1H.cjs → Endpoint-DDpF7NO1.cjs} +22 -10
  65. package/dist/Endpoint-DDpF7NO1.cjs.map +1 -0
  66. package/dist/{Endpoint-ChzcIFdV.mjs → Endpoint-S6Yh2_PN.mjs} +22 -10
  67. package/dist/Endpoint-S6Yh2_PN.mjs.map +1 -0
  68. package/dist/EndpointBuilder-CPxmF_w7.d.cts +103 -0
  69. package/dist/EndpointBuilder-Csfyfjd7.d.mts +103 -0
  70. package/dist/{EndpointBuilder-dmMiNRm9.cjs → EndpointBuilder-DpGmObMb.cjs} +68 -5
  71. package/dist/EndpointBuilder-DpGmObMb.cjs.map +1 -0
  72. package/dist/{EndpointBuilder-yo40Qkf_.mjs → EndpointBuilder-aE2E6WTx.mjs} +68 -5
  73. package/dist/EndpointBuilder-aE2E6WTx.mjs.map +1 -0
  74. package/dist/{EndpointFactory-D_mmO7Gu.d.mts → EndpointFactory-Bf9JSWzI.d.cts} +12 -11
  75. package/dist/{EndpointFactory-CNbcr8u_.cjs → EndpointFactory-BfH6mjJ3.cjs} +3 -3
  76. package/dist/EndpointFactory-BfH6mjJ3.cjs.map +1 -0
  77. package/dist/{EndpointFactory-JPhk0Qom.d.cts → EndpointFactory-Cgk1R0oO.d.mts} +12 -11
  78. package/dist/{EndpointFactory-LD3upVQK.mjs → EndpointFactory-D4leYk1N.mjs} +3 -3
  79. package/dist/EndpointFactory-D4leYk1N.mjs.map +1 -0
  80. package/dist/{Function-DDaSfL_E.cjs → Function-DagDbeXo.cjs} +7 -6
  81. package/dist/Function-DagDbeXo.cjs.map +1 -0
  82. package/dist/{Function-Cl9fiR3a.mjs → Function-DfKsM5Kx.mjs} +7 -6
  83. package/dist/Function-DfKsM5Kx.mjs.map +1 -0
  84. package/dist/{Function-C-5_23Wi.d.mts → Function-V9M9UVHp.d.mts} +25 -7
  85. package/dist/{Function-CW-WcZTu.d.cts → Function-VI1TB3Mh.d.cts} +25 -7
  86. package/dist/{FunctionBuilder-vW12WFOw.mjs → FunctionBuilder-CVT7bG2o.mjs} +27 -6
  87. package/dist/FunctionBuilder-CVT7bG2o.mjs.map +1 -0
  88. package/dist/FunctionBuilder-CjVEFTYC.d.cts +38 -0
  89. package/dist/FunctionBuilder-D1ofSeMd.d.mts +38 -0
  90. package/dist/{FunctionBuilder-LQuBiqRc.cjs → FunctionBuilder-DXvG_XD-.cjs} +27 -6
  91. package/dist/FunctionBuilder-DXvG_XD-.cjs.map +1 -0
  92. package/dist/FunctionExecutionWrapper-Bubnr0zA.mjs +101 -0
  93. package/dist/FunctionExecutionWrapper-Bubnr0zA.mjs.map +1 -0
  94. package/dist/FunctionExecutionWrapper-CwtwYozd.d.cts +48 -0
  95. package/dist/FunctionExecutionWrapper-DkNycmOh.cjs +107 -0
  96. package/dist/FunctionExecutionWrapper-DkNycmOh.cjs.map +1 -0
  97. package/dist/FunctionExecutionWrapper-rhbIYT0Q.d.mts +48 -0
  98. package/dist/{HonoEndpointAdaptor-BVQtyvna.d.cts → HonoEndpointAdaptor-B34kNobH.d.cts} +8 -7
  99. package/dist/{HonoEndpointAdaptor-W-disJnm.d.mts → HonoEndpointAdaptor-BDpi32mH.d.mts} +9 -8
  100. package/dist/{HonoEndpointAdaptor-Bc61IS6Q.cjs → HonoEndpointAdaptor-CfLRHHFw.cjs} +55 -20
  101. package/dist/HonoEndpointAdaptor-CfLRHHFw.cjs.map +1 -0
  102. package/dist/{HonoEndpointAdaptor-NR3h5gml.mjs → HonoEndpointAdaptor-DuyE06nH.mjs} +55 -20
  103. package/dist/HonoEndpointAdaptor-DuyE06nH.mjs.map +1 -0
  104. package/dist/{Subscriber-C2OPATI8.cjs → Subscriber-Bdh8rMSL.cjs} +2 -2
  105. package/dist/{Subscriber-C2OPATI8.cjs.map → Subscriber-Bdh8rMSL.cjs.map} +1 -1
  106. package/dist/{Subscriber-BVq3ST4C.d.cts → Subscriber-BhzqUzs-.d.cts} +2 -2
  107. package/dist/{Subscriber-BKftCzwT.mjs → Subscriber-CJOWwaw1.mjs} +2 -2
  108. package/dist/{Subscriber-BKftCzwT.mjs.map → Subscriber-CJOWwaw1.mjs.map} +1 -1
  109. package/dist/{Subscriber-BuHaqWo4.d.mts → Subscriber-s6yfjeOc.d.mts} +2 -2
  110. package/dist/{SubscriberBuilder-2asHtGbl.d.mts → SubscriberBuilder-BCVkp-ga.d.cts} +3 -3
  111. package/dist/{SubscriberBuilder-yDfpHPZE.mjs → SubscriberBuilder-BWQmiYd8.mjs} +2 -2
  112. package/dist/{SubscriberBuilder-yDfpHPZE.mjs.map → SubscriberBuilder-BWQmiYd8.mjs.map} +1 -1
  113. package/dist/{SubscriberBuilder-yikoQ8ND.cjs → SubscriberBuilder-DieD_60p.cjs} +2 -2
  114. package/dist/{SubscriberBuilder-yikoQ8ND.cjs.map → SubscriberBuilder-DieD_60p.cjs.map} +1 -1
  115. package/dist/{SubscriberBuilder-CHIRyNjy.d.cts → SubscriberBuilder-aCua5_wA.d.mts} +3 -3
  116. package/dist/{TestEndpointAdaptor-DpmNXp7G.mjs → TestEndpointAdaptor-BEyZa0Yg.mjs} +51 -18
  117. package/dist/TestEndpointAdaptor-BEyZa0Yg.mjs.map +1 -0
  118. package/dist/{TestEndpointAdaptor-DA1D6l-U.cjs → TestEndpointAdaptor-C8425RJ0.cjs} +51 -18
  119. package/dist/TestEndpointAdaptor-C8425RJ0.cjs.map +1 -0
  120. package/dist/{TestEndpointAdaptor-BrE5Rs4U.d.cts → TestEndpointAdaptor-H5To8PH7.d.cts} +6 -5
  121. package/dist/{TestEndpointAdaptor-B10J-cI-.d.mts → TestEndpointAdaptor-jxn68ayg.d.mts} +7 -6
  122. package/dist/adaptors/aws.cjs +14 -13
  123. package/dist/adaptors/aws.d.cts +14 -14
  124. package/dist/adaptors/aws.d.mts +15 -15
  125. package/dist/adaptors/aws.mjs +14 -13
  126. package/dist/adaptors/hono.cjs +10 -9
  127. package/dist/adaptors/hono.d.cts +8 -8
  128. package/dist/adaptors/hono.d.mts +9 -9
  129. package/dist/adaptors/hono.mjs +10 -9
  130. package/dist/adaptors/testing.cjs +8 -7
  131. package/dist/adaptors/testing.d.cts +8 -8
  132. package/dist/adaptors/testing.d.mts +9 -9
  133. package/dist/adaptors/testing.mjs +8 -7
  134. package/dist/crons/Cron.cjs +6 -6
  135. package/dist/crons/Cron.d.cts +6 -6
  136. package/dist/crons/Cron.d.mts +6 -6
  137. package/dist/crons/Cron.mjs +6 -6
  138. package/dist/crons/CronBuilder.cjs +7 -7
  139. package/dist/crons/CronBuilder.d.cts +7 -7
  140. package/dist/crons/CronBuilder.d.mts +7 -7
  141. package/dist/crons/CronBuilder.mjs +7 -7
  142. package/dist/crons/index.cjs +7 -7
  143. package/dist/crons/index.d.cts +11 -11
  144. package/dist/crons/index.d.mts +8 -8
  145. package/dist/crons/index.mjs +7 -7
  146. package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +8 -7
  147. package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +8 -8
  148. package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +9 -9
  149. package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +8 -7
  150. package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +10 -9
  151. package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +9 -9
  152. package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +10 -10
  153. package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +10 -9
  154. package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +10 -9
  155. package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +9 -9
  156. package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +10 -10
  157. package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +10 -9
  158. package/dist/endpoints/Authorizer.d.cts +1 -1
  159. package/dist/endpoints/Authorizer.d.mts +1 -1
  160. package/dist/endpoints/Endpoint.cjs +6 -6
  161. package/dist/endpoints/Endpoint.d.cts +7 -7
  162. package/dist/endpoints/Endpoint.d.mts +8 -8
  163. package/dist/endpoints/Endpoint.mjs +6 -6
  164. package/dist/endpoints/EndpointBuilder.cjs +7 -7
  165. package/dist/endpoints/EndpointBuilder.d.cts +8 -8
  166. package/dist/endpoints/EndpointBuilder.d.mts +9 -9
  167. package/dist/endpoints/EndpointBuilder.mjs +7 -7
  168. package/dist/endpoints/EndpointFactory.cjs +8 -8
  169. package/dist/endpoints/EndpointFactory.d.cts +9 -9
  170. package/dist/endpoints/EndpointFactory.d.mts +10 -10
  171. package/dist/endpoints/EndpointFactory.mjs +8 -8
  172. package/dist/endpoints/HonoEndpointAdaptor.cjs +10 -9
  173. package/dist/endpoints/HonoEndpointAdaptor.d.cts +8 -8
  174. package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -9
  175. package/dist/endpoints/HonoEndpointAdaptor.mjs +10 -9
  176. package/dist/endpoints/TestEndpointAdaptor.cjs +8 -7
  177. package/dist/endpoints/TestEndpointAdaptor.d.cts +8 -8
  178. package/dist/endpoints/TestEndpointAdaptor.d.mts +9 -9
  179. package/dist/endpoints/TestEndpointAdaptor.mjs +8 -7
  180. package/dist/endpoints/audit.cjs +0 -0
  181. package/dist/endpoints/audit.d.cts +9 -0
  182. package/dist/endpoints/audit.d.mts +9 -0
  183. package/dist/endpoints/audit.mjs +0 -0
  184. package/dist/endpoints/helpers.cjs +7 -7
  185. package/dist/endpoints/helpers.d.cts +7 -7
  186. package/dist/endpoints/helpers.d.mts +8 -8
  187. package/dist/endpoints/helpers.mjs +7 -7
  188. package/dist/endpoints/index.cjs +8 -8
  189. package/dist/endpoints/index.cjs.map +1 -1
  190. package/dist/endpoints/index.d.cts +12 -12
  191. package/dist/endpoints/index.d.mts +13 -13
  192. package/dist/endpoints/index.mjs +8 -8
  193. package/dist/endpoints/index.mjs.map +1 -1
  194. package/dist/endpoints/parseHonoQuery.cjs +1 -1
  195. package/dist/endpoints/parseHonoQuery.mjs +1 -1
  196. package/dist/endpoints/parseQueryParams.cjs +1 -1
  197. package/dist/endpoints/parseQueryParams.mjs +1 -1
  198. package/dist/endpoints/processAudits.cjs +5 -0
  199. package/dist/endpoints/processAudits.d.cts +74 -0
  200. package/dist/endpoints/processAudits.d.mts +74 -0
  201. package/dist/endpoints/processAudits.mjs +3 -0
  202. package/dist/functions/AWSLambdaFunction.cjs +6 -6
  203. package/dist/functions/AWSLambdaFunction.d.cts +4 -4
  204. package/dist/functions/AWSLambdaFunction.d.mts +4 -4
  205. package/dist/functions/AWSLambdaFunction.mjs +6 -6
  206. package/dist/functions/BaseFunctionBuilder.cjs +2 -2
  207. package/dist/functions/BaseFunctionBuilder.d.cts +2 -2
  208. package/dist/functions/BaseFunctionBuilder.d.mts +2 -2
  209. package/dist/functions/BaseFunctionBuilder.mjs +2 -2
  210. package/dist/functions/Function.cjs +2 -2
  211. package/dist/functions/Function.d.cts +2 -2
  212. package/dist/functions/Function.d.mts +2 -2
  213. package/dist/functions/Function.mjs +2 -2
  214. package/dist/functions/FunctionBuilder.cjs +4 -4
  215. package/dist/functions/FunctionBuilder.d.cts +4 -4
  216. package/dist/functions/FunctionBuilder.d.mts +4 -4
  217. package/dist/functions/FunctionBuilder.mjs +4 -4
  218. package/dist/functions/FunctionExecutionWrapper.cjs +5 -5
  219. package/dist/functions/FunctionExecutionWrapper.d.cts +3 -3
  220. package/dist/functions/FunctionExecutionWrapper.d.mts +3 -3
  221. package/dist/functions/FunctionExecutionWrapper.mjs +5 -5
  222. package/dist/functions/TestFunctionAdaptor.cjs +38 -5
  223. package/dist/functions/TestFunctionAdaptor.cjs.map +1 -1
  224. package/dist/functions/TestFunctionAdaptor.d.cts +10 -7
  225. package/dist/functions/TestFunctionAdaptor.d.mts +10 -7
  226. package/dist/functions/TestFunctionAdaptor.mjs +38 -5
  227. package/dist/functions/TestFunctionAdaptor.mjs.map +1 -1
  228. package/dist/functions/index.cjs +5 -5
  229. package/dist/functions/index.d.cts +5 -5
  230. package/dist/functions/index.d.mts +5 -5
  231. package/dist/functions/index.mjs +5 -5
  232. package/dist/{functions-yg097ymU.cjs → functions-FCb-wWFC.cjs} +2 -2
  233. package/dist/{functions-yg097ymU.cjs.map → functions-FCb-wWFC.cjs.map} +1 -1
  234. package/dist/functions-JhRsNoAZ.mjs +8 -0
  235. package/dist/{functions-HCoZ4YKF.mjs.map → functions-JhRsNoAZ.mjs.map} +1 -1
  236. package/dist/{helpers-CHsIWAEx.mjs → helpers-2CLKTnRm.mjs} +2 -2
  237. package/dist/{helpers-CHsIWAEx.mjs.map → helpers-2CLKTnRm.mjs.map} +1 -1
  238. package/dist/{helpers-Cq6wjo7s.cjs → helpers-Khuhi_Qx.cjs} +2 -2
  239. package/dist/{helpers-Cq6wjo7s.cjs.map → helpers-Khuhi_Qx.cjs.map} +1 -1
  240. package/dist/index-Bomy7R9z.d.mts +10 -0
  241. package/dist/index-DRYfZHb3.d.cts +10 -0
  242. package/dist/index.cjs +1 -1
  243. package/dist/index.d.cts +1 -1
  244. package/dist/index.d.mts +2 -2
  245. package/dist/index.mjs +1 -1
  246. package/dist/{parseHonoQuery-DopC24vB.cjs → parseHonoQuery-CT8Cvin-.cjs} +1 -1
  247. package/dist/{parseHonoQuery-DopC24vB.cjs.map → parseHonoQuery-CT8Cvin-.cjs.map} +1 -1
  248. package/dist/{parseHonoQuery-znDKBhdE.mjs → parseHonoQuery-CwFKw2ua.mjs} +1 -1
  249. package/dist/{parseHonoQuery-znDKBhdE.mjs.map → parseHonoQuery-CwFKw2ua.mjs.map} +1 -1
  250. package/dist/{parseQueryParams-BJaRh3OB.mjs → parseQueryParams-CHINupbZ.mjs} +1 -1
  251. package/dist/{parseQueryParams-BJaRh3OB.mjs.map → parseQueryParams-CHINupbZ.mjs.map} +1 -1
  252. package/dist/{parseQueryParams-BzPop4I1.cjs → parseQueryParams-CwvXXwkW.cjs} +1 -1
  253. package/dist/{parseQueryParams-BzPop4I1.cjs.map → parseQueryParams-CwvXXwkW.cjs.map} +1 -1
  254. package/dist/processAudits-BFokHhCO.cjs +174 -0
  255. package/dist/processAudits-BFokHhCO.cjs.map +1 -0
  256. package/dist/processAudits-DfcB-X-4.mjs +156 -0
  257. package/dist/processAudits-DfcB-X-4.mjs.map +1 -0
  258. package/dist/publisher-Bw4770Hi.mjs.map +1 -1
  259. package/dist/publisher-lFQleddL.cjs.map +1 -1
  260. package/dist/publisher.d.cts +3 -2
  261. package/dist/publisher.d.mts +3 -2
  262. package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +1 -1
  263. package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.cts +3 -3
  264. package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +3 -3
  265. package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +1 -1
  266. package/dist/subscribers/Subscriber.cjs +2 -2
  267. package/dist/subscribers/Subscriber.d.cts +2 -2
  268. package/dist/subscribers/Subscriber.d.mts +2 -2
  269. package/dist/subscribers/Subscriber.mjs +2 -2
  270. package/dist/subscribers/SubscriberBuilder.cjs +3 -3
  271. package/dist/subscribers/SubscriberBuilder.d.cts +3 -3
  272. package/dist/subscribers/SubscriberBuilder.d.mts +3 -3
  273. package/dist/subscribers/SubscriberBuilder.mjs +3 -3
  274. package/dist/subscribers/index.cjs +3 -3
  275. package/dist/subscribers/index.d.cts +5 -5
  276. package/dist/subscribers/index.d.mts +5 -5
  277. package/dist/subscribers/index.mjs +3 -3
  278. package/dist/{types-CVq20-fE.d.mts → types-DKf0juBf.d.mts} +1 -1
  279. package/dist/types.d.mts +1 -1
  280. package/package.json +15 -11
  281. package/src/Construct.ts +8 -0
  282. package/src/crons/Cron.ts +12 -3
  283. package/src/crons/CronBuilder.ts +85 -13
  284. package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +2 -2
  285. package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +112 -20
  286. package/src/endpoints/Endpoint.ts +208 -39
  287. package/src/endpoints/EndpointBuilder.ts +291 -21
  288. package/src/endpoints/EndpointFactory.ts +5 -1
  289. package/src/endpoints/HonoEndpointAdaptor.ts +144 -33
  290. package/src/endpoints/TestEndpointAdaptor.ts +116 -21
  291. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +8 -0
  292. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +29 -0
  293. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +626 -0
  294. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +9 -0
  295. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +757 -0
  296. package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +3 -1
  297. package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +1 -1
  298. package/src/endpoints/__tests__/Endpoint.spec.ts +19 -0
  299. package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +448 -0
  300. package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +51 -14
  301. package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +8 -8
  302. package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +11 -11
  303. package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +703 -0
  304. package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +632 -0
  305. package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +8 -0
  306. package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +1063 -0
  307. package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +4 -0
  308. package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +25 -0
  309. package/src/endpoints/audit.ts +87 -0
  310. package/src/endpoints/index.ts +1 -0
  311. package/src/endpoints/processAudits.ts +348 -0
  312. package/src/functions/AWSLambdaFunction.ts +125 -12
  313. package/src/functions/BaseFunctionBuilder.ts +98 -7
  314. package/src/functions/Function.ts +83 -15
  315. package/src/functions/FunctionBuilder.ts +217 -17
  316. package/src/functions/FunctionExecutionWrapper.ts +133 -2
  317. package/src/functions/TestFunctionAdaptor.ts +94 -8
  318. package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +82 -0
  319. package/src/functions/__tests__/Function.audits.spec.ts +393 -0
  320. package/src/functions/__tests__/Function.spec.ts +76 -0
  321. package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +54 -7
  322. package/src/publisher.ts +12 -1
  323. package/dist/AWSLambdaFunction-BTSGYZSx.mjs.map +0 -1
  324. package/dist/AWSLambdaFunction-Bel0NFTl.d.mts +0 -27
  325. package/dist/AWSLambdaFunction-DcI_77u8.cjs.map +0 -1
  326. package/dist/AWSLambdaFunction-xyCenuD7.d.cts +0 -27
  327. package/dist/AmazonApiGatewayEndpointAdaptor-BTqB3c1_.cjs.map +0 -1
  328. package/dist/AmazonApiGatewayEndpointAdaptor-vi0D3dWg.mjs.map +0 -1
  329. package/dist/BaseFunctionBuilder-DSqF1r3a.mjs.map +0 -1
  330. package/dist/BaseFunctionBuilder-bTDKP7bd.cjs.map +0 -1
  331. package/dist/Construct-XCGKof_O.cjs.map +0 -1
  332. package/dist/Construct-rZQg2yus.mjs.map +0 -1
  333. package/dist/Cron-BnO1uXhh.mjs.map +0 -1
  334. package/dist/Cron-CYIhd0VE.cjs.map +0 -1
  335. package/dist/CronBuilder-BxKwHCdJ.mjs.map +0 -1
  336. package/dist/CronBuilder-D_3AiPFO.cjs.map +0 -1
  337. package/dist/Endpoint-BdIGWw1H.cjs.map +0 -1
  338. package/dist/Endpoint-ChzcIFdV.mjs.map +0 -1
  339. package/dist/EndpointBuilder-Cx6pUcCn.d.mts +0 -55
  340. package/dist/EndpointBuilder-Xka8ULR1.d.cts +0 -55
  341. package/dist/EndpointBuilder-dmMiNRm9.cjs.map +0 -1
  342. package/dist/EndpointBuilder-yo40Qkf_.mjs.map +0 -1
  343. package/dist/EndpointFactory-CNbcr8u_.cjs.map +0 -1
  344. package/dist/EndpointFactory-LD3upVQK.mjs.map +0 -1
  345. package/dist/Function-Cl9fiR3a.mjs.map +0 -1
  346. package/dist/Function-DDaSfL_E.cjs.map +0 -1
  347. package/dist/FunctionBuilder-LQuBiqRc.cjs.map +0 -1
  348. package/dist/FunctionBuilder-fU1H7tFN.d.cts +0 -26
  349. package/dist/FunctionBuilder-udObIGV0.d.mts +0 -26
  350. package/dist/FunctionBuilder-vW12WFOw.mjs.map +0 -1
  351. package/dist/FunctionExecutionWrapper-BBIoHUt6.cjs +0 -42
  352. package/dist/FunctionExecutionWrapper-BBIoHUt6.cjs.map +0 -1
  353. package/dist/FunctionExecutionWrapper-DYBy9OP3.d.mts +0 -24
  354. package/dist/FunctionExecutionWrapper-Dtyhid1Q.mjs +0 -36
  355. package/dist/FunctionExecutionWrapper-Dtyhid1Q.mjs.map +0 -1
  356. package/dist/FunctionExecutionWrapper-Dwr2ZKzC.d.cts +0 -24
  357. package/dist/HonoEndpointAdaptor-Bc61IS6Q.cjs.map +0 -1
  358. package/dist/HonoEndpointAdaptor-NR3h5gml.mjs.map +0 -1
  359. package/dist/TestEndpointAdaptor-DA1D6l-U.cjs.map +0 -1
  360. package/dist/TestEndpointAdaptor-DpmNXp7G.mjs.map +0 -1
  361. package/dist/functions-HCoZ4YKF.mjs +0 -8
  362. package/dist/index-RtxMVjUZ.d.mts +0 -9
  363. package/dist/index-fiIGH95t.d.cts +0 -9
@@ -373,4 +373,86 @@ describe('AWSLambdaFunction', () => {
373
373
  });
374
374
 
375
375
  // Skipping timeout tests for now as middleware order needs to be adjusted
376
+
377
+ describe('database', () => {
378
+ // Mock database service
379
+ class MockDatabase {
380
+ async query(sql: string) {
381
+ return [{ id: '1', name: 'Test User' }];
382
+ }
383
+ }
384
+
385
+ class DatabaseService implements Service<'database', MockDatabase> {
386
+ serviceName = 'database' as const;
387
+ db = new MockDatabase();
388
+
389
+ async register() {
390
+ return this.db;
391
+ }
392
+ }
393
+
394
+ it('should inject database into function context', async () => {
395
+ const databaseService = new DatabaseService();
396
+ const handler = vi.fn(async ({ db }) => {
397
+ const result = await db.query('SELECT * FROM users');
398
+ return { users: result };
399
+ });
400
+
401
+ const outputSchema = z.object({
402
+ users: z.array(z.object({ id: z.string(), name: z.string() })),
403
+ });
404
+
405
+ const fn = new Function(
406
+ handler,
407
+ undefined,
408
+ undefined,
409
+ undefined,
410
+ outputSchema,
411
+ [],
412
+ logger,
413
+ undefined,
414
+ [],
415
+ undefined,
416
+ undefined,
417
+ databaseService,
418
+ );
419
+
420
+ const adaptor = new AWSLambdaFunction(envParser, fn);
421
+ const lambdaHandler = adaptor.handler;
422
+
423
+ const result = await lambdaHandler({}, createMockContext(), vi.fn());
424
+
425
+ expect(result).toEqual({ users: [{ id: '1', name: 'Test User' }] });
426
+ expect(handler).toHaveBeenCalledWith(
427
+ expect.objectContaining({
428
+ db: expect.any(MockDatabase),
429
+ }),
430
+ );
431
+ });
432
+
433
+ it('should have db as undefined when no database service is configured', async () => {
434
+ const handler = vi.fn(async ({ db }) => {
435
+ return { hasDb: db !== undefined };
436
+ });
437
+
438
+ const outputSchema = z.object({ hasDb: z.boolean() });
439
+
440
+ const fn = new Function(
441
+ handler,
442
+ undefined,
443
+ undefined,
444
+ undefined,
445
+ outputSchema,
446
+ [],
447
+ logger,
448
+ );
449
+
450
+ const adaptor = new AWSLambdaFunction(envParser, fn);
451
+ const lambdaHandler = adaptor.handler;
452
+
453
+ const result = await lambdaHandler({}, createMockContext(), vi.fn());
454
+
455
+ expect(result).toEqual({ hasDb: false });
456
+ });
457
+ });
376
458
  });
@@ -0,0 +1,393 @@
1
+ import type {
2
+ AuditRecord,
3
+ AuditStorage,
4
+ AuditableAction,
5
+ } from '@geekmidas/audit';
6
+ import { EnvironmentParser } from '@geekmidas/envkit';
7
+ import { ConsoleLogger } from '@geekmidas/logger/console';
8
+
9
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
10
+ import { z } from 'zod/v4';
11
+
12
+ import { AWSLambdaFunction } from '../AWSLambdaFunction';
13
+ import { FunctionBuilder } from '../FunctionBuilder';
14
+ import { TestFunctionAdaptor } from '../TestFunctionAdaptor';
15
+
16
+ // Define audit action types for type-safety
17
+ type UserAuditActions =
18
+ | AuditableAction<'user.processed', { userId: string; status: string }>
19
+ | AuditableAction<'user.failed', { userId: string; reason: string }>;
20
+
21
+ // Mock audit storage
22
+ class MockAuditStorage implements AuditStorage {
23
+ storedRecords: AuditRecord[] = [];
24
+
25
+ async write(records: AuditRecord[]): Promise<void> {
26
+ this.storedRecords.push(...records);
27
+ }
28
+
29
+ getDatabase() {
30
+ return undefined;
31
+ }
32
+ }
33
+
34
+ // Audit storage service - use unique names to avoid ServiceDiscovery caching
35
+ let serviceCounter = 0;
36
+ const createAuditStorageService = <T extends string>(
37
+ storage: MockAuditStorage,
38
+ name?: T,
39
+ ) => ({
40
+ serviceName: (name ?? `auditStorage-${++serviceCounter}`) as T extends string
41
+ ? T
42
+ : `auditStorage-${number}`,
43
+ async register() {
44
+ return storage;
45
+ },
46
+ });
47
+
48
+ describe('Function Audits', () => {
49
+ let logger: ConsoleLogger;
50
+ let envParser: EnvironmentParser<{}>;
51
+
52
+ beforeEach(() => {
53
+ logger = new ConsoleLogger();
54
+ envParser = new EnvironmentParser({});
55
+ vi.clearAllMocks();
56
+ });
57
+
58
+ describe('FunctionBuilder with auditor', () => {
59
+ it('should configure auditor storage service', () => {
60
+ const auditStorage = new MockAuditStorage();
61
+ const auditStorageService = createAuditStorageService(auditStorage);
62
+
63
+ const fn = new FunctionBuilder()
64
+ .auditor(auditStorageService)
65
+ .output(z.object({ result: z.string() }))
66
+ .handle(async () => {
67
+ return { result: 'success' };
68
+ });
69
+
70
+ expect(fn.auditorStorageService).toBe(auditStorageService);
71
+ });
72
+
73
+ it('should provide type-safe auditor via actions()', () => {
74
+ const auditStorage = new MockAuditStorage();
75
+ const auditStorageService = createAuditStorageService(auditStorage);
76
+
77
+ const fn = new FunctionBuilder()
78
+ .auditor(auditStorageService)
79
+ .actions<UserAuditActions>()
80
+ .output(z.object({ result: z.string() }))
81
+ .handle(async ({ auditor }) => {
82
+ // auditor should be typed with UserAuditActions
83
+ if (auditor) {
84
+ auditor.audit('user.processed', {
85
+ userId: '123',
86
+ status: 'active',
87
+ });
88
+ }
89
+ return { result: 'success' };
90
+ });
91
+
92
+ expect(fn.auditorStorageService).toBe(auditStorageService);
93
+ });
94
+ });
95
+
96
+ describe('TestFunctionAdaptor with auditor', () => {
97
+ it('should inject auditor and flush audits', async () => {
98
+ const auditStorage = new MockAuditStorage();
99
+ const auditStorageService = createAuditStorageService(auditStorage);
100
+
101
+ const fn = new FunctionBuilder()
102
+ .auditor(auditStorageService)
103
+ .actions<UserAuditActions>()
104
+ .input({ userId: z.string() })
105
+ .output(z.object({ processed: z.boolean() }))
106
+ .handle(async ({ input, auditor }) => {
107
+ if (auditor) {
108
+ auditor.audit('user.processed', {
109
+ userId: input.userId,
110
+ status: 'completed',
111
+ });
112
+ }
113
+ return { processed: true };
114
+ });
115
+
116
+ const adaptor = new TestFunctionAdaptor(fn);
117
+ const result = await adaptor.invoke({
118
+ input: { userId: 'user-123' },
119
+ services: {},
120
+ });
121
+
122
+ expect(result).toEqual({ processed: true });
123
+ expect(auditStorage.storedRecords).toHaveLength(1);
124
+ expect(auditStorage.storedRecords[0]).toMatchObject({
125
+ type: 'user.processed',
126
+ payload: { userId: 'user-123', status: 'completed' },
127
+ });
128
+ });
129
+
130
+ it('should work without auditor when not configured', async () => {
131
+ const fn = new FunctionBuilder()
132
+ .input({ value: z.number() })
133
+ .output(z.object({ doubled: z.number() }))
134
+ .handle(async (ctx) => {
135
+ // auditor should be undefined when not configured
136
+ // Use type assertion since it's not in the type when not configured
137
+ expect((ctx as any).auditor).toBeUndefined();
138
+ return { doubled: ctx.input.value * 2 };
139
+ });
140
+
141
+ const adaptor = new TestFunctionAdaptor(fn);
142
+ const result = await adaptor.invoke({
143
+ input: { value: 5 },
144
+ services: {},
145
+ });
146
+
147
+ expect(result).toEqual({ doubled: 10 });
148
+ });
149
+
150
+ it('should allow injecting custom auditor', async () => {
151
+ const customAuditStorage = new MockAuditStorage();
152
+ const auditStorageService = createAuditStorageService(customAuditStorage);
153
+
154
+ const fn = new FunctionBuilder()
155
+ .auditor(auditStorageService)
156
+ .actions<UserAuditActions>()
157
+ .input({ trigger: z.string() })
158
+ .output(z.object({ success: z.boolean() }))
159
+ .handle(async ({ auditor }) => {
160
+ if (auditor) {
161
+ auditor.audit('user.processed', {
162
+ userId: 'custom',
163
+ status: 'custom-audit',
164
+ });
165
+ }
166
+ return { success: true };
167
+ });
168
+
169
+ // Create a custom auditor with different storage
170
+ const testStorage = new MockAuditStorage();
171
+ const { DefaultAuditor } = await import('@geekmidas/audit');
172
+ const customAuditor = new DefaultAuditor<UserAuditActions>({
173
+ actor: { id: 'test', type: 'test' },
174
+ storage: testStorage,
175
+ metadata: { test: true },
176
+ });
177
+
178
+ const adaptor = new TestFunctionAdaptor(fn);
179
+ const result = await adaptor.invoke({
180
+ input: { trigger: 'test' },
181
+ services: {},
182
+ auditor: customAuditor,
183
+ });
184
+
185
+ expect(result).toEqual({ success: true });
186
+ // Custom auditor's storage should have the records
187
+ expect(testStorage.storedRecords).toHaveLength(1);
188
+ // Default storage should be empty
189
+ expect(customAuditStorage.storedRecords).toHaveLength(0);
190
+ });
191
+
192
+ it('should record multiple audits in single invocation', async () => {
193
+ const auditStorage = new MockAuditStorage();
194
+ const auditStorageService = createAuditStorageService(auditStorage);
195
+
196
+ const fn = new FunctionBuilder()
197
+ .auditor(auditStorageService)
198
+ .actions<UserAuditActions>()
199
+ .input({ userIds: z.array(z.string()) })
200
+ .output(z.object({ processed: z.number() }))
201
+ .handle(async ({ input, auditor }) => {
202
+ for (const userId of input.userIds) {
203
+ if (auditor) {
204
+ auditor.audit('user.processed', {
205
+ userId,
206
+ status: 'batch-processed',
207
+ });
208
+ }
209
+ }
210
+ return { processed: input.userIds.length };
211
+ });
212
+
213
+ const adaptor = new TestFunctionAdaptor(fn);
214
+ const result = await adaptor.invoke({
215
+ input: { userIds: ['user-1', 'user-2', 'user-3'] },
216
+ services: {},
217
+ });
218
+
219
+ expect(result).toEqual({ processed: 3 });
220
+ expect(auditStorage.storedRecords).toHaveLength(3);
221
+ expect(auditStorage.storedRecords.map((r) => r.payload)).toEqual([
222
+ { userId: 'user-1', status: 'batch-processed' },
223
+ { userId: 'user-2', status: 'batch-processed' },
224
+ { userId: 'user-3', status: 'batch-processed' },
225
+ ]);
226
+ });
227
+ });
228
+
229
+ describe('AWSLambdaFunction with auditor', () => {
230
+ const createMockLambdaContext = () => ({
231
+ functionName: 'test-function',
232
+ functionVersion: '1',
233
+ invokedFunctionArn: 'arn:aws:lambda:region:account:function:test',
234
+ memoryLimitInMB: '128',
235
+ awsRequestId: 'test-request-id',
236
+ logGroupName: '/aws/lambda/test',
237
+ logStreamName: '2023/01/01/[$LATEST]test',
238
+ getRemainingTimeInMillis: () => 30000,
239
+ done: vi.fn(),
240
+ fail: vi.fn(),
241
+ succeed: vi.fn(),
242
+ callbackWaitsForEmptyEventLoop: true,
243
+ });
244
+
245
+ it('should inject auditor in Lambda handler', async () => {
246
+ const auditStorage = new MockAuditStorage();
247
+ const auditStorageService = createAuditStorageService(auditStorage);
248
+
249
+ const fn = new FunctionBuilder()
250
+ .logger(logger)
251
+ .auditor(auditStorageService)
252
+ .actions<UserAuditActions>()
253
+ .input({ action: z.string() })
254
+ .output(z.object({ completed: z.boolean() }))
255
+ .handle(async ({ input, auditor }) => {
256
+ if (auditor) {
257
+ auditor.audit('user.processed', {
258
+ userId: 'lambda-user',
259
+ status: input.action,
260
+ });
261
+ }
262
+ return { completed: true };
263
+ });
264
+
265
+ const adaptor = new AWSLambdaFunction(envParser, fn);
266
+ const handler = adaptor.handler;
267
+
268
+ const result = await handler(
269
+ { action: 'lambda-action' },
270
+ createMockLambdaContext(),
271
+ vi.fn(),
272
+ );
273
+
274
+ expect(result).toEqual({ completed: true });
275
+ expect(auditStorage.storedRecords).toHaveLength(1);
276
+ expect(auditStorage.storedRecords[0]).toMatchObject({
277
+ type: 'user.processed',
278
+ payload: { userId: 'lambda-user', status: 'lambda-action' },
279
+ });
280
+ });
281
+
282
+ it('should work without auditor when not configured', async () => {
283
+ const fn = new FunctionBuilder()
284
+ .logger(logger)
285
+ .input({ value: z.number() })
286
+ .output(z.object({ result: z.number() }))
287
+ .handle(async (ctx) => {
288
+ // Use type assertion since auditor is not in type when not configured
289
+ expect((ctx as any).auditor).toBeUndefined();
290
+ return { result: ctx.input.value + 1 };
291
+ });
292
+
293
+ const adaptor = new AWSLambdaFunction(envParser, fn);
294
+ const handler = adaptor.handler;
295
+
296
+ const result = await handler(
297
+ { value: 10 },
298
+ createMockLambdaContext(),
299
+ vi.fn(),
300
+ );
301
+
302
+ expect(result).toEqual({ result: 11 });
303
+ });
304
+
305
+ it('should flush audits after successful execution', async () => {
306
+ const auditStorage = new MockAuditStorage();
307
+ const auditStorageService = createAuditStorageService(auditStorage);
308
+
309
+ const fn = new FunctionBuilder()
310
+ .logger(logger)
311
+ .auditor(auditStorageService)
312
+ .actions<UserAuditActions>()
313
+ .output(z.object({ status: z.string() }))
314
+ .handle(async ({ auditor }) => {
315
+ if (auditor) {
316
+ auditor.audit('user.processed', {
317
+ userId: 'flush-test',
318
+ status: 'pending',
319
+ });
320
+ }
321
+ return { status: 'ok' };
322
+ });
323
+
324
+ const adaptor = new AWSLambdaFunction(envParser, fn);
325
+ const handler = adaptor.handler;
326
+
327
+ await handler({}, createMockLambdaContext(), vi.fn());
328
+
329
+ // Records should be flushed
330
+ expect(auditStorage.storedRecords).toHaveLength(1);
331
+ });
332
+
333
+ it('should not flush audits if none were recorded', async () => {
334
+ const auditStorage = new MockAuditStorage();
335
+ const writeSpy = vi.spyOn(auditStorage, 'write');
336
+ const auditStorageService = createAuditStorageService(auditStorage);
337
+
338
+ const fn = new FunctionBuilder()
339
+ .logger(logger)
340
+ .auditor(auditStorageService)
341
+ .actions<UserAuditActions>()
342
+ .output(z.object({ status: z.string() }))
343
+ .handle(async () => {
344
+ // Don't record any audits
345
+ return { status: 'no-audits' };
346
+ });
347
+
348
+ const adaptor = new AWSLambdaFunction(envParser, fn);
349
+ const handler = adaptor.handler;
350
+
351
+ await handler({}, createMockLambdaContext(), vi.fn());
352
+
353
+ // write should not be called
354
+ expect(writeSpy).not.toHaveBeenCalled();
355
+ });
356
+ });
357
+
358
+ describe('Auditor with entity tracking', () => {
359
+ it('should record audits with entityId and table', async () => {
360
+ const auditStorage = new MockAuditStorage();
361
+ const auditStorageService = createAuditStorageService(auditStorage);
362
+
363
+ const fn = new FunctionBuilder()
364
+ .auditor(auditStorageService)
365
+ .actions<UserAuditActions>()
366
+ .input({ userId: z.string() })
367
+ .output(z.object({ success: z.boolean() }))
368
+ .handle(async ({ input, auditor }) => {
369
+ if (auditor) {
370
+ auditor.audit(
371
+ 'user.processed',
372
+ { userId: input.userId, status: 'active' },
373
+ { entityId: input.userId, table: 'users' },
374
+ );
375
+ }
376
+ return { success: true };
377
+ });
378
+
379
+ const adaptor = new TestFunctionAdaptor(fn);
380
+ await adaptor.invoke({
381
+ input: { userId: 'entity-123' },
382
+ services: {},
383
+ });
384
+
385
+ expect(auditStorage.storedRecords).toHaveLength(1);
386
+ expect(auditStorage.storedRecords[0]).toMatchObject({
387
+ type: 'user.processed',
388
+ entityId: 'entity-123',
389
+ table: 'users',
390
+ });
391
+ });
392
+ });
393
+ });
@@ -305,6 +305,82 @@ describe('Function', () => {
305
305
  // _timeout is protected, so we just verify the builder chain works
306
306
  expect(finalBuilder).toBeInstanceOf(FunctionBuilder);
307
307
  });
308
+
309
+ it('should set database service', () => {
310
+ const builder = new FunctionBuilder();
311
+
312
+ class MockDatabase {
313
+ async query(sql: string) {
314
+ return [];
315
+ }
316
+ }
317
+
318
+ const databaseService = {
319
+ serviceName: 'database' as const,
320
+ async register() {
321
+ return new MockDatabase();
322
+ },
323
+ };
324
+
325
+ const newBuilder = builder.database(databaseService);
326
+ expect(newBuilder['_databaseService']).toBe(databaseService);
327
+ });
328
+
329
+ it('should chain database with other methods', () => {
330
+ const builder = new FunctionBuilder();
331
+ const service = new TestService();
332
+ const logger = new ConsoleLogger();
333
+
334
+ class MockDatabase {
335
+ async query(sql: string) {
336
+ return [];
337
+ }
338
+ }
339
+
340
+ const databaseService = {
341
+ serviceName: 'database' as const,
342
+ async register() {
343
+ return new MockDatabase();
344
+ },
345
+ };
346
+
347
+ const finalBuilder = builder
348
+ .services([service])
349
+ .logger(logger)
350
+ .database(databaseService)
351
+ .output(z.object({ result: z.string() }));
352
+
353
+ expect(finalBuilder._services.length).toBe(1);
354
+ expect(finalBuilder['_databaseService']).toBe(databaseService);
355
+ expect(finalBuilder).toBeInstanceOf(FunctionBuilder);
356
+ });
357
+
358
+ it('should create function with database service', () => {
359
+ const builder = new FunctionBuilder();
360
+
361
+ class MockDatabase {
362
+ async query(sql: string) {
363
+ return [];
364
+ }
365
+ }
366
+
367
+ const databaseService = {
368
+ serviceName: 'database' as const,
369
+ async register() {
370
+ return new MockDatabase();
371
+ },
372
+ };
373
+
374
+ const fn = builder
375
+ .database(databaseService)
376
+ .output(z.object({ result: z.string() }))
377
+ .handle(async ({ db }) => {
378
+ // db should be available
379
+ return { result: 'success' };
380
+ });
381
+
382
+ expect(fn.databaseService).toBe(databaseService);
383
+ });
308
384
  });
309
385
  });
310
386
 
@@ -1,7 +1,21 @@
1
- import { describe, expect, it } from 'vitest';
1
+ import type { AuditRecord, AuditStorage } from '@geekmidas/audit';
2
2
  import { ConsoleLogger } from '@geekmidas/logger/console';
3
- import { FunctionBuilder } from '../FunctionBuilder';
4
3
  import type { Service } from '@geekmidas/services';
4
+ import { describe, expect, it } from 'vitest';
5
+ import { FunctionBuilder } from '../FunctionBuilder';
6
+
7
+ // In-memory audit storage for testing
8
+ class InMemoryAuditStorage implements AuditStorage {
9
+ records: AuditRecord[] = [];
10
+
11
+ async write(records: AuditRecord[]): Promise<void> {
12
+ this.records.push(...records);
13
+ }
14
+
15
+ async query(): Promise<AuditRecord[]> {
16
+ return this.records;
17
+ }
18
+ }
5
19
 
6
20
  const ServiceA = {
7
21
  serviceName: 'a' as const,
@@ -29,7 +43,7 @@ describe('FunctionBuilder - State Isolation', () => {
29
43
  const fn2 = f.handle(async () => ({}));
30
44
 
31
45
  expect(fn1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
32
- expect(fn2.services.map((s) => s.serviceName)).toEqual([]);
46
+ expect(fn2.services).toEqual([]);
33
47
  });
34
48
 
35
49
  it('should reset logger after handle() is called', () => {
@@ -53,7 +67,8 @@ describe('FunctionBuilder - State Isolation', () => {
53
67
  // Create first function (events array should be empty initially)
54
68
  const fn1 = f.handle(async () => ({}));
55
69
 
56
- // Verify state was reset
70
+ // Verify function was created and state was reset
71
+ expect(fn1).toBeDefined();
57
72
  expect((f as any)._events).toEqual([]);
58
73
  expect((f as any)._services).toEqual([]);
59
74
  });
@@ -64,7 +79,10 @@ describe('FunctionBuilder - State Isolation', () => {
64
79
  const outputSchema: any = { '~standard': { validate: () => ({}) } };
65
80
 
66
81
  // First function with schemas
67
- const fn1 = f.input(inputSchema).output(outputSchema).handle(async () => ({}));
82
+ const fn1 = f
83
+ .input(inputSchema)
84
+ .output(outputSchema)
85
+ .handle(async () => ({}));
68
86
 
69
87
  // Second function should not have schemas
70
88
  const fn2 = f.handle(async () => ({}));
@@ -130,13 +148,15 @@ describe('FunctionBuilder - State Isolation', () => {
130
148
  it('should create independent functions sequentially', () => {
131
149
  const f = new FunctionBuilder();
132
150
 
133
- const fn1 = f.services([ServiceA, ServiceB]).handle(async () => ({ result: 1 }));
151
+ const fn1 = f
152
+ .services([ServiceA, ServiceB])
153
+ .handle(async () => ({ result: 1 }));
134
154
  const fn2 = f.services([ServiceA]).handle(async () => ({ result: 2 }));
135
155
  const fn3 = f.handle(async () => ({ result: 3 }));
136
156
 
137
157
  expect(fn1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
138
158
  expect(fn2.services.map((s) => s.serviceName)).toEqual(['a']);
139
- expect(fn3.services.map((s) => s.serviceName)).toEqual([]);
159
+ expect(fn3.services).toEqual([]);
140
160
  });
141
161
  });
142
162
 
@@ -157,4 +177,31 @@ describe('FunctionBuilder - State Isolation', () => {
157
177
  expect((fn2 as any).publisherService).toBeUndefined();
158
178
  });
159
179
  });
180
+
181
+ describe('auditor isolation', () => {
182
+ const auditStorageService = {
183
+ serviceName: 'auditStorage' as const,
184
+ async register() {
185
+ return new InMemoryAuditStorage();
186
+ },
187
+ } satisfies Service<'auditStorage', InMemoryAuditStorage>;
188
+
189
+ it('should set auditor storage service', () => {
190
+ const f = new FunctionBuilder();
191
+
192
+ const fn1 = f.auditor(auditStorageService).handle(async () => ({}));
193
+
194
+ expect((fn1 as any).auditorStorageService).toBe(auditStorageService);
195
+ });
196
+
197
+ it('should reset auditor storage after handle() is called', () => {
198
+ const f = new FunctionBuilder();
199
+
200
+ const fn1 = f.auditor(auditStorageService).handle(async () => ({}));
201
+ const fn2 = f.handle(async () => ({}));
202
+
203
+ expect((fn1 as any).auditorStorageService).toBe(auditStorageService);
204
+ expect((fn2 as any).auditorStorageService).toBeUndefined();
205
+ });
206
+ });
160
207
  });
package/src/publisher.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { AuditStorage } from '@geekmidas/audit';
1
2
  import type { Logger } from '@geekmidas/logger';
2
3
  import type { StandardSchemaV1 } from '@standard-schema/spec';
3
4
 
@@ -67,8 +68,18 @@ export async function publishConstructEvents<
67
68
  OutSchema extends StandardSchemaV1 | undefined = undefined,
68
69
  TServiceName extends string = string,
69
70
  TServices extends Service[] = [],
71
+ TAuditStorageServiceName extends string = string,
72
+ TAuditStorage extends AuditStorage | undefined = undefined,
70
73
  >(
71
- construct: Construct<Logger, TServiceName, T, OutSchema, TServices>,
74
+ construct: Construct<
75
+ Logger,
76
+ TServiceName,
77
+ T,
78
+ OutSchema,
79
+ TServices,
80
+ TAuditStorageServiceName,
81
+ TAuditStorage
82
+ >,
72
83
  response: InferStandardSchema<OutSchema>,
73
84
  serviceDiscovery: ServiceDiscovery<any, any>,
74
85
  logger: Logger = construct.logger,