gemi 0.116.0 → 0.118.0

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 (355) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/app/index.js +2 -2
  4. package/dist/app/index.js.map +1 -1
  5. package/dist/auth/AuthServiceProvider.d.ts.map +1 -1
  6. package/dist/auth/config.d.ts +27 -0
  7. package/dist/auth/config.d.ts.map +1 -1
  8. package/dist/auth/connections/ConnectionManager.d.ts +133 -0
  9. package/dist/auth/connections/ConnectionManager.d.ts.map +1 -0
  10. package/dist/auth/connections/ConnectionStore.d.ts +146 -0
  11. package/dist/auth/connections/ConnectionStore.d.ts.map +1 -0
  12. package/dist/auth/connections/ConnectionsController.d.ts +23 -0
  13. package/dist/auth/connections/ConnectionsController.d.ts.map +1 -0
  14. package/dist/auth/connections/OAuthConnectionProvider.d.ts +105 -0
  15. package/dist/auth/connections/OAuthConnectionProvider.d.ts.map +1 -0
  16. package/dist/auth/connections/errors.d.ts +32 -0
  17. package/dist/auth/connections/errors.d.ts.map +1 -0
  18. package/dist/auth/oauth/oauthState.d.ts +15 -2
  19. package/dist/auth/oauth/oauthState.d.ts.map +1 -1
  20. package/dist/auth/routes.d.ts +13 -0
  21. package/dist/auth/routes.d.ts.map +1 -1
  22. package/dist/bin/orm/emit.d.ts.map +1 -1
  23. package/dist/bin/orm-generator.js +51 -4
  24. package/dist/bin/orm-generator.js.map +4 -4
  25. package/dist/bun/plugin.js +2 -2
  26. package/dist/bun/plugin.js.map +1 -1
  27. package/dist/bun/preload.js +2 -2
  28. package/dist/bun/preload.js.map +1 -1
  29. package/dist/{chunk-2tzm58j3.js → chunk-01ehxca0.js} +2 -2
  30. package/dist/{chunk-2tzm58j3.js.map → chunk-01ehxca0.js.map} +1 -1
  31. package/dist/chunk-0gtyects.js +10 -0
  32. package/dist/{chunk-yf1njzd5.js.map → chunk-0gtyects.js.map} +6 -5
  33. package/dist/{chunk-15c2vgaf.js → chunk-1m3hvy3q.js} +2 -2
  34. package/dist/{chunk-15c2vgaf.js.map → chunk-1m3hvy3q.js.map} +1 -1
  35. package/dist/{chunk-6cx8ncd4.js → chunk-1z1rj2zq.js} +3 -3
  36. package/dist/{chunk-6cx8ncd4.js.map → chunk-1z1rj2zq.js.map} +1 -1
  37. package/dist/{chunk-5stgtwqw.js → chunk-2bja99cq.js} +2 -2
  38. package/dist/{chunk-5stgtwqw.js.map → chunk-2bja99cq.js.map} +1 -1
  39. package/dist/{chunk-n672d4g8.js → chunk-30xxc6r7.js} +2 -2
  40. package/dist/{chunk-n672d4g8.js.map → chunk-30xxc6r7.js.map} +1 -1
  41. package/dist/{chunk-qjhw8nje.js → chunk-33s2xqv1.js} +1 -1
  42. package/dist/{chunk-4088szy9.js → chunk-39kyz4k6.js} +3 -3
  43. package/dist/{chunk-4088szy9.js.map → chunk-39kyz4k6.js.map} +1 -1
  44. package/dist/chunk-3nf95j9e.js +5 -0
  45. package/dist/{chunk-1q9kd20m.js.map → chunk-3nf95j9e.js.map} +1 -1
  46. package/dist/chunk-3zxfd7pn.js +14 -0
  47. package/dist/{chunk-pn8v6fj2.js.map → chunk-3zxfd7pn.js.map} +11 -6
  48. package/dist/{chunk-pyk3gzvc.js → chunk-453rmkpm.js} +2 -2
  49. package/dist/{chunk-pyk3gzvc.js.map → chunk-453rmkpm.js.map} +1 -1
  50. package/dist/chunk-47h12eme.js +57 -0
  51. package/dist/{chunk-ms9k0rx6.js.map → chunk-47h12eme.js.map} +15 -11
  52. package/dist/chunk-490sbcma.js +5 -0
  53. package/dist/chunk-490sbcma.js.map +12 -0
  54. package/dist/{chunk-kqxdsv22.js → chunk-4c1kdd8p.js} +2 -2
  55. package/dist/{chunk-kqxdsv22.js.map → chunk-4c1kdd8p.js.map} +1 -1
  56. package/dist/{chunk-jdhdrr2k.js → chunk-5cgq9c43.js} +2 -2
  57. package/dist/{chunk-jdhdrr2k.js.map → chunk-5cgq9c43.js.map} +1 -1
  58. package/dist/{chunk-9n1hx3mq.js → chunk-5dbpgyrx.js} +3 -3
  59. package/dist/{chunk-9n1hx3mq.js.map → chunk-5dbpgyrx.js.map} +1 -1
  60. package/dist/{chunk-eqse2m6n.js → chunk-5ses4tcz.js} +2 -2
  61. package/dist/{chunk-eqse2m6n.js.map → chunk-5ses4tcz.js.map} +1 -1
  62. package/dist/{chunk-2z1981d0.js → chunk-675kzd7z.js} +2 -2
  63. package/dist/{chunk-2z1981d0.js.map → chunk-675kzd7z.js.map} +1 -1
  64. package/dist/{chunk-p1aqq0ga.js → chunk-6ggmk2eg.js} +3 -3
  65. package/dist/{chunk-p1aqq0ga.js.map → chunk-6ggmk2eg.js.map} +1 -1
  66. package/dist/{chunk-mazznq15.js → chunk-76p0rf4d.js} +3 -3
  67. package/dist/{chunk-mazznq15.js.map → chunk-76p0rf4d.js.map} +1 -1
  68. package/dist/{chunk-41da9628.js → chunk-8t6dwwz6.js} +1 -1
  69. package/dist/{chunk-zyt2w03d.js → chunk-8wcpxm41.js} +2 -2
  70. package/dist/{chunk-zyt2w03d.js.map → chunk-8wcpxm41.js.map} +1 -1
  71. package/dist/chunk-9pkj7sk6.js +50 -0
  72. package/dist/chunk-9pkj7sk6.js.map +10 -0
  73. package/dist/{chunk-jmpw6bqz.js → chunk-a1qt8aky.js} +2 -2
  74. package/dist/{chunk-jmpw6bqz.js.map → chunk-a1qt8aky.js.map} +1 -1
  75. package/dist/{chunk-frerzsxq.js → chunk-a22h5cby.js} +2 -2
  76. package/dist/{chunk-frerzsxq.js.map → chunk-a22h5cby.js.map} +1 -1
  77. package/dist/{chunk-e573yxpq.js → chunk-aedkrck1.js} +3 -3
  78. package/dist/{chunk-e573yxpq.js.map → chunk-aedkrck1.js.map} +1 -1
  79. package/dist/{chunk-vxm6yevm.js → chunk-aqpaw4jq.js} +2 -2
  80. package/dist/{chunk-vxm6yevm.js.map → chunk-aqpaw4jq.js.map} +1 -1
  81. package/dist/{chunk-aeh67ynz.js → chunk-bgwtdbfw.js} +3 -3
  82. package/dist/{chunk-aeh67ynz.js.map → chunk-bgwtdbfw.js.map} +1 -1
  83. package/dist/{chunk-tw5kwbx4.js → chunk-bz8xssrc.js} +2 -2
  84. package/dist/{chunk-tw5kwbx4.js.map → chunk-bz8xssrc.js.map} +1 -1
  85. package/dist/{chunk-tzm3c7n6.js → chunk-cte6ysqd.js} +4 -4
  86. package/dist/{chunk-tzm3c7n6.js.map → chunk-cte6ysqd.js.map} +1 -1
  87. package/dist/{chunk-qsrcdzan.js → chunk-cvfg88cx.js} +3 -3
  88. package/dist/{chunk-qsrcdzan.js.map → chunk-cvfg88cx.js.map} +1 -1
  89. package/dist/{chunk-1vzks22y.js → chunk-d806cy7p.js} +2 -2
  90. package/dist/{chunk-1vzks22y.js.map → chunk-d806cy7p.js.map} +1 -1
  91. package/dist/{chunk-6chz1ktz.js → chunk-de4t48j9.js} +3 -3
  92. package/dist/{chunk-6chz1ktz.js.map → chunk-de4t48j9.js.map} +1 -1
  93. package/dist/{chunk-mqfzdfnz.js → chunk-dwpn6fze.js} +2 -2
  94. package/dist/{chunk-mqfzdfnz.js.map → chunk-dwpn6fze.js.map} +1 -1
  95. package/dist/{chunk-vbdty91k.js → chunk-ebret82e.js} +3 -3
  96. package/dist/{chunk-vbdty91k.js.map → chunk-ebret82e.js.map} +1 -1
  97. package/dist/chunk-eke2frrm.js +9 -0
  98. package/dist/{chunk-hytt9qyj.js.map → chunk-eke2frrm.js.map} +3 -4
  99. package/dist/{chunk-yer1r3t3.js → chunk-epvpmakp.js} +2 -2
  100. package/dist/{chunk-yer1r3t3.js.map → chunk-epvpmakp.js.map} +1 -1
  101. package/dist/{chunk-fxgxf16k.js → chunk-fsj5k511.js} +2 -2
  102. package/dist/{chunk-fxgxf16k.js.map → chunk-fsj5k511.js.map} +1 -1
  103. package/dist/{chunk-t4yh4nf9.js → chunk-g5ppst76.js} +3 -3
  104. package/dist/{chunk-t4yh4nf9.js.map → chunk-g5ppst76.js.map} +1 -1
  105. package/dist/{chunk-aazmrxj9.js → chunk-g9hhdcax.js} +2 -2
  106. package/dist/{chunk-aazmrxj9.js.map → chunk-g9hhdcax.js.map} +1 -1
  107. package/dist/{chunk-cbqazg9k.js → chunk-gqfqnv3f.js} +2 -2
  108. package/dist/{chunk-cbqazg9k.js.map → chunk-gqfqnv3f.js.map} +1 -1
  109. package/dist/chunk-hkf2k2eq.js +5 -0
  110. package/dist/{chunk-whtzggn6.js.map → chunk-hkf2k2eq.js.map} +3 -4
  111. package/dist/{chunk-vw8849ys.js → chunk-hm9cjxy2.js} +2 -2
  112. package/dist/{chunk-m54s6jpr.js.map → chunk-hm9cjxy2.js.map} +1 -1
  113. package/dist/{chunk-kejwjerj.js → chunk-hr1r3g0d.js} +2 -2
  114. package/dist/{chunk-kejwjerj.js.map → chunk-hr1r3g0d.js.map} +1 -1
  115. package/dist/{chunk-3hrj5rwm.js → chunk-hzepfrzy.js} +2 -2
  116. package/dist/{chunk-3hrj5rwm.js.map → chunk-hzepfrzy.js.map} +1 -1
  117. package/dist/{chunk-785b41h1.js → chunk-j5858bz7.js} +3 -3
  118. package/dist/{chunk-785b41h1.js.map → chunk-j5858bz7.js.map} +1 -1
  119. package/dist/{chunk-d9mar37g.js → chunk-jf6qqzat.js} +2 -2
  120. package/dist/{chunk-d9mar37g.js.map → chunk-jf6qqzat.js.map} +1 -1
  121. package/dist/{chunk-1hr4xht1.js → chunk-jg79n382.js} +2 -2
  122. package/dist/{chunk-1hr4xht1.js.map → chunk-jg79n382.js.map} +1 -1
  123. package/dist/chunk-k31qfe7a.js +71 -0
  124. package/dist/chunk-k31qfe7a.js.map +13 -0
  125. package/dist/{chunk-4mfrgd5m.js → chunk-kk77x2v4.js} +2 -2
  126. package/dist/{chunk-4mfrgd5m.js.map → chunk-kk77x2v4.js.map} +1 -1
  127. package/dist/{chunk-1myhm0g3.js → chunk-kkte8nze.js} +3 -3
  128. package/dist/{chunk-1myhm0g3.js.map → chunk-kkte8nze.js.map} +1 -1
  129. package/dist/{chunk-hdps9n52.js → chunk-m4kmetpb.js} +3 -3
  130. package/dist/{chunk-hdps9n52.js.map → chunk-m4kmetpb.js.map} +1 -1
  131. package/dist/{chunk-gts5p6mw.js → chunk-n4sdm0jn.js} +4 -4
  132. package/dist/{chunk-gts5p6mw.js.map → chunk-n4sdm0jn.js.map} +1 -1
  133. package/dist/chunk-nang3847.js +416 -0
  134. package/dist/chunk-nang3847.js.map +24 -0
  135. package/dist/{chunk-agyfv3f8.js → chunk-nrezmscd.js} +1 -1
  136. package/dist/{chunk-xt9tv99x.js → chunk-p83erprx.js} +2 -2
  137. package/dist/{chunk-xt9tv99x.js.map → chunk-p83erprx.js.map} +1 -1
  138. package/dist/{chunk-sr942vb1.js → chunk-pkr5dsbk.js} +2 -2
  139. package/dist/{chunk-sr942vb1.js.map → chunk-pkr5dsbk.js.map} +1 -1
  140. package/dist/{chunk-yhrye9cm.js → chunk-pqc16rrx.js} +2 -2
  141. package/dist/{chunk-yhrye9cm.js.map → chunk-pqc16rrx.js.map} +1 -1
  142. package/dist/{chunk-m54s6jpr.js → chunk-pvz90a49.js} +2 -2
  143. package/dist/{chunk-vw8849ys.js.map → chunk-pvz90a49.js.map} +1 -1
  144. package/dist/{chunk-fre6f4nk.js → chunk-q290tgza.js} +2 -2
  145. package/dist/{chunk-fre6f4nk.js.map → chunk-q290tgza.js.map} +1 -1
  146. package/dist/{chunk-8rv62v14.js → chunk-qf4bmee9.js} +2 -2
  147. package/dist/{chunk-8rv62v14.js.map → chunk-qf4bmee9.js.map} +1 -1
  148. package/dist/chunk-qkxnvpaj.js +5 -0
  149. package/dist/chunk-qkxnvpaj.js.map +10 -0
  150. package/dist/chunk-r1favzz4.js +19 -0
  151. package/dist/{chunk-ktr3k768.js.map → chunk-r1favzz4.js.map} +5 -4
  152. package/dist/{chunk-303mprnv.js → chunk-r3v2cnrj.js} +2 -2
  153. package/dist/{chunk-303mprnv.js.map → chunk-r3v2cnrj.js.map} +1 -1
  154. package/dist/{chunk-x7cpth2f.js → chunk-razjfecn.js} +1 -1
  155. package/dist/{chunk-t04f3akb.js → chunk-scc0j5k9.js} +2 -2
  156. package/dist/{chunk-t04f3akb.js.map → chunk-scc0j5k9.js.map} +1 -1
  157. package/dist/{chunk-56jky6vf.js → chunk-sce5jes2.js} +2 -2
  158. package/dist/{chunk-56jky6vf.js.map → chunk-sce5jes2.js.map} +1 -1
  159. package/dist/chunk-sd02ktf2.js +24 -0
  160. package/dist/{chunk-79xg42e7.js.map → chunk-sd02ktf2.js.map} +2 -2
  161. package/dist/{chunk-mschc94q.js → chunk-sn04cyw0.js} +2 -2
  162. package/dist/{chunk-mschc94q.js.map → chunk-sn04cyw0.js.map} +1 -1
  163. package/dist/{chunk-bra1a1fq.js → chunk-tfdmvxza.js} +2 -2
  164. package/dist/{chunk-bra1a1fq.js.map → chunk-tfdmvxza.js.map} +1 -1
  165. package/dist/{chunk-z10cas5r.js → chunk-thz75w6e.js} +2 -2
  166. package/dist/{chunk-z10cas5r.js.map → chunk-thz75w6e.js.map} +1 -1
  167. package/dist/{chunk-v1tfdgy1.js → chunk-tzdenj0n.js} +3 -3
  168. package/dist/{chunk-v1tfdgy1.js.map → chunk-tzdenj0n.js.map} +1 -1
  169. package/dist/{chunk-98m15b9x.js → chunk-x6v2zex2.js} +2 -2
  170. package/dist/{chunk-98m15b9x.js.map → chunk-x6v2zex2.js.map} +1 -1
  171. package/dist/{chunk-d2gfcf85.js → chunk-xfw8zyvn.js} +2 -2
  172. package/dist/{chunk-d2gfcf85.js.map → chunk-xfw8zyvn.js.map} +1 -1
  173. package/dist/{chunk-wyw6p3fg.js → chunk-xtzn0qfh.js} +3 -3
  174. package/dist/{chunk-wyw6p3fg.js.map → chunk-xtzn0qfh.js.map} +1 -1
  175. package/dist/{chunk-tn2bryy2.js → chunk-xx3zvc3g.js} +2 -2
  176. package/dist/{chunk-tn2bryy2.js.map → chunk-xx3zvc3g.js.map} +1 -1
  177. package/dist/{chunk-er3wf6ng.js → chunk-xzn2nmny.js} +2 -2
  178. package/dist/{chunk-er3wf6ng.js.map → chunk-xzn2nmny.js.map} +1 -1
  179. package/dist/{chunk-p91b8zcn.js → chunk-xzyy896s.js} +2 -2
  180. package/dist/{chunk-p91b8zcn.js.map → chunk-xzyy896s.js.map} +1 -1
  181. package/dist/chunk-y09r0wsw.js +5 -0
  182. package/dist/chunk-y09r0wsw.js.map +12 -0
  183. package/dist/{chunk-6d8rvr1v.js → chunk-ygf0z7kk.js} +2 -2
  184. package/dist/{chunk-6d8rvr1v.js.map → chunk-ygf0z7kk.js.map} +1 -1
  185. package/dist/chunk-z759yah5.js +5 -0
  186. package/dist/chunk-z759yah5.js.map +12 -0
  187. package/dist/client/Head.d.ts.map +1 -1
  188. package/dist/client/fonts.d.ts +69 -0
  189. package/dist/client/fonts.d.ts.map +1 -0
  190. package/dist/client/index.d.ts +1 -0
  191. package/dist/client/index.d.ts.map +1 -1
  192. package/dist/client/index.js +75 -1
  193. package/dist/client/index.js.map +1 -1
  194. package/dist/config/index.js +1 -1
  195. package/dist/console/builtins.d.ts +13 -0
  196. package/dist/console/builtins.d.ts.map +1 -0
  197. package/dist/console/run.js +13 -11
  198. package/dist/console/run.js.map +6 -5
  199. package/dist/console/runner.d.ts.map +1 -1
  200. package/dist/console/usage.d.ts +2 -0
  201. package/dist/console/usage.d.ts.map +1 -1
  202. package/dist/container/index.js +2 -2
  203. package/dist/container/index.js.map +1 -1
  204. package/dist/database/index.js +2 -2
  205. package/dist/database/index.js.map +1 -1
  206. package/dist/email/index.js +2 -2
  207. package/dist/email/index.js.map +1 -1
  208. package/dist/facades/Connections.d.ts +36 -0
  209. package/dist/facades/Connections.d.ts.map +1 -0
  210. package/dist/facades/Crypt.d.ts +26 -0
  211. package/dist/facades/Crypt.d.ts.map +1 -0
  212. package/dist/facades/Meta.d.ts +7 -1
  213. package/dist/facades/Meta.d.ts.map +1 -1
  214. package/dist/facades/Storage.d.ts +29 -0
  215. package/dist/facades/Storage.d.ts.map +1 -1
  216. package/dist/facades/index.d.ts +2 -0
  217. package/dist/facades/index.d.ts.map +1 -1
  218. package/dist/facades/index.js +2 -2
  219. package/dist/facades/index.js.map +1 -1
  220. package/dist/foundation/index.js +2 -2
  221. package/dist/foundation/index.js.map +1 -1
  222. package/dist/http/HttpRequest.d.ts +1 -0
  223. package/dist/http/HttpRequest.d.ts.map +1 -1
  224. package/dist/http/Metadata.d.ts +5 -0
  225. package/dist/http/Metadata.d.ts.map +1 -1
  226. package/dist/http/index.d.ts +3 -1
  227. package/dist/http/index.d.ts.map +1 -1
  228. package/dist/http/index.js +2 -2
  229. package/dist/http/index.js.map +1 -1
  230. package/dist/http/requestContext.d.ts +1 -0
  231. package/dist/http/requestContext.d.ts.map +1 -1
  232. package/dist/http/safeFetch/errors.d.ts +10 -0
  233. package/dist/http/safeFetch/errors.d.ts.map +1 -1
  234. package/dist/http/safeFetch/index.d.ts +1 -1
  235. package/dist/http/safeFetch/index.d.ts.map +1 -1
  236. package/dist/http/sitemap/Robots.d.ts +95 -0
  237. package/dist/http/sitemap/Robots.d.ts.map +1 -0
  238. package/dist/http/sitemap/Sitemap.d.ts +145 -0
  239. package/dist/http/sitemap/Sitemap.d.ts.map +1 -0
  240. package/dist/http/sitemap/fetchText.d.ts +16 -0
  241. package/dist/http/sitemap/fetchText.d.ts.map +1 -0
  242. package/dist/http/sitemap/index.d.ts +3 -0
  243. package/dist/http/sitemap/index.d.ts.map +1 -0
  244. package/dist/http/sitemap/xml.d.ts +21 -0
  245. package/dist/http/sitemap/xml.d.ts.map +1 -0
  246. package/dist/i18n/Translator.d.ts.map +1 -1
  247. package/dist/i18n/dictionaryRuntime.js +2 -2
  248. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  249. package/dist/i18n/index.d.ts +1 -1
  250. package/dist/i18n/index.d.ts.map +1 -1
  251. package/dist/i18n/index.js +2 -2
  252. package/dist/i18n/index.js.map +2 -2
  253. package/dist/i18n/resolveLocale.d.ts +18 -0
  254. package/dist/i18n/resolveLocale.d.ts.map +1 -1
  255. package/dist/kernel/index.js +3 -3
  256. package/dist/kernel/index.js.map +3 -3
  257. package/dist/kernel/providers.d.ts +2 -2
  258. package/dist/kernel/providers.d.ts.map +1 -1
  259. package/dist/orm/Model.d.ts.map +1 -1
  260. package/dist/orm/encryption-rotate.d.ts +44 -0
  261. package/dist/orm/encryption-rotate.d.ts.map +1 -0
  262. package/dist/orm/encryption.d.ts +54 -0
  263. package/dist/orm/encryption.d.ts.map +1 -0
  264. package/dist/orm/index.d.ts +2 -0
  265. package/dist/orm/index.d.ts.map +1 -1
  266. package/dist/orm/index.js +3 -3
  267. package/dist/orm/index.js.map +4 -4
  268. package/dist/orm/schema.d.ts +25 -1
  269. package/dist/orm/schema.d.ts.map +1 -1
  270. package/dist/server/index.js +2 -2
  271. package/dist/server/index.js.map +1 -1
  272. package/dist/services/discovery.d.ts +8 -0
  273. package/dist/services/discovery.d.ts.map +1 -1
  274. package/dist/services/encryption/Encrypter.d.ts +86 -0
  275. package/dist/services/encryption/Encrypter.d.ts.map +1 -0
  276. package/dist/services/encryption/EncryptionServiceProvider.d.ts +13 -0
  277. package/dist/services/encryption/EncryptionServiceProvider.d.ts.map +1 -0
  278. package/dist/services/encryption/config.d.ts +36 -0
  279. package/dist/services/encryption/config.d.ts.map +1 -0
  280. package/dist/services/file-storage/drivers/FileStorageDriver.d.ts +12 -1
  281. package/dist/services/file-storage/drivers/FileStorageDriver.d.ts.map +1 -1
  282. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts +8 -1
  283. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts.map +1 -1
  284. package/dist/services/file-storage/drivers/types.d.ts +17 -0
  285. package/dist/services/file-storage/drivers/types.d.ts.map +1 -1
  286. package/dist/services/file-storage/putFromUrl.d.ts +56 -0
  287. package/dist/services/file-storage/putFromUrl.d.ts.map +1 -0
  288. package/dist/services/file-storage/sniffContentType.d.ts +33 -0
  289. package/dist/services/file-storage/sniffContentType.d.ts.map +1 -0
  290. package/dist/services/index.d.ts +26 -5
  291. package/dist/services/index.d.ts.map +1 -1
  292. package/dist/services/index.js +10 -10
  293. package/dist/services/index.js.map +4 -3
  294. package/dist/services/queue/DatabaseQueueDriver.d.ts +117 -7
  295. package/dist/services/queue/DatabaseQueueDriver.d.ts.map +1 -1
  296. package/dist/services/queue/Job.d.ts +75 -0
  297. package/dist/services/queue/Job.d.ts.map +1 -1
  298. package/dist/services/queue/MemoryQueueDriver.d.ts +32 -2
  299. package/dist/services/queue/MemoryQueueDriver.d.ts.map +1 -1
  300. package/dist/services/queue/QueueDriver.d.ts +83 -1
  301. package/dist/services/queue/QueueDriver.d.ts.map +1 -1
  302. package/dist/services/queue/QueueManager.d.ts +80 -7
  303. package/dist/services/queue/QueueManager.d.ts.map +1 -1
  304. package/dist/services/queue/QueueServiceProvider.d.ts.map +1 -1
  305. package/dist/services/queue/backoff.d.ts +6 -0
  306. package/dist/services/queue/backoff.d.ts.map +1 -0
  307. package/dist/services/queue/batch.d.ts +112 -0
  308. package/dist/services/queue/batch.d.ts.map +1 -0
  309. package/dist/services/queue/config.d.ts +9 -0
  310. package/dist/services/queue/config.d.ts.map +1 -1
  311. package/dist/services/queue/queueDriverContract.d.ts +5 -0
  312. package/dist/services/queue/queueDriverContract.d.ts.map +1 -1
  313. package/dist/services/queue/work.js +2 -2
  314. package/dist/services/queue/work.js.map +1 -1
  315. package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts +89 -0
  316. package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts.map +1 -0
  317. package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts +43 -0
  318. package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts.map +1 -0
  319. package/dist/services/queue/workflow/Step.d.ts +202 -0
  320. package/dist/services/queue/workflow/Step.d.ts.map +1 -0
  321. package/dist/services/queue/workflow/Workflow.d.ts +124 -0
  322. package/dist/services/queue/workflow/Workflow.d.ts.map +1 -0
  323. package/dist/services/queue/workflow/WorkflowRuntime.d.ts +60 -0
  324. package/dist/services/queue/workflow/WorkflowRuntime.d.ts.map +1 -0
  325. package/dist/services/queue/workflow/WorkflowStore.d.ts +184 -0
  326. package/dist/services/queue/workflow/WorkflowStore.d.ts.map +1 -0
  327. package/dist/services/queue/workflow/duration.d.ts +8 -0
  328. package/dist/services/queue/workflow/duration.d.ts.map +1 -0
  329. package/dist/services/queue/workflow/workflowContract.d.ts +30 -0
  330. package/dist/services/queue/workflow/workflowContract.d.ts.map +1 -0
  331. package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
  332. package/dist/stats/route-table.js +1 -1
  333. package/dist/support/index.js +2 -2
  334. package/dist/support/index.js.map +1 -1
  335. package/dist/vitest/index.js +2 -2
  336. package/dist/vitest/index.js.map +1 -1
  337. package/package.json +1 -1
  338. package/dist/chunk-1q9kd20m.js +0 -5
  339. package/dist/chunk-49nyyjfe.js +0 -5
  340. package/dist/chunk-49nyyjfe.js.map +0 -11
  341. package/dist/chunk-79xg42e7.js +0 -24
  342. package/dist/chunk-7vb4eey2.js +0 -217
  343. package/dist/chunk-7vb4eey2.js.map +0 -16
  344. package/dist/chunk-hytt9qyj.js +0 -54
  345. package/dist/chunk-jmg2zsaf.js +0 -5
  346. package/dist/chunk-jmg2zsaf.js.map +0 -12
  347. package/dist/chunk-ktr3k768.js +0 -19
  348. package/dist/chunk-ms9k0rx6.js +0 -46
  349. package/dist/chunk-pn8v6fj2.js +0 -14
  350. package/dist/chunk-whtzggn6.js +0 -5
  351. package/dist/chunk-yf1njzd5.js +0 -10
  352. /package/dist/{chunk-qjhw8nje.js.map → chunk-33s2xqv1.js.map} +0 -0
  353. /package/dist/{chunk-41da9628.js.map → chunk-8t6dwwz6.js.map} +0 -0
  354. /package/dist/{chunk-agyfv3f8.js.map → chunk-nrezmscd.js.map} +0 -0
  355. /package/dist/{chunk-x7cpth2f.js.map → chunk-razjfecn.js.map} +0 -0
@@ -1 +1 @@
1
- {"version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AAQ,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE;;;CAqB/C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,WAAW,QAO9D"}
1
+ {"version":3,"file":"QueueServiceProvider.d.ts","sourceRoot":"","sources":["../../../services/queue/QueueServiceProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAyBhE,qBAAa,oBAAqB,SAAQ,eAAe;IACvD,QAAQ;IAYR;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,IAAI;IAcV;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE;;;CAqB/C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,WAAW,QAO9D"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The delay before the retry that follows attempt `attempt`: the number
3
+ * itself, or the array's entry for that retry with its last entry repeated.
4
+ */
5
+ export declare function backoffFor(backoff: number | number[], attempt: number): number;
6
+ //# sourceMappingURL=backoff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backoff.d.ts","sourceRoot":"","sources":["../../../services/queue/backoff.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,UAKrE"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * The bookkeeping of a job batch, shared by every driver so that the rules for
3
+ * when a batch is cancelled and which callbacks run are written once.
4
+ *
5
+ * A driver keeps a `BatchRecord` per batch and calls these functions while it
6
+ * holds that record exclusively: inside the transaction that also ends the job
7
+ * (the database driver, with the batch row locked), or synchronously (the
8
+ * memory driver). Everything here is pure; the driver writes what comes back,
9
+ * and enqueues the callback jobs `settle` returns in the same step, which is
10
+ * what makes each callback run exactly once.
11
+ *
12
+ * The rules:
13
+ *
14
+ * - Every job of the batch ends exactly once as `succeeded`, `failed` (it was
15
+ * dead-lettered) or `cancelled` (it never ran to the end because the batch was
16
+ * cancelled). `pending` counts the ones that have not ended yet.
17
+ * - `catch` is due at the first failure or cancellation, whichever comes first.
18
+ * - Without `allowFailures`, the first failure cancels the batch: the jobs still
19
+ * waiting are ended as `cancelled` at once, and running ones see it through
20
+ * `this.batch.cancelled()`.
21
+ * - Once `pending` reaches 0 the batch is finished: `then` is due when it was
22
+ * not cancelled and nothing failed (or `allowFailures` is set), and `finally`
23
+ * is always due.
24
+ */
25
+ /** A job and the arguments to dispatch it with: what `Job.with(...)` returns. */
26
+ export type JobCall = {
27
+ /** The job's registered name: its class's `static name`. */
28
+ name: string;
29
+ /** The `run` arguments, before the batch status is appended. */
30
+ args: unknown[];
31
+ };
32
+ export type BatchCallbacks = {
33
+ then?: JobCall;
34
+ catch?: JobCall;
35
+ finally?: JobCall;
36
+ };
37
+ /** What `Job.findBatch` resolves to, and the last argument a batch callback gets. */
38
+ export type BatchStatus = {
39
+ id: string;
40
+ /** The `name` given to `dispatchBatch`, or `null`. */
41
+ name: string | null;
42
+ /** How many jobs the batch was dispatched with. */
43
+ total: number;
44
+ /** Jobs that have not ended yet: waiting, running, or waiting out a retry. */
45
+ pending: number;
46
+ succeeded: number;
47
+ /** Jobs that were dead-lettered. */
48
+ failed: number;
49
+ /** Jobs that ended without running to the end because the batch was cancelled. */
50
+ cancelled: number;
51
+ /** The ids of the dead-lettered jobs, in the order they failed. */
52
+ failedJobIds: string[];
53
+ /**
54
+ * 0 to 1: the ended jobs plus the share each running job reported with
55
+ * `this.progress()`, over `total`. 1 for a batch of no jobs.
56
+ */
57
+ progress: number;
58
+ /** When the batch was cancelled, in epoch milliseconds, or `null`. */
59
+ cancelledAt: number | null;
60
+ /** When its last job ended, in epoch milliseconds, or `null` while it runs. */
61
+ finishedAt: number | null;
62
+ createdAt: number;
63
+ };
64
+ /** What a driver stores per batch. */
65
+ export type BatchRecord = Omit<BatchStatus, "progress"> & {
66
+ allowFailures: boolean;
67
+ callbacks: BatchCallbacks;
68
+ };
69
+ /** How one job of a batch ended. */
70
+ export type BatchOutcome = "succeeded" | "failed" | "cancelled";
71
+ /** The callback jobs to enqueue, their arguments already serialised. */
72
+ export type BatchCallbackJob = {
73
+ name: string;
74
+ args: string;
75
+ };
76
+ export declare function newBatchRecord(batch: {
77
+ id: string;
78
+ name: string | null;
79
+ total: number;
80
+ allowFailures: boolean;
81
+ callbacks: BatchCallbacks;
82
+ now: number;
83
+ }): BatchRecord;
84
+ /** Counts one job's end. A batch with nothing pending is left as it is. */
85
+ export declare function countOutcome(record: BatchRecord, outcome: BatchOutcome, jobId: string): BatchRecord;
86
+ /**
87
+ * Whether going from `prev` to `next` is the failure that cancels the batch:
88
+ * its first, without `allowFailures`, in a batch not already cancelled.
89
+ */
90
+ export declare function cancelsBatch(prev: BatchRecord, next: BatchRecord): boolean;
91
+ /**
92
+ * Marks the batch cancelled, counting the `waiting` jobs the driver has just
93
+ * ended as `cancelled`.
94
+ */
95
+ export declare function markCancelled(record: BatchRecord, now: number, waiting: number): BatchRecord;
96
+ /**
97
+ * Finishes the batch when nothing is pending, and says which callbacks became
98
+ * due between `prev` and `next`. Each callback's arguments are its own followed
99
+ * by the batch's status as it stands after this step.
100
+ */
101
+ export declare function settle(prev: BatchRecord, next: BatchRecord, now: number): {
102
+ record: BatchRecord;
103
+ calls: BatchCallbackJob[];
104
+ };
105
+ /**
106
+ * The status of a batch. `running` is the sum of the progress the batch's
107
+ * unfinished jobs have reported, each 0 to 1.
108
+ */
109
+ export declare function statusOf(record: BatchRecord, running?: number): BatchStatus;
110
+ /** A progress value as stored: a finite number clamped to 0..1. */
111
+ export declare function clampProgress(value: number): number;
112
+ //# sourceMappingURL=batch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../../services/queue/batch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,iFAAiF;AACjF,MAAM,MAAM,OAAO,GAAG;IACpB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,qFAAqF;AACrF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,sDAAsD;IACtD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,+EAA+E;IAC/E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,sCAAsC;AACtC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG;IACxD,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,oCAAoC;AACpC,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEhE,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,cAAc,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,WAAW,CAgBd;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAC1B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,MAAM,GACZ,WAAW,CAUb;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAO1E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,CAQ5F;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,MAAM,GACV;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,gBAAgB,EAAE,CAAA;CAAE,CAwBpD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,SAAI,GAAG,WAAW,CAMtE;AAED,mEAAmE;AACnE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKnD"}
@@ -2,6 +2,7 @@ import type { Application } from "../../foundation/Application";
2
2
  import type { Job } from "./Job";
3
3
  import type { LockStore } from "../lock/LockStore";
4
4
  import type { QueueDriver } from "./QueueDriver";
5
+ import type { WorkflowClass } from "./workflow/Workflow";
5
6
  export interface QueueConfig {
6
7
  /**
7
8
  * The `Job` subclasses this application dispatches, or nothing.
@@ -45,6 +46,14 @@ export interface QueueConfig {
45
46
  * jobs is what this field is for; pointing it at `app/` is not.
46
47
  */
47
48
  jobsDir?: string;
49
+ /**
50
+ * The `Workflow` subclasses this application runs, or nothing, by the same
51
+ * rule as `jobs`: declared (including `[]`) is used as given, and absent
52
+ * discovers the classes under `workflowsDir`.
53
+ */
54
+ workflows?: WorkflowClass[];
55
+ /** Where to look when `workflows` was not declared. Default `app/workflows`. */
56
+ workflowsDir?: string;
48
57
  concurrency?: number;
49
58
  /**
50
59
  * Where queued jobs are kept: `"memory"`, `"database"`, a `QueueDriver`, or
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../services/queue/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;IAE5B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,EACH,QAAQ,GACR,UAAU,GACV,WAAW,GACX,CAAC,CAAC,WAAW,EAAE,WAAW,KAAK,WAAW,CAAC,CAAC;IAEhD;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAA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AAC,CAAC;IAEhD;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EACF,MAAM,GACN,QAAQ,GACR,UAAU,GACV,SAAS,GACT,CAAC,CAAC,WAAW,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC;CAC/C;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAElE;AAED,wBAAgB,mBAAmB,IAAI,QAAQ,CAAC,WAAW,CAAC,CAa3D"}
@@ -24,6 +24,9 @@ import type { QueueDriver } from "./QueueDriver";
24
24
  * checks that the driver says so, because the manager then holds the dispatch
25
25
  * until the commit itself; that half is `QueueManager.transaction.test.ts`.
26
26
  *
27
+ * `features.batches` runs the batch tests: `enqueueBatch`, the counters
28
+ * `complete` and `fail` keep, `findBatch`, `cancelBatch` and `reportProgress`.
29
+ *
27
30
  * Not a `*.test.ts` file, so vitest never runs it on its own, and not exported
28
31
  * from `gemi/services`, because it imports vitest.
29
32
  *
@@ -42,5 +45,7 @@ export declare function queueDriverContract(name: string, create: () => QueueDri
42
45
  run(driver: QueueDriver, fn: () => Promise<void>): Promise<void>;
43
46
  joins: boolean;
44
47
  };
48
+ /** The driver implements the batch methods, and runs the tests that pin them. */
49
+ batches?: boolean;
45
50
  }): void;
46
51
  //# sourceMappingURL=queueDriverContract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queueDriverContract.d.ts","sourceRoot":"","sources":["../../../services/queue/queueDriverContract.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAChD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACvD,QAAQ,GAAE;IACR,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE;QACZ,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;CACE,QAulBP"}
1
+ {"version":3,"file":"queueDriverContract.d.ts","sourceRoot":"","sources":["../../../services/queue/queueDriverContract.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,eAAe,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAChD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACvD,QAAQ,GAAE;IACR,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE;QACZ,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;CACd,QAo4BP"}
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Ec as E,Hc as T}from"../../chunk-7vb4eey2.js";import"../../chunk-tn2bryy2.js";import"../../chunk-cbqazg9k.js";import"../../chunk-1myhm0g3.js";import"../../chunk-kejwjerj.js";import"../../chunk-t4yh4nf9.js";import"../../chunk-1vzks22y.js";import{fi as I,gi as J,ji as O}from"../../chunk-zyt2w03d.js";import{ni as N}from"../../chunk-1hr4xht1.js";import"../../chunk-vw8849ys.js";import L from"path";class F extends Error{name="QueueWorkerRefused"}class H{kernel;stopping;keepAlive;settings;constructor(y,z={}){this.kernel=y;this.settings={...J(),...z}}async start(){if(await this.kernel.waitForBoot(),this.stopping)return;let y=this.kernel.app;if(!y.bound(E))throw new F("[gemi] `gemi queue:work` has no queue to claim from: this application does not register QueueServiceProvider.");let z=y.make(E);if(!z.durable)throw new F('[gemi] `gemi queue:work` refuses to start: the queue uses the memory driver, which keeps each job in the process that dispatched it, so a worker never sees one. Set `driver: "database"` (or another driver every process can reach) in app/config/queue.ts, or run jobs in the server and drop the worker.');z.start(),this.keepAlive=setInterval(()=>{},1073741824),console.log(`[gemi] Queue worker started: claiming up to ${z.config.concurrency} job(s) at a time.`)}stop(y={}){return this.stopping??=this.drain({...this.settings,...y}),this.stopping}async drain(y){I();let z=this.kernel.app,A=z.resolved(E)?z.make(E):void 0;if(A)console.log(`[gemi] Shutting down: waiting for ${A.running} running job(s) (up to ${y.timeoutMs/1000}s).`),await A.drain(y.timeoutMs);let B=await this.kernel.shutdown({timeoutMs:y.providerTimeoutMs});clearInterval(this.keepAlive);let C=(A?.running??0)===0&&B.failed.length===0&&B.timedOut.length===0;return console.log(`[gemi] Shutdown ${C?"complete":"finished with errors"}.`),C?0:1}}async function U(){let y=N();process.env.ROOT_DIR=y,process.env.APP_DIR=L.join(y,"app"),T();let z=L.join(y,"app/kernel/Kernel.ts"),{default:A}=await import(z);if(typeof A!=="function")return console.error(`[gemi] ${z} has no default export to boot the worker from.`),1;let B=new A;B.boot();let C=new H(B);O(()=>C.stop());try{await C.start()}catch(G){if(!(G instanceof F))throw G;return console.error(G.message),1}return}U().then((y)=>{if(y!==void 0)process.exit(y)},(y)=>{console.error("[gemi] The queue worker failed to start:",y),process.exit(1)});
2
+ import{Rc as E,Uc as T}from"../../chunk-nang3847.js";import"../../chunk-xx3zvc3g.js";import"../../chunk-gqfqnv3f.js";import"../../chunk-kkte8nze.js";import"../../chunk-hr1r3g0d.js";import"../../chunk-g5ppst76.js";import"../../chunk-d806cy7p.js";import{Vi as I,Wi as J,Zi as O}from"../../chunk-8wcpxm41.js";import{bj as N}from"../../chunk-jg79n382.js";import"../../chunk-hm9cjxy2.js";import L from"path";class F extends Error{name="QueueWorkerRefused"}class H{kernel;stopping;keepAlive;settings;constructor(y,z={}){this.kernel=y;this.settings={...J(),...z}}async start(){if(await this.kernel.waitForBoot(),this.stopping)return;let y=this.kernel.app;if(!y.bound(E))throw new F("[gemi] `gemi queue:work` has no queue to claim from: this application does not register QueueServiceProvider.");let z=y.make(E);if(!z.durable)throw new F('[gemi] `gemi queue:work` refuses to start: the queue uses the memory driver, which keeps each job in the process that dispatched it, so a worker never sees one. Set `driver: "database"` (or another driver every process can reach) in app/config/queue.ts, or run jobs in the server and drop the worker.');z.start(),this.keepAlive=setInterval(()=>{},1073741824),console.log(`[gemi] Queue worker started: claiming up to ${z.config.concurrency} job(s) at a time.`)}stop(y={}){return this.stopping??=this.drain({...this.settings,...y}),this.stopping}async drain(y){I();let z=this.kernel.app,A=z.resolved(E)?z.make(E):void 0;if(A)console.log(`[gemi] Shutting down: waiting for ${A.running} running job(s) (up to ${y.timeoutMs/1000}s).`),await A.drain(y.timeoutMs);let B=await this.kernel.shutdown({timeoutMs:y.providerTimeoutMs});clearInterval(this.keepAlive);let C=(A?.running??0)===0&&B.failed.length===0&&B.timedOut.length===0;return console.log(`[gemi] Shutdown ${C?"complete":"finished with errors"}.`),C?0:1}}async function U(){let y=N();process.env.ROOT_DIR=y,process.env.APP_DIR=L.join(y,"app"),T();let z=L.join(y,"app/kernel/Kernel.ts"),{default:A}=await import(z);if(typeof A!=="function")return console.error(`[gemi] ${z} has no default export to boot the worker from.`),1;let B=new A;B.boot();let C=new H(B);O(()=>C.stop());try{await C.start()}catch(G){if(!(G instanceof F))throw G;return console.error(G.message),1}return}U().then((y)=>{if(y!==void 0)process.exit(y)},(y)=>{console.error("[gemi] The queue worker failed to start:",y),process.exit(1)});
3
3
 
4
- //# debugId=94D4E3D8DDBEA88A64756E2164756E21
4
+ //# debugId=FAD23F28132E03B464756E2164756E21
@@ -6,6 +6,6 @@
6
6
  "import type { Application, ShutdownReport } from \"../../foundation/Application\";\nimport { markShuttingDown, shutdownSettings, type ShutdownSettings } from \"../../server/shutdown\";\nimport { QueueManager } from \"./QueueManager\";\n\n/** The part of a `Kernel` a worker drives. */\nexport type WorkerKernel = {\n readonly app: Application;\n waitForBoot(): Promise<void>;\n shutdown(options?: { timeoutMs?: number }): Promise<ShutdownReport>;\n};\n\n/**\n * A worker that was told to start in an application it cannot claim for. The\n * message is written for the operator reading the deploy's logs.\n */\nexport class QueueWorkerRefused extends Error {\n name = \"QueueWorkerRefused\";\n}\n\n/**\n * The process `gemi queue:work` runs: the application booted as a server boots\n * it, claiming from the queue, and no `Bun.serve`. It exists so job capacity\n * can be scaled apart from request traffic, which needs a driver both kinds of\n * process can reach; see `start` for why the memory driver is refused.\n *\n * The caller marks the process as a worker (`markQueueWorker`) before the\n * kernel registers, so every claim rule that asks `claimsInThisProcess` sees a\n * process that claims, whatever `GEMI_QUEUE_CLAIM` says.\n */\nexport class QueueWorker {\n private stopping: Promise<number> | undefined;\n private keepAlive: ReturnType<typeof setInterval> | undefined;\n private readonly settings: ShutdownSettings;\n\n /**\n * `settings` default to the `GEMI_SHUTDOWN_*` variables, read here rather\n * than at the signal so a bad value is warned about while the deploy is\n * being watched, as `Server.start` does.\n */\n constructor(\n private readonly kernel: WorkerKernel,\n settings: Partial<ShutdownSettings> = {},\n ) {\n this.settings = { ...shutdownSettings(), ...settings };\n }\n\n /**\n * Boots the application and starts claiming. Rejects with\n * `QueueWorkerRefused` when the application has no queue, or its queue uses\n * the memory driver.\n *\n * Refused rather than warned about, because a memory worker can never do\n * anything: its jobs live in a `Map` in the process that dispatched them,\n * so a worker's is always empty. Left running, it looks like a healthy\n * deploy — a process up, no errors — that runs nothing, and scaling it out\n * adds no capacity. An exit the platform reports as a crash loop is a form\n * of the mistake someone will see.\n */\n async start(): Promise<void> {\n await this.kernel.waitForBoot();\n // A signal during the boot has already drained and cleared the handle\n // below. Going on would start the loop again and arm a handle nothing\n // clears, holding open a worker that has finished shutting down.\n if (this.stopping) return;\n\n const application = this.kernel.app;\n // `bound`, not `make` in a try: an application built without the queue\n // provider is a configuration to name, not an unbound-token stack trace.\n if (!application.bound(QueueManager)) {\n throw new QueueWorkerRefused(\n \"[gemi] `gemi queue:work` has no queue to claim from: this application \" +\n \"does not register QueueServiceProvider.\",\n );\n }\n const queue = application.make(QueueManager);\n if (!queue.durable) {\n throw new QueueWorkerRefused(\n \"[gemi] `gemi queue:work` refuses to start: the queue uses the memory \" +\n \"driver, which keeps each job in the process that dispatched it, so \" +\n 'a worker never sees one. Set `driver: \"database\"` (or another driver ' +\n \"every process can reach) in app/config/queue.ts, or run jobs in the \" +\n \"server and drop the worker.\",\n );\n }\n\n // Idempotent: a production boot with a durable driver has already started\n // it (`startClaimingIfServing`). Development has not, and a worker claims\n // in either.\n queue.start();\n // The queue's poll timer is unref'd, so that a script's queue does not\n // hold it open; here the queue is the process, and without a handle of its\n // own an idle worker would exit 0 as soon as it booted.\n this.keepAlive = setInterval(() => {}, 1 << 30);\n console.log(\n `[gemi] Queue worker started: claiming up to ${queue.config.concurrency} job(s) at a time.`,\n );\n }\n\n /**\n * Stops claiming, waits for the running jobs, runs every provider's\n * `shutdown()`, and resolves with the exit code: 0 when no job was left\n * running and every provider finished in time, 1 otherwise. Idempotent.\n *\n * `gemi start`'s drain, with the jobs where the requests were:\n * `isShuttingDown()` turns true, which stops a durable queue claiming;\n * running jobs get `timeoutMs` (`GEMI_SHUTDOWN_TIMEOUT`), which a server\n * spends on requests; then `Application.shutdown` gets `providerTimeoutMs`,\n * and in it the queue provider waits for whatever is still running and\n * names it. The two budgets add up as they do for a server, so a worker\n * fits the same grace period. `delayMs` is not waited: it is for a load\n * balancer, and nothing routes to a worker.\n */\n stop(settings: Partial<ShutdownSettings> = {}): Promise<number> {\n this.stopping ??= this.drain({ ...this.settings, ...settings });\n return this.stopping;\n }\n\n private async drain(settings: ShutdownSettings): Promise<number> {\n markShuttingDown();\n const application = this.kernel.app;\n // Resolving the manager now would build a driver only to stop it, which\n // is what a signal during the boot, before the provider resolved it, finds.\n const queue = application.resolved(QueueManager) ? application.make(QueueManager) : undefined;\n if (queue) {\n console.log(\n `[gemi] Shutting down: waiting for ${queue.running} running job(s) ` +\n `(up to ${settings.timeoutMs / 1000}s).`,\n );\n await queue.drain(settings.timeoutMs);\n }\n\n const report = await this.kernel.shutdown({ timeoutMs: settings.providerTimeoutMs });\n clearInterval(this.keepAlive);\n const clean =\n (queue?.running ?? 0) === 0 && report.failed.length === 0 && report.timedOut.length === 0;\n console.log(`[gemi] Shutdown ${clean ? \"complete\" : \"finished with errors\"}.`);\n return clean ? 0 : 1;\n }\n}\n"
7
7
  ],
8
8
  "mappings": ";iZAYA,kBCGO,IAAM,QAA2B,GAAM,DAC5C,GAAO,kBACT,DAYO,IAAM,CAAY,CAWJ,OAVX,SACA,UACS,SAOjB,WAAW,CACQ,EACjB,EAAsC,CAAC,EACvC,CAFiB,cAGjB,KAAK,SAAW,IAAK,EAAiB,KAAM,CAAS,OAejD,MAAK,EAAkB,CAK3B,GAJA,MAAM,KAAK,OAAO,YAAY,EAI1B,KAAK,SAAU,OAEnB,IAAM,EAAc,KAAK,OAAO,IAGhC,GAAI,CAAC,EAAY,MAAM,CAAY,EACjC,MAAM,IAAI,EACR,+GAEF,EAEF,IAAM,EAAQ,EAAY,KAAK,CAAY,EAC3C,GAAI,CAAC,EAAM,QACT,MAAM,IAAI,EACR,8SAKF,EAMF,EAAM,MAAM,EAIZ,KAAK,UAAY,YAAY,IAAM,GAAI,U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ACL,CAAC,IAAS,CACR,GAAI,IAAS,OAAW,QAAQ,KAAK,CAAI,GAE3C,CAAC,IAAU,CACT,QAAQ,MAAM,2CAA4C,CAAK,EAC/D,QAAQ,KAAK,CAAC,EAElB",
9
- "debugId": "94D4E3D8DDBEA88A64756E2164756E21",
9
+ "debugId": "FAD23F28132E03B464756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -0,0 +1,89 @@
1
+ import type { SQL, TransactionSQL } from "bun";
2
+ import type { Dialect } from "../../../database/dialect";
3
+ import type { EnqueueBatch, EnqueueJob } from "../QueueDriver";
4
+ import { type AcquireResult, type WorkflowChange, type WorkflowSnapshot, type WorkflowState, type WorkflowStore } from "./WorkflowStore";
5
+ /** A SQL fragment, as the driver's helpers build them. */
6
+ type Fragment = ReturnType<SQL["unsafe"]>;
7
+ /**
8
+ * What the database queue driver lends its workflow store: its connection,
9
+ * its transactions and clock, and the writes a workflow's changes schedule.
10
+ * The driver builds it from its private methods, so the two share one
11
+ * transaction per change.
12
+ */
13
+ export type DatabaseQueueInternals = {
14
+ sql: SQL;
15
+ dialect: Dialect;
16
+ connection: string | undefined;
17
+ configure(): Promise<void>;
18
+ atomically<T>(fn: (q: SQL) => Promise<T>): Promise<T>;
19
+ transaction(): TransactionSQL | undefined;
20
+ now(q: SQL): Fragment;
21
+ ms(q: SQL, value: number): Fragment;
22
+ timeOrNull(q: SQL, value: number | null): Fragment;
23
+ fraction(q: SQL, value: number): Fragment;
24
+ clock(q: SQL): Promise<number>;
25
+ insertJob(q: SQL, job: EnqueueJob): Promise<string>;
26
+ insertBatch(q: SQL, batch: EnqueueBatch): Promise<void>;
27
+ cancelBatch(q: SQL, id: string): Promise<boolean>;
28
+ quoted(identifier: string): string;
29
+ };
30
+ /**
31
+ * Workflows in two tables of the queue's database: one row per workflow, and
32
+ * one per step, keyed by the workflow and the step's key.
33
+ *
34
+ * Every change runs in a transaction that locks the workflow's row first
35
+ * (`SELECT … FOR UPDATE` on Postgres and MySQL; a no-op write on SQLite, which
36
+ * takes the file's write lock), reads what the change depends on, and writes
37
+ * it together with any tick job or batch it schedules. The queue's batch
38
+ * transactions lock a batch row and then job rows and never a workflow row,
39
+ * so the two kinds cannot deadlock on each other.
40
+ */
41
+ export declare class DatabaseWorkflowStore implements WorkflowStore {
42
+ private readonly db;
43
+ readonly table: string;
44
+ readonly stepTable: string;
45
+ constructor(db: DatabaseQueueInternals, options: {
46
+ table: string;
47
+ stepTable: string;
48
+ });
49
+ joinsTransaction(): boolean;
50
+ create(workflow: {
51
+ id: string;
52
+ name: string;
53
+ args: string;
54
+ }): Promise<void>;
55
+ private insertWorkflow;
56
+ find(id: string, options?: {
57
+ steps?: boolean;
58
+ }): Promise<WorkflowState | null>;
59
+ acquire(id: string, owner: string, leaseMs: number): Promise<AcquireResult>;
60
+ renew(id: string, owner: string, leaseMs: number): Promise<boolean>;
61
+ update<T>(id: string, options: {
62
+ owner?: string;
63
+ key?: string;
64
+ allSteps?: boolean;
65
+ }, decide: (snapshot: WorkflowSnapshot) => WorkflowChange<T>): Promise<T | undefined>;
66
+ prune(olderThanMs: number): Promise<number>;
67
+ private writeStep;
68
+ /**
69
+ * Reads the workflow's row and holds it until the transaction ends, as the
70
+ * driver's `lockBatch` holds a batch's.
71
+ */
72
+ private lock;
73
+ private stepOf;
74
+ private stepsOf;
75
+ private workflows;
76
+ private steps;
77
+ /** `key` is a reserved word in MySQL. */
78
+ private keyColumn;
79
+ }
80
+ /**
81
+ * The two workflow tables, as Prisma generates them for the `GemiWorkflow`
82
+ * and `GemiWorkflowStep` models in the docs (checked against `prisma migrate
83
+ * diff` for all three providers), with `IF NOT EXISTS` added. MySQL cannot
84
+ * say that of an index, so its index is declared inside the table, which is
85
+ * also where Prisma puts it.
86
+ */
87
+ export declare function createWorkflowTableStatements(dialect: Dialect, table: string, stepTable: string): string[];
88
+ export {};
89
+ //# sourceMappingURL=DatabaseWorkflowStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseWork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OAAO,CAAC;IAWzE,MAAM,CAAC,CAAC,EACN,EAAE,EAAE,MAAM,EACV,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAC7D,MAAM,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,cAAc,CAAC,CAAC,CAAC,GACxD,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAmDnB,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAiBnC,SAAS;IA2BvB;;;OAGG;YACW,IAAI;YAiBJ,MAAM;YAQN,OAAO;IAWrB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,KAAK;IAIb,yCAAyC;IACzC,OAAO,CAAC,SAAS;CAGlB;AA6ED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,MAAM,EAAE,CAkFV"}
@@ -0,0 +1,43 @@
1
+ import type { EnqueueBatch, EnqueueJob } from "../QueueDriver";
2
+ import { type AcquireResult, type StepRecord, type WorkflowChange, type WorkflowRecord, type WorkflowState, type WorkflowStore } from "./WorkflowStore";
3
+ /** What the memory driver lends its workflow store: its own writes, done synchronously. */
4
+ export type MemoryQueueWrites = {
5
+ enqueue(job: EnqueueJob): void;
6
+ enqueueBatch(batch: EnqueueBatch): void;
7
+ cancelBatch(id: string): void;
8
+ };
9
+ /**
10
+ * Workflows in this process's memory, beside the memory driver's jobs, and
11
+ * lost with them when the process exits. Every change happens synchronously
12
+ * inside the call that makes it, so it is atomic without further care.
13
+ */
14
+ export declare class MemoryWorkflowStore implements WorkflowStore {
15
+ private readonly queue;
16
+ private workflows;
17
+ private steps;
18
+ constructor(queue: MemoryQueueWrites);
19
+ create(workflow: {
20
+ id: string;
21
+ name: string;
22
+ args: string;
23
+ }): Promise<void>;
24
+ find(id: string, options?: {
25
+ steps?: boolean;
26
+ }): Promise<WorkflowState | null>;
27
+ acquire(id: string, owner: string, leaseMs: number): Promise<AcquireResult>;
28
+ renew(id: string, owner: string, leaseMs: number): Promise<boolean>;
29
+ update<T>(id: string, options: {
30
+ owner?: string;
31
+ key?: string;
32
+ allSteps?: boolean;
33
+ }, decide: (snapshot: {
34
+ workflow: WorkflowRecord;
35
+ step: StepRecord | null;
36
+ steps: StepRecord[];
37
+ now: number;
38
+ }) => WorkflowChange<T>): Promise<T | undefined>;
39
+ prune(olderThanMs: number): Promise<number>;
40
+ private stepsOf;
41
+ private tick;
42
+ }
43
+ //# sourceMappingURL=MemoryWorkflowStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryWorkflowStore.d.ts","sourceRoot":"","sources":["../../../../services/queue/workflow/MemoryWorkflowStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,KAAK,cAAc,EAGnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AAEzB,2FAA2F;AAC3F,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAKF;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IAI3C,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,SAAS,CAAqC;IACtD,OAAO,CAAC,KAAK,CAA8C;gBAE9B,KAAK,EAAE,iBAAiB;IAE/C,MAAM,CAAC,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B3E,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IASlF,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAkB3E,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOnE,MAAM,CAAC,CAAC,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAC7D,MAAM,EAAE,CAAC,QAAQ,EAAE;QACjB,QAAQ,EAAE,cAAc,CAAC;QACzB,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;QACxB,KAAK,EAAE,UAAU,EAAE,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;KACb,KAAK,cAAc,CAAC,CAAC,CAAC,GACtB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAqCnB,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAcjD,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,IAAI;CAOb"}
@@ -0,0 +1,202 @@
1
+ import { type BatchStatus } from "../batch";
2
+ import type { EnqueueBatch } from "../QueueDriver";
3
+ import type { Job } from "../Job";
4
+ import { type Duration } from "./duration";
5
+ import { type StepRecord, type WorkflowStore } from "./WorkflowStore";
6
+ /** What a `step.run` function is handed. */
7
+ export type StepContext = {
8
+ /**
9
+ * `<workflow id>:<step key>`: the same on every attempt of this step, and
10
+ * different for every other step. Pass it to a payment provider, say, so
11
+ * that an attempt repeated after a crash is not charged twice.
12
+ */
13
+ idempotencyKey: string;
14
+ /** Which attempt this is, counting from 1. */
15
+ attempt: number;
16
+ /**
17
+ * Aborted when the step's `timeout` passes or the workflow is cancelled.
18
+ * Pass it to `fetch` and friends. The workflow stops waiting for the step
19
+ * at that moment, whether or not the function notices.
20
+ */
21
+ signal: AbortSignal;
22
+ };
23
+ export type StepRunOptions = {
24
+ /** How many attempts the step gets, counting the first. Default 3. */
25
+ attempts?: number;
26
+ /**
27
+ * Milliseconds to wait before each retry: one number for every retry, or
28
+ * one per retry with the last repeated, as `Job.backoff`. Default 0. A
29
+ * retry with a delay suspends the workflow until it is due.
30
+ */
31
+ backoff?: number | number[];
32
+ /** How long one attempt may take before it counts as failed. */
33
+ timeout?: Duration;
34
+ };
35
+ export type StepWaitOptions = {
36
+ /**
37
+ * How long to wait for the signal. Past it, `waitFor` throws a
38
+ * `WaitTimeoutError`. Without it, the workflow waits until it is signalled
39
+ * or cancelled.
40
+ */
41
+ timeout?: Duration;
42
+ };
43
+ export type StepBatchOptions = {
44
+ /** A label kept with the batch. Default `workflow:<id>:<key>`. */
45
+ name?: string;
46
+ /**
47
+ * Whether a failed job leaves the rest running. Default `false`: the first
48
+ * dead-lettered job cancels the batch and `step.batch` throws a
49
+ * `StepFailedError`. With `true`, `step.batch` returns the status, failed
50
+ * jobs and all.
51
+ */
52
+ allowFailures?: boolean;
53
+ };
54
+ /** A step that ran out of attempts, or a batch that failed. */
55
+ export declare class StepFailedError extends Error {
56
+ /** The step's key. */
57
+ readonly step: string;
58
+ /** The batch's final status, for a `step.batch` that failed. */
59
+ readonly batch?: BatchStatus;
60
+ constructor(
61
+ /** The step's key. */
62
+ step: string, message: string,
63
+ /** The batch's final status, for a `step.batch` that failed. */
64
+ batch?: BatchStatus);
65
+ }
66
+ /** A `step.waitFor` whose `timeout` passed before the signal arrived. */
67
+ export declare class WaitTimeoutError extends Error {
68
+ readonly step: string;
69
+ constructor(step: string);
70
+ }
71
+ /** Why a step's `ctx.signal` was aborted by its `timeout`. */
72
+ export declare class StepTimeoutError extends Error {
73
+ constructor(step: string, timeoutMs: number);
74
+ }
75
+ /** Why a step's `ctx.signal` was aborted by `Workflow.cancel`. */
76
+ export declare class WorkflowCancelledError extends Error {
77
+ constructor(id: string);
78
+ }
79
+ /**
80
+ * Thrown through the workflow's code when a step cannot finish in this tick
81
+ * (a sleep, a wait, a batch, a retry with a delay), so the tick can end and
82
+ * the workflow resume later. Not exported: code that catches everything
83
+ * should rethrow what it does not know, and the tick treats the workflow as
84
+ * suspended even if this is swallowed.
85
+ */
86
+ export declare class WorkflowSuspended extends Error {
87
+ constructor();
88
+ }
89
+ /** What the runtime gives the steps of one tick. */
90
+ export type StepTick = {
91
+ workflowId: string;
92
+ /** The tick's hold on the workflow; every write is fenced by it. */
93
+ owner: string;
94
+ store: WorkflowStore;
95
+ /** The steps as they were when the tick took the workflow. */
96
+ steps: StepRecord[];
97
+ /** This tick runs `onCancel`, not `run`. */
98
+ cancelling: boolean;
99
+ findBatch(id: string): Promise<BatchStatus | null>;
100
+ buildBatch(job: new () => Job, args: ReadonlyArray<ReadonlyArray<unknown>>, options: {
101
+ name: string;
102
+ allowFailures: boolean;
103
+ }): EnqueueBatch;
104
+ /** Jobs were recorded: wake the queue. */
105
+ scheduled(): void;
106
+ /** How often a running step checks whether the workflow was cancelled. */
107
+ cancelCheckMs: number;
108
+ };
109
+ /** Why a tick stopped where it did. */
110
+ export type Suspension = {
111
+ status: "sleeping" | "waiting";
112
+ /** When a tick is needed to continue; none for a wait on a signal or batch. */
113
+ wakes: number[];
114
+ };
115
+ /**
116
+ * What `run` receives as its first argument. Every method takes a **key**,
117
+ * unique within the workflow and the same on every pass: a step whose key has
118
+ * a stored result returns it without running again, which is how a workflow
119
+ * resumes where it stopped. Code outside the steps runs again on every pass.
120
+ */
121
+ export declare class Step {
122
+ private readonly tick;
123
+ /** The workflow's id. */
124
+ readonly workflowId: string;
125
+ private readonly steps;
126
+ private readonly seen;
127
+ private readonly pending;
128
+ /** @internal Why the tick stopped, once a step suspended it. */
129
+ suspension: Suspension | undefined;
130
+ /** @internal The tick lost its hold on the workflow. */
131
+ lost: boolean;
132
+ /** The workflow was cancelled during this tick. */
133
+ private cancelled;
134
+ /** @internal The step the workflow is on, for its status. */
135
+ current: string | null;
136
+ /** @internal Built by the workflow runtime, once per tick. */
137
+ constructor(tick: StepTick);
138
+ /**
139
+ * Runs `fn` once and stores what it returns, as JSON; on every later pass
140
+ * the stored value is returned without running it again. A throw is retried
141
+ * up to `attempts`, after which the step fails and this throws a
142
+ * `StepFailedError`, which the workflow may catch. The value comes back as
143
+ * JSON makes it, the first time too: a `Date` becomes a string.
144
+ *
145
+ * At least once: a process that dies after `fn` and before its result is
146
+ * stored runs it again. Use `ctx.idempotencyKey` for anything that must not
147
+ * happen twice, or `attempts: 1`.
148
+ */
149
+ run<T>(key: string, fn: (ctx: StepContext) => T | Promise<T>, options?: StepRunOptions): Promise<Awaited<T>>;
150
+ /** Suspends the workflow for `duration`, without holding a process. */
151
+ sleep(key: string, duration: Duration): Promise<void>;
152
+ /**
153
+ * Suspends the workflow until `Workflow.signal(id, key, payload)` and
154
+ * returns the payload. A signal that arrives before the workflow gets here
155
+ * is kept, and returned at once.
156
+ */
157
+ waitFor<T = unknown>(key: string, options?: StepWaitOptions): Promise<T>;
158
+ /**
159
+ * Dispatches `job` once per argument tuple as a batch (`Job.dispatchBatch`)
160
+ * and suspends the workflow until every job has ended; then returns the
161
+ * batch's status. The step is recorded and the batch dispatched in one
162
+ * atomic write, so a crash cannot dispatch it twice.
163
+ */
164
+ batch<J extends Job>(key: string, job: new () => J, args: ReadonlyArray<Readonly<Parameters<J["run"]>>>, options?: StepBatchOptions): Promise<BatchStatus>;
165
+ /**
166
+ * Sets the workflow's `progress`, 0 to 1. Not a step: it writes on every
167
+ * pass that reaches it.
168
+ */
169
+ progress(value: number): Promise<void>;
170
+ /** @internal Waits for every step this tick started, however each ended. */
171
+ settled(): Promise<void>;
172
+ private track;
173
+ private remember;
174
+ /** Once suspended, nothing else may start in this tick. */
175
+ private assertRunning;
176
+ private suspend;
177
+ /**
178
+ * One atomic write, fenced by the tick's hold. A workflow that is being
179
+ * cancelled takes no new work from `run`: the write is skipped and the
180
+ * tick suspended, so `onCancel` runs next.
181
+ */
182
+ private write;
183
+ private record;
184
+ private mismatch;
185
+ private runStep;
186
+ /**
187
+ * One attempt of a `step.run` function, abandoned when its timeout passes
188
+ * or the workflow is cancelled meanwhile.
189
+ */
190
+ private execute;
191
+ private sleepStep;
192
+ private waitStep;
193
+ private batchStep;
194
+ }
195
+ /**
196
+ * A value as stored: JSON, or `null` for `undefined`. Refused past
197
+ * `WORKFLOW_OUTPUT_LIMIT`, and for what JSON cannot carry.
198
+ */
199
+ export declare function encode(value: unknown, what: string): string | null;
200
+ export declare function decode(output: string | null): unknown;
201
+ export declare function describe(error: unknown): string;
202
+ //# sourceMappingURL=Step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Step.d.ts","sourceRoot":"","sources":["../../../../services/queue/workflow/Step.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,UAAU,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,YAAY,CAAC;AAC3D,OAAO,EACL,KAAK,UAAU,EAMf,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AAEzB,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG;IACxB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,OAAO,EAAE,MAAM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