@geekmidas/constructs 10.0.0-alpha.6 → 10.0.0-alpha.61

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 (405) hide show
  1. package/README.md +223 -158
  2. package/dist/{Construct-BD5neF7w.mjs → Construct-BO1X-kt9.mjs} +32 -33
  3. package/dist/Construct-BO1X-kt9.mjs.map +1 -0
  4. package/dist/Construct-BQALFCh2.d.cts +230 -0
  5. package/dist/Construct-BQALFCh2.d.cts.map +1 -0
  6. package/dist/{Construct-CyS3RpTL.cjs → Construct-DmvXceVY.cjs} +52 -47
  7. package/dist/Construct-DmvXceVY.cjs.map +1 -0
  8. package/dist/Construct-QXnl3VqT.d.mts +230 -0
  9. package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
  10. package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-DI3nKoic.d.cts} +15 -9
  11. package/dist/Cron-DI3nKoic.d.cts.map +1 -0
  12. package/dist/{Cron-dh4rUgib.d.mts → Cron-uYAHPnp7.d.mts} +15 -9
  13. package/dist/Cron-uYAHPnp7.d.mts.map +1 -0
  14. package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BoHzlWU_.cjs} +47 -31
  15. package/dist/CronBuilder-BoHzlWU_.cjs.map +1 -0
  16. package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-CCgt0wCE.mjs} +37 -21
  17. package/dist/CronBuilder-CCgt0wCE.mjs.map +1 -0
  18. package/dist/CronBuilder-DaSUm2Na.d.mts +47 -0
  19. package/dist/CronBuilder-DaSUm2Na.d.mts.map +1 -0
  20. package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
  21. package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
  22. package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-BJDBZBZu.d.mts} +75 -91
  23. package/dist/Endpoint-BJDBZBZu.d.mts.map +1 -0
  24. package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-CMWWrQ7u.mjs} +140 -109
  25. package/dist/Endpoint-CMWWrQ7u.mjs.map +1 -0
  26. package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-DV3jK5sP.d.cts} +74 -90
  27. package/dist/Endpoint-DV3jK5sP.d.cts.map +1 -0
  28. package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-DfiXTm_v.cjs} +168 -131
  29. package/dist/Endpoint-DfiXTm_v.cjs.map +1 -0
  30. package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-7g4Dg6cW.mjs} +41 -75
  31. package/dist/EndpointFactory-7g4Dg6cW.mjs.map +1 -0
  32. package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-CLxrcS0O.cjs} +77 -111
  33. package/dist/EndpointFactory-CLxrcS0O.cjs.map +1 -0
  34. package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-CLzCLkLt.d.cts} +64 -133
  35. package/dist/EndpointFactory-CLzCLkLt.d.cts.map +1 -0
  36. package/dist/{index-lAO9egTb.d.mts → EndpointFactory-gaF4yRpP.d.mts} +65 -134
  37. package/dist/EndpointFactory-gaF4yRpP.d.mts.map +1 -0
  38. package/dist/Function-DuqGcbOI.d.mts +76 -0
  39. package/dist/Function-DuqGcbOI.d.mts.map +1 -0
  40. package/dist/Function-Pu-1kKZz.d.cts +76 -0
  41. package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-B22boEAR.cjs} +52 -54
  43. package/dist/HonoEndpointAdaptor-B22boEAR.cjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-vY4JKG8i.mjs} +42 -47
  45. package/dist/HonoEndpointAdaptor-vY4JKG8i.mjs.map +1 -0
  46. package/dist/Queue-D5jcw0mu.cjs +109 -0
  47. package/dist/Queue-D5jcw0mu.cjs.map +1 -0
  48. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
  49. package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
  50. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
  51. package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
  52. package/dist/Queue-hwPN-t31.mjs +104 -0
  53. package/dist/Queue-hwPN-t31.mjs.map +1 -0
  54. package/dist/QueueBuilder-BFQn3OzZ.cjs +135 -0
  55. package/dist/QueueBuilder-BFQn3OzZ.cjs.map +1 -0
  56. package/dist/QueueBuilder-DCuYdjMw.mjs +118 -0
  57. package/dist/QueueBuilder-DCuYdjMw.mjs.map +1 -0
  58. package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
  59. package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
  60. package/dist/QueueBuilder-QHsnVt1P.d.mts +75 -0
  61. package/dist/QueueBuilder-QHsnVt1P.d.mts.map +1 -0
  62. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
  63. package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
  64. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
  65. package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
  66. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2PwqwIl.cjs} +61 -36
  67. package/dist/SubscriberBuilder-C2PwqwIl.cjs.map +1 -0
  68. package/dist/SubscriberBuilder-CuCMFpYW.d.mts +67 -0
  69. package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +1 -0
  70. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DMFk_Ap1.mjs} +50 -24
  71. package/dist/SubscriberBuilder-DMFk_Ap1.mjs.map +1 -0
  72. package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
  73. package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
  74. package/dist/Topic-CkxOTrMv.cjs +104 -0
  75. package/dist/Topic-CkxOTrMv.cjs.map +1 -0
  76. package/dist/Topic-hPffOsot.mjs +99 -0
  77. package/dist/Topic-hPffOsot.mjs.map +1 -0
  78. package/dist/adaptors/aws.cjs +118 -216
  79. package/dist/adaptors/aws.cjs.map +1 -1
  80. package/dist/adaptors/aws.d.cts +34 -53
  81. package/dist/adaptors/aws.d.cts.map +1 -1
  82. package/dist/adaptors/aws.d.mts +35 -54
  83. package/dist/adaptors/aws.d.mts.map +1 -1
  84. package/dist/adaptors/aws.mjs +91 -191
  85. package/dist/adaptors/aws.mjs.map +1 -1
  86. package/dist/adaptors/hono.cjs +3 -10
  87. package/dist/adaptors/hono.d.cts +7 -16
  88. package/dist/adaptors/hono.d.cts.map +1 -1
  89. package/dist/adaptors/hono.d.mts +8 -17
  90. package/dist/adaptors/hono.d.mts.map +1 -1
  91. package/dist/adaptors/hono.mjs +2 -10
  92. package/dist/adaptors/testing.cjs +711 -89
  93. package/dist/adaptors/testing.cjs.map +1 -1
  94. package/dist/adaptors/testing.d.cts +325 -54
  95. package/dist/adaptors/testing.d.cts.map +1 -1
  96. package/dist/adaptors/testing.d.mts +325 -54
  97. package/dist/adaptors/testing.d.mts.map +1 -1
  98. package/dist/adaptors/testing.mjs +676 -70
  99. package/dist/adaptors/testing.mjs.map +1 -1
  100. package/dist/auth-CIFXNuDk.d.cts +194 -0
  101. package/dist/auth-CIFXNuDk.d.cts.map +1 -0
  102. package/dist/auth-CJ9Ff6Lu.d.mts +194 -0
  103. package/dist/auth-CJ9Ff6Lu.d.mts.map +1 -0
  104. package/dist/auth.cjs +172 -31
  105. package/dist/auth.cjs.map +1 -1
  106. package/dist/auth.d.cts +2 -108
  107. package/dist/auth.d.mts +2 -108
  108. package/dist/auth.mjs +161 -24
  109. package/dist/auth.mjs.map +1 -1
  110. package/dist/{cache-BrRz3fEB.d.mts → cache-CXh6GIgb.d.mts} +3 -6
  111. package/dist/cache-CXh6GIgb.d.mts.map +1 -0
  112. package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
  113. package/dist/cache-DnGDGly3.d.cts.map +1 -0
  114. package/dist/cache.cjs +68 -2
  115. package/dist/cache.cjs.map +1 -0
  116. package/dist/cache.d.cts +1 -2
  117. package/dist/cache.d.mts +1 -2
  118. package/dist/cache.mjs +67 -2
  119. package/dist/cache.mjs.map +1 -0
  120. package/dist/cipher-C1lEFX63.mjs +225 -0
  121. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  122. package/dist/cipher-CVxfwLjk.cjs +332 -0
  123. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  124. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  125. package/dist/clone-EKNovYHu.mjs.map +1 -0
  126. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  127. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  128. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
  129. package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
  130. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-DluK3_da.d.mts} +42 -11
  131. package/dist/construct-interface-DluK3_da.d.mts.map +1 -0
  132. package/dist/construct-interface.cjs +113 -7
  133. package/dist/construct-interface.cjs.map +1 -0
  134. package/dist/construct-interface.d.cts +2 -2
  135. package/dist/construct-interface.d.mts +2 -2
  136. package/dist/construct-interface.mjs +106 -2
  137. package/dist/construct-interface.mjs.map +1 -0
  138. package/dist/credential.cjs +63 -16
  139. package/dist/credential.cjs.map +1 -1
  140. package/dist/credential.d.cts +16 -9
  141. package/dist/credential.d.cts.map +1 -1
  142. package/dist/credential.d.mts +16 -9
  143. package/dist/credential.d.mts.map +1 -1
  144. package/dist/credential.mjs +58 -12
  145. package/dist/credential.mjs.map +1 -1
  146. package/dist/crons/index.cjs +105 -7
  147. package/dist/crons/index.cjs.map +1 -1
  148. package/dist/crons/index.d.cts +40 -11
  149. package/dist/crons/index.d.cts.map +1 -1
  150. package/dist/crons/index.d.mts +40 -11
  151. package/dist/crons/index.d.mts.map +1 -1
  152. package/dist/crons/index.mjs +103 -8
  153. package/dist/crons/index.mjs.map +1 -1
  154. package/dist/database/kysely.cjs +4 -181
  155. package/dist/database/kysely.d.cts +2 -152
  156. package/dist/database/kysely.d.mts +2 -152
  157. package/dist/database/kysely.mjs +2 -180
  158. package/dist/email.cjs +25 -12
  159. package/dist/email.cjs.map +1 -1
  160. package/dist/email.d.cts +3 -7
  161. package/dist/email.d.cts.map +1 -1
  162. package/dist/email.d.mts +3 -7
  163. package/dist/email.d.mts.map +1 -1
  164. package/dist/email.mjs +16 -3
  165. package/dist/email.mjs.map +1 -1
  166. package/dist/encryption.cjs +96 -0
  167. package/dist/encryption.cjs.map +1 -0
  168. package/dist/encryption.d.cts +117 -0
  169. package/dist/encryption.d.cts.map +1 -0
  170. package/dist/encryption.d.mts +117 -0
  171. package/dist/encryption.d.mts.map +1 -0
  172. package/dist/encryption.mjs +83 -0
  173. package/dist/encryption.mjs.map +1 -0
  174. package/dist/endpoints/index.cjs +8 -10
  175. package/dist/endpoints/index.d.cts +51 -7
  176. package/dist/endpoints/index.d.cts.map +1 -0
  177. package/dist/endpoints/index.d.mts +51 -7
  178. package/dist/endpoints/index.d.mts.map +1 -0
  179. package/dist/endpoints/index.mjs +6 -10
  180. package/dist/external-api-CWY9orcO.d.mts +86 -0
  181. package/dist/external-api-CWY9orcO.d.mts.map +1 -0
  182. package/dist/external-api-D-5WB-sr.d.cts +86 -0
  183. package/dist/external-api-D-5WB-sr.d.cts.map +1 -0
  184. package/dist/external-api.cjs +124 -0
  185. package/dist/external-api.cjs.map +1 -0
  186. package/dist/external-api.d.cts +2 -0
  187. package/dist/external-api.d.mts +2 -0
  188. package/dist/external-api.mjs +121 -0
  189. package/dist/external-api.mjs.map +1 -0
  190. package/dist/file-server.cjs +42 -10
  191. package/dist/file-server.cjs.map +1 -1
  192. package/dist/file-server.d.cts +6 -10
  193. package/dist/file-server.d.cts.map +1 -1
  194. package/dist/file-server.d.mts +6 -10
  195. package/dist/file-server.d.mts.map +1 -1
  196. package/dist/file-server.mjs +34 -2
  197. package/dist/file-server.mjs.map +1 -1
  198. package/dist/functions/index.cjs +3 -6
  199. package/dist/functions/index.d.cts +3 -4
  200. package/dist/functions/index.d.mts +3 -4
  201. package/dist/functions/index.mjs +2 -6
  202. package/dist/{functions-i_la-N5r.cjs → functions-CbP5ZKma.cjs} +414 -264
  203. package/dist/functions-CbP5ZKma.cjs.map +1 -0
  204. package/dist/{functions-14lpEFL4.mjs → functions-Di6n5ltG.mjs} +376 -238
  205. package/dist/{functions-14lpEFL4.mjs.map → functions-Di6n5ltG.mjs.map} +1 -1
  206. package/dist/index-BuzRvKOQ.d.cts +115 -0
  207. package/dist/index-BuzRvKOQ.d.cts.map +1 -0
  208. package/dist/index-CTkKOer4.d.mts +115 -0
  209. package/dist/index-CTkKOer4.d.mts.map +1 -0
  210. package/dist/index-CeEtxDmK.d.cts +79 -0
  211. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  212. package/dist/index-CeEtxDmK.d.mts +79 -0
  213. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  214. package/dist/index.cjs +6 -3
  215. package/dist/index.d.cts +26 -4
  216. package/dist/index.d.cts.map +1 -0
  217. package/dist/index.d.mts +26 -4
  218. package/dist/index.d.mts.map +1 -0
  219. package/dist/index.mjs +3 -3
  220. package/dist/kms-B-Hm3d5r.cjs +85 -0
  221. package/dist/kms-B-Hm3d5r.cjs.map +1 -0
  222. package/dist/kms-BdUlMJEZ.mjs +85 -0
  223. package/dist/kms-BdUlMJEZ.mjs.map +1 -0
  224. package/dist/kysely-BEm5sDlU.d.cts +173 -0
  225. package/dist/kysely-BEm5sDlU.d.cts.map +1 -0
  226. package/dist/kysely-BRzzawr2.cjs +301 -0
  227. package/dist/kysely-BRzzawr2.cjs.map +1 -0
  228. package/dist/kysely-BYfM6Zby.mjs +288 -0
  229. package/dist/kysely-BYfM6Zby.mjs.map +1 -0
  230. package/dist/kysely-CjuvdXEV.d.mts +173 -0
  231. package/dist/kysely-CjuvdXEV.d.mts.map +1 -0
  232. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-CFanua0O.mjs} +20 -60
  233. package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
  234. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -113
  235. package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
  236. package/dist/mobile-app.cjs +73 -0
  237. package/dist/mobile-app.cjs.map +1 -0
  238. package/dist/mobile-app.d.cts +61 -0
  239. package/dist/mobile-app.d.cts.map +1 -0
  240. package/dist/mobile-app.d.mts +61 -0
  241. package/dist/mobile-app.d.mts.map +1 -0
  242. package/dist/mobile-app.mjs +72 -0
  243. package/dist/mobile-app.mjs.map +1 -0
  244. package/dist/object-storage.cjs +18 -10
  245. package/dist/object-storage.cjs.map +1 -1
  246. package/dist/object-storage.d.cts +3 -7
  247. package/dist/object-storage.d.cts.map +1 -1
  248. package/dist/object-storage.d.mts +3 -7
  249. package/dist/object-storage.d.mts.map +1 -1
  250. package/dist/object-storage.mjs +11 -3
  251. package/dist/object-storage.mjs.map +1 -1
  252. package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
  253. package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
  254. package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
  255. package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
  256. package/dist/queue/index.cjs +6 -189
  257. package/dist/queue/index.d.cts +3 -60
  258. package/dist/queue/index.d.mts +3 -60
  259. package/dist/queue/index.mjs +3 -186
  260. package/dist/rest-api.cjs +88 -63
  261. package/dist/rest-api.cjs.map +1 -1
  262. package/dist/rest-api.d.cts +68 -61
  263. package/dist/rest-api.d.cts.map +1 -1
  264. package/dist/rest-api.d.mts +68 -61
  265. package/dist/rest-api.d.mts.map +1 -1
  266. package/dist/rest-api.mjs +80 -55
  267. package/dist/rest-api.mjs.map +1 -1
  268. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  269. package/dist/runSubscriber-BRp9a_qi.cjs +126 -0
  270. package/dist/runSubscriber-BRp9a_qi.cjs.map +1 -0
  271. package/dist/runSubscriber-BYEY_bfA.mjs +109 -0
  272. package/dist/runSubscriber-BYEY_bfA.mjs.map +1 -0
  273. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  274. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  275. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  276. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  277. package/dist/site.cjs +34 -9
  278. package/dist/site.cjs.map +1 -1
  279. package/dist/site.d.cts +17 -22
  280. package/dist/site.d.cts.map +1 -1
  281. package/dist/site.d.mts +17 -22
  282. package/dist/site.d.mts.map +1 -1
  283. package/dist/site.mjs +30 -5
  284. package/dist/site.mjs.map +1 -1
  285. package/dist/subscribers/index.cjs +111 -6
  286. package/dist/subscribers/index.cjs.map +1 -0
  287. package/dist/subscribers/index.d.cts +50 -6
  288. package/dist/subscribers/index.d.cts.map +1 -0
  289. package/dist/subscribers/index.d.mts +50 -6
  290. package/dist/subscribers/index.d.mts.map +1 -0
  291. package/dist/subscribers/index.mjs +108 -5
  292. package/dist/subscribers/index.mjs.map +1 -0
  293. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  294. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  295. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  296. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  297. package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
  298. package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
  299. package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
  300. package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
  301. package/dist/topic/index.cjs +3 -137
  302. package/dist/topic/index.d.cts +2 -4
  303. package/dist/topic/index.d.mts +2 -4
  304. package/dist/topic/index.mjs +2 -134
  305. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  306. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  307. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  308. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  309. package/dist/types.d.cts +1 -1
  310. package/dist/types.d.mts +1 -1
  311. package/dist/types.mjs +1 -0
  312. package/dist/worker.cjs +58 -34
  313. package/dist/worker.cjs.map +1 -1
  314. package/dist/worker.d.cts +63 -45
  315. package/dist/worker.d.cts.map +1 -1
  316. package/dist/worker.d.mts +63 -44
  317. package/dist/worker.d.mts.map +1 -1
  318. package/dist/worker.mjs +53 -29
  319. package/dist/worker.mjs.map +1 -1
  320. package/package.json +82 -41
  321. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  322. package/dist/Construct-C0ijr2qp.d.cts +0 -117
  323. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  324. package/dist/Construct-Ct8nalEi.d.mts +0 -117
  325. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  326. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  327. package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
  328. package/dist/Cron-dh4rUgib.d.mts.map +0 -1
  329. package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
  330. package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
  331. package/dist/CronBuilder-CGgY2080.d.mts +0 -44
  332. package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
  333. package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
  334. package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
  335. package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
  336. package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
  337. package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
  338. package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
  339. package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
  340. package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
  341. package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
  342. package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
  343. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  344. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  345. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  346. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  347. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  348. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  349. package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
  350. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  351. package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
  352. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  353. package/dist/Topic-19QeHBIR.d.cts +0 -91
  354. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  355. package/dist/Topic-DuFeqkBh.d.mts +0 -91
  356. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  357. package/dist/auth.d.cts.map +0 -1
  358. package/dist/auth.d.mts.map +0 -1
  359. package/dist/cache-0ANvRQnD.mjs +0 -51
  360. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  361. package/dist/cache-3WSvAulx.cjs +0 -57
  362. package/dist/cache-3WSvAulx.cjs.map +0 -1
  363. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  364. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  365. package/dist/clone-DblgEZZa.mjs.map +0 -1
  366. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  367. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  368. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  369. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  370. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  371. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  372. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  373. package/dist/database/kysely.cjs.map +0 -1
  374. package/dist/database/kysely.d.cts.map +0 -1
  375. package/dist/database/kysely.d.mts.map +0 -1
  376. package/dist/database/kysely.mjs.map +0 -1
  377. package/dist/functions-i_la-N5r.cjs.map +0 -1
  378. package/dist/index-Bd5FqCoe.d.cts.map +0 -1
  379. package/dist/index-BknhM6Ux.d.mts +0 -31
  380. package/dist/index-BknhM6Ux.d.mts.map +0 -1
  381. package/dist/index-CBSfrowv.d.cts +0 -31
  382. package/dist/index-CBSfrowv.d.cts.map +0 -1
  383. package/dist/index-D24Xm79M.d.cts +0 -171
  384. package/dist/index-D24Xm79M.d.cts.map +0 -1
  385. package/dist/index-_ajboYxK.d.mts +0 -171
  386. package/dist/index-_ajboYxK.d.mts.map +0 -1
  387. package/dist/index-lAO9egTb.d.mts.map +0 -1
  388. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  389. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  390. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  391. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  392. package/dist/queue/index.cjs.map +0 -1
  393. package/dist/queue/index.d.cts.map +0 -1
  394. package/dist/queue/index.d.mts.map +0 -1
  395. package/dist/queue/index.mjs.map +0 -1
  396. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  397. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  398. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  399. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  400. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  401. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  402. package/dist/topic/index.cjs.map +0 -1
  403. package/dist/topic/index.mjs.map +0 -1
  404. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  405. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"worker.cjs","names":["id: ConstructName<TName>","config: WorkerConfig","dependencies: readonly Dependency[]","scheduleStore?: Consumable<string, unknown>","DEFAULT_LOGGER","source: Consumable<TDbName, T>","schedule: ScheduleExpression","CronBuilder","topic: Topic<TTopicName, TEvents>","SubscriberBuilder","service: Service<TPubName, T> | Consumable<TPubName, T>","schema: T","ms: number","mb: number","constructs: T","services: T","FunctionBuilder","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 * ## 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;CACC,AAAS;;CAGT,AAAS;;CAGT,AAAS;;;;;CAMT,AAAS;CAET,YACCA,IACiBC,SAAuB,CAAE,GAEzBC,eAAsC,CAAE,GACzDC,eACC;EAJgB;EAEA;EAGjB,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;AACD,OAAK,gBAAgB;CACrB;;;;;;;;;;;;;;;;;;;;;CAsBD,SACCC,QACgB;AAChB,SAAO,IAAI,OACV,KAAK,IACL,KAAK,QACL,CAAC,GAAG,KAAK,cAAc,mCAAO,OAAO,AAAC,GACtC;CAED;;;;;;CAOD,KAAKC,UAA8B;AAClC,SAAO,KAAK,IAAI,IAAIC,kCAAc,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,SAAS;CACzE;;;;;;;;;;;CAYD,MACCC,OACC;AACD,SAAO,KAAK,IAAI,IAAIC,8CAAoB,OAAO,KAAK,OAAO,CAAC,CAAC,MAAM,MAAM;CACzE;;;;;;;;;CAUD,UACCC,SACC;AACD,SAAO,KAAK,IAAI,IAAID,8CAAoB,OAAO,KAAK,OAAO,CAAC,CAAC,UAC5D,QACA;CACD;;;;;;;;;;;;CAaD,MAA0CE,QAAW;AACpD,SAAO,KAAK,UAAU,MAAM,OAAO;CACnC;CAED,OAAmCA,QAAW;AAC7C,SAAO,KAAK,UAAU,OAAO,OAAO;CACpC;CAED,QAAQC,IAAY;AACnB,SAAO,KAAK,UAAU,QAAQ,GAAG;CACjC;CAED,WAAWC,IAAY;AACtB,SAAO,KAAK,UAAU,WAAW,GAAG;CACpC;CAED,UAAiDC,YAAe;AAC/D,SAAO,KAAK,UAAU,UAAU,WAAW;CAC3C;CAED,SAA8BC,UAAa;AAC1C,SAAO,KAAK,UAAU,SAAS,SAAS;CACxC;;;;;;CAOD,OACC,GAAG,MAGF;AACD,SAAO,KAAK,oBAAoB,CAAC,OAAO,GAAG,KAAK;CAChD;;CAGD,AAAQ,qBAAqB;AAC5B,SAAO,KAAK;CACZ;;CAGD,IAAY,YAAY;AACvB,SAAO,KAAK,IAAI,IAAIC,oCAAkB,OAAO,KAAK,OAAO,CAAC;CAC1D;;;;;;;CAQD,MAAMC,YAAkD;AACvD,SAAO,IAAI,OACV,KAAK,IACL,KAAK,QACL,CAAC,GAAG,KAAK,cAAc,GAAG,WAAW,IAAIC,mCAAO,AAAC,GACjD,KAAK;CAEN;;;;;CAMD,AAAQ,IACPC,SACI;AACJ,UAAQ,SAAS,KAAK;AACtB,UAAQ,iBAAiB,KAAK;AAE9B,SAAO;CACP;CAED,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,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","QueueBuilder","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 * ## The database is everything's default\n *\n * The same `.database(db)` is the database every cron, queue, subscriber and\n * function built from the worker receives as `db`. The work a worker groups is\n * usually work against one database, and naming it per handler was a line\n * repeated in every file that could drift in any one of them. A runnable that\n * works against another names its own with `.database(other)`, which replaces\n * the worker's — client and manifest edge both — rather than adding to it.\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 }).database(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 ({ db, logger }) => { … });\n *\n * // queues/reports.ts — against another database than the worker's\n * export const reports = worker\n * .queue('Reports')\n * .database(analytics)\n * .message(z.object({ id: z.uuid() }))\n * .handle(async ({ messages, db }) => { … });\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 { QueueBuilder } from './queue/QueueBuilder';\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<\n\tTName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> implements 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 — and the database everything built from it receives as `db`.\n\t * `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, and the one everything\n\t * built from it — crons, queues, subscribers, functions — receives as `db`.\n\t * One of them that works against another database names it with its own\n\t * `.database(other)`, which replaces this one for that runnable alone.\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 * export const sweep = jobs\n\t * .cron('rate(1 hour)')\n\t * .handle(async ({ db }) => db.deleteFrom('sessions').execute());\n\t * ```\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T>,\n\t): Worker<TName, T, TDbName> {\n\t\treturn new Worker<TName, T, TDbName>(\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(\n\t\t\tnew CronBuilder<\n\t\t\t\tComposableStandardSchema,\n\t\t\t\tService[],\n\t\t\t\tLogger,\n\t\t\t\tundefined,\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t).schedule(schedule);\n\t}\n\n\t/**\n\t * A queue and its one consumer, run by this worker.\n\t *\n\t * One construct, because a queue has exactly one consumer: nothing else can\n\t * attach a second, or forget to attach the first. Producers send to it by\n\t * depending on it — `.dependsOn([emails])` makes `services.emails` the\n\t * publisher.\n\t *\n\t * @example\n\t * ```ts\n\t * export const emails = worker\n\t * .queue('Emails')\n\t * .message(z.object({ userId: z.uuid(), template: z.string() }))\n\t * .handle(async ({ messages, services }) => { … });\n\t * ```\n\t */\n\tqueue<TQueueName extends string>(name: TQueueName) {\n\t\treturn this.own(\n\t\t\tnew QueueBuilder<\n\t\t\t\tstring,\n\t\t\t\tundefined,\n\t\t\t\t[],\n\t\t\t\tLogger,\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t).queue(name);\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. A handler that emits\n\t * follow-up events depends on the topic it emits to —\n\t * `.dependsOn([orders])` — which is the only reason it would need 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(\n\t\t\tnew SubscriberBuilder<\n\t\t\t\t[],\n\t\t\t\tLogger,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\t[],\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t).topic(topic);\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<\n\t\t\t\tWorker<TName, TDatabase, TDatabaseServiceName>['schemalessFunction']\n\t\t\t>['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(\n\t\t\tnew FunctionBuilder<\n\t\t\t\tany,\n\t\t\t\tundefined,\n\t\t\t\t[],\n\t\t\t\tLogger,\n\t\t\t\tundefined,\n\t\t\t\tstring,\n\t\t\t\tTDatabase,\n\t\t\t\tTDatabaseServiceName\n\t\t\t>().logger(this.logger),\n\t\t);\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(\n\t\tconstructs: readonly Declarable[],\n\t): Worker<TName, TDatabase, TDatabaseServiceName> {\n\t\treturn new Worker<TName, TDatabase, TDatabaseServiceName>(\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 — and hands it the worker's database.\n\t *\n\t * The database goes through the builder's own `.database()` rather than\n\t * being written into its fields, so the default is recorded exactly as an\n\t * explicit one would be: the client the handler gets, and the edge the\n\t * manifest reads. That is also what lets a later `.database(other)` replace\n\t * it outright. The builder arrives already typed with this worker's\n\t * database; this is the runtime half of that.\n\t */\n\tprivate own<\n\t\tT extends {\n\t\t\t_owner?: string;\n\t\t\t_scheduleStore?: unknown;\n\t\t\tdatabase(source: Consumable<string, unknown>): unknown;\n\t\t},\n\t>(builder: T): T {\n\t\tconst owned = this.scheduleStore\n\t\t\t? (builder.database(this.scheduleStore) as T)\n\t\t\t: builder;\n\n\t\towned._owner = this.id;\n\t\towned._scheduleStore = this.scheduleStore;\n\n\t\treturn owned;\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":";;;;;;;;;;AAqHA,IAAa,SAAb,MAAa,OAKb;CAkBmB;CAEA;CAnBlB;;CAGA;;CAGA;;;;;;CAOA;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BA,SACC,QAC4B;EAC5B,OAAO,IAAI,OACV,KAAK,IACL,KAAK,QACL,CAAC,GAAG,KAAK,cAAcC,4BAAAA,OAAO,MAAM,CAAC,GACrC,MACD;CACD;;;;;;CAOA,KAAK,UAA8B;EAClC,OAAO,KAAK,IACX,IAAIC,oBAAAA,YAOF,CAAC,CAAC,OAAO,KAAK,MAAM,CACvB,CAAC,CAAC,SAAS,QAAQ;CACpB;;;;;;;;;;;;;;;;;CAkBA,MAAiC,MAAkB;EAClD,OAAO,KAAK,IACX,IAAIC,qBAAAA,aAOF,CAAC,CAAC,OAAO,KAAK,MAAM,CACvB,CAAC,CAAC,MAAM,IAAI;CACb;;;;;;;;;;;CAYA,MACC,OACC;EACD,OAAO,KAAK,IACX,IAAIC,0BAAAA,kBAQF,CAAC,CAAC,OAAO,KAAK,MAAM,CACvB,CAAC,CAAC,MAAM,KAAK;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,MAKF;EACD,OAAO,KAAK,mBAAmB,CAAC,CAAC,OAAO,GAAG,IAAI;CAChD;;CAGA,qBAA6B;EAC5B,OAAO,KAAK;CACb;;CAGA,IAAY,YAAY;EACvB,OAAO,KAAK,IACX,IAAIC,kBAAAA,gBASF,CAAC,CAAC,OAAO,KAAK,MAAM,CACvB;CACD;;;;;;;CAQA,MACC,YACiD;EACjD,OAAO,IAAI,OACV,KAAK,IACL,KAAK,QACL,CAAC,GAAG,KAAK,cAAc,GAAG,WAAW,IAAIJ,4BAAAA,MAAM,CAAC,GAChD,KAAK,aACN;CACD;;;;;;;;;;;;CAaA,IAME,SAAe;EAChB,MAAM,QAAQ,KAAK,gBACf,QAAQ,SAAS,KAAK,aAAa,IACpC;EAEH,MAAM,SAAS,KAAK;EACpB,MAAM,iBAAiB,KAAK;EAE5B,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,24 +1,20 @@
1
- import "./Construct-C0ijr2qp.cjs";
2
- import { Function, FunctionBuilder, FunctionHandler } from "./index-D24Xm79M.cjs";
3
- import { Consumable, Declarable, ServicesOf } from "./construct-interface-D9d4Gm4p.cjs";
4
- import { ScheduleExpression } from "./Cron-DmQ8vQ4b.cjs";
5
- import "./Subscriber-2mEi0ImH.cjs";
6
- import { CronBuilder } from "./CronBuilder-BquXDbDI.cjs";
7
- import { Topic, TopicEvents, TopicMessage } from "./Topic-19QeHBIR.cjs";
8
- import { SubscriberBuilder } from "./SubscriberBuilder-waNhzjSM.cjs";
9
- import "./index-CBSfrowv.cjs";
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.cjs";
2
+ import { c as Topic, l as TopicEvents, u as TopicMessage } from "./Construct-BQALFCh2.cjs";
3
+ import { i as FunctionHandler, n as Function } from "./Function-Pu-1kKZz.cjs";
4
+ import { c as ServicesOf, i as Declarable, r as Consumable } from "./construct-interface-B1AfqRl4.cjs";
5
+ import { t as FunctionBuilder } from "./index-BuzRvKOQ.cjs";
6
+ import { i as ScheduleExpression } from "./Cron-DI3nKoic.cjs";
7
+ import { t as CronBuilder } from "./CronBuilder-g1lZLWyG.cjs";
8
+ import { t as QueueBuilder } from "./QueueBuilder-OSi6LkV9.cjs";
9
+ import { t as SubscriberBuilder } from "./SubscriberBuilder-g3fAVWgs.cjs";
10
+ import "./topic/index.cjs";
10
11
  import { EnvironmentParser } from "@geekmidas/envkit";
11
- import { EventPublisher } from "@geekmidas/events";
12
12
  import { Logger } from "@geekmidas/logger";
13
13
  import { ComposableStandardSchema } from "@geekmidas/schema";
14
14
  import { Service } from "@geekmidas/services";
15
- import { StandardSchemaV1 } from "@standard-schema/spec";
16
- import * as _geekmidas_audit13 from "@geekmidas/audit";
17
15
  import { ConstructName, Declaration, Dependency } from "@geekmidas/manifest";
18
-
19
16
  //#region src/worker.d.ts
20
-
21
- interface WorkerConfig {
17
+ export interface WorkerConfig {
22
18
  /**
23
19
  * The logger everything built from this worker runs with.
24
20
  *
@@ -36,7 +32,7 @@ interface WorkerConfig {
36
32
  */
37
33
  envParser?: EnvironmentParser<{}>;
38
34
  }
39
- declare class Worker<TName extends string = string> implements Declarable<TName> {
35
+ export declare class Worker<TName extends string = string, TDatabase = undefined, TDatabaseServiceName extends string = string> implements Declarable<TName> {
40
36
  private readonly config;
41
37
  /** Internal: how `.calls()` carries edges into the copy it returns. */
42
38
  private readonly dependencies;
@@ -47,13 +43,18 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
47
43
  readonly envParser: EnvironmentParser<{}>;
48
44
  /**
49
45
  * Where this worker's schedules live, when it has crons and a server runs
50
- * them. `undefined` until `.database(…)` says.
46
+ * them — and the database everything built from it receives as `db`.
47
+ * `undefined` until `.database(…)` says.
51
48
  */
52
49
  readonly scheduleStore?: Consumable<string, unknown>;
53
- constructor(id: ConstructName<TName>, config?: WorkerConfig, /** Internal: how `.calls()` carries edges into the copy it returns. */
50
+ constructor(id: ConstructName<TName>, config?: WorkerConfig,
51
+ /** Internal: how `.calls()` carries edges into the copy it returns. */
54
52
  dependencies?: readonly Dependency[], scheduleStore?: Consumable<string, unknown>);
55
53
  /**
56
- * The database this worker keeps its schedules in.
54
+ * The database this worker keeps its schedules in, and the one everything
55
+ * built from it — crons, queues, subscribers, functions — receives as `db`.
56
+ * One of them that works against another database names it with its own
57
+ * `.database(other)`, which replaces this one for that runnable alone.
57
58
  *
58
59
  * Only a server target uses it. On AWS a cron is an EventBridge rule
59
60
  * invoking a Lambda and nothing here is consulted — but a server has nothing
@@ -70,35 +71,47 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
70
71
  * @example
71
72
  * ```ts
72
73
  * export const jobs = new Worker('Jobs', { logger }).database(database);
74
+ *
75
+ * export const sweep = jobs
76
+ * .cron('rate(1 hour)')
77
+ * .handle(async ({ db }) => db.deleteFrom('sessions').execute());
73
78
  * ```
74
79
  */
75
- database<T, TDbName extends string>(source: Consumable<TDbName, T>): Worker<TName>;
80
+ database<T, TDbName extends string>(source: Consumable<TDbName, T>): Worker<TName, T, TDbName>;
76
81
  /**
77
82
  * A scheduled runnable.
78
83
  *
79
84
  * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
80
85
  */
81
- cron(schedule: ScheduleExpression): CronBuilder<ComposableStandardSchema, Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
86
+ cron(schedule: ScheduleExpression): CronBuilder<ComposableStandardSchema, Service[], Logger, undefined, TDatabase, TDatabaseServiceName>;
82
87
  /**
83
- * A runnable that consumes a topic.
88
+ * A queue and its one consumer, run by this worker.
84
89
  *
85
- * Binding is not publishing: a consumer is handed the topic's event types
86
- * and no connection string it could publish with. Chain `.publishes(…)` when
87
- * the handler emits follow-up events, which is the only reason it would need
88
- * one.
90
+ * One construct, because a queue has exactly one consumer: nothing else can
91
+ * attach a second, or forget to attach the first. Producers send to it by
92
+ * depending on it — `.dependsOn([emails])` makes `services.emails` the
93
+ * publisher.
89
94
  *
90
- * @example `worker.topic(users).subscribe(['user.created']).handle(…)`
95
+ * @example
96
+ * ```ts
97
+ * export const emails = worker
98
+ * .queue('Emails')
99
+ * .message(z.object({ userId: z.uuid(), template: z.string() }))
100
+ * .handle(async ({ messages, services }) => { … });
101
+ * ```
91
102
  */
92
- topic<TTopicName extends string, TEvents extends TopicEvents>(topic: Topic<TTopicName, TEvents>): SubscriberBuilder<[], Logger, undefined, EventPublisher<TopicMessage<TEvents>>, string, []>;
103
+ queue<TQueueName extends string>(name: TQueueName): QueueBuilder<TQueueName, undefined, [], Logger, TDatabase, TDatabaseServiceName>;
93
104
  /**
94
- * A runnable that consumes events typed from a publisher service.
105
+ * A runnable that consumes a topic.
106
+ *
107
+ * Binding is not publishing: a consumer is handed the topic's event types
108
+ * and no connection string it could publish with. A handler that emits
109
+ * follow-up events depends on the topic it emits to —
110
+ * `.dependsOn([orders])` — which is the only reason it would need one.
95
111
  *
96
- * The older of the two ways to bind a subscriber, kept for a project whose
97
- * events come from a hand-written publisher rather than a `Topic`
98
- * construct. `topic()` is the one to reach for: it types the events the same
99
- * way and hands the consumer no connection string it could publish with.
112
+ * @example `worker.topic(users).subscribe(['user.created']).handle(…)`
100
113
  */
101
- publisher<T extends EventPublisher<any>, TPubName extends string>(service: Service<TPubName, T> | Consumable<TPubName, T>): SubscriberBuilder<[], Logger, undefined, EventPublisher<any>, string, []>;
114
+ topic<TTopicName extends string, TEvents extends TopicEvents>(topic: Topic<TTopicName, TEvents>): SubscriberBuilder<[], Logger, undefined, EventPublisher<TopicMessage<TEvents_1>>, [], TDatabase, TDatabaseServiceName>;
102
115
  /**
103
116
  * Everything below builds a function — the runnable with no schedule and no
104
117
  * topic, invoked by something else.
@@ -110,18 +123,18 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
110
123
  * makes a cron, a topic makes a subscriber, and anything else makes a
111
124
  * function.
112
125
  */
113
- input<T extends ComposableStandardSchema>(schema: T): FunctionBuilder<T, undefined, [], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit13.AuditableAction<string, unknown>>;
114
- output<T extends StandardSchemaV1>(schema: T): FunctionBuilder<ComposableStandardSchema, T, [], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit13.AuditableAction<string, unknown>>;
115
- timeout(ms: number): FunctionBuilder<ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit13.AuditableAction<string, unknown>>;
116
- memorySize(mb: number): FunctionBuilder<ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit13.AuditableAction<string, unknown>>;
117
- dependsOn<const T extends readonly Consumable[]>(constructs: T): FunctionBuilder<ComposableStandardSchema, undefined, [...ServicesOf<T>], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit13.AuditableAction<string, unknown>>;
118
- services<T extends Service[]>(services: T): FunctionBuilder<ComposableStandardSchema, undefined, [...T], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit13.AuditableAction<string, unknown>>;
126
+ input<T extends ComposableStandardSchema>(schema: T): FunctionBuilder<T, undefined, [], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
127
+ output<T extends StandardSchemaV1>(schema: T): FunctionBuilder<any, T, [], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
128
+ timeout(ms: number): FunctionBuilder<any, undefined, [], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
129
+ memorySize(mb: number): FunctionBuilder<any, undefined, [], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
130
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): FunctionBuilder<any, undefined, [...ServicesOf<T>], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
131
+ services<T extends Service[]>(services: T): FunctionBuilder<any, undefined, [...T], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
119
132
  /**
120
133
  * A function with no input schema — the shortest runnable there is.
121
134
  *
122
135
  * @example `worker.handle(async ({ logger }) => { … })`
123
136
  */
124
- handle(...args: Parameters<ReturnType<Worker<TName>['schemalessFunction']>['handle']>): Function<ComposableStandardSchema, [], Logger, undefined, undefined, string, undefined, string, undefined, string, _geekmidas_audit13.AuditableAction<string, unknown>, FunctionHandler<ComposableStandardSchema, [], Logger, undefined, undefined, undefined, _geekmidas_audit13.AuditableAction<string, unknown>>>;
137
+ handle(...args: Parameters<ReturnType<Worker<TName, TDatabase, TDatabaseServiceName>['schemalessFunction']>['handle']>): Function<any, [], Logger, undefined, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>, FunctionHandler<any, [], Logger, undefined, TDatabase, undefined, AuditableAction<string, unknown>>>;
125
138
  /** The builder `handle` delegates to, named so its type can be referred to. */
126
139
  private schemalessFunction;
127
140
  /** The function builder the delegating methods above are built on. */
@@ -132,15 +145,20 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
132
145
  * Not `.dependsOn()`: this records the edge that derives the worker's
133
146
  * environment and its access, the same distinction `RestApi.calls()` draws.
134
147
  */
135
- calls(constructs: readonly Declarable[]): Worker<TName>;
148
+ calls(constructs: readonly Declarable[]): Worker<TName, TDatabase, TDatabaseServiceName>;
136
149
  /**
137
150
  * Stamps this worker's id onto a builder, so everything built from it says
138
- * which process runs it.
151
+ * which process runs it — and hands it the worker's database.
152
+ *
153
+ * The database goes through the builder's own `.database()` rather than
154
+ * being written into its fields, so the default is recorded exactly as an
155
+ * explicit one would be: the client the handler gets, and the edge the
156
+ * manifest reads. That is also what lets a later `.database(other)` replace
157
+ * it outright. The builder arrives already typed with this worker's
158
+ * database; this is the runtime half of that.
139
159
  */
140
160
  private own;
141
161
  declare(): Declaration[];
142
162
  }
143
- //# sourceMappingURL=worker.d.ts.map
144
163
  //#endregion
145
- export { Worker, WorkerConfig };
146
164
  //# sourceMappingURL=worker.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.cts","names":[],"sources":["../src/worker.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA2NoD,UA1InC,YAAA,CA0ImC;EAAA;;;;;;;;EAIP,MAAA,CAAA,EArInC,MAqImC;EAAA;;;;;;EAQvB,SAAA,CAAA,EAtIT,iBAsIS,CAAA,CAAA,CAAA,CAAA;;AAIc,cAvIvB,MAuIuB,CAAA,cAAA,MAAA,GAAA,MAAA,CAAA,YAtIxB,UAsIwB,CAtIb,KAsIa,CAAA,CAAA;EAAU,iBAAgB,MAAA;EAAC;EAAA,iBAAA,YAAA;EAAA,SAAA,EAAA,EApIjD,KAoIiD;EAAA;EAAA,SAAA,MAAA,EAjI7C,MAiI6C;EAAA;EAAA,SAI3C,SAAA,EAlIC,iBAkID,CAAA,CAAA,CAAA,CAAA;EAAO;;;;EAAe,SAAA,aAAA,CAAA,EA5HhB,UA4HgB,CAAA,MAAA,EAAA,OAAA,CAAA;EAAA,WAAA,CAAA,EAAA,EAzHpC,aAyHoC,CAzHtB,KAyHsB,CAAA,EAAA,MAAA,CAAA,EAxHf,YAwHe,EAAA;EAWhB,YAAZ,CAAA,EAAA,SAjI4B,UAiI5B,EAAA,EAAA,aAAA,CAAA,EAhII,UAgIJ,CAAA,MAAA,EAAA,OAAA,CAAA;EAAM;;;;;;;;;;;;;;;AArJE;;;;;8CAwDZ,WAAW,SAAS,KAC1B,OAAO;;;;;;iBAcK,qBAAkB,YAAA,0BAAA,4BAAA;;;;;;;;;;;mDAcgB,oBACzC,MAAM,YAAY,WAAQ,sBAAA,mBAAA,eAAA,aAAA;;;;;;;;;sBAad,uDACV,QAAQ,UAAU,KAAK,WAAW,UAAU,KAAE,sBAAA,mBAAA;;;;;;;;;;;;kBAkBxC,kCAAkC,IAAC,gBAAA,kBAAA,iEAAA,kBAAA,CAAA;mBAIlC,0BAA0B,IAAC,gBAAA,0BAAA,OAAA,iEAAA,kBAAA,CAAA;uBAI1B,gBAAA,yCAAA,iEAAA,kBAAA,CAAA;0BAIG,gBAAA,yCAAA,iEAAA,kBAAA,CAAA;qCAIc,0BAA0B,IAAC,gBAAA,yCAAA,WAAA,KAAA,iEAAA,kBAAA,CAAA;qBAI3C,qBAAqB,IAAC,gBAAA,yCAAA,IAAA,iEAAA,kBAAA,CAAA;;;;;;kBAU/B,WACR,WAAW,OAAO,2CAClB,SAAA,8BAAA,4EAAA,kBAAA,CAAA,kCAAA,gBAAA,8BAAA,yCAAA,kBAAA,CAAA;;;;;;;;;;;6BAqByB,eAAe,OAAO;;;;;;aAsBtC"}
1
+ {"version":3,"file":"worker.d.cts","names":["_$__topic0.TopicMessage","_$__construct_interface0.ServicesOf","_$__functions0.FunctionHandler","_$__functions0.Function"],"sources":["../src/worker.ts"],"mappings":";;;;;;;;;;;;;;;;iBAkGiB;;;;;;;;;EAShB,SAAS;;;;;;;EAOT,YAAY;;qBAGA,OACZ,+BACA,uBACA,yDACY,WAAW;mBAmBL;;mBAEA;WAnBT,IAAI;;WAGJ,QAAQ;;WAGR,WAAW;;;;;;WAOX,gBAAgB;EAEzB,YACC,IAAI,cAAc,QACD,SAAQ,cAER;;EAAA,wBAAuB,cACxC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCjB,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAC1B,OAAO,OAAO,GAAG;;;;;;EAcpB,KAAK,UAAU,qBAAkB,YAAA,0BAAA,WAAA,mBAAA,WAAA;;;;;;;;;;;;;;;;;EA6BjC,MAAM,2BAA2B,MAAM,aAAU,aAAA,2BAAA,QAAA,WAAA;;;;;;;;;;;EAuBjD,MAAM,2BAA2B,gBAAgB,aAChD,OAAO,MAAM,YAAY,WAAQ,sBAAA,mBAAA,eAAAA,aAAA,iBAAA,WAAA;;;;;;;;;;;;EA0BlC,MAAM,UAAU,0BAA0B,QAAQ,IAAC,gBAAA,kBAAA,2BAAA,WAAA,sBAAA;EAInD,OAAO,UAAU,kBAAkB,QAAQ,IAAC,qBAAA,OAAA,2BAAA,WAAA,sBAAA;EAI5C,QAAQ,aAAU,oCAAA,2BAAA,WAAA,sBAAA;EAIlB,WAAW,aAAU,oCAAA,2BAAA,WAAA,sBAAA;EAIrB,gBAAgB,mBAAmB,cAAc,YAAY,IAAC,oCAAAC,WAAA,KAAA,2BAAA,WAAA,sBAAA;EAI9D,SAAS,UAAU,WAAW,UAAU,IAAC,oCAAA,IAAA,2BAAA,WAAA,sBAAA;;;;;;EASzC,UACI,MAAM,WACR,WACC,OAAO,OAAO,WAAW,0DAE1BE,kBAAA,sCAAA,WAAA,sBAAA,kCAAAD,yBAAA,mBAAA,sBAAA;;UAMM;;cAKI;;;;;;;EAqBZ,MACC,qBAAqB,eACnB,OAAO,OAAO,WAAW;;;;;;;;;;;;UAoBpB;EAiBR,WAAW"}
package/dist/worker.d.mts CHANGED
@@ -1,23 +1,20 @@
1
- import "./Construct-Ct8nalEi.mjs";
2
- import { Function, FunctionBuilder, FunctionHandler } from "./index-_ajboYxK.mjs";
3
- import { Consumable, Declarable, ServicesOf } from "./construct-interface-g5GM5pwR.mjs";
4
- import { ScheduleExpression } from "./Cron-dh4rUgib.mjs";
5
- import "./Subscriber-xTJ9ayPN.mjs";
6
- import { CronBuilder } from "./CronBuilder-CGgY2080.mjs";
7
- import { Topic, TopicEvents, TopicMessage } from "./Topic-DuFeqkBh.mjs";
8
- import { SubscriberBuilder } from "./SubscriberBuilder-Dptmo-1A.mjs";
9
- import "./index-BknhM6Ux.mjs";
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.mjs";
2
+ import { c as Topic, l as TopicEvents, u as TopicMessage } from "./Construct-QXnl3VqT.mjs";
3
+ import { i as FunctionHandler, n as Function } from "./Function-DuqGcbOI.mjs";
4
+ import { c as ServicesOf, i as Declarable, r as Consumable } from "./construct-interface-DluK3_da.mjs";
5
+ import { t as FunctionBuilder } from "./index-CTkKOer4.mjs";
6
+ import { i as ScheduleExpression } from "./Cron-uYAHPnp7.mjs";
7
+ import { t as CronBuilder } from "./CronBuilder-DaSUm2Na.mjs";
8
+ import { t as QueueBuilder } from "./QueueBuilder-QHsnVt1P.mjs";
9
+ import { t as SubscriberBuilder } from "./SubscriberBuilder-CuCMFpYW.mjs";
10
+ import "./topic/index.mjs";
10
11
  import { ConstructName, Declaration, Dependency } from "@geekmidas/manifest";
11
12
  import { EnvironmentParser } from "@geekmidas/envkit";
12
13
  import { Service } from "@geekmidas/services";
13
- import { EventPublisher } from "@geekmidas/events";
14
14
  import { Logger } from "@geekmidas/logger";
15
15
  import { ComposableStandardSchema } from "@geekmidas/schema";
16
- import { StandardSchemaV1 } from "@standard-schema/spec";
17
-
18
16
  //#region src/worker.d.ts
19
-
20
- interface WorkerConfig {
17
+ export interface WorkerConfig {
21
18
  /**
22
19
  * The logger everything built from this worker runs with.
23
20
  *
@@ -35,7 +32,7 @@ interface WorkerConfig {
35
32
  */
36
33
  envParser?: EnvironmentParser<{}>;
37
34
  }
38
- declare class Worker<TName extends string = string> implements Declarable<TName> {
35
+ export declare class Worker<TName extends string = string, TDatabase = undefined, TDatabaseServiceName extends string = string> implements Declarable<TName> {
39
36
  private readonly config;
40
37
  /** Internal: how `.calls()` carries edges into the copy it returns. */
41
38
  private readonly dependencies;
@@ -46,13 +43,18 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
46
43
  readonly envParser: EnvironmentParser<{}>;
47
44
  /**
48
45
  * Where this worker's schedules live, when it has crons and a server runs
49
- * them. `undefined` until `.database(…)` says.
46
+ * them — and the database everything built from it receives as `db`.
47
+ * `undefined` until `.database(…)` says.
50
48
  */
51
49
  readonly scheduleStore?: Consumable<string, unknown>;
52
- constructor(id: ConstructName<TName>, config?: WorkerConfig, /** Internal: how `.calls()` carries edges into the copy it returns. */
50
+ constructor(id: ConstructName<TName>, config?: WorkerConfig,
51
+ /** Internal: how `.calls()` carries edges into the copy it returns. */
53
52
  dependencies?: readonly Dependency[], scheduleStore?: Consumable<string, unknown>);
54
53
  /**
55
- * The database this worker keeps its schedules in.
54
+ * The database this worker keeps its schedules in, and the one everything
55
+ * built from it — crons, queues, subscribers, functions — receives as `db`.
56
+ * One of them that works against another database names it with its own
57
+ * `.database(other)`, which replaces this one for that runnable alone.
56
58
  *
57
59
  * Only a server target uses it. On AWS a cron is an EventBridge rule
58
60
  * invoking a Lambda and nothing here is consulted — but a server has nothing
@@ -69,35 +71,47 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
69
71
  * @example
70
72
  * ```ts
71
73
  * export const jobs = new Worker('Jobs', { logger }).database(database);
74
+ *
75
+ * export const sweep = jobs
76
+ * .cron('rate(1 hour)')
77
+ * .handle(async ({ db }) => db.deleteFrom('sessions').execute());
72
78
  * ```
73
79
  */
74
- database<T, TDbName extends string>(source: Consumable<TDbName, T>): Worker<TName>;
80
+ database<T, TDbName extends string>(source: Consumable<TDbName, T>): Worker<TName, T, TDbName>;
75
81
  /**
76
82
  * A scheduled runnable.
77
83
  *
78
84
  * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
79
85
  */
80
- cron(schedule: ScheduleExpression): CronBuilder<ComposableStandardSchema, Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
86
+ cron(schedule: ScheduleExpression): CronBuilder<ComposableStandardSchema, Service[], Logger, undefined, TDatabase, TDatabaseServiceName>;
81
87
  /**
82
- * A runnable that consumes a topic.
88
+ * A queue and its one consumer, run by this worker.
83
89
  *
84
- * Binding is not publishing: a consumer is handed the topic's event types
85
- * and no connection string it could publish with. Chain `.publishes(…)` when
86
- * the handler emits follow-up events, which is the only reason it would need
87
- * one.
90
+ * One construct, because a queue has exactly one consumer: nothing else can
91
+ * attach a second, or forget to attach the first. Producers send to it by
92
+ * depending on it — `.dependsOn([emails])` makes `services.emails` the
93
+ * publisher.
88
94
  *
89
- * @example `worker.topic(users).subscribe(['user.created']).handle(…)`
95
+ * @example
96
+ * ```ts
97
+ * export const emails = worker
98
+ * .queue('Emails')
99
+ * .message(z.object({ userId: z.uuid(), template: z.string() }))
100
+ * .handle(async ({ messages, services }) => { … });
101
+ * ```
90
102
  */
91
- topic<TTopicName extends string, TEvents extends TopicEvents>(topic: Topic<TTopicName, TEvents>): SubscriberBuilder<[], Logger, undefined, EventPublisher<TopicMessage<TEvents_1>>, string, []>;
103
+ queue<TQueueName extends string>(name: TQueueName): QueueBuilder<TQueueName, undefined, [], Logger, TDatabase, TDatabaseServiceName>;
92
104
  /**
93
- * A runnable that consumes events typed from a publisher service.
105
+ * A runnable that consumes a topic.
106
+ *
107
+ * Binding is not publishing: a consumer is handed the topic's event types
108
+ * and no connection string it could publish with. A handler that emits
109
+ * follow-up events depends on the topic it emits to —
110
+ * `.dependsOn([orders])` — which is the only reason it would need one.
94
111
  *
95
- * The older of the two ways to bind a subscriber, kept for a project whose
96
- * events come from a hand-written publisher rather than a `Topic`
97
- * construct. `topic()` is the one to reach for: it types the events the same
98
- * way and hands the consumer no connection string it could publish with.
112
+ * @example `worker.topic(users).subscribe(['user.created']).handle(…)`
99
113
  */
100
- publisher<T extends EventPublisher<any>, TPubName extends string>(service: Service<TPubName, T> | Consumable<TPubName, T>): SubscriberBuilder<[], Logger, undefined, EventPublisher<any>, string, []>;
114
+ topic<TTopicName extends string, TEvents extends TopicEvents>(topic: Topic<TTopicName, TEvents>): SubscriberBuilder<[], Logger, undefined, EventPublisher<TopicMessage<TEvents_1>>, [], TDatabase, TDatabaseServiceName>;
101
115
  /**
102
116
  * Everything below builds a function — the runnable with no schedule and no
103
117
  * topic, invoked by something else.
@@ -109,18 +123,18 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
109
123
  * makes a cron, a topic makes a subscriber, and anything else makes a
110
124
  * function.
111
125
  */
112
- input<T extends ComposableStandardSchema>(schema: T): FunctionBuilder<T, undefined, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
113
- output<T extends StandardSchemaV1>(schema: T): FunctionBuilder<ComposableStandardSchema, T, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
114
- timeout(ms: number): FunctionBuilder<ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
115
- memorySize(mb: number): FunctionBuilder<ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
116
- dependsOn<const T extends readonly Consumable[]>(constructs: T): FunctionBuilder<ComposableStandardSchema, undefined, [...ServicesOf<T>], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
117
- services<T extends Service[]>(services: T): FunctionBuilder<ComposableStandardSchema, undefined, [...T], Logger, undefined, string, undefined, string, undefined, string, AuditableAction<string, unknown>>;
126
+ input<T extends ComposableStandardSchema>(schema: T): FunctionBuilder<T, undefined, [], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
127
+ output<T extends StandardSchemaV1>(schema: T): FunctionBuilder<any, T, [], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
128
+ timeout(ms: number): FunctionBuilder<any, undefined, [], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
129
+ memorySize(mb: number): FunctionBuilder<any, undefined, [], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
130
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): FunctionBuilder<any, undefined, [...ServicesOf<T>], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
131
+ services<T extends Service[]>(services: T): FunctionBuilder<any, undefined, [...T], Logger, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>>;
118
132
  /**
119
133
  * A function with no input schema — the shortest runnable there is.
120
134
  *
121
135
  * @example `worker.handle(async ({ logger }) => { … })`
122
136
  */
123
- 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>>>;
137
+ handle(...args: Parameters<ReturnType<Worker<TName, TDatabase, TDatabaseServiceName>['schemalessFunction']>['handle']>): Function<any, [], Logger, undefined, undefined, string, TDatabase, TDatabaseServiceName, AuditableAction<string, unknown>, FunctionHandler<any, [], Logger, undefined, TDatabase, undefined, AuditableAction<string, unknown>>>;
124
138
  /** The builder `handle` delegates to, named so its type can be referred to. */
125
139
  private schemalessFunction;
126
140
  /** The function builder the delegating methods above are built on. */
@@ -131,15 +145,20 @@ declare class Worker<TName extends string = string> implements Declarable<TName>
131
145
  * Not `.dependsOn()`: this records the edge that derives the worker's
132
146
  * environment and its access, the same distinction `RestApi.calls()` draws.
133
147
  */
134
- calls(constructs: readonly Declarable[]): Worker<TName>;
148
+ calls(constructs: readonly Declarable[]): Worker<TName, TDatabase, TDatabaseServiceName>;
135
149
  /**
136
150
  * Stamps this worker's id onto a builder, so everything built from it says
137
- * which process runs it.
151
+ * which process runs it — and hands it the worker's database.
152
+ *
153
+ * The database goes through the builder's own `.database()` rather than
154
+ * being written into its fields, so the default is recorded exactly as an
155
+ * explicit one would be: the client the handler gets, and the edge the
156
+ * manifest reads. That is also what lets a later `.database(other)` replace
157
+ * it outright. The builder arrives already typed with this worker's
158
+ * database; this is the runtime half of that.
138
159
  */
139
160
  private own;
140
161
  declare(): Declaration[];
141
162
  }
142
- //# sourceMappingURL=worker.d.ts.map
143
163
  //#endregion
144
- export { Worker, WorkerConfig };
145
164
  //# sourceMappingURL=worker.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.mts","names":[],"sources":["../src/worker.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;AA2NoD,UA1InC,YAAA,CA0ImC;EAAA;;;;;;;;EAIP,MAI1B,CAAA,EAzIT,MAyIS;EAAA;;;;;;EAIG,SAAA,CAAA,EAtIT,iBAsIS,CAAA,CAAA,CAAA,CAAA;;AAIwC,cAvIjD,MAuIiD,CAAA,cAAA,MAAA,GAAA,MAAA,CAAA,YAtIlD,UAsIkD,CAtIvC,KAsIuC,CAAA,CAAA;EAAC,iBAAA,MAAA;EAAA;EAAA,iBAAA,YAAA;EAAA,SAAA,EAAA,EApIjD,KAoIiD;EAAA;EAAA,SAAA,MAAA,EAjI7C,MAiI6C;EAAA;EAIpC,SAAc,SAAA,EAlIpB,iBAkIoB,CAAA,CAAA,CAAA,CAAA;EAAC;;;;EAAA,SAAA,aAAA,CAAA,EA5HhB,UA4HgB,CAAA,MAAA,EAAA,OAAA,CAAA;EAAA,WAWrB,CAAA,EAAA,EApIf,aAoIe,CApID,KAoIC,CAAA,EAAA,MAAA,CAAA,EAnIM,YAmIN,EAAK;EAAN,YAAjB,CAAA,EAAA,SAjIuC,UAiIvC,EAAA,EAAA,aAAA,CAAA,EAhIe,UAgIf,CAAA,MAAA,EAAA,OAAA,CAAA;EAAU;;;;;;;;;;;;;;AArJS;;;;;;8CAwDZ,WAAW,SAAS,KAC1B,OAAO;;;;;;iBAcK,qBAAkB,YAAA,0BAAA,4BAAA;;;;;;;;;;;mDAcgB,oBACzC,MAAM,YAAY,WAAQ,sBAAA,mBAAA,eAAA,aAAA;;;;;;;;;sBAad,uDACV,QAAQ,UAAU,KAAK,WAAW,UAAU,KAAE,sBAAA,mBAAA;;;;;;;;;;;;kBAkBxC,kCAAkC,IAAC,gBAAA,kBAAA,iEAAA;mBAIlC,0BAA0B,IAAC,gBAAA,0BAAA,OAAA,iEAAA;uBAI1B,gBAAA,yCAAA,iEAAA;0BAIG,gBAAA,yCAAA,iEAAA;qCAIc,0BAA0B,IAAC,gBAAA,yCAAA,WAAA,KAAA,iEAAA;qBAI3C,qBAAqB,IAAC,gBAAA,yCAAA,IAAA,iEAAA;;;;;;kBAU/B,WACR,WAAW,OAAO,2CAClB,SAAA,8BAAA,4EAAA,kCAAA,gBAAA,8BAAA,yCAAA;;;;;;;;;;;6BAqByB,eAAe,OAAO;;;;;;aAsBtC"}
1
+ {"version":3,"file":"worker.d.mts","names":["_$__topic0.TopicMessage","_$__construct_interface0.ServicesOf","_$__functions0.FunctionHandler","_$__functions0.Function"],"sources":["../src/worker.ts"],"mappings":";;;;;;;;;;;;;;;;iBAkGiB;;;;;;;;;EAShB,SAAS;;;;;;;EAOT,YAAY;;qBAGA,OACZ,+BACA,uBACA,yDACY,WAAW;mBAmBL;;mBAEA;WAnBT,IAAI;;WAGJ,QAAQ;;WAGR,WAAW;;;;;;WAOX,gBAAgB;EAEzB,YACC,IAAI,cAAc,QACD,SAAQ,cAER;;EAAA,wBAAuB,cACxC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCjB,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAC1B,OAAO,OAAO,GAAG;;;;;;EAcpB,KAAK,UAAU,qBAAkB,YAAA,0BAAA,WAAA,mBAAA,WAAA;;;;;;;;;;;;;;;;;EA6BjC,MAAM,2BAA2B,MAAM,aAAU,aAAA,2BAAA,QAAA,WAAA;;;;;;;;;;;EAuBjD,MAAM,2BAA2B,gBAAgB,aAChD,OAAO,MAAM,YAAY,WAAQ,sBAAA,mBAAA,eAAAA,aAAA,iBAAA,WAAA;;;;;;;;;;;;EA0BlC,MAAM,UAAU,0BAA0B,QAAQ,IAAC,gBAAA,kBAAA,2BAAA,WAAA,sBAAA;EAInD,OAAO,UAAU,kBAAkB,QAAQ,IAAC,qBAAA,OAAA,2BAAA,WAAA,sBAAA;EAI5C,QAAQ,aAAU,oCAAA,2BAAA,WAAA,sBAAA;EAIlB,WAAW,aAAU,oCAAA,2BAAA,WAAA,sBAAA;EAIrB,gBAAgB,mBAAmB,cAAc,YAAY,IAAC,oCAAAC,WAAA,KAAA,2BAAA,WAAA,sBAAA;EAI9D,SAAS,UAAU,WAAW,UAAU,IAAC,oCAAA,IAAA,2BAAA,WAAA,sBAAA;;;;;;EASzC,UACI,MAAM,WACR,WACC,OAAO,OAAO,WAAW,0DAE1BE,kBAAA,sCAAA,WAAA,sBAAA,kCAAAD,yBAAA,mBAAA,sBAAA;;UAMM;;cAKI;;;;;;;EAqBZ,MACC,qBAAqB,eACnB,OAAO,OAAO,WAAW;;;;;;;;;;;;UAoBpB;EAiBR,WAAW"}
package/dist/worker.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import "./Construct-BD5neF7w.mjs";
2
- import { edgeTo } from "./construct-interface-Z4CpS8tK.mjs";
3
- import { FunctionBuilder } from "./functions-14lpEFL4.mjs";
4
- import "./clone-DblgEZZa.mjs";
5
- import { envParserFor } from "./surfaceEnv-C3Ktahea.mjs";
6
- import { CronBuilder } from "./CronBuilder-CYKT5RiO.mjs";
7
- import { SubscriberBuilder } from "./SubscriberBuilder-BjkbeT9l.mjs";
1
+ import { edgeTo } from "./construct-interface.mjs";
2
+ import { t as FunctionBuilder } from "./functions-Di6n5ltG.mjs";
3
+ import { n as envParserFor } from "./surfaceEnv-wMT5QzgZ.mjs";
4
+ import { t as CronBuilder } from "./CronBuilder-CCgt0wCE.mjs";
5
+ import { t as QueueBuilder } from "./QueueBuilder-DCuYdjMw.mjs";
6
+ import { t as SubscriberBuilder } from "./SubscriberBuilder-DMFk_Ap1.mjs";
8
7
  import { canonicalId } from "@geekmidas/manifest";
9
8
  import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
10
-
11
9
  //#region src/worker.ts
12
10
  var Worker = class Worker {
11
+ config;
12
+ dependencies;
13
13
  id;
14
14
  /** Always defined — the worker's own, or the console logger. */
15
15
  logger;
@@ -17,7 +17,8 @@ var Worker = class Worker {
17
17
  envParser;
18
18
  /**
19
19
  * Where this worker's schedules live, when it has crons and a server runs
20
- * them. `undefined` until `.database(…)` says.
20
+ * them — and the database everything built from it receives as `db`.
21
+ * `undefined` until `.database(…)` says.
21
22
  */
22
23
  scheduleStore;
23
24
  constructor(id, config = {}, dependencies = [], scheduleStore) {
@@ -33,7 +34,10 @@ var Worker = class Worker {
33
34
  this.scheduleStore = scheduleStore;
34
35
  }
35
36
  /**
36
- * The database this worker keeps its schedules in.
37
+ * The database this worker keeps its schedules in, and the one everything
38
+ * built from it — crons, queues, subscribers, functions — receives as `db`.
39
+ * One of them that works against another database names it with its own
40
+ * `.database(other)`, which replaces this one for that runnable alone.
37
41
  *
38
42
  * Only a server target uses it. On AWS a cron is an EventBridge rule
39
43
  * invoking a Lambda and nothing here is consulted — but a server has nothing
@@ -50,6 +54,10 @@ var Worker = class Worker {
50
54
  * @example
51
55
  * ```ts
52
56
  * export const jobs = new Worker('Jobs', { logger }).database(database);
57
+ *
58
+ * export const sweep = jobs
59
+ * .cron('rate(1 hour)')
60
+ * .handle(async ({ db }) => db.deleteFrom('sessions').execute());
53
61
  * ```
54
62
  */
55
63
  database(source) {
@@ -64,12 +72,31 @@ var Worker = class Worker {
64
72
  return this.own(new CronBuilder().logger(this.logger)).schedule(schedule);
65
73
  }
66
74
  /**
75
+ * A queue and its one consumer, run by this worker.
76
+ *
77
+ * One construct, because a queue has exactly one consumer: nothing else can
78
+ * attach a second, or forget to attach the first. Producers send to it by
79
+ * depending on it — `.dependsOn([emails])` makes `services.emails` the
80
+ * publisher.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * export const emails = worker
85
+ * .queue('Emails')
86
+ * .message(z.object({ userId: z.uuid(), template: z.string() }))
87
+ * .handle(async ({ messages, services }) => { … });
88
+ * ```
89
+ */
90
+ queue(name) {
91
+ return this.own(new QueueBuilder().logger(this.logger)).queue(name);
92
+ }
93
+ /**
67
94
  * A runnable that consumes a topic.
68
95
  *
69
96
  * 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.
97
+ * and no connection string it could publish with. A handler that emits
98
+ * follow-up events depends on the topic it emits to —
99
+ * `.dependsOn([orders])` — which is the only reason it would need one.
73
100
  *
74
101
  * @example `worker.topic(users).subscribe(['user.created']).handle(…)`
75
102
  */
@@ -77,17 +104,6 @@ var Worker = class Worker {
77
104
  return this.own(new SubscriberBuilder().logger(this.logger)).topic(topic);
78
105
  }
79
106
  /**
80
- * A runnable that consumes events typed from a publisher service.
81
- *
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.
86
- */
87
- publisher(service) {
88
- return this.own(new SubscriberBuilder().logger(this.logger)).publisher(service);
89
- }
90
- /**
91
107
  * Everything below builds a function — the runnable with no schedule and no
92
108
  * topic, invoked by something else.
93
109
  *
@@ -143,12 +159,20 @@ var Worker = class Worker {
143
159
  }
144
160
  /**
145
161
  * Stamps this worker's id onto a builder, so everything built from it says
146
- * which process runs it.
162
+ * which process runs it — and hands it the worker's database.
163
+ *
164
+ * The database goes through the builder's own `.database()` rather than
165
+ * being written into its fields, so the default is recorded exactly as an
166
+ * explicit one would be: the client the handler gets, and the edge the
167
+ * manifest reads. That is also what lets a later `.database(other)` replace
168
+ * it outright. The builder arrives already typed with this worker's
169
+ * database; this is the runtime half of that.
147
170
  */
148
171
  own(builder) {
149
- builder._owner = this.id;
150
- builder._scheduleStore = this.scheduleStore;
151
- return builder;
172
+ const owned = this.scheduleStore ? builder.database(this.scheduleStore) : builder;
173
+ owned._owner = this.id;
174
+ owned._scheduleStore = this.scheduleStore;
175
+ return owned;
152
176
  }
153
177
  declare() {
154
178
  return [{
@@ -159,7 +183,7 @@ var Worker = class Worker {
159
183
  }];
160
184
  }
161
185
  };
162
-
163
186
  //#endregion
164
187
  export { Worker };
188
+
165
189
  //# sourceMappingURL=worker.mjs.map