@geekmidas/constructs 9.0.2 → 10.0.0-alpha.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 (385) hide show
  1. package/README.md +71 -44
  2. package/dist/{AWSScheduledFunction-Bn99MceY.d.cts → AWSScheduledFunction-9bJS4WdJ.d.cts} +8 -3
  3. package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts.map → AWSScheduledFunction-9bJS4WdJ.d.cts.map} +1 -1
  4. package/dist/{AWSScheduledFunction-CufMMhGB.mjs → AWSScheduledFunction-BJjj8B5V.mjs} +3 -3
  5. package/dist/{AWSScheduledFunction-CufMMhGB.mjs.map → AWSScheduledFunction-BJjj8B5V.mjs.map} +1 -1
  6. package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts → AWSScheduledFunction-BO5iEMSh.d.mts} +9 -4
  7. package/dist/{AWSScheduledFunction-Bn99MceY.d.cts.map → AWSScheduledFunction-BO5iEMSh.d.mts.map} +1 -1
  8. package/dist/{AWSScheduledFunction-DbkDr8CA.cjs → AWSScheduledFunction-qu4ieRZR.cjs} +9 -9
  9. package/dist/{AWSScheduledFunction-DbkDr8CA.cjs.map → AWSScheduledFunction-qu4ieRZR.cjs.map} +1 -1
  10. package/dist/{Construct-_1wX7p_Y.d.cts → Construct-B-xc0SE9.d.mts} +27 -5
  11. package/dist/Construct-B-xc0SE9.d.mts.map +1 -0
  12. package/dist/{Construct-r0U2zBwW.mjs → Construct-CdhThxDI.mjs} +3 -2
  13. package/dist/Construct-CdhThxDI.mjs.map +1 -0
  14. package/dist/{Construct-DCMuYOox.d.mts → Construct-WhCXIOPV.d.cts} +29 -7
  15. package/dist/Construct-WhCXIOPV.d.cts.map +1 -0
  16. package/dist/{Construct-vXMZJgRp.cjs → Construct-roId57cU.cjs} +7 -43
  17. package/dist/Construct-roId57cU.cjs.map +1 -0
  18. package/dist/{lazyAccessors-DmTG8sQH.cjs → Endpoint-BBkV6l0k.cjs} +869 -1079
  19. package/dist/Endpoint-BBkV6l0k.cjs.map +1 -0
  20. package/dist/{Endpoint-DgfRslct.d.cts → Endpoint-BKR5QH6O.d.mts} +57 -8
  21. package/dist/Endpoint-BKR5QH6O.d.mts.map +1 -0
  22. package/dist/{Endpoint-CLPSIl6S.d.mts → Endpoint-BQ9O0P1w.d.cts} +58 -9
  23. package/dist/Endpoint-BQ9O0P1w.d.cts.map +1 -0
  24. package/dist/{lazyAccessors-DfqZR6C4.mjs → Endpoint-BTj58Gob.mjs} +840 -1003
  25. package/dist/Endpoint-BTj58Gob.mjs.map +1 -0
  26. package/dist/EndpointFactory-BejSTzbB.mjs +808 -0
  27. package/dist/EndpointFactory-BejSTzbB.mjs.map +1 -0
  28. package/dist/EndpointFactory-DYoGLaIT.cjs +850 -0
  29. package/dist/EndpointFactory-DYoGLaIT.cjs.map +1 -0
  30. package/dist/{HonoEndpointAdaptor-DJDT3PMx.mjs → HonoEndpointAdaptor-7aYNdqJq.mjs} +5 -4
  31. package/dist/HonoEndpointAdaptor-7aYNdqJq.mjs.map +1 -0
  32. package/dist/{HonoEndpointAdaptor-CkJENANP.cjs → HonoEndpointAdaptor-wMsCyMgt.cjs} +24 -23
  33. package/dist/HonoEndpointAdaptor-wMsCyMgt.cjs.map +1 -0
  34. package/dist/{Queue-DaxjwmOQ.d.cts → Queue-D6WeziRD.d.cts} +43 -4
  35. package/dist/Queue-D6WeziRD.d.cts.map +1 -0
  36. package/dist/{Queue-HBDf0fqz.d.mts → Queue-DpUeqdC8.d.mts} +43 -4
  37. package/dist/Queue-DpUeqdC8.d.mts.map +1 -0
  38. package/dist/{Subscriber-B69ngPwl.d.cts → Subscriber-4rBJgDKI.d.mts} +9 -4
  39. package/dist/{Subscriber-B69ngPwl.d.cts.map → Subscriber-4rBJgDKI.d.mts.map} +1 -1
  40. package/dist/{Subscriber-D8Xm-86W.d.mts → Subscriber-DVQowdyj.d.cts} +11 -6
  41. package/dist/Subscriber-DVQowdyj.d.cts.map +1 -0
  42. package/dist/{Topic-C5ZMfveW.d.cts → Topic-Ohx9dvWr.d.cts} +33 -2
  43. package/dist/Topic-Ohx9dvWr.d.cts.map +1 -0
  44. package/dist/{Topic-DT10AqHk.d.mts → Topic-cmy2jOUy.d.mts} +33 -2
  45. package/dist/Topic-cmy2jOUy.d.mts.map +1 -0
  46. package/dist/adaptors/aws.cjs +39 -26
  47. package/dist/adaptors/aws.cjs.map +1 -1
  48. package/dist/adaptors/aws.d.cts +24 -16
  49. package/dist/adaptors/aws.d.cts.map +1 -1
  50. package/dist/adaptors/aws.d.mts +25 -17
  51. package/dist/adaptors/aws.d.mts.map +1 -1
  52. package/dist/adaptors/aws.mjs +26 -14
  53. package/dist/adaptors/aws.mjs.map +1 -1
  54. package/dist/adaptors/hono.cjs +9 -6
  55. package/dist/adaptors/hono.d.cts +7 -6
  56. package/dist/adaptors/hono.d.cts.map +1 -1
  57. package/dist/adaptors/hono.d.mts +8 -7
  58. package/dist/adaptors/hono.d.mts.map +1 -1
  59. package/dist/adaptors/hono.mjs +9 -6
  60. package/dist/adaptors/testing.cjs +18 -14
  61. package/dist/adaptors/testing.cjs.map +1 -1
  62. package/dist/adaptors/testing.d.cts +7 -6
  63. package/dist/adaptors/testing.d.cts.map +1 -1
  64. package/dist/adaptors/testing.d.mts +11 -10
  65. package/dist/adaptors/testing.d.mts.map +1 -1
  66. package/dist/adaptors/testing.mjs +10 -7
  67. package/dist/adaptors/testing.mjs.map +1 -1
  68. package/dist/auth.cjs +165 -0
  69. package/dist/auth.cjs.map +1 -0
  70. package/dist/auth.d.cts +108 -0
  71. package/dist/auth.d.cts.map +1 -0
  72. package/dist/auth.d.mts +108 -0
  73. package/dist/auth.d.mts.map +1 -0
  74. package/dist/auth.mjs +164 -0
  75. package/dist/auth.mjs.map +1 -0
  76. package/dist/cache-0ANvRQnD.mjs +51 -0
  77. package/dist/cache-0ANvRQnD.mjs.map +1 -0
  78. package/dist/cache-3WSvAulx.cjs +57 -0
  79. package/dist/cache-3WSvAulx.cjs.map +1 -0
  80. package/dist/cache-CdQ7OLpR.d.cts +47 -0
  81. package/dist/cache-CdQ7OLpR.d.cts.map +1 -0
  82. package/dist/cache-DYoJFcfd.d.mts +47 -0
  83. package/dist/cache-DYoJFcfd.d.mts.map +1 -0
  84. package/dist/cache.cjs +3 -0
  85. package/dist/cache.d.cts +3 -0
  86. package/dist/cache.d.mts +3 -0
  87. package/dist/cache.mjs +3 -0
  88. package/dist/chunk-DWy1uDak.cjs +39 -0
  89. package/dist/clone-DblgEZZa.mjs +39 -0
  90. package/dist/clone-DblgEZZa.mjs.map +1 -0
  91. package/dist/clone-Dy0cR2SZ.cjs +45 -0
  92. package/dist/clone-Dy0cR2SZ.cjs.map +1 -0
  93. package/dist/construct-interface-BfjcOD_E.cjs +117 -0
  94. package/dist/construct-interface-BfjcOD_E.cjs.map +1 -0
  95. package/dist/construct-interface-BqwRNYA2.d.mts +131 -0
  96. package/dist/construct-interface-BqwRNYA2.d.mts.map +1 -0
  97. package/dist/construct-interface-D2nNkHUN.d.cts +131 -0
  98. package/dist/construct-interface-D2nNkHUN.d.cts.map +1 -0
  99. package/dist/construct-interface-Z4CpS8tK.mjs +81 -0
  100. package/dist/construct-interface-Z4CpS8tK.mjs.map +1 -0
  101. package/dist/construct-interface.cjs +8 -0
  102. package/dist/construct-interface.d.cts +2 -0
  103. package/dist/construct-interface.d.mts +2 -0
  104. package/dist/construct-interface.mjs +3 -0
  105. package/dist/credential.cjs +96 -0
  106. package/dist/credential.cjs.map +1 -0
  107. package/dist/credential.d.cts +61 -0
  108. package/dist/credential.d.cts.map +1 -0
  109. package/dist/credential.d.mts +61 -0
  110. package/dist/credential.d.mts.map +1 -0
  111. package/dist/credential.mjs +94 -0
  112. package/dist/credential.mjs.map +1 -0
  113. package/dist/crons/index.cjs +39 -37
  114. package/dist/crons/index.cjs.map +1 -1
  115. package/dist/crons/index.d.cts +21 -8
  116. package/dist/crons/index.d.cts.map +1 -1
  117. package/dist/crons/index.d.mts +29 -13
  118. package/dist/crons/index.d.mts.map +1 -1
  119. package/dist/crons/index.mjs +37 -36
  120. package/dist/crons/index.mjs.map +1 -1
  121. package/dist/database/kysely.cjs +181 -0
  122. package/dist/database/kysely.cjs.map +1 -0
  123. package/dist/database/kysely.d.cts +152 -0
  124. package/dist/database/kysely.d.cts.map +1 -0
  125. package/dist/database/kysely.d.mts +152 -0
  126. package/dist/database/kysely.d.mts.map +1 -0
  127. package/dist/database/kysely.mjs +180 -0
  128. package/dist/database/kysely.mjs.map +1 -0
  129. package/dist/email.cjs +59 -0
  130. package/dist/email.cjs.map +1 -0
  131. package/dist/email.d.cts +50 -0
  132. package/dist/email.d.cts.map +1 -0
  133. package/dist/email.d.mts +50 -0
  134. package/dist/email.d.mts.map +1 -0
  135. package/dist/email.mjs +58 -0
  136. package/dist/email.mjs.map +1 -0
  137. package/dist/endpoints/index.cjs +21 -747
  138. package/dist/endpoints/index.d.cts +7 -343
  139. package/dist/endpoints/index.d.mts +7 -342
  140. package/dist/endpoints/index.mjs +11 -738
  141. package/dist/file-server.cjs +154 -0
  142. package/dist/file-server.cjs.map +1 -0
  143. package/dist/file-server.d.cts +156 -0
  144. package/dist/file-server.d.cts.map +1 -0
  145. package/dist/file-server.d.mts +156 -0
  146. package/dist/file-server.d.mts.map +1 -0
  147. package/dist/file-server.mjs +152 -0
  148. package/dist/file-server.mjs.map +1 -0
  149. package/dist/functions/index.cjs +4 -2
  150. package/dist/functions/index.d.cts +3 -2
  151. package/dist/functions/index.d.mts +3 -2
  152. package/dist/functions/index.mjs +4 -2
  153. package/dist/{functions-B-qt91O7.mjs → functions-Cpff1uZH.mjs} +55 -51
  154. package/dist/functions-Cpff1uZH.mjs.map +1 -0
  155. package/dist/{functions-C8i1kCMM.cjs → functions-DukjG8ov.cjs} +62 -57
  156. package/dist/functions-DukjG8ov.cjs.map +1 -0
  157. package/dist/{index-BVs9DvIj.d.cts → index-BTvozlUD.d.cts} +36 -9
  158. package/dist/index-BTvozlUD.d.cts.map +1 -0
  159. package/dist/index-Cvz551AO.d.mts +419 -0
  160. package/dist/index-Cvz551AO.d.mts.map +1 -0
  161. package/dist/index-D5zqAJ2e.d.cts +419 -0
  162. package/dist/index-D5zqAJ2e.d.cts.map +1 -0
  163. package/dist/{index-DP6fqv0I.d.mts → index-L7pz0R0T.d.mts} +48 -19
  164. package/dist/index-L7pz0R0T.d.mts.map +1 -0
  165. package/dist/index.cjs +1 -1
  166. package/dist/index.d.cts +3 -3
  167. package/dist/index.d.mts +3 -3
  168. package/dist/index.mjs +1 -1
  169. package/dist/lazyAccessors-DM6HcXQk.mjs +175 -0
  170. package/dist/lazyAccessors-DM6HcXQk.mjs.map +1 -0
  171. package/dist/lazyAccessors-DrJj8NpA.cjs +223 -0
  172. package/dist/lazyAccessors-DrJj8NpA.cjs.map +1 -0
  173. package/dist/object-storage.cjs +48 -0
  174. package/dist/object-storage.cjs.map +1 -0
  175. package/dist/object-storage.d.cts +36 -0
  176. package/dist/object-storage.d.cts.map +1 -0
  177. package/dist/object-storage.d.mts +36 -0
  178. package/dist/object-storage.d.mts.map +1 -0
  179. package/dist/object-storage.mjs +47 -0
  180. package/dist/object-storage.mjs.map +1 -0
  181. package/dist/{processAudits-CKjjivyz.cjs → processAudits-Bc8rz6Ev.cjs} +3 -3
  182. package/dist/{processAudits-CKjjivyz.cjs.map → processAudits-Bc8rz6Ev.cjs.map} +1 -1
  183. package/dist/{processAudits-ySnizdMG.mjs → processAudits-D89tICM4.mjs} +1 -1
  184. package/dist/{processAudits-ySnizdMG.mjs.map → processAudits-D89tICM4.mjs.map} +1 -1
  185. package/dist/{publisher-BrFOF847.mjs → publisher-CGEo8UKD.mjs} +1 -1
  186. package/dist/{publisher-BrFOF847.mjs.map → publisher-CGEo8UKD.mjs.map} +1 -1
  187. package/dist/{publisher-lFQleddL.cjs → publisher-CqGsXB2X.cjs} +1 -1
  188. package/dist/{publisher-lFQleddL.cjs.map → publisher-CqGsXB2X.cjs.map} +1 -1
  189. package/dist/queue/index.cjs +92 -30
  190. package/dist/queue/index.cjs.map +1 -1
  191. package/dist/queue/index.d.cts +19 -4
  192. package/dist/queue/index.d.cts.map +1 -1
  193. package/dist/queue/index.d.mts +22 -6
  194. package/dist/queue/index.d.mts.map +1 -1
  195. package/dist/queue/index.mjs +90 -29
  196. package/dist/queue/index.mjs.map +1 -1
  197. package/dist/rest-api.cjs +187 -0
  198. package/dist/rest-api.cjs.map +1 -0
  199. package/dist/rest-api.d.cts +221 -0
  200. package/dist/rest-api.d.cts.map +1 -0
  201. package/dist/rest-api.d.mts +221 -0
  202. package/dist/rest-api.d.mts.map +1 -0
  203. package/dist/rest-api.mjs +186 -0
  204. package/dist/rest-api.mjs.map +1 -0
  205. package/dist/site.cjs +48 -0
  206. package/dist/site.cjs.map +1 -0
  207. package/dist/site.d.cts +101 -0
  208. package/dist/site.d.cts.map +1 -0
  209. package/dist/site.d.mts +101 -0
  210. package/dist/site.d.mts.map +1 -0
  211. package/dist/site.mjs +47 -0
  212. package/dist/site.mjs.map +1 -0
  213. package/dist/subscribers/index.cjs +35 -27
  214. package/dist/subscribers/index.cjs.map +1 -1
  215. package/dist/subscribers/index.d.cts +20 -5
  216. package/dist/subscribers/index.d.cts.map +1 -1
  217. package/dist/subscribers/index.d.mts +23 -7
  218. package/dist/subscribers/index.d.mts.map +1 -1
  219. package/dist/subscribers/index.mjs +34 -27
  220. package/dist/subscribers/index.mjs.map +1 -1
  221. package/dist/surfaceEnv-BFXEms2f.cjs +39 -0
  222. package/dist/surfaceEnv-BFXEms2f.cjs.map +1 -0
  223. package/dist/surfaceEnv-C3Ktahea.mjs +27 -0
  224. package/dist/surfaceEnv-C3Ktahea.mjs.map +1 -0
  225. package/dist/{telemetry-3vdxGn4q.d.mts → telemetry-C3L0iS28.d.cts} +2 -2
  226. package/dist/{telemetry-3vdxGn4q.d.mts.map → telemetry-C3L0iS28.d.cts.map} +1 -1
  227. package/dist/{telemetry-Dqx-D3F7.d.cts → telemetry-D7bVFLGi.d.mts} +2 -2
  228. package/dist/{telemetry-Dqx-D3F7.d.cts.map → telemetry-D7bVFLGi.d.mts.map} +1 -1
  229. package/dist/topic/index.cjs +56 -13
  230. package/dist/topic/index.cjs.map +1 -1
  231. package/dist/topic/index.d.cts +2 -2
  232. package/dist/topic/index.d.cts.map +1 -1
  233. package/dist/topic/index.d.mts +2 -2
  234. package/dist/topic/index.d.mts.map +1 -1
  235. package/dist/topic/index.mjs +54 -12
  236. package/dist/topic/index.mjs.map +1 -1
  237. package/dist/{types-BDNGr7pv.d.mts → types-BlAkSuGI.d.cts} +1 -1
  238. package/dist/{types-BDNGr7pv.d.mts.map → types-BlAkSuGI.d.cts.map} +1 -1
  239. package/dist/{types-BdAaYDvd.d.cts → types-aKksMEWL.d.mts} +1 -1
  240. package/dist/{types-BdAaYDvd.d.cts.map → types-aKksMEWL.d.mts.map} +1 -1
  241. package/dist/types.d.cts +1 -1
  242. package/dist/types.d.mts +1 -1
  243. package/package.json +155 -23
  244. package/CHANGELOG.md +0 -396
  245. package/dist/Construct-DCMuYOox.d.mts.map +0 -1
  246. package/dist/Construct-_1wX7p_Y.d.cts.map +0 -1
  247. package/dist/Construct-r0U2zBwW.mjs.map +0 -1
  248. package/dist/Construct-vXMZJgRp.cjs.map +0 -1
  249. package/dist/Endpoint-CLPSIl6S.d.mts.map +0 -1
  250. package/dist/Endpoint-DgfRslct.d.cts.map +0 -1
  251. package/dist/HonoEndpointAdaptor-CkJENANP.cjs.map +0 -1
  252. package/dist/HonoEndpointAdaptor-DJDT3PMx.mjs.map +0 -1
  253. package/dist/Queue-DaxjwmOQ.d.cts.map +0 -1
  254. package/dist/Queue-HBDf0fqz.d.mts.map +0 -1
  255. package/dist/Subscriber-D8Xm-86W.d.mts.map +0 -1
  256. package/dist/Topic-C5ZMfveW.d.cts.map +0 -1
  257. package/dist/Topic-DT10AqHk.d.mts.map +0 -1
  258. package/dist/endpoints/index.cjs.map +0 -1
  259. package/dist/endpoints/index.d.cts.map +0 -1
  260. package/dist/endpoints/index.d.mts.map +0 -1
  261. package/dist/endpoints/index.mjs.map +0 -1
  262. package/dist/functions-B-qt91O7.mjs.map +0 -1
  263. package/dist/functions-C8i1kCMM.cjs.map +0 -1
  264. package/dist/index-BVs9DvIj.d.cts.map +0 -1
  265. package/dist/index-DP6fqv0I.d.mts.map +0 -1
  266. package/dist/lazyAccessors-DfqZR6C4.mjs.map +0 -1
  267. package/dist/lazyAccessors-DmTG8sQH.cjs.map +0 -1
  268. package/src/Construct.ts +0 -204
  269. package/src/__benchmarks__/build-time-optimization.bench.ts +0 -274
  270. package/src/__benchmarks__/endpoint.bench.ts +0 -494
  271. package/src/__benchmarks__/fixtures.ts +0 -241
  272. package/src/__benchmarks__/hono-adaptor.bench.ts +0 -533
  273. package/src/__benchmarks__/hono-server.bench.ts +0 -249
  274. package/src/__benchmarks__/response-builder.bench.ts +0 -428
  275. package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +0 -319
  276. package/src/__benchmarks__/strategies/strategy-c-middleware.ts +0 -530
  277. package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +0 -567
  278. package/src/__tests__/Construct.environment.spec.ts +0 -704
  279. package/src/__tests__/publisher.setting.spec.ts +0 -508
  280. package/src/__tests__/publisher.spec.ts +0 -452
  281. package/src/adaptors/aws.ts +0 -6
  282. package/src/adaptors/hono.ts +0 -1
  283. package/src/adaptors/testing.ts +0 -11
  284. package/src/crons/AWSScheduledFunction.ts +0 -73
  285. package/src/crons/Cron.ts +0 -149
  286. package/src/crons/CronBuilder.ts +0 -271
  287. package/src/crons/__tests__/AWSScheduledFunction.spec.ts +0 -152
  288. package/src/crons/__tests__/Cron.spec.ts +0 -464
  289. package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +0 -227
  290. package/src/crons/index.ts +0 -12
  291. package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +0 -677
  292. package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +0 -105
  293. package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +0 -97
  294. package/src/endpoints/Authorizer.ts +0 -152
  295. package/src/endpoints/Endpoint.ts +0 -1287
  296. package/src/endpoints/EndpointBuilder.ts +0 -758
  297. package/src/endpoints/EndpointFactory.ts +0 -1148
  298. package/src/endpoints/HonoEndpointAdaptor.ts +0 -677
  299. package/src/endpoints/MswEndpointAdaptor.ts +0 -226
  300. package/src/endpoints/TestEndpointAdaptor.ts +0 -422
  301. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +0 -499
  302. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +0 -560
  303. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +0 -1304
  304. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +0 -626
  305. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +0 -732
  306. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +0 -296
  307. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +0 -951
  308. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.responseType.spec.ts +0 -111
  309. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +0 -307
  310. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +0 -629
  311. package/src/endpoints/__tests__/Authorizer.spec.ts +0 -286
  312. package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +0 -207
  313. package/src/endpoints/__tests__/Endpoint.headers.spec.ts +0 -187
  314. package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +0 -175
  315. package/src/endpoints/__tests__/Endpoint.spec.ts +0 -857
  316. package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +0 -448
  317. package/src/endpoints/__tests__/EndpointBuilder.responseType.spec.ts +0 -47
  318. package/src/endpoints/__tests__/EndpointBuilder.spec.ts +0 -523
  319. package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +0 -492
  320. package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +0 -509
  321. package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +0 -190
  322. package/src/endpoints/__tests__/EndpointFactory.spec.ts +0 -479
  323. package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +0 -155
  324. package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +0 -703
  325. package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +0 -632
  326. package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +0 -577
  327. package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +0 -1067
  328. package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +0 -317
  329. package/src/endpoints/__tests__/HonoEndpointAdaptor.pgboss-publisher.spec.ts +0 -289
  330. package/src/endpoints/__tests__/HonoEndpointAdaptor.responseType.spec.ts +0 -128
  331. package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +0 -1207
  332. package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +0 -211
  333. package/src/endpoints/__tests__/ResponseBuilder.spec.ts +0 -235
  334. package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +0 -602
  335. package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +0 -1044
  336. package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +0 -54
  337. package/src/endpoints/__tests__/endpoint-types.test.ts +0 -88
  338. package/src/endpoints/__tests__/helpers.spec.ts +0 -37
  339. package/src/endpoints/__tests__/lazyAccessors.spec.ts +0 -330
  340. package/src/endpoints/__tests__/processAudits.spec.ts +0 -631
  341. package/src/endpoints/audit.ts +0 -87
  342. package/src/endpoints/helpers.ts +0 -98
  343. package/src/endpoints/index.ts +0 -42
  344. package/src/endpoints/lazyAccessors.ts +0 -241
  345. package/src/endpoints/parseHonoQuery.ts +0 -16
  346. package/src/endpoints/parseQueryParams.ts +0 -32
  347. package/src/endpoints/processAudits.ts +0 -371
  348. package/src/endpoints/rls.ts +0 -67
  349. package/src/functions/AWSLambdaFunction.ts +0 -348
  350. package/src/functions/BaseFunctionBuilder.ts +0 -201
  351. package/src/functions/Function.ts +0 -238
  352. package/src/functions/FunctionBuilder.ts +0 -391
  353. package/src/functions/FunctionExecutionWrapper.ts +0 -216
  354. package/src/functions/TestFunctionAdaptor.ts +0 -217
  355. package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +0 -513
  356. package/src/functions/__tests__/Function.audits.spec.ts +0 -393
  357. package/src/functions/__tests__/Function.spec.ts +0 -477
  358. package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +0 -207
  359. package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +0 -480
  360. package/src/functions/index.ts +0 -12
  361. package/src/index.ts +0 -23
  362. package/src/publisher.ts +0 -93
  363. package/src/queue/AWSLambdaQueueAdaptor.ts +0 -162
  364. package/src/queue/Queue.ts +0 -128
  365. package/src/queue/QueueBuilder.ts +0 -115
  366. package/src/queue/TestQueueAdaptor.ts +0 -63
  367. package/src/queue/__tests__/QueueBuilder.spec.ts +0 -137
  368. package/src/queue/index.ts +0 -12
  369. package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +0 -342
  370. package/src/subscribers/Subscriber.ts +0 -117
  371. package/src/subscribers/SubscriberBuilder.ts +0 -186
  372. package/src/subscribers/TestSubscriberAdaptor.ts +0 -133
  373. package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +0 -1018
  374. package/src/subscribers/__tests__/Subscriber.spec.ts +0 -430
  375. package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +0 -652
  376. package/src/subscribers/index.ts +0 -6
  377. package/src/telemetry.ts +0 -103
  378. package/src/topic/Topic.ts +0 -103
  379. package/src/topic/TopicBuilder.ts +0 -51
  380. package/src/topic/__tests__/TopicBuilder.spec.ts +0 -82
  381. package/src/topic/index.ts +0 -11
  382. package/src/types.ts +0 -13
  383. package/test.ts +0 -91
  384. package/tsconfig.json +0 -9
  385. package/tsdown.config.ts +0 -34
@@ -1,477 +0,0 @@
1
- import { EnvironmentParser } from '@geekmidas/envkit';
2
-
3
- import { ConsoleLogger } from '@geekmidas/logger/console';
4
- import type { Service } from '@geekmidas/services';
5
- import { createMockContext } from '@geekmidas/testkit/aws';
6
- import { describe, expect, it } from 'vitest';
7
- import { z } from 'zod/v4';
8
- import { ConstructType } from '../../Construct';
9
- import { AWSLambdaFunction } from '../AWSLambdaFunction';
10
- import { Function, FunctionFactory, type FunctionHandler } from '../Function';
11
- import { FunctionBuilder } from '../FunctionBuilder';
12
- import { TestFunctionAdaptor } from '../TestFunctionAdaptor';
13
-
14
- // Mock service for testing
15
- class TestService implements Service<'TestService', TestService> {
16
- serviceName = 'TestService' as const;
17
- static serviceName = 'TestService';
18
-
19
- async register() {
20
- return this;
21
- }
22
- }
23
-
24
- class AnotherTestService
25
- implements Service<'AnotherTestService', AnotherTestService>
26
- {
27
- serviceName = 'AnotherTestService' as const;
28
- static serviceName = 'AnotherTestService';
29
-
30
- async register() {
31
- return this;
32
- }
33
- }
34
-
35
- describe('Function', () => {
36
- describe('FunctionFactory', () => {
37
- it('should create a function factory with default services', () => {
38
- const service1 = new TestService();
39
- const service2 = new AnotherTestService();
40
- const factory = new FunctionFactory([service1, service2]);
41
-
42
- expect(factory).toBeDefined();
43
- });
44
-
45
- it('should deduplicate services by name', () => {
46
- const service1 = new TestService();
47
- const service2 = new TestService(); // Duplicate
48
- const service3 = new AnotherTestService();
49
-
50
- const factory = new FunctionFactory([service1, service2, service3]);
51
- // Internal defaultServices should have only 2 unique services
52
- expect(factory.defaultServices.length).toBe(2);
53
- });
54
-
55
- it('should add services using services() method', () => {
56
- const service1 = new TestService();
57
- const factory = new FunctionFactory([]);
58
-
59
- const newFactory = factory.services([service1]);
60
- expect(newFactory).toBeDefined();
61
- expect(newFactory.defaultServices.length).toBe(1);
62
- });
63
-
64
- it('should merge services when chaining services() calls', () => {
65
- const service1 = new TestService();
66
- const service2 = new AnotherTestService();
67
- const factory = new FunctionFactory([service1]);
68
-
69
- const newFactory = factory.services([service2]);
70
- expect(newFactory.defaultServices.length).toBe(2);
71
- });
72
-
73
- it('should set custom logger using logger() method', () => {
74
- const customLogger = new ConsoleLogger();
75
- const factory = new FunctionFactory([]);
76
-
77
- const newFactory = factory.logger(customLogger);
78
- expect(newFactory.defaultLogger).toBe(customLogger);
79
- });
80
- });
81
-
82
- describe('Function class', () => {
83
- it('should create a function instance', () => {
84
- const handler: FunctionHandler = async () => {
85
- return { result: 'success' };
86
- };
87
-
88
- const fn = new Function(handler);
89
- expect(fn).toBeDefined();
90
- expect(fn.__IS_FUNCTION__).toBe(true);
91
- expect(fn.timeout).toBe(30000); // Default timeout
92
- expect(fn.type).toBe(ConstructType.Function);
93
- });
94
-
95
- it('should create a function with custom timeout', () => {
96
- const handler: FunctionHandler = async () => ({ result: 'success' });
97
- const fn = new Function(handler, 60000);
98
-
99
- expect(fn.timeout).toBe(60000);
100
- });
101
-
102
- it('should create a function with input and output schemas', () => {
103
- const inputSchema = z.object({ name: z.string() });
104
- const outputSchema = z.object({ message: z.string() });
105
- const handler: FunctionHandler = async () => ({ message: 'Hello' });
106
-
107
- const fn = new Function(
108
- handler,
109
- 30000,
110
- ConstructType.Function,
111
- inputSchema,
112
- outputSchema,
113
- );
114
-
115
- expect(fn.input).toBe(inputSchema);
116
- expect(fn.outputSchema).toBe(outputSchema);
117
- });
118
-
119
- it('should detect function instances using isFunction', () => {
120
- const handler: FunctionHandler = async () => ({ result: 'success' });
121
- const fn = new Function(handler);
122
-
123
- expect(Function.isFunction(fn)).toBe(true);
124
- expect(Function.isFunction({})).toBeFalsy();
125
- expect(Function.isFunction(null)).toBeFalsy();
126
- expect(Function.isFunction(undefined)).toBeFalsy();
127
- expect(Function.isFunction({ __IS_FUNCTION__: false })).toBe(false);
128
- expect(Function.isFunction({ __IS_FUNCTION__: true })).toBe(false);
129
- });
130
- });
131
-
132
- describe('FunctionBuilder', () => {
133
- describe('isStandardSchemaV1', () => {
134
- it('should identify standard schema v1', () => {
135
- const zodSchema = z.string();
136
- expect(FunctionBuilder.isStandardSchemaV1(zodSchema)).toBe(true);
137
- });
138
-
139
- it('should return false for non-standard schemas', () => {
140
- expect(FunctionBuilder.isStandardSchemaV1({})).toBeFalsy();
141
- expect(FunctionBuilder.isStandardSchemaV1('string')).toBeFalsy();
142
- expect(FunctionBuilder.isStandardSchemaV1(123)).toBeFalsy();
143
- expect(FunctionBuilder.isStandardSchemaV1(true)).toBeFalsy();
144
- expect(
145
- FunctionBuilder.isStandardSchemaV1({ '~standard': {} }),
146
- ).toBeFalsy();
147
- expect(
148
- FunctionBuilder.isStandardSchemaV1({
149
- '~standard': { validate: 'not a function' },
150
- }),
151
- ).toBeFalsy();
152
- });
153
- });
154
-
155
- describe('parseComposableStandardSchema', () => {
156
- it('should parse standard schema', async () => {
157
- const schema = z.object({
158
- name: z.string(),
159
- age: z.number().optional(),
160
- });
161
-
162
- const data = { name: 'John', age: 30 };
163
- const result = await FunctionBuilder.parseComposableStandardSchema(
164
- data,
165
- schema,
166
- );
167
- expect(result).toEqual({ name: 'John', age: 30 });
168
- });
169
-
170
- it('should parse composed schema', async () => {
171
- const schema = {
172
- name: z.string(),
173
- age: z.number().optional(),
174
- };
175
-
176
- const data = { name: 'John', age: 30 };
177
- const result = await FunctionBuilder.parseComposableStandardSchema(
178
- data,
179
- schema,
180
- );
181
- expect(result).toEqual({ name: 'John', age: 30 });
182
- });
183
-
184
- it('should throw validation errors for invalid data', async () => {
185
- const schema = z.object({
186
- name: z.string(),
187
- age: z.number(),
188
- });
189
-
190
- const invalidData = { name: 'John', age: 'not a number' };
191
- await expect(
192
- FunctionBuilder.parseComposableStandardSchema(invalidData, schema),
193
- ).rejects.toThrow();
194
- });
195
-
196
- it('should throw validation errors for composed schema with invalid data', async () => {
197
- const schema = {
198
- name: z.string(),
199
- email: z.string().email(),
200
- };
201
-
202
- const invalidData = { name: 'John', email: 'invalid-email' };
203
- await expect(
204
- FunctionBuilder.parseComposableStandardSchema(invalidData, schema),
205
- ).rejects.toThrow();
206
- });
207
-
208
- it('should handle nested paths in composed schemas', async () => {
209
- const schema = {
210
- 'user.name': z.string(),
211
- 'user.email': z.string().email(),
212
- };
213
-
214
- const data = {
215
- user: {
216
- name: 'John',
217
- email: 'john@example.com',
218
- },
219
- };
220
-
221
- const result = await FunctionBuilder.parseComposableStandardSchema(
222
- data,
223
- schema,
224
- );
225
- expect(result).toEqual({
226
- 'user.name': 'John',
227
- 'user.email': 'john@example.com',
228
- });
229
- });
230
- });
231
-
232
- describe('builder methods', () => {
233
- it('should create a builder with default type', () => {
234
- const builder = new FunctionBuilder();
235
- expect(builder.type).toBe(ConstructType.Function);
236
- });
237
-
238
- it('should add services', () => {
239
- const service = new TestService();
240
- const builder = new FunctionBuilder().services([service]);
241
-
242
- expect(builder._services.length).toBe(1);
243
- expect(builder._services[0]).toBe(service);
244
- });
245
-
246
- it('should deduplicate services when adding', () => {
247
- const builder = new FunctionBuilder();
248
- const service1 = new TestService();
249
- const service2 = new TestService(); // Same service name
250
-
251
- const newBuilder = builder.services([service1, service2]);
252
- expect(newBuilder._services.length).toBe(1);
253
- });
254
-
255
- it('should set logger', () => {
256
- const builder = new FunctionBuilder();
257
- const customLogger = new ConsoleLogger();
258
-
259
- const newBuilder = builder.logger(customLogger);
260
- expect(newBuilder._logger).toBe(customLogger);
261
- });
262
-
263
- it('should set timeout', () => {
264
- const builder = new FunctionBuilder();
265
- const newBuilder = builder.timeout(60000);
266
-
267
- // We can't access _timeout directly as it's protected
268
- // But we can verify the method returns the builder for chaining
269
- expect(newBuilder).toBeInstanceOf(FunctionBuilder);
270
- });
271
-
272
- it('should set output schema', () => {
273
- const builder = new FunctionBuilder();
274
- const outputSchema = z.object({ result: z.string() });
275
-
276
- const newBuilder = builder.output(outputSchema);
277
- expect(newBuilder.outputSchema).toBe(outputSchema);
278
- });
279
-
280
- it('should set input schema', () => {
281
- const builder = new FunctionBuilder();
282
- const inputSchema = z.object({ data: z.string() });
283
-
284
- const newBuilder = builder.input(inputSchema);
285
- expect(newBuilder.inputSchema).toBe(inputSchema);
286
- });
287
-
288
- it('should chain multiple builder methods', () => {
289
- const builder = new FunctionBuilder();
290
- const service = new TestService();
291
- const logger = new ConsoleLogger();
292
- const inputSchema = z.object({ data: z.string() });
293
- const outputSchema = z.object({ result: z.string() });
294
-
295
- const finalBuilder = builder
296
- .services([service])
297
- .logger(logger)
298
- .timeout(45000)
299
- .input(inputSchema)
300
- .output(outputSchema);
301
-
302
- expect(finalBuilder._services.length).toBe(1);
303
- expect(finalBuilder._logger).toBe(logger);
304
- // _timeout is protected, so we just verify the builder chain works
305
- expect(finalBuilder).toBeInstanceOf(FunctionBuilder);
306
- });
307
-
308
- it('should set database service', () => {
309
- const builder = new FunctionBuilder();
310
-
311
- class MockDatabase {
312
- async query(_sql: string) {
313
- return [];
314
- }
315
- }
316
-
317
- const databaseService = {
318
- serviceName: 'database' as const,
319
- async register() {
320
- return new MockDatabase();
321
- },
322
- };
323
-
324
- const newBuilder = builder.database(databaseService);
325
- expect(newBuilder._databaseService).toBe(databaseService);
326
- });
327
-
328
- it('should chain database with other methods', () => {
329
- const builder = new FunctionBuilder();
330
- const service = new TestService();
331
- const logger = new ConsoleLogger();
332
-
333
- class MockDatabase {
334
- async query(_sql: string) {
335
- return [];
336
- }
337
- }
338
-
339
- const databaseService = {
340
- serviceName: 'database' as const,
341
- async register() {
342
- return new MockDatabase();
343
- },
344
- };
345
-
346
- const finalBuilder = builder
347
- .services([service])
348
- .logger(logger)
349
- .database(databaseService)
350
- .output(z.object({ result: z.string() }));
351
-
352
- expect(finalBuilder._services.length).toBe(1);
353
- expect(finalBuilder._databaseService).toBe(databaseService);
354
- expect(finalBuilder).toBeInstanceOf(FunctionBuilder);
355
- });
356
-
357
- it('should create function with database service', () => {
358
- const builder = new FunctionBuilder();
359
-
360
- class MockDatabase {
361
- async query(_sql: string) {
362
- return [];
363
- }
364
- }
365
-
366
- const databaseService = {
367
- serviceName: 'database' as const,
368
- async register() {
369
- return new MockDatabase();
370
- },
371
- };
372
-
373
- const fn = builder
374
- .database(databaseService)
375
- .output(z.object({ result: z.string() }))
376
- .handle(async ({ db }) => {
377
- // db should be available
378
- return { result: 'success' };
379
- });
380
-
381
- expect(fn.databaseService).toBe(databaseService);
382
- });
383
- });
384
- });
385
-
386
- describe('FunctionHandler type', () => {
387
- it('should handle function with full context', async () => {
388
- const handler: FunctionHandler<
389
- { name: z.ZodString },
390
- [TestService],
391
- ConsoleLogger,
392
- z.ZodObject<{ message: z.ZodString }>
393
- > = async ({ services, logger, input }) => {
394
- expect(services).toBeDefined();
395
- expect(logger).toBeDefined();
396
- expect(input).toBeDefined();
397
- return { message: `Hello ${input.name}` };
398
- };
399
-
400
- const result = await handler({
401
- services: { TestService: new TestService() },
402
- logger: new ConsoleLogger(),
403
- input: {
404
- name: 'John',
405
- },
406
- });
407
-
408
- expect(result).toEqual({ message: 'Hello John' });
409
- });
410
- });
411
-
412
- describe('Function Adaptors Integration', () => {
413
- describe('TestFunctionAdaptor', () => {
414
- it('should work with TestFunctionAdaptor for testing', async () => {
415
- const inputSchema = z.object({ name: z.string() });
416
- const outputSchema = z.object({ greeting: z.string() });
417
-
418
- const fn = new Function(
419
- async ({ input }) => ({
420
- greeting: `Hello ${input.name}!`,
421
- }),
422
- undefined,
423
- undefined,
424
- inputSchema,
425
- outputSchema,
426
- [],
427
- );
428
-
429
- const adaptor = new TestFunctionAdaptor(fn);
430
-
431
- const result = await adaptor.invoke({
432
- services: {},
433
- input: { name: 'Integration Test' },
434
- });
435
-
436
- expect(result).toEqual({
437
- greeting: 'Hello Integration Test!',
438
- });
439
- });
440
- });
441
-
442
- describe('AWSLambdaFunction', () => {
443
- it('should work with AWSLambdaFunction for AWS Lambda', async () => {
444
- const inputSchema = { message: z.string() };
445
- const outputSchema = z.object({ processed: z.string() });
446
-
447
- const fn = new Function(
448
- async ({ logger, ...rest }) => {
449
- logger.info('Processing message');
450
- return { processed: `Processed: ${rest.input.message}` };
451
- },
452
- undefined,
453
- undefined,
454
- inputSchema,
455
- outputSchema,
456
- [],
457
- new ConsoleLogger(),
458
- );
459
-
460
- const adaptor = new AWSLambdaFunction(new EnvironmentParser({}), fn);
461
- const handler = adaptor.handler.bind(adaptor);
462
-
463
- const mockContext = createMockContext();
464
-
465
- const result = await handler(
466
- { message: 'Hello Lambda!' },
467
- mockContext,
468
- () => {},
469
- );
470
-
471
- expect(result).toEqual({
472
- processed: 'Processed: Hello Lambda!',
473
- });
474
- });
475
- });
476
- });
477
- });
@@ -1,207 +0,0 @@
1
- import type { AuditRecord, AuditStorage } from '@geekmidas/audit';
2
- import { ConsoleLogger } from '@geekmidas/logger/console';
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
- }
19
-
20
- const ServiceA = {
21
- serviceName: 'a' as const,
22
- async register() {
23
- return { test: () => 'a' };
24
- },
25
- } satisfies Service<'a', any>;
26
-
27
- const ServiceB = {
28
- serviceName: 'b' as const,
29
- async register() {
30
- return { test: () => 'b' };
31
- },
32
- } satisfies Service<'b', any>;
33
-
34
- describe('FunctionBuilder - State Isolation', () => {
35
- describe('singleton instance state reset', () => {
36
- it('should reset services after handle() is called', () => {
37
- const f = new FunctionBuilder();
38
-
39
- // First function with ServiceA and ServiceB
40
- const fn1 = f.services([ServiceA, ServiceB]).handle(async () => ({}));
41
-
42
- // Second function should not have any services from first
43
- const fn2 = f.handle(async () => ({}));
44
-
45
- expect(fn1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
46
- expect(fn2.services).toEqual([]);
47
- });
48
-
49
- it('should reset logger after handle() is called', () => {
50
- const f = new FunctionBuilder();
51
- const customLogger = new ConsoleLogger({ app: 'custom' });
52
-
53
- // First function with custom logger
54
- const fn1 = f.logger(customLogger).handle(async () => ({}));
55
-
56
- // Second function should have default logger (not the custom one)
57
- const fn2 = f.handle(async () => ({}));
58
-
59
- expect(fn1.logger).toBe(customLogger);
60
- expect(fn2.logger).not.toBe(customLogger);
61
- expect(fn2.logger).toBeInstanceOf(ConsoleLogger);
62
- });
63
-
64
- it('should reset events after handle() is called', () => {
65
- const f = new FunctionBuilder();
66
-
67
- // Create first function (events array should be empty initially)
68
- const fn1 = f.handle(async () => ({}));
69
-
70
- // Verify function was created and state was reset
71
- expect(fn1).toBeDefined();
72
- expect((f as any)._events).toEqual([]);
73
- expect((f as any)._services).toEqual([]);
74
- });
75
-
76
- it('should reset input/output schemas after handle() is called', () => {
77
- const f = new FunctionBuilder();
78
- const inputSchema: any = { '~standard': { validate: () => ({}) } };
79
- const outputSchema: any = { '~standard': { validate: () => ({}) } };
80
-
81
- // First function with schemas
82
- const fn1 = f
83
- .input(inputSchema)
84
- .output(outputSchema)
85
- .handle(async () => ({}));
86
-
87
- // Second function should not have schemas
88
- const fn2 = f.handle(async () => ({}));
89
-
90
- expect(fn1.input).toBe(inputSchema);
91
- expect(fn1.outputSchema).toBe(outputSchema);
92
- expect(fn2.input).toBeUndefined();
93
- expect(fn2.outputSchema).toBeUndefined();
94
- });
95
-
96
- it('should reset timeout after handle() is called', () => {
97
- const f = new FunctionBuilder();
98
-
99
- // First function with custom timeout
100
- const fn1 = f.timeout(5000).handle(async () => ({}));
101
-
102
- // Second function should have default timeout (30000)
103
- const fn2 = f.handle(async () => ({}));
104
-
105
- expect(fn1.timeout).toBe(5000);
106
- expect(fn2.timeout).toBe(30000); // Default timeout
107
- });
108
- });
109
-
110
- describe('method chaining before handle()', () => {
111
- it('should accumulate services when chaining', () => {
112
- const f = new FunctionBuilder();
113
-
114
- const fn = f
115
- .services([ServiceA])
116
- .services([ServiceB])
117
- .handle(async () => ({}));
118
-
119
- expect(fn.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
120
- });
121
-
122
- it('should not share references between different builder chains', () => {
123
- const f = new FunctionBuilder();
124
-
125
- // Start two separate chains
126
- const builder1 = f.services([ServiceA]);
127
- const builder2 = f.services([ServiceB]);
128
-
129
- // They should be the same instance (singleton)
130
- expect(builder1).toBe(builder2);
131
- expect(builder1).toBe(f);
132
-
133
- // But after handle, state is reset
134
- const fn1 = builder1.handle(async () => ({}));
135
-
136
- // Now builder2 should have reset state
137
- expect((builder2 as any)._services).toEqual([]);
138
-
139
- // Add services again
140
- const fn2 = builder2.services([ServiceB]).handle(async () => ({}));
141
-
142
- expect(fn1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
143
- expect(fn2.services.map((s) => s.serviceName)).toEqual(['b']);
144
- });
145
- });
146
-
147
- describe('sequential function creation', () => {
148
- it('should create independent functions sequentially', () => {
149
- const f = new FunctionBuilder();
150
-
151
- const fn1 = f
152
- .services([ServiceA, ServiceB])
153
- .handle(async () => ({ result: 1 }));
154
- const fn2 = f.services([ServiceA]).handle(async () => ({ result: 2 }));
155
- const fn3 = f.handle(async () => ({ result: 3 }));
156
-
157
- expect(fn1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
158
- expect(fn2.services.map((s) => s.serviceName)).toEqual(['a']);
159
- expect(fn3.services).toEqual([]);
160
- });
161
- });
162
-
163
- describe('publisher isolation', () => {
164
- it('should reset publisher after handle() is called', () => {
165
- const f = new FunctionBuilder();
166
- const mockPublisher: any = {
167
- serviceName: 'publisher',
168
- async register() {
169
- return { publish: () => {} };
170
- },
171
- };
172
-
173
- const fn1 = f.publisher(mockPublisher).handle(async () => ({}));
174
- const fn2 = f.handle(async () => ({}));
175
-
176
- expect((fn1 as any).publisherService).toBe(mockPublisher);
177
- expect((fn2 as any).publisherService).toBeUndefined();
178
- });
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
- });
207
- });