@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,464 +0,0 @@
1
- import { ConsoleLogger } from '@geekmidas/logger/console';
2
- import type { Service } from '@geekmidas/services';
3
- import { describe, expect, it, vi } from 'vitest';
4
- import { z } from 'zod';
5
- import { ConstructType } from '../../Construct';
6
- import { Cron, type CronExpression, type RateExpression } from '../Cron';
7
- import { CronBuilder } from '../CronBuilder';
8
-
9
- // Mock service for testing
10
- class MockService implements Service<'MockService', MockService> {
11
- serviceName = 'MockService' as const;
12
-
13
- async register() {
14
- return this;
15
- }
16
-
17
- getValue() {
18
- return 'mock-value';
19
- }
20
- }
21
-
22
- describe('Cron', () => {
23
- describe('Cron class', () => {
24
- it('should create a Cron instance with basic handler', () => {
25
- const handler = vi.fn().mockResolvedValue({ success: true });
26
- const cron = new Cron(handler);
27
-
28
- expect(cron).toBeInstanceOf(Cron);
29
- expect(cron.type).toBe(ConstructType.Cron);
30
- expect(cron.timeout).toBe(30000); // Default timeout
31
- // The handler is stored in the protected fn property
32
- });
33
-
34
- it('should create a Cron instance with timeout', () => {
35
- const handler = vi.fn().mockResolvedValue({ data: 'test' });
36
- const timeout = 60000;
37
- const cron = new Cron(handler, timeout);
38
-
39
- expect(cron.timeout).toBe(timeout);
40
- });
41
-
42
- it('should create a Cron instance with schedule expression', () => {
43
- const handler = vi.fn();
44
- const schedule: CronExpression = 'cron(0 12 * * MON)';
45
- const cron = new Cron(handler, undefined, schedule);
46
-
47
- expect(cron).toBeInstanceOf(Cron);
48
- expect(cron.type).toBe(ConstructType.Cron);
49
- // Schedule is protected, so we can't directly test it, but it should be set
50
- });
51
-
52
- it('should create a Cron instance with input schema', () => {
53
- const inputSchema = z.object({
54
- id: z.string(),
55
- count: z.number(),
56
- });
57
-
58
- const handler = vi.fn().mockImplementation(async ({ input }) => {
59
- return { processed: input.id };
60
- });
61
-
62
- const cron = new Cron(handler, undefined, undefined, inputSchema);
63
-
64
- expect(cron).toBeInstanceOf(Cron);
65
- expect(cron.input).toBe(inputSchema);
66
- });
67
-
68
- it('should create a Cron instance with output schema', () => {
69
- const outputSchema = z.object({
70
- result: z.string(),
71
- timestamp: z.number(),
72
- });
73
-
74
- const handler = vi.fn().mockResolvedValue({
75
- result: 'success',
76
- timestamp: Date.now(),
77
- });
78
-
79
- const cron = new Cron(
80
- handler,
81
- undefined,
82
- undefined,
83
- undefined,
84
- outputSchema,
85
- );
86
-
87
- expect(cron).toBeInstanceOf(Cron);
88
- expect(cron.outputSchema).toBe(outputSchema);
89
- });
90
-
91
- it('should create a Cron instance with services', () => {
92
- const mockService = new MockService();
93
- const services = [mockService];
94
-
95
- const handler = vi.fn().mockImplementation(async ({ services }) => {
96
- return { value: services.MockService.getValue() };
97
- });
98
-
99
- const cron = new Cron(
100
- handler,
101
- undefined,
102
- undefined,
103
- undefined,
104
- undefined,
105
- services,
106
- );
107
-
108
- expect(cron).toBeInstanceOf(Cron);
109
- expect(cron.services).toEqual(services);
110
- });
111
-
112
- it('should create a Cron instance with custom logger', () => {
113
- const customLogger = new ConsoleLogger();
114
-
115
- const handler = vi.fn().mockImplementation(async ({ logger }) => {
116
- logger.info('Cron executed');
117
- return { logged: true };
118
- });
119
-
120
- const cron = new Cron(
121
- handler,
122
- undefined,
123
- undefined,
124
- undefined,
125
- undefined,
126
- [],
127
- customLogger,
128
- );
129
-
130
- expect(cron).toBeInstanceOf(Cron);
131
- expect(cron.logger).toBe(customLogger);
132
- });
133
-
134
- it('should create a Cron with all parameters', () => {
135
- const inputSchema = z.object({ name: z.string() });
136
- const outputSchema = z.object({ greeting: z.string() });
137
- const schedule: RateExpression = 'rate(5 minutes)';
138
- const timeout = 60000;
139
- const service = new MockService();
140
- const logger = new ConsoleLogger();
141
-
142
- const handler = vi
143
- .fn()
144
- .mockImplementation(async ({ input, services }) => {
145
- return {
146
- greeting: `Hello ${input.name} from ${services.MockService.getValue()}`,
147
- };
148
- });
149
-
150
- const cron = new Cron(
151
- handler,
152
- timeout,
153
- schedule,
154
- inputSchema,
155
- outputSchema,
156
- [service],
157
- logger,
158
- );
159
-
160
- expect(cron).toBeInstanceOf(Cron);
161
- expect(cron.type).toBe(ConstructType.Cron);
162
- expect(cron.timeout).toBe(timeout);
163
- expect(cron.input).toBe(inputSchema);
164
- expect(cron.outputSchema).toBe(outputSchema);
165
- expect(cron.services).toEqual([service]);
166
- expect(cron.logger).toBe(logger);
167
- });
168
- });
169
-
170
- describe('Cron.isCron', () => {
171
- it('should return true for Cron instances', () => {
172
- const cron = new Cron(vi.fn());
173
- expect(Cron.isCron(cron)).toBe(true);
174
- });
175
-
176
- it('should return false for non-Cron objects', () => {
177
- expect(Cron.isCron({})).toBe(false);
178
- expect(Cron.isCron(null)).toBeFalsy();
179
- expect(Cron.isCron(undefined)).toBeFalsy();
180
- expect(Cron.isCron('string')).toBe(false);
181
- expect(Cron.isCron(123)).toBe(false);
182
- expect(Cron.isCron([])).toBe(false);
183
- });
184
-
185
- it('should return false for objects with similar structure', () => {
186
- const fakeCron = {
187
- __IS_FUNCTION__: true,
188
- type: 'SomethingElse',
189
- };
190
- expect(Cron.isCron(fakeCron)).toBe(false);
191
- });
192
-
193
- it('should return false for objects with __IS_FUNCTION__ but wrong type', () => {
194
- const fakeFunction = {
195
- __IS_FUNCTION__: true,
196
- type: ConstructType.Function,
197
- };
198
- expect(Cron.isCron(fakeFunction)).toBe(false);
199
- });
200
- });
201
-
202
- describe('CronBuilder', () => {
203
- it('should create a CronBuilder instance', () => {
204
- const builder = new CronBuilder();
205
- expect(builder).toBeInstanceOf(CronBuilder);
206
- });
207
-
208
- it('should set schedule with schedule() method', () => {
209
- const builder = new CronBuilder();
210
- const schedule: CronExpression = 'cron(0 0 * * SUN)';
211
-
212
- const result = builder.schedule(schedule);
213
- expect(result).toBe(builder); // Should return self for chaining
214
- });
215
-
216
- it('should build Cron with handle() method', () => {
217
- const builder = new CronBuilder();
218
- const handler = vi.fn().mockResolvedValue({ done: true });
219
-
220
- const cron = builder.handle(handler);
221
-
222
- expect(cron).toBeInstanceOf(Cron);
223
- expect(cron.type).toBe(ConstructType.Cron);
224
- });
225
-
226
- it('should build Cron with full builder chain', () => {
227
- const inputSchema = z.object({ task: z.string() });
228
- const outputSchema = z.object({ completed: z.boolean() });
229
- const schedule: RateExpression = 'rate(1 hour)';
230
- const service = new MockService();
231
- const logger = new ConsoleLogger();
232
-
233
- const handler = vi.fn().mockImplementation(async ({ input }) => {
234
- return { completed: input.task === 'test' };
235
- });
236
-
237
- const cron = new CronBuilder()
238
- .input(inputSchema)
239
- .output(outputSchema)
240
- .services([service])
241
- .logger(logger)
242
- .timeout(45000)
243
- .schedule(schedule)
244
- .handle(handler);
245
-
246
- expect(cron).toBeInstanceOf(Cron);
247
- expect(cron.type).toBe(ConstructType.Cron);
248
- expect(cron.timeout).toBe(45000);
249
- expect(cron.input).toBe(inputSchema);
250
- expect(cron.outputSchema).toBe(outputSchema);
251
- expect(cron.services).toEqual([service]);
252
- expect(cron.logger).toBe(logger);
253
- });
254
-
255
- it('should support method chaining in any order', () => {
256
- const builder = new CronBuilder();
257
- const schedule: CronExpression = 'cron(30 2 * * TUE)';
258
-
259
- const chained = builder
260
- .timeout(30000)
261
- .schedule(schedule)
262
- .input(z.object({ data: z.string() }));
263
-
264
- expect(chained).toBe(builder);
265
- });
266
- });
267
-
268
- describe('Schedule Expression Types', () => {
269
- it('should accept valid rate expressions', () => {
270
- const validRates: RateExpression[] = [
271
- 'rate(5 minutes)',
272
- 'rate(1 hour)',
273
- 'rate(7 days)',
274
- 'rate(30 seconds)',
275
- 'rate(2 weeks)',
276
- ];
277
-
278
- validRates.forEach((rate) => {
279
- const builder = new CronBuilder();
280
- expect(() => builder.schedule(rate)).not.toThrow();
281
- });
282
- });
283
-
284
- it('should accept valid cron expressions', () => {
285
- const validCrons: CronExpression[] = [
286
- 'cron(0 12 * * MON)',
287
- 'cron(15 10 * * FRI)',
288
- 'cron(0 0 1 JAN SUN)',
289
- 'cron(*/5 * * * *)',
290
- 'cron(0 0-23/2 * * *)',
291
- 'cron(30 4 1,15 * *)',
292
- 'cron(0 12 * DEC MON)',
293
- ];
294
-
295
- validCrons.forEach((cron) => {
296
- const builder = new CronBuilder();
297
- expect(() => builder.schedule(cron)).not.toThrow();
298
- });
299
- });
300
-
301
- it('should work with complex cron patterns', () => {
302
- const complexPatterns: CronExpression[] = [
303
- 'cron(*/15 * * * *)', // Every 15 minutes
304
- 'cron(0 */4 * * *)', // Every 4 hours
305
- 'cron(0 9-17 * * MON-FRI)', // Every hour 9-5 on weekdays
306
- 'cron(0 0 1-7 * SUN)', // First Sunday of month
307
- 'cron(*/30 8-18 * * *)', // Every 30 min during business hours
308
- ];
309
-
310
- complexPatterns.forEach((pattern) => {
311
- const builder = new CronBuilder();
312
- expect(() => builder.schedule(pattern)).not.toThrow();
313
- });
314
- });
315
-
316
- it('should handle all month names', () => {
317
- const months: CronExpression[] = [
318
- 'cron(0 0 1 JAN *)',
319
- 'cron(0 0 1 FEB *)',
320
- 'cron(0 0 1 MAR *)',
321
- 'cron(0 0 1 APR *)',
322
- 'cron(0 0 1 MAY *)',
323
- 'cron(0 0 1 JUN *)',
324
- 'cron(0 0 1 JUL *)',
325
- 'cron(0 0 1 AUG *)',
326
- 'cron(0 0 1 SEP *)',
327
- 'cron(0 0 1 OCT *)',
328
- 'cron(0 0 1 NOV *)',
329
- 'cron(0 0 1 DEC *)',
330
- ];
331
-
332
- months.forEach((expression) => {
333
- const builder = new CronBuilder();
334
- expect(() => builder.schedule(expression)).not.toThrow();
335
- });
336
- });
337
-
338
- it('should handle all weekday names', () => {
339
- const weekdays: CronExpression[] = [
340
- 'cron(0 0 * * SUN)',
341
- 'cron(0 0 * * MON)',
342
- 'cron(0 0 * * TUE)',
343
- 'cron(0 0 * * WED)',
344
- 'cron(0 0 * * THU)',
345
- 'cron(0 0 * * FRI)',
346
- 'cron(0 0 * * SAT)',
347
- ];
348
-
349
- weekdays.forEach((expression) => {
350
- const builder = new CronBuilder();
351
- expect(() => builder.schedule(expression)).not.toThrow();
352
- });
353
- });
354
- });
355
-
356
- describe('Cron configuration', () => {
357
- it('should store handler with error handling capability', () => {
358
- const error = new Error('Cron execution failed');
359
- const handler = vi.fn().mockRejectedValue(error);
360
-
361
- const cron = new Cron(handler);
362
-
363
- expect(cron).toBeInstanceOf(Cron);
364
- // Handler is stored but not directly accessible (protected)
365
- });
366
-
367
- it('should store input schema for validation', () => {
368
- const inputSchema = z.object({
369
- id: z.string().uuid(),
370
- amount: z.number().positive(),
371
- });
372
-
373
- const handler = vi.fn();
374
- const cron = new Cron(handler, undefined, undefined, inputSchema);
375
-
376
- expect(cron.input).toBe(inputSchema);
377
- });
378
-
379
- it('should store output schema for validation', () => {
380
- const outputSchema = z.object({
381
- status: z.enum(['success', 'failure']),
382
- count: z.number().int(),
383
- });
384
-
385
- const handler = vi.fn().mockResolvedValue({
386
- status: 'invalid',
387
- count: 3.14,
388
- });
389
-
390
- const cron = new Cron(
391
- handler,
392
- undefined,
393
- undefined,
394
- undefined,
395
- outputSchema,
396
- );
397
-
398
- expect(cron.outputSchema).toBe(outputSchema);
399
- });
400
-
401
- it('should work with multiple services', () => {
402
- class ServiceA implements Service<'ServiceA', ServiceA> {
403
- serviceName = 'ServiceA' as const;
404
- async register() {
405
- return this;
406
- }
407
- getA() {
408
- return 'A';
409
- }
410
- }
411
-
412
- class ServiceB implements Service<'ServiceB', ServiceB> {
413
- serviceName = 'ServiceB' as const;
414
- async register() {
415
- return this;
416
- }
417
- getB() {
418
- return 'B';
419
- }
420
- }
421
-
422
- const services = [new ServiceA(), new ServiceB()];
423
-
424
- const handler = vi.fn().mockImplementation(async ({ services }) => {
425
- return {
426
- a: services.ServiceA.getA(),
427
- b: services.ServiceB.getB(),
428
- };
429
- });
430
-
431
- const cron = new Cron(
432
- handler,
433
- undefined,
434
- undefined,
435
- undefined,
436
- undefined,
437
- services,
438
- );
439
-
440
- expect(cron.services).toEqual(services);
441
- });
442
-
443
- it('should maintain separate instances with different configurations', () => {
444
- const handler1 = vi.fn().mockResolvedValue({ cron: 1 });
445
- const handler2 = vi.fn().mockResolvedValue({ cron: 2 });
446
-
447
- const cron1 = new CronBuilder()
448
- .timeout(1000)
449
- .schedule('rate(5 minutes)')
450
- .handle(handler1);
451
-
452
- const cron2 = new CronBuilder()
453
- .timeout(2000)
454
- .schedule('cron(0 0 * * *)')
455
- .handle(handler2);
456
-
457
- expect(cron1).toBeInstanceOf(Cron);
458
- expect(cron2).toBeInstanceOf(Cron);
459
- expect(cron1.timeout).toBe(1000);
460
- expect(cron2.timeout).toBe(2000);
461
- expect(cron1).not.toBe(cron2);
462
- });
463
- });
464
- });
@@ -1,227 +0,0 @@
1
- import { ConsoleLogger } from '@geekmidas/logger/console';
2
- import type { Service } from '@geekmidas/services';
3
- import { describe, expect, it } from 'vitest';
4
- import { CronBuilder } from '../CronBuilder';
5
-
6
- const ServiceA = {
7
- serviceName: 'a' as const,
8
- async register() {
9
- return { test: () => 'a' };
10
- },
11
- } satisfies Service<'a', any>;
12
-
13
- const ServiceB = {
14
- serviceName: 'b' as const,
15
- async register() {
16
- return { test: () => 'b' };
17
- },
18
- } satisfies Service<'b', any>;
19
-
20
- describe('CronBuilder - State Isolation', () => {
21
- describe('singleton instance state reset', () => {
22
- it('should reset services after handle() is called', () => {
23
- const c = new CronBuilder();
24
-
25
- // First cron with ServiceA and ServiceB
26
- const cron1 = c
27
- .schedule('rate(5 minutes)')
28
- .services([ServiceA, ServiceB])
29
- .handle(async () => ({}));
30
-
31
- // Second cron should not have any services from first
32
- const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
33
-
34
- expect(cron1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
35
- expect(cron2.services.map((s) => s.serviceName)).toEqual([]);
36
- });
37
-
38
- it('should reset logger after handle() is called', () => {
39
- const c = new CronBuilder();
40
- const customLogger = new ConsoleLogger({ app: 'custom' });
41
-
42
- // First cron with custom logger
43
- const cron1 = c
44
- .schedule('rate(5 minutes)')
45
- .logger(customLogger)
46
- .handle(async () => ({}));
47
-
48
- // Second cron should have default logger (not the custom one)
49
- const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
50
-
51
- expect(cron1.logger).toBe(customLogger);
52
- expect(cron2.logger).not.toBe(customLogger);
53
- expect(cron2.logger).toBeInstanceOf(ConsoleLogger);
54
- });
55
-
56
- it('should reset schedule after handle() is called', () => {
57
- const c = new CronBuilder();
58
-
59
- // First cron with schedule
60
- const cron1 = c.schedule('rate(5 minutes)').handle(async () => ({}));
61
-
62
- // Second cron should not have schedule from first
63
- const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
64
-
65
- expect(cron1.schedule).toBe('rate(5 minutes)');
66
- expect(cron2.schedule).toBe('rate(10 minutes)');
67
-
68
- // Check internal state is reset
69
- expect((c as any)._schedule).toBeUndefined();
70
- });
71
-
72
- it('should reset events after handle() is called', () => {
73
- const c = new CronBuilder();
74
-
75
- // Create first cron (events array should be empty initially)
76
- const _cron1 = c.schedule('rate(5 minutes)').handle(async () => ({}));
77
-
78
- // Verify state was reset
79
- expect((c as any)._events).toEqual([]);
80
- expect((c as any)._services).toEqual([]);
81
- expect((c as any)._schedule).toBeUndefined();
82
- });
83
-
84
- it('should reset input/output schemas after handle() is called', () => {
85
- const c = new CronBuilder();
86
- const inputSchema: any = { '~standard': { validate: () => ({}) } };
87
- const outputSchema: any = { '~standard': { validate: () => ({}) } };
88
-
89
- // First cron with schemas
90
- const cron1 = c
91
- .schedule('rate(5 minutes)')
92
- .input(inputSchema)
93
- .output(outputSchema)
94
- .handle(async () => ({}));
95
-
96
- // Second cron should not have schemas
97
- const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
98
-
99
- expect(cron1.input).toBe(inputSchema);
100
- expect(cron1.outputSchema).toBe(outputSchema);
101
- expect(cron2.input).toBeUndefined();
102
- expect(cron2.outputSchema).toBeUndefined();
103
- });
104
-
105
- it('should reset timeout after handle() is called', () => {
106
- const c = new CronBuilder();
107
-
108
- // First cron with custom timeout
109
- const cron1 = c
110
- .schedule('rate(5 minutes)')
111
- .timeout(5000)
112
- .handle(async () => ({}));
113
-
114
- // Second cron should have default timeout (30000)
115
- const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
116
-
117
- expect(cron1.timeout).toBe(5000);
118
- expect(cron2.timeout).toBe(30000); // Default timeout
119
- });
120
- });
121
-
122
- describe('method chaining before handle()', () => {
123
- it('should accumulate services when chaining', () => {
124
- const c = new CronBuilder();
125
-
126
- const cron = c
127
- .schedule('rate(5 minutes)')
128
- .services([ServiceA])
129
- .services([ServiceB])
130
- .handle(async () => ({}));
131
-
132
- expect(cron.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
133
- });
134
-
135
- it('should not share references between different builder chains', () => {
136
- const c = new CronBuilder();
137
-
138
- // Start two separate chains
139
- const builder1 = c.schedule('rate(5 minutes)').services([ServiceA]);
140
- const builder2 = c.schedule('rate(10 minutes)').services([ServiceB]);
141
-
142
- // They should be the same instance (singleton)
143
- expect(builder1).toBe(builder2);
144
- expect(builder1).toBe(c);
145
-
146
- // But after handle, state is reset
147
- const cron1 = builder1.handle(async () => ({}));
148
-
149
- // Now builder2 should have reset state
150
- expect((builder2 as any)._services).toEqual([]);
151
-
152
- // Add services again
153
- const cron2 = builder2
154
- .schedule('rate(15 minutes)')
155
- .services([ServiceB])
156
- .handle(async () => ({}));
157
-
158
- expect(cron1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
159
- expect(cron2.services.map((s) => s.serviceName)).toEqual(['b']);
160
- });
161
- });
162
-
163
- describe('sequential cron creation', () => {
164
- it('should create independent crons sequentially', () => {
165
- const c = new CronBuilder();
166
-
167
- const cron1 = c
168
- .schedule('rate(5 minutes)')
169
- .services([ServiceA, ServiceB])
170
- .handle(async () => ({ result: 1 }));
171
-
172
- const cron2 = c
173
- .schedule('rate(10 minutes)')
174
- .services([ServiceA])
175
- .handle(async () => ({ result: 2 }));
176
-
177
- const cron3 = c
178
- .schedule('rate(15 minutes)')
179
- .handle(async () => ({ result: 3 }));
180
-
181
- expect(cron1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
182
- expect(cron1.schedule).toBe('rate(5 minutes)');
183
-
184
- expect(cron2.services.map((s) => s.serviceName)).toEqual(['a']);
185
- expect(cron2.schedule).toBe('rate(10 minutes)');
186
-
187
- expect(cron3.services.map((s) => s.serviceName)).toEqual([]);
188
- expect(cron3.schedule).toBe('rate(15 minutes)');
189
- });
190
- });
191
-
192
- describe('publisher isolation', () => {
193
- it('should reset publisher after handle() is called', () => {
194
- const c = new CronBuilder();
195
- const mockPublisher: any = {
196
- serviceName: 'publisher',
197
- async register() {
198
- return { publish: () => {} };
199
- },
200
- };
201
-
202
- const cron1 = c
203
- .schedule('rate(5 minutes)')
204
- .publisher(mockPublisher)
205
- .handle(async () => ({}));
206
-
207
- const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
208
-
209
- expect((cron1 as any).publisherService).toBe(mockPublisher);
210
- expect((cron2 as any).publisherService).toBeUndefined();
211
- });
212
- });
213
-
214
- describe('cron expression types', () => {
215
- it('should handle different schedule expression formats', () => {
216
- const c = new CronBuilder();
217
-
218
- const cron1 = c.schedule('rate(5 minutes)').handle(async () => ({}));
219
- const cron2 = c.schedule('cron(0 12 * * ? *)').handle(async () => ({}));
220
- const cron3 = c.schedule('rate(1 hour)').handle(async () => ({}));
221
-
222
- expect(cron1.schedule).toBe('rate(5 minutes)');
223
- expect(cron2.schedule).toBe('cron(0 12 * * ? *)');
224
- expect(cron3.schedule).toBe('rate(1 hour)');
225
- });
226
- });
227
- });
@@ -1,12 +0,0 @@
1
- export { AWSScheduledFunction } from './AWSScheduledFunction';
2
- export {
3
- Cron,
4
- type CronExpression,
5
- type RateExpression,
6
- type ScheduleExpression,
7
- } from './Cron';
8
- export { CronBuilder } from './CronBuilder';
9
-
10
- import { CronBuilder } from './CronBuilder';
11
-
12
- export const c = new CronBuilder();