gemi 0.112.1 → 0.114.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 (240) hide show
  1. package/dist/ai/index.js +32 -32
  2. package/dist/ai/index.js.map +3 -5
  3. package/dist/app/App.d.ts.map +1 -1
  4. package/dist/app/index.js +1 -1
  5. package/dist/auth/AuthController.d.ts +19 -2
  6. package/dist/auth/AuthController.d.ts.map +1 -1
  7. package/dist/auth/config.d.ts +9 -0
  8. package/dist/auth/config.d.ts.map +1 -1
  9. package/dist/auth/oauth/GoogleOAuthProvider.d.ts +16 -17
  10. package/dist/auth/oauth/GoogleOAuthProvider.d.ts.map +1 -1
  11. package/dist/auth/oauth/OAuthProvider.d.ts +56 -7
  12. package/dist/auth/oauth/OAuthProvider.d.ts.map +1 -1
  13. package/dist/auth/oauth/XOAuthProvider.d.ts +10 -9
  14. package/dist/auth/oauth/XOAuthProvider.d.ts.map +1 -1
  15. package/dist/auth/oauth/oauthState.d.ts +70 -0
  16. package/dist/auth/oauth/oauthState.d.ts.map +1 -0
  17. package/dist/auth/routes.d.ts +3 -2
  18. package/dist/auth/routes.d.ts.map +1 -1
  19. package/dist/bin/gemi.js +8 -1
  20. package/dist/bin/gemi.js.map +3 -3
  21. package/dist/bun/plugin.js +1 -1
  22. package/dist/bun/preload.js +1 -1
  23. package/dist/chunk-0n9vs1ad.js +14 -0
  24. package/dist/{chunk-j0sncgxc.js.map → chunk-0n9vs1ad.js.map} +4 -4
  25. package/dist/{chunk-18c3y8m3.js → chunk-1f9sqht5.js} +2 -2
  26. package/dist/{chunk-18c3y8m3.js.map → chunk-1f9sqht5.js.map} +1 -1
  27. package/dist/{chunk-bhw7k8vp.js → chunk-1p0dazvk.js} +2 -2
  28. package/dist/{chunk-bhw7k8vp.js.map → chunk-1p0dazvk.js.map} +1 -1
  29. package/dist/{chunk-b7cqwcbm.js → chunk-2rphhsr7.js} +2 -2
  30. package/dist/{chunk-b7cqwcbm.js.map → chunk-2rphhsr7.js.map} +1 -1
  31. package/dist/{chunk-qx87cdfg.js → chunk-2z1981d0.js} +2 -2
  32. package/dist/{chunk-qx87cdfg.js.map → chunk-2z1981d0.js.map} +1 -1
  33. package/dist/{chunk-tb126j80.js → chunk-329ggbcw.js} +2 -2
  34. package/dist/{chunk-tb126j80.js.map → chunk-329ggbcw.js.map} +1 -1
  35. package/dist/{chunk-dm59ze55.js → chunk-37qk5dh8.js} +2 -2
  36. package/dist/{chunk-dm59ze55.js.map → chunk-37qk5dh8.js.map} +1 -1
  37. package/dist/{chunk-b7qjp7r1.js → chunk-3ma9m432.js} +2 -2
  38. package/dist/{chunk-b7qjp7r1.js.map → chunk-3ma9m432.js.map} +1 -1
  39. package/dist/{chunk-5waxjsvv.js → chunk-4szjp84e.js} +2 -2
  40. package/dist/{chunk-5waxjsvv.js.map → chunk-4szjp84e.js.map} +1 -1
  41. package/dist/{chunk-8reepafh.js → chunk-56fgk5rq.js} +2 -2
  42. package/dist/{chunk-8reepafh.js.map → chunk-56fgk5rq.js.map} +1 -1
  43. package/dist/{chunk-hfyxvdjj.js → chunk-583vxa2v.js} +2 -2
  44. package/dist/{chunk-hfyxvdjj.js.map → chunk-583vxa2v.js.map} +1 -1
  45. package/dist/{chunk-6w79zajj.js → chunk-5j76r5q8.js} +3 -3
  46. package/dist/{chunk-6w79zajj.js.map → chunk-5j76r5q8.js.map} +1 -1
  47. package/dist/chunk-60nyk1w8.js +10 -0
  48. package/dist/chunk-60nyk1w8.js.map +38 -0
  49. package/dist/{chunk-jn59bsww.js → chunk-6h9j3f1x.js} +2 -2
  50. package/dist/{chunk-jn59bsww.js.map → chunk-6h9j3f1x.js.map} +1 -1
  51. package/dist/{chunk-teny6xkw.js → chunk-75wk4jxd.js} +2 -2
  52. package/dist/{chunk-teny6xkw.js.map → chunk-75wk4jxd.js.map} +1 -1
  53. package/dist/{chunk-k7rbkhhw.js → chunk-7fwp7vwh.js} +2 -2
  54. package/dist/{chunk-k7rbkhhw.js.map → chunk-7fwp7vwh.js.map} +1 -1
  55. package/dist/{chunk-beks65me.js → chunk-7rmjr8p7.js} +3 -3
  56. package/dist/{chunk-beks65me.js.map → chunk-7rmjr8p7.js.map} +1 -1
  57. package/dist/{chunk-jn8hh25v.js → chunk-7v8sgqen.js} +2 -2
  58. package/dist/{chunk-jn8hh25v.js.map → chunk-7v8sgqen.js.map} +1 -1
  59. package/dist/{chunk-57edag57.js → chunk-8c2fs0n0.js} +3 -3
  60. package/dist/{chunk-57edag57.js.map → chunk-8c2fs0n0.js.map} +1 -1
  61. package/dist/{chunk-0z2h35d7.js → chunk-8h7dh2h2.js} +2 -2
  62. package/dist/{chunk-0z2h35d7.js.map → chunk-8h7dh2h2.js.map} +1 -1
  63. package/dist/{chunk-b1mk12xg.js → chunk-8k8534kg.js} +2 -2
  64. package/dist/{chunk-b1mk12xg.js.map → chunk-8k8534kg.js.map} +1 -1
  65. package/dist/{chunk-ga7c7tq0.js → chunk-8rt4wx8z.js} +3 -3
  66. package/dist/{chunk-ga7c7tq0.js.map → chunk-8rt4wx8z.js.map} +1 -1
  67. package/dist/{chunk-es487acc.js → chunk-a5sbgffr.js} +1 -1
  68. package/dist/{chunk-vgdcz7tk.js → chunk-ap5gek56.js} +2 -2
  69. package/dist/{chunk-vgdcz7tk.js.map → chunk-ap5gek56.js.map} +1 -1
  70. package/dist/{chunk-851k0b26.js → chunk-awp3n119.js} +2 -2
  71. package/dist/{chunk-851k0b26.js.map → chunk-awp3n119.js.map} +1 -1
  72. package/dist/{chunk-d0trs736.js → chunk-cna105t6.js} +2 -2
  73. package/dist/{chunk-d0trs736.js.map → chunk-cna105t6.js.map} +1 -1
  74. package/dist/{chunk-amvy4r59.js → chunk-d4m4amy4.js} +2 -2
  75. package/dist/{chunk-amvy4r59.js.map → chunk-d4m4amy4.js.map} +1 -1
  76. package/dist/{chunk-ddad3902.js → chunk-e6fp6dxx.js} +2 -2
  77. package/dist/{chunk-ddad3902.js.map → chunk-e6fp6dxx.js.map} +1 -1
  78. package/dist/{chunk-qyp652jz.js → chunk-e7axa0d5.js} +3 -3
  79. package/dist/{chunk-qyp652jz.js.map → chunk-e7axa0d5.js.map} +1 -1
  80. package/dist/{chunk-dx7wpz5b.js → chunk-erxv1jz7.js} +2 -2
  81. package/dist/{chunk-dx7wpz5b.js.map → chunk-erxv1jz7.js.map} +1 -1
  82. package/dist/chunk-fakvf9wb.js +5 -0
  83. package/dist/{chunk-d9an2nra.js.map → chunk-fakvf9wb.js.map} +1 -1
  84. package/dist/{chunk-s9rfgxj5.js → chunk-fv9mr1t4.js} +2 -2
  85. package/dist/{chunk-s9rfgxj5.js.map → chunk-fv9mr1t4.js.map} +1 -1
  86. package/dist/{chunk-5az0mq4p.js → chunk-gdmsn3f5.js} +2 -2
  87. package/dist/{chunk-5az0mq4p.js.map → chunk-gdmsn3f5.js.map} +1 -1
  88. package/dist/{chunk-rend2sbk.js → chunk-gv91vjeb.js} +1 -1
  89. package/dist/{chunk-dan79jab.js → chunk-h2r2rdhj.js} +2 -2
  90. package/dist/{chunk-dan79jab.js.map → chunk-h2r2rdhj.js.map} +1 -1
  91. package/dist/{chunk-15a1mrdv.js → chunk-h4pazcgg.js} +2 -2
  92. package/dist/{chunk-15a1mrdv.js.map → chunk-h4pazcgg.js.map} +1 -1
  93. package/dist/{chunk-scbvv2e4.js → chunk-hrvzchxd.js} +2 -2
  94. package/dist/{chunk-scbvv2e4.js.map → chunk-hrvzchxd.js.map} +1 -1
  95. package/dist/{chunk-1pvkw2pq.js → chunk-hytt9qyj.js} +2 -2
  96. package/dist/{chunk-1pvkw2pq.js.map → chunk-hytt9qyj.js.map} +1 -1
  97. package/dist/{chunk-mx9y9mtx.js → chunk-hz6yzzbz.js} +1 -1
  98. package/dist/{chunk-eazqda9z.js → chunk-j3nr4cg0.js} +3 -3
  99. package/dist/{chunk-eazqda9z.js.map → chunk-j3nr4cg0.js.map} +1 -1
  100. package/dist/{chunk-2taa0brj.js → chunk-jk97wv0q.js} +2 -2
  101. package/dist/{chunk-2taa0brj.js.map → chunk-jk97wv0q.js.map} +1 -1
  102. package/dist/{chunk-mrdarm2q.js → chunk-jv4g8grc.js} +2 -2
  103. package/dist/{chunk-mrdarm2q.js.map → chunk-jv4g8grc.js.map} +1 -1
  104. package/dist/{chunk-gcs9ydjv.js → chunk-jyrsd1dn.js} +2 -2
  105. package/dist/{chunk-gcs9ydjv.js.map → chunk-jyrsd1dn.js.map} +1 -1
  106. package/dist/{chunk-yv1psptb.js → chunk-jzp0fs6h.js} +2 -2
  107. package/dist/{chunk-yv1psptb.js.map → chunk-jzp0fs6h.js.map} +1 -1
  108. package/dist/{chunk-tmrmwthr.js → chunk-kcx468qv.js} +2 -2
  109. package/dist/{chunk-tmrmwthr.js.map → chunk-kcx468qv.js.map} +1 -1
  110. package/dist/{chunk-zfter1x0.js → chunk-kg1nbxvm.js} +4 -4
  111. package/dist/{chunk-zfter1x0.js.map → chunk-kg1nbxvm.js.map} +1 -1
  112. package/dist/{chunk-9hr0bcfy.js → chunk-kqb4s1r0.js} +3 -3
  113. package/dist/{chunk-9hr0bcfy.js.map → chunk-kqb4s1r0.js.map} +1 -1
  114. package/dist/{chunk-53bek7sp.js → chunk-m17ktssc.js} +1 -1
  115. package/dist/{chunk-75ptmewf.js → chunk-m2yfvwrn.js} +2 -2
  116. package/dist/{chunk-75ptmewf.js.map → chunk-m2yfvwrn.js.map} +1 -1
  117. package/dist/{chunk-ck0v2kzw.js → chunk-mqcy5vja.js} +2 -2
  118. package/dist/{chunk-ck0v2kzw.js.map → chunk-mqcy5vja.js.map} +1 -1
  119. package/dist/{chunk-f1y8eggf.js → chunk-n672d4g8.js} +2 -2
  120. package/dist/{chunk-f1y8eggf.js.map → chunk-n672d4g8.js.map} +1 -1
  121. package/dist/{chunk-p2fhtf5r.js → chunk-nek1gzz2.js} +3 -3
  122. package/dist/{chunk-p2fhtf5r.js.map → chunk-nek1gzz2.js.map} +1 -1
  123. package/dist/{chunk-jdtn0zk2.js → chunk-pmywkp1w.js} +3 -3
  124. package/dist/{chunk-jdtn0zk2.js.map → chunk-pmywkp1w.js.map} +1 -1
  125. package/dist/chunk-q95k1ymq.js +4 -0
  126. package/dist/{chunk-ryzcfxq7.js.map → chunk-q95k1ymq.js.map} +3 -3
  127. package/dist/{chunk-30yg31sz.js → chunk-r4namj39.js} +2 -2
  128. package/dist/{chunk-30yg31sz.js.map → chunk-r4namj39.js.map} +1 -1
  129. package/dist/{chunk-a9q2cr4w.js → chunk-rrqr1dwq.js} +2 -2
  130. package/dist/{chunk-a9q2cr4w.js.map → chunk-rrqr1dwq.js.map} +1 -1
  131. package/dist/{chunk-xv74rhay.js → chunk-tp3mzj4v.js} +2 -2
  132. package/dist/{chunk-xv74rhay.js.map → chunk-tp3mzj4v.js.map} +1 -1
  133. package/dist/{chunk-csbc1fxa.js → chunk-ty4aj41k.js} +3 -3
  134. package/dist/{chunk-csbc1fxa.js.map → chunk-ty4aj41k.js.map} +1 -1
  135. package/dist/chunk-v9na3dny.js +46 -0
  136. package/dist/{chunk-4sb1484x.js.map → chunk-v9na3dny.js.map} +11 -9
  137. package/dist/{chunk-kk502yk2.js → chunk-w2fpr99k.js} +2 -2
  138. package/dist/{chunk-kk502yk2.js.map → chunk-w2fpr99k.js.map} +1 -1
  139. package/dist/{chunk-et3vhkbf.js → chunk-wwmdqhzy.js} +2 -2
  140. package/dist/{chunk-et3vhkbf.js.map → chunk-wwmdqhzy.js.map} +1 -1
  141. package/dist/chunk-wysm6qte.js +5 -0
  142. package/dist/chunk-wysm6qte.js.map +12 -0
  143. package/dist/{chunk-j9jqxv1d.js → chunk-x157wrgy.js} +2 -2
  144. package/dist/{chunk-j9jqxv1d.js.map → chunk-x157wrgy.js.map} +1 -1
  145. package/dist/{chunk-mvtgx1mr.js → chunk-xrh6k13s.js} +2 -2
  146. package/dist/{chunk-mvtgx1mr.js.map → chunk-xrh6k13s.js.map} +1 -1
  147. package/dist/{chunk-xs4c2nvz.js → chunk-y0wx6w80.js} +2 -2
  148. package/dist/{chunk-xs4c2nvz.js.map → chunk-y0wx6w80.js.map} +1 -1
  149. package/dist/{chunk-wexs11yy.js → chunk-yp5979we.js} +2 -2
  150. package/dist/{chunk-wexs11yy.js.map → chunk-yp5979we.js.map} +1 -1
  151. package/dist/{chunk-qtbf3w6w.js → chunk-z32xfe8c.js} +2 -2
  152. package/dist/{chunk-qtbf3w6w.js.map → chunk-z32xfe8c.js.map} +1 -1
  153. package/dist/{chunk-d8ekyng4.js → chunk-zgn0p8qr.js} +3 -3
  154. package/dist/{chunk-d8ekyng4.js.map → chunk-zgn0p8qr.js.map} +1 -1
  155. package/dist/{chunk-rx2shb3t.js → chunk-zns7xcz9.js} +1 -1
  156. package/dist/config/index.js +1 -1
  157. package/dist/console/run.js +2 -2
  158. package/dist/console/run.js.map +1 -1
  159. package/dist/container/index.js +2 -2
  160. package/dist/container/index.js.map +1 -1
  161. package/dist/database/index.js +2 -2
  162. package/dist/database/index.js.map +1 -1
  163. package/dist/email/index.js +2 -2
  164. package/dist/email/index.js.map +1 -1
  165. package/dist/facades/index.js +2 -2
  166. package/dist/facades/index.js.map +1 -1
  167. package/dist/foundation/index.js +2 -2
  168. package/dist/foundation/index.js.map +1 -1
  169. package/dist/http/HttpRequest.d.ts +31 -0
  170. package/dist/http/HttpRequest.d.ts.map +1 -1
  171. package/dist/http/McpRouter.d.ts +54 -1
  172. package/dist/http/McpRouter.d.ts.map +1 -1
  173. package/dist/http/RateLimitMiddleware.d.ts +4 -1
  174. package/dist/http/RateLimitMiddleware.d.ts.map +1 -1
  175. package/dist/http/index.d.ts +1 -0
  176. package/dist/http/index.d.ts.map +1 -1
  177. package/dist/http/index.js +2 -2
  178. package/dist/http/index.js.map +1 -1
  179. package/dist/http/modelOriginated.d.ts +36 -2
  180. package/dist/http/modelOriginated.d.ts.map +1 -1
  181. package/dist/i18n/dictionaryRuntime.js +2 -2
  182. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  183. package/dist/i18n/index.js +2 -2
  184. package/dist/i18n/index.js.map +1 -1
  185. package/dist/kernel/Kernel.d.ts +3 -0
  186. package/dist/kernel/Kernel.d.ts.map +1 -1
  187. package/dist/kernel/index.js +3 -3
  188. package/dist/kernel/index.js.map +3 -3
  189. package/dist/orm/index.js +2 -2
  190. package/dist/orm/index.js.map +1 -1
  191. package/dist/server/index.js +2 -2
  192. package/dist/server/index.js.map +1 -1
  193. package/dist/services/index.d.ts +8 -2
  194. package/dist/services/index.d.ts.map +1 -1
  195. package/dist/services/index.js +44 -9
  196. package/dist/services/index.js.map +8 -6
  197. package/dist/services/mcp/McpRegistry.d.ts +190 -29
  198. package/dist/services/mcp/McpRegistry.d.ts.map +1 -1
  199. package/dist/services/mcp/http/McpHttpServer.d.ts +153 -0
  200. package/dist/services/mcp/http/McpHttpServer.d.ts.map +1 -0
  201. package/dist/services/mcp/http/callers.d.ts +131 -0
  202. package/dist/services/mcp/http/callers.d.ts.map +1 -0
  203. package/dist/services/mcp/http/limits.d.ts +11 -0
  204. package/dist/services/mcp/http/limits.d.ts.map +1 -0
  205. package/dist/services/mcp/http/oauth/McpOAuthServer.d.ts +150 -0
  206. package/dist/services/mcp/http/oauth/McpOAuthServer.d.ts.map +1 -0
  207. package/dist/services/mcp/http/oauth/consentPage.d.ts +14 -0
  208. package/dist/services/mcp/http/oauth/consentPage.d.ts.map +1 -0
  209. package/dist/services/mcp/http/oauth/store.d.ts +98 -0
  210. package/dist/services/mcp/http/oauth/store.d.ts.map +1 -0
  211. package/dist/services/mcp/http/protocol.d.ts +95 -0
  212. package/dist/services/mcp/http/protocol.d.ts.map +1 -0
  213. package/dist/services/mcp/http/signedState.d.ts +25 -0
  214. package/dist/services/mcp/http/signedState.d.ts.map +1 -0
  215. package/dist/services/queue/work.js +2 -2
  216. package/dist/services/queue/work.js.map +1 -1
  217. package/dist/services/router/ApiRouteDispatcher.d.ts +29 -0
  218. package/dist/services/router/ApiRouteDispatcher.d.ts.map +1 -1
  219. package/dist/services/router/RouteServiceProvider.d.ts +6 -0
  220. package/dist/services/router/RouteServiceProvider.d.ts.map +1 -1
  221. package/dist/services/router/config.d.ts +16 -0
  222. package/dist/services/router/config.d.ts.map +1 -1
  223. package/dist/stats/route-table.js +1 -1
  224. package/dist/support/index.js +2 -2
  225. package/dist/support/index.js.map +1 -1
  226. package/dist/vitest/index.js +1 -1
  227. package/package.json +1 -1
  228. package/dist/chunk-3z9vhjd7.js +0 -5
  229. package/dist/chunk-3z9vhjd7.js.map +0 -10
  230. package/dist/chunk-4sb1484x.js +0 -46
  231. package/dist/chunk-bf1ets45.js +0 -5
  232. package/dist/chunk-bf1ets45.js.map +0 -33
  233. package/dist/chunk-d9an2nra.js +0 -5
  234. package/dist/chunk-j0sncgxc.js +0 -14
  235. package/dist/chunk-ryzcfxq7.js +0 -4
  236. /package/dist/{chunk-es487acc.js.map → chunk-a5sbgffr.js.map} +0 -0
  237. /package/dist/{chunk-rend2sbk.js.map → chunk-gv91vjeb.js.map} +0 -0
  238. /package/dist/{chunk-mx9y9mtx.js.map → chunk-hz6yzzbz.js.map} +0 -0
  239. /package/dist/{chunk-53bek7sp.js.map → chunk-m17ktssc.js.map} +0 -0
  240. /package/dist/{chunk-rx2shb3t.js.map → chunk-zns7xcz9.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  // @bun
2
2
  function E(z){return z}function f(){return{url:process.env.DATABASE_URL,dialect:void 0,options:void 0,slowTransactionThreshold:b,connections:void 0}}var b=2000;class Q extends Error{constructor(z){super(`Could not infer a database dialect from "${z}". Expected a URL starting with postgres://, postgresql://, mysql://, mariadb://, `+"sqlite://, or file: \u2014 or a SQLite path such as ./dev.db or :memory:.");this.name="UnknownDatabaseUrlError"}}class j extends Error{constructor(z){super(z===void 0||z==="default"?"No database URL configured. Set the DATABASE_URL environment variable, or set `url` in app/config/database.ts.":`The "${z}" database connection has no \`url\`. Set one under \`connections.${z}\` in app/config/database.ts.`);this.name="MissingDatabaseUrlError"}}var L={"postgres:":"postgres","postgresql:":"postgres","mysql:":"mysql","mariadb:":"mariadb","sqlite:":"sqlite","file:":"sqlite"},D=[".db",".sqlite",".sqlite3"];function F(z){let B=z.trim();if(B==="")throw new Q(z);if(B===":memory:")return"sqlite";let G=B.indexOf(":");if(G!==-1){let J=B.slice(0,G+1).toLowerCase(),K=L[J];if(K)return K}if(S(B))return"sqlite";throw new Q(z)}function S(z){if(z.startsWith("./")||z.startsWith("../")||z.startsWith("/"))return!0;let B=z.toLowerCase();return D.some((G)=>B.endsWith(G))}function p(z){return z==="sqlite"}function m(z){return z==="mysql"||z==="mariadb"}import{existsSync as g,readFileSync as y,realpathSync as I,statSync as U}from"fs";import{isAbsolute as w,join as H,resolve as q}from"path";var O=H("prisma","schema.prisma");class R extends Error{constructor(z,B,G){super(`"${z}" now resolves to ${B}, which is where Prisma migrates it. gemi used to open ${G} instead, and that file holds data \u2014 so `+`opening the resolved one would quietly leave it behind. gemi will not choose. Move ${G} onto ${B} if it is the database you want, or point DATABASE_URL at an absolute path to say so explicitly.`);this.name="AmbiguousSqlitePathError"}}function C(z){let B=z.trim(),G="",J=B;for(let K of["file://","file:","sqlite://","sqlite:"])if(B.slice(0,K.length).toLowerCase()===K){G=B.slice(0,K.length),J=B.slice(K.length);break}if(J===":memory:"||J.startsWith(":memory:?"))return null;return{prefix:G,file:J}}function _(z,B,G=process.cwd()){if(B!=="sqlite")return{url:z};let J=C(z);if(!J||J.file==="")return{url:z};if(w(J.file))return{url:z};let K=J.file.indexOf("?"),Z=K===-1?J.file:J.file.slice(0,K),$=K===-1?"":J.file.slice(K),X=H(G,"prisma");if(!T(G,z))return{url:z};let W=q(G,Z),Y=q(X,Z);if(W===Y)return{url:z};return{url:`${J.prefix}${Y}${$}`,moved:{from:W,to:Y}}}function T(z,B){let G=H(z,O);if(!g(G))return!1;let J;try{J=y(G,"utf8")}catch{return!1}let Z=J.replace(/^\s*\/\/.*$/gm,"").match(/datasource\s+\w+\s*\{([\s\S]*?)\}/);if(!Z)return!1;let $=Z[1];if(!/provider\s*=\s*["']sqlite["']/.test($))return!1;let X=$.match(/url\s*=\s*env\(\s*["']([^"']+)["']\s*\)/);if(X){let Y=process.env[X[1]];return typeof Y==="string"&&Y.trim()===B.trim()}let W=$.match(/url\s*=\s*["']([^"']+)["']/);return W?W[1].trim()===B.trim():!1}function k(z){try{if(I(z.from)===I(z.to))return null}catch{}try{let B=U(z.from);return B.isFile()&&B.size>0?z.from:null}catch{return null}}var{SQL:A}=globalThis.Bun;var V="default";class P extends Error{constructor(z,B){super(`No database connection named "${z}". Configured: ${B.map((G)=>`"${G}"`).join(", ")}. Declare it under \`connections\` in app/config/database.ts.`);this.name="UnknownConnectionError"}}class x extends Error{constructor(z){super(`"${z}" is the name of the connection declared by the top-level \`url\` and \`options\`, so it cannot also appear under \`connections\`. Rename it, or move its settings up to the top level.`);this.name="ReservedConnectionNameError"}}class N extends Error{open;requested;constructor(z,B){super(`A transaction is open on the "${z}" connection, and this statement names "${B}". A transaction cannot span two connections: the statement would run outside it and stay committed when the transaction rolls back. Move this query outside the transaction, or run the whole unit on one connection.`);this.open=z;this.requested=B;this.name="CrossConnectionTransactionError"}}class M{name;config;sql;dialect;url;ready;constructor(z,B={}){this.name=z;this.config=B;let G=B.url;if(!G)throw new j(z);this.dialect=B.dialect??F(G);let J=_(G,this.dialect);if(J.moved){let K=k(J.moved);if(K)throw new R(G,J.moved.to,K)}this.url=J.url,this.sql=B.options?new A(this.url,B.options):new A(this.url),this.ready=this.configure()}async configure(){if(this.dialect!=="sqlite")return;await this.sql.unsafe("pragma foreign_keys = ON")}get query(){return this.sql}async close(){this.ready.catch(()=>{}),await this.sql.close()}}class h{config;static token="database";name=V;pools=new Map;ready;constructor(z={}){this.config=z;let{connections:B={},...G}=z;this.pools.set(V,new M(V,G));try{this.build(B,G.slowTransactionThreshold)}catch(J){for(let K of this.pools.values())K.ready.catch(()=>{}),K.close().catch(()=>{});throw J}this.ready=Promise.all([...this.pools.values()].map((J)=>J.ready)).then(()=>{return})}build(z,B){for(let[G,J]of Object.entries(z)){if(G===V)throw new x(G);this.pools.set(G,new M(G,{slowTransactionThreshold:B,...J}))}}connection(z=V){if(z===V)return this;let B=this.pools.get(z);if(!B)throw new P(z,this.connectionNames);return B}get connectionNames(){return[...this.pools.keys()]}get sql(){return this.default.sql}get dialect(){return this.default.dialect}get url(){return this.default.url}get query(){return this.sql}async close(){this.ready.catch(()=>{}),await Promise.all([...this.pools.values()].map((z)=>z.close()))}get default(){return this.pools.get(V)}}
3
- export{E as Sg,f as Tg,b as Ug,Q as Vg,j as Wg,F as Xg,p as Yg,m as Zg,R as _g,V as $g,P as ah,x as bh,N as ch,M as dh,h as eh};
3
+ export{E as ph,f as qh,b as rh,Q as sh,j as th,F as uh,p as vh,m as wh,R as xh,V as yh,P as zh,x as Ah,N as Bh,M as Ch,h as Dh};
4
4
 
5
- //# debugId=11A745ADDC7EE95464756E2164756E21
5
+ //# debugId=4D9B188A8AC30CF164756E2164756E21
@@ -9,6 +9,6 @@
9
9
  "import type { SQL } from \"bun\";\nimport type { ConnectionConfig, DatabaseConfig } from \"./config\";\nimport {\n Connection,\n DEFAULT_CONNECTION,\n ReservedConnectionNameError,\n UnknownConnectionError,\n type DatabaseConnection,\n} from \"./Connection\";\nimport type { Dialect } from \"./dialect\";\n\n// Wraps Bun's `SQL` client. Bun ships one client that speaks SQLite, Postgres,\n// MySQL and MariaDB, so gemi does not need a driver per database — it needs to\n// know *which* one is in use, which is what `dialect` carries.\n//\n// Safe to build eagerly: Bun's client connects on the first query, not at\n// construction. (`RedisManager` used to be cited here as the parallel case. As\n// of #403 it builds its client in a memoizing getter instead — not because\n// eager construction was unsafe, but because naming Bun's `RedisClient` at\n// module scope is what made `gemi/services` unloadable off Bun. `Connection`\n// still imports `SQL` as a value for the same reason, which is the remaining\n// half of #396.) It is still bound as a lazy singleton,\n// so an app that never touches the database never resolves it and never has to\n// have DATABASE_URL set.\n//\n// Since #327 it holds *connections*, plural: the top-level `url` and `options`\n// build the one called `\"default\"`, and each key under `connections` builds\n// another. What it does not do is decide which one a query uses — that is the\n// ORM's ambient scope and the `DB` facade, because the choice is per query\n// rather than per application. See `connection` below.\nexport class DatabaseManager implements DatabaseConnection {\n static token = \"database\";\n\n /**\n * This object *is* the default connection, so it answers to the name.\n *\n * Not a formality: `connection(\"default\")` returns `this` rather than the\n * `Connection` in the map, which is what keeps every existing reader —\n * `DB.sql`, `db.dialect`, and the test harnesses that wrap the manager in a\n * Proxy to count statements — looking at the same object the ORM executes\n * through. A second object for the default pool would have quietly bypassed\n * all of them while every test still passed.\n */\n public readonly name = DEFAULT_CONNECTION;\n\n /**\n * Every pool this manager owns, keyed by name and including the default one.\n *\n * Private because the map is the manager's bookkeeping — `connection()` is\n * the way in, and it is the only path that knows the default is `this`.\n */\n private readonly pools = new Map<string, Connection>();\n\n /**\n * Resolves once **every** connection has been configured, or rejects if one\n * could not be. Only SQLite has anything to do; elsewhere it is already\n * resolved.\n *\n * All of them rather than the default alone, because the thing a caller waits\n * on this for — SQLite's `pragma foreign_keys` — is per client, so a second\n * SQLite connection has its own and a caller awaiting one manager-level\n * promise means all of them.\n */\n public readonly ready: Promise<void>;\n\n constructor(public config: DatabaseConfig = {}) {\n const { connections = {}, ...primary } = config;\n\n // The default first, so a `MissingDatabaseUrlError` from a missing\n // `DATABASE_URL` still comes out of construction the way it always has,\n // rather than after a named connection has already opened a client.\n this.pools.set(\n DEFAULT_CONNECTION,\n new Connection(DEFAULT_CONNECTION, primary),\n );\n\n // A connection that is built before the one whose config is wrong is still\n // a live client with an open handle, and on the throwing path nothing else\n // will ever hold it: the manager never becomes a value, so nobody can call\n // `close`. Left alone, the pragma this constructor issues for a SQLite\n // connection settles against a client being torn down and surfaces as an\n // unhandled rejection with no configuration error anywhere near it.\n try {\n this.build(connections, primary.slowTransactionThreshold);\n } catch (error) {\n for (const pool of this.pools.values()) {\n // The in-flight configuration first: it is what rejects when the client\n // under it goes away, and this is the only place that can say the\n // rejection was expected.\n pool.ready.catch(() => {});\n pool.close().catch(() => {});\n }\n throw error;\n }\n\n // Built once here rather than derived per read, so that a connection whose\n // configuration rejects produces one unhandled rejection at most instead of\n // a fresh one per access.\n this.ready = Promise.all(\n [...this.pools.values()].map((pool) => pool.ready),\n ).then(() => undefined);\n }\n\n private build(\n connections: Record<string, ConnectionConfig>,\n slowTransactionThreshold: number | false | undefined,\n ): void {\n for (const [name, connection] of Object.entries(connections)) {\n if (name === DEFAULT_CONNECTION)\n throw new ReservedConnectionNameError(name);\n\n this.pools.set(\n name,\n new Connection(name, {\n // The threshold is the one setting a named connection is likely to\n // want *unchanged*: it is a development diagnostic about holding a\n // pooled connection, and that concern does not stop applying because\n // the pool has a name. `url`, `options` and `dialect` are deliberately\n // not inherited — a connection that borrowed the default's URL by\n // omission would be a second pool onto the same database created by a\n // typo in a key.\n slowTransactionThreshold,\n ...connection,\n }),\n );\n }\n }\n\n /**\n * The connection called `name`, or the default one when called with nothing.\n *\n * Throws rather than falling back to the default for an unknown name, and\n * that is the important half. A fallback would make `Model.on(\"analitycs\")`\n * run on the hot path — the exact pool the caller was trying to stay off —\n * and the only symptom would be the incident it was meant to prevent,\n * arriving weeks later with nothing pointing back at the typo.\n */\n connection(name: string = DEFAULT_CONNECTION): DatabaseConnection {\n // `this`, not `pools.get(DEFAULT_CONNECTION)` — see `name` above.\n if (name === DEFAULT_CONNECTION) return this;\n\n const found = this.pools.get(name);\n if (!found) throw new UnknownConnectionError(name, this.connectionNames);\n return found;\n }\n\n /** Every configured name, default first. For error messages and diagnostics. */\n get connectionNames(): string[] {\n return [...this.pools.keys()];\n }\n\n /**\n * The default connection's client. Unchanged in meaning: an application that\n * never names a connection sees exactly what it saw before #327.\n */\n get sql(): SQL {\n return this.default.sql;\n }\n\n get dialect(): Dialect {\n return this.default.dialect;\n }\n\n get url(): string {\n return this.default.url;\n }\n\n // Escape hatch matching Bun's own API, so `db.query` reads like `sql` does in\n // Bun's docs: db.query`select * from users where id = ${id}`\n get query(): SQL {\n return this.sql;\n }\n\n /** Closes every connection, not only the default one. */\n async close(): Promise<void> {\n // The aggregate promise needs the same treatment each connection's own\n // `ready` gets in `Connection.close` — it is derived from them, so a\n // rejection there arrives here as a second, separately unhandled one.\n this.ready.catch(() => {});\n await Promise.all([...this.pools.values()].map((pool) => pool.close()));\n }\n\n private get default(): Connection {\n return this.pools.get(DEFAULT_CONNECTION)!;\n }\n}\n"
10
10
  ],
11
11
  "mappings": ";AA6FO,SAAS,CAAoB,CAAC,EAAwC,CAC3E,OAAO,EAGF,SAAS,CAAsB,EAAmB,CACvD,MAAO,CACL,IAAK,QAAQ,IAAI,aACjB,QAAS,OACT,QAAS,OACT,yBAA0B,EAC1B,YAAa,MACf,EAOK,IAAM,EAA6B,KCxGnC,MAAM,UAAgC,KAAM,CACjD,WAAW,CAAC,EAAa,CACvB,MACE,4CAA4C,sFAE1C,2EACJ,EACA,KAAK,KAAO,0BAEhB,CAEO,MAAM,UAAgC,KAAM,CAKjD,WAAW,CAAC,EAAqB,CAC/B,MACE,IAAe,QAAa,IAAe,UACvC,iHAEA,QAAQ,sEACiB,gCAC/B,EACA,KAAK,KAAO,0BAEhB,CAEA,IAAM,EAAqC,CACzC,YAAa,WACb,cAAe,WACf,SAAU,QACV,WAAY,UACZ,UAAW,SACX,QAAS,QACX,EAEM,EAAyB,CAAC,MAAO,UAAW,UAAU,EAUrD,SAAS,CAAY,CAAC,EAAsB,CACjD,IAAM,EAAU,EAAI,KAAK,EAEzB,GAAI,IAAY,GACd,MAAM,IAAI,EAAwB,CAAG,EAKvC,GAAI,IAAY,WACd,MAAO,SAGT,IAAM,EAAY,EAAQ,QAAQ,GAAG,EACrC,GAAI,IAAc,GAAI,CACpB,IAAM,EAAW,EAAQ,MAAM,EAAG,EAAY,CAAC,EAAE,YAAY,EACvD,EAAU,EAAU,GAC1B,GAAI,EACF,OAAO,EAOX,GAAI,EAAoB,CAAO,EAC7B,MAAO,SAGT,MAAM,IAAI,EAAwB,CAAG,EAGvC,SAAS,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O,KAAK,SAIR,MAAK,EAAkB,CAI3B,KAAK,MAAM,MAAM,IAAM,EAAE,EACzB,MAAM,QAAQ,IAAI,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC,EAAE,IAAI,CAAC,IAAS,EAAK,MAAM,CAAC,CAAC,KAG5D,QAAO,EAAe,CAChC,OAAO,KAAK,MAAM,IAAI,CAAkB,EAE5C",
12
- "debugId": "11A745ADDC7EE95464756E2164756E21",
12
+ "debugId": "4D9B188A8AC30CF164756E2164756E21",
13
13
  "names": []
14
14
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
2
  function H(z){if(z===401)return"authentication";if(z===403)return"permission";if(z===404)return"not_found";if(z===416)return"range_not_satisfiable";if(z===429)return"rate_limit";if(z>=500)return"server_error";return"form_error"}var N="GEMI_REQUEST_BREAKER_ERROR";class J extends Error{static legacyStringPayload=!1;kind=N;payload;constructor(z,C={}){super(z);let D=C.status??400;this.payload={api:{status:D,data:{error:L(C.kind??H(D),z??"",D)},...C.headers?{headers:C.headers}:{}},view:{status:D}}}}function L(z,C,D){return{kind:z,message:C,status:D}}function X(z,C,D){return J.legacyStringPayload?C:L(z,C,D)}
3
- export{H as pg,N as qg,J as rg,L as sg,X as tg};
3
+ export{H as Og,N as Pg,J as Qg,L as Rg,X as Sg};
4
4
 
5
- //# debugId=D2BFC0A6B1952C4C64756E2164756E21
5
+ //# debugId=70D38DF4A4A454A564756E2164756E21
@@ -6,6 +6,6 @@
6
6
  "import { refusalKindForStatus, type Refusal, type RefusalKind } from \"./refusal\";\n\nexport const GEMI_REQUEST_BREAKER_ERROR = \"GEMI_REQUEST_BREAKER_ERROR\";\n\nexport type RequestBreakerOptions = {\n /** The answer's status. 400 when absent. */\n status?: number;\n /**\n * What the client's guards classify it as. Absent, it follows from\n * `status`: 401 `authentication`, 403 `permission`, 404 `not_found`, 429\n * `rate_limit`, 5xx `server_error`, any other status `form_error`.\n */\n kind?: Exclude<RefusalKind, \"validation_error\">;\n /** Extra headers for the API answer. */\n headers?: Record<string, string>;\n};\n\nexport class RequestBreakerError extends Error {\n /**\n * Answer the refusals that were bare strings before 0.88 — authentication,\n * authorization, permission, CSRF and a 500 — with that string again,\n * instead of `{ kind, message, status }`.\n *\n * For a shipped native client that reads `body.error` as a string and cannot\n * be rolled forward in the same deploy as the server. Set it once at boot,\n * and remove the line when the clients read `body.error.message`:\n *\n * ```ts\n * RequestBreakerError.legacyStringPayload = true;\n * ```\n *\n * gemi's own web client reads either shape. Refusals that were already\n * objects (404, 429, a policy 403) stay objects.\n */\n static legacyStringPayload = false;\n\n public kind = GEMI_REQUEST_BREAKER_ERROR;\n public payload: {\n api: Record<string, any>;\n view: Record<string, any>;\n /**\n * What a `.json` view navigation answers, when that differs from `api`.\n * Absent, it gets `api` — right for most breakers, but not for one that\n * must be a 401 to an API client and a redirect to the client router.\n */\n viewData?: Record<string, any>;\n };\n\n /**\n * A refusal that answers `{ error: { kind, message, status } }` with\n * `status`, so the client's guards classify it without a payload of your\n * own. A subclass that sets `payload` itself replaces this.\n *\n * ```ts\n * throw new RequestBreakerError(\"This slug is taken\", { status: 409 });\n * // → 409 { error: { kind: \"form_error\", message: \"This slug is taken\", status: 409 } }\n * ```\n */\n constructor(message?: string, options: RequestBreakerOptions = {}) {\n super(message);\n const status = options.status ?? 400;\n this.payload = {\n api: {\n status,\n data: {\n error: refusal(options.kind ?? refusalKindForStatus(status), message ?? \"\", status),\n },\n ...(options.headers ? { headers: options.headers } : {}),\n },\n view: { status },\n };\n }\n}\n\n/** A refusal's `error` field. */\nexport function refusal<K extends Exclude<RefusalKind, \"validation_error\">>(\n kind: K,\n message: string,\n status: number,\n): Refusal<K> {\n return { kind, message, status };\n}\n\n/**\n * A refusal that was a bare string before 0.88: the object, or the string\n * under `RequestBreakerError.legacyStringPayload`.\n *\n * @internal\n */\nexport function stringEraRefusal<K extends Exclude<RefusalKind, \"validation_error\">>(\n kind: K,\n message: string,\n status: number,\n): Refusal<K> | string {\n return RequestBreakerError.legacyStringPayload ? message : refusal(kind, message, status);\n}\n"
7
7
  ],
8
8
  "mappings": ";AAqDO,SAAS,CAAoB,CAAC,EAA0D,CAC7F,GAAI,IAAW,IAAK,MAAO,iBAC3B,GAAI,IAAW,IAAK,MAAO,aAC3B,GAAI,IAAW,IAAK,MAAO,YAC3B,GAAI,IAAW,IAAK,MAAO,wBAC3B,GAAI,IAAW,IAAK,MAAO,aAC3B,GAAI,GAAU,IAAK,MAAO,eAC1B,MAAO,aC1DF,IAAM,EAA6B,6BAenC,MAAM,UAA4B,KAAM,OAiBtC,qBAAsB,GAEtB,KAAO,EACP,QAqBP,WAAW,CAAC,EAAkB,EAAiC,CAAC,EAAG,CACjE,MAAM,CAAO,EACb,IAAM,EAAS,EAAQ,QAAU,IACjC,KAAK,QAAU,CACb,IAAK,CACH,SACA,KAAM,CACJ,MAAO,EAAQ,EAAQ,MAAQ,EAAqB,CAAM,EAAG,GAAW,GAAI,CAAM,CACpF,KACI,EAAQ,QAAU,CAAE,QAAS,EAAQ,OAAQ,EAAI,CAAC,CACxD,EACA,KAAM,CAAE,QAAO,CACjB,EAEJ,CAGO,SAAS,CAA2D,CACzE,EACA,EACA,EACY,CACZ,MAAO,CAAE,OAAM,UAAS,QAAO,EAS1B,SAAS,CAAoE,CAClF,EACA,EACA,EACqB,CACrB,OAAO,EAAoB,oBAAsB,EAAU,EAAQ,EAAM,EAAS,CAAM",
9
- "debugId": "D2BFC0A6B1952C4C64756E2164756E21",
9
+ "debugId": "70D38DF4A4A454A564756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Fa as y}from"./chunk-5stgtwqw.js";import{createElement as q}from"react";function z(i,n){let p=Object.keys(n).sort((s,g)=>g.length-s.length).map((s)=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),b=new RegExp(p.join("|"),"g");return i.replace(b,(s)=>n[s])}async function L(i,n,p=[],b){let s=[...p.map((t)=>`${i}/views/${t}.tsx`),b?`${i}/views/${b}.tsx`:`${i}/views/RootLayout.tsx`],g=new Set;for(let t of s){let u=n.moduleGraph.getModulesByFile(t);if(u)for(let x of u)g.add(x)}let e=[],l=[],r={};for(let t of g)if(t)for(let u of t.importedModules){if(u.file.includes("module.css"))r[u.file]=u.ssrTransformResult.map.sourcesContent.join("");if(u.file.includes(".css"))l.push(u.file)}for(let t of l){let u=await n.transformRequest(t+"?direct"),x=t.includes("module.css"),k="";if(x)k=z(r[t],u.default);e.push({isDev:!0,id:t,content:x?k:u.code})}return e.map((t,u)=>{return q("style",{key:u,type:"text/css","data-vite-dev-id":t.id,dangerouslySetInnerHTML:{__html:t.content}})})}async function _(i=[]){return i.map((n,p)=>{return q("style",{key:p,id:n?.id,type:"text/css",dangerouslySetInnerHTML:{__html:n.content}})})}import{existsSync as J}from"fs";import{basename as N}from"path";import{networkInterfaces as O}from"os";var v={name:"gemi",version:"0.112.1",private:!1,license:"MIT",author:"Enes Tufekci <enes@gemijs.dev>",repository:{type:"git",url:"git+https://github.com/nstfkc/gemi.git",directory:"packages/gemi"},bin:{gemi:"./dist/bin/gemi.js","gemi-orm-generator":"./dist/bin/orm-generator.js"},files:["dist/**/*","ide/typescript-plugin/package.json","skills/**/*"],module:!0,exports:{"./http":"./http/index.ts","./client":"./client/index.ts","./ai":"./ai/index.ts","./ai/client":"./ai/client/index.ts","./testing":"./testing/index.ts","./app":"./app/index.ts","./facades":"./facades/index.ts","./email":"./email/index.ts","./vite":"./dist/vite/index.mjs","./kernel":"./kernel/index.ts","./services":"./services/index.ts","./i18n":"./i18n/index.ts","./dictionary":"./i18n/dictionaryRuntime.ts","./server":"./server/index.ts","./config":"./config/index.ts","./container":"./container/index.ts","./foundation":"./foundation/index.ts","./database":"./database/index.ts","./orm":"./orm/index.ts","./support":"./support/index.ts","./console/run":"./console/run.ts","./queue/work":"./services/queue/work.ts","./stats/route-table":"./stats/route-table.ts","./ide/typescript-plugin":"./ide/typescript-plugin/index.ts","./bun/preload":"./bun/preload.ts","./bun/plugin":"./bun/plugin.ts","./vitest":"./vitest/index.ts"},scripts:{lint:"oxlint",typecheck:"tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json && tsc --noEmit -p ide/typescript-plugin/tsconfig.json",build:"NODE_ENV=production bun run build:core && bun run build:bin && bun run build:types && bun run build:client && bun run build:plugin && bun run build:ts-plugin && bun run build:client-types && bun run build:augmentation","build:core":"bun ./scripts/build.ts","build:bin":"bun build --outdir=./dist/bin --target=bun --external=vite --external=react-dom --external=react/jsx-runtime --external=bun --external=sharp --external=@azure/storage-blob --external=typescript --sourcemap ./bin/gemi.ts ./bin/orm-generator.ts && bun ./scripts/prepare-bin.ts","build:client":"rm -rf dist/client dist/testing dist/ai/client dist/chunks && vite build -c vite.client.config.mts","build:plugin":"vite build -c vite.plugin.config.mts","build:ts-plugin":"bun ./scripts/build-ts-plugin.ts","build:types":"tsc -p tsconfig.build.json","build:client-types":"tsc -p tsconfig.browser.json",test:"bun --bun x vitest","test:types":"vitest run --typecheck.only","test:live":"bun --bun x vitest run ai/live","test:packaging":"bun --bun x vitest run --config vitest.packaging.config.ts","build:publish":"bun scripts/build-publish.ts",prepublishOnly:"echo 'Do not publish from this directory \u2014 its exports point at TS source. Run: bun run build:publish, then publish from .publish/' && exit 1","build:augmentation":"bun ./scripts/wire-augmentation.ts"},dependencies:{"@aws-sdk/client-s3":"^3.629.0","@aws-sdk/s3-request-presigner":"^3.629.0","ast-types":"^0.14.2",commander:"^12.1.0",history:"^5.3.0","jsx-email":"2.0.0-rc2.1","magic-string":"^0.30.17",open:"^10.1.0","react-error-boundary":"^6.0.0",recast:"^0.23.9",resend:"^6.12.3",satori:"^0.12.2","temporal-polyfill":"^0.2.5","twitter-api-v2":"^1.20.2","urlpattern-polyfill":"^10.0.0",uuid:"^9.0.1"},devDependencies:{"@babel/parser":"^7.25.4","@prisma/generator-helper":"^6.5.0","@repo/typescript-config":"*","@testing-library/react":"^16.3.2","@types/bun":"^1.3.14","@types/eslint":"^8.56.5","@types/node":"^20.11.24","@types/react":"^19.0.2","@types/react-dom":"^19.0.2",eslint:"^8.57.0",jsdom:"^30.0.1",oxlint:"^1.39.0",postgres:"^3.4.5",react:"19.2.3","react-dom":"19.2.3",typescript:"^5.7.3",vitest:"^4.0.0"},peerDependencies:{"@azure/storage-blob":"^12.28.0",react:">=19","react-dom":">=19",sharp:"^0.34.2",typescript:">=5",vite:"^8.0.0",postgres:"^3.4.0"},peerDependenciesMeta:{"@azure/storage-blob":{optional:!0},typescript:{optional:!0},postgres:{optional:!0}}};var Q=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551","\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D"],W=Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,c=(i,n)=>W?`\x1B[${i}m${n}\x1B[0m`:n,X=(i)=>c("1",i),d=(i)=>c("2",i),j=(i)=>c("36",i),Y=(i)=>c("32",i),Z=(i)=>c("35",i);function $(){return v.version??"?"}function f(i){for(let n of Object.values(O()))for(let p of n??[])if((p.family==="IPv4"||p.family===4)&&!p.internal)return`http://${p.address}:${i}`;return null}function H(i){return y(i).filter((n)=>J(n)).map((n)=>N(n))}function T(i){let{port:n,rootDir:p}=i,b=`http://localhost:${n}`,s=f(n),g=H(p),e=(r,t)=>` ${Y("\u279C")} ${X(r.padEnd(9))}${t}`,l=["",...Q.map((r)=>Z(r)),"",` ${d("gemi")} ${j(`v${$()}`)}`,"",e("Local:",j(b)),e("Network:",s?j(s):d("unavailable")),e("Env:",g.length?g.join(", "):d("none")),""];console.log(l.join(`
2
+ import{Fa as y}from"./chunk-5stgtwqw.js";import{createElement as q}from"react";function z(i,n){let p=Object.keys(n).sort((s,g)=>g.length-s.length).map((s)=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),b=new RegExp(p.join("|"),"g");return i.replace(b,(s)=>n[s])}async function L(i,n,p=[],b){let s=[...p.map((t)=>`${i}/views/${t}.tsx`),b?`${i}/views/${b}.tsx`:`${i}/views/RootLayout.tsx`],g=new Set;for(let t of s){let u=n.moduleGraph.getModulesByFile(t);if(u)for(let x of u)g.add(x)}let e=[],l=[],r={};for(let t of g)if(t)for(let u of t.importedModules){if(u.file.includes("module.css"))r[u.file]=u.ssrTransformResult.map.sourcesContent.join("");if(u.file.includes(".css"))l.push(u.file)}for(let t of l){let u=await n.transformRequest(t+"?direct"),x=t.includes("module.css"),k="";if(x)k=z(r[t],u.default);e.push({isDev:!0,id:t,content:x?k:u.code})}return e.map((t,u)=>{return q("style",{key:u,type:"text/css","data-vite-dev-id":t.id,dangerouslySetInnerHTML:{__html:t.content}})})}async function _(i=[]){return i.map((n,p)=>{return q("style",{key:p,id:n?.id,type:"text/css",dangerouslySetInnerHTML:{__html:n.content}})})}import{existsSync as J}from"fs";import{basename as N}from"path";import{networkInterfaces as O}from"os";var v={name:"gemi",version:"0.114.0",private:!1,license:"MIT",author:"Enes Tufekci <enes@gemijs.dev>",repository:{type:"git",url:"git+https://github.com/nstfkc/gemi.git",directory:"packages/gemi"},bin:{gemi:"./dist/bin/gemi.js","gemi-orm-generator":"./dist/bin/orm-generator.js"},files:["dist/**/*","ide/typescript-plugin/package.json","skills/**/*"],module:!0,exports:{"./http":"./http/index.ts","./client":"./client/index.ts","./ai":"./ai/index.ts","./ai/client":"./ai/client/index.ts","./testing":"./testing/index.ts","./app":"./app/index.ts","./facades":"./facades/index.ts","./email":"./email/index.ts","./vite":"./dist/vite/index.mjs","./kernel":"./kernel/index.ts","./services":"./services/index.ts","./i18n":"./i18n/index.ts","./dictionary":"./i18n/dictionaryRuntime.ts","./server":"./server/index.ts","./config":"./config/index.ts","./container":"./container/index.ts","./foundation":"./foundation/index.ts","./database":"./database/index.ts","./orm":"./orm/index.ts","./support":"./support/index.ts","./console/run":"./console/run.ts","./queue/work":"./services/queue/work.ts","./stats/route-table":"./stats/route-table.ts","./ide/typescript-plugin":"./ide/typescript-plugin/index.ts","./bun/preload":"./bun/preload.ts","./bun/plugin":"./bun/plugin.ts","./vitest":"./vitest/index.ts"},scripts:{lint:"oxlint",typecheck:"tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json && tsc --noEmit -p ide/typescript-plugin/tsconfig.json",build:"NODE_ENV=production bun run build:core && bun run build:bin && bun run build:types && bun run build:client && bun run build:plugin && bun run build:ts-plugin && bun run build:client-types && bun run build:augmentation","build:core":"bun ./scripts/build.ts","build:bin":"bun build --outdir=./dist/bin --target=bun --external=vite --external=react-dom --external=react/jsx-runtime --external=bun --external=sharp --external=@azure/storage-blob --external=typescript --sourcemap ./bin/gemi.ts ./bin/orm-generator.ts && bun ./scripts/prepare-bin.ts","build:client":"rm -rf dist/client dist/testing dist/ai/client dist/chunks && vite build -c vite.client.config.mts","build:plugin":"vite build -c vite.plugin.config.mts","build:ts-plugin":"bun ./scripts/build-ts-plugin.ts","build:types":"tsc -p tsconfig.build.json","build:client-types":"tsc -p tsconfig.browser.json",test:"bun --bun x vitest","test:types":"vitest run --typecheck.only","test:live":"bun --bun x vitest run ai/live","test:packaging":"bun --bun x vitest run --config vitest.packaging.config.ts","build:publish":"bun scripts/build-publish.ts",prepublishOnly:"echo 'Do not publish from this directory \u2014 its exports point at TS source. Run: bun run build:publish, then publish from .publish/' && exit 1","build:augmentation":"bun ./scripts/wire-augmentation.ts"},dependencies:{"@aws-sdk/client-s3":"^3.629.0","@aws-sdk/s3-request-presigner":"^3.629.0","ast-types":"^0.14.2",commander:"^12.1.0",history:"^5.3.0","jsx-email":"2.0.0-rc2.1","magic-string":"^0.30.17",open:"^10.1.0","react-error-boundary":"^6.0.0",recast:"^0.23.9",resend:"^6.12.3",satori:"^0.12.2","temporal-polyfill":"^0.2.5","twitter-api-v2":"^1.20.2","urlpattern-polyfill":"^10.0.0",uuid:"^9.0.1"},devDependencies:{"@babel/parser":"^7.25.4","@prisma/generator-helper":"^6.5.0","@repo/typescript-config":"*","@testing-library/react":"^16.3.2","@types/bun":"^1.3.14","@types/eslint":"^8.56.5","@types/node":"^20.11.24","@types/react":"^19.0.2","@types/react-dom":"^19.0.2",eslint:"^8.57.0",jsdom:"^30.0.1",oxlint:"^1.39.0",postgres:"^3.4.5",react:"19.2.3","react-dom":"19.2.3",typescript:"^5.7.3",vitest:"^4.0.0"},peerDependencies:{"@azure/storage-blob":"^12.28.0",react:">=19","react-dom":">=19",sharp:"^0.34.2",typescript:">=5",vite:"^8.0.0",postgres:"^3.4.0"},peerDependenciesMeta:{"@azure/storage-blob":{optional:!0},typescript:{optional:!0},postgres:{optional:!0}}};var Q=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551","\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D"],W=Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,c=(i,n)=>W?`\x1B[${i}m${n}\x1B[0m`:n,X=(i)=>c("1",i),d=(i)=>c("2",i),j=(i)=>c("36",i),Y=(i)=>c("32",i),Z=(i)=>c("35",i);function $(){return v.version??"?"}function f(i){for(let n of Object.values(O()))for(let p of n??[])if((p.family==="IPv4"||p.family===4)&&!p.internal)return`http://${p.address}:${i}`;return null}function H(i){return y(i).filter((n)=>J(n)).map((n)=>N(n))}function T(i){let{port:n,rootDir:p}=i,b=`http://localhost:${n}`,s=f(n),g=H(p),e=(r,t)=>` ${Y("\u279C")} ${X(r.padEnd(9))}${t}`,l=["",...Q.map((r)=>Z(r)),"",` ${d("gemi")} ${j(`v${$()}`)}`,"",e("Local:",j(b)),e("Network:",s?j(s):d("unavailable")),e("Env:",g.length?g.join(", "):d("none")),""];console.log(l.join(`
3
3
  `))}function I(i=process.env.SERVER_IDLE_TIMEOUT){if(i===void 0||i.trim()==="")return 10;let n=Number(i.trim());if(!Number.isInteger(n)||n<0||n>255)throw Error(`SERVER_IDLE_TIMEOUT must be a whole number of seconds from 0 to 255 (0 disables the timeout), got ${JSON.stringify(i)}.`);return n}
4
4
  export{L as R,_ as S,T,I as U};
5
5
 
6
- //# debugId=629A59C3BB94F49D64756E2164756E21
6
+ //# debugId=CC6D84D87A42B15164756E2164756E21
@@ -7,6 +7,6 @@
7
7
  "/**\n * Bun's default, and what both servers use when `SERVER_IDLE_TIMEOUT` is unset.\n */\nexport const DEFAULT_SERVER_IDLE_TIMEOUT = 10;\n\n/**\n * The `idleTimeout` (seconds) both `gemi dev` and `gemi start` pass to\n * `Bun.serve`, from `SERVER_IDLE_TIMEOUT` (#787).\n *\n * One reader for both servers, so a long-poll that works under `gemi start`\n * also works under `gemi dev`. Before this, only `httpProd` read the variable\n * and the dev server always ran at Bun's 10 seconds.\n *\n * It is the time a connection may stay silent, a response that has not started\n * included, before Bun closes it; `0` disables it. It does not apply to an\n * upgraded websocket (the HMR relay included), which has its own\n * `websocket.idleTimeout`.\n *\n * Unset or blank means the default. Anything that is not a whole number from 0\n * to 255 (Bun's own limits) fails the boot with the variable's name, instead\n * of Bun's \"expects idleTimeout to be an integer\", which does not say where the\n * value came from.\n */\nexport function serverIdleTimeout(raw: string | undefined = process.env.SERVER_IDLE_TIMEOUT): number {\n if (raw === undefined || raw.trim() === \"\") return DEFAULT_SERVER_IDLE_TIMEOUT;\n\n const seconds = Number(raw.trim());\n if (!Number.isInteger(seconds) || seconds < 0 || seconds > 255) {\n throw new Error(\n `SERVER_IDLE_TIMEOUT must be a whole number of seconds from 0 to 255 ` +\n `(0 disables the timeout), got ${JSON.stringify(raw)}.`,\n );\n }\n return seconds;\n}\n"
8
8
  ],
9
9
  "mappings": ";yCAAA,wBAAS,cAGT,SAAS,CAAc,CAAC,EAAc,EAAwC,CAC5E,IAAM,EAAc,OAAO,KAAK,CAAM,EACnC,KAAK,CAAC,EAAG,IAAM,EAAE,OAAS,EAAE,MAAM,EAClC,IA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O,CAAC,CAAC,IAAI,IAEvC,EAAM,CACV,GACA,GAAG,EAAI,IAAI,CAAC,IAAS,EAAQ,CAAI,CAAC,EAClC,GACA,KAAK,EAAI,MAAM,KAAK,EAAK,IAAI,EAAY,GAAG,IAC5C,GACA,EAAI,SAAU,EAAK,CAAK,CAAC,EACzB,EAAI,WAAY,EAAU,EAAK,CAAO,EAAI,EAAI,aAAa,CAAC,EAC5D,EAAI,OAAQ,EAAI,OAAS,EAAI,KAAK,IAAI,EAAI,EAAI,MAAM,CAAC,EACrD,EACF,EAEA,QAAQ,IAAI,EAAI,KAAK;AAAA,CAAI,CAAC,EC/CrB,SAAS,CAAiB,CAAC,EAA0B,QAAQ,IAAI,oBAA6B,CACnG,GAAI,IAAQ,QAAa,EAAI,KAAK,IAAM,GAAI,MArBH,IAuBzC,IAAM,EAAU,OAAO,EAAI,KAAK,CAAC,EACjC,GAAI,CAAC,OAAO,UAAU,CAAO,GAAK,EAAU,GAAK,EAAU,IACzD,MAAU,MACR,qGACmC,KAAK,UAAU,CAAG,IACvD,EAEF,OAAO",
10
- "debugId": "629A59C3BB94F49D64756E2164756E21",
10
+ "debugId": "CC6D84D87A42B15164756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{bc as B}from"./chunk-qx87cdfg.js";import{fc as L,hc as T}from"./chunk-ga7c7tq0.js";import{Nh as M,Oh as Y,Ph as W}from"./chunk-8reepafh.js";class D extends Error{code;constructor(q,z=1){super(q);this.code=z;this.name="CommandFailed"}}class X{static commandName="unset";static description="";static args=[];static options=[];run(q){}}function u(q){return q}function _(){return{commands:[],commandsDir:"app/commands"}}var S=Symbol.for("gemi.console.builder");function E(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{wc as B}from"./chunk-2z1981d0.js";import{Ac as L,Cc as T}from"./chunk-8rt4wx8z.js";import{ki as M,li as Y,mi as W}from"./chunk-56fgk5rq.js";class D extends Error{code;constructor(q,z=1){super(q);this.code=z;this.name="CommandFailed"}}class X{static commandName="unset";static description="";static args=[];static options=[];run(q){}}function u(q){return q}function _(){return{commands:[],commandsDir:"app/commands"}}var S=Symbol.for("gemi.console.builder");function E(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{bc as B}from"./chunk-qx87cdfg.js";import{fc as L,hc as T}from"./chunk-ga7
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 N(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 b(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{D as Pb,X as Qb,u as Rb,_ as Sb,p as Tb,m as Ub,C as Vb,l as Wb,I as Xb,Z as Yb,Pq as Zb,Qq as _b,Vq as $b,Xq as ac};
17
+ export{D as ic,X as jc,u as kc,_ as lc,p as mc,m as nc,C as oc,l as pc,I as qc,Z as rc,Pq as sc,Qq as tc,Vq as uc,Xq as vc};
18
18
 
19
- //# debugId=F4BF85548D6425F064756E2164756E21
19
+ //# debugId=67E5085AF959430164756E2164756E21
@@ -11,6 +11,6 @@
11
11
  "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\";\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 * 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"
12
12
  ],
13
13
  "mappings": ";+JA4GO,AAAM,IAAsB,KAAM,CAG5B,KAFX,WAAW,CACT,EACS,EAAe,EACxB,CACA,MAAM,CAAO,EAFJ,YAGT,KAAK,KAAO,gBAEhB,CAYO,MAAM,CAAQ,OAKZ,aAAc,cAGd,aAAc,SAGd,MAA0B,CAAC,QAG3B,SAA2B,CAAC,EAWnC,GAAG,CAAC,EAA0B,EAChC,CC1GO,SAAS,CAAmB,CAAC,EAAsC,CACxE,OAAO,EAGF,SAAS,CAAqB,EAA4B,CAC/D,MAAO,CACL,SAAU,CAAC,EACX,YAAa,cACf,ECDK,IAAM,EAA+B,OAAO,IAAI,sBAAsB,EAoF7E,SAAS,CAAgB,CAAC,EAAoB,CAC5C,GAAI,EAAK,KAAK,IAAM,GAClB,MAAU,MAAM,iCAAiC,EAGnD,GAAI,OAAO,KAAK,CAAI,GAAK,KAAK,KAAK,CAAI,EACrC,MAAU,MACR,wBAAwB,KAAK,UAAU,CA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wC,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",
14
- "debugId": "F4BF85548D6425F064756E2164756E21",
14
+ "debugId": "67E5085AF959430164756E2164756E21",
15
15
  "names": []
16
16
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{S as D,T as KJ,U as OJ}from"./chunk-k7rbkhhw.js";import{na as B,ra as L,sa as UJ}from"./chunk-frerzsxq.js";import{Ca as e}from"./chunk-4mfrgd5m.js";import"./chunk-5stgtwqw.js";import{Ud as QJ,Vd as A,sc as a}from"./chunk-4sb1484x.js";import"./chunk-9hr0bcfy.js";import"./chunk-1pvkw2pq.js";import{Ff as o,Gf as n,Jf as i}from"./chunk-j0sncgxc.js";import{tg as WJ}from"./chunk-teny6xkw.js";import"./chunk-yv1psptb.js";import"./chunk-b1mk12xg.js";import"./chunk-hfyxvdjj.js";import"./chunk-57edag57.js";import"./chunk-jn59bsww.js";import"./chunk-dx7wpz5b.js";import"./chunk-s9rfgxj5.js";import"./chunk-eazqda9z.js";import"./chunk-dm59ze55.js";import"./chunk-et3vhkbf.js";import{Ph as YJ}from"./chunk-8reepafh.js";import{Qh as N}from"./chunk-5waxjsvv.js";import"./chunk-ddad3902.js";import{join as w,resolve as VJ,sep as zJ}from"path";import{Duplex as qJ}from"stream";import{constants as P,createBrotliCompress as TJ,createGzip as RJ}from"zlib";var bJ=["br","gzip"],kJ=1024,SJ=5,wJ=19,vJ=6;function EJ(J){if(J===void 0)return 1;if(!/^\d+(\.\d{0,3})?$/.test(J.trim()))return 1;let $=Number(J.trim());return Number.isFinite($)?Math.min($,1):1}function yJ(J){if(J===null||J===void 0)return null;let $=new Map;for(let Z of J.split(",")){let[X,...Q]=Z.split(";"),W=X.trim().toLowerCase();if(W==="")continue;let j=1;for(let Y of Q){let K=Y.indexOf("=");if(K===-1)continue;if(Y.slice(0,K).trim().toLowerCase()==="q"){j=EJ(Y.slice(K+1));break}}$.set(W,j)}return $}function b(J,$=bJ){let Z=yJ(J);if(!Z)return null;let X=Z.get("*"),Q=null,W=0;for(let j of $){let Y=Z.get(j)??X??0;if(Y>W)Q=j,W=Y}return Q}function gJ(J,$){if(!J)return!1;return J.split(",").some((Z)=>Z.trim().toLowerCase().split("=")[0].trim()===$)}function fJ(J,$){if(J==="HEAD")return!1;if($.status<200||$.status===204||$.status===206||$.status===304)return!1;if($.headers.has("Content-Range"))return!1;let Z=$.headers.get("Content-Type");if(!Z||!/^\s*text\/html\s*(;|$)/i.test(Z))return!1;if(!$.body)return!1;let X=$.headers.get("Content-Encoding");if(X&&X.trim().toLowerCase()!=="identity")return!1;if(gJ($.headers.get("Cache-Control"),"no-transform"))return!1;let Q=$.headers.get("Content-Length");if(Q!==null&&Number(Q)<kJ)return!1;return!0}function mJ(J){let $=J==="br"?TJ({params:{[P.BROTLI_PARAM_QUALITY]:SJ,[P.BROTLI_PARAM_LGWIN]:wJ},flush:P.BROTLI_OPERATION_FLUSH}):RJ({level:vJ,flush:P.Z_SYNC_FLUSH});return qJ.toWeb($)}function uJ(J){let $=J.get("Vary");if(!$){J.set("Vary","Accept-Encoding");return}let Z=$.split(",").map((X)=>X.trim().toLowerCase());if(Z.includes("*")||Z.includes("accept-encoding"))return;J.append("Vary","Accept-Encoding")}function c(J,$){if(!fJ(J.method,$))return $;let Z=new Headers($.headers);uJ(Z);let X=b(J.headers.get("Accept-Encoding"));if(!X)return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z});let Q;try{Q=mJ(X)}catch{return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z})}return Z.set("Content-Encoding",X),Z.delete("Content-Length"),new Response($.body.pipeThrough(Q),{status:$.status,statusText:$.statusText,headers:Z})}import{readdir as nJ,stat as t}from"fs/promises";import{join as iJ}from"path";import{mkdir as U2,readFile as hJ,stat as K2,writeFile as O2}from"fs/promises";import{dirname as z2,join as cJ}from"path";import{promisify as p}from"util";import{brotliCompress as pJ,constants as C2,gzip as dJ}from"zlib";var lJ=".vite/static-assets.json";var d={br:".br",gzip:".gz"},oJ=["br","gzip"],I2=p(pJ),F2=p(dJ);async function l(J){let $;try{$=await hJ(cJ(J,lJ),"utf8")}catch{return null}let Z;try{Z=JSON.parse($)?.files}catch{return null}if(!Z||typeof Z!=="object")return null;let X={files:{}};for(let[Q,W]of Object.entries(Z)){if(!Array.isArray(W))continue;X.files[Q]=oJ.filter((j)=>W.includes(j))}return X}function k(J){let $=J.toString(),Z=new Bun.CryptoHasher("sha1");return Z.update($),Z.digest("hex")}async function r(J){let $=new Set;async function Z(X,Q){let W;try{W=await nJ(X,{withFileTypes:!0})}catch{return}for(let j of W){if(j.name.startsWith("."))continue;if(Q&&j.name==="assets")continue;let Y=iJ(X,j.name),K=j.isDirectory(),V=j.isFile();if(j.isSymbolicLink())try{let I=await t(Y);K=I.isDirectory(),V=I.isFile()}catch{continue}if(V)$.add(Y);else if(K&&!j.isSymbolicLink())await Z(Y,!1)}}return await Z(J,!0),$}var aJ="public, max-age=31536000, must-revalidate",tJ="public, max-age=31536000, immutable";async function rJ(J,$,Z){if(Z.length===0||J.headers.has("Range"))return null;let X=b(J.headers.get("Accept-Encoding"),Z);if(!X)return null;let Q=$+d[X];try{let W=await t(Q);return W.isFile()?{encoding:X,path:Q,size:W.size}:null}catch{return null}}async function s(J,$,Z={}){let X=Bun.file($),Q=Z.encodings??[],W={"Content-Type":X.type||"application/octet-stream","Cache-Control":Z.immutable?tJ:aJ,"Accept-Ranges":"bytes"};if(Q.length>0)W.Vary="Accept-Encoding";let j=await rJ(J,$,Q);if(j){let V=Bun.file(j.path);return new Response(V.stream(),{headers:{...W,"Content-Encoding":j.encoding,"Content-Length":String(j.size),ETag:`${k(V.lastModified)}-${j.encoding}`}})}let Y=X.size;W.ETag=k(X.lastModified);let K=o(J.headers.get("Range"));if(K){let V=n(K,Y);if(!V)return a(Y);return new Response(X.slice(V.start,V.end+1).stream(),{status:206,headers:{...W,"Content-Range":i(V.start,V.end,Y),"Content-Length":String(V.length)}})}return new Response(X.stream(),{headers:{...W,"Content-Length":String(Y)}})}import{stat as Z2}from"fs/promises";var _="app/client.tsx";function JJ(J,$=B){let Z=J[_]?.file;if(!Z)return;return{module:L(Z,$),preload:M(J,_,$)}}function M(J,$,Z=B){let X=[],Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y?.file)return;X.push(L(Y.file,Z));for(let K of Y.imports??[])W(K)};return W($),X}function $J(J,$){let Z=[],X=new Set,Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y)return;for(let K of Y.imports??[])W(K);for(let K of Y.css??[])if(!X.has(K))X.add(K),Z.push(K)};return W($),Z}function ZJ(J,$=B){let Z=new Map;return(X)=>{if(!Z.has(X)){let Q=`${X}${e}`,W=J[Q]?.file;Z.set(X,W?{src:L(W,$),preload:M(J,Q,$)}:void 0)}return Z.get(X)}}function XJ(J,$=30000){let Z=JSON.stringify("gemi:chunk-reload"),X=JSON.stringify(`Failed to fetch dynamically imported module: ${J}`);return`var r=!1;try{var s=window.sessionStorage,m=JSON.parse(s.getItem(${Z})||"null");var d=m?Date.now()-m.at:NaN;if(navigator.onLine!==!1&&!(d>=0&&d<${$})){s.setItem(${Z},JSON.stringify({url:window.location.href,at:Date.now()}));r=!0}}catch(e){}if(r)window.location.reload();else throw new Error(${X});export {}`}var sJ=new RegExp(`^${QJ}/.+\\.m?js$`);function eJ(J){return sJ.test(J)}function HJ(J){if(eJ(J))return new Response(XJ(J),{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store"}});if(A(J))return new Response("Not found",{status:404});return}var J2=`<!DOCTYPE html>
2
+ import{S as D,T as KJ,U as OJ}from"./chunk-7fwp7vwh.js";import{na as B,ra as L,sa as UJ}from"./chunk-frerzsxq.js";import{Ca as e}from"./chunk-4mfrgd5m.js";import"./chunk-5stgtwqw.js";import{Nc as a,qe as QJ,re as A}from"./chunk-v9na3dny.js";import"./chunk-kqb4s1r0.js";import"./chunk-hytt9qyj.js";import{cg as o,dg as n,gg as i}from"./chunk-0n9vs1ad.js";import{Sg as WJ}from"./chunk-75wk4jxd.js";import"./chunk-jzp0fs6h.js";import"./chunk-8k8534kg.js";import"./chunk-583vxa2v.js";import"./chunk-8c2fs0n0.js";import"./chunk-6h9j3f1x.js";import"./chunk-erxv1jz7.js";import"./chunk-fv9mr1t4.js";import"./chunk-j3nr4cg0.js";import"./chunk-37qk5dh8.js";import"./chunk-wwmdqhzy.js";import{mi as YJ}from"./chunk-56fgk5rq.js";import{ni as N}from"./chunk-4szjp84e.js";import"./chunk-e6fp6dxx.js";import{join as w,resolve as VJ,sep as zJ}from"path";import{Duplex as qJ}from"stream";import{constants as P,createBrotliCompress as TJ,createGzip as RJ}from"zlib";var bJ=["br","gzip"],kJ=1024,SJ=5,wJ=19,vJ=6;function EJ(J){if(J===void 0)return 1;if(!/^\d+(\.\d{0,3})?$/.test(J.trim()))return 1;let $=Number(J.trim());return Number.isFinite($)?Math.min($,1):1}function yJ(J){if(J===null||J===void 0)return null;let $=new Map;for(let Z of J.split(",")){let[X,...Q]=Z.split(";"),W=X.trim().toLowerCase();if(W==="")continue;let j=1;for(let Y of Q){let K=Y.indexOf("=");if(K===-1)continue;if(Y.slice(0,K).trim().toLowerCase()==="q"){j=EJ(Y.slice(K+1));break}}$.set(W,j)}return $}function b(J,$=bJ){let Z=yJ(J);if(!Z)return null;let X=Z.get("*"),Q=null,W=0;for(let j of $){let Y=Z.get(j)??X??0;if(Y>W)Q=j,W=Y}return Q}function gJ(J,$){if(!J)return!1;return J.split(",").some((Z)=>Z.trim().toLowerCase().split("=")[0].trim()===$)}function fJ(J,$){if(J==="HEAD")return!1;if($.status<200||$.status===204||$.status===206||$.status===304)return!1;if($.headers.has("Content-Range"))return!1;let Z=$.headers.get("Content-Type");if(!Z||!/^\s*text\/html\s*(;|$)/i.test(Z))return!1;if(!$.body)return!1;let X=$.headers.get("Content-Encoding");if(X&&X.trim().toLowerCase()!=="identity")return!1;if(gJ($.headers.get("Cache-Control"),"no-transform"))return!1;let Q=$.headers.get("Content-Length");if(Q!==null&&Number(Q)<kJ)return!1;return!0}function mJ(J){let $=J==="br"?TJ({params:{[P.BROTLI_PARAM_QUALITY]:SJ,[P.BROTLI_PARAM_LGWIN]:wJ},flush:P.BROTLI_OPERATION_FLUSH}):RJ({level:vJ,flush:P.Z_SYNC_FLUSH});return qJ.toWeb($)}function uJ(J){let $=J.get("Vary");if(!$){J.set("Vary","Accept-Encoding");return}let Z=$.split(",").map((X)=>X.trim().toLowerCase());if(Z.includes("*")||Z.includes("accept-encoding"))return;J.append("Vary","Accept-Encoding")}function c(J,$){if(!fJ(J.method,$))return $;let Z=new Headers($.headers);uJ(Z);let X=b(J.headers.get("Accept-Encoding"));if(!X)return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z});let Q;try{Q=mJ(X)}catch{return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z})}return Z.set("Content-Encoding",X),Z.delete("Content-Length"),new Response($.body.pipeThrough(Q),{status:$.status,statusText:$.statusText,headers:Z})}import{readdir as nJ,stat as t}from"fs/promises";import{join as iJ}from"path";import{mkdir as U2,readFile as hJ,stat as K2,writeFile as O2}from"fs/promises";import{dirname as z2,join as cJ}from"path";import{promisify as p}from"util";import{brotliCompress as pJ,constants as C2,gzip as dJ}from"zlib";var lJ=".vite/static-assets.json";var d={br:".br",gzip:".gz"},oJ=["br","gzip"],I2=p(pJ),F2=p(dJ);async function l(J){let $;try{$=await hJ(cJ(J,lJ),"utf8")}catch{return null}let Z;try{Z=JSON.parse($)?.files}catch{return null}if(!Z||typeof Z!=="object")return null;let X={files:{}};for(let[Q,W]of Object.entries(Z)){if(!Array.isArray(W))continue;X.files[Q]=oJ.filter((j)=>W.includes(j))}return X}function k(J){let $=J.toString(),Z=new Bun.CryptoHasher("sha1");return Z.update($),Z.digest("hex")}async function r(J){let $=new Set;async function Z(X,Q){let W;try{W=await nJ(X,{withFileTypes:!0})}catch{return}for(let j of W){if(j.name.startsWith("."))continue;if(Q&&j.name==="assets")continue;let Y=iJ(X,j.name),K=j.isDirectory(),V=j.isFile();if(j.isSymbolicLink())try{let I=await t(Y);K=I.isDirectory(),V=I.isFile()}catch{continue}if(V)$.add(Y);else if(K&&!j.isSymbolicLink())await Z(Y,!1)}}return await Z(J,!0),$}var aJ="public, max-age=31536000, must-revalidate",tJ="public, max-age=31536000, immutable";async function rJ(J,$,Z){if(Z.length===0||J.headers.has("Range"))return null;let X=b(J.headers.get("Accept-Encoding"),Z);if(!X)return null;let Q=$+d[X];try{let W=await t(Q);return W.isFile()?{encoding:X,path:Q,size:W.size}:null}catch{return null}}async function s(J,$,Z={}){let X=Bun.file($),Q=Z.encodings??[],W={"Content-Type":X.type||"application/octet-stream","Cache-Control":Z.immutable?tJ:aJ,"Accept-Ranges":"bytes"};if(Q.length>0)W.Vary="Accept-Encoding";let j=await rJ(J,$,Q);if(j){let V=Bun.file(j.path);return new Response(V.stream(),{headers:{...W,"Content-Encoding":j.encoding,"Content-Length":String(j.size),ETag:`${k(V.lastModified)}-${j.encoding}`}})}let Y=X.size;W.ETag=k(X.lastModified);let K=o(J.headers.get("Range"));if(K){let V=n(K,Y);if(!V)return a(Y);return new Response(X.slice(V.start,V.end+1).stream(),{status:206,headers:{...W,"Content-Range":i(V.start,V.end,Y),"Content-Length":String(V.length)}})}return new Response(X.stream(),{headers:{...W,"Content-Length":String(Y)}})}import{stat as Z2}from"fs/promises";var _="app/client.tsx";function JJ(J,$=B){let Z=J[_]?.file;if(!Z)return;return{module:L(Z,$),preload:M(J,_,$)}}function M(J,$,Z=B){let X=[],Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y?.file)return;X.push(L(Y.file,Z));for(let K of Y.imports??[])W(K)};return W($),X}function $J(J,$){let Z=[],X=new Set,Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y)return;for(let K of Y.imports??[])W(K);for(let K of Y.css??[])if(!X.has(K))X.add(K),Z.push(K)};return W($),Z}function ZJ(J,$=B){let Z=new Map;return(X)=>{if(!Z.has(X)){let Q=`${X}${e}`,W=J[Q]?.file;Z.set(X,W?{src:L(W,$),preload:M(J,Q,$)}:void 0)}return Z.get(X)}}function XJ(J,$=30000){let Z=JSON.stringify("gemi:chunk-reload"),X=JSON.stringify(`Failed to fetch dynamically imported module: ${J}`);return`var r=!1;try{var s=window.sessionStorage,m=JSON.parse(s.getItem(${Z})||"null");var d=m?Date.now()-m.at:NaN;if(navigator.onLine!==!1&&!(d>=0&&d<${$})){s.setItem(${Z},JSON.stringify({url:window.location.href,at:Date.now()}));r=!0}}catch(e){}if(r)window.location.reload();else throw new Error(${X});export {}`}var sJ=new RegExp(`^${QJ}/.+\\.m?js$`);function eJ(J){return sJ.test(J)}function HJ(J){if(eJ(J))return new Response(XJ(J),{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store"}});if(A(J))return new Response("Not found",{status:404});return}var J2=`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8" />
@@ -21,4 +21,4 @@ import{S as D,T as KJ,U as OJ}from"./chunk-k7rbkhhw.js";import{na as B,ra as L,s
21
21
  </html>`;function S(J,$,Z){if(!Z)console.error(J);else try{Z(J instanceof Error?J:Error(String(J),{cause:J}))}catch(X){console.error(J),console.error(X)}if(N($))return new Response(JSON.stringify({error:WJ("server_error","Internal Server Error",500)}),{status:500,headers:{"Content-Type":"application/json"}});return new Response(J2,{status:500,headers:{"Content-Type":"text/html; charset=utf-8"}})}var $2={kind:"none"};function jJ(J){let $=(J??"").trim().toLowerCase();if($===""||$==="false"||$==="off"||$==="0")return $2;if($==="true")return{kind:"all"};if(/^[1-9]\d*$/.test($))return{kind:"hops",hops:Number($)};throw Error(`GEMI_TRUST_PROXY must be "false", "true" or the number of proxies in front of the app (e.g. 1). Got ${JSON.stringify(J)}.`)}function GJ(J,$,Z){if(Z.kind==="all"){if(!J.get("x-forwarded-for")&&$)J.set("x-forwarded-for",$);return}J.delete("x-real-ip");let X=$;if(Z.kind==="hops"){let Q=(J.get("x-forwarded-for")??"").split(",").map((j)=>j.trim()).filter(Boolean),W=Q.length-Z.hops;X=W>=0?Q[W]:Q[0]??$}if(X)J.set("x-forwarded-for",X);else J.delete("x-forwarded-for")}var q=YJ(),X2=w(q,"app"),x=w(q,"dist"),C=w(x,"client");function Q2(J){let $;try{$=decodeURIComponent(J)}catch{return null}let Z=VJ(C,"."+$.replace("/assets/assets","/assets"));return Z.startsWith(C+zJ)?Z:null}async function H2(J){try{return(await Z2(J)).isFile()}catch{return!1}}async function Z3(J,$){let Z=await import(`${x}/client/.vite/manifest.json`),X=await import(`${x}/server/.vite/manifest.json`),Q=await UJ(`${x}/client`);process.env.ROOT_DIR=q,process.env.APP_DIR=X2,process.env.DIST_DIR=x;let W={},j={},Y={},K={},V={},I=(H,G)=>`"${H}": () => import("${G}")`,v=[];for(let H of["404",...J.getFlatComponentTree.call(J)]){let G=X[`app/views/${H}.tsx`];if(!G?.file){console.log(`Server file not found for ${H}`),console.log(G);let z=Object.keys(X),F=`app/views/${H}.tsx`;console.log(`${F} not found in server manifest`),console.log(z)}let U=await import(`${process.env.DIST_DIR}/server/${G?.file}`);W[H]=U.default,j[H]=U.OpenGraph,Y[H]=U;let O=Z[`app/views/${H}.tsx`];if(O?.css&&O?.css.length>0)K[H]=O?.css;if(O)v.push(I(H,L(O?.file,Q))),V[H]=M(Z,`app/views/${H}.tsx`,Q)}let xJ=`{${v.join(",")}}`,E=JJ(Z,Q);if(!E)console.error(`Client manifest has no "${_}" entry \u2014 dist/client is incomplete, so documents will render but never hydrate.`);let LJ=Z["app/client.tsx"]?.css??[],y=(await Promise.all(LJ.map((H)=>Bun.file(`${x}/client/${H}`).text()))).join(`
22
22
  `),CJ=ZJ(Z,Q),g=new Map,IJ=(H)=>{let G=g.get(H);if(!G)G=Bun.file(`${x}/client/${H}`).text(),g.set(H,G);return G},FJ=async(H,G)=>{let U=new Set;for(let z of G?[G,...H]:H)for(let F of $J(Z,`app/views/${z}.tsx`))U.add(F);let O=await Promise.all([...U].map(async(z)=>({id:z,content:await IJ(z)})));return D(G?O:[{content:y},...O])},PJ=await r(C),f=new Map;for(let[H,G]of Object.entries((await l(C))?.files??{})){let U=VJ(C,H);if(U.startsWith(C+zJ))f.set(U,{immutable:!0,encodings:G})}async function _J(H){let{pathname:G}=new URL(H.url);if(N(G))return await T(H,G);let U=Q2(G);if(A(G)||G.startsWith("/.well-known")||U!==null&&PJ.has(U)){if(!U||!await H2(U))return HJ(G)??await T(H,G);try{return await s(H,U,f.get(U))}catch(z){return J.onException?.(z),new Response("Not found",{status:404})}}return await T(H,G)}async function T(H,G){let U=J.fetch.bind(J);try{let O=await U(H);if(O instanceof Response)return O;else{let z=[];return z.push({content:y}),await O({getStyles:async(R,u)=>{if(!R)return D([]);if(u?.static)return FJ(R,u.layout);for(let AJ of R){let NJ=Z[`app/views/${AJ}.tsx`];for(let h of NJ?.css??[]){let DJ=Bun.file(`${process.env.DIST_DIR}/client/${h}`);z.push({id:h,content:await DJ.text()})}}return D(z)},clientEntry:E,modulePreloadManifest:V,loaders:xJ,viewImportMap:W,viewModules:Y,ogMap:j,cssManifest:K,assetBase:Q,resolveIsland:CJ})}}catch(O){return S(O,G,J.onException)}}let BJ=(process.env.GEMI_COMPRESSION??"auto").toLowerCase()!=="off",MJ=jJ(process.env.GEMI_TRUST_PROXY),m=Bun.serve({maxRequestBodySize:10737418240,fetch:async(H,G)=>{GJ(H.headers,G.requestIP(H)?.address??null,MJ);let U=await $(H,(O)=>J.withGlobalMiddleware(O,_J,(z)=>S(z,new URL(O.url).pathname,J.onException)));return BJ?c(H,U):U},idleTimeout:OJ(),port:process.env.PORT||5173});return KJ({port:m.port,rootDir:q}),m}export{Z3 as httpProd};
23
23
 
24
- //# debugId=331CEB3C12D1567964756E2164756E21
24
+ //# debugId=B299AA2DC3C3598164756E2164756E21
@@ -14,6 +14,6 @@
14
14
  "/**\n * Which `X-Forwarded-For` entries the production server believes (#8).\n *\n * `X-Forwarded-For` is written by whoever sends the request. A client talking\n * to the app directly — or through a proxy that appends to the header rather\n * than replacing it — picks any address it likes, and `clientIp` (the rate\n * limiter's default key) used to read the left-most entry, which is exactly\n * the one the client wrote. So the server decides here, once, at the edge,\n * and hands the app a single address it can rely on:\n *\n * - `none` (the default): no proxy is trusted. The header is replaced with the\n * socket's peer address, and `X-Real-IP` is dropped.\n * - `hops` (`GEMI_TRUST_PROXY=<n>`): the `n` proxies nearest the app are\n * trusted. Each appends the address it was reached from, so the client is\n * the `n`-th entry from the right of `X-Forwarded-For`. Anything\n * further left was written by someone the app does not trust and is dropped.\n * - `all` (`GEMI_TRUST_PROXY=true`): the inbound header is passed through\n * unchanged, as before 0.88. Only sound behind a proxy that overwrites\n * `X-Forwarded-For` (and `X-Real-IP`) rather than appending to it.\n */\nexport type ForwardedTrust =\n | { kind: \"none\" }\n | { kind: \"all\" }\n | { kind: \"hops\"; hops: number };\n\nconst NONE: ForwardedTrust = { kind: \"none\" };\n\n/**\n * `GEMI_TRUST_PROXY` as a policy. Unset, empty, `false`, `off` and `0` trust\n * nothing; `true` trusts everything; a positive integer is a hop count.\n * Anything else throws, so a typo fails the boot instead of silently trusting\n * nothing (every client sharing the proxy's address) or everything.\n */\nexport function parseTrustProxy(value: string | undefined): ForwardedTrust {\n const raw = (value ?? \"\").trim().toLowerCase();\n if (raw === \"\" || raw === \"false\" || raw === \"off\" || raw === \"0\") {\n return NONE;\n }\n if (raw === \"true\") {\n return { kind: \"all\" };\n }\n if (/^[1-9]\\d*$/.test(raw)) {\n return { kind: \"hops\", hops: Number(raw) };\n }\n throw new Error(\n `GEMI_TRUST_PROXY must be \"false\", \"true\" or the number of proxies in front of the app (e.g. 1). Got ${JSON.stringify(value)}.`,\n );\n}\n\n/**\n * Rewrites `headers` so `X-Forwarded-For` holds what `trust` says the client\n * address is. `peer` is the socket's remote address — `null` for a unix\n * socket, where the immediate hop is still counted as one proxy.\n */\nexport function applyForwardedTrust(\n headers: Headers,\n peer: string | null,\n trust: ForwardedTrust,\n): void {\n if (trust.kind === \"all\") {\n if (!headers.get(\"x-forwarded-for\") && peer) {\n headers.set(\"x-forwarded-for\", peer);\n }\n return;\n }\n\n // Under any other policy `X-Real-IP` is as client-written as the rest; the\n // address the app should use is the one left in `X-Forwarded-For`.\n headers.delete(\"x-real-ip\");\n\n let client: string | null = peer;\n if (trust.kind === \"hops\") {\n const entries = (headers.get(\"x-forwarded-for\") ?? \"\")\n .split(\",\")\n .map((entry) => entry.trim())\n .filter(Boolean);\n // The chain is `entries` + `peer`; the client sits `hops` places left of\n // its end, i.e. `entries[entries.length - hops]`. A shorter chain than\n // expected means the request skipped a proxy, so its left-most hop is the\n // furthest thing seen — never anything further left than that.\n const index = entries.length - trust.hops;\n client = index >= 0 ? entries[index]! : (entries[0] ?? peer);\n }\n\n if (client) {\n headers.set(\"x-forwarded-for\", client);\n } else {\n headers.delete(\"x-forwarded-for\");\n }\n}\n"
15
15
  ],
16
16
  "mappings": ";i5BAAA,SAAS,OAAM,IAAS,QCkBxB,WAAS,UACT,cAAS,oBAAW,WAAsB,QAW1C,FAAM,HAAuC,LAAC,DAAM,AAAM,JAQpD,HAAyB,DAYzB,HAAiB,JACjB,HAAqB,GAGrB,GAAa,EAEnB,SAAS,EAAW,CAAC,EAAiC,CACpD,GAAI,IAAQ,OACV,MAAO,GAKT,GAAI,CAAC,oB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AK1B,cACA,wBACA,WACA,gBACA,cACA,QACA,cACA,YACA,gBACF,CAAC,GAEH,MAAO,EAAK,CACZ,OAAO,EAAuB,EAAK,EAAU,EAAI,WAAW,GAOhE,IAAM,IAAsB,QAAQ,IAAI,kBAAoB,QAAQ,YAAY,IAAM,MAIhF,GAAiB,GAAgB,QAAQ,IAAI,gBAAgB,EAE7D,EAAS,IAAI,MAAM,CACvB,mBAAoB,YACpB,MAAO,MAAO,EAAK,IAAW,CAG5B,GAAoB,EAAI,QAAS,EAAO,UAAU,CAAG,GAAG,SAAW,KAAM,EAAc,EAGvF,IAAM,EAAM,MAAM,EAAgB,EAAK,CAAC,IACtC,EAAI,qBAAqB,EAAK,GAAgB,CAAC,IAC7C,EAAuB,EAAK,IAAI,IAAI,EAAI,GAAG,EAAE,SAAU,EAAI,WAAW,CACxE,CACF,EAKA,OAAO,GAAqB,EAAiB,EAAK,CAAG,EAAI,GAE3D,YAAa,GAAkB,EAC/B,KAAM,QAAQ,IAAI,MAAQ,IAC5B,CAAC,EAID,OAFA,GAAmB,CAAE,KAAM,EAAO,KAAM,SAAQ,CAAC,EAE1C",
17
- "debugId": "331CEB3C12D1567964756E2164756E21",
17
+ "debugId": "B299AA2DC3C3598164756E2164756E21",
18
18
  "names": []
19
19
  }
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{$g as K,Ug as X,ch as W}from"./chunk-jn59bsww.js";import{AsyncLocalStorage as S}from"async_hooks";var z=new S;function g(){return z.getStore()?.tx}function U(){return z.getStore()?.connection??K}function O(j,q){let v=z.getStore();if(U()===j)return q();return y(j),z.run({...v,depth:v?.depth??0,connection:j===K?void 0:j},q)}function y(j){let q=z.getStore();if(q?.tx===void 0)return;let v=q.connection??K;if(v===j)return;throw new W(v,j)}function L(j){let q=z.getStore();if(q?.tx===void 0||q.afterCommit===void 0)return!1;return q.afterCommit.push(j),!0}function h(j){if(L(j))return Promise.resolve();let q=(v)=>{console.error("An after-commit callback threw. No transaction was open, so it ran immediately.",v)};try{return Promise.resolve(j()).catch(q)}catch(v){return q(v),Promise.resolve()}}function k(j){let q=z.getStore();if(q?.tx===void 0||q.commitDependsOn===void 0)return!1;return q.commitDependsOn.push(j),!0}class F extends Error{constructor(j){super(`A statement this transaction depended on failed after being issued on it, so the transaction rolled back instead of committing: ${j instanceof Error?j.message:String(j)}`,{cause:j});this.name="TransactionDependencyError"}}async function R(j,q){if(j.length===q)return;let B=(await Promise.allSettled(j.slice(q))).find((G)=>G.status==="rejected");if(B)throw new F(B.reason)}function N(){let j=z.getStore();return j?.tx===void 0?null:j.depth}function T(){return z.getStore()?.system===!0}function x(j){let q=z.getStore();return z.run({...q,depth:q?.depth??0,system:!0},j)}function p(j){return z.getStore()?.trashed?.get(j)}function f(j,q,v){let B=z.getStore(),G=new Map(B?.trashed);return G.set(j,q),z.run({...B,depth:B?.depth??0,trashed:G},v)}function C(){return z.getStore()?.actor}function l(j,q){let v=z.getStore();return z.run({...v,depth:v?.depth??0,system:!1,actor:{user:j??null}},q)}function _(j){if(Bun.env.NODE_ENV!=="development")return null;if(j===!1)return null;if(j===void 0)return X;if(!Number.isFinite(j)||j<=0)return X;return j}function A(j){let q=_(j);if(q===null)return()=>{};let v=Error("transaction opened here"),B=setTimeout(()=>{let G=v.stack?.split(`
2
+ import{Bh as W,rh as X,yh as K}from"./chunk-6h9j3f1x.js";import{AsyncLocalStorage as S}from"async_hooks";var z=new S;function g(){return z.getStore()?.tx}function U(){return z.getStore()?.connection??K}function O(j,q){let v=z.getStore();if(U()===j)return q();return y(j),z.run({...v,depth:v?.depth??0,connection:j===K?void 0:j},q)}function y(j){let q=z.getStore();if(q?.tx===void 0)return;let v=q.connection??K;if(v===j)return;throw new W(v,j)}function L(j){let q=z.getStore();if(q?.tx===void 0||q.afterCommit===void 0)return!1;return q.afterCommit.push(j),!0}function h(j){if(L(j))return Promise.resolve();let q=(v)=>{console.error("An after-commit callback threw. No transaction was open, so it ran immediately.",v)};try{return Promise.resolve(j()).catch(q)}catch(v){return q(v),Promise.resolve()}}function k(j){let q=z.getStore();if(q?.tx===void 0||q.commitDependsOn===void 0)return!1;return q.commitDependsOn.push(j),!0}class F extends Error{constructor(j){super(`A statement this transaction depended on failed after being issued on it, so the transaction rolled back instead of committing: ${j instanceof Error?j.message:String(j)}`,{cause:j});this.name="TransactionDependencyError"}}async function R(j,q){if(j.length===q)return;let B=(await Promise.allSettled(j.slice(q))).find((G)=>G.status==="rejected");if(B)throw new F(B.reason)}function N(){let j=z.getStore();return j?.tx===void 0?null:j.depth}function T(){return z.getStore()?.system===!0}function x(j){let q=z.getStore();return z.run({...q,depth:q?.depth??0,system:!0},j)}function p(j){return z.getStore()?.trashed?.get(j)}function f(j,q,v){let B=z.getStore(),G=new Map(B?.trashed);return G.set(j,q),z.run({...B,depth:B?.depth??0,trashed:G},v)}function C(){return z.getStore()?.actor}function l(j,q){let v=z.getStore();return z.run({...v,depth:v?.depth??0,system:!1,actor:{user:j??null}},q)}function _(j){if(Bun.env.NODE_ENV!=="development")return null;if(j===!1)return null;if(j===void 0)return X;if(!Number.isFinite(j)||j<=0)return X;return j}function A(j){let q=_(j);if(q===null)return()=>{};let v=Error("transaction opened here"),B=setTimeout(()=>{let G=v.stack?.split(`
3
3
  `).slice(1).join(`
4
4
  `)??"";console.warn(`[gemi] A database transaction has not settled after ${q}ms. It `+"reserves a pooled connection until it does \u2014 check for network or "+`filesystem I/O inside the callback, and move it outside the transaction if you find any.
5
5
  ${G}
6
6
  (development only; set database.slowTransactionThreshold to change the threshold, or false to switch this off)`)},q);return B.unref?.(),()=>clearTimeout(B)}async function D(j,q){if(j.length===0)return;await z.run({...q,tx:void 0,afterCommit:void 0,commitDependsOn:void 0,depth:q?.depth??0},async()=>{for(let v of j)try{await v()}catch(B){console.error("An after-commit callback threw. The transaction it was waiting on had already committed and stays committed, and the callbacks after it still ran.",B)}})}function u(j,q,v){let B=z.getStore(),G=v?.connection??K;if(y(G),B?.tx){let J=B.afterCommit,Q=J?.length??0,P=B.commitDependsOn,M=P?.length??0;return B.tx.savepoint((V)=>{let H=V;return z.run({...B,tx:H,depth:B.depth+1},async()=>{let I=await q(H);if(P)await R(P,M);return I})}).catch((V)=>{if(J)J.length=Q;if(P)P.length=M;throw V})}let Y=A(v?.slowTransactionThreshold),Z=[],$=[];try{return j.begin((J)=>z.run({...B,tx:J,depth:0,connection:G===K?void 0:G,afterCommit:Z,commitDependsOn:$},async()=>{let Q=await q(J);return await R($,0),Q})).finally(Y).then(async(J)=>{return await D(Z,B),J})}catch(J){throw Y(),J}}
7
- export{z as Bg,g as Cg,U as Dg,O as Eg,y as Fg,L as Gg,h as Hg,k as Ig,F as Jg,N as Kg,T as Lg,x as Mg,p as Ng,f as Og,C as Pg,l as Qg,u as Rg};
7
+ export{z as _g,g as $g,U as ah,O as bh,y as ch,L as dh,h as eh,k as fh,F as gh,N as hh,T as ih,x as jh,p as kh,f as lh,C as mh,l as nh,u as oh};
8
8
 
9
- //# debugId=624E16E646FB007B64756E2164756E21
9
+ //# debugId=B0585474E152798964756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "import type { SQL, TransactionSQL } from \"bun\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { SLOW_TRANSACTION_THRESHOLD } from \"../database/config\";\nimport {\n CrossConnectionTransactionError,\n DEFAULT_CONNECTION,\n} from \"../database/Connection\";\n\n/**\n * The ambient transaction: the ORM's own `AsyncLocalStorage`, holding nothing\n * but the open handle and how deep the nesting is.\n *\n * One store per scope with one owner, which is the pattern the framework\n * already follows — `kernel/context.ts` holds the Application,\n * `http/requestContext.ts` the request and its user. The reasoning for\n * not folding this into the kernel's is written up beside it, and the short\n * version is that a transaction scope has to *nest inside* an Application scope\n * without replacing it, and `foundation/app.ts` must keep reading exactly one\n * shape out of the kernel store or resolving a service becomes a transaction\n * concern.\n *\n * What makes an ALS the right home rather than a field somewhere: two concurrent\n * requests each in their own transaction must never see each other's handle.\n * Anything reachable from the Application — which is one object shared by every\n * in-flight request — fails that by construction, and fails it as silently\n * written data, not as an error. \"two concurrent transactions never see each\n * other's handle\" in `context.test.ts` is the test that would catch it.\n */\nexport interface OrmScope {\n /**\n * Bun's transaction handle. Every ORM statement in scope runs on it, which\n * means they all run on one reserved connection — so nothing here may issue\n * two statements concurrently. `Model.$exec` already runs its nested writes\n * and its relation reads sequentially, for exactly this reason.\n */\n tx?: TransactionSQL;\n /** 0 for the outermost transaction, 1+ for each savepoint inside it. */\n depth: number;\n /**\n * Which named connection this subtree's queries run on, and — when `tx` is\n * set — which connection the open transaction belongs to.\n *\n * Ambient rather than an argument threaded through `$exec`, for the same\n * reason the handle above is: a relation read resolves its target through the\n * registry and calls that class's `$exec`, so an argument would have to be\n * carried by every intermediate that has no interest in it, and the one that\n * forgot would silently read a nested `include` off the *other* pool. There\n * is no error that shape produces; there are just rows from the wrong place.\n *\n * `undefined` means the default connection. Kept as absent-rather-than-\n * `\"default\"` so that entering a scope on the default connection is\n * indistinguishable from not entering one, which is what makes the\n * cross-connection check below cost a comparison of two `undefined`s on every\n * application that never declares a second connection.\n */\n connection?: string;\n /**\n * Whether policies are suspended for this scope. Set only by\n * `Model.asSystem`, and never by anything ambient — the whole point is that\n * unscoped access is a decision visible at the call site, not the accidental\n * result of a missing user.\n */\n system?: boolean;\n /**\n * The user policies should scope to, when there is no request to read one\n * from. Set only by `Model.asUser`.\n *\n * A sentinel wrapper rather than the bare value, so that \"a scope was entered\n * with `null`\" stays distinguishable from \"no scope was entered\" — the two\n * mean different things under deny-by-default.\n */\n actor?: { user: unknown };\n /**\n * Work that must not happen unless this transaction commits — an event whose\n * `static afterCommit` is set, today, and nothing else.\n *\n * **Created by the outermost `withTransaction` and never by a savepoint.** A\n * savepoint's scope is a spread of its parent's (`{ ...current, tx: nested }`),\n * so the array arrives here already shared by reference with the transaction\n * that opened it — which is the behaviour wanted rather than a leak. A\n * dispatch made inside a savepoint that commits, in a transaction that then\n * rolls back, must not run: rolling back the outermost transaction discards\n * the list whole, savepoint entries included, because nothing ever drains it.\n *\n * The inverse — a savepoint that rolls back under a transaction that commits\n * — is the case sharing gets wrong on its own, and `withTransaction`'s\n * savepoint branch is where it is put right.\n *\n * Absent, rather than an empty array, on every scope that is not a\n * transaction: `runAsSystem`, `runAsUser` and `runOnConnection` spread\n * whatever they are given, so \"there is a list here\" and \"there is an open\n * transaction here\" have to stay the same question. `deferUntilCommit`\n * answers `false` when either half is missing and the caller runs the work\n * now, which is what keeps a hand-built scope carrying a `tx` — the shape\n * tests write — from swallowing a dispatch into a list nothing drains.\n */\n afterCommit?: AfterCommitCallback[];\n /**\n * Statements written on `tx` that the commit must wait for and must not\n * outlive — today, a job row the database queue driver wrote on the\n * transaction (#563), and nothing else. See `commitDependsOn`.\n *\n * Created and shared exactly as `afterCommit` is, and truncated with it\n * when a savepoint rolls back.\n */\n commitDependsOn?: Promise<unknown>[];\n /**\n * Models whose soft-delete scope (`static $softDeletes`) is lifted or\n * inverted for this async subtree, by name — set only by\n * `Model.withTrashed(fn)` / `Model.onlyTrashed(fn)`.\n *\n * Keyed by model name rather than class because a nested relation read\n * resolves its target through the registry by name, and the block has to\n * reach those reads too. A fresh map per block, never mutated, so an inner\n * block cannot leak its entry back into the enclosing one.\n */\n trashed?: ReadonlyMap<string, TrashedMode>;\n}\n\n/**\n * How a soft-deleted model's trashed rows are treated: `\"with\"` includes them,\n * `\"only\"` reads nothing else. Absent means the default — they are hidden.\n */\nexport type TrashedMode = \"with\" | \"only\";\n\n/**\n * Work deferred to a transaction's commit.\n *\n * Awaited when it is drained, and its rejection is caught there: a callback is\n * a side effect that the transaction is not waiting on and cannot be told\n * about, so the only thing left to do with a failure is report it.\n *\n * Not exported: a caller passes a lambda and never names this, and an export\n * nothing outside this file uses is what `orm/architecture.test.ts` is pointed\n * at. The declaration emit carries it along regardless, so `OrmScope` stays\n * readable from a `.d.ts`.\n */\ntype AfterCommitCallback = () => void | Promise<void>;\n\n/**\n * One ambient scope for the ORM, not one per feature.\n *\n * Transactions (iteration 5) and system access (iteration 6) are both\n * \"something is true for this async subtree and every query in it\", so they\n * share a store rather than minting a second `AsyncLocalStorage` each. The\n * inventory note in `kernel/context.ts` sets the bar for adding one; two\n * booleans-worth of ORM state does not clear it.\n */\nexport const ormContext = new AsyncLocalStorage<OrmScope>();\n\n/**\n * The open transaction, or `undefined` outside one. This is what `Model.$exec`\n * consults to decide which connection a statement runs on.\n *\n * Exported as the escape hatch for code that genuinely needs the handle — a raw\n * query that must join the surrounding transaction, say. **Do not store what it\n * returns.** Bun's handle stays callable after its `begin` resolves: queries on\n * it then run on the pooled connection, outside any transaction, and succeed.\n * Verified against both dialects, and it is the reason `Model.transaction`'s\n * callback takes no argument.\n */\nexport function currentTransaction(): TransactionSQL | undefined {\n return ormContext.getStore()?.tx;\n}\n\n/**\n * The connection every query in this scope runs on unless it names another.\n *\n * `\"default\"` outside any scope, so callers get a name rather than a\n * `string | undefined` to normalise themselves — the store keeps it absent,\n * which is not the same distinction and is nobody else's business.\n */\nexport function currentConnectionName(): string {\n return ormContext.getStore()?.connection ?? DEFAULT_CONNECTION;\n}\n\n/**\n * Run `fn` with `name` as the ambient connection.\n *\n * Merged into the current scope rather than replacing it, exactly as\n * `runAsSystem` and `runAsUser` are: naming a connection must not drop an open\n * transaction handle or re-enable policies underneath it.\n *\n * Deliberately absent from `orm/index.ts`, so it is not part of what an\n * application can reach — `Model.on(name)` and `DB.connection(name)` are the\n * two doors, and both funnel through here so that a nested relation read,\n * which resolves its own class out of the registry and calls its `$exec`,\n * inherits the connection without anything having to pass it along.\n */\nexport function runOnConnection<T>(\n name: string,\n fn: () => Promise<T>,\n): Promise<T> {\n const current = ormContext.getStore();\n if (currentConnectionName() === name) return fn();\n\n // ENTERING A CONNECTION IS WHERE THE CROSS-CONNECTION CHECK BELONGS, not at\n // each door — and it has to be *here*, before the scope is entered, because\n // entering it is what makes the check impossible afterwards.\n //\n // The scope carries `tx` and `connection` together, so overwriting the name\n // while an open handle stays in place produces a store that says \"a\n // transaction on analytics\" while holding the *default* connection's handle.\n // Every check downstream then agrees with itself and the statement runs on\n // the wrong connection's transaction. `Model.save` found this: it routes to\n // the row's own connection, so it is the one caller that switches connections\n // with a transaction already open.\n assertConnectionUsable(name);\n\n return ormContext.run(\n {\n ...current,\n depth: current?.depth ?? 0,\n connection: name === DEFAULT_CONNECTION ? undefined : name,\n },\n fn,\n );\n}\n\n/**\n * Refuse a statement that names one connection while a transaction is open on\n * another.\n *\n * The check `withTransaction`'s single-connection note asked for, and the\n * reasoning for refusing rather than routing is on\n * `CrossConnectionTransactionError`. Both doors call it — `Model.$exec` for\n * every model operation, `DB` for a raw fragment — because either one alone\n * leaves the other free to straddle the two connections, and a raw `DB.execute`\n * escaping a transaction is the more damaging of the two.\n *\n * Only ever fires on a query that *names* a connection: an unqualified one\n * resolves to the ambient name, which is the transaction's own.\n */\nexport function assertConnectionUsable(name: string): void {\n const store = ormContext.getStore();\n if (store?.tx === undefined) return;\n\n const open = store.connection ?? DEFAULT_CONNECTION;\n if (open === name) return;\n\n throw new CrossConnectionTransactionError(open, name);\n}\n\n/**\n * Hold `callback` until the open transaction commits, and say whether that\n * happened.\n *\n * `false` means there was nothing to wait for — no transaction is open, or the\n * scope was entered by hand rather than by `withTransaction` — and the caller\n * must run the work itself, now. That return value is the whole contract: a\n * caller that ignores it turns \"no transaction here\" into a side effect queued\n * on a list nothing will ever drain, which is a dispatch that silently never\n * happens.\n *\n * `true` means the callback is on the outermost scope's list and will run after\n * `begin` resolves, outside the transaction, whatever the caller does next. It\n * will not run at all if the transaction rolls back, or if a savepoint it was\n * registered inside rolls back — both of which are the point.\n *\n * Nothing here is ordered against anything but the other deferred callbacks:\n * they run in registration order, one at a time, after the commit round-trip.\n */\nexport function deferUntilCommit(callback: AfterCommitCallback): boolean {\n const store = ormContext.getStore();\n if (store?.tx === undefined || store.afterCommit === undefined) return false;\n\n store.afterCommit.push(callback);\n return true;\n}\n\n/**\n * Run `callback` once the open transaction commits, or now when none is open.\n * Never when the transaction rolls back, nor when a savepoint it was\n * registered inside rolls back.\n *\n * The application-facing form of `deferUntilCommit`, exported from `gemi/orm`\n * (#786). The difference is the `false` branch: `deferUntilCommit` hands the\n * \"no transaction\" case back to the caller, who must remember to run the work\n * itself, and this runs it. A caller that wants a side effect only once its\n * writes are durable — waking a long-poll, notifying another process — has\n * nothing left to get wrong.\n *\n * Inside a transaction the callback joins the same list `static afterCommit`\n * events use, so it is drained after `begin` resolves, outside the\n * transaction, in registration order with them.\n *\n * The returned promise resolves once the callback has run (no transaction) or\n * been queued (inside one). It never rejects: a callback that throws is\n * reported on stderr, as a deferred one is at the drain, so a caller that does\n * not await — the usual case — cannot leave an unhandled rejection behind, and\n * the two branches fail the same way. A sync callback outside a transaction\n * runs before this returns.\n */\nexport function afterCommit(\n callback: () => void | Promise<void>,\n): Promise<void> {\n if (deferUntilCommit(callback)) return Promise.resolve();\n\n const report = (error: unknown) => {\n console.error(\n `An after-commit callback threw. No transaction was open, so it ran ` +\n `immediately.`,\n error,\n );\n };\n try {\n return Promise.resolve(callback()).catch(report);\n } catch (error) {\n report(error);\n return Promise.resolve();\n }\n}\n\n/**\n * Make the open transaction's commit depend on `write`, a statement issued on\n * its handle: the transaction does not commit until `write` settles, and\n * rolls back — rejecting with `TransactionDependencyError` — if it rejected.\n *\n * For a write the caller may not await. A queued listener's dispatch never is\n * (`EventManager` pushes it and moves on), and on Postgres a statement that\n * fails aborts the whole transaction: every statement after it is refused and\n * Bun's `COMMIT` quietly becomes a rollback. Without this, the callback's\n * promise resolved, `begin` resolved, and the rows the caller wrote were gone\n * with nothing to say so. MySQL does not abort on a failed statement, and is\n * failed here anyway, so that a joined write means the same thing on both:\n * it commits with the transaction or the transaction does not commit.\n *\n * `false` when there is no transaction to depend on, as for\n * `deferUntilCommit`.\n */\nexport function commitDependsOn(write: Promise<unknown>): boolean {\n const store = ormContext.getStore();\n if (store?.tx === undefined || store.commitDependsOn === undefined) {\n return false;\n }\n store.commitDependsOn.push(write);\n return true;\n}\n\n/**\n * A write the transaction's commit depended on failed, so the transaction —\n * or the savepoint the write was made in — rolled back. `cause` is the write's\n * own error.\n */\nexport class TransactionDependencyError extends Error {\n constructor(cause: unknown) {\n super(\n `A statement this transaction depended on failed after being issued on ` +\n `it, so the transaction rolled back instead of committing: ` +\n `${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n this.name = \"TransactionDependencyError\";\n }\n}\n\n/**\n * Wait for the writes registered from `mark` on, and throw if one failed.\n *\n * Called at the end of a transaction's or savepoint's callback, *inside*\n * `begin`/`savepoint`, so a throw is what makes Bun roll back rather than\n * commit — after `begin` has resolved it is too late to do anything but\n * report. Every write is settled before throwing, so none is still running on\n * the handle when the rollback is issued.\n */\nasync function awaitDependencies(\n writes: Promise<unknown>[],\n mark: number,\n): Promise<void> {\n if (writes.length === mark) return;\n const settled = await Promise.allSettled(writes.slice(mark));\n const failed = settled.find(\n (outcome): outcome is PromiseRejectedResult => outcome.status === \"rejected\",\n );\n if (failed) throw new TransactionDependencyError(failed.reason);\n}\n\n/** How deeply nested the current transaction is; `null` outside one. */\nexport function transactionDepth(): number | null {\n const store = ormContext.getStore();\n return store?.tx === undefined ? null : store.depth;\n}\n\n/** Whether policies are suspended for the current async scope. */\nexport function isSystemScope(): boolean {\n return ormContext.getStore()?.system === true;\n}\n\n/**\n * Run `fn` with policies suspended.\n *\n * The escape hatch the deny-by-default rule needs to be usable: a cron tick, a\n * queue worker or a seed script has no user, and under deny-by-default every\n * policied model would refuse it. This makes that intent explicit *at the call\n * site*, which is the property that matters — unscoped access must never be\n * what happens when a user simply fails to turn up.\n *\n * It nests inside a transaction and a transaction nests inside it: the scope is\n * merged rather than replaced, so `asSystem` does not silently drop an open\n * handle.\n */\nexport function runAsSystem<T>(fn: () => Promise<T>): Promise<T> {\n const current = ormContext.getStore();\n return ormContext.run({ ...current, depth: current?.depth ?? 0, system: true }, fn);\n}\n\n/**\n * How `model`'s trashed rows are treated in this async scope, or `undefined`\n * for the default (hidden). See `OrmScope.trashed`.\n */\nexport function trashedMode(model: string): TrashedMode | undefined {\n return ormContext.getStore()?.trashed?.get(model);\n}\n\n/**\n * Run `fn` with `model`'s soft-delete scope lifted (`\"with\"`) or inverted\n * (`\"only\"`). Merged into the current scope like `runAsSystem`, so it keeps an\n * open transaction, the system flag and the actor — and every other policy.\n */\nexport function runWithTrashed<T>(\n model: string,\n mode: TrashedMode,\n fn: () => Promise<T>,\n): Promise<T> {\n const current = ormContext.getStore();\n const trashed = new Map(current?.trashed);\n trashed.set(model, mode);\n return ormContext.run(\n { ...current, depth: current?.depth ?? 0, trashed },\n fn,\n );\n}\n\n/** The explicitly-set actor, or `undefined` when none was. */\nexport function currentActor(): { user: unknown } | undefined {\n return ormContext.getStore()?.actor;\n}\n\n/**\n * Run `fn` with policies scoped to `user`, for code with no request to read one\n * from.\n *\n * The counterpart to `runAsSystem`, and the reason that one is not the only\n * escape hatch. A queue worker processing \"send the invoice for organisation 7\"\n * genuinely acts *as somebody*; giving it `asSystem` would suspend policies\n * entirely and leave it hand-scoping every query — which is precisely the\n * unscoped-by-accident failure the deny-by-default rule exists to prevent. The\n * narrow tool should be the easy one.\n *\n * It is also what makes policies testable without reaching into\n * `RequestContext`'s internals.\n *\n * Takes precedence over the request store, so a job that says who it is acting\n * as is not quietly overridden by an ambient request that happens to enclose it.\n *\n * It also **clears `system`**, which is the more surprising half. Acting as a\n * user is strictly narrower than acting as the system, so naming one inside an\n * `asSystem` block has to narrow back — and the spread would otherwise carry\n * `system: true` forward, leaving `$exec` to skip policies entirely while\n * `currentUser()` cheerfully returned the actor. Silently unscoped, from the\n * realistic shape: a worker enters `asSystem` to read its job queue, then\n * narrows to the job's owner for the work itself. The reverse nesting —\n * `asSystem` inside `asUser` — suspends policies, which is what it should do.\n */\nexport function runAsUser<T>(user: unknown, fn: () => Promise<T>): Promise<T> {\n const current = ormContext.getStore();\n return ormContext.run(\n {\n ...current,\n depth: current?.depth ?? 0,\n system: false,\n actor: { user: user ?? null },\n },\n fn,\n );\n}\n\n/**\n * The warning threshold in milliseconds, or `null` when the warning is off.\n *\n * `configured` is `database.slowTransactionThreshold` — see `DatabaseConfig`.\n * It arrives as a value rather than being read from here so that this file\n * keeps knowing nothing about the container: `withTransaction` is reachable\n * with a bare pool, and its tests use one.\n *\n * Exported for its own tests. The behaviour worth pinning is the fallback —\n * that a malformed threshold lands on the default rather than disabling — and\n * that cannot be observed through `withTransaction`: \"no warning fired\" is what\n * a disabled warning looks like too, so a behavioural test of it passes just as\n * happily when the fallback is gone. Asserting the number directly is the only\n * form of that test that can fail.\n */\nexport function slowTransactionThreshold(\n configured?: number | false,\n): number | null {\n // Read per call, never cached at module scope. `scripts/build.ts` rewrites\n // `process.env.NODE_ENV` to `Bun.env.NODE_ENV` precisely so mode stays a\n // runtime question in the built framework; caching it here would undo that.\n if (process.env.NODE_ENV !== \"development\") return null;\n\n // The one way to switch it off, and it has to be spelled. Everything else\n // falls back, so the warning is never lost to a mistyped value — only to an\n // explicit `false`.\n if (configured === false) return null;\n\n if (configured === undefined) return SLOW_TRANSACTION_THRESHOLD;\n if (!Number.isFinite(configured) || configured <= 0) {\n return SLOW_TRANSACTION_THRESHOLD;\n }\n return configured;\n}\n\n/**\n * Warn, in development only, about a transaction that has been open too long.\n *\n * The risk is structural rather than occasional: an open transaction holds one\n * reserved connection for as long as its callback runs, and nothing about\n * `Model.transaction(async () => { ... })` stops that callback from awaiting a\n * `fetch`, an S3 upload or a slow queue push. Under concurrency that drains the\n * pool, and the symptom — every unrelated query in the process blocking on\n * connection acquisition — names neither the callback nor the I/O in it.\n *\n * A timer rather than measuring elapsed time on the way out, for one reason:\n * the worst case is the transaction that *never* settles (a hung request, a\n * lock wait, a deadlock). After-the-fact measurement is silent for exactly that\n * case; a timer fires while it is still open and still holding the connection.\n *\n * The `Error` is constructed up front and read only if the timer fires — V8\n * formats `.stack` lazily on first access, so an ordinary fast transaction pays\n * for an object allocation and nothing else.\n *\n * The clock starts at the `begin` call, not at the moment a connection is\n * acquired, and stops when `begin` settles rather than when the callback\n * returns — so it spans the pool wait and the commit round-trip as well as the\n * callback. That is deliberate: all three are time this transaction is in\n * flight, and a warning that only covered the callback would stay silent for a\n * transaction stuck waiting on an exhausted pool, which is the exact situation\n * a long transaction elsewhere creates. Hence \"not settled\" rather than \"open\n * for\" — the message must not claim a connection was held for the whole span.\n */\nfunction watchForSlowTransaction(configured?: number | false): () => void {\n const threshold = slowTransactionThreshold(configured);\n if (threshold === null) return () => {};\n\n const site = new Error(\"transaction opened here\");\n\n const timer = setTimeout(() => {\n const stack = site.stack?.split(\"\\n\").slice(1).join(\"\\n\") ?? \"\";\n console.warn(\n `[gemi] A database transaction has not settled after ${threshold}ms. It ` +\n `reserves a pooled connection until it does — check for network or ` +\n `filesystem I/O inside the callback, and move it outside the ` +\n `transaction if you find any.\\n${stack}\\n` +\n `(development only; set database.slowTransactionThreshold to change ` +\n `the threshold, or false to switch this off)`,\n );\n }, threshold);\n\n // Otherwise the warning timer is itself a reason the process stays alive,\n // which would turn a diagnostic into a hang in short-lived commands and\n // scripts.\n timer.unref?.();\n\n return () => clearTimeout(timer);\n}\n\n/**\n * Runs what a committed transaction deferred, outside the transaction it was\n * deferred by.\n *\n * `outside` is the scope that was ambient before `begin` — an `asSystem` block,\n * a named connection, or nothing at all — and re-entering it explicitly is the\n * guarantee rather than a tidy-up. The alternative is relying on where a `.then`\n * happens to have captured its context, and the failure that produces is the\n * one the whole feature is about: a listener that runs \"after commit\" while\n * still holding the closed transaction's handle joins nothing, because Bun's\n * handle stays callable and simply runs on the pool. So the scope is rebuilt\n * with `tx` and the drained list cleared, and a listener that opens its own\n * transaction gets a real one.\n *\n * Errors are caught per callback and the next one still runs, for the reason\n * the event subsystem catches per listener: these are independent side effects\n * whose order came from a filesystem walk. And the transaction is not failed by\n * one — it committed, the database kept the rows, and reporting a rejection to\n * the caller would have it roll back or retry work that is already durable.\n * stderr is all that is left, and it is enough: the caller has no decision to\n * make here.\n *\n * The transaction's own promise does not resolve until this has finished, which\n * is the one thing about `afterCommit` that a caller can feel. Deliberate: the\n * alternative is a floating promise whose rejection nobody sees and whose work\n * a short-lived process — a command, a seed — exits out from under.\n */\nasync function drainAfterCommit(\n callbacks: AfterCommitCallback[],\n outside: OrmScope | undefined,\n): Promise<void> {\n if (callbacks.length === 0) return;\n\n await ormContext.run(\n {\n ...outside,\n tx: undefined,\n afterCommit: undefined,\n commitDependsOn: undefined,\n depth: outside?.depth ?? 0,\n },\n async () => {\n for (const callback of callbacks) {\n try {\n await callback();\n } catch (error) {\n console.error(\n `An after-commit callback threw. The transaction it was waiting ` +\n `on had already committed and stays committed, and the ` +\n `callbacks after it still ran.`,\n error,\n );\n }\n }\n },\n );\n}\n\n/**\n * Run `fn` inside a transaction, entering the ambient scope for its whole async\n * subtree.\n *\n * The single implementation behind both `Model.transaction` and\n * `DB.transaction`, so the two cannot become transaction systems that ignore\n * each other: a `Model.create` inside a `DB.transaction` joins it, and a raw\n * `DB.sql` inside a `Model.transaction` can join it through\n * `currentTransaction()`.\n *\n * Nesting becomes a savepoint. Not a preference — Bun refuses the alternative\n * outright (`cannot call begin inside a transaction use savepoint() instead`),\n * and a savepoint is the semantics worth having anyway: an inner failure rolls\n * back to it and leaves the outer transaction usable, which a caller that\n * catches can rely on. Verified on SQLite and Postgres.\n *\n * Note Bun hands the savepoint callback the *same* handle object as the outer\n * transaction (`sp === tx`), so the depth counter is the only thing that\n * actually changes on the way in. The callback's argument is still what gets\n * stored, so this keeps working if that ever stops being true. The cast is\n * because Bun types a savepoint handle as plain `SQL` — without `savepoint` on\n * it — while the runtime object does carry the method, which is what makes\n * three levels of nesting work.\n *\n * Anything `deferUntilCommit` queued is drained once `begin` resolves, outside\n * the transaction and only on the outermost call — a savepoint has committed\n * nothing durable, so draining there would run work that a later rollback of\n * the enclosing transaction was meant to have prevented. See `drainAfterCommit`\n * for what that costs the caller.\n *\n * In development, an outermost transaction that stays open past\n * `options.slowTransactionThreshold` (2s by default, `false` to disable) warns\n * — see `watchForSlowTransaction`. Nothing here *prevents* a long transaction;\n * the warning exists because the cost of one is paid by unrelated queries\n * elsewhere in the process, which makes it hard to trace back.\n *\n * The threshold is passed in rather than read from `app(DatabaseManager)` here.\n * Every caller already holds the manager — it is where `pool` came from — and\n * taking it as an argument keeps this file free of the container, so a bare\n * `SQL` is still enough to call it. Its tests rely on that.\n *\n * `options.connection` is the name `pool` belongs to, and follows the same rule\n * for the same reason: the pool cannot be asked what it is called. Passing it\n * is what lets a nested `withTransaction` tell \"the same connection, so take a\n * savepoint\" from \"a different one, so refuse\" — omitting it means the default\n * connection, which is what a two-argument call always meant.\n *\n * The return type is asserted rather than inferred for one reason worth\n * knowing: Bun's `begin` unwraps a callback that resolves to an *array of\n * promises*, awaiting each. So `Model.transaction(async () => [a, b])` where\n * `a` and `b` are promises resolves to their values, not to the promises. That\n * is Bun's behaviour and is left alone; it is only surprising if unmentioned.\n */\nexport function withTransaction<T>(\n pool: SQL,\n fn: (tx: TransactionSQL) => Promise<T>,\n options?: { slowTransactionThreshold?: number | false; connection?: string },\n): Promise<T> {\n const current = ormContext.getStore();\n\n // THE SINGLE-CONNECTION ASSUMPTION, WHICH IS NOW CHECKED RATHER THAN PINNED.\n //\n // The savepoint branch below ignores `pool` entirely. That was correct while\n // there was one `DatabaseManager` and one `SQL` — the ambient handle and\n // whatever pool the caller passed were necessarily the same database — and\n // the note that stood here said what would happen when a second connection\n // became configurable (#327): a `DB.transaction` on B inside a\n // `Model.transaction` on A would savepoint on **A** and hand the callback A's\n // handle, so statements landed in the wrong database with no error at all.\n //\n // So the name is compared before the branch is taken, and a mismatch raises.\n // Refusing is the whole answer rather than half of one — there is no way to\n // make one transaction span two pools, and the alternatives are covered on\n // `CrossConnectionTransactionError`.\n //\n // A caller that passes no `connection` is treated as naming the default,\n // which is what `withTransaction(pool, fn)` meant before this argument\n // existed.\n const name = options?.connection ?? DEFAULT_CONNECTION;\n assertConnectionUsable(name);\n\n // `current?.tx` rather than `current`: since iteration 6 a scope can exist\n // with no open transaction — `Model.asSystem` enters one — and a savepoint\n // needs an actual handle, not merely a store.\n if (current?.tx) {\n // WHERE THE SHARED AFTER-COMMIT LIST IS PUT RIGHT.\n //\n // The savepoint's scope is a spread of this one, so it appends to the\n // transaction's list rather than to a list of its own — which is what makes\n // \"the outer transaction rolled back, so nothing runs\" free. The case that\n // is not free is this one: the savepoint rolls back and the transaction\n // goes on to commit. Its entries have to go, or a dispatch made inside a\n // block the database threw away runs anyway, which is the same wrong answer\n // as before with an extra step.\n //\n // A mark on the way in and a truncate on the way out, rather than tagging\n // each entry with its depth and dropping everything at or below the failing\n // one. Depth cannot tell two *siblings* apart: a savepoint that committed\n // and one that rolled back both left entries at the same depth, adjacent in\n // the list, and dropping by depth would discard the committed sibling's\n // work as well. The index is exact because the ORM issues one statement at\n // a time on a transaction handle — see `OrmScope.tx` — so nothing appends\n // between the mark and the failure but this savepoint's own subtree.\n const deferred = current.afterCommit;\n const mark = deferred?.length ?? 0;\n // The same mark for the writes the commit depends on. The savepoint waits\n // for its own before it releases, so one that failed rolls back only the\n // savepoint — which a caller that catches can survive, exactly as it\n // survives a statement that threw inside it — and is then forgotten\n // rather than failing the transaction a second time.\n const dependencies = current.commitDependsOn;\n const dependencyMark = dependencies?.length ?? 0;\n\n return current.tx\n .savepoint((sp) => {\n const nested = sp as TransactionSQL;\n return ormContext.run(\n { ...current, tx: nested, depth: current.depth + 1 },\n async () => {\n const result = await fn(nested);\n if (dependencies) {\n await awaitDependencies(dependencies, dependencyMark);\n }\n return result;\n },\n );\n })\n .catch((error: unknown) => {\n if (deferred) deferred.length = mark;\n if (dependencies) dependencies.length = dependencyMark;\n throw error;\n }) as Promise<T>;\n }\n\n // Only the outermost scope is watched. A savepoint reserves no connection of\n // its own — its lifetime is bounded by the transaction it sits in, which is\n // already being timed — so warning per depth would report one slow block as\n // several warnings and point at the innermost frame rather than the one\n // holding the connection.\n const stopWatching = watchForSlowTransaction(\n options?.slowTransactionThreshold,\n );\n\n // Built out here rather than inside the `begin` callback, because the drain\n // below needs it *after* that callback's scope is gone, and reading it off\n // the store then is exactly what is no longer possible.\n const deferred: AfterCommitCallback[] = [];\n const dependencies: Promise<unknown>[] = [];\n\n // The `try` covers a *synchronous* throw from `begin` — a closed pool, say.\n // `.finally` alone would not: it is only attached once `begin` has returned a\n // promise, so a synchronous throw escapes with the timer still armed and\n // eventually warns about a transaction that never opened. `unref` keeps that\n // from holding the process, which makes it cosmetic rather than a leak, but\n // it is the same gap the `.finally` below exists to close.\n try {\n // Spread rather than replace: a `Model.transaction` inside a\n // `Model.asSystem` must not silently re-enable policies for its subtree.\n //\n // The connection goes into the scope alongside the handle, and the pair is\n // what makes the check at the top of this function possible: \"which\n // connection is this transaction on\" has to be answerable from the store,\n // because the handle itself does not say. It is also what makes an\n // unqualified query inside `DB.connection(\"analytics\").transaction(...)`\n // *join* the transaction instead of being refused by it — the query\n // inherits the name rather than defaulting to the hot path.\n return (\n pool\n .begin((tx) =>\n ormContext.run(\n {\n ...current,\n tx,\n depth: 0,\n connection: name === DEFAULT_CONNECTION ? undefined : name,\n // A fresh list per outermost transaction, assigned rather than\n // left to the spread. `current` holds no list today — the drain\n // clears the field before it runs anything — and assigning is\n // what keeps that from being load-bearing: a transaction opened\n // by a callback during a drain gets its own list either way,\n // rather than appending to the array it is being run out of.\n afterCommit: deferred,\n commitDependsOn: dependencies,\n },\n async () => {\n const result = await fn(tx);\n await awaitDependencies(dependencies, 0);\n return result;\n },\n ),\n )\n // `finally` and not a `then`/`catch` pair: the connection is released on\n // rollback exactly as it is on commit, so a throwing callback must clear\n // the timer too or every failed transaction leaves a warning armed\n // against a connection that has already gone back to the pool.\n //\n // Before the drain, so that a slow after-commit listener is not\n // reported as a transaction that will not settle. The connection went\n // back to the pool at the commit; the warning is about holding it.\n .finally(stopWatching)\n // Only here, on the fulfilled path. A rejected `begin` rolled back, so\n // the scope and everything queued on it are discarded unread — which is\n // the whole of what `afterCommit` promises.\n .then(async (result) => {\n await drainAfterCommit(de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,EAAS,GAAI,EAAQ,MAAO,EAAQ,MAAQ,CAAE,EACnD,SAAY,CACV,IAAM,EAAS,MAAM,EAAG,CAAM,EAC9B,GAAI,EACF,MAAM,EAAkB,EAAc,CAAc,EAEtD,OAAO,EAEX,EACD,EACA,MAAM,CAAC,IAAmB,CACzB,GAAI,EAAU,EAAS,OAAS,EAChC,GAAI,EAAc,EAAa,OAAS,EACxC,MAAM,EACP,EAQL,IAAM,EAAe,EACnB,GAAS,wBACX,EAKM,EAAkC,CAAC,EACnC,EAAmC,CAAC,EAQ1C,GAAI,CAWF,OACE,EACG,MAAM,CAAC,IACN,EAAW,IACT,IACK,EACH,KACA,MAAO,EACP,WAAY,IAAS,EAAqB,OAAY,EAOtD,YAAa,EACb,gBAAiB,CACnB,EACA,SAAY,CACV,IAAM,EAAS,MAAM,EAAG,CAAE,EAE1B,OADA,MAAM,EAAkB,EAAc,CAAC,EAChC,EAEX,CACF,EASC,QAAQ,CAAY,EAIpB,KAAK,MAAO,IAAW,CAEtB,OADA,MAAM,EAAiB,EAAU,CAAO,EACjC,EACR,EAEL,MAAO,EAAO,CAEd,MADA,EAAa,EACP",
8
- "debugId": "624E16E646FB007B64756E2164756E21",
8
+ "debugId": "B0585474E152798964756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{X as M}from"./chunk-d0trs736.js";import{Vh as E}from"./chunk-ddad3902.js";class x{marshaller;serializer;deserializer;serdeContext;defaultContentType;constructor({marshaller:i,serializer:n,deserializer:o,serdeContext:c,defaultContentType:y}){this.marshaller=i,this.serializer=n,this.deserializer=o,this.serdeContext=c,this.defaultContentType=y}async serializeEventStream({eventStream:i,requestSchema:n,initialRequest:o}){let c=this.marshaller,y=n.getEventStreamMember(),p=n.getMemberSchema(y),d=this.serializer,f=this.defaultContentType,h=Symbol("initialRequestMarker"),S={async*[Symbol.asyncIterator](){if(o){let r={":event-type":{type:"string",value:"initial-request"},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:f}};d.write(n,o);let t=d.flush();yield{[h]:!0,headers:r,body:t}}for await(let r of i)yield r}};return c.serialize(S,(r)=>{if(r[h])return{headers:r.headers,body:r.body};let t=Object.keys(r).find((s)=>{return s!=="__type"})??"",{additionalHeaders:e,body:a,eventType:l,explicitPayloadContentType:m}=this.writeEventBody(t,p,r);return{headers:{":event-type":{type:"string",value:l},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:m??f},...e},body:a}})}async deserializeEventStream({response:i,responseSchema:n,initialResponseContainer:o}){let c=this.marshaller,y=n.getEventStreamMember(),d=n.getMemberSchema(y).getMemberSchemas(),f=Symbol("initialResponseMarker"),h=c.deserialize(i.body,async(t)=>{let e=Object.keys(t).find((l)=>{return l!=="__type"})??"",a=t[e].body;if(e==="initial-response"){let l=await this.deserializer.read(n,a);return delete l[y],{[f]:!0,...l}}else if(e in d){let l=d[e];if(l.isStructSchema()){let m={},u=!1;for(let[s,g]of l.structIterator()){let{eventHeader:v,eventPayload:w}=g.getMergedTraits();if(u=u||Boolean(v||w),w){if(g.isBlobSchema())m[s]=a;else if(g.isStringSchema())m[s]=(this.serdeContext?.utf8Encoder??z.toUtf8)(a);else if(g.isStructSchema())m[s]=await this.deserializer.read(g,a)}else if(v){let b=t[e].headers[s]?.value;if(b!=null)if(g.isNumericSchema())if(b&&typeof b==="object"&&"bytes"in b)m[s]=BigInt(b.toString());else m[s]=Number(b);else m[s]=b}}if(u)return{[e]:m};if(a.byteLength===0)return{[e]:{}}}return{[e]:await this.deserializer.read(l,a)}}else return{$unknown:t}}),S=h[Symbol.asyncIterator](),r=await S.next();if(r.done)return h;if(r.value?.[f]){if(!n)throw Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");for(let[t,e]of Object.entries(r.value))o[t]=e}return{async*[Symbol.asyncIterator](){if(!r?.value?.[f])yield r.value;while(!0){let{done:t,value:e}=await S.next();if(t)break;yield e}}}}writeEventBody(i,n,o){let c=this.serializer,y=i,p=null,d,f=(()=>{return n.getSchema()[4].includes(i)})(),h={};if(!f){let[t,e]=o[i];y=t,c.write(15,e)}else{let t=n.getMemberSchema(i);if(t.isStructSchema()){for(let[e,a]of t.structIterator()){let{eventHeader:l,eventPayload:m}=a.getMergedTraits();if(m)p=e;else if(l){let u=o[i][e],s="binary";if(a.isNumericSchema())if(-2147483648<=u&&u<=2147483647)s="integer";else s="long";else if(a.isTimestampSchema())s="timestamp";else if(a.isStringSchema())s="string";else if(a.isBooleanSchema())s="boolean";if(u!=null)h[e]={type:s,value:u},delete o[i][e]}}if(p!==null){let e=t.getMemberSchema(p);if(e.isBlobSchema())d="application/octet-stream";else if(e.isStringSchema())d="text/plain";c.write(e,o[i][p])}else c.write(t,o[i])}else if(t.isUnitSchema())c.write(t,{});else throw Error("@smithy/core/event-streams - non-struct member not supported in event stream union.")}let S=c.flush()??new Uint8Array;return{body:typeof S==="string"?(this.serdeContext?.utf8Decoder??z.fromUtf8)(S):S,eventType:y,explicitPayloadContentType:d,additionalHeaders:h}}}var z,T;var C=E(()=>{z=M();T=x});C();export{T as EventStreamSerde};export default {get EventStreamSerde(){return T}};
2
+ import{X as M}from"./chunk-cna105t6.js";import{si as E}from"./chunk-e6fp6dxx.js";class x{marshaller;serializer;deserializer;serdeContext;defaultContentType;constructor({marshaller:i,serializer:n,deserializer:o,serdeContext:c,defaultContentType:y}){this.marshaller=i,this.serializer=n,this.deserializer=o,this.serdeContext=c,this.defaultContentType=y}async serializeEventStream({eventStream:i,requestSchema:n,initialRequest:o}){let c=this.marshaller,y=n.getEventStreamMember(),p=n.getMemberSchema(y),d=this.serializer,f=this.defaultContentType,h=Symbol("initialRequestMarker"),S={async*[Symbol.asyncIterator](){if(o){let r={":event-type":{type:"string",value:"initial-request"},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:f}};d.write(n,o);let t=d.flush();yield{[h]:!0,headers:r,body:t}}for await(let r of i)yield r}};return c.serialize(S,(r)=>{if(r[h])return{headers:r.headers,body:r.body};let t=Object.keys(r).find((s)=>{return s!=="__type"})??"",{additionalHeaders:e,body:a,eventType:l,explicitPayloadContentType:m}=this.writeEventBody(t,p,r);return{headers:{":event-type":{type:"string",value:l},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:m??f},...e},body:a}})}async deserializeEventStream({response:i,responseSchema:n,initialResponseContainer:o}){let c=this.marshaller,y=n.getEventStreamMember(),d=n.getMemberSchema(y).getMemberSchemas(),f=Symbol("initialResponseMarker"),h=c.deserialize(i.body,async(t)=>{let e=Object.keys(t).find((l)=>{return l!=="__type"})??"",a=t[e].body;if(e==="initial-response"){let l=await this.deserializer.read(n,a);return delete l[y],{[f]:!0,...l}}else if(e in d){let l=d[e];if(l.isStructSchema()){let m={},u=!1;for(let[s,g]of l.structIterator()){let{eventHeader:v,eventPayload:w}=g.getMergedTraits();if(u=u||Boolean(v||w),w){if(g.isBlobSchema())m[s]=a;else if(g.isStringSchema())m[s]=(this.serdeContext?.utf8Encoder??z.toUtf8)(a);else if(g.isStructSchema())m[s]=await this.deserializer.read(g,a)}else if(v){let b=t[e].headers[s]?.value;if(b!=null)if(g.isNumericSchema())if(b&&typeof b==="object"&&"bytes"in b)m[s]=BigInt(b.toString());else m[s]=Number(b);else m[s]=b}}if(u)return{[e]:m};if(a.byteLength===0)return{[e]:{}}}return{[e]:await this.deserializer.read(l,a)}}else return{$unknown:t}}),S=h[Symbol.asyncIterator](),r=await S.next();if(r.done)return h;if(r.value?.[f]){if(!n)throw Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");for(let[t,e]of Object.entries(r.value))o[t]=e}return{async*[Symbol.asyncIterator](){if(!r?.value?.[f])yield r.value;while(!0){let{done:t,value:e}=await S.next();if(t)break;yield e}}}}writeEventBody(i,n,o){let c=this.serializer,y=i,p=null,d,f=(()=>{return n.getSchema()[4].includes(i)})(),h={};if(!f){let[t,e]=o[i];y=t,c.write(15,e)}else{let t=n.getMemberSchema(i);if(t.isStructSchema()){for(let[e,a]of t.structIterator()){let{eventHeader:l,eventPayload:m}=a.getMergedTraits();if(m)p=e;else if(l){let u=o[i][e],s="binary";if(a.isNumericSchema())if(-2147483648<=u&&u<=2147483647)s="integer";else s="long";else if(a.isTimestampSchema())s="timestamp";else if(a.isStringSchema())s="string";else if(a.isBooleanSchema())s="boolean";if(u!=null)h[e]={type:s,value:u},delete o[i][e]}}if(p!==null){let e=t.getMemberSchema(p);if(e.isBlobSchema())d="application/octet-stream";else if(e.isStringSchema())d="text/plain";c.write(e,o[i][p])}else c.write(t,o[i])}else if(t.isUnitSchema())c.write(t,{});else throw Error("@smithy/core/event-streams - non-struct member not supported in event stream union.")}let S=c.flush()??new Uint8Array;return{body:typeof S==="string"?(this.serdeContext?.utf8Decoder??z.fromUtf8)(S):S,eventType:y,explicitPayloadContentType:d,additionalHeaders:h}}}var z,T;var C=E(()=>{z=M();T=x});C();export{T as EventStreamSerde};export default {get EventStreamSerde(){return T}};
3
3
 
4
- //# debugId=E52583FF9AB4D29064756E2164756E21
4
+ //# debugId=0F964E6CC529D3B664756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "'use strict';\n\nvar utilUtf8 = require('@smithy/util-utf8');\n\nclass EventStreamSerde {\n marshaller;\n serializer;\n deserializer;\n serdeContext;\n defaultContentType;\n constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }) {\n this.marshaller = marshaller;\n this.serializer = serializer;\n this.deserializer = deserializer;\n this.serdeContext = serdeContext;\n this.defaultContentType = defaultContentType;\n }\n async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {\n const marshaller = this.marshaller;\n const eventStreamMember = requestSchema.getEventStreamMember();\n const unionSchema = requestSchema.getMemberSchema(eventStreamMember);\n const serializer = this.serializer;\n const defaultContentType = this.defaultContentType;\n const initialRequestMarker = Symbol(\"initialRequestMarker\");\n const eventStreamIterable = {\n async *[Symbol.asyncIterator]() {\n if (initialRequest) {\n const headers = {\n \":event-type\": { type: \"string\", value: \"initial-request\" },\n \":message-type\": { type: \"string\", value: \"event\" },\n \":content-type\": { type: \"string\", value: defaultContentType },\n };\n serializer.write(requestSchema, initialRequest);\n const body = serializer.flush();\n yield {\n [initialRequestMarker]: true,\n headers,\n body,\n };\n }\n for await (const page of eventStream) {\n yield page;\n }\n },\n };\n return marshaller.serialize(eventStreamIterable, (event) => {\n if (event[initialRequestMarker]) {\n return {\n headers: event.headers,\n body: event.body,\n };\n }\n const unionMember = Object.keys(event).find((key) => {\n return key !== \"__type\";\n }) ?? \"\";\n const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);\n const headers = {\n \":event-type\": { type: \"string\", value: eventType },\n \":message-type\": { type: \"string\", value: \"event\" },\n \":content-type\": { type: \"string\", value: explicitPayloadContentType ?? defaultContentType },\n ...additionalHeaders,\n };\n return {\n headers,\n body,\n };\n });\n }\n async deserializeEventStream({ response, responseSchema, initialResponseContainer, }) {\n const marshaller = this.marshaller;\n const eventStreamMember = responseSchema.getEventStreamMember();\n const unionSchema = responseSchema.getMemberSchema(eventStreamMember);\n const memberSchemas = unionSchema.getMemberSchemas();\n const initialResponseMarker = Symbol(\"initialResponseMarker\");\n const asyncIterable = marshaller.deserialize(response.body, async (event) => {\n const unionMember = Object.keys(event).find((key) => {\n return key !== \"__type\";\n }) ?? \"\";\n const body = event[unionMember].body;\n if (unionMember === \"initial-response\") {\n const dataObject = await this.deserializer.read(responseSchema, body);\n delete dataObject[eventStreamMember];\n return {\n [initialResponseMarker]: true,\n ...dataObject,\n };\n }\n else if (unionMember in memberSchemas) {\n const eventStreamSchema = memberSchemas[unionMember];\n if (eventStreamSchema.isStructSchema()) {\n const out = {};\n let hasBindings = false;\n for (const [name, member] of eventStreamSchema.structIterator()) {\n const { eventHeader, eventPayload } = member.getMergedTraits();\n hasBindings = hasBindings || Boolean(eventHeader || eventPayload);\n if (eventPayload) {\n if (member.isBlobSchema()) {\n out[name] = body;\n }\n else if (member.isStringSchema()) {\n out[name] = (this.serdeContext?.utf8Encoder ?? utilUtf8.toUtf8)(body);\n }\n else if (member.isStructSchema()) {\n out[name] = await this.deserializer.read(member, body);\n }\n }\n else if (eventHeader) {\n const value = event[unionMember].headers[name]?.value;\n if (value != null) {\n if (member.isNumericSchema()) {\n if (value && typeof value === \"object\" && \"bytes\" in value) {\n out[name] = BigInt(value.toString());\n }\n else {\n out[name] = Number(value);\n }\n }\n else {\n out[name] = value;\n }\n }\n }\n }\n if (hasBindings) {\n return {\n [unionMember]: out,\n };\n }\n if (body.byteLength === 0) {\n return {\n [unionMember]: {},\n };\n }\n }\n return {\n [unionMember]: await this.deserializer.read(eventStreamSchema, body),\n };\n }\n else {\n return {\n $unknown: event,\n };\n }\n });\n const asyncIterator = asyncIterable[Symbol.asyncIterator]();\n const firstEvent = await asyncIterator.next();\n if (firstEvent.done) {\n return asyncIterable;\n }\n if (firstEvent.value?.[initialResponseMarker]) {\n if (!responseSchema) {\n throw new Error(\"@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.\");\n }\n for (const [key, value] of Object.entries(firstEvent.value)) {\n initialResponseContainer[key] = value;\n }\n }\n return {\n async *[Symbol.asyncIterator]() {\n if (!firstEvent?.value?.[initialResponseMarker]) {\n yield firstEvent.value;\n }\n while (true) {\n const { done, value } = await asyncIterator.next();\n if (done) {\n break;\n }\n yield value;\n }\n },\n };\n }\n writeEventBody(unionMember, unionSchema, event) {\n const serializer = this.serializer;\n let eventType = unionMember;\n let explicitPayloadMember = null;\n let explicitPayloadContentType;\n const isKnownSchema = (() => {\n const struct = unionSchema.getSchema();\n return struct[4].includes(unionMember);\n })();\n const additionalHeaders = {};\n if (!isKnownSchema) {\n const [type, value] = event[unionMember];\n eventType = type;\n serializer.write(15, value);\n }\n else {\n const eventSchema = unionSchema.getMemberSchema(unionMember);\n if (eventSchema.isStructSchema()) {\n for (const [memberName, memberSchema] of eventSchema.structIterator()) {\n const { eventHeader, eventPayload } = memberSchema.getMergedTraits();\n if (eventPayload) {\n explicitPayloadMember = memberName;\n }\n else if (eventHeader) {\n const value = event[unionMember][memberName];\n let type = \"binary\";\n if (memberSchema.isNumericSchema()) {\n if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {\n type = \"integer\";\n }\n else {\n type = \"long\";\n }\n }\n else if (memberSchema.isTimestampSchema()) {\n type = \"timestamp\";\n }\n else if (memberSchema.isStringSchema()) {\n type = \"string\";\n }\n else if (memberSchema.isBooleanSchema()) {\n type = \"boolean\";\n }\n if (value != null) {\n additionalHeaders[memberName] = {\n type,\n value,\n };\n delete event[unionMember][memberName];\n }\n }\n }\n if (explicitPayloadMember !== null) {\n const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);\n if (payloadSchema.isBlobSchema()) {\n explicitPayloadContentType = \"application/octet-stream\";\n }\n else if (payloadSchema.isStringSchema()) {\n explicitPayloadContentType = \"text/plain\";\n }\n serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);\n }\n else {\n serializer.write(eventSchema, event[unionMember]);\n }\n }\n else if (eventSchema.isUnitSchema()) {\n serializer.write(eventSchema, {});\n }\n else {\n throw new Error(\"@smithy/core/event-streams - non-struct member not supported in event stream union.\");\n }\n }\n const messageSerialization = serializer.flush() ?? new Uint8Array();\n const body = typeof messageSerialization === \"string\"\n ? (this.serdeContext?.utf8Decoder ?? utilUtf8.fromUtf8)(messageSerialization)\n : messageSerialization;\n return {\n body,\n eventType,\n explicitPayloadContentType,\n additionalHeaders,\n };\n }\n}\n\nexports.EventStreamSerde = EventStreamSerde;\n"
6
6
  ],
7
7
  "mappings": ";uFAIA,AAAM,CAAiB,CACnB,WACA,WACA,aACA,aACA,mBACA,WAAW,EAAG,aAAY,aAAY,eAAc,eAAc,sBAAuB,CACrF,KAAK,WAAa,EAClB,KAAK,WAAa,EAClB,KAAK,aAAe,EACpB,KAAK,aAAe,EACpB,KAAK,mBAAqB,OAExB,qBAAoB,EAAG,cAAa,gBAAe,kBAAmB,CACxE,IAAM,EAAa,KAAK,WAClB,EAAoB,EAAc,qBAAqB,EACvD,EAAc,EAA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B,EAGzE,OAAW,MAAM,EAAa,EAAM,EAAY,EAGnD,QAAI,EAAY,aAAa,EAC9B,EAAW,MAAM,EAAa,CAAC,CAAC,EAGhC,WAAU,MAAM,qFAAqF,EAG7G,IAAM,EAAuB,EAAW,MAAM,GAAK,IAAI,WAIvD,MAAO,CACH,KAJS,OAAO,IAAyB,UACtC,KAAK,cAAc,aAAe,EAAS,UAAU,CAAoB,EAC1E,EAGF,YACA,6BACA,mBACJ,EAER,KA9PI,EAgQI,eAhQJ,MAgQI,EAAmB",
8
- "debugId": "E52583FF9AB4D29064756E2164756E21",
8
+ "debugId": "0F964E6CC529D3B664756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
2
  class J extends Error{lock;token;constructor(x,y,B="its lease ran out or another holder took it"){super(`Lost the lock "${x}" (token ${y}): ${B}.`);this.lock=x;this.token=y;this.name="LockLostError"}}var Q=60000,V=100,X=(x)=>new Promise((y)=>setTimeout(y,x));class O{store;name;owner;token;ttl;lost;controller=new AbortController;deadline;expiryTimer;renewTimer;done=!1;constructor(x,y,B,z,C,G){this.store=x;this.name=y;this.owner=B;this.token=z;this.ttl=C;this.lost=this.controller.signal,this.deadline=G+C,this.armExpiry()}get expired(){return this.lost.aborted||performance.now()>=this.deadline}async extend(x=this.ttl){if(this.lost.aborted)return!1;let y=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,y+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 J(this.name,this.token);try{return await this.store.fence(this.name,this.owner,this.token,x)}catch(y){if(y instanceof J)this.markLost();throw y}}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 J(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 Y{store;static token="locks";constructor(x){this.store=x}async acquire(x,y={}){let B=y.ttl??Q;if(!(B>0))throw Error(`A lock's ttl must be a positive number of milliseconds; got ${B}.`);let z=Bun.randomUUIDv7(),C=performance.now()+Math.max(0,y.wait??0);for(;;){let G=performance.now(),K=await this.store.acquire(x,z,B);if(K!==null){let N=new O(this.store,x,z,K,B,G);if(y.renew)N.startRenewing();return N}let M=C-performance.now();if(M<=0)return null;await X(Math.min(V,M))}}async run(x,y,B){let z=await this.acquire(x,{...y,renew:y.renew??!0});if(!z)return{acquired:!1};let C;try{C=await B(z)}catch(G){throw await z.release().catch(()=>{}),G}if(z.expired)throw z.markLost(),z.lost.reason;return await z.release(),{acquired:!0,value:C}}}
3
- export{J as xg,O as yg,Y as zg};
3
+ export{J as Wg,O as Xg,Y as Yg};
4
4
 
5
- //# debugId=275ACC29E0A8C8B764756E2164756E21
5
+ //# debugId=0345D8A2F1E5245564756E2164756E21