@geekmidas/constructs 10.0.0-alpha.3 → 10.0.0-alpha.30

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 (341) hide show
  1. package/README.md +52 -3
  2. package/dist/{Construct-Ct8nalEi.d.mts → Construct-DTqYvkPG.d.cts} +11 -13
  3. package/dist/Construct-DTqYvkPG.d.cts.map +1 -0
  4. package/dist/{Construct-BD5neF7w.mjs → Construct-Detz65RA.mjs} +31 -29
  5. package/dist/Construct-Detz65RA.mjs.map +1 -0
  6. package/dist/{Construct-C0ijr2qp.d.cts → Construct-pVadmURD.d.mts} +10 -12
  7. package/dist/Construct-pVadmURD.d.mts.map +1 -0
  8. package/dist/{Construct-CyS3RpTL.cjs → Construct-yG9Sw-5p.cjs} +51 -43
  9. package/dist/Construct-yG9Sw-5p.cjs.map +1 -0
  10. package/dist/{Cron-ByxdOfpE.d.mts → Cron-B_iuyNxr.d.mts} +17 -6
  11. package/dist/Cron-B_iuyNxr.d.mts.map +1 -0
  12. package/dist/{Cron-Wqh464aO.d.cts → Cron-CA2oa2nC.d.cts} +16 -5
  13. package/dist/Cron-CA2oa2nC.d.cts.map +1 -0
  14. package/dist/{CronBuilder-BL0AP6fs.d.mts → CronBuilder-BIKCLWu7.d.mts} +7 -10
  15. package/dist/CronBuilder-BIKCLWu7.d.mts.map +1 -0
  16. package/dist/{CronBuilder-BmABazzH.mjs → CronBuilder-BRkzUOAs.mjs} +35 -17
  17. package/dist/CronBuilder-BRkzUOAs.mjs.map +1 -0
  18. package/dist/{CronBuilder-BqpEzMPQ.d.cts → CronBuilder-B_KqaodP.d.cts} +6 -9
  19. package/dist/CronBuilder-B_KqaodP.d.cts.map +1 -0
  20. package/dist/{CronBuilder-CkXPJiGO.cjs → CronBuilder-BbnT7tqo.cjs} +45 -27
  21. package/dist/CronBuilder-BbnT7tqo.cjs.map +1 -0
  22. package/dist/{Endpoint-2Wg7T7Cq.d.mts → Endpoint-BojvdQoh.d.mts} +63 -84
  23. package/dist/Endpoint-BojvdQoh.d.mts.map +1 -0
  24. package/dist/{Endpoint-VIOpSo0S.mjs → Endpoint-DO332Dnm.mjs} +117 -109
  25. package/dist/Endpoint-DO332Dnm.mjs.map +1 -0
  26. package/dist/{Endpoint-BiaaMEn_.cjs → Endpoint-QKuFg5gs.cjs} +145 -131
  27. package/dist/Endpoint-QKuFg5gs.cjs.map +1 -0
  28. package/dist/{Endpoint-CH9Fn1AD.d.cts → Endpoint-xNGuv2Fq.d.cts} +61 -82
  29. package/dist/Endpoint-xNGuv2Fq.d.cts.map +1 -0
  30. package/dist/{EndpointFactory-DTTCkGEL.mjs → EndpointFactory-B9HAjDAP.mjs} +26 -32
  31. package/dist/EndpointFactory-B9HAjDAP.mjs.map +1 -0
  32. package/dist/{EndpointFactory-ChxLZllA.cjs → EndpointFactory-BmO0WnXE.cjs} +63 -69
  33. package/dist/EndpointFactory-BmO0WnXE.cjs.map +1 -0
  34. package/dist/{index-BxHDdy6a.d.mts → EndpointFactory-CaYTrUOO.d.mts} +12 -92
  35. package/dist/EndpointFactory-CaYTrUOO.d.mts.map +1 -0
  36. package/dist/{index-V2nksZIJ.d.cts → EndpointFactory-DyT1yOJL.d.cts} +10 -90
  37. package/dist/EndpointFactory-DyT1yOJL.d.cts.map +1 -0
  38. package/dist/{HonoEndpointAdaptor-NKQQQbBY.mjs → HonoEndpointAdaptor-CiqAZ5Mt.mjs} +40 -47
  39. package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs.map → HonoEndpointAdaptor-CiqAZ5Mt.mjs.map} +1 -1
  40. package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs → HonoEndpointAdaptor-DoEQdC3r.cjs} +48 -52
  41. package/dist/HonoEndpointAdaptor-DoEQdC3r.cjs.map +1 -0
  42. package/dist/Queue-B7yRXQmL.cjs +124 -0
  43. package/dist/Queue-B7yRXQmL.cjs.map +1 -0
  44. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-Bhzi2WQC.d.cts} +8 -9
  45. package/dist/Queue-Bhzi2WQC.d.cts.map +1 -0
  46. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-BoUA-e83.d.mts} +9 -10
  47. package/dist/Queue-BoUA-e83.d.mts.map +1 -0
  48. package/dist/Queue-DpKTLl6E.mjs +119 -0
  49. package/dist/Queue-DpKTLl6E.mjs.map +1 -0
  50. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-CIO3pwji.d.mts} +7 -8
  51. package/dist/Subscriber-CIO3pwji.d.mts.map +1 -0
  52. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-DQCaiOXF.d.cts} +7 -8
  53. package/dist/Subscriber-DQCaiOXF.d.cts.map +1 -0
  54. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-B4YRTBng.mjs} +16 -10
  55. package/dist/SubscriberBuilder-B4YRTBng.mjs.map +1 -0
  56. package/dist/{SubscriberBuilder-Dptmo-1A.d.mts → SubscriberBuilder-C2FRfd26.d.mts} +8 -11
  57. package/dist/SubscriberBuilder-C2FRfd26.d.mts.map +1 -0
  58. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2bCOuPT.cjs} +28 -23
  59. package/dist/SubscriberBuilder-C2bCOuPT.cjs.map +1 -0
  60. package/dist/{SubscriberBuilder-waNhzjSM.d.cts → SubscriberBuilder-CjDGSTZc.d.cts} +7 -10
  61. package/dist/SubscriberBuilder-CjDGSTZc.d.cts.map +1 -0
  62. package/dist/Topic-Ct3Le8Wt.mjs +103 -0
  63. package/dist/Topic-Ct3Le8Wt.mjs.map +1 -0
  64. package/dist/Topic-D5rlM9wS.cjs +108 -0
  65. package/dist/Topic-D5rlM9wS.cjs.map +1 -0
  66. package/dist/{Topic-19QeHBIR.d.cts → Topic-D6blllEn.d.cts} +5 -7
  67. package/dist/Topic-D6blllEn.d.cts.map +1 -0
  68. package/dist/{Topic-DuFeqkBh.d.mts → Topic-DVvheJ_-.d.mts} +6 -8
  69. package/dist/Topic-DVvheJ_-.d.mts.map +1 -0
  70. package/dist/adaptors/aws.cjs +87 -106
  71. package/dist/adaptors/aws.cjs.map +1 -1
  72. package/dist/adaptors/aws.d.cts +14 -27
  73. package/dist/adaptors/aws.d.cts.map +1 -1
  74. package/dist/adaptors/aws.d.mts +16 -29
  75. package/dist/adaptors/aws.d.mts.map +1 -1
  76. package/dist/adaptors/aws.mjs +60 -81
  77. package/dist/adaptors/aws.mjs.map +1 -1
  78. package/dist/adaptors/hono.cjs +3 -10
  79. package/dist/adaptors/hono.d.cts +5 -13
  80. package/dist/adaptors/hono.d.cts.map +1 -1
  81. package/dist/adaptors/hono.d.mts +7 -15
  82. package/dist/adaptors/hono.d.mts.map +1 -1
  83. package/dist/adaptors/hono.mjs +2 -10
  84. package/dist/adaptors/testing.cjs +396 -82
  85. package/dist/adaptors/testing.cjs.map +1 -1
  86. package/dist/adaptors/testing.d.cts +150 -33
  87. package/dist/adaptors/testing.d.cts.map +1 -1
  88. package/dist/adaptors/testing.d.mts +151 -34
  89. package/dist/adaptors/testing.d.mts.map +1 -1
  90. package/dist/adaptors/testing.mjs +368 -63
  91. package/dist/adaptors/testing.mjs.map +1 -1
  92. package/dist/auth-Bmo1wSQF.d.cts +177 -0
  93. package/dist/auth-Bmo1wSQF.d.cts.map +1 -0
  94. package/dist/auth-CJ5dp7T7.d.mts +177 -0
  95. package/dist/auth-CJ5dp7T7.d.mts.map +1 -0
  96. package/dist/auth.cjs +113 -28
  97. package/dist/auth.cjs.map +1 -1
  98. package/dist/auth.d.cts +2 -108
  99. package/dist/auth.d.mts +2 -108
  100. package/dist/auth.mjs +103 -20
  101. package/dist/auth.mjs.map +1 -1
  102. package/dist/{cache-BrRz3fEB.d.mts → cache-B2s0b-ss.d.mts} +3 -6
  103. package/dist/cache-B2s0b-ss.d.mts.map +1 -0
  104. package/dist/{cache-BtZY_tHe.d.cts → cache-CYe2Kzjc.d.cts} +3 -6
  105. package/dist/cache-CYe2Kzjc.d.cts.map +1 -0
  106. package/dist/cache.cjs +68 -2
  107. package/dist/cache.cjs.map +1 -0
  108. package/dist/cache.d.cts +1 -2
  109. package/dist/cache.d.mts +1 -2
  110. package/dist/cache.mjs +67 -2
  111. package/dist/cache.mjs.map +1 -0
  112. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  113. package/dist/clone-EKNovYHu.mjs.map +1 -0
  114. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  115. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  116. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-D2gesxos.d.mts} +28 -10
  117. package/dist/construct-interface-D2gesxos.d.mts.map +1 -0
  118. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-DPusCUSQ.d.cts} +28 -10
  119. package/dist/construct-interface-DPusCUSQ.d.cts.map +1 -0
  120. package/dist/construct-interface.cjs +116 -7
  121. package/dist/construct-interface.cjs.map +1 -0
  122. package/dist/construct-interface.d.cts +2 -2
  123. package/dist/construct-interface.d.mts +2 -2
  124. package/dist/construct-interface.mjs +108 -2
  125. package/dist/construct-interface.mjs.map +1 -0
  126. package/dist/credential.cjs +43 -9
  127. package/dist/credential.cjs.map +1 -1
  128. package/dist/credential.d.cts +5 -8
  129. package/dist/credential.d.cts.map +1 -1
  130. package/dist/credential.d.mts +5 -8
  131. package/dist/credential.d.mts.map +1 -1
  132. package/dist/credential.mjs +36 -2
  133. package/dist/credential.mjs.map +1 -1
  134. package/dist/crons/index.cjs +68 -10
  135. package/dist/crons/index.cjs.map +1 -1
  136. package/dist/crons/index.d.cts +32 -14
  137. package/dist/crons/index.d.cts.map +1 -1
  138. package/dist/crons/index.d.mts +32 -14
  139. package/dist/crons/index.d.mts.map +1 -1
  140. package/dist/crons/index.mjs +66 -10
  141. package/dist/crons/index.mjs.map +1 -1
  142. package/dist/database/kysely.cjs +40 -15
  143. package/dist/database/kysely.cjs.map +1 -1
  144. package/dist/database/kysely.d.cts +2 -152
  145. package/dist/database/kysely.d.mts +2 -152
  146. package/dist/database/kysely.mjs +28 -5
  147. package/dist/database/kysely.mjs.map +1 -1
  148. package/dist/email.cjs +25 -12
  149. package/dist/email.cjs.map +1 -1
  150. package/dist/email.d.cts +3 -7
  151. package/dist/email.d.cts.map +1 -1
  152. package/dist/email.d.mts +3 -7
  153. package/dist/email.d.mts.map +1 -1
  154. package/dist/email.mjs +16 -3
  155. package/dist/email.mjs.map +1 -1
  156. package/dist/endpoints/index.cjs +7 -10
  157. package/dist/endpoints/index.d.cts +60 -7
  158. package/dist/endpoints/index.d.cts.map +1 -0
  159. package/dist/endpoints/index.d.mts +60 -7
  160. package/dist/endpoints/index.d.mts.map +1 -0
  161. package/dist/endpoints/index.mjs +5 -10
  162. package/dist/file-server.cjs +42 -10
  163. package/dist/file-server.cjs.map +1 -1
  164. package/dist/file-server.d.cts +6 -10
  165. package/dist/file-server.d.cts.map +1 -1
  166. package/dist/file-server.d.mts +6 -10
  167. package/dist/file-server.d.mts.map +1 -1
  168. package/dist/file-server.mjs +34 -2
  169. package/dist/file-server.mjs.map +1 -1
  170. package/dist/functions/index.cjs +2 -6
  171. package/dist/functions/index.d.cts +2 -4
  172. package/dist/functions/index.d.mts +2 -4
  173. package/dist/functions/index.mjs +2 -6
  174. package/dist/{functions-Bd3TPxid.cjs → functions-DKN6aQWJ.cjs} +325 -268
  175. package/dist/functions-DKN6aQWJ.cjs.map +1 -0
  176. package/dist/{functions-Cxbo-pEd.mjs → functions-DlFm8HmH.mjs} +298 -238
  177. package/dist/functions-DlFm8HmH.mjs.map +1 -0
  178. package/dist/{index-JSf9xNIJ.d.cts → index-BI23K3wy.d.cts} +17 -22
  179. package/dist/index-BI23K3wy.d.cts.map +1 -0
  180. package/dist/index-CeEtxDmK.d.cts +79 -0
  181. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  182. package/dist/index-CeEtxDmK.d.mts +79 -0
  183. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  184. package/dist/index-fnpjXiA-.d.mts +26 -0
  185. package/dist/index-fnpjXiA-.d.mts.map +1 -0
  186. package/dist/index-tE_119SX.d.cts +26 -0
  187. package/dist/index-tE_119SX.d.cts.map +1 -0
  188. package/dist/{index-CubPzHd9.d.mts → index-yb3fXNyH.d.mts} +18 -23
  189. package/dist/index-yb3fXNyH.d.mts.map +1 -0
  190. package/dist/index.cjs +3 -3
  191. package/dist/index.d.cts +4 -4
  192. package/dist/index.d.mts +4 -4
  193. package/dist/index.mjs +2 -3
  194. package/dist/kysely-CEVXacPN.d.cts +159 -0
  195. package/dist/kysely-CEVXacPN.d.cts.map +1 -0
  196. package/dist/kysely-mcTdPNhl.d.mts +159 -0
  197. package/dist/kysely-mcTdPNhl.d.mts.map +1 -0
  198. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-BHtcqgz2.mjs} +22 -25
  199. package/dist/lazyAccessors-BHtcqgz2.mjs.map +1 -0
  200. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-Dx9NLwJZ.cjs} +72 -76
  201. package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +1 -0
  202. package/dist/object-storage.cjs +18 -10
  203. package/dist/object-storage.cjs.map +1 -1
  204. package/dist/object-storage.d.cts +3 -7
  205. package/dist/object-storage.d.cts.map +1 -1
  206. package/dist/object-storage.d.mts +3 -7
  207. package/dist/object-storage.d.mts.map +1 -1
  208. package/dist/object-storage.mjs +11 -3
  209. package/dist/object-storage.mjs.map +1 -1
  210. package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
  211. package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
  212. package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
  213. package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
  214. package/dist/queue/index.cjs +9 -118
  215. package/dist/queue/index.cjs.map +1 -1
  216. package/dist/queue/index.d.cts +8 -15
  217. package/dist/queue/index.d.cts.map +1 -1
  218. package/dist/queue/index.d.mts +8 -15
  219. package/dist/queue/index.d.mts.map +1 -1
  220. package/dist/queue/index.mjs +5 -114
  221. package/dist/queue/index.mjs.map +1 -1
  222. package/dist/rest-api.cjs +88 -62
  223. package/dist/rest-api.cjs.map +1 -1
  224. package/dist/rest-api.d.cts +62 -60
  225. package/dist/rest-api.d.cts.map +1 -1
  226. package/dist/rest-api.d.mts +62 -60
  227. package/dist/rest-api.d.mts.map +1 -1
  228. package/dist/rest-api.mjs +80 -54
  229. package/dist/rest-api.mjs.map +1 -1
  230. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  231. package/dist/site.cjs +33 -9
  232. package/dist/site.cjs.map +1 -1
  233. package/dist/site.d.cts +11 -22
  234. package/dist/site.d.cts.map +1 -1
  235. package/dist/site.d.mts +11 -22
  236. package/dist/site.d.mts.map +1 -1
  237. package/dist/site.mjs +29 -5
  238. package/dist/site.mjs.map +1 -1
  239. package/dist/subscribers/index.cjs +2 -11
  240. package/dist/subscribers/index.d.cts +3 -14
  241. package/dist/subscribers/index.d.mts +3 -14
  242. package/dist/subscribers/index.mjs +2 -11
  243. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  244. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  245. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  246. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  247. package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
  248. package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
  249. package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
  250. package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
  251. package/dist/topic/index.cjs +8 -107
  252. package/dist/topic/index.cjs.map +1 -1
  253. package/dist/topic/index.d.cts +3 -32
  254. package/dist/topic/index.d.mts +3 -32
  255. package/dist/topic/index.mjs +4 -103
  256. package/dist/topic/index.mjs.map +1 -1
  257. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  258. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  259. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  260. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  261. package/dist/types.d.cts +1 -1
  262. package/dist/types.d.mts +1 -1
  263. package/dist/types.mjs +1 -0
  264. package/dist/worker.cjs +109 -35
  265. package/dist/worker.cjs.map +1 -1
  266. package/dist/worker.d.cts +87 -42
  267. package/dist/worker.d.cts.map +1 -1
  268. package/dist/worker.d.mts +87 -42
  269. package/dist/worker.d.mts.map +1 -1
  270. package/dist/worker.mjs +104 -30
  271. package/dist/worker.mjs.map +1 -1
  272. package/package.json +59 -55
  273. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  274. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  275. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  276. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  277. package/dist/Cron-ByxdOfpE.d.mts.map +0 -1
  278. package/dist/Cron-Wqh464aO.d.cts.map +0 -1
  279. package/dist/CronBuilder-BL0AP6fs.d.mts.map +0 -1
  280. package/dist/CronBuilder-BmABazzH.mjs.map +0 -1
  281. package/dist/CronBuilder-BqpEzMPQ.d.cts.map +0 -1
  282. package/dist/CronBuilder-CkXPJiGO.cjs.map +0 -1
  283. package/dist/Endpoint-2Wg7T7Cq.d.mts.map +0 -1
  284. package/dist/Endpoint-BiaaMEn_.cjs.map +0 -1
  285. package/dist/Endpoint-CH9Fn1AD.d.cts.map +0 -1
  286. package/dist/Endpoint-VIOpSo0S.mjs.map +0 -1
  287. package/dist/EndpointFactory-ChxLZllA.cjs.map +0 -1
  288. package/dist/EndpointFactory-DTTCkGEL.mjs.map +0 -1
  289. package/dist/HonoEndpointAdaptor-NKQQQbBY.mjs.map +0 -1
  290. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  291. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  292. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  293. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  294. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  295. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  296. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  297. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  298. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  299. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  300. package/dist/auth.d.cts.map +0 -1
  301. package/dist/auth.d.mts.map +0 -1
  302. package/dist/cache-0ANvRQnD.mjs +0 -51
  303. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  304. package/dist/cache-3WSvAulx.cjs +0 -57
  305. package/dist/cache-3WSvAulx.cjs.map +0 -1
  306. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  307. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  308. package/dist/clone-DblgEZZa.mjs.map +0 -1
  309. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  310. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  311. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  312. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  313. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  314. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  315. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  316. package/dist/database/kysely.d.cts.map +0 -1
  317. package/dist/database/kysely.d.mts.map +0 -1
  318. package/dist/functions-Bd3TPxid.cjs.map +0 -1
  319. package/dist/functions-Cxbo-pEd.mjs.map +0 -1
  320. package/dist/index-BxHDdy6a.d.mts.map +0 -1
  321. package/dist/index-CubPzHd9.d.mts.map +0 -1
  322. package/dist/index-JSf9xNIJ.d.cts.map +0 -1
  323. package/dist/index-V2nksZIJ.d.cts.map +0 -1
  324. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  325. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  326. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  327. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  328. package/dist/subscribers/index.cjs.map +0 -1
  329. package/dist/subscribers/index.d.cts.map +0 -1
  330. package/dist/subscribers/index.d.mts.map +0 -1
  331. package/dist/subscribers/index.mjs.map +0 -1
  332. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  333. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  334. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  335. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  336. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  337. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  338. package/dist/topic/index.d.cts.map +0 -1
  339. package/dist/topic/index.d.mts.map +0 -1
  340. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  341. package/dist/types-aKksMEWL.d.mts.map +0 -1
package/dist/worker.mjs CHANGED
@@ -1,21 +1,25 @@
1
- import "./Construct-BD5neF7w.mjs";
2
- import { edgeTo } from "./construct-interface-Z4CpS8tK.mjs";
3
- import { FunctionBuilder } from "./functions-Cxbo-pEd.mjs";
4
- import "./clone-DblgEZZa.mjs";
5
- import { envParserFor } from "./surfaceEnv-C3Ktahea.mjs";
6
- import { CronBuilder } from "./CronBuilder-BmABazzH.mjs";
7
- import { SubscriberBuilder } from "./SubscriberBuilder-BjkbeT9l.mjs";
1
+ import { edgeTo } from "./construct-interface.mjs";
2
+ import { t as FunctionBuilder } from "./functions-DlFm8HmH.mjs";
3
+ import { n as envParserFor } from "./surfaceEnv-wMT5QzgZ.mjs";
4
+ import { t as CronBuilder } from "./CronBuilder-BRkzUOAs.mjs";
5
+ import { t as SubscriberBuilder } from "./SubscriberBuilder-B4YRTBng.mjs";
8
6
  import { canonicalId } from "@geekmidas/manifest";
9
7
  import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
10
-
11
8
  //#region src/worker.ts
12
9
  var Worker = class Worker {
10
+ config;
11
+ dependencies;
13
12
  id;
14
13
  /** Always defined — the worker's own, or the console logger. */
15
14
  logger;
16
15
  /** Always defined, and normally the default. */
17
16
  envParser;
18
- constructor(id, config = {}, dependencies = []) {
17
+ /**
18
+ * Where this worker's schedules live, when it has crons and a server runs
19
+ * them. `undefined` until `.database(…)` says.
20
+ */
21
+ scheduleStore;
22
+ constructor(id, config = {}, dependencies = [], scheduleStore) {
19
23
  this.config = config;
20
24
  this.dependencies = dependencies;
21
25
  const canonical = canonicalId(id);
@@ -25,37 +29,107 @@ var Worker = class Worker {
25
29
  id: canonical,
26
30
  envParser: config.envParser
27
31
  } : void 0);
32
+ this.scheduleStore = scheduleStore;
28
33
  }
29
34
  /**
30
- * This worker's cron factory, carrying its logger.
35
+ * The database this worker keeps its schedules in.
36
+ *
37
+ * Only a server target uses it. On AWS a cron is an EventBridge rule
38
+ * invoking a Lambda and nothing here is consulted — but a server has nothing
39
+ * firing its crons except itself, and a process that schedules in memory
40
+ * fires every job once per replica while reporting that all is well.
41
+ *
42
+ * So the store is declared rather than discovered. It could have been
43
+ * inferred — from a database the app happens to declare, or from the events
44
+ * backend when that backend is pg-boss — and both would work until an app
45
+ * had two databases, or moved its events to SNS, at which point the
46
+ * schedules would quietly move or stop. Naming it is one line and cannot
47
+ * drift.
31
48
  *
32
- * `export const c = crons.logger(logger)` written once and hung off the
33
- * thing that runs it, so a cron file opens with the schedule rather than
34
- * with an import of a logger it has to know the path to.
49
+ * @example
50
+ * ```ts
51
+ * export const jobs = new Worker('Jobs', { logger }).database(database);
52
+ * ```
35
53
  */
36
- get crons() {
37
- return this.own(new CronBuilder().logger(this.logger));
54
+ database(source) {
55
+ return new Worker(this.id, this.config, [...this.dependencies, edgeTo(source)], source);
38
56
  }
39
57
  /**
40
- * This worker's subscriber factory, carrying its logger.
58
+ * A scheduled runnable.
41
59
  *
42
- * Chain `.publisher(…)` before `.subscribe([…])`: the event names are typed
43
- * from the publisher's message union, so there is nothing to spell twice.
60
+ * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
44
61
  */
45
- get subscribers() {
46
- return this.own(new SubscriberBuilder().logger(this.logger));
62
+ cron(schedule) {
63
+ return this.own(new CronBuilder().logger(this.logger)).schedule(schedule);
47
64
  }
48
- /** This worker's function factory, carrying its logger. */
49
- get functions() {
50
- return this.own(new FunctionBuilder().logger(this.logger));
65
+ /**
66
+ * A runnable that consumes a topic.
67
+ *
68
+ * Binding is not publishing: a consumer is handed the topic's event types
69
+ * and no connection string it could publish with. Chain `.publishes(…)` when
70
+ * the handler emits follow-up events, which is the only reason it would need
71
+ * one.
72
+ *
73
+ * @example `worker.topic(users).subscribe(['user.created']).handle(…)`
74
+ */
75
+ topic(topic) {
76
+ return this.own(new SubscriberBuilder().logger(this.logger)).topic(topic);
51
77
  }
52
78
  /**
53
- * Sugar for the common case, the way `api.get()` is for `api.endpoints`.
79
+ * A runnable that consumes events typed from a publisher service.
54
80
  *
55
- * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
81
+ * The older of the two ways to bind a subscriber, kept for a project whose
82
+ * events come from a hand-written publisher rather than a `Topic`
83
+ * construct. `topic()` is the one to reach for: it types the events the same
84
+ * way and hands the consumer no connection string it could publish with.
56
85
  */
57
- cron(schedule) {
58
- return this.crons.schedule(schedule);
86
+ publisher(service) {
87
+ return this.own(new SubscriberBuilder().logger(this.logger)).publisher(service);
88
+ }
89
+ /**
90
+ * Everything below builds a function — the runnable with no schedule and no
91
+ * topic, invoked by something else.
92
+ *
93
+ * These sit on the worker rather than behind a `functions` namespace because
94
+ * the namespace was a hop that said nothing: `worker.functions.input(…)`
95
+ * names a collection to reach one member of it. What kind of runnable is
96
+ * being built is decided by which of these is called first — a schedule
97
+ * makes a cron, a topic makes a subscriber, and anything else makes a
98
+ * function.
99
+ */
100
+ input(schema) {
101
+ return this.functions.input(schema);
102
+ }
103
+ output(schema) {
104
+ return this.functions.output(schema);
105
+ }
106
+ timeout(ms) {
107
+ return this.functions.timeout(ms);
108
+ }
109
+ memorySize(mb) {
110
+ return this.functions.memorySize(mb);
111
+ }
112
+ dependsOn(constructs) {
113
+ return this.functions.dependsOn(constructs);
114
+ }
115
+ services(services) {
116
+ return this.functions.services(services);
117
+ }
118
+ /**
119
+ * A function with no input schema — the shortest runnable there is.
120
+ *
121
+ * @example `worker.handle(async ({ logger }) => { … })`
122
+ */
123
+ handle(...args) {
124
+ return this.schemalessFunction().handle(...args);
125
+ }
126
+ /** The builder `handle` delegates to, named so its type can be referred to. */
127
+ schemalessFunction() {
128
+ return this.functions;
129
+ }
130
+ /** The function builder the delegating methods above are built on. */
131
+ get functions() {
132
+ return this.own(new FunctionBuilder().logger(this.logger));
59
133
  }
60
134
  /**
61
135
  * Resources and surfaces this worker calls.
@@ -64,7 +138,7 @@ var Worker = class Worker {
64
138
  * environment and its access, the same distinction `RestApi.calls()` draws.
65
139
  */
66
140
  calls(constructs) {
67
- return new Worker(this.id, this.config, [...this.dependencies, ...constructs.map(edgeTo)]);
141
+ return new Worker(this.id, this.config, [...this.dependencies, ...constructs.map(edgeTo)], this.scheduleStore);
68
142
  }
69
143
  /**
70
144
  * Stamps this worker's id onto a builder, so everything built from it says
@@ -72,19 +146,19 @@ var Worker = class Worker {
72
146
  */
73
147
  own(builder) {
74
148
  builder._owner = this.id;
149
+ builder._scheduleStore = this.scheduleStore;
75
150
  return builder;
76
151
  }
77
152
  declare() {
78
153
  return [{
79
154
  kind: "worker",
80
155
  id: this.id,
81
- ...this.config.app ? { app: this.config.app } : {},
82
156
  ...this.dependencies.length ? { dependencies: this.dependencies } : {},
83
157
  provides: []
84
158
  }];
85
159
  }
86
160
  };
87
-
88
161
  //#endregion
89
162
  export { Worker };
163
+
90
164
  //# sourceMappingURL=worker.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker.mjs","names":["id: ConstructName<TName>","config: WorkerConfig","dependencies: readonly Dependency[]","schedule: ScheduleExpression","constructs: readonly Declarable[]","builder: T"],"sources":["../src/worker.ts"],"sourcesContent":["/**\n * A process with no port.\n *\n * `RestApi` is the process that answers HTTP. This is the one that does not —\n * the thing that runs a schedule, drains a queue, consumes a topic. Until it\n * existed, those had nowhere to say they belonged: a cron declared a schedule\n * and nothing else, and which container ran it was decided by the directory the\n * file sat in. A glob owned it.\n *\n * The cost of that shows up in the scaffolds. `gkm init --template worker` —\n * a project that is background jobs and nothing else — declared\n * `new RestApi('Api', { defaultAuthorizer: 'none', logger })`: an HTTP surface\n * with no HTTP on it, written because it was the only construct that made an\n * app exist and the only way to get a logger into the generated runtime.\n *\n * It takes no authorizer, and that is the tell that these are two constructs\n * rather than one with a flag: a `RestApi` needs one because an HTTP surface\n * can ship open by omission, and nothing reaches a worker from outside.\n *\n * @example\n * ```ts\n * // constructs/worker.ts\n * import { Worker } from '@geekmidas/constructs/worker';\n * import { logger } from './logger.js';\n *\n * export const worker = new Worker('Worker', { logger }).calls([database]);\n *\n * // crons/cleanup.ts\n * import { worker } from '@acme/constructs/worker.js';\n *\n * export const cleanup = worker\n * .cron('rate(1 day)')\n * .handle(async ({ logger }) => { … });\n * ```\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\ttype AppSpec,\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n} from '@geekmidas/manifest';\nimport { type Declarable, edgeTo } from './construct-interface';\nimport type { ScheduleExpression } from './crons/Cron';\nimport { CronBuilder } from './crons/CronBuilder';\nimport { envParserFor } from './endpoints/surfaceEnv';\nimport { FunctionBuilder } from './functions/FunctionBuilder';\nimport { SubscriberBuilder } from './subscribers/SubscriberBuilder';\n\nexport interface WorkerConfig {\n\t/**\n\t * Where its source lives and how it is run.\n\t *\n\t * Normally omitted, like every other app's: `Worker` means `apps/worker`\n\t * where that directory exists and the project root otherwise. Write one only\n\t * for a layout that genuinely differs.\n\t */\n\tapp?: AppSpec;\n\t/**\n\t * The logger everything built from this worker runs with.\n\t *\n\t * The actual logger, not a path to one — the same reason `RestApi` takes\n\t * one. Every cron and subscriber in a scaffolded project used to open with\n\t * `import { logger } from '…/constructs/logger.js'`, which is the line this\n\t * removes.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * The environment parser everything built from this worker runs with.\n\t *\n\t * Defaults to `process.env` merged with the credentials `gkm dev` injected,\n\t * which is what an application's own `config/env.ts` always was.\n\t */\n\tenvParser?: EnvironmentParser<{}>;\n}\n\nexport class Worker<TName extends string = string>\n\timplements Declarable<TName>\n{\n\treadonly id: TName;\n\n\t/** Always defined — the worker's own, or the console logger. */\n\treadonly logger: Logger;\n\n\t/** Always defined, and normally the default. */\n\treadonly envParser: EnvironmentParser<{}>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: WorkerConfig = {},\n\t\t/** Internal: how `.calls()` carries edges into the copy it returns. */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.logger = config.logger ?? DEFAULT_LOGGER;\n\t\tthis.envParser = envParserFor(\n\t\t\tconfig.envParser\n\t\t\t\t? { id: canonical, envParser: config.envParser }\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\t/**\n\t * This worker's cron factory, carrying its logger.\n\t *\n\t * `export const c = crons.logger(logger)` written once and hung off the\n\t * thing that runs it, so a cron file opens with the schedule rather than\n\t * with an import of a logger it has to know the path to.\n\t */\n\tget crons() {\n\t\treturn this.own(new CronBuilder().logger(this.logger));\n\t}\n\n\t/**\n\t * This worker's subscriber factory, carrying its logger.\n\t *\n\t * Chain `.publisher(…)` before `.subscribe([…])`: the event names are typed\n\t * from the publisher's message union, so there is nothing to spell twice.\n\t */\n\tget subscribers() {\n\t\treturn this.own(new SubscriberBuilder().logger(this.logger));\n\t}\n\n\t/** This worker's function factory, carrying its logger. */\n\tget functions() {\n\t\treturn this.own(new FunctionBuilder().logger(this.logger));\n\t}\n\n\t/**\n\t * Sugar for the common case, the way `api.get()` is for `api.endpoints`.\n\t *\n\t * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`\n\t */\n\tcron(schedule: ScheduleExpression) {\n\t\treturn this.crons.schedule(schedule);\n\t}\n\n\t/**\n\t * Resources and surfaces this worker calls.\n\t *\n\t * Not `.dependsOn()`: this records the edge that derives the worker's\n\t * environment and its access, the same distinction `RestApi.calls()` draws.\n\t */\n\tcalls(constructs: readonly Declarable[]): Worker<TName> {\n\t\treturn new Worker<TName>(this.id as ConstructName<TName>, this.config, [\n\t\t\t...this.dependencies,\n\t\t\t...constructs.map(edgeTo),\n\t\t]);\n\t}\n\n\t/**\n\t * Stamps this worker's id onto a builder, so everything built from it says\n\t * which process runs it.\n\t */\n\tprivate own<T extends { _owner?: string }>(builder: T): T {\n\t\tbuilder._owner = this.id;\n\n\t\treturn builder;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'worker',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.config.app ? { app: this.config.app } : {}),\n\t\t\t\t...(this.dependencies.length\n\t\t\t\t\t? { dependencies: this.dependencies }\n\t\t\t\t\t: {}),\n\t\t\t\t// Nothing calls a worker, so it publishes no address.\n\t\t\t\tprovides: [],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAgFA,IAAa,SAAb,MAAa,OAEb;CACC,AAAS;;CAGT,AAAS;;CAGT,AAAS;CAET,YACCA,IACiBC,SAAuB,CAAE,GAEzBC,eAAsC,CAAE,GACxD;EAHgB;EAEA;EAEjB,MAAM,YAAY,YAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,SAAS,OAAO,UAAU;AAC/B,OAAK,YAAY,aAChB,OAAO,YACJ;GAAE,IAAI;GAAW,WAAW,OAAO;EAAW,WAEjD;CACD;;;;;;;;CASD,IAAI,QAAQ;AACX,SAAO,KAAK,IAAI,IAAI,cAAc,OAAO,KAAK,OAAO,CAAC;CACtD;;;;;;;CAQD,IAAI,cAAc;AACjB,SAAO,KAAK,IAAI,IAAI,oBAAoB,OAAO,KAAK,OAAO,CAAC;CAC5D;;CAGD,IAAI,YAAY;AACf,SAAO,KAAK,IAAI,IAAI,kBAAkB,OAAO,KAAK,OAAO,CAAC;CAC1D;;;;;;CAOD,KAAKC,UAA8B;AAClC,SAAO,KAAK,MAAM,SAAS,SAAS;CACpC;;;;;;;CAQD,MAAMC,YAAkD;AACvD,SAAO,IAAI,OAAc,KAAK,IAA4B,KAAK,QAAQ,CACtE,GAAG,KAAK,cACR,GAAG,WAAW,IAAI,OAAO,AACzB;CACD;;;;;CAMD,AAAQ,IAAmCC,SAAe;AACzD,UAAQ,SAAS,KAAK;AAEtB,SAAO;CACP;CAED,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,OAAO,MAAM,EAAE,KAAK,KAAK,OAAO,IAAK,IAAG,CAAE;GACnD,GAAI,KAAK,aAAa,SACnB,EAAE,cAAc,KAAK,aAAc,IACnC,CAAE;GAEL,UAAU,CAAE;EACZ,CACD;CACD;AACD"}
1
+ {"version":3,"file":"worker.mjs","names":[],"sources":["../src/worker.ts"],"sourcesContent":["/**\n * A process with no port.\n *\n * `RestApi` is the process that answers HTTP. This is the one that does not —\n * the thing that runs a schedule, drains a queue, consumes a topic. Until it\n * existed, those had nowhere to say they belonged: a cron declared a schedule\n * and nothing else, and which container ran it was decided by the directory the\n * file sat in. A glob owned it.\n *\n * The cost of that shows up in the scaffolds. `gkm init --template worker` —\n * a project that is background jobs and nothing else — declared\n * `new RestApi('Api', { defaultAuthorizer: 'none', logger })`: an HTTP surface\n * with no HTTP on it, written because it was the only construct that made an\n * app exist and the only way to get a logger into the generated runtime.\n *\n * It takes no authorizer, and that is the tell that these are two constructs\n * rather than one with a flag: a `RestApi` needs one because an HTTP surface\n * can ship open by omission, and nothing reaches a worker from outside.\n *\n * ## Crons on a server target need a database\n *\n * A cron becomes an EventBridge rule on AWS and nothing here is consulted. A\n * server has nothing firing its crons but itself, and a process that schedules\n * in memory fires every job once per replica while reporting success — so the\n * schedule is kept in Postgres, and the worker says which one with\n * `.database(db)`.\n *\n * A worker with crons and no `.database(…)` schedules nothing on a server\n * target and says so at startup. That is a limitation of workers today rather\n * than a design: the store could be a cache, or something the target\n * provisions, and Postgres is what exists.\n *\n * It is not an app. A worker names the process that runs its crons and\n * subscribers, and that process is the app's server — the same one the\n * endpoints run in, minus the HTTP surface. Giving a worker a container of its\n * own made a second thing to build, deploy and keep alive for work that was\n * always going to run somewhere already. Declare as many as the shape of the\n * work wants: they are groupings, not deployments.\n *\n * @example\n * ```ts\n * // constructs/worker.ts\n * import { Worker } from '@geekmidas/constructs/worker';\n * import { logger } from './logger.js';\n *\n * export const worker = new Worker('Worker', { logger }).calls([database]);\n *\n * // crons/cleanup.ts\n * import { worker } from '@acme/constructs/worker.js';\n *\n * export const cleanup = worker\n * .cron('rate(1 day)')\n * .handle(async ({ logger }) => { … });\n * ```\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n} from '@geekmidas/manifest';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\ttype Consumable,\n\ttype Declarable,\n\tedgeTo,\n} from './construct-interface';\nimport type { ScheduleExpression } from './crons/Cron';\nimport { CronBuilder } from './crons/CronBuilder';\nimport { envParserFor } from './endpoints/surfaceEnv';\nimport { FunctionBuilder } from './functions/FunctionBuilder';\nimport { SubscriberBuilder } from './subscribers/SubscriberBuilder';\nimport type { Topic, TopicEvents } from './topic/Topic';\n\nexport interface WorkerConfig {\n\t/**\n\t * The logger everything built from this worker runs with.\n\t *\n\t * The actual logger, not a path to one — the same reason `RestApi` takes\n\t * one. Every cron and subscriber in a scaffolded project used to open with\n\t * `import { logger } from '…/constructs/logger.js'`, which is the line this\n\t * removes.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * The environment parser everything built from this worker runs with.\n\t *\n\t * Defaults to `process.env` merged with the credentials `gkm dev` injected,\n\t * which is what an application's own `config/env.ts` always was.\n\t */\n\tenvParser?: EnvironmentParser<{}>;\n}\n\nexport class Worker<TName extends string = string>\n\timplements Declarable<TName>\n{\n\treadonly id: TName;\n\n\t/** Always defined — the worker's own, or the console logger. */\n\treadonly logger: Logger;\n\n\t/** Always defined, and normally the default. */\n\treadonly envParser: EnvironmentParser<{}>;\n\n\t/**\n\t * Where this worker's schedules live, when it has crons and a server runs\n\t * them. `undefined` until `.database(…)` says.\n\t */\n\treadonly scheduleStore?: Consumable<string, unknown>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: WorkerConfig = {},\n\t\t/** Internal: how `.calls()` carries edges into the copy it returns. */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t\tscheduleStore?: Consumable<string, unknown>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.logger = config.logger ?? DEFAULT_LOGGER;\n\t\tthis.envParser = envParserFor(\n\t\t\tconfig.envParser\n\t\t\t\t? { id: canonical, envParser: config.envParser }\n\t\t\t\t: undefined,\n\t\t);\n\t\tthis.scheduleStore = scheduleStore;\n\t}\n\n\t/**\n\t * The database this worker keeps its schedules in.\n\t *\n\t * Only a server target uses it. On AWS a cron is an EventBridge rule\n\t * invoking a Lambda and nothing here is consulted — but a server has nothing\n\t * firing its crons except itself, and a process that schedules in memory\n\t * fires every job once per replica while reporting that all is well.\n\t *\n\t * So the store is declared rather than discovered. It could have been\n\t * inferred — from a database the app happens to declare, or from the events\n\t * backend when that backend is pg-boss — and both would work until an app\n\t * had two databases, or moved its events to SNS, at which point the\n\t * schedules would quietly move or stop. Naming it is one line and cannot\n\t * drift.\n\t *\n\t * @example\n\t * ```ts\n\t * export const jobs = new Worker('Jobs', { logger }).database(database);\n\t * ```\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T>,\n\t): Worker<TName> {\n\t\treturn new Worker<TName>(\n\t\t\tthis.id as ConstructName<TName>,\n\t\t\tthis.config,\n\t\t\t[...this.dependencies, edgeTo(source)],\n\t\t\tsource as unknown as Consumable<string, unknown>,\n\t\t);\n\t}\n\n\t/**\n\t * A scheduled runnable.\n\t *\n\t * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`\n\t */\n\tcron(schedule: ScheduleExpression) {\n\t\treturn this.own(new CronBuilder().logger(this.logger)).schedule(schedule);\n\t}\n\n\t/**\n\t * A runnable that consumes a topic.\n\t *\n\t * Binding is not publishing: a consumer is handed the topic's event types\n\t * and no connection string it could publish with. Chain `.publishes(…)` when\n\t * the handler emits follow-up events, which is the only reason it would need\n\t * one.\n\t *\n\t * @example `worker.topic(users).subscribe(['user.created']).handle(…)`\n\t */\n\ttopic<TTopicName extends string, TEvents extends TopicEvents>(\n\t\ttopic: Topic<TTopicName, TEvents>,\n\t) {\n\t\treturn this.own(new SubscriberBuilder().logger(this.logger)).topic(topic);\n\t}\n\n\t/**\n\t * A runnable that consumes events typed from a publisher service.\n\t *\n\t * The older of the two ways to bind a subscriber, kept for a project whose\n\t * events come from a hand-written publisher rather than a `Topic`\n\t * construct. `topic()` is the one to reach for: it types the events the same\n\t * way and hands the consumer no connection string it could publish with.\n\t */\n\tpublisher<T extends EventPublisher<any>, TPubName extends string>(\n\t\tservice: Service<TPubName, T> | Consumable<TPubName, T>,\n\t) {\n\t\treturn this.own(new SubscriberBuilder().logger(this.logger)).publisher(\n\t\t\tservice as never,\n\t\t);\n\t}\n\n\t/**\n\t * Everything below builds a function — the runnable with no schedule and no\n\t * topic, invoked by something else.\n\t *\n\t * These sit on the worker rather than behind a `functions` namespace because\n\t * the namespace was a hop that said nothing: `worker.functions.input(…)`\n\t * names a collection to reach one member of it. What kind of runnable is\n\t * being built is decided by which of these is called first — a schedule\n\t * makes a cron, a topic makes a subscriber, and anything else makes a\n\t * function.\n\t */\n\tinput<T extends ComposableStandardSchema>(schema: T) {\n\t\treturn this.functions.input(schema);\n\t}\n\n\toutput<T extends StandardSchemaV1>(schema: T) {\n\t\treturn this.functions.output(schema);\n\t}\n\n\ttimeout(ms: number) {\n\t\treturn this.functions.timeout(ms);\n\t}\n\n\tmemorySize(mb: number) {\n\t\treturn this.functions.memorySize(mb);\n\t}\n\n\tdependsOn<const T extends readonly Consumable[]>(constructs: T) {\n\t\treturn this.functions.dependsOn(constructs);\n\t}\n\n\tservices<T extends Service[]>(services: T) {\n\t\treturn this.functions.services(services);\n\t}\n\n\t/**\n\t * A function with no input schema — the shortest runnable there is.\n\t *\n\t * @example `worker.handle(async ({ logger }) => { … })`\n\t */\n\thandle(\n\t\t...args: Parameters<\n\t\t\tReturnType<Worker<TName>['schemalessFunction']>['handle']\n\t\t>\n\t) {\n\t\treturn this.schemalessFunction().handle(...args);\n\t}\n\n\t/** The builder `handle` delegates to, named so its type can be referred to. */\n\tprivate schemalessFunction() {\n\t\treturn this.functions;\n\t}\n\n\t/** The function builder the delegating methods above are built on. */\n\tprivate get functions() {\n\t\treturn this.own(new FunctionBuilder().logger(this.logger));\n\t}\n\n\t/**\n\t * Resources and surfaces this worker calls.\n\t *\n\t * Not `.dependsOn()`: this records the edge that derives the worker's\n\t * environment and its access, the same distinction `RestApi.calls()` draws.\n\t */\n\tcalls(constructs: readonly Declarable[]): Worker<TName> {\n\t\treturn new Worker<TName>(\n\t\t\tthis.id as ConstructName<TName>,\n\t\t\tthis.config,\n\t\t\t[...this.dependencies, ...constructs.map(edgeTo)],\n\t\t\tthis.scheduleStore,\n\t\t);\n\t}\n\n\t/**\n\t * Stamps this worker's id onto a builder, so everything built from it says\n\t * which process runs it.\n\t */\n\tprivate own<T extends { _owner?: string; _scheduleStore?: unknown }>(\n\t\tbuilder: T,\n\t): T {\n\t\tbuilder._owner = this.id;\n\t\tbuilder._scheduleStore = this.scheduleStore;\n\n\t\treturn builder;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'worker',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.dependencies.length\n\t\t\t\t\t? { dependencies: this.dependencies }\n\t\t\t\t\t: {}),\n\t\t\t\t// Nothing calls a worker, so it publishes no address.\n\t\t\t\tprovides: [],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;AAoGA,IAAa,SAAb,MAAa,OAEb;CAiBmB;CAEA;CAlBlB;;CAGA;;CAGA;;;;;CAMA;CAEA,YACC,IACA,SAAwC,CAAC,GAEzC,eAAuD,CAAC,GACxD,eACC;EAJgB,KAAA,SAAA;EAEA,KAAA,eAAA;EAGjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,SAAS,OAAO,UAAU;EAC/B,KAAK,YAAY,aAChB,OAAO,YACJ;GAAE,IAAI;GAAW,WAAW,OAAO;EAAU,IAC7C,KAAA,CACJ;EACA,KAAK,gBAAgB;CACtB;;;;;;;;;;;;;;;;;;;;;CAsBA,SACC,QACgB;EAChB,OAAO,IAAI,OACV,KAAK,IACL,KAAK,QACL,CAAC,GAAG,KAAK,cAAc,OAAO,MAAM,CAAC,GACrC,MACD;CACD;;;;;;CAOA,KAAK,UAA8B;EAClC,OAAO,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,OAAO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I,KAAK,aAAa,SACnB,EAAE,cAAc,KAAK,aAAa,IAClC,CAAC;GAEJ,UAAU,CAAC;EACZ,CACD;CACD;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/constructs",
3
- "version": "10.0.0-alpha.3",
3
+ "version": "10.0.0-alpha.30",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -244,14 +244,14 @@
244
244
  "lodash.set": "~4.3.2",
245
245
  "lodash.uniqby": "~4.7.0",
246
246
  "openapi-types": "~12.1.3",
247
- "qs": "~6.15.0",
248
- "@geekmidas/envkit": "^10.0.0-alpha.3",
249
- "@geekmidas/errors": "^10.0.0-alpha.3",
250
- "@geekmidas/events": "^10.0.0-alpha.3",
251
- "@geekmidas/logger": "^10.0.0-alpha.3",
252
- "@geekmidas/manifest": "^10.0.0-alpha.3",
253
- "@geekmidas/schema": "^10.0.0-alpha.3",
254
- "@geekmidas/services": "^10.0.0-alpha.3"
247
+ "qs": "~6.16.0",
248
+ "@geekmidas/envkit": "^10.0.0-alpha.30",
249
+ "@geekmidas/errors": "^10.0.0-alpha.30",
250
+ "@geekmidas/events": "^10.0.0-alpha.30",
251
+ "@geekmidas/logger": "^10.0.0-alpha.30",
252
+ "@geekmidas/manifest": "^10.0.0-alpha.30",
253
+ "@geekmidas/schema": "^10.0.0-alpha.30",
254
+ "@geekmidas/services": "^10.0.0-alpha.30"
255
255
  },
256
256
  "devDependencies": {
257
257
  "@types/lodash.compact": "~3.0.9",
@@ -259,44 +259,45 @@
259
259
  "@types/lodash.pick": "~4.4.9",
260
260
  "@types/lodash.set": "~4.3.9",
261
261
  "@types/lodash.uniqby": "~4.7.9",
262
- "@types/pg": "~8.15.6",
263
- "@types/qs": "~6.15.0",
264
- "better-auth": "~1.4.18",
265
- "kysely": "~0.29.4",
266
- "msw": "~2.10.3",
267
- "pg": "~8.16.3",
268
- "zod": "~4.1.13",
269
- "@geekmidas/audit": "^10.0.0-alpha.3",
270
- "@geekmidas/auth": "10.0.0-alpha.3",
271
- "@geekmidas/cache": "^10.0.0-alpha.3",
272
- "@geekmidas/db": "^10.0.0-alpha.3",
273
- "@geekmidas/emailkit": "^10.0.0-alpha.3",
274
- "@geekmidas/envkit": "^10.0.0-alpha.3",
275
- "@geekmidas/errors": "^10.0.0-alpha.3",
276
- "@geekmidas/events": "^10.0.0-alpha.3",
277
- "@geekmidas/logger": "^10.0.0-alpha.3",
278
- "@geekmidas/rate-limit": "^10.0.0-alpha.3",
279
- "@geekmidas/schema": "^10.0.0-alpha.3",
280
- "@geekmidas/services": "^10.0.0-alpha.3",
281
- "@geekmidas/telescope": "10.0.0-alpha.3",
282
- "@geekmidas/testkit": "^10.0.0-alpha.3"
262
+ "@types/pg": "~8.23.1",
263
+ "@types/qs": "~6.15.1",
264
+ "better-auth": "~1.7.6",
265
+ "kysely": "~0.29.6",
266
+ "msw": "~2.15.0",
267
+ "pg": "~8.23.0",
268
+ "zod": "~4.6.5",
269
+ "@geekmidas/audit": "^10.0.0-alpha.30",
270
+ "@geekmidas/auth": "10.0.0-alpha.30",
271
+ "@geekmidas/cache": "^10.0.0-alpha.30",
272
+ "@geekmidas/db": "^10.0.0-alpha.30",
273
+ "@geekmidas/emailkit": "^10.0.0-alpha.30",
274
+ "@geekmidas/envkit": "^10.0.0-alpha.30",
275
+ "@geekmidas/errors": "^10.0.0-alpha.30",
276
+ "@geekmidas/events": "^10.0.0-alpha.30",
277
+ "@geekmidas/logger": "^10.0.0-alpha.30",
278
+ "@geekmidas/rate-limit": "^10.0.0-alpha.30",
279
+ "@geekmidas/schema": "^10.0.0-alpha.30",
280
+ "@geekmidas/services": "^10.0.0-alpha.30",
281
+ "@geekmidas/telescope": "10.0.0-alpha.30",
282
+ "@geekmidas/testkit": "^10.0.0-alpha.30"
283
283
  },
284
284
  "peerDependencies": {
285
- "@middy/core": ">=6.3.1",
286
- "@types/aws-lambda": ">=8.10.92",
287
- "better-auth": ">=1.4.18",
288
- "hono": ">=4.8.2",
289
- "kysely": ">=0.28.2 <0.30.0",
290
- "msw": ">=2.0.0",
291
- "pg": "~8.16.3",
292
- "@geekmidas/audit": "^10.0.0-alpha.3",
293
- "@geekmidas/auth": "10.0.0-alpha.3",
294
- "@geekmidas/cache": "^10.0.0-alpha.3",
295
- "@geekmidas/db": "^10.0.0-alpha.3",
296
- "@geekmidas/emailkit": "^10.0.0-alpha.3",
297
- "@geekmidas/rate-limit": "^10.0.0-alpha.3",
298
- "@geekmidas/storage": "^10.0.0-alpha.3",
299
- "@geekmidas/telescope": "10.0.0-alpha.3"
285
+ "@middy/core": ">=7.9.2",
286
+ "@types/aws-lambda": ">=8.10.163",
287
+ "better-auth": ">=1.7.5",
288
+ "hono": ">=4.13.8",
289
+ "kysely": "~0.29.6",
290
+ "msw": ">=2.15.0",
291
+ "pg": ">=8.23.0",
292
+ "@geekmidas/audit": "^10.0.0-alpha.30",
293
+ "@geekmidas/auth": "10.0.0-alpha.30",
294
+ "@geekmidas/cache": "^10.0.0-alpha.30",
295
+ "@geekmidas/db": "^10.0.0-alpha.30",
296
+ "@geekmidas/emailkit": "^10.0.0-alpha.30",
297
+ "@geekmidas/rate-limit": "^10.0.0-alpha.30",
298
+ "@geekmidas/storage": "^10.0.0-alpha.30",
299
+ "@geekmidas/telescope": "10.0.0-alpha.30",
300
+ "@geekmidas/testkit": "^10.0.0-alpha.30"
300
301
  },
301
302
  "peerDependenciesMeta": {
302
303
  "@geekmidas/audit": {
@@ -308,37 +309,40 @@
308
309
  "@geekmidas/db": {
309
310
  "optional": true
310
311
  },
312
+ "@geekmidas/emailkit": {
313
+ "optional": true
314
+ },
311
315
  "@geekmidas/rate-limit": {
312
316
  "optional": true
313
317
  },
314
- "@middy/core": {
318
+ "@geekmidas/storage": {
315
319
  "optional": true
316
320
  },
317
- "@types/aws-lambda": {
321
+ "@geekmidas/telescope": {
318
322
  "optional": true
319
323
  },
320
- "hono": {
324
+ "@geekmidas/testkit": {
321
325
  "optional": true
322
326
  },
323
- "msw": {
327
+ "@middy/core": {
324
328
  "optional": true
325
329
  },
326
- "@geekmidas/storage": {
330
+ "@types/aws-lambda": {
327
331
  "optional": true
328
332
  },
329
- "kysely": {
333
+ "better-auth": {
330
334
  "optional": true
331
335
  },
332
- "pg": {
336
+ "hono": {
333
337
  "optional": true
334
338
  },
335
- "@geekmidas/emailkit": {
339
+ "kysely": {
336
340
  "optional": true
337
341
  },
338
- "better-auth": {
342
+ "msw": {
339
343
  "optional": true
340
344
  },
341
- "@geekmidas/telescope": {
345
+ "pg": {
342
346
  "optional": true
343
347
  }
344
348
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"Construct-BD5neF7w.mjs","names":["compact","snifferContext: ServiceContext","type: ConstructType","logger: TLogger","services: TServices","events: MappedEvent<T, any>[]","publisherService?: Service<TServiceName, T>","outputSchema?: OutSchema","timeout?: number","memorySize?: number","auditorStorageService?: Service<\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditStorage\n\t\t>","constructs: string[]","opts: { markOptional?: boolean }","services: Service[]","service: Service"],"sources":["../../../node_modules/.pnpm/lodash.compact@3.0.1/node_modules/lodash.compact/index.js","../src/Construct.ts"],"sourcesContent":["/**\n * lodash 3.0.1 (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Available under MIT license <https://lodash.com/license>\n */\n\n/**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\nfunction compact(array) {\n var index = -1,\n length = array ? array.length : 0,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nmodule.exports = compact;\n","import type { AuditStorage } from '@geekmidas/audit';\nimport {\n\tSnifferEnvironmentParser,\n\ttype SniffResult,\n\tsniffWithFireAndForget,\n} from '@geekmidas/envkit/sniffer';\nimport type { EventPublisher, MappedEvent } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { Service, ServiceContext } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport compact from 'lodash.compact';\n\n// Cache for service environment variables to handle singleton services\n// Stores both the full list and the optional subset so the same sniff result\n// can satisfy both getEnvironment() and getEnvironment({ markOptional: true }).\nconst serviceEnvCache = new Map<\n\tService,\n\t{ envVars: string[]; optionalEnvVars: string[] }\n>();\n\n/**\n * Noop context for environment sniffing.\n * Used when calling service.register() to detect env vars without a real request.\n * Returns dummy values since services should only use context in instance methods,\n * not during registration.\n */\nconst snifferContext: ServiceContext = {\n\tgetLogger() {\n\t\t// Return a noop logger for sniffing - services shouldn't log during registration\n\t\treturn {\n\t\t\tdebug: () => {},\n\t\t\tinfo: () => {},\n\t\t\twarn: () => {},\n\t\t\terror: () => {},\n\t\t\tchild: () => snifferContext.getLogger(),\n\t\t} as unknown as Logger;\n\t},\n\tgetRequestId() {\n\t\treturn 'sniffer-context';\n\t},\n\tgetRequestStartTime() {\n\t\treturn Date.now();\n\t},\n\thasContext() {\n\t\treturn false;\n\t},\n};\n\nexport abstract class Construct<\n\tTLogger extends Logger = Logger,\n\tTServiceName extends string = string,\n\tT extends EventPublisher<any> | undefined = undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTAuditStorageServiceName extends string = string,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTDatabaseServiceName extends string = string,\n\tTDatabase = unknown,\n> {\n\t/** Database service for this construct (used by Endpoint for RLS/audit context) */\n\tpublic databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\n\t/**\n\t * The deploy unit that runs this, by construct id.\n\t *\n\t * What an endpoint's `surface` is to it, and for the same reason: something\n\t * has to say which process a runnable belongs to, and until this existed the\n\t * only thing that said so was the directory its file sat in. Set by the\n\t * factory it was built from — `worker.crons`, `api.endpoints` — so it is\n\t * carried rather than configured.\n\t *\n\t * Undefined for a construct built from a free-standing builder, which is\n\t * still how `c`, `s` and `f` work.\n\t */\n\tpublic owner?: string;\n\n\tconstructor(\n\t\tpublic readonly type: ConstructType,\n\t\tpublic readonly logger: TLogger,\n\t\tpublic readonly services: TServices,\n\t\tpublic readonly events: MappedEvent<T, any>[] = [],\n\t\tpublic readonly publisherService?: Service<TServiceName, T>,\n\t\tpublic outputSchema?: OutSchema,\n\t\tpublic readonly timeout?: number,\n\t\tpublic readonly memorySize?: number,\n\t\tpublic readonly auditorStorageService?: Service<\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditStorage\n\t\t>,\n\t\t/**\n\t\t * The constructs this one declared an edge to, by id.\n\t\t *\n\t\t * What the manifest records. `services` is the same information in the\n\t\t * form a handler runs with — clients, keyed by name — and an id cannot be\n\t\t * recovered from one of those reliably, so both are kept.\n\t\t *\n\t\t * Last in the list because every other parameter is positional and already\n\t\t * spoken for; a new one anywhere else silently rebinds existing callers.\n\t\t */\n\t\tpublic readonly constructs: string[] = [],\n\t) {}\n\n\t/**\n\t * Returns an array of environment variable names required by this construct's services.\n\t * This is determined by running a \"sniffer\" EnvironmentParser through each service's\n\t * register method to track which environment variables are accessed.\n\t *\n\t * Results are cached per service class to handle singleton patterns where\n\t * subsequent register() calls may short-circuit and not access env vars.\n\t *\n\t * @param markOptional - When true, optional vars (those accessed via `.optional()` or\n\t * `.default()`) are suffixed with `?` in the returned array (e.g. `'PORT?'`).\n\t * @returns Promise that resolves to array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const endpoint = e\n\t * .services([databaseService, authService])\n\t * .get('/users')\n\t * .handle(async () => []);\n\t *\n\t * await endpoint.getEnvironment(); // ['AUTH_SECRET', 'DATABASE_URL']\n\t * await endpoint.getEnvironment({ markOptional: true }); // ['AUTH_SECRET', 'DATABASE_URL', 'PORT?']\n\t * ```\n\t */\n\tasync getEnvironment(\n\t\topts: { markOptional?: boolean } = {},\n\t): Promise<string[]> {\n\t\tconst { markOptional = false } = opts;\n\t\tconst envVars = new Set<string>();\n\t\tconst optionalVars = new Set<string>();\n\t\tconst services: Service[] = compact([\n\t\t\t...this.services,\n\t\t\tthis.publisherService,\n\t\t\tthis.publisherService,\n\t\t\tthis.auditorStorageService,\n\t\t\tthis.databaseService,\n\t\t]);\n\n\t\ttry {\n\t\t\tfor (const service of services) {\n\t\t\t\t// Check cache first - handles singleton services that short-circuit\n\t\t\t\tif (serviceEnvCache.has(service)) {\n\t\t\t\t\tconst cached = serviceEnvCache.get(service)!;\n\t\t\t\t\tcached.envVars.forEach((v) => envVars.add(v));\n\t\t\t\t\tcached.optionalEnvVars.forEach((v) => optionalVars.add(v));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Use sniffService to properly handle all error scenarios\n\t\t\t\tconst result = await sniffService(service);\n\n\t\t\t\t// Log any issues for debugging\n\t\t\t\tif (result.error) {\n\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t{ error: result.error.message, service: service.serviceName },\n\t\t\t\t\t\t'Service threw error during env sniffing (env vars still captured)',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (result.unhandledRejections.length > 0) {\n\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\terrors: result.unhandledRejections.map((e) => e.message),\n\t\t\t\t\t\t\tservice: service.serviceName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'Fire-and-forget rejections during env sniffing (suppressed)',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Cache and collect env vars (both required and optional)\n\t\t\t\tserviceEnvCache.set(service, {\n\t\t\t\t\tenvVars: result.envVars,\n\t\t\t\t\toptionalEnvVars: result.optionalEnvVars,\n\t\t\t\t});\n\t\t\t\tresult.envVars.forEach((v) => envVars.add(v));\n\t\t\t\tresult.optionalEnvVars.forEach((v) => optionalVars.add(v));\n\t\t\t}\n\n\t\t\tconst sorted = Array.from(envVars).sort();\n\t\t\tif (!markOptional || optionalVars.size === 0) return sorted;\n\t\t\treturn sorted.map((v) => (optionalVars.has(v) ? `${v}?` : v));\n\t\t} catch (error) {\n\t\t\tthis.logger.error(\n\t\t\t\t{ error },\n\t\t\t\t'Error determining environment variables for construct',\n\t\t\t);\n\n\t\t\treturn [];\n\t\t}\n\t}\n}\n\nexport enum ConstructType {\n\tCron = 'dev.geekmidas.function.cron',\n\tEndpoint = 'dev.geekmidas.function.endpoint',\n\tFunction = 'dev.geekmidas.function.function',\n\tSubscriber = 'dev.geekmidas.function.subscriber',\n\tQueue = 'dev.geekmidas.function.queue',\n\tTopic = 'dev.geekmidas.resource.topic',\n}\n\n/**\n * Utility to test sniffing a service for environment variables.\n * Useful for debugging services that throw errors during sniffing.\n *\n * @example\n * ```typescript\n * import { sniffService } from '@geekmidas/constructs';\n * import { authService } from './services/AuthService';\n *\n * const result = await sniffService(authService);\n * console.log('Env vars:', result.envVars);\n * console.log('Error:', result.error);\n * ```\n */\nexport async function sniffService(service: Service): Promise<SniffResult> {\n\tconst sniffer = new SnifferEnvironmentParser();\n\n\treturn sniffWithFireAndForget(sniffer, () =>\n\t\tservice.register({\n\t\t\tenvParser: sniffer as any,\n\t\t\tcontext: snifferContext,\n\t\t}),\n\t);\n}\n\n// Export for testing\nexport { snifferContext };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBA,SAASA,UAAQ,OAAO;EACtB,IAAI,QAAQ,IACR,SAAS,QAAQ,MAAM,SAAS,GAChC,WAAW,GACX,SAAS,CAAE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,wBAL0C,EAM1C,aAN0C,CAAA,GAAA,SAAA;EAAY;;;;;;;;;;EAJpB,SACX,UAAA,EAAA,MAAA,EAAA;EAAO;EACI,eACC,CAAA,EApBZ,OAoBY,CApBJ,oBAoBI,EApBkB,SAoBlB,CAAA;EAAC;;;;;;;;;AA+C5B;AAiEX;AAuBA;EAAkC,KAAA,CAAA,EAAA,MAAA;EAAA,WAAU,CAAA,IAAA,EA1IpB,aA0IoB,EAAA,MAAA,EAzIlB,OAyIkB,EAAA,QAAA,EAxIhB,SAwIgB,EAAA,MAAA,CAAA,EAvIlB,WAuIkB,CAvIN,CAuIM,EAAA,GAAA,CAAA,EAAA,EAAA,gBAAA,CAAA,EAtIP,OAsIO,CAtIC,YAsID,EAtIe,CAsIf,CAAA,GAAA,SAAA,EAAA,YAAA,CAAA,EArIpB,SAqIoB,GAAA,SAAA,EAAA,OAAA,CAAA,EAAA,MAAA,GAAA,SAAA,EAAA,UAAA,CAAA,EAAA,MAAA,GAAA,SAAA,EAAA,qBAAA,CAAA,EAlIF,OAkIE,CAjIzC,wBAiIyC,EAhIzC,aAgIyC,CAAA,GAAA,SAAA;EAAO;;AAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAxFzD;;aAiEQ,aAAA;;;;;;;;;;;;;;;;;;;;;;iBAuBU,YAAA,UAAsB,UAAU,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Construct-CyS3RpTL.cjs","names":["compact","snifferContext: ServiceContext","type: ConstructType","logger: TLogger","services: TServices","events: MappedEvent<T, any>[]","publisherService?: Service<TServiceName, T>","outputSchema?: OutSchema","timeout?: number","memorySize?: number","auditorStorageService?: Service<\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditStorage\n\t\t>","constructs: string[]","opts: { markOptional?: boolean }","services: Service[]","service: Service","SnifferEnvironmentParser"],"sources":["../../../node_modules/.pnpm/lodash.compact@3.0.1/node_modules/lodash.compact/index.js","../src/Construct.ts"],"sourcesContent":["/**\n * lodash 3.0.1 (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Available under MIT license <https://lodash.com/license>\n */\n\n/**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\nfunction compact(array) {\n var index = -1,\n length = array ? array.length : 0,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nmodule.exports = compact;\n","import type { AuditStorage } from '@geekmidas/audit';\nimport {\n\tSnifferEnvironmentParser,\n\ttype SniffResult,\n\tsniffWithFireAndForget,\n} from '@geekmidas/envkit/sniffer';\nimport type { EventPublisher, MappedEvent } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { Service, ServiceContext } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport compact from 'lodash.compact';\n\n// Cache for service environment variables to handle singleton services\n// Stores both the full list and the optional subset so the same sniff result\n// can satisfy both getEnvironment() and getEnvironment({ markOptional: true }).\nconst serviceEnvCache = new Map<\n\tService,\n\t{ envVars: string[]; optionalEnvVars: string[] }\n>();\n\n/**\n * Noop context for environment sniffing.\n * Used when calling service.register() to detect env vars without a real request.\n * Returns dummy values since services should only use context in instance methods,\n * not during registration.\n */\nconst snifferContext: ServiceContext = {\n\tgetLogger() {\n\t\t// Return a noop logger for sniffing - services shouldn't log during registration\n\t\treturn {\n\t\t\tdebug: () => {},\n\t\t\tinfo: () => {},\n\t\t\twarn: () => {},\n\t\t\terror: () => {},\n\t\t\tchild: () => snifferContext.getLogger(),\n\t\t} as unknown as Logger;\n\t},\n\tgetRequestId() {\n\t\treturn 'sniffer-context';\n\t},\n\tgetRequestStartTime() {\n\t\treturn Date.now();\n\t},\n\thasContext() {\n\t\treturn false;\n\t},\n};\n\nexport abstract class Construct<\n\tTLogger extends Logger = Logger,\n\tTServiceName extends string = string,\n\tT extends EventPublisher<any> | undefined = undefined,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTAuditStorageServiceName extends string = string,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTDatabaseServiceName extends string = string,\n\tTDatabase = unknown,\n> {\n\t/** Database service for this construct (used by Endpoint for RLS/audit context) */\n\tpublic databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\n\t/**\n\t * The deploy unit that runs this, by construct id.\n\t *\n\t * What an endpoint's `surface` is to it, and for the same reason: something\n\t * has to say which process a runnable belongs to, and until this existed the\n\t * only thing that said so was the directory its file sat in. Set by the\n\t * factory it was built from — `worker.crons`, `api.endpoints` — so it is\n\t * carried rather than configured.\n\t *\n\t * Undefined for a construct built from a free-standing builder, which is\n\t * still how `c`, `s` and `f` work.\n\t */\n\tpublic owner?: string;\n\n\tconstructor(\n\t\tpublic readonly type: ConstructType,\n\t\tpublic readonly logger: TLogger,\n\t\tpublic readonly services: TServices,\n\t\tpublic readonly events: MappedEvent<T, any>[] = [],\n\t\tpublic readonly publisherService?: Service<TServiceName, T>,\n\t\tpublic outputSchema?: OutSchema,\n\t\tpublic readonly timeout?: number,\n\t\tpublic readonly memorySize?: number,\n\t\tpublic readonly auditorStorageService?: Service<\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditStorage\n\t\t>,\n\t\t/**\n\t\t * The constructs this one declared an edge to, by id.\n\t\t *\n\t\t * What the manifest records. `services` is the same information in the\n\t\t * form a handler runs with — clients, keyed by name — and an id cannot be\n\t\t * recovered from one of those reliably, so both are kept.\n\t\t *\n\t\t * Last in the list because every other parameter is positional and already\n\t\t * spoken for; a new one anywhere else silently rebinds existing callers.\n\t\t */\n\t\tpublic readonly constructs: string[] = [],\n\t) {}\n\n\t/**\n\t * Returns an array of environment variable names required by this construct's services.\n\t * This is determined by running a \"sniffer\" EnvironmentParser through each service's\n\t * register method to track which environment variables are accessed.\n\t *\n\t * Results are cached per service class to handle singleton patterns where\n\t * subsequent register() calls may short-circuit and not access env vars.\n\t *\n\t * @param markOptional - When true, optional vars (those accessed via `.optional()` or\n\t * `.default()`) are suffixed with `?` in the returned array (e.g. `'PORT?'`).\n\t * @returns Promise that resolves to array of environment variable names, sorted alphabetically\n\t *\n\t * @example\n\t * ```typescript\n\t * const endpoint = e\n\t * .services([databaseService, authService])\n\t * .get('/users')\n\t * .handle(async () => []);\n\t *\n\t * await endpoint.getEnvironment(); // ['AUTH_SECRET', 'DATABASE_URL']\n\t * await endpoint.getEnvironment({ markOptional: true }); // ['AUTH_SECRET', 'DATABASE_URL', 'PORT?']\n\t * ```\n\t */\n\tasync getEnvironment(\n\t\topts: { markOptional?: boolean } = {},\n\t): Promise<string[]> {\n\t\tconst { markOptional = false } = opts;\n\t\tconst envVars = new Set<string>();\n\t\tconst optionalVars = new Set<string>();\n\t\tconst services: Service[] = compact([\n\t\t\t...this.services,\n\t\t\tthis.publisherService,\n\t\t\tthis.publisherService,\n\t\t\tthis.auditorStorageService,\n\t\t\tthis.databaseService,\n\t\t]);\n\n\t\ttry {\n\t\t\tfor (const service of services) {\n\t\t\t\t// Check cache first - handles singleton services that short-circuit\n\t\t\t\tif (serviceEnvCache.has(service)) {\n\t\t\t\t\tconst cached = serviceEnvCache.get(service)!;\n\t\t\t\t\tcached.envVars.forEach((v) => envVars.add(v));\n\t\t\t\t\tcached.optionalEnvVars.forEach((v) => optionalVars.add(v));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Use sniffService to properly handle all error scenarios\n\t\t\t\tconst result = await sniffService(service);\n\n\t\t\t\t// Log any issues for debugging\n\t\t\t\tif (result.error) {\n\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t{ error: result.error.message, service: service.serviceName },\n\t\t\t\t\t\t'Service threw error during env sniffing (env vars still captured)',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (result.unhandledRejections.length > 0) {\n\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\terrors: result.unhandledRejections.map((e) => e.message),\n\t\t\t\t\t\t\tservice: service.serviceName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'Fire-and-forget rejections during env sniffing (suppressed)',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Cache and collect env vars (both required and optional)\n\t\t\t\tserviceEnvCache.set(service, {\n\t\t\t\t\tenvVars: result.envVars,\n\t\t\t\t\toptionalEnvVars: result.optionalEnvVars,\n\t\t\t\t});\n\t\t\t\tresult.envVars.forEach((v) => envVars.add(v));\n\t\t\t\tresult.optionalEnvVars.forEach((v) => optionalVars.add(v));\n\t\t\t}\n\n\t\t\tconst sorted = Array.from(envVars).sort();\n\t\t\tif (!markOptional || optionalVars.size === 0) return sorted;\n\t\t\treturn sorted.map((v) => (optionalVars.has(v) ? `${v}?` : v));\n\t\t} catch (error) {\n\t\t\tthis.logger.error(\n\t\t\t\t{ error },\n\t\t\t\t'Error determining environment variables for construct',\n\t\t\t);\n\n\t\t\treturn [];\n\t\t}\n\t}\n}\n\nexport enum ConstructType {\n\tCron = 'dev.geekmidas.function.cron',\n\tEndpoint = 'dev.geekmidas.function.endpoint',\n\tFunction = 'dev.geekmidas.function.function',\n\tSubscriber = 'dev.geekmidas.function.subscriber',\n\tQueue = 'dev.geekmidas.function.queue',\n\tTopic = 'dev.geekmidas.resource.topic',\n}\n\n/**\n * Utility to test sniffing a service for environment variables.\n * Useful for debugging services that throw errors during sniffing.\n *\n * @example\n * ```typescript\n * import { sniffService } from '@geekmidas/constructs';\n * import { authService } from './services/AuthService';\n *\n * const result = await sniffService(authService);\n * console.log('Env vars:', result.envVars);\n * console.log('Error:', result.error);\n * ```\n */\nexport async function sniffService(service: Service): Promise<SniffResult> {\n\tconst sniffer = new SnifferEnvironmentParser();\n\n\treturn sniffWithFireAndForget(sniffer, () =>\n\t\tservice.register({\n\t\t\tenvParser: sniffer as any,\n\t\t\tcontext: snifferContext,\n\t\t}),\n\t);\n}\n\n// Export for testing\nexport { snifferContext };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBA,SAASA,UAAQ,OAAO;EACtB,IAAI,QAAQ,IACR,SAAS,QAAQ,MAAM,SAAS,GAChC,WAAW,GACX,SAAS,CAAE;AAEf,SAAO,EAAE,QAAQ,QAAQ;GACvB,IAAI,QAAQ,MAAM;AAClB,OAAI,MACF,QAAO,cAAc;EAExB;AACD,SAAO;CACR;AAED,QAAO,UAAUA;;;;;;ACvBjB,MAAM,kCAAkB,IAAI;;;;;;;AAW5B,MAAMC,iBAAiC;CACtC,YAAY;AAEX,SAAO;GACN,OAAO,MAAM,CAAE;GACf,MAAM,MAAM,CAAE;GACd,MAAM,MAAM,CAAE;GACd,OAAO,MAAM,CAAE;GACf,OAAO,MAAM,eAAe,WAAW;EACvC;CACD;CACD,eAAe;AACd,SAAO;CACP;CACD,sBAAsB;AACrB,SAAO,KAAK,KAAK;CACjB;CACD,aAAa;AACZ,SAAO;CACP;AACD;AAED,IAAsB,YAAtB,MAUE;;CAED,AAAO;;;;;;;;;;;;;CAcP,AAAO;CAEP,YACiBC,MACAC,QACAC,UACAC,SAAgC,CAAE,GAClCC,kBACTC,cACSC,SACAC,YACAC,uBAcAC,aAAuB,CAAE,GACxC;EAvBe;EACA;EACA;EACA;EACA;EACT;EACS;EACA;EACA;EAcA;CACb;;;;;;;;;;;;;;;;;;;;;;;;CAyBJ,MAAM,eACLC,OAAmC,CAAE,GACjB;EACpB,MAAM,EAAE,eAAe,OAAO,GAA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MA,EAiMA,0BAjMA,EAkMA,CAlMA,EAmMA,KAnMA,CAAA;EAAO,MACP,CAAA,EAAA,EAwNI,eAxNJ,CAwNoB,MAxNpB,EAwN4B,SAxN5B,EAwNuC,OAxNvC,EAwNgD,SAxNhD,EAwN2D,SAxN3D,CAAA,CAAA,EAyNE,IAzNF,CA0NA,MA1NA,EA2NA,SA3NA,EA4NA,OA5NA,EA6NA,SA7NA,EA8NA,eA9NA,EA+NA,0BA/NA,EAgOA,SAhOA,EAiOA,oBAjOA,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"CronBuilder-BmABazzH.mjs","names":["obj: any","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>","timeout?: number","_schedule?: ScheduleExpression","input?: TInput","outputSchema?: OutSchema","services: TServices","logger?: TLogger","publisherService?: Service<TEventPublisherServiceName, TEventPublisher>","events: any[]","memorySize?: number","databaseService?: Service<TDatabaseServiceName, TDatabase>","constructs: string[]","memorySize: number","_expression: ScheduleExpression","schema: T","constructs: T","s: Service","services: T","logger: T","publisher: Service<TName, T>","source: Consumable<TName, T> | Service<TName, T>","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>"],"sources":["../src/crons/Cron.ts","../src/crons/CronBuilder.ts"],"sourcesContent":["import type { AuditableAction } from '@geekmidas/audit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\nimport { ConstructType } from '../Construct';\nimport { Function, type FunctionHandler } from '../functions';\n\nexport class Cron<\n\tTInput extends ComposableStandardSchema | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends Function<\n\tTInput,\n\tTServices,\n\tTLogger,\n\tOutSchema,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName,\n\tAuditableAction<string, unknown>,\n\tFunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>\n> {\n\tstatic isCron(obj: any): obj is Cron<any, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as Function).__IS_FUNCTION__ === true &&\n\t\t\t\tobj.type === ConstructType.Cron,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t\ttimeout?: number,\n\t\tprotected _schedule?: ScheduleExpression,\n\t\tinput?: TInput,\n\t\toutputSchema?: OutSchema,\n\t\tservices: TServices = [] as unknown as TServices,\n\t\tlogger?: TLogger,\n\t\tpublisherService?: Service<TEventPublisherServiceName, TEventPublisher>,\n\t\tevents: any[] = [],\n\t\tmemorySize?: number,\n\t\tdatabaseService?: Service<TDatabaseServiceName, TDatabase>,\n\t\t/**\n\t\t * The construct ids `.dependsOn()` named — last, so no existing positional\n\t\t * argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tfn,\n\t\t\ttimeout,\n\t\t\tConstructType.Cron,\n\t\t\tinput,\n\t\t\toutputSchema,\n\t\t\tservices,\n\t\t\tlogger,\n\t\t\tpublisherService,\n\t\t\tevents,\n\t\t\tmemorySize,\n\t\t\tundefined, // auditorStorageService\n\t\t\tdatabaseService,\n\t\t\tconstructs,\n\t\t);\n\t}\n\n\tget schedule(): ScheduleExpression | undefined {\n\t\treturn this._schedule;\n\t}\n}\n\nexport type RateExpression = `rate(${string})`;\n\ntype CronMinute =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronHour =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronDay =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronMonth =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'JAN'\n\t| 'FEB'\n\t| 'MAR'\n\t| 'APR'\n\t| 'MAY'\n\t| 'JUN'\n\t| 'JUL'\n\t| 'AUG'\n\t| 'SEP'\n\t| 'OCT'\n\t| 'NOV'\n\t| 'DEC'\n\t| string; // Allow more complex patterns\n\ntype CronWeekday =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'SUN'\n\t| 'MON'\n\t| 'TUE'\n\t| 'WED'\n\t| 'THU'\n\t| 'FRI'\n\t| 'SAT'\n\t| `${string}-${string}` // Allow patterns like MON-FRI\n\t| string; // Allow more complex patterns\n\nexport type CronExpression =\n\t`cron(${CronMinute} ${CronHour} ${CronDay} ${CronMonth} ${CronWeekday})`;\n\nexport type ScheduleExpression = RateExpression | CronExpression;\n","import type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport uniqBy from 'lodash.uniqby';\nimport { ConstructType } from '../Construct';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tserviceOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { FunctionBuilder, type FunctionHandler } from '../functions';\nimport { Cron, type ScheduleExpression } from './Cron';\n\nexport class CronBuilder<\n\tTInput extends ComposableStandardSchema,\n\tTServices extends Service[],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends FunctionBuilder<\n\tTInput,\n\tOutSchema,\n\tTServices,\n\tTLogger,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName\n> {\n\tprivate _schedule?: ScheduleExpression;\n\n\tconstructor() {\n\t\tsuper(ConstructType.Cron);\n\t}\n\n\toverride memorySize(memorySize: number): this {\n\t\treturn cloneWith(this, { _memorySize: memorySize });\n\t}\n\n\tschedule(\n\t\t_expression: ScheduleExpression,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _schedule: _expression });\n\t}\n\n\toverride input<T extends ComposableStandardSchema>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\tinputSchema: schema as unknown as TInput,\n\t\t}) as unknown as CronBuilder<\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride output<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tT,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\toutputSchema: schema as unknown as OutSchema,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\toverride dependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: uniqBy(\n\t\t\t\t[...this._services, ...services],\n\t\t\t\t(s: Service) => s.serviceName,\n\t\t\t),\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride services<T extends Service[]>(\n\t\tservices: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: uniqBy(\n\t\t\t\t[...this._services, ...services],\n\t\t\t\t(s) => s.serviceName,\n\t\t\t) as TServices,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride logger<T extends Logger>(\n\t\tlogger: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tT,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride publisher<T extends EventPublisher<any>, TName extends string>(\n\t\tpublisher: Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tT,\n\t\tTName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_publisher: publisher as unknown as Service<\n\t\t\t\tTEventPublisherServiceName,\n\t\t\t\tTEventPublisher\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tT,\n\t\t\tTName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * Set the database service for this cron job.\n\t * The database will be available in the handler context as `db`.\n\t */\n\toverride database<T, TName extends string>(\n\t\tsource: Consumable<TName, T> | Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tT,\n\t\tTName\n\t> {\n\t\tconst service = serviceOf(source);\n\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: service as unknown as Service<\n\t\t\t\tTDatabaseServiceName,\n\t\t\t\tTDatabase\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tT,\n\t\t\tTName\n\t\t>;\n\t}\n\n\toverride handle(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t): Cron<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tconst cron = new Cron(\n\t\t\tfn,\n\t\t\tthis._timeout,\n\t\t\tthis._schedule,\n\t\t\tthis.inputSchema,\n\t\t\tthis.outputSchema,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._publisher,\n\t\t\tthis._events,\n\t\t\tthis._memorySize,\n\t\t\tthis._databaseService,\n\t\t\tthis._constructs,\n\t\t);\n\n\t\t// Which process runs it. Carried from the factory rather than inferred\n\t\t// from the directory the file happens to sit in.\n\t\tcron.owner = this._owner;\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base — `const fn = f.logger(log).timeout(60_000)` — keeps\n\t\t// its configuration for every construct built from it. The reset that\n\t\t// used to be here wiped the base on first use, which made a base usable\n\t\t// exactly once, and quietly reverted the logger to the default.\n\n\t\treturn cron;\n\t}\n}\n"],"mappings":";;;;;;AAUA,IAAa,OAAb,cASU,SAaR;CACD,OAAO,OAAOA,KAA2C;AACxD,SAAO,QACN,OACE,IAAiB,oBAAoB,QACtC,IAAI,SAAS,cAAc,KAC5B;CACD;CAED,YACCC,IACAC,SACUC,WACVC,OACAC,cACAC,WAAsB,CAAE,GACxBC,QACAC,kBACAC,SAAgB,CAAE,GAClBC,YACAC,iBAKAC,aAAuB,CAAE,GACxB;AACD,QACC,IACA,SACA,cAAc,MACd,OACA,cACA,UACA,QACA,kBACA,QACA,oBAEA,iBACA,WACA;EA7BS;CA8BV;CAED,IAAI,WAA2C;AAC9C,SAAO,KAAK;CACZ;AACD;;;;;AC7DD,IAAa,cAAb,cASU,gBAWR;CACD,AAAQ;CAER,cAAc;AACb,QAAM,cAAc,KAAK;CACzB;CAED,AAAS,WAAWC,YAA0B;AAC7C,SAAO,UAAU,MAAM,EAAE,aAAa,WAAY,EAAC;CACnD;CAED,SACCC,aAUC;AACD,SAAO,UAAU,MAAM,EAAE,WAAW,YAAa,EAAC;CAClD;CAED,AAAS,MACRC,QAUC;AACD,SAAO,UAAU,MAAM,EACtB,aAAa,OACb,EAAC;CAUF;CAED,AAAS,OACRA,QAUC;AACD,SAAO,UAAU,MAAM,EACtB,cAAc,OACd,EAAC;CAUF;;;;;;;;;;;;CAaD,AAAS,UACRC,YAUC;EAQD,MAAM,WAAW,WAAW,WAAW;AAEvC,SAAO,UAAU,MAAM;GACtB,WAAW,2BACV,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,GAChC,CAACC,MAAe,EAAE,YAClB;GACD,aAAa,MAAM,YAAY,KAAK,YAAY;EAChD,EAAC;CAUF;CAED,AAAS,SACRC,UAUC;AACD,SAAO,UAAU,MAAM,EACtB,WAAW,2BACV,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,GAChC,CAAC,MAAM,EAAE,YACT,CACD,EAAC;CAUF;CAED,AAAS,OACRC,QAUC;AACD,SAAO,UAAU,MAAM,EACtB,SAAS,OACT,EAAC;CAUF;CAED,AAAS,UACRC,WAUC;AACD,SAAO,UAAU,MAAM,EACtB,YAAY,UAIZ,EAAC;CAUF;;;;;CAMD,AAAS,SACRC,QAUC;EACD,MAAM,UAAU,UAAU,OAAO;AAEjC,SAAO,UAAU,MAAM,EACtB,kBAAkB,QAIlB,EAAC;CAUF;CAED,AAAS,OACRC,IAUC;EACD,MAAM,OAAO,IAAI,KAChB,IACA,KAAK,UACL,KAAK,WACL,KAAK,aACL,KAAK,cACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,SACL,KAAK,aACL,KAAK,kBACL,KAAK;AAKN,OAAK,QAAQ,KAAK;AAQlB,SAAO;CACP;AACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"CronBuilder-BqpEzMPQ.d.cts","names":[],"sources":["../src/crons/CronBuilder.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAkBa,2BACG,4CACG,2BACF,SAAS,0BACP,kEACM,8KAIf,gBACT,QACA,WACA,WACA,SACA,iBACA,+CAGA,WACA;;EAnBY,WAAA,CAAA;EAAW,UAAA,CAAA,UAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAA,QACR,CAAA,WAAA,EA+BD,kBA/BC,CAAA,EAgCZ,WAhCY,CAiCd,MAjCc,EAkCd,SAlCc,EAmCd,OAnCc,EAoCd,SApCc,EAqCd,eArCc,EAsCd,0BAtCc,EAuCd,SAvCc,EAwCd,oBAxCc,CAAA;EAAwB,KACrB,CAAA,UA4CO,wBA5CP,CAAA,CAAA,MAAA,EA6CT,C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A,MAAA,CAAA,CAAA,SAAA,EA2KS,OA3KT,CA2KiB,KA3KjB,EA2KwB,CA3KxB,CAAA,CAAA,EA4KA,WA5KA,CA6KF,MA7KE,EA8KF,SA9KE,EA+KF,OA/KE,EAgLF,SAhLE,EAiLF,CAjLE,EAkLF,KAlLE,EAmLF,SAnLE,EAoLF,oBApLE,CAAA;EAAW;;;;EAiBJ,QACT,CAAA,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,MAAA,EA0LQ,UA1LR,CA0LmB,KA1LnB,EA0L0B,CA1L1B,CAAA,GA0L+B,OA1L/B,CA0LuC,KA1LvC,EA0L8C,CA1L9C,CAAA,CAAA,EA2LE,WA3LF,CA4LA,MA5LA,EA6LA,SA7LA,EA8LA,OA9LA,EA+LA,SA/LA,EAgMA,eAhMA,EAiMA,0BAjMA,EAkMA,CAlMA,EAmMA,KAnMA,CAAA;EAAO,MACP,CAAA,EAAA,EAwNI,eAxNJ,CAwNoB,MAxNpB,EAwN4B,SAxN5B,EAwNuC,OAxNvC,EAwNgD,SAxNhD,EAwN2D,SAxN3D,CAAA,CAAA,EAyNE,IAzNF,CA0NA,MA1NA,EA2NA,SA3NA,EA4NA,OA5NA,EA6NA,SA7NA,EA8NA,eA9NA,EA+NA,0BA/NA,EAgOA,SAhOA,EAiOA,oBAjOA,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"CronBuilder-CkXPJiGO.cjs","names":["Function","obj: any","ConstructType","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>","timeout?: number","_schedule?: ScheduleExpression","input?: TInput","outputSchema?: OutSchema","services: TServices","logger?: TLogger","publisherService?: Service<TEventPublisherServiceName, TEventPublisher>","events: any[]","memorySize?: number","databaseService?: Service<TDatabaseServiceName, TDatabase>","constructs: string[]","FunctionBuilder","ConstructType","memorySize: number","_expression: ScheduleExpression","schema: T","constructs: T","s: Service","services: T","logger: T","publisher: Service<TName, T>","source: Consumable<TName, T> | Service<TName, T>","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>"],"sources":["../src/crons/Cron.ts","../src/crons/CronBuilder.ts"],"sourcesContent":["import type { AuditableAction } from '@geekmidas/audit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\nimport { ConstructType } from '../Construct';\nimport { Function, type FunctionHandler } from '../functions';\n\nexport class Cron<\n\tTInput extends ComposableStandardSchema | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends Function<\n\tTInput,\n\tTServices,\n\tTLogger,\n\tOutSchema,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName,\n\tAuditableAction<string, unknown>,\n\tFunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>\n> {\n\tstatic isCron(obj: any): obj is Cron<any, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as Function).__IS_FUNCTION__ === true &&\n\t\t\t\tobj.type === ConstructType.Cron,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t\ttimeout?: number,\n\t\tprotected _schedule?: ScheduleExpression,\n\t\tinput?: TInput,\n\t\toutputSchema?: OutSchema,\n\t\tservices: TServices = [] as unknown as TServices,\n\t\tlogger?: TLogger,\n\t\tpublisherService?: Service<TEventPublisherServiceName, TEventPublisher>,\n\t\tevents: any[] = [],\n\t\tmemorySize?: number,\n\t\tdatabaseService?: Service<TDatabaseServiceName, TDatabase>,\n\t\t/**\n\t\t * The construct ids `.dependsOn()` named — last, so no existing positional\n\t\t * argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tfn,\n\t\t\ttimeout,\n\t\t\tConstructType.Cron,\n\t\t\tinput,\n\t\t\toutputSchema,\n\t\t\tservices,\n\t\t\tlogger,\n\t\t\tpublisherService,\n\t\t\tevents,\n\t\t\tmemorySize,\n\t\t\tundefined, // auditorStorageService\n\t\t\tdatabaseService,\n\t\t\tconstructs,\n\t\t);\n\t}\n\n\tget schedule(): ScheduleExpression | undefined {\n\t\treturn this._schedule;\n\t}\n}\n\nexport type RateExpression = `rate(${string})`;\n\ntype CronMinute =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronHour =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronDay =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronMonth =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'JAN'\n\t| 'FEB'\n\t| 'MAR'\n\t| 'APR'\n\t| 'MAY'\n\t| 'JUN'\n\t| 'JUL'\n\t| 'AUG'\n\t| 'SEP'\n\t| 'OCT'\n\t| 'NOV'\n\t| 'DEC'\n\t| string; // Allow more complex patterns\n\ntype CronWeekday =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'SUN'\n\t| 'MON'\n\t| 'TUE'\n\t| 'WED'\n\t| 'THU'\n\t| 'FRI'\n\t| 'SAT'\n\t| `${string}-${string}` // Allow patterns like MON-FRI\n\t| string; // Allow more complex patterns\n\nexport type CronExpression =\n\t`cron(${CronMinute} ${CronHour} ${CronDay} ${CronMonth} ${CronWeekday})`;\n\nexport type ScheduleExpression = RateExpression | CronExpression;\n","import type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport uniqBy from 'lodash.uniqby';\nimport { ConstructType } from '../Construct';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tserviceOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { FunctionBuilder, type FunctionHandler } from '../functions';\nimport { Cron, type ScheduleExpression } from './Cron';\n\nexport class CronBuilder<\n\tTInput extends ComposableStandardSchema,\n\tTServices extends Service[],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends FunctionBuilder<\n\tTInput,\n\tOutSchema,\n\tTServices,\n\tTLogger,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName\n> {\n\tprivate _schedule?: ScheduleExpression;\n\n\tconstructor() {\n\t\tsuper(ConstructType.Cron);\n\t}\n\n\toverride memorySize(memorySize: number): this {\n\t\treturn cloneWith(this, { _memorySize: memorySize });\n\t}\n\n\tschedule(\n\t\t_expression: ScheduleExpression,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _schedule: _expression });\n\t}\n\n\toverride input<T extends ComposableStandardSchema>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\tinputSchema: schema as unknown as TInput,\n\t\t}) as unknown as CronBuilder<\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride output<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tT,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\toutputSchema: schema as unknown as OutSchema,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\toverride dependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: uniqBy(\n\t\t\t\t[...this._services, ...services],\n\t\t\t\t(s: Service) => s.serviceName,\n\t\t\t),\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride services<T extends Service[]>(\n\t\tservices: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: uniqBy(\n\t\t\t\t[...this._services, ...services],\n\t\t\t\t(s) => s.serviceName,\n\t\t\t) as TServices,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride logger<T extends Logger>(\n\t\tlogger: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tT,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride publisher<T extends EventPublisher<any>, TName extends string>(\n\t\tpublisher: Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tT,\n\t\tTName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_publisher: publisher as unknown as Service<\n\t\t\t\tTEventPublisherServiceName,\n\t\t\t\tTEventPublisher\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tT,\n\t\t\tTName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * Set the database service for this cron job.\n\t * The database will be available in the handler context as `db`.\n\t */\n\toverride database<T, TName extends string>(\n\t\tsource: Consumable<TName, T> | Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tT,\n\t\tTName\n\t> {\n\t\tconst service = serviceOf(source);\n\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: service as unknown as Service<\n\t\t\t\tTDatabaseServiceName,\n\t\t\t\tTDatabase\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tT,\n\t\t\tTName\n\t\t>;\n\t}\n\n\toverride handle(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t): Cron<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tconst cron = new Cron(\n\t\t\tfn,\n\t\t\tthis._timeout,\n\t\t\tthis._schedule,\n\t\t\tthis.inputSchema,\n\t\t\tthis.outputSchema,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._publisher,\n\t\t\tthis._events,\n\t\t\tthis._memorySize,\n\t\t\tthis._databaseService,\n\t\t\tthis._constructs,\n\t\t);\n\n\t\t// Which process runs it. Carried from the factory rather than inferred\n\t\t// from the directory the file happens to sit in.\n\t\tcron.owner = this._owner;\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base — `const fn = f.logger(log).timeout(60_000)` — keeps\n\t\t// its configuration for every construct built from it. The reset that\n\t\t// used to be here wiped the base on first use, which made a base usable\n\t\t// exactly once, and quietly reverted the logger to the default.\n\n\t\treturn cron;\n\t}\n}\n"],"mappings":";;;;;;;AAUA,IAAa,OAAb,cASUA,2BAaR;CACD,OAAO,OAAOC,KAA2C;AACxD,SAAO,QACN,OACE,IAAiB,oBAAoB,QACtC,IAAI,SAASC,gCAAc,KAC5B;CACD;CAED,YACCC,IACAC,SACUC,WACVC,OACAC,cACAC,WAAsB,CAAE,GACxBC,QACAC,kBACAC,SAAgB,CAAE,GAClBC,YACAC,iBAKAC,aAAuB,CAAE,GACxB;AACD,QACC,IACA,SACAZ,gCAAc,MACd,OACA,cACA,UACA,QACA,kBACA,QACA,oBAEA,iBACA,WACA;EA7BS;CA8BV;CAED,IAAI,WAA2C;AAC9C,SAAO,KAAK;CACZ;AACD;;;;;AC7DD,IAAa,c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