@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.cjs CHANGED
@@ -1,62 +1,136 @@
1
- const require_chunk = require('./chunk-DWy1uDak.cjs');
2
- const require_construct_interface = require('./construct-interface-BfjcOD_E.cjs');
3
- require('./Construct-CyS3RpTL.cjs');
4
- const require_functions = require('./functions-Bd3TPxid.cjs');
5
- require('./clone-Dy0cR2SZ.cjs');
6
- const require_surfaceEnv = require('./surfaceEnv-BFXEms2f.cjs');
7
- const require_CronBuilder = require('./CronBuilder-CkXPJiGO.cjs');
8
- const require_SubscriberBuilder = require('./SubscriberBuilder-4OPehf2R.cjs');
9
- const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
10
- const __geekmidas_logger_console = require_chunk.__toESM(require("@geekmidas/logger/console"));
11
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_construct_interface = require("./construct-interface.cjs");
3
+ const require_functions = require("./functions-DKN6aQWJ.cjs");
4
+ const require_surfaceEnv = require("./surfaceEnv-CNimK76p.cjs");
5
+ const require_CronBuilder = require("./CronBuilder-BbnT7tqo.cjs");
6
+ const require_SubscriberBuilder = require("./SubscriberBuilder-C2bCOuPT.cjs");
7
+ let _geekmidas_manifest = require("@geekmidas/manifest");
8
+ let _geekmidas_logger_console = require("@geekmidas/logger/console");
12
9
  //#region src/worker.ts
13
10
  var Worker = class Worker {
11
+ config;
12
+ dependencies;
14
13
  id;
15
14
  /** Always defined — the worker's own, or the console logger. */
16
15
  logger;
17
16
  /** Always defined, and normally the default. */
18
17
  envParser;
19
- constructor(id, config = {}, dependencies = []) {
18
+ /**
19
+ * Where this worker's schedules live, when it has crons and a server runs
20
+ * them. `undefined` until `.database(…)` says.
21
+ */
22
+ scheduleStore;
23
+ constructor(id, config = {}, dependencies = [], scheduleStore) {
20
24
  this.config = config;
21
25
  this.dependencies = dependencies;
22
- const canonical = (0, __geekmidas_manifest.canonicalId)(id);
26
+ const canonical = (0, _geekmidas_manifest.canonicalId)(id);
23
27
  this.id = canonical;
24
- this.logger = config.logger ?? __geekmidas_logger_console.DEFAULT_LOGGER;
28
+ this.logger = config.logger ?? _geekmidas_logger_console.DEFAULT_LOGGER;
25
29
  this.envParser = require_surfaceEnv.envParserFor(config.envParser ? {
26
30
  id: canonical,
27
31
  envParser: config.envParser
28
32
  } : void 0);
33
+ this.scheduleStore = scheduleStore;
29
34
  }
30
35
  /**
31
- * This worker's cron factory, carrying its logger.
36
+ * The database this worker keeps its schedules in.
37
+ *
38
+ * Only a server target uses it. On AWS a cron is an EventBridge rule
39
+ * invoking a Lambda and nothing here is consulted — but a server has nothing
40
+ * firing its crons except itself, and a process that schedules in memory
41
+ * fires every job once per replica while reporting that all is well.
42
+ *
43
+ * So the store is declared rather than discovered. It could have been
44
+ * inferred — from a database the app happens to declare, or from the events
45
+ * backend when that backend is pg-boss — and both would work until an app
46
+ * had two databases, or moved its events to SNS, at which point the
47
+ * schedules would quietly move or stop. Naming it is one line and cannot
48
+ * drift.
32
49
  *
33
- * `export const c = crons.logger(logger)` written once and hung off the
34
- * thing that runs it, so a cron file opens with the schedule rather than
35
- * with an import of a logger it has to know the path to.
50
+ * @example
51
+ * ```ts
52
+ * export const jobs = new Worker('Jobs', { logger }).database(database);
53
+ * ```
36
54
  */
37
- get crons() {
38
- return this.own(new require_CronBuilder.CronBuilder().logger(this.logger));
55
+ database(source) {
56
+ return new Worker(this.id, this.config, [...this.dependencies, require_construct_interface.edgeTo(source)], source);
39
57
  }
40
58
  /**
41
- * This worker's subscriber factory, carrying its logger.
59
+ * A scheduled runnable.
42
60
  *
43
- * Chain `.publisher(…)` before `.subscribe([…])`: the event names are typed
44
- * from the publisher's message union, so there is nothing to spell twice.
61
+ * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
45
62
  */
46
- get subscribers() {
47
- return this.own(new require_SubscriberBuilder.SubscriberBuilder().logger(this.logger));
63
+ cron(schedule) {
64
+ return this.own(new require_CronBuilder.CronBuilder().logger(this.logger)).schedule(schedule);
48
65
  }
49
- /** This worker's function factory, carrying its logger. */
50
- get functions() {
51
- return this.own(new require_functions.FunctionBuilder().logger(this.logger));
66
+ /**
67
+ * A runnable that consumes a topic.
68
+ *
69
+ * Binding is not publishing: a consumer is handed the topic's event types
70
+ * and no connection string it could publish with. Chain `.publishes(…)` when
71
+ * the handler emits follow-up events, which is the only reason it would need
72
+ * one.
73
+ *
74
+ * @example `worker.topic(users).subscribe(['user.created']).handle(…)`
75
+ */
76
+ topic(topic) {
77
+ return this.own(new require_SubscriberBuilder.SubscriberBuilder().logger(this.logger)).topic(topic);
52
78
  }
53
79
  /**
54
- * Sugar for the common case, the way `api.get()` is for `api.endpoints`.
80
+ * A runnable that consumes events typed from a publisher service.
55
81
  *
56
- * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
82
+ * The older of the two ways to bind a subscriber, kept for a project whose
83
+ * events come from a hand-written publisher rather than a `Topic`
84
+ * construct. `topic()` is the one to reach for: it types the events the same
85
+ * way and hands the consumer no connection string it could publish with.
57
86
  */
58
- cron(schedule) {
59
- return this.crons.schedule(schedule);
87
+ publisher(service) {
88
+ return this.own(new require_SubscriberBuilder.SubscriberBuilder().logger(this.logger)).publisher(service);
89
+ }
90
+ /**
91
+ * Everything below builds a function — the runnable with no schedule and no
92
+ * topic, invoked by something else.
93
+ *
94
+ * These sit on the worker rather than behind a `functions` namespace because
95
+ * the namespace was a hop that said nothing: `worker.functions.input(…)`
96
+ * names a collection to reach one member of it. What kind of runnable is
97
+ * being built is decided by which of these is called first — a schedule
98
+ * makes a cron, a topic makes a subscriber, and anything else makes a
99
+ * function.
100
+ */
101
+ input(schema) {
102
+ return this.functions.input(schema);
103
+ }
104
+ output(schema) {
105
+ return this.functions.output(schema);
106
+ }
107
+ timeout(ms) {
108
+ return this.functions.timeout(ms);
109
+ }
110
+ memorySize(mb) {
111
+ return this.functions.memorySize(mb);
112
+ }
113
+ dependsOn(constructs) {
114
+ return this.functions.dependsOn(constructs);
115
+ }
116
+ services(services) {
117
+ return this.functions.services(services);
118
+ }
119
+ /**
120
+ * A function with no input schema — the shortest runnable there is.
121
+ *
122
+ * @example `worker.handle(async ({ logger }) => { … })`
123
+ */
124
+ handle(...args) {
125
+ return this.schemalessFunction().handle(...args);
126
+ }
127
+ /** The builder `handle` delegates to, named so its type can be referred to. */
128
+ schemalessFunction() {
129
+ return this.functions;
130
+ }
131
+ /** The function builder the delegating methods above are built on. */
132
+ get functions() {
133
+ return this.own(new require_functions.FunctionBuilder().logger(this.logger));
60
134
  }
61
135
  /**
62
136
  * Resources and surfaces this worker calls.
@@ -65,7 +139,7 @@ var Worker = class Worker {
65
139
  * environment and its access, the same distinction `RestApi.calls()` draws.
66
140
  */
67
141
  calls(constructs) {
68
- return new Worker(this.id, this.config, [...this.dependencies, ...constructs.map(require_construct_interface.edgeTo)]);
142
+ return new Worker(this.id, this.config, [...this.dependencies, ...constructs.map(require_construct_interface.edgeTo)], this.scheduleStore);
69
143
  }
70
144
  /**
71
145
  * Stamps this worker's id onto a builder, so everything built from it says
@@ -73,19 +147,19 @@ var Worker = class Worker {
73
147
  */
74
148
  own(builder) {
75
149
  builder._owner = this.id;
150
+ builder._scheduleStore = this.scheduleStore;
76
151
  return builder;
77
152
  }
78
153
  declare() {
79
154
  return [{
80
155
  kind: "worker",
81
156
  id: this.id,
82
- ...this.config.app ? { app: this.config.app } : {},
83
157
  ...this.dependencies.length ? { dependencies: this.dependencies } : {},
84
158
  provides: []
85
159
  }];
86
160
  }
87
161
  };
88
-
89
162
  //#endregion
90
163
  exports.Worker = Worker;
164
+
91
165
  //# sourceMappingURL=worker.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker.cjs","names":["id: ConstructName<TName>","config: WorkerConfig","dependencies: readonly Dependency[]","DEFAULT_LOGGER","CronBuilder","SubscriberBuilder","FunctionBuilder","schedule: ScheduleExpression","constructs: readonly Declarable[]","edgeTo","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,sCAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,SAAS,OAAO,UAAUC;AAC/B,OAAK,YAAY,gCAChB,OAAO,YACJ;GAAE,IAAI;GAAW,WAAW,OAAO;EAAW,WAEjD;CACD;;;;;;;;CASD,IAAI,QAAQ;AACX,SAAO,KAAK,IAAI,IAAIC,kCAAc,OAAO,KAAK,OAAO,CAAC;CACtD;;;;;;;CAQD,IAAI,cAAc;AACjB,SAAO,KAAK,IAAI,IAAIC,8CAAoB,OAAO,KAAK,OAAO,CAAC;CAC5D;;CAGD,IAAI,YAAY;AACf,SAAO,KAAK,IAAI,IAAIC,oCAAkB,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,IAAIC,mCAAO,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.cjs","names":["canonicalId","DEFAULT_LOGGER","envParserFor","edgeTo","CronBuilder","SubscriberBuilder","FunctionBuilder"],"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,aAAA,GAAYA,oBAAAA,YAAAA,CAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,SAAS,OAAO,UAAUC,0BAAAA;EAC/B,KAAK,YAAYC,mBAAAA,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,cAAcC,4BAAAA,OAAO,MAAM,CAAC,GACrC,MACD;CACD;;;;;;CAOA,KAAK,UAA8B;EAClC,OAAO,KAAK,IAAI,IAAIC,oBAAAA,YAAY,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,QAAQ;CACzE;;;;;;;;;;;CAYA,MACC,OACC;EACD,OAAO,KAAK,IAAI,IAAIC,0BAAAA,kBAAkB,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK;CACzE;;;;;;;;;CAUA,UACC,SACC;EACD,OAAO,KAAK,IAAI,IAAIA,0BAAAA,kBAAkB,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,UAC5D,OACD;CACD;;;;;;;;;;;;CAaA,MAA0C,QAAW;EACpD,OAAO,KAAK,UAAU,MAAM,MAAM;CACnC;CAEA,OAAmC,QAAW;EAC7C,OAAO,KAAK,UAAU,OAAO,MAAM;CACpC;CAEA,QAAQ,IAAY;EACnB,OAAO,KAAK,UAAU,QAAQ,EAAE;CACjC;CAEA,WAAW,IAAY;EACtB,OAAO,KAAK,UAAU,WAAW,EAAE;CACpC;CAEA,UAAiD,YAAe;EAC/D,OAAO,KAAK,UAAU,UAAU,UAAU;CAC3C;CAEA,SAA8B,UAAa;EAC1C,OAAO,KAAK,UAAU,SAAS,QAAQ;CACxC;;;;;;CAOA,OACC,GAAG,MAGF;EACD,OAAO,KAAK,mBAAmB,CAAC,CAAC,OAAO,GAAG,IAAI;CAChD;;CAGA,qBAA6B;EAC5B,OAAO,KAAK;CACb;;CAGA,IAAY,YAAY;EACvB,OAAO,KAAK,IAAI,IAAIC,kBAAAA,gBAAgB,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC;CAC1D;;;;;;;CAQA,MAAM,YAAkD;EACvD,OAAO,IAAI,OACV,KAAK,IACL,KAAK,QACL,CAAC,GAAG,KAAK,cAAc,GAAG,WAAW,IAAIH,4BAAAA,MAAM,CAAC,GAChD,KAAK,aACN;CACD;;;;;CAMA,IACC,SACI;EACJ,QAAQ,SAAS,KAAK;EACtB,QAAQ,iBAAiB,KAAK;EAE9B,OAAO;CACR;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,aAAa,SACnB,EAAE,cAAc,KAAK,aAAa,IAClC,CAAC;GAEJ,UAAU,CAAC;EACZ,CACD;CACD;AACD"}
package/dist/worker.d.cts CHANGED
@@ -1,29 +1,19 @@
1
- import "./Construct-C0ijr2qp.cjs";
2
- import { FunctionBuilder } from "./index-JSf9xNIJ.cjs";
3
- import { Declarable } from "./construct-interface-D9d4Gm4p.cjs";
4
- import { ScheduleExpression } from "./Cron-Wqh464aO.cjs";
5
- import "./Subscriber-2mEi0ImH.cjs";
6
- import { CronBuilder } from "./CronBuilder-BqpEzMPQ.cjs";
7
- import "./Topic-19QeHBIR.cjs";
8
- import { SubscriberBuilder } from "./SubscriberBuilder-waNhzjSM.cjs";
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.cjs";
2
+ import { a as FunctionHandler, r as Function, t as FunctionBuilder } from "./index-BI23K3wy.cjs";
3
+ import { c as ServicesOf, i as Declarable, r as Consumable } from "./construct-interface-DPusCUSQ.cjs";
4
+ import { i as ScheduleExpression } from "./Cron-CA2oa2nC.cjs";
5
+ import { t as CronBuilder } from "./CronBuilder-B_KqaodP.cjs";
6
+ import { n as TopicEvents, r as TopicMessage, t as Topic } from "./Topic-D6blllEn.cjs";
7
+ import { t as SubscriberBuilder } from "./SubscriberBuilder-CjDGSTZc.cjs";
8
+ import "./index-tE_119SX.cjs";
9
9
  import { EnvironmentParser } from "@geekmidas/envkit";
10
+ import { EventPublisher } from "@geekmidas/events";
10
11
  import { Logger } from "@geekmidas/logger";
11
- import * as _geekmidas_schema12 from "@geekmidas/schema";
12
- import * as _geekmidas_services13 from "@geekmidas/services";
13
- import * as _geekmidas_audit15 from "@geekmidas/audit";
14
- import { AppSpec, ConstructName, Declaration, Dependency } from "@geekmidas/manifest";
15
-
12
+ import { ComposableStandardSchema } from "@geekmidas/schema";
13
+ import { Service } from "@geekmidas/services";
14
+ import { ConstructName, Declaration, Dependency } from "@geekmidas/manifest";
16
15
  //#region src/worker.d.ts
17
-
18
- interface WorkerConfig {
19
- /**
20
- * Where its source lives and how it is run.
21
- *
22
- * Normally omitted, like every other app's: `Worker` means `apps/worker`
23
- * where that directory exists and the project root otherwise. Write one only
24
- * for a layout that genuinely differs.
25
- */
26
- app?: AppSpec;
16
+ export interface WorkerConfig {
27
17
  /**
28
18
  * The logger everything built from this worker runs with.
29
19
  *
@@ -41,7 +31,7 @@ interface WorkerConfig {
41
31
  */
42
32
  envParser?: EnvironmentParser<{}>;
43
33
  }
44
- declare class Worker<TName extends string = string> implements Declarable<TName> {
34
+ export declare class Worker<TName extends string = string> implements Declarable<TName> {
45
35
  private readonly config;
46
36
  /** Internal: how `.calls()` carries edges into the copy it returns. */
47
37
  private readonly dependencies;
@@ -50,31 +40,88 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
50
40
  readonly logger: Logger;
51
41
  /** Always defined, and normally the default. */
52
42
  readonly envParser: EnvironmentParser<{}>;
53
- constructor(id: ConstructName<TName>, config?: WorkerConfig, /** Internal: how `.calls()` carries edges into the copy it returns. */
54
- dependencies?: readonly Dependency[]);
55
43
  /**
56
- * This worker's cron factory, carrying its logger.
57
- *
58
- * `export const c = crons.logger(logger)` written once and hung off the
59
- * thing that runs it, so a cron file opens with the schedule rather than
60
- * with an import of a logger it has to know the path to.
44
+ * Where this worker's schedules live, when it has crons and a server runs
45
+ * them. `undefined` until `.database(…)` says.
61
46
  */
62
- get crons(): CronBuilder<_geekmidas_schema12.ComposableStandardSchema, _geekmidas_services13.Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
47
+ readonly scheduleStore?: Consumable<string, unknown>;
48
+ constructor(id: ConstructName<TName>, config?: WorkerConfig,
49
+ /** Internal: how `.calls()` carries edges into the copy it returns. */
50
+ dependencies?: readonly Dependency[], scheduleStore?: Consumable<string, unknown>);
63
51
  /**
64
- * This worker's subscriber factory, carrying its logger.
52
+ * The database this worker keeps its schedules in.
65
53
  *
66
- * Chain `.publisher(…)` before `.subscribe([…])`: the event names are typed
67
- * from the publisher's message union, so there is nothing to spell twice.
54
+ * Only a server target uses it. On AWS a cron is an EventBridge rule
55
+ * invoking a Lambda and nothing here is consulted — but a server has nothing
56
+ * firing its crons except itself, and a process that schedules in memory
57
+ * fires every job once per replica while reporting that all is well.
58
+ *
59
+ * So the store is declared rather than discovered. It could have been
60
+ * inferred — from a database the app happens to declare, or from the events
61
+ * backend when that backend is pg-boss — and both would work until an app
62
+ * had two databases, or moved its events to SNS, at which point the
63
+ * schedules would quietly move or stop. Naming it is one line and cannot
64
+ * drift.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * export const jobs = new Worker('Jobs', { logger }).database(database);
69
+ * ```
68
70
  */
69
- get subscribers(): SubscriberBuilder<[], Logger, undefined, undefined, string, []>;
70
- /** This worker's function factory, carrying its logger. */
71
- get functions(): FunctionBuilder<_geekmidas_schema12.ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit15.AuditableAction<string, unknown>>;
71
+ database<T, TDbName extends string>(source: Consumable<TDbName, T>): Worker<TName>;
72
72
  /**
73
- * Sugar for the common case, the way `api.get()` is for `api.endpoints`.
73
+ * A scheduled runnable.
74
74
  *
75
75
  * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
76
76
  */
77
- cron(schedule: ScheduleExpression): CronBuilder<_geekmidas_schema12.ComposableStandardSchema, _geekmidas_services13.Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
77
+ cron(schedule: ScheduleExpression): CronBuilder<ComposableStandardSchema, Service[], Logger, undefined, undefined, string, undefined, string>;
78
+ /**
79
+ * A runnable that consumes a topic.
80
+ *
81
+ * Binding is not publishing: a consumer is handed the topic's event types
82
+ * and no connection string it could publish with. Chain `.publishes(…)` when
83
+ * the handler emits follow-up events, which is the only reason it would need
84
+ * one.
85
+ *
86
+ * @example `worker.topic(users).subscribe(['user.created']).handle(…)`
87
+ */
88
+ topic<TTopicName extends string, TEvents extends TopicEvents>(topic: Topic<TTopicName, TEvents>): SubscriberBuilder<[], Logger, undefined, EventPublisher<TopicMessage<TEvents_1>>, string, []>;
89
+ /**
90
+ * A runnable that consumes events typed from a publisher service.
91
+ *
92
+ * The older of the two ways to bind a subscriber, kept for a project whose
93
+ * events come from a hand-written publisher rather than a `Topic`
94
+ * construct. `topic()` is the one to reach for: it types the events the same
95
+ * way and hands the consumer no connection string it could publish with.
96
+ */
97
+ publisher<T extends EventPublisher<any>, TPubName extends string>(service: Service<TPubName, T> | Consumable<TPubName, T>): SubscriberBuilder<[], Logger, undefined, EventPublisher<any>, string, []>;
98
+ /**
99
+ * Everything below builds a function — the runnable with no schedule and no
100
+ * topic, invoked by something else.
101
+ *
102
+ * These sit on the worker rather than behind a `functions` namespace because
103
+ * the namespace was a hop that said nothing: `worker.functions.input(…)`
104
+ * names a collection to reach one member of it. What kind of runnable is
105
+ * being built is decided by which of these is called first — a schedule
106
+ * makes a cron, a topic makes a subscriber, and anything else makes a
107
+ * function.
108
+ */
109
+ input<T extends ComposableStandardSchema>(schema: T): FunctionBuilder<T, undefined, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
110
+ output<T extends StandardSchemaV1>(schema: T): FunctionBuilder<ComposableStandardSchema, T, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
111
+ timeout(ms: number): FunctionBuilder<ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
112
+ memorySize(mb: number): FunctionBuilder<ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
113
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): FunctionBuilder<ComposableStandardSchema, undefined, [...ServicesOf<T>], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
114
+ services<T extends Service[]>(services: T): FunctionBuilder<ComposableStandardSchema, undefined, [...T], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
115
+ /**
116
+ * A function with no input schema — the shortest runnable there is.
117
+ *
118
+ * @example `worker.handle(async ({ logger }) => { … })`
119
+ */
120
+ handle(...args: Parameters<ReturnType<Worker<TName>['schemalessFunction']>['handle']>): Function<ComposableStandardSchema, [], Logger, undefined, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>, FunctionHandler<ComposableStandardSchema, [], Logger, undefined, undefined, undefined, AuditableAction<string, unknown>>>;
121
+ /** The builder `handle` delegates to, named so its type can be referred to. */
122
+ private schemalessFunction;
123
+ /** The function builder the delegating methods above are built on. */
124
+ private get functions();
78
125
  /**
79
126
  * Resources and surfaces this worker calls.
80
127
  *
@@ -89,7 +136,5 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
89
136
  private own;
90
137
  declare(): Declaration[];
91
138
  }
92
- //# sourceMappingURL=worker.d.ts.map
93
139
  //#endregion
94
- export { Worker, WorkerConfig };
95
140
  //# sourceMappingURL=worker.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.cts","names":[],"sources":["../src/worker.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;AA2IkC,UAtFjB,YAAA,CAsFiB;EAAA;;;;;;;EA2BX,GArFX,CAAA,EApBL,OAoBK;EAAU;;;;;;;;WAXZ;;;;;;;cAOG;;cAGA,iDACD,WAAW;;;;eAET;;mBAGI;;sBAGG;kBAGf,cAAc,iBACO;0BAEe;;;;;;;;eAoBhC,YApB0C,mBAAA,CAoB1C,wBAAA,EAAA,qBAAA,CAAA,4BAAA;;;;;;;qBAUM,sBAAA;;mBAKF,gBALE,mBAAA,CAKF,wBAAA,iBAAA,iEAAA,kBAAA,CAAA;;;;;;iBASE,qBAAkB,YAAA,mBAAA,CAAA,wBAAA,EAAA,qBAAA,CAAA,4BAAA;;;;;;;6BAUN,eAAe,OAAO;;;;;;aAiBtC"}
1
+ {"version":3,"file":"worker.d.cts","names":["_$__topic0.TopicMessage","_$__construct_interface0.ServicesOf","_$__functions0.FunctionHandler","_$__functions0.Function"],"sources":["../src/worker.ts"],"mappings":";;;;;;;;;;;;;;;iBAiFiB;;;;;;;;;EAShB,SAAS;;;;;;;EAOT,YAAY;;qBAGA,OAAO,0CACR,WAAW;mBAkBJ;;mBAEA;WAlBT,IAAI;;WAGJ,QAAQ;;WAGR,WAAW;;;;;WAMX,gBAAgB;EAEzB,YACC,IAAI,cAAc,QACD,SAAQ,cAER;;EAAA,wBAAuB,cACxC,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAkCjB,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAC1B,OAAO;;;;;;EAcV,KAAK,UAAU,qBAAkB,YAAA,0BAAA,WAAA;;;;;;;;;;;EAcjC,MAAM,2BAA2B,gBAAgB,aAChD,OAAO,MAAM,YAAY,WAAQ,sBAAA,mBAAA,eAAAA,aAAA;;;;;;;;;EAalC,UAAU,UAAU,qBAAqB,yBACxC,SAAS,QAAQ,UAAU,KAAK,WAAW,UAAU,KAAE,sBAAA,mBAAA;;;;;;;;;;;;EAkBxD,MAAM,UAAU,0BAA0B,QAAQ,IAAC,gBAAA,kBAAA,iEAAA;EAInD,OAAO,UAAU,kBAAkB,QAAQ,IAAC,gBAAA,0BAAA,OAAA,iEAAA;EAI5C,QAAQ,aAAU,gBAAA,yCAAA,iEAAA;EAIlB,WAAW,aAAU,gBAAA,yCAAA,iEAAA;EAIrB,gBAAgB,mBAAmB,cAAc,YAAY,IAAC,gBAAA,yCAAAC,WAAA,KAAA,iEAAA;EAI9D,SAAS,UAAU,WAAW,UAAU,IAAC,gBAAA,yCAAA,IAAA,iEAAA;;;;;;EASzC,UACI,MAAM,WACR,WAAW,OAAO,2CAClBE,SAAA,8BAAA,4EAAA,kCAAAD,gBAAA,8BAAA,yCAAA;;UAMM;;cAKI;;;;;;;EAUZ,MAAM,qBAAqB,eAAe,OAAO;;;;;UAazC;EASR,WAAW"}
package/dist/worker.d.mts CHANGED
@@ -1,29 +1,19 @@
1
- import "./Construct-Ct8nalEi.mjs";
2
- import { FunctionBuilder } from "./index-CubPzHd9.mjs";
3
- import { Declarable } from "./construct-interface-g5GM5pwR.mjs";
4
- import { ScheduleExpression } from "./Cron-ByxdOfpE.mjs";
5
- import "./Subscriber-xTJ9ayPN.mjs";
6
- import { CronBuilder } from "./CronBuilder-BL0AP6fs.mjs";
7
- import "./Topic-DuFeqkBh.mjs";
8
- import { SubscriberBuilder } from "./SubscriberBuilder-Dptmo-1A.mjs";
9
- import { AppSpec, ConstructName, Declaration, Dependency } from "@geekmidas/manifest";
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.mjs";
2
+ import { a as FunctionHandler, r as Function, t as FunctionBuilder } from "./index-yb3fXNyH.mjs";
3
+ import { c as ServicesOf, i as Declarable, r as Consumable } from "./construct-interface-D2gesxos.mjs";
4
+ import { i as ScheduleExpression } from "./Cron-B_iuyNxr.mjs";
5
+ import { t as CronBuilder } from "./CronBuilder-BIKCLWu7.mjs";
6
+ import { n as TopicEvents, r as TopicMessage, t as Topic } from "./Topic-DVvheJ_-.mjs";
7
+ import { t as SubscriberBuilder } from "./SubscriberBuilder-C2FRfd26.mjs";
8
+ import "./index-fnpjXiA-.mjs";
9
+ import { ConstructName, Declaration, Dependency } from "@geekmidas/manifest";
10
10
  import { EnvironmentParser } from "@geekmidas/envkit";
11
- import * as _geekmidas_services1 from "@geekmidas/services";
12
- import * as _geekmidas_audit3 from "@geekmidas/audit";
11
+ import { EventPublisher } from "@geekmidas/events";
12
+ import { Service } from "@geekmidas/services";
13
13
  import { Logger } from "@geekmidas/logger";
14
- import * as _geekmidas_schema0 from "@geekmidas/schema";
15
-
14
+ import { ComposableStandardSchema } from "@geekmidas/schema";
16
15
  //#region src/worker.d.ts
17
-
18
- interface WorkerConfig {
19
- /**
20
- * Where its source lives and how it is run.
21
- *
22
- * Normally omitted, like every other app's: `Worker` means `apps/worker`
23
- * where that directory exists and the project root otherwise. Write one only
24
- * for a layout that genuinely differs.
25
- */
26
- app?: AppSpec;
16
+ export interface WorkerConfig {
27
17
  /**
28
18
  * The logger everything built from this worker runs with.
29
19
  *
@@ -41,7 +31,7 @@ interface WorkerConfig {
41
31
  */
42
32
  envParser?: EnvironmentParser<{}>;
43
33
  }
44
- declare class Worker<TName extends string = string> implements Declarable<TName> {
34
+ export declare class Worker<TName extends string = string> implements Declarable<TName> {
45
35
  private readonly config;
46
36
  /** Internal: how `.calls()` carries edges into the copy it returns. */
47
37
  private readonly dependencies;
@@ -50,31 +40,88 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
50
40
  readonly logger: Logger;
51
41
  /** Always defined, and normally the default. */
52
42
  readonly envParser: EnvironmentParser<{}>;
53
- constructor(id: ConstructName<TName>, config?: WorkerConfig, /** Internal: how `.calls()` carries edges into the copy it returns. */
54
- dependencies?: readonly Dependency[]);
55
43
  /**
56
- * This worker's cron factory, carrying its logger.
57
- *
58
- * `export const c = crons.logger(logger)` written once and hung off the
59
- * thing that runs it, so a cron file opens with the schedule rather than
60
- * with an import of a logger it has to know the path to.
44
+ * Where this worker's schedules live, when it has crons and a server runs
45
+ * them. `undefined` until `.database(…)` says.
61
46
  */
62
- get crons(): CronBuilder<_geekmidas_schema0.ComposableStandardSchema, _geekmidas_services1.Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
47
+ readonly scheduleStore?: Consumable<string, unknown>;
48
+ constructor(id: ConstructName<TName>, config?: WorkerConfig,
49
+ /** Internal: how `.calls()` carries edges into the copy it returns. */
50
+ dependencies?: readonly Dependency[], scheduleStore?: Consumable<string, unknown>);
63
51
  /**
64
- * This worker's subscriber factory, carrying its logger.
52
+ * The database this worker keeps its schedules in.
65
53
  *
66
- * Chain `.publisher(…)` before `.subscribe([…])`: the event names are typed
67
- * from the publisher's message union, so there is nothing to spell twice.
54
+ * Only a server target uses it. On AWS a cron is an EventBridge rule
55
+ * invoking a Lambda and nothing here is consulted — but a server has nothing
56
+ * firing its crons except itself, and a process that schedules in memory
57
+ * fires every job once per replica while reporting that all is well.
58
+ *
59
+ * So the store is declared rather than discovered. It could have been
60
+ * inferred — from a database the app happens to declare, or from the events
61
+ * backend when that backend is pg-boss — and both would work until an app
62
+ * had two databases, or moved its events to SNS, at which point the
63
+ * schedules would quietly move or stop. Naming it is one line and cannot
64
+ * drift.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * export const jobs = new Worker('Jobs', { logger }).database(database);
69
+ * ```
68
70
  */
69
- get subscribers(): SubscriberBuilder<[], Logger, undefined, undefined, string, []>;
70
- /** This worker's function factory, carrying its logger. */
71
- get functions(): FunctionBuilder<_geekmidas_schema0.ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit3.AuditableAction<string, unknown>>;
71
+ database<T, TDbName extends string>(source: Consumable<TDbName, T>): Worker<TName>;
72
72
  /**
73
- * Sugar for the common case, the way `api.get()` is for `api.endpoints`.
73
+ * A scheduled runnable.
74
74
  *
75
75
  * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
76
76
  */
77
- cron(schedule: ScheduleExpression): CronBuilder<_geekmidas_schema0.ComposableStandardSchema, _geekmidas_services1.Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
77
+ cron(schedule: ScheduleExpression): CronBuilder<ComposableStandardSchema, Service[], Logger, undefined, undefined, string, undefined, string>;
78
+ /**
79
+ * A runnable that consumes a topic.
80
+ *
81
+ * Binding is not publishing: a consumer is handed the topic's event types
82
+ * and no connection string it could publish with. Chain `.publishes(…)` when
83
+ * the handler emits follow-up events, which is the only reason it would need
84
+ * one.
85
+ *
86
+ * @example `worker.topic(users).subscribe(['user.created']).handle(…)`
87
+ */
88
+ topic<TTopicName extends string, TEvents extends TopicEvents>(topic: Topic<TTopicName, TEvents>): SubscriberBuilder<[], Logger, undefined, EventPublisher<TopicMessage<TEvents_1>>, string, []>;
89
+ /**
90
+ * A runnable that consumes events typed from a publisher service.
91
+ *
92
+ * The older of the two ways to bind a subscriber, kept for a project whose
93
+ * events come from a hand-written publisher rather than a `Topic`
94
+ * construct. `topic()` is the one to reach for: it types the events the same
95
+ * way and hands the consumer no connection string it could publish with.
96
+ */
97
+ publisher<T extends EventPublisher<any>, TPubName extends string>(service: Service<TPubName, T> | Consumable<TPubName, T>): SubscriberBuilder<[], Logger, undefined, EventPublisher<any>, string, []>;
98
+ /**
99
+ * Everything below builds a function — the runnable with no schedule and no
100
+ * topic, invoked by something else.
101
+ *
102
+ * These sit on the worker rather than behind a `functions` namespace because
103
+ * the namespace was a hop that said nothing: `worker.functions.input(…)`
104
+ * names a collection to reach one member of it. What kind of runnable is
105
+ * being built is decided by which of these is called first — a schedule
106
+ * makes a cron, a topic makes a subscriber, and anything else makes a
107
+ * function.
108
+ */
109
+ input<T extends ComposableStandardSchema>(schema: T): FunctionBuilder<T, undefined, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
110
+ output<T extends StandardSchemaV1>(schema: T): FunctionBuilder<ComposableStandardSchema, T, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
111
+ timeout(ms: number): FunctionBuilder<ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
112
+ memorySize(mb: number): FunctionBuilder<ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
113
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): FunctionBuilder<ComposableStandardSchema, undefined, [...ServicesOf<T>], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
114
+ services<T extends Service[]>(services: T): FunctionBuilder<ComposableStandardSchema, undefined, [...T], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
115
+ /**
116
+ * A function with no input schema — the shortest runnable there is.
117
+ *
118
+ * @example `worker.handle(async ({ logger }) => { … })`
119
+ */
120
+ handle(...args: Parameters<ReturnType<Worker<TName>['schemalessFunction']>['handle']>): Function<ComposableStandardSchema, [], Logger, undefined, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>, FunctionHandler<ComposableStandardSchema, [], Logger, undefined, undefined, undefined, AuditableAction<string, unknown>>>;
121
+ /** The builder `handle` delegates to, named so its type can be referred to. */
122
+ private schemalessFunction;
123
+ /** The function builder the delegating methods above are built on. */
124
+ private get functions();
78
125
  /**
79
126
  * Resources and surfaces this worker calls.
80
127
  *
@@ -89,7 +136,5 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
89
136
  private own;
90
137
  declare(): Declaration[];
91
138
  }
92
- //# sourceMappingURL=worker.d.ts.map
93
139
  //#endregion
94
- export { Worker, WorkerConfig };
95
140
  //# sourceMappingURL=worker.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.mts","names":[],"sources":["../src/worker.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;AA2IkC,UAtFjB,YAAA,CAsFiB;EAAA;;;;;;;EA2BX,GArFX,CAAA,EApBL,OAoBK;EAAU;;;;;;;;WAXZ;;;;;;;cAOG;;cAGA,iDACD,WAAW;;;;eAET;;mBAGI;;sBAGG;kBAGf,cAAc,iBACO;0BAEe;;;;;;;;eAoBhC,YApB0C,kBAAA,CAoB1C,wBAAA,EAAA,oBAAA,CAAA,4BAAA;;;;;;;qBAUM,sBAAA;;mBAKF,gBALE,kBAAA,CAKF,wBAAA,iBAAA,iEAAA,iBAAA,CAAA;;;;;;iBASE,qBAAkB,YAAA,kBAAA,CAAA,wBAAA,EAAA,oBAAA,CAAA,4BAAA;;;;;;;6BAUN,eAAe,OAAO;;;;;;aAiBtC"}
1
+ {"version":3,"file":"worker.d.mts","names":["_$__topic0.TopicMessage","_$__construct_interface0.ServicesOf","_$__functions0.FunctionHandler","_$__functions0.Function"],"sources":["../src/worker.ts"],"mappings":";;;;;;;;;;;;;;;iBAiFiB;;;;;;;;;EAShB,SAAS;;;;;;;EAOT,YAAY;;qBAGA,OAAO,0CACR,WAAW;mBAkBJ;;mBAEA;WAlBT,IAAI;;WAGJ,QAAQ;;WAGR,WAAW;;;;;WAMX,gBAAgB;EAEzB,YACC,IAAI,cAAc,QACD,SAAQ,cAER;;EAAA,wBAAuB,cACxC,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAkCjB,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAC1B,OAAO;;;;;;EAcV,KAAK,UAAU,qBAAkB,YAAA,0BAAA,WAAA;;;;;;;;;;;EAcjC,MAAM,2BAA2B,gBAAgB,aAChD,OAAO,MAAM,YAAY,WAAQ,sBAAA,mBAAA,eAAAA,aAAA;;;;;;;;;EAalC,UAAU,UAAU,qBAAqB,yBACxC,SAAS,QAAQ,UAAU,KAAK,WAAW,UAAU,KAAE,sBAAA,mBAAA;;;;;;;;;;;;EAkBxD,MAAM,UAAU,0BAA0B,QAAQ,IAAC,gBAAA,kBAAA,iEAAA;EAInD,OAAO,UAAU,kBAAkB,QAAQ,IAAC,gBAAA,0BAAA,OAAA,iEAAA;EAI5C,QAAQ,aAAU,gBAAA,yCAAA,iEAAA;EAIlB,WAAW,aAAU,gBAAA,yCAAA,iEAAA;EAIrB,gBAAgB,mBAAmB,cAAc,YAAY,IAAC,gBAAA,yCAAAC,WAAA,KAAA,iEAAA;EAI9D,SAAS,UAAU,WAAW,UAAU,IAAC,gBAAA,yCAAA,IAAA,iEAAA;;;;;;EASzC,UACI,MAAM,WACR,WAAW,OAAO,2CAClBE,SAAA,8BAAA,4EAAA,kCAAAD,gBAAA,8BAAA,yCAAA;;UAMM;;cAKI;;;;;;;EAUZ,MAAM,qBAAqB,eAAe,OAAO;;;;;UAazC;EASR,WAAW"}