gemi 0.124.0 → 0.126.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 (331) hide show
  1. package/dist/ai/AgentController.d.ts +185 -3
  2. package/dist/ai/AgentController.d.ts.map +1 -1
  3. package/dist/ai/client/index.d.ts +1 -1
  4. package/dist/ai/client/index.d.ts.map +1 -1
  5. package/dist/ai/client/index.js +38 -9
  6. package/dist/ai/client/index.js.map +1 -1
  7. package/dist/ai/client/reducer.d.ts.map +1 -1
  8. package/dist/ai/index.d.ts +2 -2
  9. package/dist/ai/index.d.ts.map +1 -1
  10. package/dist/ai/index.js +31 -48
  11. package/dist/ai/index.js.map +6 -15
  12. package/dist/ai/types.d.ts +26 -0
  13. package/dist/ai/types.d.ts.map +1 -1
  14. package/dist/ai/useChat.d.ts +35 -2
  15. package/dist/ai/useChat.d.ts.map +1 -1
  16. package/dist/app/index.js +1 -1
  17. package/dist/auth/AuthController.d.ts.map +1 -1
  18. package/dist/auth/AuthManager.d.ts +11 -0
  19. package/dist/auth/AuthManager.d.ts.map +1 -1
  20. package/dist/auth/AuthServiceProvider.d.ts +2 -0
  21. package/dist/auth/AuthServiceProvider.d.ts.map +1 -1
  22. package/dist/auth/config.d.ts +71 -2
  23. package/dist/auth/config.d.ts.map +1 -1
  24. package/dist/auth/connections/ConnectionsController.d.ts.map +1 -1
  25. package/dist/auth/oauth/GoogleOAuthProvider.d.ts +1 -1
  26. package/dist/auth/oauth/GoogleOAuthProvider.d.ts.map +1 -1
  27. package/dist/auth/oauth/InstagramOAuthProvider.d.ts +1 -1
  28. package/dist/auth/oauth/InstagramOAuthProvider.d.ts.map +1 -1
  29. package/dist/auth/oauth/XOAuthProvider.d.ts.map +1 -1
  30. package/dist/auth/oauth/providers.d.ts +10 -0
  31. package/dist/auth/oauth/providers.d.ts.map +1 -0
  32. package/dist/bun/plugin.js +1 -1
  33. package/dist/bun/preload.js +1 -1
  34. package/dist/{chunk-cfdwsvtx.js → chunk-094m8mj3.js} +2 -2
  35. package/dist/{chunk-cfdwsvtx.js.map → chunk-094m8mj3.js.map} +1 -1
  36. package/dist/chunk-0arss2xy.js +5 -0
  37. package/dist/{chunk-mqtfaqx5.js.map → chunk-0arss2xy.js.map} +5 -4
  38. package/dist/{chunk-rtawbqec.js → chunk-0f0xxqhy.js} +3 -3
  39. package/dist/{chunk-rtawbqec.js.map → chunk-0f0xxqhy.js.map} +1 -1
  40. package/dist/chunk-15bmfr7f.js +5 -0
  41. package/dist/chunk-15bmfr7f.js.map +14 -0
  42. package/dist/{chunk-6bgb1nhq.js → chunk-1dzs05dc.js} +2 -2
  43. package/dist/{chunk-6bgb1nhq.js.map → chunk-1dzs05dc.js.map} +1 -1
  44. package/dist/{chunk-30xxc6r7.js → chunk-1eb4p352.js} +2 -2
  45. package/dist/{chunk-30xxc6r7.js.map → chunk-1eb4p352.js.map} +1 -1
  46. package/dist/{chunk-s5jxc63j.js → chunk-1gd1ykgj.js} +3 -3
  47. package/dist/{chunk-s5jxc63j.js.map → chunk-1gd1ykgj.js.map} +1 -1
  48. package/dist/{chunk-4drnyymm.js → chunk-1v368y9a.js} +2 -2
  49. package/dist/{chunk-4drnyymm.js.map → chunk-1v368y9a.js.map} +1 -1
  50. package/dist/{chunk-sd0c2001.js → chunk-28bby5pp.js} +2 -2
  51. package/dist/{chunk-sd0c2001.js.map → chunk-28bby5pp.js.map} +1 -1
  52. package/dist/{chunk-wbg2tza5.js → chunk-3fyhd641.js} +1 -1
  53. package/dist/{chunk-3y294mb8.js → chunk-43faxwf5.js} +2 -2
  54. package/dist/{chunk-3y294mb8.js.map → chunk-43faxwf5.js.map} +1 -1
  55. package/dist/{chunk-v2ggafz1.js → chunk-56ryda9y.js} +2 -2
  56. package/dist/{chunk-v2ggafz1.js.map → chunk-56ryda9y.js.map} +1 -1
  57. package/dist/{chunk-dxfhhw5h.js → chunk-5vvfcdpk.js} +2 -2
  58. package/dist/{chunk-dxfhhw5h.js.map → chunk-5vvfcdpk.js.map} +1 -1
  59. package/dist/{chunk-2affxmkn.js → chunk-62zn06wb.js} +2 -2
  60. package/dist/{chunk-2affxmkn.js.map → chunk-62zn06wb.js.map} +1 -1
  61. package/dist/{chunk-bt9qv2jj.js → chunk-7dzprr9b.js} +3 -3
  62. package/dist/{chunk-bt9qv2jj.js.map → chunk-7dzprr9b.js.map} +1 -1
  63. package/dist/{chunk-n1a2zj5z.js → chunk-7eerqsg2.js} +2 -2
  64. package/dist/{chunk-n1a2zj5z.js.map → chunk-7eerqsg2.js.map} +3 -3
  65. package/dist/{chunk-nnarmbjv.js → chunk-7nfprr9v.js} +2 -2
  66. package/dist/chunk-7nfprr9v.js.map +10 -0
  67. package/dist/{chunk-yzhv93b0.js → chunk-7x2n788t.js} +3 -3
  68. package/dist/{chunk-yzhv93b0.js.map → chunk-7x2n788t.js.map} +1 -1
  69. package/dist/{chunk-zsvav1dk.js → chunk-84rbdyhe.js} +2 -2
  70. package/dist/{chunk-zsvav1dk.js.map → chunk-84rbdyhe.js.map} +1 -1
  71. package/dist/chunk-87bmhng2.js +5 -0
  72. package/dist/{chunk-70nnh0y7.js.map → chunk-87bmhng2.js.map} +1 -1
  73. package/dist/{chunk-nn2jeat2.js → chunk-87jj7n9q.js} +2 -2
  74. package/dist/{chunk-17dndh5z.js.map → chunk-87jj7n9q.js.map} +1 -1
  75. package/dist/{chunk-17dndh5z.js → chunk-89swy5aq.js} +2 -2
  76. package/dist/{chunk-nn2jeat2.js.map → chunk-89swy5aq.js.map} +1 -1
  77. package/dist/{chunk-2n4490pk.js → chunk-8df7fn7f.js} +3 -3
  78. package/dist/{chunk-2n4490pk.js.map → chunk-8df7fn7f.js.map} +1 -1
  79. package/dist/{chunk-qdj8ek8z.js → chunk-99z9d0sa.js} +2 -2
  80. package/dist/{chunk-qdj8ek8z.js.map → chunk-99z9d0sa.js.map} +1 -1
  81. package/dist/{chunk-1rnh9qrp.js → chunk-9hhxy88x.js} +2 -2
  82. package/dist/{chunk-1rnh9qrp.js.map → chunk-9hhxy88x.js.map} +1 -1
  83. package/dist/{chunk-nkzmk7v3.js → chunk-9x0pgkns.js} +2 -2
  84. package/dist/{chunk-nkzmk7v3.js.map → chunk-9x0pgkns.js.map} +1 -1
  85. package/dist/{chunk-qhz0x97z.js → chunk-avfntxm1.js} +2 -2
  86. package/dist/{chunk-qhz0x97z.js.map → chunk-avfntxm1.js.map} +1 -1
  87. package/dist/{chunk-92sk56n0.js → chunk-b2pdqxj3.js} +12 -12
  88. package/dist/{chunk-92sk56n0.js.map → chunk-b2pdqxj3.js.map} +7 -8
  89. package/dist/{chunk-5e22tm7m.js → chunk-bghxdjqv.js} +1 -1
  90. package/dist/{chunk-fn2qfwgx.js → chunk-bhbxhk9e.js} +2 -2
  91. package/dist/{chunk-fn2qfwgx.js.map → chunk-bhbxhk9e.js.map} +1 -1
  92. package/dist/{chunk-65s834td.js → chunk-c48gag78.js} +1 -1
  93. package/dist/{chunk-bnt8kx6x.js → chunk-c65rh4k8.js} +2 -2
  94. package/dist/{chunk-bnt8kx6x.js.map → chunk-c65rh4k8.js.map} +1 -1
  95. package/dist/chunk-cwpezdpw.js +57 -0
  96. package/dist/{chunk-5j50q4g8.js.map → chunk-cwpezdpw.js.map} +29 -21
  97. package/dist/chunk-dm7mada7.js +15 -0
  98. package/dist/{chunk-n0r5xyk2.js.map → chunk-dm7mada7.js.map} +6 -5
  99. package/dist/{chunk-mrswc6qw.js → chunk-ebdkmzm9.js} +2 -2
  100. package/dist/{chunk-mrswc6qw.js.map → chunk-ebdkmzm9.js.map} +1 -1
  101. package/dist/{chunk-z5jydj5r.js → chunk-ecb8qggy.js} +2 -2
  102. package/dist/{chunk-z5jydj5r.js.map → chunk-ecb8qggy.js.map} +1 -1
  103. package/dist/{chunk-y434jc1c.js → chunk-etf6h5m1.js} +2 -2
  104. package/dist/{chunk-y434jc1c.js.map → chunk-etf6h5m1.js.map} +1 -1
  105. package/dist/{chunk-fvrmptd0.js → chunk-ewv1m1sv.js} +3 -3
  106. package/dist/{chunk-fvrmptd0.js.map → chunk-ewv1m1sv.js.map} +1 -1
  107. package/dist/{chunk-fw7ds23a.js → chunk-gv59djt3.js} +2 -2
  108. package/dist/{chunk-fw7ds23a.js.map → chunk-gv59djt3.js.map} +1 -1
  109. package/dist/{chunk-3hqwz48c.js → chunk-gxp48t81.js} +4 -4
  110. package/dist/{chunk-3hqwz48c.js.map → chunk-gxp48t81.js.map} +1 -1
  111. package/dist/{chunk-pmyh33v5.js → chunk-h4755p9h.js} +2 -2
  112. package/dist/{chunk-pmyh33v5.js.map → chunk-h4755p9h.js.map} +1 -1
  113. package/dist/{chunk-jys8y39p.js → chunk-hye22tpt.js} +2 -2
  114. package/dist/{chunk-jys8y39p.js.map → chunk-hye22tpt.js.map} +1 -1
  115. package/dist/{chunk-7gfdts60.js → chunk-jg3kg55f.js} +2 -2
  116. package/dist/{chunk-7gfdts60.js.map → chunk-jg3kg55f.js.map} +1 -1
  117. package/dist/{chunk-j7v7dft7.js → chunk-k6gvbvyw.js} +1 -1
  118. package/dist/{chunk-qycwjzsv.js → chunk-kzk5r6v4.js} +3 -3
  119. package/dist/{chunk-qycwjzsv.js.map → chunk-kzk5r6v4.js.map} +1 -1
  120. package/dist/{chunk-rttrpjqk.js → chunk-m63v6aze.js} +2 -2
  121. package/dist/{chunk-rttrpjqk.js.map → chunk-m63v6aze.js.map} +1 -1
  122. package/dist/{chunk-1qwhty9p.js → chunk-mj4n5mar.js} +2 -2
  123. package/dist/{chunk-1qwhty9p.js.map → chunk-mj4n5mar.js.map} +1 -1
  124. package/dist/{chunk-h3p8qzft.js → chunk-mj7h1dgh.js} +2 -2
  125. package/dist/{chunk-h3p8qzft.js.map → chunk-mj7h1dgh.js.map} +1 -1
  126. package/dist/{chunk-f4cmz31h.js → chunk-mpt5jg4e.js} +2 -2
  127. package/dist/{chunk-f4cmz31h.js.map → chunk-mpt5jg4e.js.map} +1 -1
  128. package/dist/{chunk-w61sphn5.js → chunk-n8mxsfc2.js} +3 -3
  129. package/dist/{chunk-w61sphn5.js.map → chunk-n8mxsfc2.js.map} +1 -1
  130. package/dist/{chunk-34fkx6kb.js → chunk-nrf23yan.js} +2 -2
  131. package/dist/{chunk-34fkx6kb.js.map → chunk-nrf23yan.js.map} +1 -1
  132. package/dist/{chunk-pe46a5a5.js → chunk-nv2t87c3.js} +2 -2
  133. package/dist/{chunk-pe46a5a5.js.map → chunk-nv2t87c3.js.map} +1 -1
  134. package/dist/{chunk-c4jnxmf2.js → chunk-p0ccxfkq.js} +1 -1
  135. package/dist/{chunk-019wz697.js → chunk-p7abyc0b.js} +2 -2
  136. package/dist/{chunk-019wz697.js.map → chunk-p7abyc0b.js.map} +1 -1
  137. package/dist/{chunk-8m2htvjn.js → chunk-psdyfaf1.js} +2 -2
  138. package/dist/{chunk-8m2htvjn.js.map → chunk-psdyfaf1.js.map} +1 -1
  139. package/dist/{chunk-b5afy6k9.js → chunk-q9mxjh10.js} +2 -2
  140. package/dist/{chunk-b5afy6k9.js.map → chunk-q9mxjh10.js.map} +1 -1
  141. package/dist/{chunk-kzsjyvvc.js → chunk-qmcjh6de.js} +2 -2
  142. package/dist/{chunk-kzsjyvvc.js.map → chunk-qmcjh6de.js.map} +1 -1
  143. package/dist/{chunk-w3812s34.js → chunk-qy3s6pwz.js} +2 -2
  144. package/dist/{chunk-w3812s34.js.map → chunk-qy3s6pwz.js.map} +1 -1
  145. package/dist/{chunk-ykz38t0t.js → chunk-ravssmdy.js} +2 -2
  146. package/dist/{chunk-ykz38t0t.js.map → chunk-ravssmdy.js.map} +1 -1
  147. package/dist/{chunk-v8v5qfnh.js → chunk-rtb64x14.js} +3 -3
  148. package/dist/{chunk-v8v5qfnh.js.map → chunk-rtb64x14.js.map} +1 -1
  149. package/dist/{chunk-3j6s5bmx.js → chunk-rvdsaqdv.js} +1 -1
  150. package/dist/chunk-s0kns9q1.js +22 -0
  151. package/dist/chunk-s0kns9q1.js.map +21 -0
  152. package/dist/{chunk-skf89vrv.js → chunk-s2krqtwj.js} +2 -2
  153. package/dist/{chunk-skf89vrv.js.map → chunk-s2krqtwj.js.map} +1 -1
  154. package/dist/{chunk-75ewjc4a.js → chunk-s2y2b8tz.js} +2 -2
  155. package/dist/{chunk-75ewjc4a.js.map → chunk-s2y2b8tz.js.map} +1 -1
  156. package/dist/{chunk-675kzd7z.js → chunk-t8kzaxaa.js} +2 -2
  157. package/dist/{chunk-675kzd7z.js.map → chunk-t8kzaxaa.js.map} +1 -1
  158. package/dist/{chunk-a3g7y70h.js → chunk-v1eeh7a7.js} +3 -3
  159. package/dist/{chunk-a3g7y70h.js.map → chunk-v1eeh7a7.js.map} +1 -1
  160. package/dist/{chunk-mvkz22p4.js → chunk-v7nw1g2n.js} +2 -2
  161. package/dist/{chunk-mvkz22p4.js.map → chunk-v7nw1g2n.js.map} +1 -1
  162. package/dist/{chunk-f29pktad.js → chunk-v80890xx.js} +3 -3
  163. package/dist/{chunk-f29pktad.js.map → chunk-v80890xx.js.map} +1 -1
  164. package/dist/{chunk-jctb7v53.js → chunk-w4111j5d.js} +2 -2
  165. package/dist/{chunk-jctb7v53.js.map → chunk-w4111j5d.js.map} +1 -1
  166. package/dist/{chunk-121p4g9j.js → chunk-wat33wxh.js} +2 -2
  167. package/dist/{chunk-121p4g9j.js.map → chunk-wat33wxh.js.map} +1 -1
  168. package/dist/{chunk-9tr92nwy.js → chunk-x5vpjzpp.js} +2 -2
  169. package/dist/{chunk-9tr92nwy.js.map → chunk-x5vpjzpp.js.map} +1 -1
  170. package/dist/{chunk-zsfwcdqn.js → chunk-xe2cfmyb.js} +2 -2
  171. package/dist/{chunk-zsfwcdqn.js.map → chunk-xe2cfmyb.js.map} +1 -1
  172. package/dist/{chunk-w4z6x54b.js → chunk-ych1dv5q.js} +3 -3
  173. package/dist/{chunk-w4z6x54b.js.map → chunk-ych1dv5q.js.map} +1 -1
  174. package/dist/{chunk-96a1459v.js → chunk-yffm8nxa.js} +2 -2
  175. package/dist/{chunk-96a1459v.js.map → chunk-yffm8nxa.js.map} +1 -1
  176. package/dist/{chunk-rpyczdta.js → chunk-yg8se4vs.js} +3 -3
  177. package/dist/{chunk-rpyczdta.js.map → chunk-yg8se4vs.js.map} +1 -1
  178. package/dist/chunk-zbvdkh6q.js +10 -0
  179. package/dist/chunk-zbvdkh6q.js.map +44 -0
  180. package/dist/{chunk-szn2n976.js → chunk-zy5gxk1g.js} +2 -2
  181. package/dist/{chunk-szn2n976.js.map → chunk-zy5gxk1g.js.map} +1 -1
  182. package/dist/chunks/{ThemeProvider-CbOx8IRl.js → ThemeProvider-CS2a1snV.js} +27 -1
  183. package/dist/chunks/ThemeProvider-CS2a1snV.js.map +1 -0
  184. package/dist/client/Mutation.d.ts +7 -6
  185. package/dist/client/Mutation.d.ts.map +1 -1
  186. package/dist/client/MutationError.d.ts +53 -1
  187. package/dist/client/MutationError.d.ts.map +1 -1
  188. package/dist/client/QueryResource.d.ts +9 -0
  189. package/dist/client/QueryResource.d.ts.map +1 -1
  190. package/dist/client/auth/useEmailCode.d.ts +3 -3
  191. package/dist/client/auth/useForgotPassword.d.ts +1 -1
  192. package/dist/client/auth/useResetPassword.d.ts +1 -1
  193. package/dist/client/auth/useSignIn.d.ts +1 -1
  194. package/dist/client/auth/useSignOut.d.ts +1 -1
  195. package/dist/client/auth/useSignUp.d.ts +1 -1
  196. package/dist/client/index.d.ts +4 -2
  197. package/dist/client/index.d.ts.map +1 -1
  198. package/dist/client/index.js +182 -30
  199. package/dist/client/index.js.map +1 -1
  200. package/dist/client/useMutation.d.ts +18 -8
  201. package/dist/client/useMutation.d.ts.map +1 -1
  202. package/dist/client/useQuery.d.ts +9 -0
  203. package/dist/client/useQuery.d.ts.map +1 -1
  204. package/dist/client/useSetQueryData.d.ts +69 -0
  205. package/dist/client/useSetQueryData.d.ts.map +1 -0
  206. package/dist/config/index.js +1 -1
  207. package/dist/console/run.js +2 -2
  208. package/dist/console/run.js.map +1 -1
  209. package/dist/container/index.js +2 -2
  210. package/dist/container/index.js.map +1 -1
  211. package/dist/database/index.js +2 -2
  212. package/dist/database/index.js.map +1 -1
  213. package/dist/email/index.js +2 -2
  214. package/dist/email/index.js.map +1 -1
  215. package/dist/facades/Auth.d.ts +29 -2
  216. package/dist/facades/Auth.d.ts.map +1 -1
  217. package/dist/facades/Cache.d.ts +36 -0
  218. package/dist/facades/Cache.d.ts.map +1 -0
  219. package/dist/facades/RateLimiter.d.ts +16 -1
  220. package/dist/facades/RateLimiter.d.ts.map +1 -1
  221. package/dist/facades/Url.d.ts +12 -1
  222. package/dist/facades/Url.d.ts.map +1 -1
  223. package/dist/facades/index.d.ts +1 -0
  224. package/dist/facades/index.d.ts.map +1 -1
  225. package/dist/facades/index.js +2 -2
  226. package/dist/facades/index.js.map +1 -1
  227. package/dist/foundation/index.js +2 -2
  228. package/dist/foundation/index.js.map +1 -1
  229. package/dist/http/HttpRequest.d.ts +14 -0
  230. package/dist/http/HttpRequest.d.ts.map +1 -1
  231. package/dist/http/McpRouter.d.ts +121 -2
  232. package/dist/http/McpRouter.d.ts.map +1 -1
  233. package/dist/http/Metadata.d.ts.map +1 -1
  234. package/dist/http/RateLimitExceededError.d.ts +24 -0
  235. package/dist/http/RateLimitExceededError.d.ts.map +1 -0
  236. package/dist/http/RateLimitMiddleware.d.ts +2 -5
  237. package/dist/http/RateLimitMiddleware.d.ts.map +1 -1
  238. package/dist/http/index.d.ts +2 -1
  239. package/dist/http/index.d.ts.map +1 -1
  240. package/dist/http/index.js +2 -2
  241. package/dist/http/index.js.map +1 -1
  242. package/dist/http/refusal.d.ts +6 -1
  243. package/dist/http/refusal.d.ts.map +1 -1
  244. package/dist/http/requestContext.d.ts +3 -1
  245. package/dist/http/requestContext.d.ts.map +1 -1
  246. package/dist/http/requestState.d.ts +57 -0
  247. package/dist/http/requestState.d.ts.map +1 -0
  248. package/dist/i18n/dictionaryRuntime.js +2 -2
  249. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  250. package/dist/i18n/index.js +2 -2
  251. package/dist/i18n/index.js.map +1 -1
  252. package/dist/kernel/index.js +3 -3
  253. package/dist/kernel/index.js.map +3 -3
  254. package/dist/kernel/providers.d.ts +2 -2
  255. package/dist/kernel/providers.d.ts.map +1 -1
  256. package/dist/orm/index.js +2 -2
  257. package/dist/orm/index.js.map +1 -1
  258. package/dist/server/Server.d.ts.map +1 -1
  259. package/dist/server/health.d.ts +67 -0
  260. package/dist/server/health.d.ts.map +1 -0
  261. package/dist/server/index.d.ts +1 -0
  262. package/dist/server/index.d.ts.map +1 -1
  263. package/dist/server/index.js +2 -2
  264. package/dist/server/index.js.map +5 -4
  265. package/dist/server/shutdown.d.ts +3 -4
  266. package/dist/server/shutdown.d.ts.map +1 -1
  267. package/dist/services/cache/CacheManager.d.ts +115 -0
  268. package/dist/services/cache/CacheManager.d.ts.map +1 -0
  269. package/dist/services/cache/CacheServiceProvider.d.ts +5 -0
  270. package/dist/services/cache/CacheServiceProvider.d.ts.map +1 -0
  271. package/dist/services/cache/CacheStore.d.ts +26 -0
  272. package/dist/services/cache/CacheStore.d.ts.map +1 -0
  273. package/dist/services/cache/MemoryCacheStore.d.ts +36 -0
  274. package/dist/services/cache/MemoryCacheStore.d.ts.map +1 -0
  275. package/dist/services/cache/RedisCacheStore.d.ts +54 -0
  276. package/dist/services/cache/RedisCacheStore.d.ts.map +1 -0
  277. package/dist/services/cache/config.d.ts +35 -0
  278. package/dist/services/cache/config.d.ts.map +1 -0
  279. package/dist/services/features/gate.d.ts +11 -0
  280. package/dist/services/features/gate.d.ts.map +1 -0
  281. package/dist/services/index.d.ts +10 -4
  282. package/dist/services/index.d.ts.map +1 -1
  283. package/dist/services/index.js +9 -9
  284. package/dist/services/index.js.map +5 -5
  285. package/dist/services/logging/LogManager.d.ts +1 -0
  286. package/dist/services/logging/LogManager.d.ts.map +1 -1
  287. package/dist/services/logging/config.d.ts +23 -1
  288. package/dist/services/logging/config.d.ts.map +1 -1
  289. package/dist/services/logging/consoleSink.d.ts +25 -0
  290. package/dist/services/logging/consoleSink.d.ts.map +1 -0
  291. package/dist/services/mcp/McpRegistry.d.ts +106 -14
  292. package/dist/services/mcp/McpRegistry.d.ts.map +1 -1
  293. package/dist/services/mcp/http/McpHttpServer.d.ts +41 -2
  294. package/dist/services/mcp/http/McpHttpServer.d.ts.map +1 -1
  295. package/dist/services/mcp/toAgentTools.d.ts +21 -3
  296. package/dist/services/mcp/toAgentTools.d.ts.map +1 -1
  297. package/dist/services/queue/work.js +2 -2
  298. package/dist/services/queue/work.js.map +1 -1
  299. package/dist/services/rate-limiter/RateLimiter.d.ts +12 -0
  300. package/dist/services/rate-limiter/RateLimiter.d.ts.map +1 -1
  301. package/dist/services/router/globalMiddleware.d.ts +4 -3
  302. package/dist/services/router/globalMiddleware.d.ts.map +1 -1
  303. package/dist/stats/route-table.js +1 -1
  304. package/dist/support/index.js +2 -2
  305. package/dist/support/index.js.map +1 -1
  306. package/dist/testing/index.js +1 -1
  307. package/dist/utils/appOrigin.d.ts +19 -0
  308. package/dist/utils/appOrigin.d.ts.map +1 -0
  309. package/dist/vitest/index.js +1 -1
  310. package/package.json +1 -1
  311. package/skills/gemi-react-best-practices/SKILL.md +1 -1
  312. package/skills/gemi-react-best-practices/rules/query-mutate-over-refetch.md +14 -0
  313. package/skills/gemi-react-best-practices/rules/routing-middleware-dsl.md +2 -1
  314. package/dist/chunk-5j50q4g8.js +0 -57
  315. package/dist/chunk-70nnh0y7.js +0 -5
  316. package/dist/chunk-kc924zjz.js +0 -5
  317. package/dist/chunk-kc924zjz.js.map +0 -12
  318. package/dist/chunk-mqtfaqx5.js +0 -5
  319. package/dist/chunk-n0r5xyk2.js +0 -14
  320. package/dist/chunk-nnarmbjv.js.map +0 -10
  321. package/dist/chunk-pya4rqm2.js +0 -5
  322. package/dist/chunk-pya4rqm2.js.map +0 -12
  323. package/dist/chunk-zmf3vhex.js +0 -10
  324. package/dist/chunk-zmf3vhex.js.map +0 -43
  325. package/dist/chunks/ThemeProvider-CbOx8IRl.js.map +0 -1
  326. /package/dist/{chunk-wbg2tza5.js.map → chunk-3fyhd641.js.map} +0 -0
  327. /package/dist/{chunk-5e22tm7m.js.map → chunk-bghxdjqv.js.map} +0 -0
  328. /package/dist/{chunk-65s834td.js.map → chunk-c48gag78.js.map} +0 -0
  329. /package/dist/{chunk-j7v7dft7.js.map → chunk-k6gvbvyw.js.map} +0 -0
  330. /package/dist/{chunk-c4jnxmf2.js.map → chunk-p0ccxfkq.js.map} +0 -0
  331. /package/dist/{chunk-3j6s5bmx.js.map → chunk-rvdsaqdv.js.map} +0 -0
@@ -5,6 +5,6 @@
5
5
  "/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global global, define, Symbol, Reflect, Promise, SuppressedError, Iterator */\r\nvar __extends;\r\nvar __assign;\r\nvar __rest;\r\nvar __decorate;\r\nvar __param;\r\nvar __esDecorate;\r\nvar __runInitializers;\r\nvar __propKey;\r\nvar __setFunctionName;\r\nvar __metadata;\r\nvar __awaiter;\r\nvar __generator;\r\nvar __exportStar;\r\nvar __values;\r\nvar __read;\r\nvar __spread;\r\nvar __spreadArrays;\r\nvar __spreadArray;\r\nvar __await;\r\nvar __asyncGenerator;\r\nvar __asyncDelegator;\r\nvar __asyncValues;\r\nvar __makeTemplateObject;\r\nvar __importStar;\r\nvar __importDefault;\r\nvar __classPrivateFieldGet;\r\nvar __classPrivateFieldSet;\r\nvar __classPrivateFieldIn;\r\nvar __createBinding;\r\nvar __addDisposableResource;\r\nvar __disposeResources;\r\nvar __rewriteRelativeImportExtension;\r\n(function (factory) {\r\n var root = typeof global === \"object\" ? global : typeof self === \"object\" ? self : typeof this === \"object\" ? this : {};\r\n if (typeof define === \"function\" && define.amd) {\r\n define(\"tslib\", [\"exports\"], function (exports) { factory(createExporter(root, createExporter(exports))); });\r\n }\r\n else if (typeof module === \"object\" && typeof module.exports === \"object\") {\r\n factory(createExporter(root, createExporter(module.exports)));\r\n }\r\n else {\r\n factory(createExporter(root));\r\n }\r\n function createExporter(exports, previous) {\r\n if (exports !== root) {\r\n if (typeof Object.create === \"function\") {\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n }\r\n else {\r\n exports.__esModule = true;\r\n }\r\n }\r\n return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };\r\n }\r\n})\r\n(function (exporter) {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n\r\n __extends = function (d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n\r\n __assign = Object.assign || function (t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n\r\n __rest = function (s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n };\r\n\r\n __decorate = function (decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n };\r\n\r\n __param = function (paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n };\r\n\r\n __esDecorate = function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n };\r\n\r\n __runInitializers = function (thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n };\r\n\r\n __propKey = function (x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n };\r\n\r\n __setFunctionName = function (f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n };\r\n\r\n __metadata = function (metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n };\r\n\r\n __awaiter = function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n };\r\n\r\n __generator = function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n };\r\n\r\n __exportStar = function(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n };\r\n\r\n __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n }) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n });\r\n\r\n __values = function (o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n };\r\n\r\n __read = function (o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n };\r\n\r\n /** @deprecated */\r\n __spread = function () {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n };\r\n\r\n /** @deprecated */\r\n __spreadArrays = function () {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n };\r\n\r\n __spreadArray = function (to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n };\r\n\r\n __await = function (v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n };\r\n\r\n __asyncGenerator = function (thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n };\r\n\r\n __asyncDelegator = function (o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n };\r\n\r\n __asyncValues = function (o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n };\r\n\r\n __makeTemplateObject = function (cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n };\r\n\r\n var __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n }) : function(o, v) {\r\n o[\"default\"] = v;\r\n };\r\n\r\n var ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n };\r\n\r\n __importStar = function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n };\r\n\r\n __importDefault = function (mod) {\r\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\r\n };\r\n\r\n __classPrivateFieldGet = function (receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n };\r\n\r\n __classPrivateFieldSet = function (receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n };\r\n\r\n __classPrivateFieldIn = function (state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n };\r\n\r\n __addDisposableResource = function (env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n };\r\n\r\n var _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n };\r\n\r\n __disposeResources = function (env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n };\r\n\r\n __rewriteRelativeImportExtension = function (path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n };\r\n\r\n exporter(\"__extends\", __extends);\r\n exporter(\"__assign\", __assign);\r\n exporter(\"__rest\", __rest);\r\n exporter(\"__decorate\", __decorate);\r\n exporter(\"__param\", __param);\r\n exporter(\"__esDecorate\", __esDecorate);\r\n exporter(\"__runInitializers\", __runInitializers);\r\n exporter(\"__propKey\", __propKey);\r\n exporter(\"__setFunctionName\", __setFunctionName);\r\n exporter(\"__metadata\", __metadata);\r\n exporter(\"__awaiter\", __awaiter);\r\n exporter(\"__generator\", __generator);\r\n exporter(\"__exportStar\", __exportStar);\r\n exporter(\"__createBinding\", __createBinding);\r\n exporter(\"__values\", __values);\r\n exporter(\"__read\", __read);\r\n exporter(\"__spread\", __spread);\r\n exporter(\"__spreadArrays\", __spreadArrays);\r\n exporter(\"__spreadArray\", __spreadArray);\r\n exporter(\"__await\", __await);\r\n exporter(\"__asyncGenerator\", __asyncGenerator);\r\n exporter(\"__asyncDelegator\", __asyncDelegator);\r\n exporter(\"__asyncValues\", __asyncValues);\r\n exporter(\"__makeTemplateObject\", __makeTemplateObject);\r\n exporter(\"__importStar\", __importStar);\r\n exporter(\"__importDefault\", __importDefault);\r\n exporter(\"__classPrivateFieldGet\", __classPrivateFieldGet);\r\n exporter(\"__classPrivateFieldSet\", __classPrivateFieldSet);\r\n exporter(\"__classPrivateFieldIn\", __classPrivateFieldIn);\r\n exporter(\"__addDisposableResource\", __addDisposableResource);\r\n exporter(\"__disposeResources\", __disposeResources);\r\n exporter(\"__rewriteRelativeImportExtension\", __rewriteRelativeImportExtension);\r\n});\r\n\r\n0 && (module.exports = {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __exportStar: __exportStar,\r\n __createBinding: __createBinding,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n});\r\n"
6
6
  ],
7
7
  "mappings": ";6DAeA,IAAI,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,GACA,IACH,QAAS,CAAC,EAAS,CAChB,IAAI,EAAO,OAAO,SAAW,SAAW,OAAS,OAAO,OAAS,SAAW,KAAO,OAAO,OAAS,SAAW,KAAO,CAAC,EACtH,GAAI,OAAO,SAAW,YAAc,OAAO,IACvC,OAAO,QAAS,CAAC,SAAS,EAAG,QAAS,CAAC,EAAS,CAAE,EAAQ,EAAe,EAAM,EAAe,CAAO,CAAC,CAAC,EAAI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EACrC,EAAS,kBAAmB,CAAe,EAC3C,EAAS,yBAA0B,CAAsB,EACzD,EAAS,yBAA0B,CAAsB,EACzD,EAAS,wBAAyB,CAAqB,EACvD,EAAS,0BAA2B,CAAuB,EAC3D,EAAS,qBAAsB,EAAkB,EACjD,EAAS,mCAAoC,EAAgC,EAChF",
8
- "debugId": "8FBB82C89709EA3B64756E2164756E21",
8
+ "debugId": "2B0495105D006DEA64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ class K extends Error{lock;token;constructor(x,z,C="its lease ran out or another holder took it"){super(`Lost the lock "${x}" (token ${z}): ${C}.`);this.lock=x;this.token=z;this.name="LockLostError"}}var X=60000,Y=100,Z=(x)=>new Promise((z)=>setTimeout(z,x));class V{store;name;owner;token;ttl;lost;controller=new AbortController;deadline;expiryTimer;renewTimer;done=!1;constructor(x,z,C,B,G,J){this.store=x;this.name=z;this.owner=C;this.token=B;this.ttl=G;this.lost=this.controller.signal,this.deadline=J+G,this.armExpiry()}get expired(){return this.lost.aborted||performance.now()>=this.deadline}async extend(x=this.ttl){if(this.lost.aborted)return!1;let z=performance.now();if(!await this.store.extend(this.name,this.owner,this.token,x))return this.markLost(),!1;if(this.done)return!0;return this.deadline=Math.max(this.deadline,z+x),this.armExpiry(),!0}async isHeld(){if(this.lost.aborted)return!1;let x=await this.store.held(this.name,this.owner,this.token);if(!x)this.markLost();return x}async fence(x){if(this.lost.aborted)throw new K(this.name,this.token);try{return await this.store.fence(this.name,this.owner,this.token,x)}catch(z){if(z instanceof K)this.markLost();throw z}}async release(){if(this.stop(),this.lost.aborted)return!1;return this.store.release(this.name,this.owner,this.token)}startRenewing(){if(this.renewTimer||this.done)return;this.renewTimer=setInterval(()=>{this.extend().catch((x)=>{console.error(`[gemi] Could not renew the lock "${this.name}".`,x)})},Math.max(1,Math.floor(this.ttl/3))),this.renewTimer.unref?.()}markLost(x){if(this.stop(),!this.lost.aborted)this.controller.abort(new K(this.name,this.token,x))}stop(){this.done=!0,clearInterval(this.renewTimer),clearTimeout(this.expiryTimer),this.renewTimer=void 0,this.expiryTimer=void 0}armExpiry(){clearTimeout(this.expiryTimer),this.expiryTimer=setTimeout(()=>this.markLost("its lease ran out before it was renewed"),Math.max(0,this.deadline-performance.now())),this.expiryTimer.unref?.()}}class ${store;static token="locks";constructor(x){this.store=x}async acquire(x,z={}){let C=z.ttl??X;if(!(C>0))throw Error(`A lock's ttl must be a positive number of milliseconds; got ${C}.`);let B=Bun.randomUUIDv7(),G=performance.now()+Math.max(0,z.wait??0);for(;;){let J=performance.now(),M=await this.store.acquire(x,B,C);if(M!==null){let Q=new V(this.store,x,B,M,C,J);if(z.renew)Q.startRenewing();return Q}let O=G-performance.now();if(O<=0)return null;await Z(Math.min(Y,O))}}async run(x,z,C){let B=await this.acquire(x,{...z,renew:z.renew??!0});if(!B)return{acquired:!1};let G;try{G=await C(B)}catch(J){throw await B.release().catch(()=>{}),J}if(B.expired)throw B.markLost(),B.lost.reason;return await B.release(),{acquired:!0,value:G}}}var j={ms:1,s:1000,m:60000,h:3600000,d:86400000,w:604800000};function P(x){if(typeof x==="number"){if(!Number.isFinite(x)||x<0)throw TypeError(`A duration is 0 or more milliseconds; got ${x}.`);return Math.round(x)}let z=/^\s*(\d+(?:\.\d+)?)\s*(ms|s|m|h|d|w)\s*$/.exec(String(x));if(!z)throw TypeError(`"${String(x)}" is not a duration. Use milliseconds, or a number and one of ms, s, m, h, d, w ("30s", "7d").`);return Math.round(Number(z[1])*j[z[2]])}
3
+ export{P as kj,K as lj,V as mj,$ as nj};
4
+
5
+ //# debugId=249E5D68F51CEA2364756E2164756E21
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../services/lock/LockStore.ts", "../services/lock/LockManager.ts"],
3
+ "sources": ["../services/lock/LockStore.ts", "../services/lock/LockManager.ts", "../services/queue/workflow/duration.ts"],
4
4
  "sourcesContent": [
5
5
  "/**\n * Where locks are kept: one record per lock name, with the current holder, a\n * fencing token and a lease.\n *\n * ### The model\n *\n * A lock is held by an **owner** (a random id per acquisition, or a job's id)\n * until its **lease** runs out or the owner releases it. Every successful\n * `acquire` raises the name's **token** by one, so tokens only grow per name and\n * a newer holder always has a larger one than any older holder. A store never\n * forgets a name on release, which is what keeps the token growing; `prune`\n * (on a store that has it) removes names idle for long enough.\n *\n * A lease that runs out is lost, even if nobody has taken the lock since:\n * `extend`, `held` and `fence` all refuse it. That is the rule that makes the\n * token mean something. A holder whose process stalled past its lease cannot\n * renew its way back in after another process may have started the same work.\n *\n * ### Time\n *\n * Durations cross this interface as relative milliseconds, as they do for\n * `QueueDriver`, so a store shared between machines can measure every lease on\n * one clock, its own.\n */\nexport interface LockStore {\n /**\n * Takes `name` for `owner` for `ttlMs`, if nobody holds it or the holder's\n * lease ran out, and resolves to the new fencing token. `null` when it is\n * held. Two concurrent calls, from any processes sharing the store, never\n * both succeed.\n */\n acquire(name: string, owner: string, ttlMs: number): Promise<number | null>;\n\n /**\n * Renews a lease to `ttlMs` from now, and resolves to whether `owner` still\n * held it with `token`. A lease that already ran out is not renewed.\n */\n extend(name: string, owner: string, token: number, ttlMs: number): Promise<boolean>;\n\n /**\n * Ends a hold, and resolves to whether `owner` held it (with `token`, when\n * given) and its lease had not run out. Releasing a lock someone else now\n * holds does nothing.\n */\n release(name: string, owner: string, token?: number): Promise<boolean>;\n\n /** The current holder, or `null` when the lock is free or its lease ran out. */\n holder(name: string): Promise<{ owner: string; token: number } | null>;\n\n /** Whether `owner` still holds `name` with `token`, its lease running. */\n held(name: string, owner: string, token: number): Promise<boolean>;\n\n /**\n * Raises a counter kept under `name` to `value` if it is below it, and\n * resolves to whether it did. For \"once per tick across instances\": every\n * instance advances to the tick's number and only the first one gets `true`.\n * A name used here must not also be used with `acquire`.\n */\n advance(name: string, value: number): Promise<boolean>;\n\n /**\n * Runs `fn` only if `owner` still holds `name` with `token`, and keeps the\n * lock from changing hands until `fn` settles. Rejects with `LockLostError`\n * when the hold is gone. On the database store this is a transaction that\n * locks the lock's row first, so writes `fn` makes through the ORM on the\n * same connection commit only while the hold is current, and a new holder's\n * `acquire` waits for that commit.\n */\n fence<T>(name: string, owner: string, token: number, fn: () => Promise<T>): Promise<T>;\n\n /**\n * Counts one hit against a fixed window kept under `name`: allowed when\n * fewer than `limit` were counted in the current window, which starts at the\n * first hit after the last one ended and lasts `windowMs`. A refused hit is\n * not counted. `resetInMs` is how long until the window ends. A name used\n * here must not also be used with `acquire` or `advance`.\n */\n hit(\n name: string,\n limit: number,\n windowMs: number,\n ): Promise<{ allowed: boolean; resetInMs: number }>;\n\n /** Takes back one counted hit from the current window, if it has one. */\n refund(name: string): Promise<void>;\n}\n\n/** The hold on a lock ended before the work it guarded did. */\nexport class LockLostError extends Error {\n constructor(\n readonly lock: string,\n readonly token: number,\n detail = \"its lease ran out or another holder took it\",\n ) {\n super(`Lost the lock \"${lock}\" (token ${token}): ${detail}.`);\n this.name = \"LockLostError\";\n }\n}\n",
6
- "import { LockLostError, type LockStore } from \"./LockStore\";\n\nexport type AcquireOptions = {\n /** The lease, in milliseconds. Default one minute. */\n ttl?: number;\n /**\n * How long to keep trying when the lock is held, in milliseconds. Default\n * `0`: one try.\n */\n wait?: number;\n /**\n * Renew the lease every third of `ttl` until the lock is released. Default\n * `true` for `run`, `false` for `acquire`, whose caller may never release.\n */\n renew?: boolean;\n};\n\nexport type LockRunResult<T> = { acquired: true; value: T } | { acquired: false };\n\nconst DEFAULT_TTL = 60_000;\nconst WAIT_STEP = 100;\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * One hold on a lock, from a successful `acquire` until `release` or the end\n * of its lease.\n *\n * `token` is the fencing token: it grows with each new holder of the name, so\n * a write that records it can be refused when an older holder tries to make\n * it late. `fence` does that refusal for writes to the application's own\n * database.\n *\n * `lost` aborts when the hold is known to be gone: a renewal found another\n * holder, or the lease ran out by this process's clock without a successful\n * renewal. The local deadline is measured from just before each request that\n * set the lease, so it always falls before the store's own expiry.\n */\nexport class HeldLock {\n readonly lost: AbortSignal;\n private readonly controller = new AbortController();\n private deadline: number;\n private expiryTimer: ReturnType<typeof setTimeout> | undefined;\n private renewTimer: ReturnType<typeof setInterval> | undefined;\n private done = false;\n\n constructor(\n private readonly store: LockStore,\n readonly name: string,\n readonly owner: string,\n readonly token: number,\n readonly ttl: number,\n requestedAt: number,\n ) {\n this.lost = this.controller.signal;\n this.deadline = requestedAt + ttl;\n this.armExpiry();\n }\n\n /** Whether the lease has run out by this process's clock, or the hold was lost. */\n get expired(): boolean {\n return this.lost.aborted || performance.now() >= this.deadline;\n }\n\n /** Renews the lease. `false`, and `lost` aborted, when the hold was already gone. */\n async extend(ttl = this.ttl): Promise<boolean> {\n if (this.lost.aborted) return false;\n const requestedAt = performance.now();\n const ok = await this.store.extend(this.name, this.owner, this.token, ttl);\n if (!ok) {\n this.markLost();\n return false;\n }\n if (this.done) return true;\n this.deadline = Math.max(this.deadline, requestedAt + ttl);\n this.armExpiry();\n return true;\n }\n\n /** Asks the store whether this hold is still current. */\n async isHeld(): Promise<boolean> {\n if (this.lost.aborted) return false;\n const held = await this.store.held(this.name, this.owner, this.token);\n if (!held) this.markLost();\n return held;\n }\n\n /**\n * Runs `fn` only while this hold is current, and keeps the lock from\n * changing hands until it settles; rejects with `LockLostError` otherwise.\n * On the database store `fn` runs in a transaction on the store's\n * connection, so ORM writes inside it commit only if the hold was current.\n */\n async fence<T>(fn: () => Promise<T>): Promise<T> {\n if (this.lost.aborted) throw new LockLostError(this.name, this.token);\n try {\n return await this.store.fence(this.name, this.owner, this.token, fn);\n } catch (error) {\n if (error instanceof LockLostError) this.markLost();\n throw error;\n }\n }\n\n /** Ends the hold. `false` when it had already been lost. */\n async release(): Promise<boolean> {\n this.stop();\n if (this.lost.aborted) return false;\n return this.store.release(this.name, this.owner, this.token);\n }\n\n /** Renews every third of the lease until `release`. */\n startRenewing() {\n if (this.renewTimer || this.done) return;\n this.renewTimer = setInterval(\n () => {\n this.extend().catch((error) => {\n // Not lost yet: the local deadline still decides, so a store that\n // comes back within the lease keeps the hold.\n console.error(`[gemi] Could not renew the lock \"${this.name}\".`, error);\n });\n },\n Math.max(1, Math.floor(this.ttl / 3)),\n );\n this.renewTimer.unref?.();\n }\n\n /** @internal Marks the hold as gone and stops every timer. */\n markLost(detail?: string) {\n this.stop();\n if (!this.lost.aborted) {\n this.controller.abort(new LockLostError(this.name, this.token, detail));\n }\n }\n\n private stop() {\n this.done = true;\n clearInterval(this.renewTimer);\n clearTimeout(this.expiryTimer);\n this.renewTimer = undefined;\n this.expiryTimer = undefined;\n }\n\n private armExpiry() {\n clearTimeout(this.expiryTimer);\n this.expiryTimer = setTimeout(\n () => this.markLost(\"its lease ran out before it was renewed\"),\n Math.max(0, this.deadline - performance.now()),\n );\n this.expiryTimer.unref?.();\n }\n}\n\n/**\n * Named locks with leases and fencing tokens, over a `LockStore`. The queue\n * builds one over its own storage (`app(QueueManager).locks`), so with the\n * database driver the locks hold across every process sharing the database.\n * The `Lock` facade fronts it.\n */\nexport class LockManager {\n static token = \"locks\";\n\n constructor(readonly store: LockStore) {}\n\n /** Takes the lock, or resolves `null` if it is held (after `wait`, when given). */\n async acquire(name: string, options: AcquireOptions = {}): Promise<HeldLock | null> {\n const ttl = options.ttl ?? DEFAULT_TTL;\n if (!(ttl > 0))\n throw new Error(`A lock's ttl must be a positive number of milliseconds; got ${ttl}.`);\n const owner = Bun.randomUUIDv7();\n const giveUpAt = performance.now() + Math.max(0, options.wait ?? 0);\n for (;;) {\n const requestedAt = performance.now();\n const token = await this.store.acquire(name, owner, ttl);\n if (token !== null) {\n const lock = new HeldLock(this.store, name, owner, token, ttl, requestedAt);\n if (options.renew) lock.startRenewing();\n return lock;\n }\n const left = giveUpAt - performance.now();\n if (left <= 0) return null;\n await sleep(Math.min(WAIT_STEP, left));\n }\n }\n\n /**\n * Runs `fn` while holding the lock, renewing the lease as it runs, and\n * releases it after. `{ acquired: false }` when the lock was held.\n *\n * If the hold is lost while `fn` runs, `lock.lost` aborts, and once `fn`\n * settles this rejects with `LockLostError` instead of resolving: the caller\n * must not treat work done without the lock as done under it.\n */\n async run<T>(\n name: string,\n options: AcquireOptions,\n fn: (lock: HeldLock) => Promise<T> | T,\n ): Promise<LockRunResult<T>> {\n const lock = await this.acquire(name, { ...options, renew: options.renew ?? true });\n if (!lock) return { acquired: false };\n\n let value: T;\n try {\n value = await fn(lock);\n } catch (error) {\n await lock.release().catch(() => {});\n throw error;\n }\n if (lock.expired) {\n lock.markLost();\n throw lock.lost.reason as LockLostError;\n }\n await lock.release();\n return { acquired: true, value };\n }\n}\n"
6
+ "import { LockLostError, type LockStore } from \"./LockStore\";\n\nexport type AcquireOptions = {\n /** The lease, in milliseconds. Default one minute. */\n ttl?: number;\n /**\n * How long to keep trying when the lock is held, in milliseconds. Default\n * `0`: one try.\n */\n wait?: number;\n /**\n * Renew the lease every third of `ttl` until the lock is released. Default\n * `true` for `run`, `false` for `acquire`, whose caller may never release.\n */\n renew?: boolean;\n};\n\nexport type LockRunResult<T> = { acquired: true; value: T } | { acquired: false };\n\nconst DEFAULT_TTL = 60_000;\nconst WAIT_STEP = 100;\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * One hold on a lock, from a successful `acquire` until `release` or the end\n * of its lease.\n *\n * `token` is the fencing token: it grows with each new holder of the name, so\n * a write that records it can be refused when an older holder tries to make\n * it late. `fence` does that refusal for writes to the application's own\n * database.\n *\n * `lost` aborts when the hold is known to be gone: a renewal found another\n * holder, or the lease ran out by this process's clock without a successful\n * renewal. The local deadline is measured from just before each request that\n * set the lease, so it always falls before the store's own expiry.\n */\nexport class HeldLock {\n readonly lost: AbortSignal;\n private readonly controller = new AbortController();\n private deadline: number;\n private expiryTimer: ReturnType<typeof setTimeout> | undefined;\n private renewTimer: ReturnType<typeof setInterval> | undefined;\n private done = false;\n\n constructor(\n private readonly store: LockStore,\n readonly name: string,\n readonly owner: string,\n readonly token: number,\n readonly ttl: number,\n requestedAt: number,\n ) {\n this.lost = this.controller.signal;\n this.deadline = requestedAt + ttl;\n this.armExpiry();\n }\n\n /** Whether the lease has run out by this process's clock, or the hold was lost. */\n get expired(): boolean {\n return this.lost.aborted || performance.now() >= this.deadline;\n }\n\n /** Renews the lease. `false`, and `lost` aborted, when the hold was already gone. */\n async extend(ttl = this.ttl): Promise<boolean> {\n if (this.lost.aborted) return false;\n const requestedAt = performance.now();\n const ok = await this.store.extend(this.name, this.owner, this.token, ttl);\n if (!ok) {\n this.markLost();\n return false;\n }\n if (this.done) return true;\n this.deadline = Math.max(this.deadline, requestedAt + ttl);\n this.armExpiry();\n return true;\n }\n\n /** Asks the store whether this hold is still current. */\n async isHeld(): Promise<boolean> {\n if (this.lost.aborted) return false;\n const held = await this.store.held(this.name, this.owner, this.token);\n if (!held) this.markLost();\n return held;\n }\n\n /**\n * Runs `fn` only while this hold is current, and keeps the lock from\n * changing hands until it settles; rejects with `LockLostError` otherwise.\n * On the database store `fn` runs in a transaction on the store's\n * connection, so ORM writes inside it commit only if the hold was current.\n */\n async fence<T>(fn: () => Promise<T>): Promise<T> {\n if (this.lost.aborted) throw new LockLostError(this.name, this.token);\n try {\n return await this.store.fence(this.name, this.owner, this.token, fn);\n } catch (error) {\n if (error instanceof LockLostError) this.markLost();\n throw error;\n }\n }\n\n /** Ends the hold. `false` when it had already been lost. */\n async release(): Promise<boolean> {\n this.stop();\n if (this.lost.aborted) return false;\n return this.store.release(this.name, this.owner, this.token);\n }\n\n /** Renews every third of the lease until `release`. */\n startRenewing() {\n if (this.renewTimer || this.done) return;\n this.renewTimer = setInterval(\n () => {\n this.extend().catch((error) => {\n // Not lost yet: the local deadline still decides, so a store that\n // comes back within the lease keeps the hold.\n console.error(`[gemi] Could not renew the lock \"${this.name}\".`, error);\n });\n },\n Math.max(1, Math.floor(this.ttl / 3)),\n );\n this.renewTimer.unref?.();\n }\n\n /** @internal Marks the hold as gone and stops every timer. */\n markLost(detail?: string) {\n this.stop();\n if (!this.lost.aborted) {\n this.controller.abort(new LockLostError(this.name, this.token, detail));\n }\n }\n\n private stop() {\n this.done = true;\n clearInterval(this.renewTimer);\n clearTimeout(this.expiryTimer);\n this.renewTimer = undefined;\n this.expiryTimer = undefined;\n }\n\n private armExpiry() {\n clearTimeout(this.expiryTimer);\n this.expiryTimer = setTimeout(\n () => this.markLost(\"its lease ran out before it was renewed\"),\n Math.max(0, this.deadline - performance.now()),\n );\n this.expiryTimer.unref?.();\n }\n}\n\n/**\n * Named locks with leases and fencing tokens, over a `LockStore`. The queue\n * builds one over its own storage (`app(QueueManager).locks`), so with the\n * database driver the locks hold across every process sharing the database.\n * The `Lock` facade fronts it.\n */\nexport class LockManager {\n static token = \"locks\";\n\n constructor(readonly store: LockStore) {}\n\n /** Takes the lock, or resolves `null` if it is held (after `wait`, when given). */\n async acquire(name: string, options: AcquireOptions = {}): Promise<HeldLock | null> {\n const ttl = options.ttl ?? DEFAULT_TTL;\n if (!(ttl > 0))\n throw new Error(`A lock's ttl must be a positive number of milliseconds; got ${ttl}.`);\n const owner = Bun.randomUUIDv7();\n const giveUpAt = performance.now() + Math.max(0, options.wait ?? 0);\n for (;;) {\n const requestedAt = performance.now();\n const token = await this.store.acquire(name, owner, ttl);\n if (token !== null) {\n const lock = new HeldLock(this.store, name, owner, token, ttl, requestedAt);\n if (options.renew) lock.startRenewing();\n return lock;\n }\n const left = giveUpAt - performance.now();\n if (left <= 0) return null;\n await sleep(Math.min(WAIT_STEP, left));\n }\n }\n\n /**\n * Runs `fn` while holding the lock, renewing the lease as it runs, and\n * releases it after. `{ acquired: false }` when the lock was held.\n *\n * If the hold is lost while `fn` runs, `lock.lost` aborts, and once `fn`\n * settles this rejects with `LockLostError` instead of resolving: the caller\n * must not treat work done without the lock as done under it.\n */\n async run<T>(\n name: string,\n options: AcquireOptions,\n fn: (lock: HeldLock) => Promise<T> | T,\n ): Promise<LockRunResult<T>> {\n const lock = await this.acquire(name, { ...options, renew: options.renew ?? true });\n if (!lock) return { acquired: false };\n\n let value: T;\n try {\n value = await fn(lock);\n } catch (error) {\n await lock.release().catch(() => {});\n throw error;\n }\n if (lock.expired) {\n lock.markLost();\n throw lock.lost.reason as LockLostError;\n }\n await lock.release();\n return { acquired: true, value };\n }\n}\n",
7
+ "/**\n * A length of time: milliseconds as a number, or a number and a unit, such as\n * `\"500ms\"`, `\"30s\"`, `\"5m\"`, `\"2h\"`, `\"7d\"` or `\"1w\"`.\n */\nexport type Duration = number | `${number}${\"ms\" | \"s\" | \"m\" | \"h\" | \"d\" | \"w\"}`;\n\nconst UNITS: Record<string, number> = {\n ms: 1,\n s: 1000,\n m: 60_000,\n h: 60 * 60_000,\n d: 24 * 60 * 60_000,\n w: 7 * 24 * 60 * 60_000,\n};\n\n/** A `Duration` in milliseconds. Throws for anything else, on the caller's stack. */\nexport function toMilliseconds(duration: Duration): number {\n if (typeof duration === \"number\") {\n if (!Number.isFinite(duration) || duration < 0) {\n throw new TypeError(`A duration is 0 or more milliseconds; got ${duration}.`);\n }\n return Math.round(duration);\n }\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*(ms|s|m|h|d|w)\\s*$/.exec(String(duration));\n if (!match) {\n throw new TypeError(\n `\"${String(duration)}\" is not a duration. Use milliseconds, or a number and ` +\n `one of ms, s, m, h, d, w (\"30s\", \"7d\").`,\n );\n }\n return Math.round(Number(match[1]) * UNITS[match[2]!]!);\n}\n"
7
8
  ],
8
- "mappings": ";AAwFO,MAAM,UAAsB,KAAM,CAE5B,KACA,MAFX,WAAW,CACA,EACA,EACT,EAAS,8CACT,CACA,MAAM,kBAAkB,aAAgB,OAAW,IAAS,EAJnD,YACA,aAIT,KAAK,KAAO,gBAEhB,CC9EA,IAAM,EAAc,MACd,EAAY,IAEZ,EAAQ,CAAC,IAAe,IAAI,QAAQ,CAAC,IAAY,WAAW,EAAS,CAAE,CAAC,EAgBvE,MAAM,CAAS,CASD,MACR,KACA,MACA,MACA,IAZF,KACQ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O,CAEd,MADA,MAAM,EAAK,QAAQ,EAAE,MAAM,IAAM,EAAE,EAC7B,EAER,GAAI,EAAK,QAEP,MADA,EAAK,SAAS,EACR,EAAK,KAAK,OAGlB,OADA,MAAM,EAAK,QAAQ,EACZ,CAAE,SAAU,GAAM,OAAM,EAEnC,CChNA,IAAM,EAAgC,CACpC,GAAI,EACJ,EAAG,KACH,EAAG,MACH,EAAG,QACH,EAAG,SACH,EAAG,SACL,EAGO,SAAS,CAAc,CAAC,EAA4B,CACzD,GAAI,OAAO,IAAa,SAAU,CAChC,GAAI,CAAC,OAAO,SAAS,CAAQ,GAAK,EAAW,EAC3C,MAAU,UAAU,6CAA6C,IAAW,EAE9E,OAAO,KAAK,MAAM,CAAQ,EAE5B,IAAM,EAAQ,2CAA2C,KAAK,OAAO,CAAQ,CAAC,EAC9E,GAAI,CAAC,EACH,MAAU,UACR,IAAI,OAAO,CAAQ,iGAErB,EAEF,OAAO,KAAK,MAAM,OAAO,EAAM,EAAE,EAAI,EAAM,EAAM,GAAK",
10
+ "debugId": "249E5D68F51CEA2364756E2164756E21",
10
11
  "names": []
11
12
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ac as R}from"./chunk-675kzd7z.js";import{Gc as E,Ic as Q,Rc as S}from"./chunk-92sk56n0.js";import{oj as K}from"./chunk-rpyczdta.js";import{Ej as A,Fj as $,Gj as D}from"./chunk-nkzmk7v3.js";class j extends Error{code;constructor(q,z=1){super(q);this.code=z;this.name="CommandFailed"}}class J{static commandName="unset";static description="";static args=[];static options=[];run(q){}}function p(q){return q}function C(){return{commands:[],commandsDir:"app/commands"}}var I=Symbol.for("gemi.console.builder");function k(q){if(q.trim()==="")throw Error("A command name cannot be empty.");if(/[{}]/.test(q)||/\s/.test(q))throw Error(`Invalid command name ${JSON.stringify(q)}. gemi does not parse a signature string; the name is the whole of it. Declare arguments with .arg() and flags with .option():
2
+ import{od as R}from"./chunk-t8kzaxaa.js";import{Ed as S,Jd as E,vd as Q}from"./chunk-b2pdqxj3.js";import{sk as K}from"./chunk-yg8se4vs.js";import{Jk as A,Kk as $,Lk as D}from"./chunk-9x0pgkns.js";class j extends Error{code;constructor(q,z=1){super(q);this.code=z;this.name="CommandFailed"}}class J{static commandName="unset";static description="";static args=[];static options=[];run(q){}}function p(q){return q}function C(){return{commands:[],commandsDir:"app/commands"}}var I=Symbol.for("gemi.console.builder");function k(q){if(q.trim()==="")throw Error("A command name cannot be empty.");if(/[{}]/.test(q)||/\s/.test(q))throw Error(`Invalid command name ${JSON.stringify(q)}. gemi does not parse a signature string; the name is the whole of it. Declare arguments with .arg() and flags with .option():
3
3
 
4
4
  defineCommand("mail:send")
5
5
  .arg("user", { required: true })
@@ -14,6 +14,6 @@ import{Ac as R}from"./chunk-675kzd7z.js";import{Gc as E,Ic as Q,Rc as S}from"./c
14
14
  static event = UserRegistered;
15
15
 
16
16
  If this is an abstract base its subclasses extend, move it out of the `+"listeners directory \u2014 the walk excludes gemi's `Listener` and "+"nothing else, so a base sitting beside its subclasses is registered and run like one of them.")}function v(q){for(let z of q){if(Object.getOwnPropertyDescriptor(z,"name")?.writable)continue;console.warn(`Event listener ${z.name} does not declare \`static name\`, so it is registered under its class name, which a production build renames. Nothing reads that name across a build boundary while the `+"listener is sync, which is why this is a warning \u2014 but adding "+`\`queued = true\` to it is refused at boot for the same reason, because the queue's key is that string. Add: static name = "${z.name}";`)}}function u(q){let z=new Set;for(let{event:F}of q){if(z.has(F))continue;if(Object.getOwnPropertyDescriptor(F,"name")?.writable)continue;z.add(F),console.warn(`Event ${F.name} does not declare \`static name\`, so it is dispatched under its class name. A production build minifies the code that dispatches it and renames the class, while discovery reads `+"the listener's copy from source and does not \u2014 so the dispatch would "+`reach no listener in production and nowhere else. Add: static name = "${F.name}";`)}}
17
- export{j as kc,J as lc,p as mc,C as nc,c as oc,o as pc,T as qc,i as rc,B as sc,U as tc,W as uc,Sq as vc,Zq as wc,_q as xc,Iq as yc,Uq as zc};
17
+ export{j as _c,J as $c,p as ad,C as bd,c as cd,o as dd,T as ed,i as fd,B as gd,U as hd,W as id,Sq as jd,Zq as kd,_q as ld,Iq as md,Uq as nd};
18
18
 
19
- //# debugId=3BA8561FCA88054C64756E2164756E21
19
+ //# debugId=C96D436D786F6FF864756E2164756E21
@@ -12,6 +12,6 @@
12
12
  "import { existsSync } from \"node:fs\";\nimport { dirname, isAbsolute, join } from \"node:path\";\n\nimport {\n discoverClasses,\n DiscoveryError,\n projectRoot,\n} from \"../support/discover\";\nimport { Command, type CommandClass } from \"../console/Command\";\nimport { commandConfigDefaults } from \"../console/config\";\nimport { isUnfinishedBuilder } from \"../console/builder\";\nimport { CronJob } from \"./cron/CronJob\";\nimport { scheduleConfigDefaults } from \"./cron/config\";\nimport { eventConfigDefaults } from \"./events/config\";\nimport type { EventClass } from \"./events/Event\";\nimport { Listener, type ListenerClass } from \"./events/Listener\";\nimport { Job } from \"./queue/Job\";\nimport { queueConfigDefaults } from \"./queue/config\";\nimport { Workflow, type WorkflowClass } from \"./queue/workflow/Workflow\";\n\n/**\n * Reading an application's jobs off the filesystem, for the two subsystems that\n * were asking every app to write its job list twice.\n *\n * Both functions here are the same call to `discoverClasses` with a different\n * base class, which is deliberate: one walk, one set of skip rules, one answer\n * to \"what does this app have\". They are exported from `gemi/services` rather\n * than kept private to the providers because the list stopped being something\n * an app could import — a test that used to walk the exported `jobs` array\n * needs somewhere to ask the same question, and so does a script.\n *\n * What the providers add on top of these is the decision of *whether* to ask,\n * which is the config's to make and not this file's.\n */\n\n/**\n * A directory the app named, resolved the way the app meant it.\n *\n * Relative paths hang off the project root rather than `process.cwd()` at the\n * moment of the call, because a config slice saying `app/jobs` means the app's\n * `app/jobs` and not whatever directory somebody happened to launch a script\n * from. Absolute paths are taken as given, which is what makes these callable\n * from a test that has no project around it.\n */\nfunction resolveDir(dir: string): string {\n return isAbsolute(dir) ? dir : join(projectRoot(), dir);\n}\n\n/**\n * Says something when the directory is missing *and so is the tree it lives in*.\n *\n * A missing directory has two readings and they want opposite responses. An app\n * that has never written a cron job has no `app/cron`, and warning about that on\n * every boot for the rest of its life is noise — the answer \"you have no cron\n * jobs\" is correct and uninteresting. But a deploy that ships `dist/` and\n * `node_modules/` without the source has no `app/cron` *and no `app/`*, and\n * there discovery quietly returns nothing while the app very much does have\n * jobs: the exact silence #322 and #323 exist to remove, reintroduced one layer\n * down and in production only.\n *\n * The parent directory is what tells them apart. If neither the directory nor\n * the one above it is there, the tree this was pointed into is not there\n * either, and that is worth a sentence.\n */\nfunction warnIfSourceIsMissing(\n resolved: string,\n subject: string,\n slice: string,\n) {\n if (existsSync(resolved) || existsSync(dirname(resolved))) return;\n\n console.warn(\n `No ${subject} were discovered: neither ${resolved} nor the directory ` +\n `above it exists, so this process cannot see the application's source. ` +\n `If this is a deploy that ships only the build output, list the classes ` +\n `explicitly in app/config/${slice}.ts so they travel with it.`,\n );\n}\n\n/**\n * The `Job` subclasses under `dir`, defaulting to the config slice's `app/jobs`.\n *\n * This is what a `queue` config slice with no `jobs` key resolves to. Call it\n * directly to ask the question a test used to answer by importing the array:\n * every job this application would register, in the order it would register\n * them.\n *\n * Every file underneath is imported, so calling this runs the app's job modules\n * — the cost `discoverClasses` documents at length, paid once per call.\n */\nexport async function discoverJobs(\n dir: string = queueConfigDefaults().jobsDir,\n): Promise<Array<new () => Job>> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"queue jobs\", \"queue\");\n const jobs = await discoverClasses(resolved, Job);\n warnIfNameWillNotSurviveTheBuild(jobs);\n return jobs;\n}\n\n/**\n * The `Workflow` subclasses under `dir`, defaulting to the queue slice's\n * `app/workflows`: what a `queue` slice with no `workflows` key resolves to.\n * A missing directory is no workflows, said nothing about unless the tree\n * above it is missing too.\n */\nexport async function discoverWorkflows(\n dir: string = queueConfigDefaults().workflowsDir,\n): Promise<WorkflowClass[]> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"workflows\", \"queue\");\n const workflows = (await discoverClasses(resolved, Workflow)) as WorkflowClass[];\n for (const workflow of workflows) {\n if (Object.getOwnPropertyDescriptor(workflow, \"name\")?.writable) continue;\n console.warn(\n `Workflow ${workflow.name} does not declare \\`static name\\`. A workflow ` +\n `is stored under its name, and a production build renames the class. ` +\n `Add: static name = \"${workflow.name}\";`,\n );\n }\n return workflows;\n}\n\n/**\n * Says something about a discovered job that never declared `static name`.\n *\n * This is the one hazard discovery introduces rather than removes, and it is\n * production-only. `gemi build` minifies the server entry, and app code\n * reachable from it — a controller, and every job class that controller\n * imports to dispatch — is bundled and minified with it. Minification renames\n * the class binding, and a class's implicit `.name` is that binding: a\n * `TestJob` in the bundle reports `\"D\"`. Discovery, meanwhile, imports\n * `app/jobs/TestJob.ts` from source at runtime, where it is still `\"TestJob\"`.\n * The queue is keyed by that name, so the two halves stop agreeing and the\n * dispatch is dropped — in production, and only there.\n *\n * A declared `static name = \"TestJob\"` is a string literal, which survives\n * minification intact, and the two halves agree again. `docs/jobs-and-queues.md`\n * has always called it required; before discovery an app could get away without\n * it, because the explicit `jobs` array was bundled too and both sides were\n * wrong in the same way.\n *\n * The check is exact rather than a guess: a `static name = \"...\"` class field\n * defines a *writable* own property, while the implicit class name is\n * non-writable. Cron is unaffected — `CronJob.name` is an instance field\n * holding a string literal, not the class binding.\n */\nfunction warnIfNameWillNotSurviveTheBuild(jobs: Array<new () => Job>) {\n for (const job of jobs) {\n if (Object.getOwnPropertyDescriptor(job, \"name\")?.writable) continue;\n\n console.warn(\n `Queued job ${job.name} does not declare \\`static name\\`, so it is ` +\n `registered under its class name. A production build minifies the ` +\n `class that dispatches it and renames it, while discovery reads this ` +\n `file from source and does not — so the dispatch would be dropped in ` +\n `production and nowhere else. Add: static name = \"${job.name}\";`,\n );\n }\n}\n\n/**\n * The `CronJob` subclasses under `dir`, defaulting to the config slice's\n * `app/cron`.\n *\n * This is what a `schedule` config slice with no `jobs` key resolves to. Call it\n * directly to ask the question a test used to answer by importing the array —\n * though after boot `app(Scheduler).jobs` is the better one, because it is what\n * the scheduler actually took rather than what this would find if asked again.\n *\n * Every file underneath is imported, so calling this runs the app's cron\n * modules — the cost `discoverClasses` documents at length, paid once per call.\n */\nexport async function discoverCronJobs(\n dir: string = scheduleConfigDefaults().jobsDir,\n): Promise<Array<new () => CronJob>> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"cron jobs\", \"schedule\");\n return await discoverClasses(resolved, CronJob);\n}\n\n/**\n * The `Command` subclasses under `dir`, defaulting to the config slice's\n * `app/commands`.\n *\n * This is what a `commands`-less `command` slice resolves to, and what\n * `gemi run` lists. Unlike the two above it is not called during boot — a\n * command registry has one consumer, and importing every file under\n * `app/commands` into every server process would be a cost paid on every start\n * for code no request reaches.\n *\n * Every file underneath is imported, so calling this runs the app's command\n * modules — the cost `discoverClasses` documents at length, paid once per call.\n */\nexport async function discoverCommands(\n dir: string = commandConfigDefaults().commandsDir,\n): Promise<CommandClass[]> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"commands\", \"command\");\n\n const unfinished: string[] = [];\n\n const commands = await discoverClasses(\n resolved,\n Command,\n [],\n (value, file) => {\n if (isUnfinishedBuilder(value)) unfinished.push(file);\n },\n );\n\n refuseUnfinishedBuilders(unfinished);\n\n return commands as CommandClass[];\n}\n\n/**\n * Stops the walk for a builder chain that was never finished.\n *\n * This is the one silence the builder introduces, and it is the exact shape\n * #322 and #323 exist to remove. `defineCommand(...).arg(...)` without a\n * trailing `.handle(...)` is a plain object rather than a class, so\n * `discoverClasses` discards it along with every constant and helper a command\n * file happens to export — and the command disappears from `gemi run` with\n * nothing raised. The author sees a listing containing every command except the\n * one they just wrote.\n *\n * A throw rather than a warning, because there is no reading of an unfinished\n * builder under which the author meant it: the chain builds a description of a\n * command and then discards it.\n *\n * \"Unfinished\" is decided by `.handle()` clearing the brand, not by the export\n * still being a builder object. Those differ for the natural way to share\n * declarations —\n *\n * export const base = defineCommand(\"reindex\").option(\"verbose\", …);\n * export default base.handle(async () => {});\n *\n * — where `base` is a builder that *did* produce a command. Keying off the shape\n * alone made that file abort the whole of `gemi run`, taking every other command\n * in the project down with it, under a message that was untrue for it.\n */\nfunction refuseUnfinishedBuilders(files: string[]): void {\n if (files.length === 0) return;\n\n const subject =\n files.length === 1\n ? `${files[0]} exports a command builder that never called \\`.handle()\\``\n : `${files.length} files export a command builder that never called ` +\n `\\`.handle()\\`:\\n ${files.join(\"\\n \")}`;\n\n throw new DiscoveryError(\n `${subject}, so there is no command to run. \\`.handle()\\` is what turns ` +\n `the chain into a command — finish it:\\n\\n` +\n ` export default defineCommand(\"my-command\")\\n` +\n ` .handle(async ({ line }) => { line(\"hello\") })`,\n );\n}\n\n/**\n * The `Listener` subclasses under `dir`, defaulting to the config slice's\n * `app/listeners`.\n *\n * This is what an `events` config slice with no `listeners` key resolves to.\n * Call it directly to ask what an application would register: every listener,\n * in the order it would register them.\n *\n * Only listeners are walked. Event classes are never discovered — each is\n * imported by the listener that binds to it and by the code that dispatches it,\n * so there is nothing a walk over them would find that is not already in the\n * module graph.\n *\n * **Known residual, matching jobs and cron.** `discoverClasses` excludes the\n * `base` it is handed and not intermediates, so an abstract listener base\n * written in `listenersDir` and extended by its siblings is discovered and\n * registered alongside them — constructed, with its `handle` called, on every\n * dispatch of whatever event it declares. Keep shared bases outside the\n * directory.\n *\n * Every file underneath is imported, so calling this runs the app's listener\n * modules — the cost `discoverClasses` documents at length, paid once per call.\n *\n * @throws DiscoveryError if a discovered listener declares no `static event`.\n */\nexport async function discoverListeners(\n dir: string = eventConfigDefaults().listenersDir,\n): Promise<ListenerClass[]> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"event listeners\", \"events\");\n\n const listeners = (await discoverClasses(\n resolved,\n Listener,\n )) as ListenerClass[];\n\n refuseListenersWithNoEvent(listeners);\n warnIfListenerNameWillNotSurviveTheBuild(listeners);\n warnIfEventNameWillNotSurviveTheBuild(listeners);\n\n return listeners;\n}\n\n/**\n * Stops the walk for a listener that binds to nothing.\n *\n * `static event` is declared as required on the base and the compiler still\n * cannot see it missing: every subclass inherits the declaration whether or not\n * it assigns to one, so `typeof SomeListener` type-checks either way. What the\n * author gets instead is a file that is imported, registered under no name, and\n * never called — the silence this whole module is arranged against.\n *\n * A throw rather than a warning, because there is no reading of a listener with\n * no event under which the author meant it. The usual cause is the residual\n * above: an abstract base sharing a gate between two listeners, sitting in\n * `listenersDir` where the walk finds it. Moving it out is the fix, and the\n * message says so — the alternative, excluding it by some guess about\n * abstractness, is how a discovery pass ends up quietly covering less than the\n * directory holds.\n */\nfunction refuseListenersWithNoEvent(listeners: ListenerClass[]): void {\n const orphans = listeners.filter((listener) => !listener.event);\n if (orphans.length === 0) return;\n\n throw new DiscoveryError(\n `${orphans\n .map((listener) => listener.name)\n .join(\", \")} declare no \\`static event\\`, so there is no event name to ` +\n `register them under and their \\`handle\\` would never run. Every ` +\n `listener binds to exactly one event:\\n\\n` +\n ` static event = UserRegistered;\\n\\n` +\n `If this is an abstract base its subclasses extend, move it out of the ` +\n `listeners directory — the walk excludes gemi's \\`Listener\\` and ` +\n `nothing else, so a base sitting beside its subclasses is registered ` +\n `and run like one of them.`,\n );\n}\n\n/**\n * Says something about a discovered listener that never declared `static name`.\n *\n * The hazard is `warnIfNameWillNotSurviveTheBuild`'s, one subsystem over: a\n * `static name = \"...\"` class field defines a *writable* own property while the\n * implicit class binding does not, and a minifier renames the binding while\n * leaving the string literal alone. The two spellings are indistinguishable by\n * value — both read `\"SendWelcomeEmail\"` in development — so the descriptor is\n * the only thing that tells them apart, and the difference only becomes visible\n * in a production build.\n *\n * A warning rather than a refusal, because a *sync* listener's name has no\n * second half to disagree with: every reader of it comes from this same\n * source-side walk, so a minified build and this walk cannot produce two\n * different strings for it. A **queued** listener does have one — the name is\n * the queue's key and it crosses a JSON boundary — and that case is refused\n * outright, by `jobForListener`, at the point the listener is registered with\n * the queue rather than here. This walk cannot tell the two apart without\n * constructing every listener it found; the registry constructs them anyway.\n */\nfunction warnIfListenerNameWillNotSurviveTheBuild(listeners: ListenerClass[]) {\n for (const listener of listeners) {\n if (Object.getOwnPropertyDescriptor(listener, \"name\")?.writable) continue;\n\n console.warn(\n `Event listener ${listener.name} does not declare \\`static name\\`, so ` +\n `it is registered under its class name, which a production build ` +\n `renames. Nothing reads that name across a build boundary while the ` +\n `listener is sync, which is why this is a warning — but adding ` +\n `\\`queued = true\\` to it is refused at boot for the same reason, ` +\n `because the queue's key is that string. Add: static name = ` +\n `\"${listener.name}\";`,\n );\n }\n}\n\n/**\n * Says something about the *event* a discovered listener binds to, when that\n * event's name is the implicit class binding.\n *\n * This is the check that matters from the first dispatch, and it is the reason\n * `discoverListeners` reads `static event` at all. The registry is keyed by the\n * event's name; the dispatcher supplies that name from the class it constructs.\n * A production build minifies the server entry and the app code reachable from\n * it — the controller, and the event class it imports in order to dispatch —\n * while discovery imports `app/listeners/*.ts` from source, and those files\n * import `app/events/*.ts` from source too. Two module graphs, two class\n * objects, and an implicit `.name` that reads `\"UserRegistered\"` on one side\n * and `\"D\"` on the other. The dispatch then finds no listeners, which is legal,\n * normal, and completely silent.\n *\n * A declared `static name` is a string literal, which survives minification\n * intact, and the two halves agree again.\n *\n * Checked through the descriptor rather than the string, and not by comparing\n * `event.name` to anything: in development the two spellings produce the same\n * value, so a check on the string would be a tautology that passes forever.\n */\nfunction warnIfEventNameWillNotSurviveTheBuild(listeners: ListenerClass[]) {\n const warned = new Set<EventClass>();\n\n for (const { event } of listeners) {\n if (warned.has(event)) continue;\n if (Object.getOwnPropertyDescriptor(event, \"name\")?.writable) continue;\n warned.add(event);\n\n console.warn(\n `Event ${event.name} does not declare \\`static name\\`, so it is ` +\n `dispatched under its class name. A production build minifies the ` +\n `code that dispatches it and renames the class, while discovery reads ` +\n `the listener's copy from source and does not — so the dispatch would ` +\n `reach no listener in production and nowhere else. Add: ` +\n `static name = \"${event.name}\";`,\n );\n }\n}\n"
13
13
  ],
14
14
  "mappings": ";sNA4GO,AAAM,IAAsB,DAA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,CAAC,IAAa,EAAS,IAAI,EAC/B,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA,wEAKV,sEACA,+FAEJ,EAuBF,SAAS,CAAwC,CAAC,EAA4B,CAC5E,QAAW,KAAY,EAAW,CAChC,GAAI,OAAO,yBAAyB,EAAU,MAAM,GAAG,SAAU,SAEjE,QAAQ,KACN,kBAAkB,EAAS,gLAGzB,sEACA,+HAEI,EAAS,QACjB,GA0BJ,SAAS,CAAqC,CAAC,EAA4B,CACzE,IAAM,EAAS,IAAI,IAEnB,QAAa,WAAW,EAAW,CACjC,GAAI,EAAO,IAAI,CAAK,EAAG,SACvB,GAAI,OAAO,yBAAyB,EAAO,MAAM,GAAG,SAAU,SAC9D,EAAO,IAAI,CAAK,EAEhB,QAAQ,KACN,SAAS,EAAM,yLAGb,6EACA,yEACkB,EAAM,QAC5B",
15
- "debugId": "3BA8561FCA88054C64756E2164756E21",
15
+ "debugId": "C96D436D786F6FF864756E2164756E21",
16
16
  "names": []
17
17
  }
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ function v(j){return Object.freeze({name:j})}class T extends Error{key;constructor(j){super(`Request state "${j.name}" is not set. Check that whatever sets it (a middleware, \`context()\`) ran for this request.`);this.key=j;this.name="MissingRequestStateError"}}class K{#j=new Map;get(j){return this.#j.get(j)}require(j){if(!this.#j.has(j))throw new T(j);return this.#j.get(j)}set(j,J){return this.#j.set(j,J),J}has(j){return this.#j.has(j)}delete(j){return this.#j.delete(j)}static carry(j,J){for(let[Q,V]of j.#j)if(!J.#j.has(Q))J.#j.set(Q,V)}}function B(){for(let j of["HOST_NAME","APP_URL"]){let J=process.env[j]?.trim().replace(/\/+$/,"");if(J)return J}return}function p(j){let J=B(),Q=J===void 0?"fallback":J===process.env.HOST_NAME?.trim().replace(/\/+$/,"")?"HOST_NAME":"APP_URL",V=J??j?.trim().replace(/\/+$/,"");if(!V)throw Error("The app's public origin is not configured: set HOST_NAME (or APP_URL), e.g. HOST_NAME=https://example.com.");let Z=URL.canParse(V)?new URL(V).protocol:null;if(Z!=="http:"&&Z!=="https:")throw Error(`The app's public origin from ${Q} (${JSON.stringify(V)}) is not an absolute http(s) URL, e.g. https://example.com.`);return V}import{AsyncLocalStorage as q}from"async_hooks";var A=new Set(["woff2","woff","truetype","opentype","collection","embedded-opentype","svg"]),O={woff2:"woff2",woff:"woff",ttf:"truetype",otf:"opentype",ttc:"collection",eot:"embedded-opentype",svg:"svg"};var S=new Set(["auto","block","swap","fallback","optional"]),I=/^[a-zA-Z0-9.%+\- ]+$/,w=/^[uU]\+[0-9a-fA-F?]{1,6}(-[0-9a-fA-F]{1,6})?(\s*,\s*[uU]\+[0-9a-fA-F?]{1,6}(-[0-9a-fA-F]{1,6})?)*$/;function G(j){throw TypeError(`Meta.fonts: ${j}`)}function R(j){let J=(j.split(/[?#]/)[0]??"").split("/").pop()??"",Q=J.lastIndexOf(".");return Q===-1?null:O[J.slice(Q+1).toLowerCase()]??null}function P(j,J){if(J===void 0||J===null)return null;let Q=String(J).trim();if(!Q||!I.test(Q))G(`${j} ${JSON.stringify(J)} is not a valid font-${j} value`);return Q}function W(j){if(!Array.isArray(j))G("expected an array of fonts");return j.map((J)=>{if(typeof J?.family!=="string"||!J.family.trim())G("every font needs a family");let Q=typeof J.src==="string"?[{url:J.src}]:J.src;if(!Array.isArray(Q)||Q.length===0)G(`font "${J.family}" needs a src`);let V=Q.map(($)=>{if(typeof $?.url!=="string"||!$.url.trim())G(`font "${J.family}" has a source without a url`);if($.format!==void 0&&!A.has($.format))G(`font "${J.family}" has an unknown format ${JSON.stringify($.format)}`);return{url:$.url.trim(),format:$.format??R($.url)}}),Z=J.display??"swap";if(!S.has(Z))G(`display ${JSON.stringify(Z)} is not a valid font-display value`);let X=J.unicodeRange?.trim()||null;if(X&&!w.test(X))G(`unicodeRange ${JSON.stringify(J.unicodeRange)} is not a valid unicode-range`);return{family:J.family.trim(),src:V,weight:P("weight",J.weight),style:P("style",J.style),stretch:P("stretch",J.stretch),display:Z,unicodeRange:X,preload:J.preload===!0}})}class U{content={title:"Gemi App",description:null,openGraph:null,htmlAttributes:null,canonical:null,alternates:null,fonts:null};touched=!1;render(){return{title:this.content.title,description:this.content.description,openGraph:this.content.openGraph,htmlAttributes:this.content.htmlAttributes,canonical:this.content.canonical,alternates:this.content.alternates,fonts:this.content.fonts}}htmlAttributes(j){this.touched=!0;let J=Object.fromEntries(Object.entries(j).filter(([,Q])=>Q!==void 0));this.content.htmlAttributes={...this.content.htmlAttributes,...J}}canonical(j){this.touched=!0,this.content.canonical=j}alternates(j){this.touched=!0,this.content.alternates=j}fonts(j){let J=W(j);this.touched=!0,this.content.fonts=[...this.content.fonts??[],...J]}title(j){this.touched=!0,this.content.title=j}description(j){this.touched=!0,this.content.description=j}openGraph({title:j,description:J,type:Q,url:V,image:Z,imageAlt:X,imageWidth:$,imageHeight:L,twitterImage:D=Z,twitterImageAlt:E=X,twitterImageWidth:_=$,twitterImageHeight:x=L}){this.touched=!0;let H=Z,N=D;if(Z&&!Z.startsWith("http"))H=`${B()}${Z}`,N=`${B()}${D}`;this.content.openGraph=Object.fromEntries(Object.entries({title:j,description:J,type:Q,url:V,image:H,imageAlt:X,imageWidth:$,imageHeight:L,twitterImage:N,twitterImageAlt:E,twitterImageWidth:_,twitterImageHeight:x}).filter(([k,C])=>C!==void 0))}}function F(j,J,Q={}){return[`${j}=${J}`,Q.maxAge?`Max-Age=${Q.maxAge}`:"",Q.httpOnly?"HttpOnly":"",Q.secure?"Secure":"",Q.sameSite?`SameSite=${Q.sameSite}`:"SameSite=Strict",Q.path?`Path=${Q.path}`:"Path=/",Q.domain?`Domain=${Q.domain}`:"",Q.expires?`Expires=${Q.expires.toUTCString()}`:"",Q.partitioned?"Partitioned":""].filter((V)=>V!=="").join("; ")}var z=new q;class M{req;cookies=new Set;headers=new Headers;serverQueries=null;user=null;csrfHmac=null;locale=null;metadata=new U;rangeRequest=null;sessionId=null;featureEvaluations=null;featureContext=null;featureBuckets=null;pendingWork=new Set;ended=!1;constructor(j){this.req=j}waitUntil(j){if(this.ended)return;let J=Promise.resolve(j).then(()=>{},()=>{});this.pendingWork.add(J),J.then(()=>this.pendingWork.delete(J))}hasPendingWork(){return this.pendingWork.size>0}async whenIdle(){while(this.pendingWork.size>0)await Promise.all(Array.from(this.pendingWork))}setLocale(j){this.locale=j}renderMeta(){return this.metadata.render()}setCSRFHmac(j){this.csrfHmac=j}setCookie(j,J,Q={}){this.cookies.add(F(j,J,Q))}deleteCookie(j,J={}){this.cookies.add(F(j,"",{...J,maxAge:-1}))}setHeaders(j,J){this.headers.set(j,J)}setUser(j){this.user=j}setRequest(j){this.req=j}destroy(){this.ended=!0,delete this.cookies,delete this.headers,this.serverQueries=null,this.sessionId=null,this.featureEvaluations=null,this.featureContext=null,this.featureBuckets=null,delete this.user}}var b="session_id";function y(){let j=Y.getStore();if(!j)return null;if(j.sessionId)return j.sessionId;let J=j.req?.cookies?.get(b);if(J)j.sessionId=J;return j.sessionId}function a(){let j=Y.getStore();if(!j)return null;let J=y();if(J)return J;let Q=Bun.randomUUIDv7();return j.sessionId=Q,j.setCookie(b,Q,{httpOnly:!0,secure:Bun.env.NODE_ENV==="production",sameSite:"Lax",expires:new Date(Date.now()+31536000000)}),Q}class Y{static getStore(){return z.getStore()}static setRequest(j){z.getStore().req=j}static run(j,J,Q){let V=new M(j);if(Q){if(V.user=Q.user,Q.state&&j.state)K.carry(Q.state,j.state)}return z.run(V,J)}static runWith(j,J){return z.run(j,J)}static exit(j){return z.exit(j)}}
3
+ export{B as gi,p as hi,v as ii,T as ji,K as ki,y as li,a as mi,Y as ni};
4
+
5
+ //# debugId=D175EE7B1A8404F464756E2164756E21
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../http/requestState.ts", "../utils/appOrigin.ts", "../http/requestContext.ts", "../client/fonts.ts", "../http/Metadata.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Typed values kept for the length of one request (#887): what a middleware\n * resolved, handed to the controller, or what an agent turn's `context()`\n * decided, handed to its `onMessage`.\n *\n * ```ts\n * export const pageScope = stateKey<PageScope>(\"pageScope\");\n *\n * // middleware\n * this.req.state.set(pageScope, await resolvePageScope(this.req.params.pageId));\n *\n * // controller\n * const scope = req.state.require(pageScope);\n * ```\n *\n * WHY KEYS, NOT A DECLARATION-MERGED INTERFACE. A key compares by identity, so\n * it stays private to the module that made it and two modules choosing the\n * same name cannot collide; and a read that must find a value (`require`)\n * comes back as `T`, where every field of an app-wide interface would have to\n * be optional. The name is for error messages only.\n *\n * WHY ON THE REQUEST, NOT THE CONTEXT STORE. Every `HttpRequest` built for a\n * request — the router's, a middleware's, `req = new HttpRequest()` in a\n * handler, a custom request class — shares one `RequestState`, so it reads the\n * same wherever it is reached from. Held by those objects rather than by the\n * store, it is still readable after the store is destroyed, by a hook that\n * runs as a streamed body ends.\n */\nexport interface StateKey<T> {\n readonly name: string;\n /** Type-only: carries `T`. Never set. */\n readonly __type?: T;\n}\n\nexport function stateKey<T>(name: string): StateKey<T> {\n return Object.freeze({ name });\n}\n\n/** `req.state.require(key)` found nothing: the code that sets it did not run. */\nexport class MissingRequestStateError extends Error {\n constructor(public readonly key: StateKey<unknown>) {\n super(\n `Request state \"${key.name}\" is not set. ` +\n \"Check that whatever sets it (a middleware, `context()`) ran for this request.\",\n );\n this.name = \"MissingRequestStateError\";\n }\n}\n\nexport class RequestState {\n #values = new Map<StateKey<unknown>, unknown>();\n\n /** The value, or `undefined` when nothing set it for this request. */\n get<T>(key: StateKey<T>): T | undefined {\n return this.#values.get(key) as T | undefined;\n }\n\n /** The value; throws `MissingRequestStateError` when nothing set it. */\n require<T>(key: StateKey<T>): T {\n if (!this.#values.has(key)) {\n throw new MissingRequestStateError(key);\n }\n return this.#values.get(key) as T;\n }\n\n /** Sets the value for the rest of this request and returns it. */\n set<T>(key: StateKey<T>, value: NoInfer<T>): T {\n this.#values.set(key, value);\n return value;\n }\n\n has(key: StateKey<any>): boolean {\n return this.#values.has(key);\n }\n\n delete(key: StateKey<any>): boolean {\n return this.#values.delete(key);\n }\n\n /**\n * Internal: copies what the global middleware list set into the route's\n * request (see `RequestContext.run`). A key the route already holds keeps\n * its own value.\n */\n static carry(from: RequestState, to: RequestState) {\n for (const [key, value] of from.#values) {\n if (!to.#values.has(key)) {\n to.#values.set(key, value);\n }\n }\n }\n}\n",
6
+ "/**\n * The app's public origin as configured: `HOST_NAME`, else `APP_URL`, trimmed\n * and without a trailing `/`. `undefined` when neither is set.\n *\n * `HOST_NAME` comes first because it is the variable gemi has always read, so\n * an app that sets it gets the same value it always did. Read on every call,\n * never cached, so a test that stubs the environment sees its value at once.\n *\n * No validation here: gemi's own call sites keep their behaviour when the value\n * is unset or odd. `Url.origin()` is the checked accessor.\n */\nexport function configuredAppOrigin(): string | undefined {\n for (const name of [\"HOST_NAME\", \"APP_URL\"] as const) {\n const value = process.env[name]?.trim().replace(/\\/+$/, \"\");\n if (value) {\n return value;\n }\n }\n return undefined;\n}\n\n/**\n * `configuredAppOrigin()`, required to be an absolute http(s) URL. Falls back\n * to `fallback` when nothing is configured; throws when there is no fallback\n * either, or when the configured value is not such a URL.\n */\nexport function appOrigin(fallback?: string): string {\n const configured = configuredAppOrigin();\n const source = configured === undefined ? \"fallback\" : configured === process.env.HOST_NAME?.trim().replace(/\\/+$/, \"\") ? \"HOST_NAME\" : \"APP_URL\";\n const value = configured ?? fallback?.trim().replace(/\\/+$/, \"\");\n if (!value) {\n throw new Error(\n \"The app's public origin is not configured: set HOST_NAME (or APP_URL), e.g. HOST_NAME=https://example.com.\",\n );\n }\n const protocol = URL.canParse(value) ? new URL(value).protocol : null;\n if (protocol !== \"http:\" && protocol !== \"https:\") {\n throw new Error(\n `The app's public origin from ${source} (${JSON.stringify(value)}) is not an absolute http(s) URL, e.g. https://example.com.`,\n );\n }\n return value;\n}\n",
7
+ "import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { HttpRequest } from \"./HttpRequest\";\nimport { Metadata } from \"./Metadata\";\nimport type { ByteRange } from \"./range\";\nimport { RequestState } from \"./requestState\";\n// Type-only: `services/router` imports from `http`, so a runtime import here\n// would be circular.\nimport type { ServerQueryStore } from \"../services/router/ServerQueryStore\";\n\nexport interface CreateCookieOptions {\n maxAge?: number;\n expires?: Date;\n httpOnly?: boolean;\n secure?: boolean;\n sameSite?: \"Strict\" | \"Lax\";\n path?: string;\n domain?: string;\n partitioned?: boolean;\n}\n\nexport function createCookie(\n name: string,\n value: string,\n options: CreateCookieOptions = {},\n) {\n return [\n `${name}=${value}`,\n options.maxAge ? `Max-Age=${options.maxAge}` : \"\",\n options.httpOnly ? \"HttpOnly\" : \"\",\n options.secure ? \"Secure\" : \"\",\n options.sameSite ? `SameSite=${options.sameSite}` : \"SameSite=Strict\",\n options.path ? `Path=${options.path}` : \"Path=/\",\n options.domain ? `Domain=${options.domain}` : \"\",\n options.expires ? `Expires=${options.expires.toUTCString()}` : \"\",\n options.partitioned ? \"Partitioned\" : \"\",\n ]\n .filter((i) => i !== \"\")\n .join(\"; \");\n}\n\nconst requestContext = new AsyncLocalStorage<Store>();\n\n/**\n * What a route's request context takes over from the global middleware list's\n * (see `runGlobalMiddleware`): the user, so one the list resolved is not\n * looked up a second time, and the request state the list set (#887).\n */\nexport interface CarriedContext {\n user: any;\n state?: RequestState;\n}\n\nclass Store {\n cookies: Set<string> = new Set();\n headers: Headers = new Headers();\n /**\n * Every server-side query of this request — prefetched or discovered during\n * the streaming render. Assigned by the view router (or lazily by the\n * `Query` facade); `null` for api requests, which must not query themselves.\n */\n serverQueries: ServerQueryStore | null = null;\n user: any = null;\n csrfHmac: string | null = null;\n locale: string | null = null;\n metadata = new Metadata();\n /**\n * The parsed `Range` of the in-flight request, picked up by\n * `FileStorage.read()` so a range reaches the storage backend without every\n * handler having to thread it through by hand.\n *\n * Only populated inside a `this.stream()` route, and cleared once that route\n * returns: a `FileStorage.read()` in an ordinary handler must never start\n * silently returning partial bytes.\n */\n rangeRequest: ByteRange | null = null;\n\n /**\n * This request's `session_id`, once read or minted.\n *\n * The cookie itself cannot answer for it. `setCookie` appends a *serialized*\n * `Set-Cookie` string to `cookies`, so a value written during this request is\n * not readable back out of it, and `req.cookies` still holds only what the\n * browser sent. Anything needing the id in the same request that mints it —\n * feature-flag bucketing, most obviously — has to read it from here.\n */\n sessionId: string | null = null;\n\n /**\n * This request's feature-flag evaluations, computed once.\n *\n * One map per request is what keeps a handler and the SSR payload from\n * disagreeing: a percentage rollout evaluated twice would be consistent\n * anyway — the bucketing is deterministic — but an attribute hook reading a\n * clock, or a `now`-based rule, would not be. Anything the page renders and\n * anything the server branched on have to be the same answer.\n */\n featureEvaluations: Map<string, unknown> | null = null;\n /** The context those evaluations were made against, built at most once. */\n featureContext: unknown = null;\n /** Bucket memo, shared across every flag evaluated for this request. */\n featureBuckets: Map<string, number> | null = null;\n\n /**\n * What `waitUntil` was handed and has not settled yet. Public only because\n * `req.ctx()`'s declared type spells this class out, which a private field\n * cannot be part of; nothing outside the store should touch either.\n */\n pendingWork = new Set<Promise<void>>();\n ended = false;\n\n constructor(public req: HttpRequest) {}\n\n /**\n * Keeps this request open until `work` settles: the api router holds\n * `onRequestEnd` and `destroy()` back until then, so code in `work` still\n * finds `user`, headers and cookies here.\n *\n * For work that outlives the response on purpose. An agent run is the\n * reason it exists: a client that disconnects has not stopped the run, and\n * its next tool call still reads the user who started it. Ignored once the\n * request has ended — there is nothing left to hold open.\n *\n * Only api routes honour this. A view request ends regardless, so work\n * handed to its store — a run started in a view loader — finds no user.\n */\n waitUntil(work: PromiseLike<unknown>) {\n if (this.ended) {\n return;\n }\n const settled = Promise.resolve(work).then(\n () => {},\n () => {},\n );\n this.pendingWork.add(settled);\n void settled.then(() => this.pendingWork.delete(settled));\n }\n\n /** Whether anything handed to `waitUntil` is still running. */\n hasPendingWork() {\n return this.pendingWork.size > 0;\n }\n\n /**\n * Settles once everything handed to `waitUntil` has, including work added\n * while waiting — a run can start another before it ends.\n */\n async whenIdle() {\n while (this.pendingWork.size > 0) {\n await Promise.all(Array.from(this.pendingWork));\n }\n }\n\n setLocale(locale: string) {\n this.locale = locale;\n }\n\n renderMeta() {\n return this.metadata.render();\n }\n\n setCSRFHmac(hmac: string) {\n this.csrfHmac = hmac;\n }\n\n setCookie(name: string, value: string, options: CreateCookieOptions = {}) {\n this.cookies.add(createCookie(name, value, options));\n }\n\n /**\n * A cookie set with a `domain` or `path` is only cleared by a deletion that\n * names the same ones.\n */\n deleteCookie(name: string, options: Pick<CreateCookieOptions, \"domain\" | \"path\"> = {}) {\n this.cookies.add(createCookie(name, \"\", { ...options, maxAge: -1 }));\n }\n\n setHeaders(name: string, value: string) {\n this.headers.set(name, value);\n }\n\n setUser(user: any) {\n this.user = user;\n }\n\n setRequest(req: HttpRequest<any, any>) {\n this.req = req;\n }\n\n destroy() {\n this.ended = true;\n delete this.cookies;\n delete this.headers;\n this.serverQueries = null;\n this.sessionId = null;\n this.featureEvaluations = null;\n this.featureContext = null;\n this.featureBuckets = null;\n delete this.user;\n }\n}\n\nexport const SESSION_ID_COOKIE = \"session_id\";\n\n/**\n * The `session_id` the browser sent, or the one minted earlier in this request.\n * Never mints one, so it is safe on an api request, where a `Set-Cookie` nobody\n * asked for would be a surprise.\n *\n * `null` outside a request, and for an anonymous visitor whose first request is\n * not a view — both meaning \"no stable subject\", which callers must handle\n * rather than paper over with a random value. A per-call random id would give\n * every request its own bucket, which is worse than no bucketing at all: a\n * percentage rollout would reshuffle on every page load.\n *\n * ## It is client-supplied, and unauthenticated\n *\n * Whatever the browser sent, unvalidated. It is a bucketing subject, not a\n * credential — never authenticate or authorize on it. A visitor can pick a value\n * that lands them in any percentage rollout, and signing it would not change\n * that: they can discard the cookie and collect fresh ones until one does. Load\n * bearing enough to state, because `.feature()` route gating is built on top of\n * evaluation — see its documentation for what may safely gate a route.\n */\nexport function sessionId(): string | null {\n const store = RequestContext.getStore();\n if (!store) {\n return null;\n }\n if (store.sessionId) {\n return store.sessionId;\n }\n const sent = store.req?.cookies?.get(SESSION_ID_COOKIE);\n if (sent) {\n store.sessionId = sent;\n }\n return store.sessionId;\n}\n\n/**\n * The same, but mints and sets the cookie when the browser sent none.\n *\n * Call this once per **view** request, early enough that everything downstream —\n * flag evaluation included — sees the same id the browser is about to be given.\n * It used to live inline in `ViewRouteDispatcher.onRequestEnd`, which ran only\n * on the document path and only after the response was decided, so a client-side\n * navigation minted nothing and a first-ever visitor had no id at the point\n * flags were evaluated.\n */\nexport function ensureSessionId(): string | null {\n const store = RequestContext.getStore();\n if (!store) {\n return null;\n }\n const existing = sessionId();\n if (existing) {\n return existing;\n }\n\n const minted = Bun.randomUUIDv7();\n store.sessionId = minted;\n store.setCookie(SESSION_ID_COOKIE, minted, {\n httpOnly: true,\n secure: process.env.NODE_ENV === \"production\",\n // `Lax`, not `Strict`, and the difference is load-bearing. `Strict`\n // withholds the cookie on cross-site *top-level navigation*, so a visitor\n // arriving from a search result or a shared link would arrive without it,\n // be minted a new id, and overwrite the old one — re-bucketing on every\n // external entry, which is how most anonymous traffic arrives. This is not\n // a credential (`access_token` stays `Strict`); it is an opaque bucketing\n // id, and `Lax` still blocks cross-site POST.\n sameSite: \"Lax\",\n expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365),\n });\n return minted;\n}\n\nexport class RequestContext {\n static getStore() {\n return requestContext.getStore()!;\n }\n\n static setRequest(req: HttpRequest<any, any>) {\n requestContext.getStore().req = req;\n }\n\n /**\n * Opens a fresh request scope. `carried` seeds it with what the global\n * middleware list resolved for the same request; nothing else crosses over.\n */\n static run<T>(\n httpRequest: HttpRequest,\n fn: () => T,\n carried?: CarriedContext | null,\n ): T {\n const store = new Store(httpRequest);\n if (carried) {\n store.user = carried.user;\n if (carried.state && httpRequest.state) {\n RequestState.carry(carried.state, httpRequest.state);\n }\n }\n return requestContext.run(store, fn);\n }\n\n /**\n * Re-enters an *existing* request scope. Stream lifecycle callbacks fire\n * after the HTTP server has taken over the response body — outside the\n * AsyncLocalStorage scope the request ran in — so the view router captures\n * the live store and re-enters it around user-facing hooks, keeping\n * `req.ctx()` (and everything context-backed) working inside them.\n */\n static runWith<T>(store: Store, fn: () => T): T {\n return requestContext.run(store, fn);\n }\n\n /**\n * Runs `fn` outside any request scope, as the server's own `fetch` handler\n * is. For a request dispatched from inside another one, which must start from\n * where a client's request would, not from its initiator's store.\n */\n static exit<T>(fn: () => T): T {\n return requestContext.exit(fn);\n }\n}\n",
8
+ "/**\n * `Meta.fonts`: the `@font-face` rules and font preloads of one response.\n * Pure, so the server (validation) and `<Head />` (rendering) share it.\n */\n\n/** A font file format, as `@font-face`'s `format()` names it. */\nexport type FontFormat =\n | \"woff2\"\n | \"woff\"\n | \"truetype\"\n | \"opentype\"\n | \"collection\"\n | \"embedded-opentype\"\n | \"svg\";\n\n/** One file of a font; list the preferred format first. */\nexport type FontSource = {\n url: string;\n /** Inferred from the url's extension when left out. */\n format?: FontFormat;\n};\n\n/** One `@font-face`, see `Meta.fonts`. */\nexport type MetaFont = {\n /** The `font-family` name that CSS refers to, e.g. `\"Acme Sans\"`. */\n family: string;\n /** A url, or several files with the preferred one first. */\n src: string | FontSource[];\n /** `font-weight`: `400`, `\"bold\"`, or a range for a variable font, `\"100 900\"`. */\n weight?: string | number;\n /** `font-style`: `\"normal\"`, `\"italic\"`, `\"oblique 10deg\"`. */\n style?: string;\n /** `font-stretch`: `\"condensed\"`, `\"75% 125%\"`. */\n stretch?: string;\n /** `font-display`. Defaults to `\"swap\"`. */\n display?: \"auto\" | \"block\" | \"swap\" | \"fallback\" | \"optional\";\n /** `unicode-range`, e.g. `\"U+0000-00FF, U+0131\"`. */\n unicodeRange?: string;\n /**\n * Preload the first file with `<link rel=\"preload\" as=\"font\" crossorigin>`.\n * Only for fonts the page renders above the fold: a preloaded font that is\n * never used is a wasted download (and a console warning).\n */\n preload?: boolean;\n};\n\n/** A font after `normalizeFonts`: validated, with every source's format resolved. */\nexport type NormalizedFont = {\n family: string;\n src: { url: string; format: FontFormat | null }[];\n weight: string | null;\n style: string | null;\n stretch: string | null;\n display: NonNullable<MetaFont[\"display\"]>;\n unicodeRange: string | null;\n preload: boolean;\n};\n\nexport type FontPreload = { href: string; type: string | null };\n\nconst FORMATS = new Set<FontFormat>([\n \"woff2\",\n \"woff\",\n \"truetype\",\n \"opentype\",\n \"collection\",\n \"embedded-opentype\",\n \"svg\",\n]);\n\nconst FORMAT_BY_EXTENSION: Record<string, FontFormat> = {\n woff2: \"woff2\",\n woff: \"woff\",\n ttf: \"truetype\",\n otf: \"opentype\",\n ttc: \"collection\",\n eot: \"embedded-opentype\",\n svg: \"svg\",\n};\n\nconst MIME_BY_FORMAT: Partial<Record<FontFormat, string>> = {\n woff2: \"font/woff2\",\n woff: \"font/woff\",\n truetype: \"font/ttf\",\n opentype: \"font/otf\",\n collection: \"font/collection\",\n};\n\nconst DISPLAYS = new Set([\"auto\", \"block\", \"swap\", \"fallback\", \"optional\"]);\n\n// Descriptors are written into the CSS as they are, so only keywords, numbers,\n// angles and percentages pass: nothing that can end the declaration or rule.\nconst DESCRIPTOR = /^[a-zA-Z0-9.%+\\- ]+$/;\nconst UNICODE_RANGE = /^[uU]\\+[0-9a-fA-F?]{1,6}(-[0-9a-fA-F]{1,6})?(\\s*,\\s*[uU]\\+[0-9a-fA-F?]{1,6}(-[0-9a-fA-F]{1,6})?)*$/;\n\nfunction invalid(message: string): never {\n throw new TypeError(`Meta.fonts: ${message}`);\n}\n\n/** The format a url's extension implies (`.woff2` → `\"woff2\"`), ignoring query and hash. */\nexport function fontFormatOf(url: string): FontFormat | null {\n const file = (url.split(/[?#]/)[0] ?? \"\").split(\"/\").pop() ?? \"\";\n const dot = file.lastIndexOf(\".\");\n return dot === -1 ? null : (FORMAT_BY_EXTENSION[file.slice(dot + 1).toLowerCase()] ?? null);\n}\n\nfunction descriptor(name: string, value: string | number | undefined): string | null {\n if (value === undefined || value === null) return null;\n const text = String(value).trim();\n if (!text || !DESCRIPTOR.test(text)) {\n invalid(`${name} ${JSON.stringify(value)} is not a valid font-${name} value`);\n }\n return text;\n}\n\n/** Validates what a handler passed; throws a `TypeError` naming the bad value. */\nexport function normalizeFonts(fonts: MetaFont[]): NormalizedFont[] {\n if (!Array.isArray(fonts)) invalid(\"expected an array of fonts\");\n return fonts.map((font) => {\n if (typeof font?.family !== \"string\" || !font.family.trim()) {\n invalid(\"every font needs a family\");\n }\n const sources = typeof font.src === \"string\" ? [{ url: font.src }] : font.src;\n if (!Array.isArray(sources) || sources.length === 0) {\n invalid(`font \"${font.family}\" needs a src`);\n }\n const src = sources.map((source) => {\n if (typeof source?.url !== \"string\" || !source.url.trim()) {\n invalid(`font \"${font.family}\" has a source without a url`);\n }\n if (source.format !== undefined && !FORMATS.has(source.format)) {\n invalid(`font \"${font.family}\" has an unknown format ${JSON.stringify(source.format)}`);\n }\n return { url: source.url.trim(), format: source.format ?? fontFormatOf(source.url) };\n });\n const display = font.display ?? \"swap\";\n if (!DISPLAYS.has(display)) {\n invalid(`display ${JSON.stringify(display)} is not a valid font-display value`);\n }\n const unicodeRange = font.unicodeRange?.trim() || null;\n if (unicodeRange && !UNICODE_RANGE.test(unicodeRange)) {\n invalid(`unicodeRange ${JSON.stringify(font.unicodeRange)} is not a valid unicode-range`);\n }\n return {\n family: font.family.trim(),\n src,\n weight: descriptor(\"weight\", font.weight),\n style: descriptor(\"style\", font.style),\n stretch: descriptor(\"stretch\", font.stretch),\n display,\n unicodeRange,\n preload: font.preload === true,\n };\n });\n}\n\n/**\n * A CSS string literal holding `value`. Quotes, backslashes, control\n * characters and `<` (so `</style>` can't close the element) are escaped.\n */\nexport function cssString(value: string): string {\n // oxlint-disable-next-line no-control-regex -- escaping them is the point\n const escaped = value.replace(/[\\\\\"<>\\u0000-\\u001f\\u007f]/g, (char) =>\n char === \"\\\\\" || char === '\"' ? `\\\\${char}` : `\\\\${char.charCodeAt(0).toString(16)} `,\n );\n return `\"${escaped}\"`;\n}\n\n/** One `@font-face` rule. */\nexport function fontFaceRule(font: NormalizedFont): string {\n const src = font.src\n .map(({ url, format }) => `url(${cssString(url)})${format ? ` format(${cssString(format)})` : \"\"}`)\n .join(\", \");\n const declarations = [\n `font-family: ${cssString(font.family)}`,\n `src: ${src}`,\n font.weight && `font-weight: ${font.weight}`,\n font.style && `font-style: ${font.style}`,\n font.stretch && `font-stretch: ${font.stretch}`,\n `font-display: ${font.display}`,\n font.unicodeRange && `unicode-range: ${font.unicodeRange}`,\n ].filter(Boolean);\n return `@font-face { ${declarations.join(\"; \")}; }`;\n}\n\n/** The `@font-face` rules for `fonts`, an identical font declared twice once. */\nexport function fontFaceRules(fonts: NormalizedFont[] | null | undefined): string[] {\n return [...new Set((fonts ?? []).map(fontFaceRule))];\n}\n\n/** The first file of every font marked `preload`, each url once. */\nexport function fontPreloads(fonts: NormalizedFont[] | null | undefined): FontPreload[] {\n const preloads = new Map<string, FontPreload>();\n for (const font of fonts ?? []) {\n const first = font.preload ? font.src[0] : undefined;\n if (first && !preloads.has(first.url)) {\n preloads.set(first.url, {\n href: first.url,\n type: (first.format && MIME_BY_FORMAT[first.format]) ?? null,\n });\n }\n }\n return [...preloads.values()];\n}\n",
9
+ "import { type MetaFont, type NormalizedFont, normalizeFonts } from \"../client/fonts\";\nimport { configuredAppOrigin } from \"../utils/appOrigin\";\n\nexport type { MetaFont };\n\nexport type OpenGraphParams = {\n title: string;\n description?: string;\n type: string;\n url: string;\n image: string;\n imageAlt?: string;\n imageWidth?: number;\n imageHeight?: number;\n twitterImage?: string;\n twitterImageAlt?: string;\n twitterImageWidth?: number;\n twitterImageHeight?: number;\n};\n/**\n * Attributes for the document's `<html>` element, handed to the root (or a\n * static view's) layout as its `htmlAttributes` prop.\n */\nexport type HtmlAttributes = {\n /** The document's language, e.g. `\"tr\"`. Defaults to the request's locale. */\n lang?: string;\n /** Text direction. Defaults to the one `lang` is written in. */\n dir?: \"ltr\" | \"rtl\" | \"auto\";\n};\n\n/** One `<link rel=\"alternate\" hreflang>`: the same page in another language. */\nexport type AlternateLink = {\n /** A BCP 47 tag, or `\"x-default\"` for the page to use when none matches. */\n hrefLang: string;\n href: string;\n};\n\nexport class Metadata {\n content: any = {\n title: \"Gemi App\",\n description: null,\n openGraph: null,\n htmlAttributes: null,\n canonical: null,\n alternates: null,\n fonts: null,\n };\n\n /**\n * Whether a handler set anything, as opposed to `content` still being the\n * defaults. A partially rendered response that touched no metadata sends\n * none, so the client keeps what the skipped segments put there.\n */\n touched = false;\n\n render() {\n return {\n title: this.content.title,\n description: this.content.description,\n openGraph: this.content.openGraph,\n htmlAttributes: this.content.htmlAttributes,\n canonical: this.content.canonical,\n alternates: this.content.alternates,\n fonts: this.content.fonts,\n };\n }\n\n /** Merged into what earlier calls set; `undefined` leaves an attribute alone. */\n htmlAttributes(attributes: HtmlAttributes) {\n this.touched = true;\n const defined = Object.fromEntries(\n Object.entries(attributes).filter(([, value]) => value !== undefined),\n );\n this.content.htmlAttributes = { ...this.content.htmlAttributes, ...defined };\n }\n\n canonical(url: string) {\n this.touched = true;\n this.content.canonical = url;\n }\n\n alternates(links: AlternateLink[]) {\n this.touched = true;\n this.content.alternates = links;\n }\n\n /** Added to what earlier calls declared, so a layout and its page can both declare fonts. */\n fonts(fonts: MetaFont[]) {\n const normalized: NormalizedFont[] = normalizeFonts(fonts);\n this.touched = true;\n this.content.fonts = [...(this.content.fonts ?? []), ...normalized];\n }\n\n title(title: string) {\n this.touched = true;\n this.content.title = title;\n }\n\n description(description: string) {\n this.touched = true;\n this.content.description = description;\n }\n\n openGraph({\n title,\n description,\n type,\n url,\n image,\n imageAlt,\n imageWidth,\n imageHeight,\n twitterImage = image,\n twitterImageAlt = imageAlt,\n twitterImageWidth = imageWidth,\n twitterImageHeight = imageHeight,\n }: OpenGraphParams) {\n this.touched = true;\n let _image = image;\n let _twitterImage = twitterImage;\n if (image && !image.startsWith(\"http\")) {\n _image = `${configuredAppOrigin()}${image}`;\n _twitterImage = `${configuredAppOrigin()}${twitterImage}`;\n }\n this.content.openGraph = Object.fromEntries(\n Object.entries({\n title,\n description,\n type,\n url,\n image: _image,\n imageAlt,\n imageWidth,\n imageHeight,\n twitterImage: _twitterImage,\n twitterImageAlt,\n twitterImageWidth,\n twitterImageHeight,\n }).filter(([_, value]) => value !== undefined),\n );\n }\n}\n"
10
+ ],
11
+ "mappings": ";AAkCO,SAAS,CAAW,CAAC,EAA2B,CACrD,OAAO,OAAO,OAAO,CAAE,MAAK,CAAC,EAIxB,MAAM,UAAiC,KAAM,CACtB,IAA5B,WAAW,CAAiB,EAAwB,CAClD,MACE,kBAAkB,EAAI,mGAExB,EAJ0B,WAK1B,KAAK,KAAO,2BAEhB,CAEO,MAAM,CAAa,CACxB,GAAU,IAAI,IAGd,GAAM,CAAC,EAAiC,CACtC,OAAO,KAAK,GAAQ,IAAI,CAAG,EAI7B,OAAU,CAAC,EAAqB,CAC9B,GAAI,CAAC,KAAK,GAAQ,IAAI,CAAG,EACvB,MAAM,IAAI,EAAyB,CAAG,EAExC,OAAO,KAAK,GAAQ,IAAI,CAAG,EAI7B,GAAM,CAAC,EAAkB,EAAsB,CAE7C,OADA,KAAK,GAAQ,IAAI,EAAK,CAAK,EACpB,EAGT,GAAG,CAAC,EAA6B,CAC/B,OAAO,KAAK,GAAQ,IAAI,CAAG,EAG7B,MAAM,CAAC,EAA6B,CAClC,OAAO,KAAK,GAAQ,OAAO,CAAG,QAQzB,MAAK,CAAC,EAAoB,EAAkB,CACjD,QAAY,EAAK,KAAU,EAAK,GAC9B,GAAI,CAAC,EAAG,GAAQ,IAAI,CAAG,EACrB,EAAG,GAAQ,IAAI,EAAK,CAAK,EAIjC,CChFO,SAAS,CAAmB,EAAuB,CACxD,QAAW,IAAQ,CAAC,YAAa,SAAS,EAAY,CACpD,IAAM,EAAQ,QAAQ,IAAI,IAAO,KAAK,EAAE,QAAQ,OAAQ,EAAE,EAC1D,GAAI,EACF,OAAO,EAGX,OAQK,SAAS,CAAS,CAAC,EAA2B,CACnD,IAAM,EAAa,EAAoB,EACjC,EAAS,IAAe,OAAY,WAAa,IA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AC1D,CAAC,EACM,EAGF,MAAM,CAAe,OACnB,SAAQ,EAAG,CAChB,OAAO,EAAe,SAAS,QAG1B,WAAU,CAAC,EAA4B,CAC5C,EAAe,SAAS,EAAE,IAAM,QAO3B,IAAM,CACX,EACA,EACA,EACG,CACH,IAAM,EAAQ,IAAI,EAAM,CAAW,EACnC,GAAI,GAEF,GADA,EAAM,KAAO,EAAQ,KACjB,EAAQ,OAAS,EAAY,MAC/B,EAAa,MAAM,EAAQ,MAAO,EAAY,KAAK,EAGvD,OAAO,EAAe,IAAI,EAAO,CAAE,QAU9B,QAAU,CAAC,EAAc,EAAgB,CAC9C,OAAO,EAAe,IAAI,EAAO,CAAE,QAQ9B,KAAO,CAAC,EAAgB,CAC7B,OAAO,EAAe,KAAK,CAAE,EAEjC",
12
+ "debugId": "D175EE7B1A8404F464756E2164756E21",
13
+ "names": []
14
+ }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Kj as a}from"./chunk-17dndh5z.js";var i=a((f)=>{function u(t){let r={};if(t=t.replace(/^\?/,""),t)for(let n of t.split("&")){let[e,s=null]=n.split("=");if(e=decodeURIComponent(e),s)s=decodeURIComponent(s);if(!(e in r))r[e]=s;else if(Array.isArray(r[e]))r[e].push(s);else r[e]=[r[e],s]}return r}f.parseQueryString=u});var U=a((d)=>{var y=i(),c=(t)=>{if(typeof t==="string")return c(new URL(t));let{hostname:r,pathname:n,port:e,protocol:s,search:o}=t,p;if(o)p=y.parseQueryString(o);return{hostname:r,port:e?parseInt(e):void 0,protocol:s,path:n,query:p}};d.parseUrl=c});
2
+ import{Pk as a}from"./chunk-89swy5aq.js";var i=a((f)=>{function u(t){let r={};if(t=t.replace(/^\?/,""),t)for(let n of t.split("&")){let[e,s=null]=n.split("=");if(e=decodeURIComponent(e),s)s=decodeURIComponent(s);if(!(e in r))r[e]=s;else if(Array.isArray(r[e]))r[e].push(s);else r[e]=[r[e],s]}return r}f.parseQueryString=u});var U=a((d)=>{var y=i(),c=(t)=>{if(typeof t==="string")return c(new URL(t));let{hostname:r,pathname:n,port:e,protocol:s,search:o}=t,p;if(o)p=y.parseQueryString(o);return{hostname:r,port:e?parseInt(e):void 0,protocol:s,path:n,query:p}};d.parseUrl=c});
3
3
  export{U as Z};
4
4
 
5
- //# debugId=F11535EF8967294164756E2164756E21
5
+ //# debugId=55322A5E0A100FD564756E2164756E21
@@ -6,6 +6,6 @@
6
6
  "'use strict';\n\nvar querystringParser = require('@smithy/querystring-parser');\n\nconst parseUrl = (url) => {\n if (typeof url === \"string\") {\n return parseUrl(new URL(url));\n }\n const { hostname, pathname, port, protocol, search } = url;\n let query;\n if (search) {\n query = querystringParser.parseQueryString(search);\n }\n return {\n hostname,\n port: port ? parseInt(port) : undefined,\n protocol,\n path: pathname,\n query,\n };\n};\n\nexports.parseUrl = parseUrl;\n"
7
7
  ],
8
8
  "mappings": ";uDAEA,SAAS,CAAgB,CAAC,EAAa,CACnC,IAAM,EAAQ,CAAC,EAEf,GADA,EAAc,EAAY,QAAQ,MAAO,EAAE,EACvC,EACA,QAAW,KAAQ,EAAY,MAAM,GAAG,EAAG,CACvC,IAAK,EAAK,EAAQ,MAAQ,EAAK,MAAM,GAAG,EAExC,GADA,EAAM,mBAAmB,CAAG,EACxB,EACA,EAAQ,mBAAmB,CAAK,EAEpC,GAAI,EAAE,KAAO,GACT,EAAM,GAAO,EAEZ,QAAI,MAAM,QAAQ,EAAM,EAAI,EAC7B,EAAM,GAAK,KAAK,CAAK,EAGrB,OAAM,GAAO,CAAC,EAAM,GAAM,CAAK,EAI3C,OAAO,EAGH,mBAAmB,kBCxB3B,IAAI,MAEE,EAAW,CAAC,IAAQ,CACtB,GAAI,OAAO,IAAQ,SACf,OAAO,EAAS,IAAI,IAAI,CAAG,CAAC,EAEhC,IAAQ,WAAU,WAAU,OAAM,WAAU,UAAW,EACnD,EACJ,GAAI,EACA,EAAQ,EAAkB,iBAAiB,CAAM,EAErD,MAAO,CACH,WACA,KAAM,EAAO,SAAS,CAAI,EAAI,OAC9B,WACA,KAAM,EACN,OACJ,GAGI,WAAW",
9
- "debugId": "F11535EF8967294164756E2164756E21",
9
+ "debugId": "55322A5E0A100FD564756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
2
  class B{app;constructor(z){this.app=z}register(){}boot(){}shutdown(z){}}
3
- export{B as Yc};
3
+ export{B as Md};
4
4
 
5
- //# debugId=DBAD9399BC25435864756E2164756E21
5
+ //# debugId=24E6DAC9D1C43EBD64756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "import type { Application } from \"../foundation/Application\";\n\n/**\n * What a provider's `shutdown()` may resolve: nothing, or whether it\n * abandoned work at the deadline. See `ServiceProvider` below.\n */\nexport type ProviderShutdownResult = void | { abandoned: boolean };\n\n/**\n * Every hook defaults to a no-op. `register()` binds services into the\n * container and must not resolve any of them; `boot()` runs after every\n * provider has registered, so it may resolve freely.\n *\n * `shutdown()` runs once when a production server is told to stop (`SIGTERM`\n * or `SIGINT`), after it has stopped accepting requests and the in-flight ones\n * have finished or run out of grace — so nothing a request needs is torn down\n * under it. Providers shut down in reverse registration order, so one\n * registered after another may still use it. Each is awaited, but under a\n * shared deadline (`GEMI_SHUTDOWN_PROVIDER_TIMEOUT`): one that overruns is\n * abandoned and the next begins, and one that throws is logged and does not\n * stop the rest. See `Application.shutdown`.\n *\n * Under `gemi dev` it also runs on every `bun --hot` reload, for the\n * application the reload replaced, once the new one is serving and the old\n * one's requests have finished (see `server/devReload.ts`). A hook that closes\n * something kept on `globalThis` across reloads would close it for the new\n * application too.\n *\n * `timeoutMs` is what is left of that shared deadline when this provider is\n * reached. A provider that waits for something — jobs finishing, a queue\n * draining — should bound its own wait by a little less than this, so that it\n * is still the one to report what it gave up on. Ignoring it is fine; the\n * provider is then simply abandoned at the deadline, with only a generic line\n * from `Application` to say so.\n *\n * A provider that bounds its own wait and gives up on work it was waiting for\n * resolves `{ abandoned: true }`. `Application` then reports it in `timedOut`\n * as if it had overrun, and the process exits `1` — the work was cut off just\n * the same, and an orchestrator or a log alert has to be able to see that from\n * the exit code. The provider names what it abandoned in its own log line.\n */\nexport abstract class ServiceProvider {\n constructor(protected app: Application) {}\n\n register(): void {}\n\n boot(): void | Promise<void> {}\n\n shutdown(options?: {\n timeoutMs: number;\n }): ProviderShutdownResult | Promise<ProviderShutdownResult> {}\n}\n"
6
6
  ],
7
7
  "mappings": ";AAyCO,MAAe,CAAgB,CACd,IAAtB,WAAW,CAAW,EAAkB,CAAlB,WAEtB,QAAQ,EAAS,EAEjB,IAAI,EAAyB,EAE7B,QAAQ,CAAC,EAEoD,EAC/D",
8
- "debugId": "DBAD9399BC25435864756E2164756E21",
8
+ "debugId": "24E6DAC9D1C43EBD64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{Nh as X,Zh as P}from"./chunk-96a1459v.js";function f(){return{now:new Date,resolved:{}}}var b={now:new Date(0),resolved:{}};function x(z){return(G,H=b)=>{let V=[];for(let Z=0;Z<z.length;Z++)V.push(z[Z](G,H));return V}}var j="\x00";function W(z){return{text:z,binders:[]}}function Q(z,G=""){return{text:j+G,binders:[z]}}function p(z){return z.text.split(j)}function m(z,G){return{text:z.join(j),binders:G}}function $(...z){return I(z,"")}function I(z,G){let H="",V=[];for(let Z=0;Z<z.length;Z++){if(Z>0)H+=G;H+=z[Z].text;for(let Y of z[Z].binders)V.push(Y)}return{text:H,binders:V}}function c(z,G,H){let V=z.text.split(j),Z=V.length-1;if(Z!==z.binders.length)throw Error(`Compiled ${Z} parameter placeholders but collected ${z.binders.length} binders.`);if(Z>G.maxBoundParameters)throw new P(H.model,H.operation,Z,G.maxBoundParameters,G.name,G.bindsListAsOneParameter?"That is one parameter per value in the statement.":`That is one parameter per value, and on ${G.name} each element of an 'in' list counts separately.`);let Y=V[0];for(let B=0;B<Z;B++)Y+=G.placeholder(B)+V[B+1];return{text:Y,binders:z.binders}}class K{name="postgres";supportsInsensitiveMode=!0;bindsListAsOneParameter=!0;supportsReturning=!0;maxBoundParameters=65535;typesParametersFromStatement=!0;quoteIdent(z){if(z.includes("\x00"))throw Error(`Refusing to quote the identifier ${JSON.stringify(z)}: it contains a NUL byte, which is reserved as the parameter marker.`);return`"${z.replace(/"/g,'""')}"`}placeholder(z){return`$${z+1}`}inList(z,G,H,V){return $(W(`${z} ${G?"<> all":"= any"} (`),Q((Y,B)=>C(V(Y,B))),W(")"))}static COMPOSITE_IN_TYPES={Int:"int",BigInt:"bigint",String:"text",Boolean:"boolean"};canBindCompositeIn(z){return z.length>0&&z.every((G)=>K.COMPOSITE_IN_TYPES[G])}compositeIn(z,G,H){let V=z.map((Z,Y)=>$(Q((B,J)=>C(H(B,J).map((F)=>F[Y]))),W(`::${K.COMPOSITE_IN_TYPES[G[Y]]}[]`)));return $(W(`(${z.join(", ")}) in (select * from unnest(`),...V.flatMap((Z,Y)=>Y===0?[Z]:[W(", "),Z]),W("))"))}listFilters=new Set(["equals","has","hasEvery","hasSome","isEmpty"]);listHas(z,G){return $(G,W(` = any(${z})`))}listHasEvery(z,G){return $(W(`${z} @> `),G)}listHasSome(z,G){return $(W(`${z} && `),G)}listIsEmpty(z,G){return $(W(`${z} ${G?"=":"<>"} `),Q(()=>C([])))}listPush(z,G){return $(W(`array_cat(${z}, `),G,W(")"))}jsonPathSyntax="array";jsonFilters=new Set(["equals","not","string_contains","string_starts_with","string_ends_with","array_contains","lt","lte","gt","gte"]);jsonComparesAsText=!0;jsonExtract(z,G,H){return $(W(`${z} ${H?"#>>":"#>"} `),Q((V,Z)=>C(G(V,Z))))}jsonValueAt(z,G){return $(W("("),this.jsonExtract(z,G,!1),W(")::jsonb"))}jsonHasKeys(z,G,H,V){let Z=()=>G===void 0?W(`(${z})::jsonb`):$(W("("),this.jsonExtract(z,G,!1),W(")::jsonb")),Y=V==="one"?$(Q(H),W("::text")):$(Q((J,F)=>C(H(J,F)??[])),W("::text[]")),B=V==="one"?"?":V==="some"?"?|":"?&";return $(W("(jsonb_typeof("),Z(),W(") = 'object' and "),Z(),W(` ${B} `),Y,W(")"))}distinctFrom(z,G,H){let V=H.type==="Json"&&!H.isList;return $(W(V?`(${z})::jsonb is distinct from `:`${z} is distinct from `),G)}jsonArrayContains(z,G,H){return $(W("("),this.jsonExtract(z,G,!1),W(") @> "),Q((V,Z)=>{let Y=H(V,Z);if(Y===null||Y===void 0)return null;return typeof Y==="string"||typeof Y==="object"?Y:JSON.stringify(Y)}),W("::jsonb"))}like(z,G,H){return $(W(`${z} ${G?"ilike":"like"} `),Q(H))}ignoreConflicts(){return W(" on conflict do nothing")}rowLock(z,G){let H=z.onLocked==="skipLocked"?" skip locked":z.onLocked==="noWait"?" nowait":"";return W(` for ${z.mode==="share"?"share":"update"} of ${this.quoteIdent(G)}${H}`)}paginate(z,G){let H=[];if(z)H.push($(W(" limit "),Q(z)));if(G)H.push($(W(" offset "),Q(G)));return $(...H)}constraintViolation(z){let G=z;if(!G)return null;if(String(G.errno??G.code??"")!=="23505")return null;let V=typeof G.constraint==="string"&&G.constraint!==""?G.constraint:void 0,Z=typeof G.detail==="string"?G.detail:"",Y=/\((.+?)\)=/.exec(Z);return{kind:"unique",columns:Y?(Y[1].match(/"(?:[^"]|"")*"|[^,]+/g)??[]).map((J)=>J.trim()).filter((J)=>J!=="").map((J)=>/^".*"$/s.test(J)?J.slice(1,-1).replace(/""/g,'"'):J):[],constraint:V}}castParameter(z){if(z.isList)return"";return z.type==="Json"?"::text::jsonb":""}encode(z,G){if(z===null||z===void 0)return null;if(G.isList){if(!Array.isArray(z))throw Error(`gemi ORM bug: a non-array reached the parameter binder for the scalar list '${G.column}' (received ${typeof z}). Every path that binds a list is supposed to have checked its operand.`);return C(G.type==="Json"?z.map((H)=>H===null||H===void 0?null:JSON.stringify(H)):z)}return z}encodeUntyped(z){return z}needsDecode(z){return z.isList===!0||z.type==="BigInt"||z.type==="Bytes"}decode(z,G){if(z===null||z===void 0)return null;if(G.isList)return this.decodeList(z,G);return this.decodeScalar(z,G)}decodeList(z,G){let H=Array.isArray(z)?z:typeof z==="string"?E(z,G):ArrayBuffer.isView(z)?Array.from(z):null;if(H===null)throw new X(G,z);return H.map((V)=>V===null||V===void 0?null:this.decodeScalar(V,G))}decodeScalar(z,G){switch(G.type){case"BigInt":if(typeof z==="bigint")return z;try{return BigInt(z)}catch{throw new X(G,z)}case"Json":return z;case"Bytes":return Buffer.isBuffer(z)?new Uint8Array(z.buffer,z.byteOffset,z.byteLength):z;default:return z}}}function C(z){let G="{";for(let H=0;H<z.length;H++){if(H>0)G+=",";G+=D(z[H])}return G+"}"}function D(z){if(z===null||z===void 0)return"NULL";if(z instanceof Date)return`"${z.toISOString()}"`;if(ArrayBuffer.isView(z)){let H="";for(let V of new Uint8Array(z.buffer,z.byteOffset,z.byteLength))H+=V.toString(16).padStart(2,"0");return`"\\\\x${H}"`}return`"${(typeof z==="string"?z:String(z)).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`}function E(z,G){if(!z.startsWith("{")||!z.endsWith("}"))throw new X(G,z);if(z==="{}")return[];let H=[],V=1,Z=z.length-1;while(V<=Z){let Y="",B=!1;if(z[V]==='"'){B=!0,V++;while(V<Z&&z[V]!=='"')Y+=z[V]==="\\"?z[++V]:z[V],V++;V++}else while(V<Z&&z[V]!==","){if(z[V]==="{")throw new X(G,z);Y+=z[V],V++}if(H.push(!B&&Y.toUpperCase()==="NULL"?null:Y),V<Z&&z[V]!==",")throw new X(G,z);V++}if(G.type!=="Json")return H;return H.map((Y)=>{if(Y===null)return null;try{return JSON.parse(Y)}catch{throw new X(G,Y)}})}var k={"Prisma.DbNull":"db","Prisma.JsonNull":"json","Prisma.AnyNull":"any"};function _(z){return new class{toString(){return z}}}var s=_("Prisma.DbNull"),y=_("Prisma.JsonNull"),u=_("Prisma.AnyNull"),r=y;function A(z){if(typeof z!=="object"||z===null)return null;for(let H in z)return null;if(Object.getOwnPropertyNames(z).length>0)return null;let G;try{G=String(z)}catch{return null}return k[G]??null}var h=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(\.\d+)?$/;function q(z,G){if(z instanceof Date)return z;let H;if(typeof z==="number")H=new Date(z);else if(typeof z==="bigint")H=new Date(Number(z));else if(typeof z==="string")H=new Date(h.test(z)?`${z.replace(" ","T")}Z`:z);else throw new X(G,z);if(Number.isNaN(H.getTime()))throw new X(G,z);return H}class S{name="sqlite";supportsInsensitiveMode=!1;bindsListAsOneParameter=!1;supportsReturning=!0;maxBoundParameters=32766;typesParametersFromStatement=!1;quoteIdent(z){if(z.includes("\x00"))throw Error(`Refusing to quote the identifier ${JSON.stringify(z)}: it contains a NUL byte, which is reserved as the parameter marker.`);return`"${z.replace(/"/g,'""')}"`}placeholder(z){return"?"}inList(z,G,H,V){let Z=G?"not in":"in",Y=[];for(let B=0;B<H;B++)Y.push(Q((J,F)=>V(J,F)[B]));return $(W(`${z} ${Z} (`),I(Y,", "),W(")"))}canBindCompositeIn(){return!1}compositeIn(){throw Error("SQLite cannot bind a composite `in`; `canBindCompositeIn` is the guard.")}listFilters=new Set;listHas(){throw Error(N("has"))}listHasEvery(){throw Error(N("hasEvery"))}listHasSome(){throw Error(N("hasSome"))}listIsEmpty(){throw Error(N("isEmpty"))}listPush(){throw Error(N("push"))}jsonPathSyntax="jsonpath";jsonFilters=new Set(["equals","not","string_contains","string_starts_with","string_ends_with"]);jsonComparesAsText=!1;jsonExtract(z,G,H){return $(W(`json_extract(${z}, `),Q(G),W(")"))}jsonValueAt(z,G){return $(W(`(${z} -> `),Q(G),W(")"))}jsonHasKeys(z,G,H,V,Z){let Y=(O,U)=>G===void 0?"$":G(O,U),B=(O)=>$(W(`json_type(${z}, `),Q((U,M)=>{let w=H(U,M),L=O===void 0?w:w[O];return`${Y(U,M)}.${JSON.stringify(String(L))}`}),W(") is not null")),J=V==="one"?[B(void 0)]:Array.from({length:Z},(O,U)=>B(U)),F=J.length===0?W(V==="some"?"0":"1"):I(J,V==="every"?" and ":" or ");return $(W(`(json_type(${z}, `),Q(Y),W(") = 'object' and ("),F,W("))"))}distinctFrom(z,G,H){if(H.type==="Json"&&!H.isList)return $(W(`json(${z}) is not json(`),G,W(")"));return $(W(`${z} is not `),G)}jsonArrayContains(){throw Error("SQLite cannot express array_contains; `jsonFilters` is the guard.")}like(z,G,H){return $(W(`${z} like `),Q(H))}ignoreConflicts(){return null}rowLock(z,G){return W("")}paginate(z,G){if(!z&&!G)return W("");if(!G)return $(W(" limit "),Q(z));return $(W(" limit "),Q(z??(()=>-1)),W(" offset "),Q(G))}constraintViolation(z){let G=z?.code;if(G!=="SQLITE_CONSTRAINT_UNIQUE"&&G!=="SQLITE_CONSTRAINT_PRIMARYKEY")return null;let H=String(z.message??""),V=/constraint failed:\s*(.+)$/.exec(H);if(!V)return{kind:"unique",columns:[]};return{kind:"unique",columns:V[1].split(",").map((Y)=>Y.trim()).map((Y)=>{let B=Y.indexOf(".");return B===-1?Y:Y.slice(B+1)}).filter((Y)=>Y!=="")}}castParameter(z){return""}encode(z,G){if(z===null||z===void 0)return null;switch(G.type){case"DateTime":return z instanceof Date?z.getTime():z;case"Boolean":return typeof z==="boolean"?z?1:0:z;case"Json":{let H=A(z);if(H==="db")return null;if(H==="json")return"null";if(H==="any")throw Error("gemi ORM bug: Prisma.AnyNull reached the SQLite encoder. It is a filter operand only, and both the filter and write paths are supposed to have handled it before this point.")}return JSON.stringify(z);default:return z}}encodeUntyped(z){if(z instanceof Date)return z.getTime();if(typeof z==="boolean")return z?1:0;return z}needsDecode(z){switch(z.type){case"DateTime":case"Boolean":case"BigInt":case"Json":return!0;default:return!1}}decode(z,G){if(z===null||z===void 0)return null;switch(G.type){case"DateTime":return q(z,G);case"Boolean":if(typeof z==="boolean")return z;return Number(z)!==0;case"BigInt":if(typeof z==="bigint")return z;try{return BigInt(z)}catch{throw new X(G,z)}case"Json":try{return typeof z==="string"?JSON.parse(z):z}catch{throw new X(G,z)}default:return z}}}function N(z){return`SQLite has no array type, so it cannot express '${z}' on a scalar list; \`listFilters\` is the guard.`}class R extends Error{constructor(z){super(`The gemi ORM does not support the '${z}' dialect. Only sqlite `+"and postgres are implemented \u2014 see the supported matrix in "+`docs/orm.md.
2
+ import{Qi as X,aj as P}from"./chunk-yffm8nxa.js";function f(){return{now:new Date,resolved:{}}}var b={now:new Date(0),resolved:{}};function x(z){return(G,H=b)=>{let V=[];for(let Z=0;Z<z.length;Z++)V.push(z[Z](G,H));return V}}var j="\x00";function W(z){return{text:z,binders:[]}}function Q(z,G=""){return{text:j+G,binders:[z]}}function p(z){return z.text.split(j)}function m(z,G){return{text:z.join(j),binders:G}}function $(...z){return I(z,"")}function I(z,G){let H="",V=[];for(let Z=0;Z<z.length;Z++){if(Z>0)H+=G;H+=z[Z].text;for(let Y of z[Z].binders)V.push(Y)}return{text:H,binders:V}}function c(z,G,H){let V=z.text.split(j),Z=V.length-1;if(Z!==z.binders.length)throw Error(`Compiled ${Z} parameter placeholders but collected ${z.binders.length} binders.`);if(Z>G.maxBoundParameters)throw new P(H.model,H.operation,Z,G.maxBoundParameters,G.name,G.bindsListAsOneParameter?"That is one parameter per value in the statement.":`That is one parameter per value, and on ${G.name} each element of an 'in' list counts separately.`);let Y=V[0];for(let B=0;B<Z;B++)Y+=G.placeholder(B)+V[B+1];return{text:Y,binders:z.binders}}class K{name="postgres";supportsInsensitiveMode=!0;bindsListAsOneParameter=!0;supportsReturning=!0;maxBoundParameters=65535;typesParametersFromStatement=!0;quoteIdent(z){if(z.includes("\x00"))throw Error(`Refusing to quote the identifier ${JSON.stringify(z)}: it contains a NUL byte, which is reserved as the parameter marker.`);return`"${z.replace(/"/g,'""')}"`}placeholder(z){return`$${z+1}`}inList(z,G,H,V){return $(W(`${z} ${G?"<> all":"= any"} (`),Q((Y,B)=>C(V(Y,B))),W(")"))}static COMPOSITE_IN_TYPES={Int:"int",BigInt:"bigint",String:"text",Boolean:"boolean"};canBindCompositeIn(z){return z.length>0&&z.every((G)=>K.COMPOSITE_IN_TYPES[G])}compositeIn(z,G,H){let V=z.map((Z,Y)=>$(Q((B,J)=>C(H(B,J).map((F)=>F[Y]))),W(`::${K.COMPOSITE_IN_TYPES[G[Y]]}[]`)));return $(W(`(${z.join(", ")}) in (select * from unnest(`),...V.flatMap((Z,Y)=>Y===0?[Z]:[W(", "),Z]),W("))"))}listFilters=new Set(["equals","has","hasEvery","hasSome","isEmpty"]);listHas(z,G){return $(G,W(` = any(${z})`))}listHasEvery(z,G){return $(W(`${z} @> `),G)}listHasSome(z,G){return $(W(`${z} && `),G)}listIsEmpty(z,G){return $(W(`${z} ${G?"=":"<>"} `),Q(()=>C([])))}listPush(z,G){return $(W(`array_cat(${z}, `),G,W(")"))}jsonPathSyntax="array";jsonFilters=new Set(["equals","not","string_contains","string_starts_with","string_ends_with","array_contains","lt","lte","gt","gte"]);jsonComparesAsText=!0;jsonExtract(z,G,H){return $(W(`${z} ${H?"#>>":"#>"} `),Q((V,Z)=>C(G(V,Z))))}jsonValueAt(z,G){return $(W("("),this.jsonExtract(z,G,!1),W(")::jsonb"))}jsonHasKeys(z,G,H,V){let Z=()=>G===void 0?W(`(${z})::jsonb`):$(W("("),this.jsonExtract(z,G,!1),W(")::jsonb")),Y=V==="one"?$(Q(H),W("::text")):$(Q((J,F)=>C(H(J,F)??[])),W("::text[]")),B=V==="one"?"?":V==="some"?"?|":"?&";return $(W("(jsonb_typeof("),Z(),W(") = 'object' and "),Z(),W(` ${B} `),Y,W(")"))}distinctFrom(z,G,H){let V=H.type==="Json"&&!H.isList;return $(W(V?`(${z})::jsonb is distinct from `:`${z} is distinct from `),G)}jsonArrayContains(z,G,H){return $(W("("),this.jsonExtract(z,G,!1),W(") @> "),Q((V,Z)=>{let Y=H(V,Z);if(Y===null||Y===void 0)return null;return typeof Y==="string"||typeof Y==="object"?Y:JSON.stringify(Y)}),W("::jsonb"))}like(z,G,H){return $(W(`${z} ${G?"ilike":"like"} `),Q(H))}ignoreConflicts(){return W(" on conflict do nothing")}rowLock(z,G){let H=z.onLocked==="skipLocked"?" skip locked":z.onLocked==="noWait"?" nowait":"";return W(` for ${z.mode==="share"?"share":"update"} of ${this.quoteIdent(G)}${H}`)}paginate(z,G){let H=[];if(z)H.push($(W(" limit "),Q(z)));if(G)H.push($(W(" offset "),Q(G)));return $(...H)}constraintViolation(z){let G=z;if(!G)return null;if(String(G.errno??G.code??"")!=="23505")return null;let V=typeof G.constraint==="string"&&G.constraint!==""?G.constraint:void 0,Z=typeof G.detail==="string"?G.detail:"",Y=/\((.+?)\)=/.exec(Z);return{kind:"unique",columns:Y?(Y[1].match(/"(?:[^"]|"")*"|[^,]+/g)??[]).map((J)=>J.trim()).filter((J)=>J!=="").map((J)=>/^".*"$/s.test(J)?J.slice(1,-1).replace(/""/g,'"'):J):[],constraint:V}}castParameter(z){if(z.isList)return"";return z.type==="Json"?"::text::jsonb":""}encode(z,G){if(z===null||z===void 0)return null;if(G.isList){if(!Array.isArray(z))throw Error(`gemi ORM bug: a non-array reached the parameter binder for the scalar list '${G.column}' (received ${typeof z}). Every path that binds a list is supposed to have checked its operand.`);return C(G.type==="Json"?z.map((H)=>H===null||H===void 0?null:JSON.stringify(H)):z)}return z}encodeUntyped(z){return z}needsDecode(z){return z.isList===!0||z.type==="BigInt"||z.type==="Bytes"}decode(z,G){if(z===null||z===void 0)return null;if(G.isList)return this.decodeList(z,G);return this.decodeScalar(z,G)}decodeList(z,G){let H=Array.isArray(z)?z:typeof z==="string"?E(z,G):ArrayBuffer.isView(z)?Array.from(z):null;if(H===null)throw new X(G,z);return H.map((V)=>V===null||V===void 0?null:this.decodeScalar(V,G))}decodeScalar(z,G){switch(G.type){case"BigInt":if(typeof z==="bigint")return z;try{return BigInt(z)}catch{throw new X(G,z)}case"Json":return z;case"Bytes":return Buffer.isBuffer(z)?new Uint8Array(z.buffer,z.byteOffset,z.byteLength):z;default:return z}}}function C(z){let G="{";for(let H=0;H<z.length;H++){if(H>0)G+=",";G+=D(z[H])}return G+"}"}function D(z){if(z===null||z===void 0)return"NULL";if(z instanceof Date)return`"${z.toISOString()}"`;if(ArrayBuffer.isView(z)){let H="";for(let V of new Uint8Array(z.buffer,z.byteOffset,z.byteLength))H+=V.toString(16).padStart(2,"0");return`"\\\\x${H}"`}return`"${(typeof z==="string"?z:String(z)).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`}function E(z,G){if(!z.startsWith("{")||!z.endsWith("}"))throw new X(G,z);if(z==="{}")return[];let H=[],V=1,Z=z.length-1;while(V<=Z){let Y="",B=!1;if(z[V]==='"'){B=!0,V++;while(V<Z&&z[V]!=='"')Y+=z[V]==="\\"?z[++V]:z[V],V++;V++}else while(V<Z&&z[V]!==","){if(z[V]==="{")throw new X(G,z);Y+=z[V],V++}if(H.push(!B&&Y.toUpperCase()==="NULL"?null:Y),V<Z&&z[V]!==",")throw new X(G,z);V++}if(G.type!=="Json")return H;return H.map((Y)=>{if(Y===null)return null;try{return JSON.parse(Y)}catch{throw new X(G,Y)}})}var k={"Prisma.DbNull":"db","Prisma.JsonNull":"json","Prisma.AnyNull":"any"};function _(z){return new class{toString(){return z}}}var s=_("Prisma.DbNull"),y=_("Prisma.JsonNull"),u=_("Prisma.AnyNull"),r=y;function A(z){if(typeof z!=="object"||z===null)return null;for(let H in z)return null;if(Object.getOwnPropertyNames(z).length>0)return null;let G;try{G=String(z)}catch{return null}return k[G]??null}var h=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(\.\d+)?$/;function q(z,G){if(z instanceof Date)return z;let H;if(typeof z==="number")H=new Date(z);else if(typeof z==="bigint")H=new Date(Number(z));else if(typeof z==="string")H=new Date(h.test(z)?`${z.replace(" ","T")}Z`:z);else throw new X(G,z);if(Number.isNaN(H.getTime()))throw new X(G,z);return H}class S{name="sqlite";supportsInsensitiveMode=!1;bindsListAsOneParameter=!1;supportsReturning=!0;maxBoundParameters=32766;typesParametersFromStatement=!1;quoteIdent(z){if(z.includes("\x00"))throw Error(`Refusing to quote the identifier ${JSON.stringify(z)}: it contains a NUL byte, which is reserved as the parameter marker.`);return`"${z.replace(/"/g,'""')}"`}placeholder(z){return"?"}inList(z,G,H,V){let Z=G?"not in":"in",Y=[];for(let B=0;B<H;B++)Y.push(Q((J,F)=>V(J,F)[B]));return $(W(`${z} ${Z} (`),I(Y,", "),W(")"))}canBindCompositeIn(){return!1}compositeIn(){throw Error("SQLite cannot bind a composite `in`; `canBindCompositeIn` is the guard.")}listFilters=new Set;listHas(){throw Error(N("has"))}listHasEvery(){throw Error(N("hasEvery"))}listHasSome(){throw Error(N("hasSome"))}listIsEmpty(){throw Error(N("isEmpty"))}listPush(){throw Error(N("push"))}jsonPathSyntax="jsonpath";jsonFilters=new Set(["equals","not","string_contains","string_starts_with","string_ends_with"]);jsonComparesAsText=!1;jsonExtract(z,G,H){return $(W(`json_extract(${z}, `),Q(G),W(")"))}jsonValueAt(z,G){return $(W(`(${z} -> `),Q(G),W(")"))}jsonHasKeys(z,G,H,V,Z){let Y=(O,U)=>G===void 0?"$":G(O,U),B=(O)=>$(W(`json_type(${z}, `),Q((U,M)=>{let w=H(U,M),L=O===void 0?w:w[O];return`${Y(U,M)}.${JSON.stringify(String(L))}`}),W(") is not null")),J=V==="one"?[B(void 0)]:Array.from({length:Z},(O,U)=>B(U)),F=J.length===0?W(V==="some"?"0":"1"):I(J,V==="every"?" and ":" or ");return $(W(`(json_type(${z}, `),Q(Y),W(") = 'object' and ("),F,W("))"))}distinctFrom(z,G,H){if(H.type==="Json"&&!H.isList)return $(W(`json(${z}) is not json(`),G,W(")"));return $(W(`${z} is not `),G)}jsonArrayContains(){throw Error("SQLite cannot express array_contains; `jsonFilters` is the guard.")}like(z,G,H){return $(W(`${z} like `),Q(H))}ignoreConflicts(){return null}rowLock(z,G){return W("")}paginate(z,G){if(!z&&!G)return W("");if(!G)return $(W(" limit "),Q(z));return $(W(" limit "),Q(z??(()=>-1)),W(" offset "),Q(G))}constraintViolation(z){let G=z?.code;if(G!=="SQLITE_CONSTRAINT_UNIQUE"&&G!=="SQLITE_CONSTRAINT_PRIMARYKEY")return null;let H=String(z.message??""),V=/constraint failed:\s*(.+)$/.exec(H);if(!V)return{kind:"unique",columns:[]};return{kind:"unique",columns:V[1].split(",").map((Y)=>Y.trim()).map((Y)=>{let B=Y.indexOf(".");return B===-1?Y:Y.slice(B+1)}).filter((Y)=>Y!=="")}}castParameter(z){return""}encode(z,G){if(z===null||z===void 0)return null;switch(G.type){case"DateTime":return z instanceof Date?z.getTime():z;case"Boolean":return typeof z==="boolean"?z?1:0:z;case"Json":{let H=A(z);if(H==="db")return null;if(H==="json")return"null";if(H==="any")throw Error("gemi ORM bug: Prisma.AnyNull reached the SQLite encoder. It is a filter operand only, and both the filter and write paths are supposed to have handled it before this point.")}return JSON.stringify(z);default:return z}}encodeUntyped(z){if(z instanceof Date)return z.getTime();if(typeof z==="boolean")return z?1:0;return z}needsDecode(z){switch(z.type){case"DateTime":case"Boolean":case"BigInt":case"Json":return!0;default:return!1}}decode(z,G){if(z===null||z===void 0)return null;switch(G.type){case"DateTime":return q(z,G);case"Boolean":if(typeof z==="boolean")return z;return Number(z)!==0;case"BigInt":if(typeof z==="bigint")return z;try{return BigInt(z)}catch{throw new X(G,z)}case"Json":try{return typeof z==="string"?JSON.parse(z):z}catch{throw new X(G,z)}default:return z}}}function N(z){return`SQLite has no array type, so it cannot express '${z}' on a scalar list; \`listFilters\` is the guard.`}class R extends Error{constructor(z){super(`The gemi ORM does not support the '${z}' dialect. Only sqlite `+"and postgres are implemented \u2014 see the supported matrix in "+`docs/orm.md.
3
3
 
4
4
  The *connection* is fine: Bun's client speaks ${z}, so raw SQL through DB.query / DB.sql and transactions all work. It is the query compiler that has no ${z} dialect, so every model operation raises this.
5
5
 
6
6
  Point DATABASE_URL at Postgres or SQLite to use the ORM, or keep using Prisma's own client for this database.`);this.name="UnsupportedDialectError"}}function Vz(z){return T[z]!==null}function Wz(){return Object.keys(T)}var T={sqlite:new S,postgres:new K,mysql:null,mariadb:null};function Yz(z){let G=T[z];if(G===null)throw new R(z);return G}
7
- export{f as Df,x as Ef,W as Ff,Q as Gf,p as Hf,m as If,$ as Jf,I as Kf,c as Lf,K as Mf,s as Nf,y as Of,u as Pf,r as Qf,A as Rf,S as Sf,R as Tf,Vz as Uf,Wz as Vf,Yz as Wf};
7
+ export{f as Bg,x as Cg,W as Dg,Q as Eg,p as Fg,m as Gg,$ as Hg,I as Ig,c as Jg,K as Kg,s as Lg,y as Mg,u as Ng,r as Og,A as Pg,S as Qg,R as Rg,Vz as Sg,Wz as Tg,Yz as Ug};
8
8
 
9
- //# debugId=44481EF23B8174B064756E2164756E21
9
+ //# debugId=E2B48E9F903E47ED64756E2164756E21