gemi 0.55.0 → 0.57.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 (199) hide show
  1. package/dist/app/index.js +1 -1
  2. package/dist/broadcasting/index.js +1 -1
  3. package/dist/bun/plugin.js +1 -1
  4. package/dist/bun/preload.js +1 -1
  5. package/dist/{chunk-rsdg619q.js → chunk-11dkjm1r.js} +2 -2
  6. package/dist/{chunk-rsdg619q.js.map → chunk-11dkjm1r.js.map} +1 -1
  7. package/dist/{chunk-eqrd31ye.js → chunk-17m5wxv0.js} +2 -2
  8. package/dist/{chunk-eqrd31ye.js.map → chunk-17m5wxv0.js.map} +1 -1
  9. package/dist/{chunk-ct274qts.js → chunk-1esnvq2z.js} +2 -2
  10. package/dist/{chunk-ct274qts.js.map → chunk-1esnvq2z.js.map} +1 -1
  11. package/dist/{chunk-4xx78ba9.js → chunk-1nqdzmvm.js} +2 -2
  12. package/dist/{chunk-4xx78ba9.js.map → chunk-1nqdzmvm.js.map} +1 -1
  13. package/dist/{chunk-dzzmqv0j.js → chunk-32d510cd.js} +2 -2
  14. package/dist/{chunk-dzzmqv0j.js.map → chunk-32d510cd.js.map} +1 -1
  15. package/dist/{chunk-kgmr9qxx.js → chunk-4f69ygc8.js} +2 -2
  16. package/dist/{chunk-kgmr9qxx.js.map → chunk-4f69ygc8.js.map} +1 -1
  17. package/dist/chunk-5fmbsy4q.js +6 -0
  18. package/dist/{chunk-9r1atj8w.js.map → chunk-5fmbsy4q.js.map} +2 -2
  19. package/dist/{chunk-699z6d8y.js → chunk-5txddtaa.js} +3 -3
  20. package/dist/{chunk-699z6d8y.js.map → chunk-5txddtaa.js.map} +1 -1
  21. package/dist/{chunk-gasdfwva.js → chunk-5z5xskg1.js} +2 -2
  22. package/dist/{chunk-gasdfwva.js.map → chunk-5z5xskg1.js.map} +1 -1
  23. package/dist/{chunk-3e88tyee.js → chunk-64bq12j3.js} +2 -2
  24. package/dist/{chunk-3e88tyee.js.map → chunk-64bq12j3.js.map} +1 -1
  25. package/dist/{chunk-javjeayw.js → chunk-67zyjx0c.js} +2 -2
  26. package/dist/{chunk-javjeayw.js.map → chunk-67zyjx0c.js.map} +1 -1
  27. package/dist/{chunk-xjy5apyr.js → chunk-6c14bexh.js} +2 -2
  28. package/dist/{chunk-xjy5apyr.js.map → chunk-6c14bexh.js.map} +1 -1
  29. package/dist/{chunk-vkngcrzq.js → chunk-6fc909z5.js} +2 -2
  30. package/dist/{chunk-vkngcrzq.js.map → chunk-6fc909z5.js.map} +1 -1
  31. package/dist/{chunk-v6v6sem5.js → chunk-74aj8ms2.js} +2 -2
  32. package/dist/{chunk-v6v6sem5.js.map → chunk-74aj8ms2.js.map} +1 -1
  33. package/dist/{chunk-npg72mez.js → chunk-7pn0bnsc.js} +2 -2
  34. package/dist/{chunk-npg72mez.js.map → chunk-7pn0bnsc.js.map} +1 -1
  35. package/dist/{chunk-x14sk95v.js → chunk-8v81dvje.js} +3 -3
  36. package/dist/{chunk-x14sk95v.js.map → chunk-8v81dvje.js.map} +1 -1
  37. package/dist/chunk-9j9wqrb2.js +5 -0
  38. package/dist/chunk-9j9wqrb2.js.map +33 -0
  39. package/dist/{chunk-enhkf60v.js → chunk-a70s8pz4.js} +2 -2
  40. package/dist/{chunk-enhkf60v.js.map → chunk-a70s8pz4.js.map} +1 -1
  41. package/dist/{chunk-wgpa04jb.js → chunk-ae6xz52s.js} +2 -2
  42. package/dist/{chunk-wgpa04jb.js.map → chunk-ae6xz52s.js.map} +1 -1
  43. package/dist/{chunk-62ke19q4.js → chunk-ba0rkpk5.js} +4 -4
  44. package/dist/{chunk-62ke19q4.js.map → chunk-ba0rkpk5.js.map} +1 -1
  45. package/dist/{chunk-4yafsffx.js → chunk-btr9kyqh.js} +2 -2
  46. package/dist/{chunk-4yafsffx.js.map → chunk-btr9kyqh.js.map} +1 -1
  47. package/dist/{chunk-gzdf2025.js → chunk-bw8kt7ps.js} +2 -2
  48. package/dist/{chunk-gzdf2025.js.map → chunk-bw8kt7ps.js.map} +1 -1
  49. package/dist/{chunk-02gdzs5t.js → chunk-cecq6q1b.js} +1 -1
  50. package/dist/{chunk-d36dfqxw.js → chunk-d6kgxmp7.js} +3 -3
  51. package/dist/{chunk-d36dfqxw.js.map → chunk-d6kgxmp7.js.map} +1 -1
  52. package/dist/{chunk-g30q4n5y.js → chunk-dcwjwfjc.js} +2 -2
  53. package/dist/{chunk-g30q4n5y.js.map → chunk-dcwjwfjc.js.map} +1 -1
  54. package/dist/{chunk-77xj0dgc.js → chunk-dwz0wbhj.js} +2 -2
  55. package/dist/{chunk-77xj0dgc.js.map → chunk-dwz0wbhj.js.map} +1 -1
  56. package/dist/{chunk-9r0sb4zn.js → chunk-dxxak51x.js} +2 -2
  57. package/dist/{chunk-9r0sb4zn.js.map → chunk-dxxak51x.js.map} +1 -1
  58. package/dist/{chunk-62723jyy.js → chunk-e9zz0zfv.js} +1 -1
  59. package/dist/{chunk-01am9k5v.js → chunk-f233yzxf.js} +2 -2
  60. package/dist/{chunk-01am9k5v.js.map → chunk-f233yzxf.js.map} +1 -1
  61. package/dist/{chunk-tja0c815.js → chunk-fck5yw2s.js} +2 -2
  62. package/dist/{chunk-tja0c815.js.map → chunk-fck5yw2s.js.map} +1 -1
  63. package/dist/chunk-g5pj95dz.js +9 -0
  64. package/dist/{chunk-kry5vwam.js.map → chunk-g5pj95dz.js.map} +3 -3
  65. package/dist/{chunk-31kcf7dq.js → chunk-j21tm6jf.js} +2 -2
  66. package/dist/{chunk-31kcf7dq.js.map → chunk-j21tm6jf.js.map} +1 -1
  67. package/dist/{chunk-pvdbrt4z.js → chunk-jny4f23c.js} +3 -3
  68. package/dist/{chunk-pvdbrt4z.js.map → chunk-jny4f23c.js.map} +1 -1
  69. package/dist/{chunk-64s1pzz1.js → chunk-jzatvtjd.js} +2 -2
  70. package/dist/{chunk-64s1pzz1.js.map → chunk-jzatvtjd.js.map} +1 -1
  71. package/dist/{chunk-cn2r5jfj.js → chunk-k5bjfhz8.js} +2 -2
  72. package/dist/{chunk-cn2r5jfj.js.map → chunk-k5bjfhz8.js.map} +1 -1
  73. package/dist/{chunk-kgg1eqne.js → chunk-ka4tdhm8.js} +2 -2
  74. package/dist/{chunk-kgg1eqne.js.map → chunk-ka4tdhm8.js.map} +1 -1
  75. package/dist/{chunk-h3mwgbg7.js → chunk-katt90qz.js} +2 -2
  76. package/dist/{chunk-h3mwgbg7.js.map → chunk-katt90qz.js.map} +1 -1
  77. package/dist/{chunk-y9fp58bg.js → chunk-knvxwrwh.js} +2 -2
  78. package/dist/{chunk-y9fp58bg.js.map → chunk-knvxwrwh.js.map} +1 -1
  79. package/dist/{chunk-9c89q2mz.js → chunk-ma5rj4st.js} +2 -2
  80. package/dist/{chunk-9c89q2mz.js.map → chunk-ma5rj4st.js.map} +1 -1
  81. package/dist/{chunk-v06qcyj5.js → chunk-mqwrmbh4.js} +3 -3
  82. package/dist/{chunk-v06qcyj5.js.map → chunk-mqwrmbh4.js.map} +1 -1
  83. package/dist/{chunk-jdj7k3r9.js → chunk-msyqr4y7.js} +2 -2
  84. package/dist/{chunk-jdj7k3r9.js.map → chunk-msyqr4y7.js.map} +1 -1
  85. package/dist/{chunk-q0waxxz5.js → chunk-n2zmg475.js} +2 -2
  86. package/dist/{chunk-q0waxxz5.js.map → chunk-n2zmg475.js.map} +1 -1
  87. package/dist/{chunk-33wjsw4r.js → chunk-nkbreczg.js} +3 -3
  88. package/dist/{chunk-33wjsw4r.js.map → chunk-nkbreczg.js.map} +1 -1
  89. package/dist/{chunk-1pwwrpa3.js → chunk-nqk3cx97.js} +2 -2
  90. package/dist/{chunk-1pwwrpa3.js.map → chunk-nqk3cx97.js.map} +1 -1
  91. package/dist/{chunk-4qwwy968.js → chunk-q8k3gh8k.js} +2 -2
  92. package/dist/{chunk-4qwwy968.js.map → chunk-q8k3gh8k.js.map} +1 -1
  93. package/dist/{chunk-f9mfw82d.js → chunk-qfzyym5h.js} +3 -3
  94. package/dist/{chunk-f9mfw82d.js.map → chunk-qfzyym5h.js.map} +1 -1
  95. package/dist/{chunk-rgb69nh1.js → chunk-qkrba9c2.js} +2 -2
  96. package/dist/{chunk-rgb69nh1.js.map → chunk-qkrba9c2.js.map} +1 -1
  97. package/dist/{chunk-1zfsgffv.js → chunk-r8637cqv.js} +3 -3
  98. package/dist/{chunk-1zfsgffv.js.map → chunk-r8637cqv.js.map} +1 -1
  99. package/dist/chunk-r9as9htn.js +5 -0
  100. package/dist/{chunk-b50zmz3t.js.map → chunk-r9as9htn.js.map} +1 -1
  101. package/dist/{chunk-tmnhkphv.js → chunk-r9h6aj7g.js} +4 -4
  102. package/dist/{chunk-tmnhkphv.js.map → chunk-r9h6aj7g.js.map} +1 -1
  103. package/dist/{chunk-w9k9s4wh.js → chunk-rc2asvyf.js} +2 -2
  104. package/dist/{chunk-w9k9s4wh.js.map → chunk-rc2asvyf.js.map} +1 -1
  105. package/dist/{chunk-m0ggfy1m.js → chunk-rxsmwbxv.js} +2 -2
  106. package/dist/{chunk-m0ggfy1m.js.map → chunk-rxsmwbxv.js.map} +1 -1
  107. package/dist/{chunk-rjxdc0xh.js → chunk-swe2b6rv.js} +1 -1
  108. package/dist/chunk-tzsnadg1.js +37 -0
  109. package/dist/chunk-tzsnadg1.js.map +20 -0
  110. package/dist/{chunk-3y75q5a2.js → chunk-vdzb29p5.js} +2 -2
  111. package/dist/{chunk-3y75q5a2.js.map → chunk-vdzb29p5.js.map} +1 -1
  112. package/dist/{chunk-8k1zqrvh.js → chunk-wrypq618.js} +2 -2
  113. package/dist/{chunk-8k1zqrvh.js.map → chunk-wrypq618.js.map} +1 -1
  114. package/dist/{chunk-hs5v3eqj.js → chunk-yhzb9qpk.js} +2 -2
  115. package/dist/{chunk-hs5v3eqj.js.map → chunk-yhzb9qpk.js.map} +1 -1
  116. package/dist/client/index.d.ts +3 -2
  117. package/dist/client/index.d.ts.map +1 -1
  118. package/dist/config/index.js +1 -1
  119. package/dist/console/run.js +2 -2
  120. package/dist/console/run.js.map +1 -1
  121. package/dist/container/index.js +2 -2
  122. package/dist/container/index.js.map +1 -1
  123. package/dist/database/index.js +2 -2
  124. package/dist/database/index.js.map +1 -1
  125. package/dist/email/index.js +2 -2
  126. package/dist/email/index.js.map +1 -1
  127. package/dist/facades/index.d.ts +1 -0
  128. package/dist/facades/index.d.ts.map +1 -1
  129. package/dist/facades/index.js +2 -2
  130. package/dist/facades/index.js.map +1 -1
  131. package/dist/foundation/index.js +2 -2
  132. package/dist/foundation/index.js.map +1 -1
  133. package/dist/gemi.d.ts +45 -0
  134. package/dist/http/index.js +2 -2
  135. package/dist/http/index.js.map +1 -1
  136. package/dist/i18n/dictionaryRuntime.js +2 -2
  137. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  138. package/dist/i18n/index.js +2 -2
  139. package/dist/i18n/index.js.map +1 -1
  140. package/dist/ide/typescript-plugin/index.js +1206 -0
  141. package/dist/ide/typescript-plugin/index.js.map +17 -0
  142. package/dist/internal/type-stubs/app/http/routes/api.d.ts +24 -0
  143. package/dist/internal/type-stubs/app/http/routes/api.d.ts.map +1 -0
  144. package/dist/internal/type-stubs/app/http/routes/view.d.ts +6 -0
  145. package/dist/internal/type-stubs/app/http/routes/view.d.ts.map +1 -0
  146. package/dist/internal/type-stubs/app/i18n/index.d.ts +4 -0
  147. package/dist/internal/type-stubs/app/i18n/index.d.ts.map +1 -0
  148. package/dist/kernel/index.js +3 -3
  149. package/dist/kernel/index.js.map +3 -3
  150. package/dist/kernel/providers.d.ts +16 -4
  151. package/dist/kernel/providers.d.ts.map +1 -1
  152. package/dist/orm/context.d.ts +65 -0
  153. package/dist/orm/context.d.ts.map +1 -1
  154. package/dist/orm/index.js +2 -2
  155. package/dist/orm/index.js.map +1 -1
  156. package/dist/server/index.js +2 -2
  157. package/dist/server/index.js.map +1 -1
  158. package/dist/services/discovery.d.ts +27 -0
  159. package/dist/services/discovery.d.ts.map +1 -1
  160. package/dist/services/events/Event.d.ts +208 -0
  161. package/dist/services/events/Event.d.ts.map +1 -0
  162. package/dist/services/events/EventManager.d.ts +285 -0
  163. package/dist/services/events/EventManager.d.ts.map +1 -0
  164. package/dist/services/events/EventServiceProvider.d.ts +46 -0
  165. package/dist/services/events/EventServiceProvider.d.ts.map +1 -0
  166. package/dist/services/events/FakeEventManager.d.ts +155 -0
  167. package/dist/services/events/FakeEventManager.d.ts.map +1 -0
  168. package/dist/services/events/FakeEventManager.test-d.d.ts +2 -0
  169. package/dist/services/events/FakeEventManager.test-d.d.ts.map +1 -0
  170. package/dist/services/events/Listener.d.ts +189 -0
  171. package/dist/services/events/Listener.d.ts.map +1 -0
  172. package/dist/services/events/Listener.test-d.d.ts +2 -0
  173. package/dist/services/events/Listener.test-d.d.ts.map +1 -0
  174. package/dist/services/events/config.d.ts +55 -0
  175. package/dist/services/events/config.d.ts.map +1 -0
  176. package/dist/services/events/listenerJob.d.ts +43 -0
  177. package/dist/services/events/listenerJob.d.ts.map +1 -0
  178. package/dist/services/index.d.ts +6 -1
  179. package/dist/services/index.d.ts.map +1 -1
  180. package/dist/services/index.js +8 -8
  181. package/dist/services/index.js.map +5 -3
  182. package/dist/services/queue/QueueManager.d.ts +31 -0
  183. package/dist/services/queue/QueueManager.d.ts.map +1 -1
  184. package/dist/support/index.js +2 -2
  185. package/dist/support/index.js.map +1 -1
  186. package/dist/testing/index.d.ts +24 -0
  187. package/dist/testing/index.d.ts.map +1 -1
  188. package/ide/typescript-plugin/package.json +5 -0
  189. package/package.json +4 -2
  190. package/dist/chunk-4t80js0n.js +0 -33
  191. package/dist/chunk-4t80js0n.js.map +0 -18
  192. package/dist/chunk-98a576s9.js +0 -5
  193. package/dist/chunk-98a576s9.js.map +0 -30
  194. package/dist/chunk-9r1atj8w.js +0 -6
  195. package/dist/chunk-b50zmz3t.js +0 -5
  196. package/dist/chunk-kry5vwam.js +0 -9
  197. /package/dist/{chunk-02gdzs5t.js.map → chunk-cecq6q1b.js.map} +0 -0
  198. /package/dist/{chunk-62723jyy.js.map → chunk-e9zz0zfv.js.map} +0 -0
  199. /package/dist/{chunk-rjxdc0xh.js.map → chunk-swe2b6rv.js.map} +0 -0
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{Db as Q,Fb as I,Hb as m,Ib as l,Jb as p,Lb as b,ub as u,vb as $}from"./chunk-tzsnadg1.js";import{Sb as H}from"./chunk-17m5wxv0.js";import{Ub as S,ac as L,gc as q,hc as U,ic as T,oc as R,qc as E,rc as W,wc as k}from"./chunk-r9h6aj7g.js";import{Gc as v}from"./chunk-g5pj95dz.js";import{ie as w,ne as M,re as j}from"./chunk-6fc909z5.js";import{_e as Y}from"./chunk-btr9kyqh.js";import{df as J}from"./chunk-jny4f23c.js";import{ff as y,if as A}from"./chunk-mqwrmbh4.js";async function a(x){try{if(!await x.shouldRun.call(x))return}catch(B){console.error(`Error evaluating shouldRun for cron job ${x.name}:`,B);return}try{await x.onTick.call(x)}catch(B){console.error(`Error executing cron job ${x.name}:`,B)}try{await x.callback.call(x)}catch(B){console.error(`Error in cron job ${x.name}:`,B)}try{await x.onComplete.call(x)}catch(B){console.error(`Error completing cron job ${x.name}:`,B)}}class V{static token="scheduler";handles=[];resolved;constructor(x){this.resolved=x.jobs}get jobs(){return[...this.resolved]}useJobs(x){this.resolved=x}start(x=(B)=>B()){if(this.resolved.length===0)return;let B=globalThis.__gemiCronJobs??=new Map,C=new Map;for(let F of this.resolved){let G=new F;if(!G.name){console.error(`Cron job must have a name \u2014 ${F.name||"an anonymous class"} has none, so it is not scheduled. If this is a base class that other jobs extend, move it out of the discovered directory: \`abstract\` does not survive to runtime, so a class under app/cron is indistinguishable from a job.`);continue}if(!G.cron){console.error(`Cron job must have an expression. Job: ${G.name}`);continue}let P=C.get(G.name);if(P!==void 0){console.error(`Two cron jobs claim the name "${G.name}" \u2014 ${P} is scheduled and ${F.name||"an anonymous class"} is not. A name is the scheduler's key, so only one job can hold it. Rename one.`);continue}C.set(G.name,F.name||"an anonymous class"),B.get(G.name)?.stop();let X=Bun.cron(G.cron,()=>x(()=>a(G)));B.set(G.name,X),this.handles.push(X)}}stop(){for(let x of this.handles)x.stop();this.handles=[]}}class n extends H{register(){this.app.singleton(M,()=>new M(this.app.config.get("auth",{})))}}class t extends H{register(){this.app.singleton(V,()=>new V(Y(Q(),this.app.config.get("schedule",{}))))}async boot(){let x=this.app.make(V),B=this.app.config.get("schedule",{});if(B.jobs===void 0){let{jobsDir:F}=Y(Q(),B);x.useJobs(await p(F))}if(process.env.GEMI_NO_SCHEDULE==="1")return;let C=this.app;x.start((F)=>y.run(C,F))}}class e extends H{register(){this.app.singleton(J,()=>new J(this.app.config.get("mail",{})))}}function xx(x){return`listener:${x}`}function g(x,B){Bx(x);let{maxAttempts:C,worker:F}=B,G=x.event.name,P=class extends m{maxAttempts=C;worker=F;async run(...X){let[Z,_]=Cx(X),O=A(K).rehydrate(Z,_);await new x().handle(O)}onFail(X){console.error(`The listener ${x.name} threw while handling ${G} off the queue. The queue will retry it up to ${C} times in total; nothing the dispatcher did is waiting on it.`,X)}onDeadletter(X){console.error(`The listener ${x.name} failed every one of its ${C} attempts at ${G} and has been dead-lettered, so this side effect did not happen and will not be retried.`,X)}};return Object.defineProperty(P,"name",{value:xx(x.name),writable:!0}),P}function Bx(x){if(Object.getOwnPropertyDescriptor(x,"name")?.writable)return;throw Error(`The listener ${x.name} sets \`queued = true\` but does not declare \`static name\`, so it would be registered with the queue `+"under its class name \u2014 which a production build renames while the "+`payload that names it does not. Add: static name = "${x.name}";`)}function Cx(x){return typeof x[0]==="string"?x:x[0]}class K{static token="events";listeners={};events={};warnedFor=new Set;warnedAboutWaiting=new Set;config;constructor(x={}){this.config=Y(I(),x),this.useListeners(this.config.listeners)}useListeners(x){this.config.listeners=x,this.listeners={},this.events={};let B=new Set;for(let C of x){if(!C.event){console.error(`Listener ${C.name} does not declare \`static event\`, so there is no event name to register it under and its handle will never run. Add: static event = SomeEvent;`);continue}if(B.has(C.name)){console.error(`Two event listeners are named "${C.name}" \u2014 the first is `+"registered and this one is not. A listener's name identifies it across the framework, so only one class can hold it. Rename one.");continue}B.add(C.name);let F=C.event.name,G=new C;this.events[F]??=C.event,(this.listeners[F]??=[]).push({listener:C,job:G.queued?g(C,G):null})}}get queuedListenerJobs(){return Object.values(this.listeners).flat().flatMap(({job:x})=>x?[x]:[])}get registeredListeners(){return[...this.config.listeners]}dispatch(x,B){if(this.deferToCommit(x,B,!1))return;this.runListeners(x,B)}async dispatchAndWait(x,B){if(this.deferToCommit(x,B,!0))return;return this.runListeners(x,B)}deferToCommit(x,B,C){let{name:F,afterCommit:G}=x.constructor;if(!G)return!1;let P=v(()=>this.runListeners(x,B));if(P&&C)this.warnNothingIsWaitedFor(F);return P}async runListeners(x,B){let C=x.constructor.name,F=this.listeners[C];if(!F?.length){this.warnNothingIsListening(C);return}for(let{listener:G,job:P}of F){if(P){this.enqueue(P,G,C,B);continue}try{await new G().handle(x)}catch(X){console.error(`The listener ${G.name} threw while handling ${C}. The `+"listeners after it still ran \u2014 a listener's failure is its own.",X)}}}rehydrate(x,B=[]){let C=this.events[x];if(!C)throw Error(`Cannot rebuild the event "${x}" that came off the queue: no registered listener binds to an event of that name, so there is no class to construct. A queued listener runs in an application that `+"discovered its own listeners \u2014 check that this process sees the "+`same app/listeners as the one that dispatched, and that the event declares \`static name = "${x}"\`.`);return new C(...B)}enqueue(x,B,C,F){if(F===void 0){console.error(`The listener ${B.name} is queued, but ${C} reached the dispatcher without its constructor arguments, so there is nothing for the queue to rebuild it from and the listener was skipped. Dispatch through ${C}.dispatch(...) or ${C}.dispatchAndWait(...), which carry them.`);return}try{A($).push(x,JSON.stringify([C,F]))}catch(G){console.error(`The listener ${B.name} could not be queued for ${C}, so it did not run and will not be retried. The listeners after it still ran.`,G)}}warnNothingIsWaitedFor(x){if(Bun.env.NODE_ENV==="production")return;if(this.warnedAboutWaiting.has(x))return;this.warnedAboutWaiting.add(x),console.warn(`[gemi] ${x}.dispatchAndWait() was called inside a transaction and ${x} declares \`static afterCommit = true\`, so it resolved `+"immediately with no listener having run \u2014 they run when the "+"transaction commits. Await the transaction instead, or drop afterCommit if the caller needs the side effects first. Development only.")}warnNothingIsListening(x){if(Bun.env.NODE_ENV==="production")return;if(this.warnedFor.has(x))return;this.warnedFor.add(x),console.warn(`[gemi] ${x} was dispatched and nothing is listening for it. A listener registers under the name its event declares, so check that app/listeners holds a Listener with \`static event = ${x}\` and that ${x} declares \`static name = "${x}"\`. Development only.`)}}class Fx extends H{register(){this.app.singleton(K,()=>new K(this.app.config.get("events",{})))}async boot(){let x=this.app.make(K),B=this.app.config.get("events",{});if(B.listeners===void 0){let{listenersDir:G}=Y(I(),B);x.useListeners(await b(G))}let C=x.queuedListenerJobs;if(C.length===0)return;let F=this.app.make($);for(let G of C)F.registerJob(G)}}class Gx extends H{register(){this.app.singleton(L,()=>new L(this.app.config.get("filesystem",{})))}}class Hx extends H{register(){this.app.singleton(q,()=>new q(this.app.config.get("image",{})))}}class Px extends H{register(){this.app.instance(R,new R)}}function GB(x){return x}function c(){return{maxFileSize:10485760,onLogFileClosed:()=>{},onLogCreated:()=>{}}}class Xx extends H{register(){this.app.singleton(U,()=>new U(Y(c(),this.app.config.get("log",{}))))}async boot(){await this.app.make(U).boot()}}class Yx extends H{register(){this.app.singleton(T,()=>new T(Y(w(),this.app.config.get("middleware",{}))))}}function AB(x){return x}function h(){return{channels:{}}}class Zx extends H{register(){this.app.singleton(S,()=>new S(Y(h(),this.app.config.get("broadcast",{}))))}}class _x extends H{register(){this.app.singleton($,()=>new $(this.app.config.get("queue",{})))}async boot(){let x=this.app.config.get("queue",{});if(x.jobs!==void 0)return;let{jobsDir:B}=Y(u(),x);this.app.make($).useJobs(await l(B))}}class N{}function d(x,B){return Math.floor(x/B)*B}function $x(x,B){if(B<=0)return 0;return Math.min(1,Math.max(0,(B-x)/B))}function D(x,B,C,F){return B*$x(C,F)+x}function Ox(x){let{current:B,previous:C,elapsed:F,window:G,limit:P,cost:X}=x,Z=P-X;if(Z<0)return G;let _=Math.max(0,G-F);if(C>0){let z=G*(1-(Z-B)/C);if(z<=G)return Math.max(0,Math.ceil(z-F))}if(B<=Z)return _;if(B<=0)return _;let O=G*(1-Z/B);return _+Math.max(0,Math.ceil(O))}function i(x){let{allowed:B,current:C,previous:F,now:G,elapsed:P,window:X,limit:Z,cost:_}=x;if(B){let z=D(C,F,P,X);return{allowed:!0,limit:Z,remaining:Math.max(0,Math.floor(Z-z)),resetAt:G-P+X,retryAfter:0}}let O=Ox({current:C,previous:F,elapsed:P,window:X,limit:Z,cost:_});return{allowed:!1,limit:Z,remaining:0,resetAt:G+O,retryAfter:O}}class f extends N{buckets=new Map;maxKeys;constructor(x={}){super();this.maxKeys=Math.max(1,x.maxKeys??1e5)}consume(x){let{key:B,limit:C,window:F}=x,G=x.cost??1,P=Date.now(),X=d(P,F),Z=P-X,_=this.roll(B,F,X),z=D(_.current,_.previous,Z,F)+G<=C;if(z)_.current+=G;if(this.buckets.delete(B),this.buckets.set(B,_),this.buckets.size>this.maxKeys)this.evict(P);return i({allowed:z,current:_.current,previous:_.previous,now:P,elapsed:Z,window:F,limit:C,cost:G})}clear(){this.buckets.clear()}get size(){return this.buckets.size}roll(x,B,C){let F=this.buckets.get(x);if(!F||F.window!==B)return{window:B,windowStart:C,current:0,previous:0};if(F.windowStart===C)return F;if(F.windowStart+B===C)return F.previous=F.current,F.current=0,F.windowStart=C,F;return F.previous=0,F.current=0,F.windowStart=C,F}evict(x){for(let[B,C]of this.buckets)if(x-C.windowStart>=C.window*2)this.buckets.delete(B);for(let B of this.buckets.keys()){if(this.buckets.size<=this.maxKeys)break;this.buckets.delete(B)}}}function pB(x){return x}function o(){return{driver:new f,limit:1000,window:60}}class zx extends H{register(){this.app.singleton(j,()=>new j(Y(o(),this.app.config.get("ratelimiter",{}))))}}function hB(x){return x}function s(){return{url:process.env.REDIS_URL,options:void 0}}class Kx extends H{register(){this.app.singleton(k,()=>new k(Y(s(),this.app.config.get("redis",{}))))}}function r(x,B){let C=x.get(B);if(!C)throw Error(`Missing "${B}" configuration. Route dispatching needs a root router \u2014 declare it in "app/config/route.ts".`);return C}class Vx extends H{register(){this.app.singleton(W,()=>new W(r(this.app.config,"route.api"))),this.app.singleton(E,()=>new E(r(this.app.config,"route.view")))}boot(){this.app.make(W),this.app.make(E)}}
3
+ export{V as Ta,n as Ua,t as Va,e as Wa,K as Xa,Fx as Ya,Gx as Za,Hx as _a,Px as $a,GB as ab,c as bb,Xx as cb,Yx as db,AB as eb,h as fb,Zx as gb,_x as hb,d as ib,i as jb,N as kb,f as lb,pB as mb,o as nb,zx as ob,hB as pb,s as qb,Kx as rb,Vx as sb};
4
+
5
+ //# debugId=B49E52DEF3A11B7964756E2164756E21
@@ -0,0 +1,33 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../services/cron/Scheduler.ts", "../auth/AuthServiceProvider.ts", "../services/cron/ScheduleServiceProvider.ts", "../services/email/MailServiceProvider.ts", "../services/events/listenerJob.ts", "../services/events/EventManager.ts", "../services/events/EventServiceProvider.ts", "../services/file-storage/FilesystemServiceProvider.ts", "../services/image-optimization/ImageServiceProvider.ts", "../services/kernel-id/KernelIdServiceProvider.ts", "../services/logging/config.ts", "../services/logging/LogServiceProvider.ts", "../services/middleware/MiddlewareServiceProvider.ts", "../services/pubsub/config.ts", "../services/pubsub/BroadcastServiceProvider.ts", "../services/queue/QueueServiceProvider.ts", "../services/rate-limiter/drivers/RateLimiterDriver.ts", "../services/rate-limiter/slidingWindow.ts", "../services/rate-limiter/drivers/InMemoryRateLimiterDriver.ts", "../services/rate-limiter/config.ts", "../services/rate-limiter/RateLimiterServiceProvider.ts", "../services/redis/config.ts", "../services/redis/RedisServiceProvider.ts", "../services/router/RouteServiceProvider.ts"],
4
+ "sourcesContent": [
5
+ "import type { CronJob } from \"./CronJob\";\nimport type { ScheduleConfig } from \"./config\";\n\n// The handle the in-process `Bun.cron(schedule, callback)` overload returns\n// (has `.stop()`). `ReturnType<typeof Bun.cron>` can't be used — it resolves to\n// the module-path overload's `Promise<void>` instead.\ntype BunCronHandle = Bun.CronJob;\n\n// Runs a tick inside whatever async context the framework needs, so a job body\n// can resolve services exactly like a request handler can.\nexport type ScheduleRunner = <T>(cb: () => T | Promise<T>) => Promise<T> | T;\n\ndeclare global {\n // Registered cron jobs keyed by name, kept on `globalThis` so it survives\n // `bun --hot` reloads. Re-registering a name stops the previous schedule\n // first, so a reload *updates* the job in place instead of stacking a\n // duplicate. (Bun also stops all in-process cron jobs before re-evaluating on\n // hot reload; this makes the intent explicit and covers any re-construction.)\n var __gemiCronJobs: Map<string, BunCronHandle> | undefined;\n}\n\n/**\n * One tick of one job: the gate, then the three hooks in order.\n *\n * Named and exported rather than left inline in `start()` because otherwise the\n * only way to reach it is to wait — the tightest schedule `Bun.cron` accepts is\n * once a minute, which is not a thing a test can honestly sit through. What a\n * caller gives up by calling this directly is Bun's clock; what it keeps is\n * everything the scheduler puts between the clock and the job, which is the\n * part that has behaviour.\n *\n * The three hooks each catch and log, so one throwing does not stop the next —\n * `onComplete` in particular runs whether `callback` returned or threw, closer\n * to a `finally` than to a success handler.\n */\nexport async function runTick(job: CronJob): Promise<void> {\n try {\n // Plain truthiness, not `!== false`. The sloppy gate an app writes is\n // `if (!isProduction) return false;`, which returns `undefined` on the path\n // that was meant to run — and between the two readings of that, the one\n // that skips a recurring tick is recoverable and the one that mails a\n // customer from a developer's laptop is not. The declared return type makes\n // that method a compile error anyway, so the type system catches it while\n // it is still being written and the runtime stays on the safe side.\n if (!(await job.shouldRun.call(job))) {\n return;\n }\n } catch (error) {\n // Fail closed, for the same reason. A gate that throws has told us nothing\n // about whether the job may run, and the framework already refuses to\n // schedule a job whose name or expression it cannot read rather than run\n // something half-declared. The throw is logged, so this is loud; the missed\n // tick comes back on the next one.\n console.error(\n `Error evaluating shouldRun for cron job ${job.name}:`,\n error,\n );\n return;\n }\n\n try {\n await job.onTick.call(job);\n } catch (error) {\n console.error(`Error executing cron job ${job.name}:`, error);\n }\n try {\n await job.callback.call(job);\n } catch (error) {\n console.error(`Error in cron job ${job.name}:`, error);\n }\n try {\n await job.onComplete.call(job);\n } catch (error) {\n console.error(`Error completing cron job ${job.name}:`, error);\n }\n}\n\nexport class Scheduler {\n static token = \"scheduler\";\n\n private handles: BunCronHandle[] = [];\n private resolved: Array<new () => CronJob>;\n\n constructor(config: Required<ScheduleConfig>) {\n this.resolved = config.jobs;\n }\n\n /**\n * The jobs this scheduler will run, or ran — declared in the config slice or\n * discovered under `app/cron`, whichever the slice asked for.\n *\n * #323 turned an application's schedule from an array it could import into a\n * directory it cannot, and an app that had a test walking that array —\n * asserting every report has an owner, that no two share an expression — was\n * about to lose it. This is where that test goes instead, and it is the\n * better question anyway: the config slice says what was asked for, this says\n * what the scheduler took.\n *\n * It lists what `start()` iterates, not what `Bun.cron` accepted. A job with\n * no name, no expression, or a name another job already claimed is logged and\n * skipped, and still appears here — a test walking this should see the\n * problem rather than have it tidied away.\n *\n * A copy, so that walk cannot edit the set the scheduler is running from.\n */\n get jobs(): ReadonlyArray<new () => CronJob> {\n return [...this.resolved];\n }\n\n /**\n * Replaces the job set, for the provider to hand over what it found under\n * `app/cron` before it calls `start()`.\n *\n * The scheduler is constructed in `register()`, where reading a directory and\n * importing what is in it is not allowed to happen — that phase is\n * synchronous and resolves nothing. So it is built from whatever the slice\n * declared and corrected in `boot()`, one line before it starts. Calling this\n * after `start()` changes what `jobs` reports and nothing else; the schedules\n * are already registered.\n */\n useJobs(jobs: Array<new () => CronJob>) {\n this.resolved = jobs;\n }\n\n /**\n * Schedules every configured job. Called from `ScheduleServiceProvider.boot()`\n * — never from the constructor — so a job body may resolve any service the\n * container holds by the time it first ticks. That ordering is what replaced\n * the old `kernel.waitForBoot()` handshake.\n */\n start(run: ScheduleRunner = (cb) => cb()) {\n if (this.resolved.length === 0) {\n return;\n }\n\n const registry = (globalThis.__gemiCronJobs ??= new Map());\n\n // Names claimed during *this* pass, which is a different question from what\n // `registry` holds. `registry` spans hot reloads and is supposed to already\n // contain the previous reload's handle under the same name; this starts\n // empty every time and is how a name claimed twice in one schedule is told\n // apart from the same job coming back after an edit.\n const claimed = new Map<string, string>();\n\n for (const Job of this.resolved) {\n const job = new Job();\n if (!job.name) {\n // Named by its class, because under discovery nobody wrote this job\n // down anywhere and `JSON.stringify(job)` on a nameless one prints\n // `{}`. The overwhelmingly common cause is the second sentence: a\n // shared base class sitting in the walked directory. `abstract` is\n // erased before this code runs, so there is nothing here that could\n // tell a base class from a job — only the message can.\n console.error(\n `Cron job must have a name — ${Job.name || \"an anonymous class\"} ` +\n `has none, so it is not scheduled. If this is a base class that ` +\n `other jobs extend, move it out of the discovered directory: ` +\n `\\`abstract\\` does not survive to runtime, so a class under ` +\n `app/cron is indistinguishable from a job.`,\n );\n continue;\n }\n if (!job.cron) {\n console.error(`Cron job must have an expression. Job: ${job.name}`);\n continue;\n }\n const taken = claimed.get(job.name);\n if (taken !== undefined) {\n // Refusing the second one, rather than letting it through to the\n // `registry.get(...).stop()` below — which is what used to happen, and\n // it stopped the *first* job's schedule while leaving both classes in\n // `jobs`. That is the failure #323 exists to remove wearing a disguise:\n // a report that silently stops arriving, and a test walking `jobs` that\n // sees two healthy entries and passes.\n console.error(\n `Two cron jobs claim the name \"${job.name}\" — ${taken} is ` +\n `scheduled and ${Job.name || \"an anonymous class\"} is not. A name ` +\n `is the scheduler's key, so only one job can hold it. Rename one.`,\n );\n continue;\n }\n claimed.set(job.name, Job.name || \"an anonymous class\");\n\n // Update in place: stop any schedule previously registered under this name\n // before re-registering, so a hot reload replaces rather than duplicates.\n registry.get(job.name)?.stop();\n\n // Inside `run`, gate included: a `shouldRun` that resolves a service to\n // decide is the ordinary case, and evaluating it out here would leave it\n // without the application context every other line of the tick has.\n const handle = Bun.cron(job.cron, () => run(() => runTick(job)));\n\n registry.set(job.name, handle);\n this.handles.push(handle);\n }\n }\n\n stop() {\n for (const handle of this.handles) {\n handle.stop();\n }\n this.handles = [];\n }\n}\n",
6
+ "import { ServiceProvider } from \"../support/ServiceProvider\";\nimport type { AuthConfig } from \"./config\";\nimport { AuthManager } from \"./AuthManager\";\n\nexport class AuthServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n AuthManager,\n () => new AuthManager(this.app.config.get<AuthConfig>(\"auth\", {})),\n );\n }\n}\n",
7
+ "import { kernelContext } from \"../../kernel/context\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { discoverCronJobs } from \"../discovery\";\nimport { scheduleConfigDefaults, type ScheduleConfig } from \"./config\";\nimport { Scheduler } from \"./Scheduler\";\n\nexport class ScheduleServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n Scheduler,\n () =>\n new Scheduler(\n withDefaults(\n scheduleConfigDefaults(),\n this.app.config.get<ScheduleConfig>(\"schedule\", {}),\n ),\n ),\n );\n }\n\n /**\n * Resolves the schedule, then starts it.\n *\n * Cron jobs are scheduled in phase two, not in `register()`: a job body is\n * free to resolve any service, and by the time `boot()` runs every provider\n * has registered. Each tick re-enters the application context so the job sees\n * the same container a request handler would.\n *\n * ### Why the raw slice and not the scheduler's config\n *\n * The decision here is whether the app said anything, and by the time the\n * scheduler holds a config it can no longer tell: `withDefaults` treats an\n * absent key and an `undefined` one alike and substitutes the default `[]`,\n * which is the same value an app writes when it means \"nothing scheduled, and\n * I mean it\". Reading the slice before defaults are applied is the only place\n * that difference still exists.\n *\n * So: `jobs` present, including `jobs: []`, is used verbatim and no directory\n * is read. Absent or `undefined` — which includes an app with no `schedule`\n * slice at all — the classes under `jobsDir` are, which is the case #323 is\n * about: a cron job that is written and never listed fires never, and nothing\n * downstream is waiting to notice.\n */\n async boot() {\n const scheduler = this.app.make(Scheduler);\n const slice = this.app.config.get<ScheduleConfig>(\"schedule\", {});\n\n if (slice.jobs === undefined) {\n const { jobsDir } = withDefaults(scheduleConfigDefaults(), slice);\n scheduler.useJobs(await discoverCronJobs(jobsDir));\n }\n\n // Resolved, listed, and not started.\n //\n // `gemi run` sets this on the process it spawns. Booting the application is\n // how a console command reaches the container, and starting the schedule is\n // a side effect of that which nobody asked for: a `gemi run backfill` that\n // takes four minutes would otherwise fire the application's whole cron\n // schedule in a process no operator is watching, and `Bun.cron` handles hold\n // the loop open besides.\n //\n // Deliberately above `start` and below `useJobs`, so `app(Scheduler).jobs`\n // still answers honestly — a command that wants to fire a tick by hand can,\n // and a test asking what this application schedules gets the same answer\n // either way.\n //\n // An environment variable rather than a config field, because this is a\n // property of *this process* and not of the application: the same variable\n // is how a deploy runs one cron dyno beside several web ones, and a config\n // slice would have to know which command started it.\n if (process.env.GEMI_NO_SCHEDULE === \"1\") return;\n\n const app = this.app;\n scheduler.start((cb) => kernelContext.run(app, cb));\n }\n}\n",
8
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport type { MailConfig } from \"./config\";\nimport { MailManager } from \"./MailManager\";\n\nexport class MailServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n MailManager,\n () => new MailManager(this.app.config.get<MailConfig>(\"mail\", {})),\n );\n }\n}\n",
9
+ "import { app } from \"../../foundation/app\";\nimport { Job } from \"../queue/Job\";\nimport { EventManager } from \"./EventManager\";\nimport type { Listener, ListenerClass } from \"./Listener\";\n\n/**\n * The adapter that lets `queued = true` be one line: a `Job` subclass, built at\n * registration, that runs exactly one listener.\n *\n * Retries, `maxAttempts`, dead-lettering, `concurrency` and worker-thread\n * execution are four features the queue already has, already documents for\n * applications, and is already tested on. A second queue for listeners would be\n * four features that are almost the same as those, differing in ways nobody\n * decided. So a queued listener is not queued by anything written here — it is\n * a job, and everything after `push` is the queue's.\n */\n\n/**\n * The name a listener's synthetic job is registered under.\n *\n * Prefixed, and visibly so. The synthetic jobs land in\n * `QueueManager.registeredJobs` alongside the app's own, because that getter is\n * documented as reporting what the manager was handed and a queued listener\n * genuinely is something the queue will run — hiding them would make a queue\n * introspection tool lie about what is about to execute. The prefix is what\n * keeps an author from reading `SendWelcomeEmail` there and looking for a job\n * file they never wrote.\n */\nexport function listenerJobName(listenerName: string): string {\n return `listener:${listenerName}`;\n}\n\n/**\n * Builds the `Job` subclass that runs one queued listener.\n *\n * `instance` is the listener the caller already constructed to read `queued`\n * off; the three fields that decide where the work runs are read from that one\n * instance rather than from a fresh one per attempt, so a listener's\n * constructor runs once at boot instead of once per retry.\n *\n * What crosses the queue is `[eventName, constructorArguments]` as JSON — a\n * name and the arguments, never the event instance and never the classes. That\n * is invariant 1 at its second boundary: the class objects on the pushing side\n * and the running side can come from two different module graphs (a minified\n * bundle and a source-side discovery walk), so a name declared as a string\n * literal is the only thing both ends agree on. `EventManager.rehydrate` turns\n * it back into an event.\n */\nexport function jobForListener(\n listener: ListenerClass,\n instance: Listener,\n): new () => Job {\n refuseImplicitName(listener);\n\n const attempts = instance.maxAttempts;\n const inWorker = instance.worker;\n const boundTo = listener.event.name;\n\n const job = class extends Job {\n maxAttempts = attempts;\n worker = inWorker;\n\n async run(...payload: unknown[]) {\n const [eventName, args] = readPayload(payload);\n const event = app(EventManager).rehydrate(eventName, args);\n await new listener().handle(event);\n }\n\n // The queue's failure path is silent unless a job writes to it: `onFail`\n // and `onDeadletter` on `Job` are empty bodies, and `QueueManager.run`\n // routes every rejection into exactly those two. Without these overrides a\n // queued listener that throws produces no output anywhere — `dispatch`\n // returned long ago, the sync path's \"the listener X threw while handling\n // Y\" line is on a branch this listener never takes, and the last thing that\n // happens is the entry leaving the queue. A welcome email that stopped\n // being sent in production would look exactly like one that was never\n // dispatched.\n //\n // That is also what makes `rehydrate`'s throw the informative failure it is\n // documented as: a payload naming an event this process does not know is\n // the shape a `worker = true` listener hits when its thread booted a\n // different build of the application, and it is unreachable from the\n // dispatcher's stack.\n //\n // Both hooks, not one. `onFail` carries the error and fires per attempt, so\n // a listener failing differently on each is visible; `onDeadletter` fires\n // once and reports the fact no attempt is left, which is a different thing\n // to know and the only line that means the work is gone. The final attempt\n // logs both, deliberately.\n //\n // The event is named from `static event` rather than from the payload:\n // reading the payload here means parsing it, and a throw out of either hook\n // would escape through `QueueManager.run`'s `catch` into a `run()` nobody\n // awaits.\n onFail(error: Error) {\n console.error(\n `The listener ${listener.name} threw while handling ${boundTo} off ` +\n `the queue. The queue will retry it up to ${attempts} times in ` +\n `total; nothing the dispatcher did is waiting on it.`,\n error,\n );\n }\n\n onDeadletter(error: Error) {\n console.error(\n `The listener ${listener.name} failed every one of its ${attempts} ` +\n `attempts at ${boundTo} and has been dead-lettered, so this side ` +\n `effect did not happen and will not be retried.`,\n error,\n );\n }\n };\n\n // The `value` is load-bearing: the queue keys its registry off `job.name`,\n // so without it the entry would be named after whatever binding this class\n // expression picked up. `writable: true` is the other half, and nothing\n // reads it today — it is here so the descriptor matches the one a declared\n // `static name = \"...\"` field produces. Every \"was this name declared?\"\n // check in the framework is a descriptor read rather than a value read\n // (`discovery.ts`, and `refuseImplicitName` below), because in development\n // the declared and the implicit spelling read the same string; and\n // redefining `name` without the flag leaves the class's own non-writable\n // descriptor in place. So a check later pointed at a *registered* job rather\n // than a discovered one — the queue's registry is the obvious place to move\n // one — would report every synthetic entry as a job the author never wrote,\n // under a fix they cannot apply. Cheap to keep, wrong to drop.\n Object.defineProperty(job, \"name\", {\n value: listenerJobName(listener.name),\n writable: true,\n });\n\n return job;\n}\n\n/**\n * Refuses to queue a listener whose name is the implicit class binding.\n *\n * A sync listener's name is only ever read inside one module graph, so\n * discovery warns about this and moves on. A queued one puts the name on the\n * wire: the push side looks the job up by `listener:<name>` in its registry and\n * the running side looks it up in *its* registry, and those two can be\n * different builds of the same application — the main process discovering\n * `app/listeners` from source while a `worker = true` listener runs in a thread\n * that imported `dist/server/bootstrap.mjs`, where minification renamed the\n * class. The names then disagree, `dispatchJob` resolves nothing, the worker\n * reports success, and the side effect silently stops happening in production.\n *\n * A throw rather than a warning because the failure is invisible from every\n * side once it happens, and because the fix is one line the author can read in\n * the message.\n */\nfunction refuseImplicitName(listener: ListenerClass): void {\n if (Object.getOwnPropertyDescriptor(listener, \"name\")?.writable) return;\n\n throw new Error(\n `The listener ${listener.name} sets \\`queued = true\\` but does not ` +\n `declare \\`static name\\`, so it would be registered with the queue ` +\n `under its class name — which a production build renames while the ` +\n `payload that names it does not. Add: static name = \"${listener.name}\";`,\n );\n}\n\n/**\n * The payload, whichever of the two shapes the queue handed it over in.\n *\n * The queue calls `run` two different ways and this is the only place that has\n * to know. In-process, `QueueManager.run` spreads the parsed arguments:\n * `run(\"UserRegistered\", [7, \"ada@example.com\"])`. Through a worker thread the\n * far side is `QueueManager.dispatchJob`, which passes the parsed array whole:\n * `run([\"UserRegistered\", [7, \"ada@example.com\"]])`. Reading only the first\n * shape would make `worker = true` a listener that receives an event named\n * `undefined` — a throw out of `rehydrate`, in a worker thread, retried to\n * dead-letter.\n *\n * The two are told apart by what is in the first slot rather than by counting\n * arguments, because the payload's own first element is always the event name\n * and a name is always a string.\n */\nfunction readPayload(payload: unknown[]): [string, unknown[]] {\n return (typeof payload[0] === \"string\" ? payload : payload[0]) as [\n string,\n unknown[],\n ];\n}\n",
10
+ "import { app } from \"../../foundation/app\";\nimport { deferUntilCommit } from \"../../orm/context\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport type { Job } from \"../queue/Job\";\nimport { QueueManager } from \"../queue/QueueManager\";\nimport { eventConfigDefaults, type EventConfig } from \"./config\";\nimport type { Event, EventClass } from \"./Event\";\nimport { jobForListener } from \"./listenerJob\";\nimport type { ListenerClass } from \"./Listener\";\n\n/**\n * One listener, and where it runs.\n *\n * `queued` is an instance field, so answering \"does this one go on the queue?\"\n * means constructing the listener — done once here, at registration, rather\n * than once per dispatch. The synthetic job is built at the same moment for the\n * same reason: `EventServiceProvider.boot()` has to hand it to the queue before\n * the first dispatch, and a job built per dispatch would be a different class\n * object each time under the same registry key.\n */\ntype Registration = {\n listener: ListenerClass;\n /** The job a queued listener is pushed as, or `null` when it runs inline. */\n job: (new () => Job) | null;\n};\n\n/**\n * The registry a dispatch fans out through: event name -> the listeners bound\n * to it.\n *\n * Shaped after `QueueManager` deliberately — constructed in `register()` from\n * whatever the config slice declared, handed the discovered set in `boot()`,\n * and reporting through a `registered*` getter what it was *given* rather than\n * what it accepted, so a test can see a collision instead of having it tidied\n * away.\n *\n * Three things are not `QueueManager`'s, and each is a decision rather than a\n * detail:\n *\n * **Many listeners per key.** Two listeners for one event is the normal case\n * here, where two jobs for one name is the pathological one. So the map holds\n * arrays and `useListeners` appends. The collision it does refuse is two\n * *listener classes* claiming one `static name`.\n *\n * **Registration order is the walk's order, and means nothing.** It is stable —\n * `discoverClasses` sorts per directory and the module namespace sorts by name\n * — so it is reproducible, but no listener may depend on running before\n * another, because nothing about a filesystem layout was chosen to express\n * that. What makes it safe to say is the rule below: nothing a listener does\n * can stop the next one.\n *\n * **A dispatch nobody handles warns.** That is the entire early-warning system\n * for the subsystem, and it is why it is not optional; see `dispatchAndWait`.\n *\n * A `queued` listener is not run here at all. It is registered with the\n * `QueueManager` as a synthetic job and pushed to it on dispatch, so retries,\n * `maxAttempts`, dead-lettering and worker threads are the queue's rather than\n * a second implementation of the queue's — and nothing the request had (the\n * current actor, the ambient transaction) is still promised by the time it\n * runs. See `Listener.queued`.\n *\n * **A dispatch does not always fan out at the dispatch.** An event declaring\n * `static afterCommit` has the whole of it — queued listeners included — held\n * on the ORM's transaction scope and drained when that transaction commits, or\n * dropped when it rolls back. That is the only thing in this file that reads\n * ambient state, and `deferToCommit` is where it happens.\n */\nexport class EventManager {\n static token = \"events\";\n\n /** Event name -> every listener bound to it, in registration order. */\n private listeners: Record<string, Registration[]> = {};\n\n /**\n * Event name -> the class to rebuild it from, for a listener coming back off\n * the queue.\n *\n * Read from each listener's `static event` at registration, which is the one\n * place in the subsystem an event class is dereferenced. An event nobody\n * listens for is never in here, and that is exactly right: nothing can have\n * been queued for it.\n */\n private events: Record<string, EventClass> = {};\n\n /**\n * Event names already warned about. Per-manager, and the manager is per\n * application, so a test that builds a fresh kernel gets a fresh set.\n */\n private warnedFor = new Set<string>();\n\n /**\n * Event names already warned about for the `dispatchAndWait` + `afterCommit`\n * pairing. A second set rather than a second entry in the one above: the two\n * warnings are about different mistakes, and sharing the set would mean a\n * dispatch that legitimately has no listeners silences the one that says a\n * caller is awaiting nothing.\n */\n private warnedAboutWaiting = new Set<string>();\n\n readonly config: Required<EventConfig>;\n\n constructor(config: EventConfig = {}) {\n this.config = withDefaults(eventConfigDefaults(), config);\n this.useListeners(this.config.listeners);\n }\n\n /**\n * Replaces the registered set, for the provider to hand over what it found\n * under `app/listeners`.\n *\n * Two phases, for the reason `QueueManager.useJobs` documents: the manager is\n * constructed in `register()`, which is synchronous and must resolve nothing,\n * while reading a directory and importing what is in it is neither. So the\n * manager is built from whatever the config slice declared — nothing, when\n * the app left `listeners` out — and the discovered set arrives in `boot()`.\n *\n * The consequence worth knowing: anything that constructs an application and\n * skips phase two dispatches into an empty registry, and an empty registry is\n * a legal steady state rather than an error. The development-only warning\n * below is the only thing that says so.\n *\n * Every listener is **constructed once here**, to read the fields that decide\n * where it runs — `queued`, and through it `maxAttempts` and `worker`. A\n * listener's constructor therefore runs at boot as well as on every dispatch,\n * so it wants to assign fields and nothing else. A queued one also has its\n * synthetic job built here; `EventServiceProvider` hands those to the queue\n * once boot reaches it, so calling this again *after* boot would leave the\n * queue holding jobs for listeners this registry no longer has.\n */\n useListeners(listeners: ListenerClass[]) {\n this.config.listeners = listeners;\n\n this.listeners = {};\n this.events = {};\n const claimed = new Set<string>();\n\n for (const listener of listeners) {\n // Declared as required on the base class and still checked here: every\n // subclass inherits the declaration whether or not it assigns to it, so\n // `typeof SomeListener` satisfies `ListenerClass` either way and the\n // compiler cannot see the omission. Refused rather than registered under\n // some fallback, because there is no fallback — a listener with no event\n // is a file the author wrote that nothing will ever call.\n if (!listener.event) {\n console.error(\n `Listener ${listener.name} does not declare \\`static event\\`, so ` +\n `there is no event name to register it under and its handle will ` +\n `never run. Add: static event = SomeEvent;`,\n );\n continue;\n }\n\n // Two classes with one name, refused here and nowhere else — which is\n // what keeps the queue from being handed two jobs called\n // `listener:NotifyAdmins` and having to decide between them one layer\n // down, where the loser is a side effect that reports success. A\n // directory walk is what makes the clash ordinary, since nothing forces\n // the import alias a hand-written list would have demanded.\n if (claimed.has(listener.name)) {\n console.error(\n `Two event listeners are named \"${listener.name}\" — the first is ` +\n `registered and this one is not. A listener's name identifies it ` +\n `across the framework, so only one class can hold it. Rename one.`,\n );\n continue;\n }\n claimed.add(listener.name);\n\n // The one place the event class is dereferenced, and deliberately the\n // only one: this runs in the module graph that declared the class, so the\n // name it yields is the source-side one that discovery and a minified\n // dispatcher both agree on. Nothing downstream keeps the class object —\n // except `this.events`, which keeps it under that same string so a\n // listener coming back off the queue has something to rebuild from. First\n // claim wins there too: a name is what identifies an event to everything\n // downstream, so two classes declaring one are one event already.\n const name = listener.event.name;\n const instance = new listener();\n\n this.events[name] ??= listener.event;\n (this.listeners[name] ??= []).push({\n listener,\n job: instance.queued ? jobForListener(listener, instance) : null,\n });\n }\n }\n\n /**\n * The synthetic jobs the queue has to be told about — one per queued\n * listener, named `listener:<name>`.\n *\n * `EventServiceProvider.boot()` is the only caller. It reads this rather than\n * having the manager reach for the `QueueManager` itself, because\n * registration happens in `register()`, where resolving another service is\n * exactly what a provider must not do. A copy, so the caller cannot edit what\n * a dispatch pushes.\n */\n get queuedListenerJobs(): ReadonlyArray<new () => Job> {\n return Object.values(this.listeners)\n .flat()\n .flatMap(({ job }) => (job ? [job] : []));\n }\n\n /**\n * What the manager was handed, discovered or declared.\n *\n * \"Is this listener registered?\" is a question with a silent wrong answer —\n * an unregistered listener is a side effect that does not happen, and nothing\n * is waiting on it to notice. This is where a test asks it out loud.\n *\n * It reports what came in, not what the registry accepted, so a name claimed\n * twice appears twice here — deliberately, the same way `QueueManager` and\n * `Scheduler` do. A copy, so a walk over it cannot edit what dispatch reads.\n */\n get registeredListeners(): ReadonlyArray<ListenerClass> {\n return [...this.config.listeners];\n }\n\n /**\n * Fires the event and returns. The sync listeners run to completion after the\n * caller has moved on.\n *\n * Nothing is awaited and nothing can reject: `runListeners` catches every\n * listener's failure itself, so the floating promise here has no rejection to\n * float.\n *\n * `args` is the event's constructor arguments; see `dispatchAndWait`.\n *\n * On an `afterCommit` event inside a transaction, \"after the caller has moved\n * on\" becomes \"after that transaction commits\" — see `deferToCommit`.\n */\n dispatch(event: Event, args?: readonly unknown[]): void {\n if (this.deferToCommit(event, args, false)) return;\n void this.runListeners(event, args);\n }\n\n /**\n * Fires the event and resolves once every **sync** listener has settled.\n *\n * On an `afterCommit` event inside an open transaction it resolves\n * **immediately, having run nothing** — there is no listener to wait for yet,\n * and the transaction it would be waiting on is the caller's own. That is the\n * sharp edge `Event.afterCommit` documents and the reason the flag ships\n * opt-in; it warns once per event name in development, because nothing else\n * about the call site can show it.\n */\n async dispatchAndWait(\n event: Event,\n args?: readonly unknown[],\n ): Promise<void> {\n if (this.deferToCommit(event, args, true)) return;\n return this.runListeners(event, args);\n }\n\n /**\n * Queues the fan-out on the open transaction when the event asked for that,\n * and reports whether it did — `false` means the caller runs it now.\n *\n * Three cases, and only the third defers: an event without\n * `static afterCommit` behaves exactly as it did before this existed; one\n * with it, dispatched outside a transaction, has nothing to wait for; one\n * with it, inside a transaction, runs when that transaction commits and not\n * at all if it rolls back.\n *\n * `currentTransaction()` is not consulted directly, and the difference\n * matters: `deferUntilCommit` also answers `false` for a scope carrying a\n * handle that `withTransaction` did not open, which has no commit hook and\n * therefore no list that will ever be drained. Reading the handle alone would\n * queue the dispatch onto nothing and lose it silently.\n *\n * The whole fan-out is deferred, sync listeners and queued ones alike. A\n * queued listener is *pushed* at commit rather than at dispatch, which is the\n * only correct reading of `afterCommit`: the queue drains in-process and\n * often synchronously from `push`, so pushing early is running early.\n */\n private deferToCommit(\n event: Event,\n args: readonly unknown[] | undefined,\n awaited: boolean,\n ): boolean {\n // Read off the constructor, the same way the registry key is, and typed\n // structurally for the same reason: `Event` arrives here as a type-only\n // import, and the class object an application dispatches may have come from\n // a different module graph than the one this file was compiled against.\n const { name, afterCommit } = event.constructor as {\n name: string;\n afterCommit?: boolean;\n };\n if (!afterCommit) return false;\n\n const deferred = deferUntilCommit(() => this.runListeners(event, args));\n if (deferred && awaited) this.warnNothingIsWaitedFor(name);\n return deferred;\n }\n\n /**\n * Runs every **sync** listener bound to this event, in registration order,\n * and resolves when the last of them has settled. Every queued one is handed\n * to the `QueueManager` on the way past and is not waited for.\n *\n * The dispatch itself is `dispatch` and `dispatchAndWait` above; this is what\n * they run, and what an `afterCommit` event's transaction runs later. Split\n * out so that \"when does the fan-out happen\" is decided in exactly one place\n * rather than in each entry point.\n *\n * ### Sync and queued in one pass\n *\n * A queued listener is pushed at the point in the order it occupies, so its\n * *dispatch* is ordered with the rest and its *execution* is not: the queue\n * decides when. What that costs is worth knowing — `dispatchAndWait`\n * resolving says every sync listener has finished and says nothing at all\n * about a queued one, which may not have started or may already have failed\n * twice. Whether a listener is queued is therefore a decision about what the\n * caller can rely on having happened, not only about latency.\n *\n * @param args the arguments the event's constructor was called with, which\n * `Event.dispatch` forwards. Only a queued listener needs them: the event\n * instance itself never crosses the queue, and what is rebuilt on the other\n * side is `new EventClass(...args)`. Dispatching a hand-built instance\n * straight at the manager therefore cannot queue, and says so on stderr\n * rather than pushing a payload that would rehydrate into an event with\n * `undefined` fields.\n *\n * ### One at a time, deliberately\n *\n * Each listener is awaited before the next one starts, rather than started\n * together under a `Promise.allSettled`. Concurrency would make \"registration\n * order\" a claim about start order only, and the order it is a claim about is\n * the one `registeredListeners` reports and the discovery tests assert on.\n *\n * What it costs is worth knowing, because it is the one way listener\n * independence is not total: a listener that *hangs* — an un-timed-out\n * `fetch` to a host that never answers — delays every listener after it for\n * as long as it hangs, and under `dispatch` the caller has already moved on,\n * so an audit row a later listener writes simply is not there yet. A throw is\n * not this: that is caught below and the next listener runs immediately. A\n * listener that can block indefinitely is a listener that wants its own\n * timeout, or a `Job`.\n *\n * ### Errors\n *\n * Each listener runs inside its own `try`. A throw is logged with the event\n * name, the listener name, and the error, and the loop continues — listeners\n * are independent side effects, and letting listener 2 cancel 3 through 5\n * would make a filesystem walk's order load-bearing. Neither this nor\n * `dispatch` ever rejects, for the same reason from the caller's side: a\n * rejection would make listener 1's failure the dispatcher's problem while\n * listener 5's silently is not.\n *\n * ### Why zero listeners is worth a line on stderr\n *\n * A registry keyed by the wrong string, a `static name` that does not survive\n * a production build, a typo, and a listener directory that was never walked\n * all produce the same single symptom: nobody handled it. Zero listeners is\n * also a perfectly legal steady state, so the warning is development-only and\n * fires once per event name — a dispatch in a loop would otherwise bury the\n * terminal.\n */\n protected async runListeners(\n event: Event,\n args?: readonly unknown[],\n ): Promise<void> {\n const name = (event.constructor as { name: string }).name;\n const handlers = this.listeners[name];\n\n if (!handlers?.length) {\n this.warnNothingIsListening(name);\n return;\n }\n\n for (const { listener: Listener, job } of handlers) {\n if (job) {\n this.enqueue(job, Listener, name, args);\n continue;\n }\n\n try {\n await new Listener().handle(event);\n } catch (error) {\n console.error(\n `The listener ${Listener.name} threw while handling ${name}. The ` +\n `listeners after it still ran — a listener's failure is its own.`,\n error,\n );\n }\n }\n }\n\n /**\n * Rebuilds an event from what crossed the queue.\n *\n * The queue carries a name and an argument array, because that is all JSON\n * can carry: **the constructor arguments are what is serialized, not the\n * instance** — the same bargain `Job.dispatch` makes. So an event whose\n * constructor does work beyond assigning fields does that work a second time\n * here, in the worker, with none of the dispatching request around it.\n *\n * A name that resolves to nothing throws, and is the one place in this file\n * that does. The payload is already off the queue by the time this runs and\n * the listener is one line away from being handed `undefined`, so the\n * alternative is a `handle` reading `event.email` off nothing, several frames\n * further on, with the name that would have explained it no longer in scope.\n * A throw here is caught by `QueueManager.run` and takes the queue's ordinary\n * retry-then-dead-letter path.\n */\n rehydrate(eventName: string, args: readonly unknown[] = []): Event {\n const EventClass = this.events[eventName];\n\n if (!EventClass) {\n throw new Error(\n `Cannot rebuild the event \"${eventName}\" that came off the queue: no ` +\n `registered listener binds to an event of that name, so there is no ` +\n `class to construct. A queued listener runs in an application that ` +\n `discovered its own listeners — check that this process sees the ` +\n `same app/listeners as the one that dispatched, and that the event ` +\n `declares \\`static name = \"${eventName}\"\\`.`,\n );\n }\n\n return new EventClass(...args);\n }\n\n /**\n * Hands one queued listener to the queue, as `[eventName, args]`.\n *\n * Nothing is awaited: `push` returns as soon as the entry is on the queue,\n * which is the whole of what `queued = true` buys. The event instance the\n * sync listeners share does not go with it — only the name and the arguments\n * do, so nothing that was resolved from the request's context can be smuggled\n * across into an application that does not have it.\n *\n * Failing to queue is caught for the same reason a listener's throw is: it is\n * one listener's problem, and the listeners after it in the walk did not do\n * anything to deserve it. Two things reach that catch — an argument JSON\n * cannot serialise, and an application with no queue bound — and both would\n * otherwise reject `dispatchAndWait`, which is documented never to.\n */\n private enqueue(\n job: new () => Job,\n listener: ListenerClass,\n eventName: string,\n args?: readonly unknown[],\n ) {\n if (args === undefined) {\n console.error(\n `The listener ${listener.name} is queued, but ${eventName} reached ` +\n `the dispatcher without its constructor arguments, so there is ` +\n `nothing for the queue to rebuild it from and the listener was ` +\n `skipped. Dispatch through ${eventName}.dispatch(...) or ` +\n `${eventName}.dispatchAndWait(...), which carry them.`,\n );\n return;\n }\n\n try {\n app(QueueManager).push(job, JSON.stringify([eventName, args]));\n } catch (error) {\n console.error(\n `The listener ${listener.name} could not be queued for ${eventName}, ` +\n `so it did not run and will not be retried. The listeners after it ` +\n `still ran.`,\n error,\n );\n }\n }\n\n /**\n * The one warning for the pairing that reads as doing something and does not.\n *\n * `await UserRegistered.dispatchAndWait(...)` inside a transaction, on an\n * event that defers to commit, resolves with nothing having run — the\n * listeners are queued on a transaction the caller has not finished. There is\n * no other symptom: the promise resolves, the listeners do run later, and the\n * only thing that is wrong is that the caller's `await` bought it nothing.\n * Code that reads what a listener wrote on the next line finds it missing,\n * and nothing connects the two.\n *\n * Development only and once per event name, on the same terms as the\n * zero-listener warning: both are legal steady states that are usually a\n * mistake, and a dispatch in a loop must not bury the terminal.\n */\n private warnNothingIsWaitedFor(name: string) {\n if (process.env.NODE_ENV === \"production\") return;\n if (this.warnedAboutWaiting.has(name)) return;\n this.warnedAboutWaiting.add(name);\n\n console.warn(\n `[gemi] ${name}.dispatchAndWait() was called inside a transaction and ` +\n `${name} declares \\`static afterCommit = true\\`, so it resolved ` +\n `immediately with no listener having run — they run when the ` +\n `transaction commits. Await the transaction instead, or drop ` +\n `afterCommit if the caller needs the side effects first. Development ` +\n `only.`,\n );\n }\n\n private warnNothingIsListening(name: string) {\n if (process.env.NODE_ENV === \"production\") return;\n if (this.warnedFor.has(name)) return;\n this.warnedFor.add(name);\n\n console.warn(\n `[gemi] ${name} was dispatched and nothing is listening for it. A ` +\n `listener registers under the name its event declares, so check that ` +\n `app/listeners holds a Listener with \\`static event = ${name}\\` and ` +\n `that ${name} declares \\`static name = \"${name}\"\\`. Development only.`,\n );\n }\n}\n",
11
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { discoverListeners } from \"../discovery\";\nimport { QueueManager } from \"../queue/QueueManager\";\nimport { eventConfigDefaults, type EventConfig } from \"./config\";\nimport { EventManager } from \"./EventManager\";\n\nexport class EventServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n EventManager,\n () => new EventManager(this.app.config.get<EventConfig>(\"events\", {})),\n );\n }\n\n /**\n * Fills in the listener registry when the app did not declare one.\n *\n * ### Why the raw slice and not the manager's config\n *\n * The decision here is whether the app said anything, and by the time the\n * manager holds a config it can no longer tell: `withDefaults` treats an\n * absent key and an `undefined` one alike and substitutes the default `[]`,\n * which is the same value an app writes when it means \"no listeners, and I\n * mean it\". Reading the slice before defaults are applied is the only place\n * the difference still exists.\n *\n * So: `listeners` present, including `listeners: []`, is used verbatim and no\n * directory is read. Absent or `undefined`, the classes under `listenersDir`\n * are.\n *\n * ### Why phase two\n *\n * Discovery imports every file it walks, which is asynchronous, and\n * `register()` is not. It also has to finish before the first dispatch rather\n * than before the first request — a dispatch against an empty registry is not\n * an error, it is a side effect that quietly does not happen — so the\n * registry has to be complete by the end of boot.\n *\n * ### Why the queue is handed the listener jobs from here\n *\n * A queued listener is registered with the `QueueManager` as a synthetic job,\n * and that registration cannot happen in `register()`: resolving another\n * service is the one thing a `register()` must not do, and the jobs are not\n * known until discovery has run anyway. It also cannot happen before\n * `QueueServiceProvider.boot()` fills the queue's registry, which is why this\n * provider sits after it in `frameworkProviders` — `useJobs` replaces that\n * registry wholesale, so the queue has to be finished with it before\n * `registerJob` starts adding to it.\n *\n * The declared-listeners path falls through to it rather than returning\n * early: an app that lists its listeners in `app/config/events.ts` still has\n * queued ones, and skipping the queue for them would make `queued = true` a\n * field that silently does nothing depending on how the app registers.\n */\n async boot() {\n const manager = this.app.make(EventManager);\n const slice = this.app.config.get<EventConfig>(\"events\", {});\n\n if (slice.listeners === undefined) {\n const { listenersDir } = withDefaults(eventConfigDefaults(), slice);\n manager.useListeners(await discoverListeners(listenersDir));\n }\n\n // Nothing queued, nothing to resolve. An application assembled out of this\n // provider alone — a test, a script — has no `QueueManager` bound, and\n // asking for one it has no use for would turn that into a boot failure.\n const jobs = manager.queuedListenerJobs;\n if (jobs.length === 0) return;\n\n const queue = this.app.make(QueueManager);\n for (const job of jobs) {\n queue.registerJob(job);\n }\n }\n}\n",
12
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport type { FilesystemConfig } from \"./config\";\nimport { FilesystemManager } from \"./FilesystemManager\";\n\nexport class FilesystemServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n FilesystemManager,\n () =>\n new FilesystemManager(\n this.app.config.get<FilesystemConfig>(\"filesystem\", {}),\n ),\n );\n }\n}\n",
13
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport type { ImageConfig } from \"./config\";\nimport { ImageManager } from \"./ImageManager\";\n\nexport class ImageServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n ImageManager,\n () => new ImageManager(this.app.config.get<ImageConfig>(\"image\", {})),\n );\n }\n}\n",
14
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { KernelId } from \"./KernelId\";\n\n// Config-less by nature: the id is generated per process, never declared.\nexport class KernelIdServiceProvider extends ServiceProvider {\n register() {\n this.app.instance(KernelId, new KernelId());\n }\n}\n",
15
+ "import type { LogEntry } from \"./types\";\n\n// Config key: `log`. Derived from `LoggingServiceProvider`.\nexport interface LogConfig {\n maxFileSize?: number;\n\n onLogFileClosed?: (file: File) => void | Promise<void>;\n onLogCreated?: (logEntry: LogEntry) => void | Promise<void>;\n}\n\nexport function defineLogConfig(config: LogConfig): LogConfig {\n return config;\n}\n\nexport function logConfigDefaults(): Required<LogConfig> {\n return {\n maxFileSize: 1024 * 1024 * 10, // 10MB\n onLogFileClosed: () => {},\n onLogCreated: () => {},\n };\n}\n",
16
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { LogManager } from \"./LogManager\";\nimport { logConfigDefaults, type LogConfig } from \"./config\";\n\nexport class LogServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n LogManager,\n () =>\n new LogManager(\n withDefaults(\n logConfigDefaults(),\n this.app.config.get<LogConfig>(\"log\", {}),\n ),\n ),\n );\n }\n\n /**\n * The log directory is created once at kernel boot rather than on the first\n * `Log.info()`, which is what the old eagerly-constructed container did.\n * Resolving here is deliberate: it is the one service whose readiness is a\n * boot-time side effect, and paying for it lazily mid-request would add file\n * IO to whichever handler happened to log first.\n */\n async boot() {\n await this.app.make(LogManager).boot();\n }\n}\n",
17
+ "import {\n middlewareConfigDefaults,\n type MiddlewareConfig,\n} from \"../../http/middleware-config\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { MiddlewareRegistry } from \"./MiddlewareRegistry\";\n\nexport class MiddlewareServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n MiddlewareRegistry,\n () =>\n new MiddlewareRegistry(\n withDefaults(\n middlewareConfigDefaults(),\n this.app.config.get<MiddlewareConfig>(\"middleware\", {}),\n ),\n ),\n );\n }\n}\n",
18
+ "import type { BroadcastingChannel } from \"../../broadcasting/BroadcastingChannel\";\n\n// Config key: `broadcast`. Derived from `BroadcastingServiceProvider`.\nexport interface BroadcastConfig {\n channels?: Record<string, new () => BroadcastingChannel>;\n}\n\nexport function defineBroadcastConfig(\n config: BroadcastConfig,\n): BroadcastConfig {\n return config;\n}\n\nexport function broadcastConfigDefaults(): Required<BroadcastConfig> {\n return {\n channels: {},\n };\n}\n",
19
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { BroadcastManager } from \"./BroadcastManager\";\nimport { broadcastConfigDefaults, type BroadcastConfig } from \"./config\";\n\nexport class BroadcastServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n BroadcastManager,\n () =>\n new BroadcastManager(\n withDefaults(\n broadcastConfigDefaults(),\n this.app.config.get<BroadcastConfig>(\"broadcast\", {}),\n ),\n ),\n );\n }\n}\n",
20
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { discoverJobs } from \"../discovery\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { queueConfigDefaults, type QueueConfig } from \"./config\";\nimport { QueueManager } from \"./QueueManager\";\n\nexport class QueueServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n QueueManager,\n () => new QueueManager(this.app.config.get<QueueConfig>(\"queue\", {})),\n );\n }\n\n /**\n * Fills in the job registry when the app did not declare one.\n *\n * ### Why the raw slice and not the manager's config\n *\n * The decision here is whether the app said anything, and by the time the\n * manager holds a config it can no longer tell: `withDefaults` treats an\n * absent key and an `undefined` one alike and substitutes the default `[]`,\n * which is the same value an app writes when it means \"no jobs, and I mean\n * it\". Reading the slice before defaults are applied is the only place the\n * difference still exists.\n *\n * So: `jobs` present, including `jobs: []`, is used verbatim and no directory\n * is read. Absent or `undefined`, the classes under `jobsDir` are.\n *\n * ### Why phase two\n *\n * Discovery imports every file it walks, which is asynchronous, and\n * `register()` is not. It also has to happen before the first dispatch rather\n * than before the first tick — there is no equivalent of the scheduler's\n * `start()` to hang it off, so the registry has to be complete by the end of\n * boot.\n */\n async boot() {\n const slice = this.app.config.get<QueueConfig>(\"queue\", {});\n if (slice.jobs !== undefined) return;\n\n const { jobsDir } = withDefaults(queueConfigDefaults(), slice);\n this.app.make(QueueManager).useJobs(await discoverJobs(jobsDir));\n }\n}\n",
21
+ "import type { ConsumeParams, RateLimitResult } from \"../types\";\n\nexport abstract class RateLimiterDriver {\n /**\n * Records one request against `params.key` and reports whether it fits.\n *\n * Implementations must decide *and* record atomically — two concurrent calls\n * for the same key may never both be told they were the last one that fit.\n *\n * May be sync or async: the in-memory driver answers immediately, a network\n * backed driver returns a promise. Callers always `await` the result.\n */\n abstract consume(\n params: ConsumeParams,\n ): Promise<RateLimitResult> | RateLimitResult;\n}\n",
22
+ "import type { RateLimitResult } from \"./types\";\n\n/**\n * The sliding-window-counter algorithm, shared by every driver.\n *\n * A fixed window is cheap but lets a client spend its whole budget at the end\n * of one window and again at the start of the next — twice the limit across a\n * window's worth of time. A true sliding log fixes that but has to keep a\n * timestamp per request.\n *\n * The counter variant keeps two integers per key (this window and the one\n * before it) and estimates usage by weighting the previous window by how much\n * of it still overlaps the trailing window:\n *\n * usage = previous * (window - elapsed) / window + current\n *\n * That is a ~0.003% error on real traffic and costs two integers per key, so\n * it is what the in-memory and Redis drivers both implement.\n */\n\n/** Epoch ms of the start of the window `now` falls into. */\nexport function windowStartFor(now: number, window: number) {\n return Math.floor(now / window) * window;\n}\n\n/** Weight of the previous window's count, from `1` down to `0`. */\nexport function previousWeight(elapsed: number, window: number) {\n if (window <= 0) return 0;\n return Math.min(1, Math.max(0, (window - elapsed) / window));\n}\n\n/** Estimated usage of the trailing `window` ending at `now`. */\nexport function estimateUsage(\n current: number,\n previous: number,\n elapsed: number,\n window: number,\n) {\n return previous * previousWeight(elapsed, window) + current;\n}\n\n/**\n * How long until a request costing `cost` would be admitted, in milliseconds.\n *\n * Solves the usage equation for `elapsed` instead of guessing: the caller gets\n * a `Retry-After` that lands the moment capacity actually frees up rather than\n * at the end of the window, which for a sliding window is usually far too late.\n */\nexport function timeUntilAllowed(params: {\n current: number;\n previous: number;\n elapsed: number;\n window: number;\n limit: number;\n cost: number;\n}) {\n const { current, previous, elapsed, window, limit, cost } = params;\n // Usage the bucket may sit at for this request to still fit.\n const budget = limit - cost;\n\n // The request can never fit, no matter how long the caller waits. Report a\n // full window rather than `Infinity` so a `Retry-After` header stays usable.\n if (budget < 0) return window;\n\n const remainingWindow = Math.max(0, window - elapsed);\n\n // Phase 1 — capacity frees up inside the current window as `previous` decays.\n if (previous > 0) {\n // previous * (window - e) / window + current = budget => solve for e\n const target = window * (1 - (budget - current) / previous);\n if (target <= window) {\n return Math.max(0, Math.ceil(target - elapsed));\n }\n }\n\n // Phase 2 — `current` alone is already over budget, so nothing frees up until\n // the window rolls and `current` becomes the decaying `previous`.\n if (current <= budget) return remainingWindow;\n if (current <= 0) return remainingWindow;\n\n const target = window * (1 - budget / current);\n return remainingWindow + Math.max(0, Math.ceil(target));\n}\n\n/**\n * Turns a driver's post-operation counters into the result the caller sees.\n * `current` and `previous` are the counts *after* an allowed request has been\n * recorded, so every driver reports the same numbers for the same state.\n */\nexport function buildResult(params: {\n allowed: boolean;\n current: number;\n previous: number;\n now: number;\n elapsed: number;\n window: number;\n limit: number;\n cost: number;\n}): RateLimitResult {\n const { allowed, current, previous, now, elapsed, window, limit, cost } =\n params;\n\n if (allowed) {\n const usage = estimateUsage(current, previous, elapsed, window);\n return {\n allowed: true,\n limit,\n remaining: Math.max(0, Math.floor(limit - usage)),\n resetAt: now - elapsed + window,\n retryAfter: 0,\n };\n }\n\n const retryAfter = timeUntilAllowed({\n current,\n previous,\n elapsed,\n window,\n limit,\n cost,\n });\n\n return {\n allowed: false,\n limit,\n remaining: 0,\n resetAt: now + retryAfter,\n retryAfter,\n };\n}\n",
23
+ "import { buildResult, estimateUsage, windowStartFor } from \"../slidingWindow\";\nimport type { ConsumeParams, RateLimitResult } from \"../types\";\nimport { RateLimiterDriver } from \"./RateLimiterDriver\";\n\ninterface Bucket {\n /** Window length this bucket was counted with, so config changes reset it. */\n window: number;\n windowStart: number;\n current: number;\n previous: number;\n}\n\nexport interface InMemoryRateLimiterOptions {\n /**\n * Hard cap on tracked keys. Reached only by traffic that never repeats a key\n * (spoofed `x-forwarded-for`, for instance); the map is swept of dead buckets\n * first and only then evicts live ones, oldest touched first.\n *\n * Defaults to 100k keys — a few MB, and far more than a single instance\n * legitimately sees inside one window.\n */\n maxKeys?: number;\n}\n\n/**\n * Per-process rate limiter. The default driver, and the right one for a single\n * instance or for development.\n *\n * State lives in this process only: with N instances behind a load balancer the\n * effective limit is N × the configured limit, and it resets on deploy. Point\n * the service provider at `RedisRateLimiter` once you run more than one.\n */\nexport class InMemoryRateLimiter extends RateLimiterDriver {\n private buckets = new Map<string, Bucket>();\n private maxKeys: number;\n\n constructor(options: InMemoryRateLimiterOptions = {}) {\n super();\n this.maxKeys = Math.max(1, options.maxKeys ?? 100_000);\n }\n\n consume(params: ConsumeParams): RateLimitResult {\n const { key, limit, window } = params;\n const cost = params.cost ?? 1;\n const now = Date.now();\n const windowStart = windowStartFor(now, window);\n const elapsed = now - windowStart;\n\n const bucket = this.roll(key, window, windowStart);\n const usage = estimateUsage(\n bucket.current,\n bucket.previous,\n elapsed,\n window,\n );\n const allowed = usage + cost <= limit;\n\n if (allowed) {\n bucket.current += cost;\n }\n\n // Re-inserting moves the key to the end of the iteration order, which is\n // what makes eviction least-recently-used rather than arbitrary.\n this.buckets.delete(key);\n this.buckets.set(key, bucket);\n if (this.buckets.size > this.maxKeys) {\n this.evict(now);\n }\n\n return buildResult({\n allowed,\n current: bucket.current,\n previous: bucket.previous,\n now,\n elapsed,\n window,\n limit,\n cost,\n });\n }\n\n /** Drops all counters. Mainly useful in tests. */\n clear() {\n this.buckets.clear();\n }\n\n /** Number of tracked keys. Exposed for tests and diagnostics. */\n get size() {\n return this.buckets.size;\n }\n\n /** Advances a bucket to `windowStart`, creating it when absent or stale. */\n private roll(key: string, window: number, windowStart: number): Bucket {\n const bucket = this.buckets.get(key);\n\n if (!bucket || bucket.window !== window) {\n return { window, windowStart, current: 0, previous: 0 };\n }\n\n if (bucket.windowStart === windowStart) {\n return bucket;\n }\n\n if (bucket.windowStart + window === windowStart) {\n bucket.previous = bucket.current;\n bucket.current = 0;\n bucket.windowStart = windowStart;\n return bucket;\n }\n\n // Idle for more than a full window: everything it held has decayed away.\n bucket.previous = 0;\n bucket.current = 0;\n bucket.windowStart = windowStart;\n return bucket;\n }\n\n private evict(now: number) {\n for (const [key, bucket] of this.buckets) {\n // Fully decayed — it would be reset on the next read anyway.\n if (now - bucket.windowStart >= bucket.window * 2) {\n this.buckets.delete(key);\n }\n }\n\n // Still over the cap, so the traffic is live rather than stale. Drop the\n // least recently touched keys; the worst case is that a client whose bucket\n // was dropped gets a fresh budget, which beats growing without bound.\n for (const key of this.buckets.keys()) {\n if (this.buckets.size <= this.maxKeys) break;\n this.buckets.delete(key);\n }\n }\n}\n",
24
+ "import { InMemoryRateLimiter } from \"./drivers/InMemoryRateLimiterDriver\";\nimport type { RateLimiterDriver } from \"./drivers/RateLimiterDriver\";\n\n// Config key: `ratelimiter`. Derived from `RateLimiterServiceProvider`.\nexport interface RateLimiterConfig {\n /**\n * Where counters live. In-process by default; swap in `RedisRateLimiter` once\n * the app runs on more than one instance.\n */\n driver?: RateLimiterDriver;\n\n /** Requests allowed per window when the `rate-limit` DSL omits a limit. */\n limit?: number;\n\n /** Window length in **seconds** when the `rate-limit` DSL omits one. */\n window?: number;\n}\n\nexport function defineRateLimiterConfig(\n config: RateLimiterConfig,\n): RateLimiterConfig {\n return config;\n}\n\nexport function rateLimiterConfigDefaults(): Required<RateLimiterConfig> {\n return {\n driver: new InMemoryRateLimiter(),\n limit: 1000,\n window: 60,\n };\n}\n",
25
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { RateLimiter } from \"./RateLimiter\";\nimport { rateLimiterConfigDefaults, type RateLimiterConfig } from \"./config\";\n\nexport class RateLimiterServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n RateLimiter,\n () =>\n new RateLimiter(\n withDefaults(\n rateLimiterConfigDefaults(),\n this.app.config.get<RateLimiterConfig>(\"ratelimiter\", {}),\n ),\n ),\n );\n }\n}\n",
26
+ "import type { RedisOptions } from \"bun\";\n\n// Config key: `redis`. Derived from `RedisServiceProvider`.\nexport interface RedisConfig {\n // Connection URL for Bun's Redis client. Defaults to the `REDIS_URL`\n // environment variable (Bun itself falls back to `redis://localhost:6379`\n // when unset).\n url?: string;\n\n // Optional Bun Redis client options (TLS, timeouts, auto-reconnect, ...).\n options?: RedisOptions;\n}\n\nexport function defineRedisConfig(config: RedisConfig): RedisConfig {\n return config;\n}\n\nexport function redisConfigDefaults(): RedisConfig {\n return {\n url: process.env.REDIS_URL,\n options: undefined,\n };\n}\n",
27
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { redisConfigDefaults, type RedisConfig } from \"./config\";\nimport { RedisManager } from \"./RedisManager\";\n\nexport class RedisServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n RedisManager,\n () =>\n new RedisManager(\n withDefaults(\n redisConfigDefaults(),\n this.app.config.get<RedisConfig>(\"redis\", {}),\n ),\n ),\n );\n }\n}\n",
28
+ "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { ApiRouteDispatcher } from \"./ApiRouteDispatcher\";\nimport { ViewRouteDispatcher } from \"./ViewRouteDispatcher\";\nimport type { ApiRouteConfig, ViewRouteConfig } from \"./config\";\nimport type { Repository } from \"../../support/Repository\";\n\nfunction readConfig<T>(config: Repository, key: string): T {\n const slice = config.get<T>(key);\n if (!slice) {\n throw new Error(\n `Missing \"${key}\" configuration. Route dispatching needs a root router — declare it in \"app/config/route.ts\".`,\n );\n }\n return slice;\n}\n\n/**\n * Owns both route dispatchers. Laravel ships a single RouteServiceProvider for\n * every route file it loads; the api/view split is a config slice, not a\n * separate provider.\n */\nexport class RouteServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n ApiRouteDispatcher,\n () =>\n new ApiRouteDispatcher(\n readConfig<ApiRouteConfig>(this.app.config, \"route.api\"),\n ),\n );\n\n this.app.singleton(\n ViewRouteDispatcher,\n () =>\n new ViewRouteDispatcher(\n readConfig<ViewRouteConfig>(this.app.config, \"route.view\"),\n ),\n );\n }\n\n /**\n * The two dispatchers are the one pair of services that must not be built\n * lazily: constructing them flattens the route tables and runs\n * `assertNoReservedRoutePaths`, so a missing `route` config or a route under\n * a reserved prefix has to fail the boot rather than the first request that\n * happens to hit it.\n */\n boot() {\n this.app.make(ApiRouteDispatcher);\n this.app.make(ViewRouteDispatcher);\n }\n}\n"
29
+ ],
30
+ "mappings": ";kgBAmCA,SAAsB,LAAO,LAAC,JAA6B,LACzD,HAAI,LAQF,GAAI,CAAE,MAAM,EAAI,UAAU,KAAK,CAAG,EAChC,OAEF,MAAO,EAAO,CAMd,QAAQ,MACN,2CAA2C,EAAI,QAC/C,CACF,EACA,OAGF,GAAI,CACF,MAAM,EAAI,OAAO,KAAK,CAAG,EACzB,MAAO,EAAO,CACd,QAAQ,MAAM,4BAA4B,EAAI,QAAS,CAAK,EAE9D,GAAI,CACF,MAAM,EAAI,SAAS,KAAK,CAAG,EAC3B,MAAO,EAAO,CACd,QAAQ,MAAM,qBAAqB,EAAI,QAAS,CAAK,EAEvD,GAAI,CACF,MAAM,EAAI,WAAW,KAAK,CAAG,EAC7B,MAAO,EAAO,CACd,QAAQ,MAAM,6BAA6B,EAAI,QAAS,CAAK,GAI1D,MAAM,CAAU,OACd,OAAQ,YAEP,QAA2B,CAAC,EAC5B,SAER,WAAW,CAAC,EAAkC,CAC5C,KAAK,SAAW,EAAO,QAqBrB,KAAI,EAAqC,CAC3C,MAAO,CA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AAI,KAAK,CAAkB,EAChC,KAAK,IAAI,KAAK,CAAmB,EAErC",
31
+ "debugId": "B49E52DEF3A11B7964756E2164756E21",
32
+ "names": []
33
+ }
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{Dc as a}from"./chunk-kry5vwam.js";import{re as l,se as O,te as E,ue as k}from"./chunk-f9mfw82d.js";import{Ge as R,He as i,Ie as C,Je as M,Ke as Xz,xe as T}from"./chunk-01am9k5v.js";var $z=["every","none","some"],Vz=["is","isNot"];function g(z){return z==="many"?$z:Vz}function h(z,J){let W=Object.keys(z);return W.length>0&&W.every((Z)=>J.includes(Z))}var m="_count";function y(z){return Object.keys(z.relations).filter((J)=>z.relations[J]?.kind==="many").sort()}function N(z,J,W,Z){let X={model:z,operation:J,hasUser:W!=null};return Object.defineProperty(X,"user",{enumerable:!0,get(){if(W==null&&!Z)throw new R(z,J,"no-user");return W}}),X}class n{}class Qz extends n{}var qz=new Set(["findMany","findFirst","findFirstOrThrow","findUnique","findUniqueOrThrow","count","aggregate","groupBy","update","updateMany","delete","deleteMany"]),Yz=new Set(["create","createMany","upsert"]),jz=new Set(["update","updateMany","upsert"]),Lz=new Set(["update","updateMany"]),Kz=new Set(["create","createMany"]),p=new WeakMap;function Gz(z,J,W){if(typeof z!=="function")return z;let Z=p.get(z);if(Z!==void 0)return Z;let X;try{X=new z}catch($){throw new M(b(J),W,"constructor-threw",`${f(z)}, and constructing it threw:
2
+ import{Kc as a}from"./chunk-g5pj95dz.js";import{Ae as E,Be as k,ye as l,ze as O}from"./chunk-qfzyym5h.js";import{Ee as T,Ne as R,Oe as i,Pe as C,Qe as M,Re as Xz}from"./chunk-f233yzxf.js";var $z=["every","none","some"],Vz=["is","isNot"];function g(z){return z==="many"?$z:Vz}function h(z,J){let W=Object.keys(z);return W.length>0&&W.every((Z)=>J.includes(Z))}var m="_count";function y(z){return Object.keys(z.relations).filter((J)=>z.relations[J]?.kind==="many").sort()}function N(z,J,W,Z){let X={model:z,operation:J,hasUser:W!=null};return Object.defineProperty(X,"user",{enumerable:!0,get(){if(W==null&&!Z)throw new R(z,J,"no-user");return W}}),X}class n{}class Qz extends n{}var qz=new Set(["findMany","findFirst","findFirstOrThrow","findUnique","findUniqueOrThrow","count","aggregate","groupBy","update","updateMany","delete","deleteMany"]),Yz=new Set(["create","createMany","upsert"]),jz=new Set(["update","updateMany","upsert"]),Lz=new Set(["update","updateMany"]),Kz=new Set(["create","createMany"]),p=new WeakMap;function Gz(z,J,W){if(typeof z!=="function")return z;let Z=p.get(z);if(Z!==void 0)return Z;let X;try{X=new z}catch($){throw new M(b(J),W,"constructor-threw",`${f(z)}, and constructing it threw:
3
3
 
4
4
  ${$?.message??String($)}`,H,void 0,{cause:$})}return t(X,J,W),p.set(z,X),X}function S(z,J){return z.map((W,Z)=>Gz(W,J,Z))}var H=["before","scope","onCreate","onUpdate","redact"];var u=new WeakSet;function s(z,J){if(u.has(J))return;for(let W=0;W<J.length;W++)Uz(J[W],z,W);u.add(J)}function Uz(z,J,W){let Z=b(J),X=typeof z;if(z===null||Array.isArray(z)||X!=="object"&&X!=="function")throw new M(Z,W,"not-a-policy",o(z),H);if(X==="function"){if(!Mz(z))throw new M(Z,W,"not-constructable",f(z),H);return}t(z,J,W)}function t(z,J,W){let Z=b(J),X=0,$=[];for(let Y of H){let q=z[Y];if(q===void 0||q===null){if(Y in z)$.push(Y);continue}if(typeof q!=="function")throw new M(Z,W,"hook-not-callable",`'${Y}' that is ${o(q)} rather than a function`,H);X++}if(X>0)return;if($.length>0)throw new M(Z,W,"no-hooks",`It writes ${$.map((Y)=>`'${Y}'`).join(", ")} down and leaves ${$.length===1?"it":"them"} unset, which reads as `+"absent \u2014 so nothing is left to run.",H);let V=Fz(z),Q=Iz(V);throw new M(Z,W,"no-hooks",V.length===0?"It is empty.":`It spells ${Hz(V)}.`+(V.length===1&&V[0]==="default"?" A lone 'default' is a module namespace rather than the policy "+"inside it \u2014 put `entry.default` in the array, or import the "+"policy by name.":""),H,Q)}function Hz(z){let J=z.slice(0,8).map((W)=>`'${W}'`);return z.length>J.length?`${J.join(", ")} and ${z.length-J.length} more`:J.join(", ")}function Mz(z){try{return Reflect.construct(Bz,[],z),!0}catch{return!1}}var Bz=function(){};function Fz(z){let J=new Set,W=z;while(W!==null&&W!==Object.prototype){for(let Z of Object.getOwnPropertyNames(W))if(Z!=="constructor")J.add(Z);W=Object.getPrototypeOf(W)}return[...J]}function Iz(z){let J,W=2;for(let Z of z)for(let X of H){let $=Tz(Z.toLowerCase(),X.toLowerCase());if($<W)W=$,J={key:Z,hook:X}}return J}function Tz(z,J){if(z===J)return 0;let W=Array.from({length:J.length+1},(Z,X)=>X);for(let Z=1;Z<=z.length;Z++){let X=W[0];W[0]=Z;for(let $=1;$<=J.length;$++){let V=W[$];W[$]=Math.min(W[$]+1,W[$-1]+1,X+(z[Z-1]===J[$-1]?0:1)),X=V}}return W[J.length]}function o(z){if(z===null)return"null";if(z===void 0)return"undefined";if(typeof z==="string")return`the string ${JSON.stringify(z)}`;if(typeof z==="function")return f(z);if(Array.isArray(z))return"an array";if(typeof z==="object")return"an object";return`the ${typeof z} ${String(z)}`}function f(z){return z.name?`the function \`${z.name}\``:"an anonymous function"}function _(z){let J,W,Z,X=z;while(X&&X!==Function.prototype){if(Object.hasOwn(X,"$policy"))throw Error(`${X.name??"This model"} declares \`$policy\`, which is now \`$policies\` and takes a list. The old `+"name is not read, so this model is currently unpolicied \u2014 every "+"scope, onCreate and redact on it is being skipped.");if(Object.hasOwn(X,"$policies")&&X.$policies){let $=X.$policies;if($.length>0){let V=X;if(s(V,$),W===void 0&&J===void 0)W=$,Z=V;else J??=S(W,Z),W=void 0,J.unshift(...S($,V))}}X=Object.getPrototypeOf(X)}if(J!==void 0)return J;if(W===void 0)return Nz;return W.some(($)=>typeof $==="function")?S(W,Z):W}function r(z){let J=z;while(J&&J!==Function.prototype){if(Object.hasOwn(J,"$policies")&&J.$policies){let W=J.$policies;if(W.length>0)s(J,W)}J=Object.getPrototypeOf(J)}}function b(z){return z?.name??"This model"}var Nz=Object.freeze([]);function D(z,J,W,Z=[]){if(z.length===0)return W;let X=W,$;for(let V of z)if(V.before){if(V.before(J)===!1)throw new R(J.model,J.operation)}for(let V of z){if(!V.scope)continue;if(Kz.has(J.operation)){Sz(V,J);continue}let Q=V.scope(J);if(Q===void 0||Q===null)continue;if(Rz(J),Lz.has(J.operation)&&!V.onUpdate){let Y=Pz(Q);if(Y.length>0)($??=[]).push(...Y)}X=_z(X,Q)}if(Yz.has(J.operation)){for(let V of z)if(V.onCreate)X=Dz(X,J,V)}if(jz.has(J.operation)){for(let V of z)if(V.onUpdate)X=Az(X,J,V)}if($!==void 0)Cz($,J,X,Z);return X}function _z(z,J){let W=z?.where;if(W===void 0||W===null)return{...z,where:J};if(typeof W!=="object"||Array.isArray(W))return{...z,where:{AND:[W,J]}};let Z=W.AND,X=Z===void 0||Z===null?[]:Array.isArray(Z)?Z:[Z];return{...z,where:{...W,AND:[...X,J]}}}function Dz(z,J,W){let Z=(X)=>W.onCreate(J,{...X});if(J.operation==="createMany"){let X=z?.data;return{...z,data:Array.isArray(X)?X.map(Z):Z(X)}}if(J.operation==="upsert")return{...z,create:Z(z?.create)};return{...z,data:Z(z?.data)}}function Az(z,J,W){let Z=J.operation==="upsert"?"update":"data",X=z?.[Z];if(X===void 0||X===null)return z;return{...z,[Z]:W.onUpdate(J,{...X})}}function Cz(z,J,W,Z=[]){let X=W?.data;if(typeof X!=="object"||X===null)return;let $=z.filter((V)=>(V in X)&&!Z.includes(V));if($.length===0)return;throw new i(J.model,J.operation,[...new Set($)])}function Pz(z){if(typeof z!=="object"||z===null||Array.isArray(z))return[];let J=[];for(let W of Object.keys(z)){if(W==="AND"||W==="OR"||W==="NOT")continue;J.push(W)}return J}function Sz(z,J){if(z.onCreate)return;throw new T(J.operation,J.model,J.operation,`${J.model} has a policy that scopes reads but no 'onCreate', and ${J.operation} has no where clause for a scope to narrow. As written the policy would confine reads to the caller and let an insert name any value it likes. Add an onCreate that sets the scoped `+"column \u2014 or, if unscoped creates are intended, say so with an onCreate "+"that returns its data unchanged.")}function Rz(z){if(qz.has(z.operation))return;throw new T(z.operation,z.model,z.operation,`${z.model} has a policy with a scope, and ${z.operation} cannot carry one: its where clause compiles to an 'on conflict' target, which is a key rather than a filter. Running it would write outside the scope.
5
5
 
6
6
  Two ways out. Use update and create separately, which both scope `+"normally \u2014 or leave the conflict key out of 'create', which Model.upsert "+"runs as a scoped read and a scoped write inside one transaction. The refusal is about 'on conflict' specifically, not about upsert.")}function dz(z,J,W){if(z.length===0)return;let Z=z.filter((X)=>X.redact);if(Z.length===0)return;for(let X of fz(W))for(let $ of Z)$.redact(J,X)}function fz(z){if(Array.isArray(z))return z;if(z===null||z===void 0)return[];if(typeof z!=="object")return[];return[z]}function lz(z,J,W){for(let Z of W){let X=z.fields[Z];if(X&&!X.nullable)throw new T(`redact.${Z}`,z.name,"redact",`'${Z}' is not nullable, so setting it to null would contradict `+"the generated type \u2014 which still says the field is there. Make the "+"field optional in schema.prisma, omit it with 'select' instead, or delete the key yourself if a runtime-only guarantee is enough.");if(Z in J)J[Z]=null}}function iz(){let z=a();if(z)return z.user;return bz()?.user??null}function bz(){try{return l.getStore()}catch{return}}var e=Symbol("gemi.orm.policiesAppliedByCaller");function az(z){return{...z,[e]:!0}}function nz(z){return typeof z==="object"&&z!==null&&z[e]===!0}var zz=Symbol("gemi.orm.columnsWrittenByTheOrm");function sz(z,J){return{...z,[zz]:J}}function tz(z){if(typeof z!=="object"||z===null)return c;let J=z[zz];return Array.isArray(J)?J:c}var c=[],Jz=Symbol("gemi.orm.operationTheRowIsReturnedFor");function oz(z,J){return{...z,[Jz]:J}}function rz(z){if(typeof z!=="object"||z===null)return;let J=z[Jz];return typeof J==="string"?J:void 0}var A="findMany";function Oz(z,J,W,Z,X){if(J===void 0||J===null)return J;if(typeof J!=="object")return J;let $=J;for(let Y of["include","select"]){let q=J[Y];if(typeof q!=="object"||q===null||Array.isArray(q))continue;let j;for(let L of Object.keys(q)){if(L===m){let w=Ez(z,q[L],W,Z,X);if(w!==q[L])j??={...q},j[L]=w;continue}let G=z.relations[L];if(!G)continue;let K=q[L];if(K===void 0||K===!1)continue;let U=X(G.model);if(!U)continue;let F=K===!0?{}:K;if(typeof F!=="object"||Array.isArray(F))continue;let x=Oz(U.schema,F,W,Z,X),v=!Z&&U.policies.length>0?D(U.policies,N(U.schema.name,A,W,Z),x):x;if(v!==F)j??={...q},j[L]=v}if(j)$={...$,[Y]:j}}let V=Wz(z,$.orderBy,W,Z,X);if(V!==$.orderBy)$={...$,orderBy:V};let Q=I(z,$.where,W,Z,X);if(Q!==$.where)$={...$,where:Q};return $}function Wz(z,J,W,Z,X){if(Z)return J;if(typeof J!=="object"||J===null)return J;if(Array.isArray(J)){let Q=!1,Y=J.map((q)=>{let j=Wz(z,q,W,Z,X);if(j!==q)Q=!0;return j});return Q?Y:J}let $,V=J;for(let Q of Object.keys(V)){let Y=z.relations[Q];if(!Y)continue;let q=V[Q];if(typeof q!=="object"||q===null||Array.isArray(q))continue;let j=X(Y.model);if(!j||j.policies.length===0)continue;let L=D(j.policies,N(j.schema.name,A,W,Z),q);if(L!==q)$??={...V},$[Q]=L}return $??J}function Ez(z,J,W,Z,X){if(Z)return J;let $=J===!0;if(!$&&(typeof J!=="object"||J===null||Array.isArray(J)))return J;let V=$?Object.fromEntries(y(z).map((q)=>[q,!0])):J.select;if(typeof V!=="object"||V===null||Array.isArray(V))return J;let Q,Y=V;for(let q of Object.keys(Y)){let j=Y[q];if(j===void 0||j===!1)continue;let L=z.relations[q];if(!L)continue;let G=X(L.model);if(!G||G.policies.length===0)continue;let K=j===!0?{}:j;if(typeof K!=="object"||Array.isArray(K))continue;let U=D(G.policies,N(G.schema.name,A,W,Z),K);if(U!==K)Q??={...Y},Q[q]=U}if(!Q)return J;return $?{select:Q}:{...J,select:Q}}function I(z,J,W,Z,X){if(typeof J!=="object"||J===null)return J;if(Array.isArray(J)){let Q=!1,Y=J.map((q)=>{let j=I(z,q,W,Z,X);if(j!==q)Q=!0;return j});return Q?Y:J}let $,V=J;for(let Q of Object.keys(V)){let Y=V[Q];if(Y===void 0)continue;if(Q==="AND"||Q==="OR"||Q==="NOT"){let L=I(z,Y,W,Z,X);if(L!==Y)$??={...V},$[Q]=L;continue}let q=z.relations[Q];if(!q)continue;let j=kz(q,Y,W,Z,X);if(j!==Y)$??={...V},$[Q]=j}return $??J}function kz(z,J,W,Z,X){if(typeof J!=="object"||J===null||Array.isArray(J))return J;let $=X(z.model);if(!$)return J;let V=g(z.kind),Q=!h(J,V),Y=Q?[["is",J]]:Object.entries(J),q;for(let[j,L]of Y){if(L===null||L===void 0)continue;let G=I($.schema,L,W,Z,X),K=!Z&&$.policies.length>0?D($.policies,N($.schema.name,A,W,Z),{where:G}).where:G,U=j==="every"?xz(G,K):K;if(U!==L)q??=Q?{}:{...J},q[j]=U}if(!q)return J;return q}function xz(z,J){if(J===z)return z;let W=d(z),X=d(J).slice(W.length);if(X.length===0)return z;return{OR:[{NOT:X.length===1?X[0]:{AND:X}},z]}}function d(z){if(typeof z!=="object"||z===null)return[];let J=z.AND;if(J===void 0)return[];return Array.isArray(J)?J:[J]}function vz(...z){let[J]=wz(...z);if(J!==void 0)throw J}function wz(...z){let J=[];for(let W of z)for(let Z of Object.values(W)){let X=Zz(Z);if(X===null)continue;r(X);let $=X.$schema.name,V=E($)?k($):void 0;if(V===void 0||V===X)continue;let Q=_(X),Y=_(V),q=Q.length!==Y.length||Q.some((j,L)=>j!==Y[L]);if(P(V,X)||P(X,V)){let j=P(X,V)?V:X,L=j===V?X:V;if(_(j).length===0){if(V===L)continue;if(!q)continue;J.push(new C($,B(V),B(X),Q.length>0?"queried":"registered"));continue}if(q)J.push(new C($,B(j),B(L),"narrowing"));continue}if(!q)continue;J.push(new C($,B(V),B(X),Q.length>0?"queried":"registered"))}return J}function XJ(...z){let J=new Map;for(let Z of z){let X=new Map;for(let $ of new Set(Object.values(Z))){let V=Zz($);if(V===null)continue;let Q=V.$schema.name,Y=X.get(Q);if(Y===void 0)X.set(Q,[V]);else Y.push(V)}for(let[$,V]of X)J.set($,gz($,V))}let W=[...J.keys()].filter((Z)=>E(Z)).map((Z)=>[Z,k(Z)]);for(let[Z,X]of J)O(Z,X);try{vz(...z)}catch(Z){for(let[X,$]of W)O(X,$);throw Z}}function gz(z,J){if(J.length===1)return J[0];let W=J.filter(($)=>!hz($)),Z=W.length>0?W:J;if(Z.length===1)return Z[0];let X=Z.filter(($)=>Z.every((V)=>V===$||P(V,$)));if(X.length===1)return X[0];throw new Xz(z,Z.map(($)=>B($)))}function hz(z){if("$generated"in z)return Object.hasOwn(z,"$generated")&&z.$generated===!0;return Object.hasOwn(z,"$schema")}function P(z,J){let W=Object.getPrototypeOf(z);while(W!==null&&W!==Function.prototype){if(W===J)return!0;W=Object.getPrototypeOf(W)}return!1}function B(z){return z?.name??String(z)}function Zz(z){if(typeof z!=="function")return null;let J=z.$schema;if(J===void 0||typeof J.name!=="string")return null;return z}
7
7
  export{g as ta,h as ua,m as va,y as wa,N as xa,n as ya,Qz as za,_ as Aa,D as Ba,dz as Ca,lz as Da,iz as Ea,az as Fa,nz as Ga,sz as Ha,tz as Ia,oz as Ja,rz as Ka,A as La,Oz as Ma,vz as Na,wz as Oa,XJ as Pa};
8
8
 
9
- //# debugId=E1DDFE8375E3A3DC64756E2164756E21
9
+ //# debugId=2C618B73A1149D9F64756E2164756E21
@@ -7,6 +7,6 @@
7
7
  "import {\n AmbiguousModelRegistrationError,\n UnregisteredPolicyClassError,\n} from \"./errors\";\nimport { assertPolicyShapes, policiesFor } from \"./policy\";\nimport * as registry from \"./registry\";\nimport type { ModelSchema } from \"./schema\";\n\n/** A model class, as much of one as anything below `Model.ts` can name. */\ntype ModelClass = object & { $schema: ModelSchema };\n\n/**\n * Checks that every policied model class an application defines is the one the\n * registry resolves its name to — **ahead of any query**, rather than when one\n * happens to be run.\n *\n * ### Why this exists\n *\n * `Model.$exec` already refuses a query whose class carries policies the\n * registered class does not (`UnregisteredPolicyClassError`). That guard closed\n * the two shapes found in #51, and it is the right check, but it can only fire\n * on a class somebody actually queries **at the root**. Its condition begins\n * `registered !== this`, and there is a case where that is false and the leak is\n * real:\n *\n * export class Membership extends MembershipModel {\n * static $policies = [{ scope: (ctx) => ({ orgId: ctx.user.orgId }) }]\n * }\n * // ...and no `register(\"Membership\", Membership)`\n *\n * If nothing ever calls `Membership.findMany()` — because memberships are only\n * ever read through `include: { memberships: true }` — then the include resolves\n * the name to the *generated base*, `this` **is** that base, the comparison\n * never runs, and rows come back unscoped with no error. Not a policy chain that\n * fails to diverge: a check that is never reached.\n *\n * A model reached only through includes is usually a membership or a pivot,\n * which is exactly the kind that carries a tenant scope. So the residual runs\n * the wrong way: the guard is weakest where the data is most sensitive.\n *\n * ### What this does about it\n *\n * The same rule, triggered differently. Instead of waiting for a root query,\n * it takes the modules where an application's model classes live and applies the\n * divergence comparison to every one of them:\n *\n * import * as models from \"@/app/models\"\n * assertPoliciesRegistered(models)\n *\n * Reading a class out of a module namespace is what makes the unqueried case\n * visible — the class exists and is exported whether or not anything queries it.\n *\n * `registerModels` runs this after registering, and `Kernel.models` runs\n * `registerModels` at boot, so an application that declares its model modules\n * gets it without asking. This is the same check for modules the Kernel does\n * not own — a test over a package's models, a script that boots nothing.\n *\n * It can only see modules it is handed, which is the residual either way: a\n * policied class in a file no barrel re-exports is invisible to it.\n * `gemi check models` closes that by handing it the files instead of the\n * barrel — see `auditModelRegistrations`, which is the same rule without the\n * throw.\n */\nexport function assertPoliciesRegistered(\n ...modules: Array<Record<string, unknown>>\n): void {\n const [first] = auditModelRegistrations(...modules);\n if (first !== undefined) throw first;\n}\n\n/**\n * Every problem `assertPoliciesRegistered` would report, as values rather than\n * as a throw — in the order it would have reported them, so the first element is\n * exactly what that function throws.\n *\n * ### Why the rule needed a second caller\n *\n * A throw is the right shape at boot: the first policied class that does not own\n * its name is a reason not to start, and the rest of the list is noise nobody\n * reads before fixing the first one.\n *\n * It is the wrong shape for a checker. `gemi check models` walks\n * `app/models/**` and audits each file, so it wants *all* of them, and it wants\n * to sort them — a policied class the Kernel never sees is a leak to report,\n * while a policied view deliberately kept out of the declared modules is the\n * arrangement the error for that case actually recommends, and reporting it\n * would be telling an author to undo what the framework told them to do.\n * `UnregisteredPolicyClassError.carries` is what separates the two, and it can\n * only be read off an error somebody is holding.\n *\n * Errors rather than a plain finding type, because the message is the useful\n * part and it is already written once, in the error. Constructing them is not\n * free — a stack per finding — and it is a check somebody runs, not a request\n * path.\n */\nexport function auditModelRegistrations(\n ...modules: Array<Record<string, unknown>>\n): UnregisteredPolicyClassError[] {\n const problems: UnregisteredPolicyClassError[] = [];\n\n for (const module of modules) {\n for (const exported of Object.values(module)) {\n const model = asModelClass(exported);\n if (model === null) continue;\n\n // #321's boot-time half, run **before** the early return below and for\n // every class rather than only the diverging ones. Left below the return,\n // the two commonest arrangements were never checked at all — a class that\n // already owns its name, and one whose name nothing else claims — so a\n // `{ scopes: … }` typo registered, reported green, and read unscoped.\n //\n // `assertPolicyShapes` and not `policiesFor`, and the difference is the\n // point: this walk checks the entries and constructs nothing. Resolving\n // here instead is one line and would additionally catch a policy class\n // whose constructor throws — at the price of constructing every policy\n // class in the application at `registerModels` time, ahead of whatever\n // config or container the constructor reaches for. A guard against a\n // policy that does nothing must not become the reason a working\n // application stops booting, so the cases that need an instance are left\n // to `policiesFor`, which is reached below, on the first query, and by\n // `Model.$exec`.\n assertPolicyShapes(model);\n\n const name = model.$schema.name;\n const registered = registry.has(name)\n ? (registry.get<unknown>(name) as object)\n : undefined;\n\n // Nothing registered under the name at all. The generated `index.ts`\n // registers every model, so reaching this means it was never imported —\n // a different mistake, and one the first query reports clearly through\n // `ModelNotRegisteredError`. Not this function's business.\n if (registered === undefined || registered === model) continue;\n\n const ours = policiesFor(model);\n const theirs = policiesFor(registered);\n const diverges =\n ours.length !== theirs.length ||\n ours.some((policy, index) => policy !== theirs[index]);\n\n // The two classes are on one prototype chain — a base and something\n // extending it — which is the arrangement almost every application has,\n // and the one this audit used to get wrong in both directions.\n //\n // `policiesFor` accumulates upwards, so a descendant's chain always\n // contains its ancestor's. What separates the two shapes is therefore\n // whether the **ancestor** carries anything of its own.\n if (descendsFrom(registered, model) || descendsFrom(model, registered)) {\n const ancestor = descendsFrom(model, registered) ? registered : model;\n const descendant = ancestor === registered ? model : registered;\n\n if (policiesFor(ancestor).length === 0) {\n // The ancestor contributes nothing, so the descendant is the first\n // class to carry a policy: it is not a view over the model, it *is*\n // the model. A generated base is the usual ancestor here, and a\n // hand-written intermediate behaves the same way.\n //\n // Registered already? Then this is the correct arrangement, and it\n // has to be skipped rather than reported — it used not to be, and\n // that is why the documented\n //\n // assertPoliciesRegistered(generated, models)\n //\n // threw the moment an application wrote its first policy: it walked\n // the generated namespace, found `UserModel` diverging from the\n // registered `User`, and refused the thing it exists to protect.\n // Being reachable through a base is not the bug; querying through one\n // is, and that is a property of a call site rather than of a module's\n // export list, so `Model.$exec` keeps that direction.\n if (registered === descendant) continue;\n\n // Neither class carries anything, so which one owns the name changes\n // no query's scope. An unregistered plain subclass is not a mistake.\n if (!diverges) continue;\n\n // Not registered, and it has policies: #316 itself. The policied\n // class is not the one the name resolves to, so every nested read\n // runs the ancestor and skips it.\n problems.push(\n new UnregisteredPolicyClassError(\n name,\n nameOf(registered),\n nameOf(model),\n ours.length > 0 ? \"queried\" : \"registered\",\n ),\n );\n continue;\n }\n\n // The ancestor carries policies of its own, so it is a registered model\n // in good standing and the descendant is narrowing it. The registry\n // holds one class per name: registering the view applies its narrowing\n // to every nested read, and leaving the ancestor registered skips the\n // view's policies entirely. Both are silent, so neither is chosen.\n if (diverges) {\n problems.push(\n new UnregisteredPolicyClassError(\n name,\n nameOf(ancestor),\n nameOf(descendant),\n \"narrowing\",\n ),\n );\n }\n\n // Same chain, same policies — a plain typed view. Nothing to report.\n continue;\n }\n\n if (!diverges) continue;\n\n // Unrelated classes claiming one name. Whichever is registered, the\n // other's policies are simply not in effect.\n problems.push(\n new UnregisteredPolicyClassError(\n name,\n nameOf(registered),\n nameOf(model),\n ours.length > 0 ? \"queried\" : \"registered\",\n ),\n );\n }\n }\n\n return problems;\n}\n\n/**\n * Registers every model class the given modules export, under the name each\n * one's schema carries, and then audits the result.\n *\n * ### The line this exists to delete\n *\n * `register(\"User\", User)` next to every subclass is a correct instruction and\n * a bad mechanism, because forgetting it is invisible. A relation read resolves\n * its target by name, so an unregistered policied subclass leaves the generated\n * base owning the name and every nested `include` of that model comes back\n * unscoped — no error, no warning, and an authorization hole in the direction\n * nobody checks. `assertPoliciesRegistered` turns that into a loud failure, but\n * only for someone who remembered to run it.\n *\n * Deriving the registration from the module removes the mistake instead of\n * reporting it. The name is not a string an author repeats; it is\n * `$schema.name`, which the generator wrote and the subclass inherits:\n *\n * import * as generated from \"./generated\"\n * import * as models from \"./models\"\n *\n * registerModels(generated, models)\n *\n * Later modules win, so the application's classes replace the generated bases\n * they extend. `register` still exists and still works — this is what an\n * application calls once instead of writing it thirteen times.\n *\n * ### What it still cannot see\n *\n * Modules it is handed. A policied class in a file nothing imports is invisible\n * to this exactly as it is to `assertPoliciesRegistered`, and closing *that*\n * would take the framework enumerating the filesystem at boot. Handing it a\n * barrel is the whole discipline: one file to add a model to, and the audit\n * covers everything in it.\n *\n * `Kernel.models` is that call, wired at boot, so an application declares its\n * model modules the way it already declares config slices and providers.\n */\nexport function registerModels(\n ...modules: Array<Record<string, unknown>>\n): void {\n // Elected into a local map first, and only committed once the audit passes.\n //\n // The registry is process-wide and outlives the throw. Registering as we went\n // meant a refused call left the arrangement it had just refused installed —\n // `registerModels({Ours}, {Theirs})` threw, and `\"User\"` resolved to `Theirs`\n // afterwards, which is the leaking mapping the audit exists to reject. A\n // server whose boot dies never notices; a dev server that catches and keeps\n // serving, or a test harness that continues past the error, serves the rest\n // of the process from it.\n const staged = new Map<string, ModelClass>();\n\n for (const module of modules) {\n const candidates = new Map<string, ModelClass[]>();\n\n // Deduped by identity first: `export { User }` alongside a default export\n // is the same class under two keys, not two classes competing for a name.\n for (const exported of new Set(Object.values(module))) {\n const model = asModelClass(exported);\n if (model === null) continue;\n\n const name = model.$schema.name;\n const existing = candidates.get(name);\n if (existing === undefined) candidates.set(name, [model]);\n else existing.push(model);\n }\n\n // Later modules win, which is what lets an application's classes replace\n // the generated bases they extend.\n for (const [name, classes] of candidates) {\n staged.set(name, elect(name, classes));\n }\n }\n\n // What the registry said before, so a failed audit can put it back. `register`\n // has no inverse, so a name that was previously *absent* cannot be made\n // absent again — it is left pointing at what this call elected. That is the\n // one residue, and it is the harmless direction: the alternative to a wrong\n // registration under a name nothing claimed is `ModelNotRegisteredError`, and\n // the class elected here is the one this module set would have used anyway.\n const previous = [...staged.keys()]\n .filter((name) => registry.has(name))\n .map((name) => [name, registry.get<unknown>(name)] as const);\n\n for (const [name, model] of staged) registry.register(name, model);\n\n try {\n assertPoliciesRegistered(...modules);\n } catch (error) {\n for (const [name, model] of previous) registry.register(name, model);\n throw error;\n }\n}\n\n/**\n * Which of several classes claiming one name in one module gets it.\n *\n * Two shapes put more than one candidate in a namespace, and they want opposite\n * answers, so neither \"most derived\" nor \"least derived\" is the rule on its\n * own:\n *\n * export * from \"./generated\" // UserModel, and\n * export class User extends UserModel { static $policies = [...] }\n *\n * wants the subclass — electing the base here *is* the leak, in the one file an\n * author most plausibly writes it in. While\n *\n * export class User extends UserModel { static $policies = [...] }\n * export class AdminUser extends User {}\n *\n * wants `User`. `AdminUser` is a typed view over the same rows; it inherits the\n * policies either way, so registering it changes nothing when it adds none and\n * silently applies its own narrowing to every nested read when it does.\n *\n * What separates them is which class the *generator* wrote. It emits\n * `static $schema = schema.User` on the base, and a subclass inherits that\n * property rather than declaring one — so an own `$schema` is the mark of a\n * generated base, and it is a fact about the classes rather than about the\n * order somebody exported them in. Application classes are preferred over\n * bases; among application classes the least derived wins, for the reason\n * `AdminUser` gives.\n *\n * When that leaves no single answer the candidates are unrelated classes with a\n * genuine claim each, and there is nothing left to infer. That case is refused\n * rather than guessed at: `register` says which, in the application's own\n * words.\n */\nfunction elect(name: string, classes: ModelClass[]): ModelClass {\n if (classes.length === 1) return classes[0]!;\n\n const written = classes.filter((candidate) => !isGeneratedBase(candidate));\n const eligible = written.length > 0 ? written : classes;\n\n if (eligible.length === 1) return eligible[0]!;\n\n const roots = eligible.filter((candidate) =>\n eligible.every(\n (other) => other === candidate || descendsFrom(other, candidate),\n ),\n );\n\n if (roots.length === 1) return roots[0]!;\n\n throw new AmbiguousModelRegistrationError(\n name,\n eligible.map((candidate) => nameOf(candidate)),\n );\n}\n\n/**\n * Whether the generator wrote this class, rather than an application extending\n * one it wrote.\n *\n * The generator marks its own output — `static $generated = true` on each\n * emitted base, and on nothing else — so for artifacts that carry the mark this\n * is a fact the generator stated rather than a property of how it happens to be\n * written. A subclass *inherits* the mark and does not own it, which is what\n * makes own-vs-inherited the whole test.\n *\n * ### The fallback, and why it is second\n *\n * `$schema` is also declared on the emitted base and inherited below it, so\n * owning *that* used to answer the same question, and it answered it wrongly for\n * one shape (#318): a subclass that redeclares `static $schema` — pointing at a\n * modified schema object, or by copy-paste — read as a base, every candidate\n * looked generated, and the least derived won. That did not pass quietly, since\n * `assertPoliciesRegistered` runs immediately after `elect` and refuses a\n * policied class that lost its name. But loud-and-wrong is still wrong, and the\n * silent half — a subclass with statics and row methods but no policies, whose\n * methods then never run inside a nested read — had nothing to refuse.\n *\n * The inference survives as the fallback for artifacts generated *before* the\n * mark existed, where it is the only signal there is. `\"$generated\" in candidate`\n * is what separates the two worlds: it walks the prototype chain, so it is true\n * for a marked base and for everything under it, and false for every class in an\n * app whose `app/models/generated` predates 0.51. Asking `Object.hasOwn` first\n * and falling back on `false` would send a subclass of a *marked* base back into\n * the inference — which is exactly the case the mark was added to fix.\n *\n * `registration.test.ts` in the template asserts the contract against real\n * generator output, because this is the one place a generator change could\n * quietly invalidate an assumption made here.\n */\nfunction isGeneratedBase(candidate: ModelClass): boolean {\n // Owning the mark, not merely having it — and owning it set to `true`. The\n // declared type is `?: true`, so TypeScript already refuses `false`; reading\n // the value anyway is what makes `static $generated = false` mean the thing\n // it plainly says in an app with no typechecking between it and here.\n if (\"$generated\" in candidate) {\n return (\n Object.hasOwn(candidate, \"$generated\") &&\n (candidate as { $generated?: unknown }).$generated === true\n );\n }\n\n return Object.hasOwn(candidate, \"$schema\");\n}\n\n/**\n * Whether `derived` has `base` in its static prototype chain — the `extends`\n * relation between two classes, walked on the constructor side because that is\n * where `$schema` and `$policies` live.\n */\nfunction descendsFrom(derived: unknown, base: unknown): boolean {\n let current = Object.getPrototypeOf(derived);\n\n while (current !== null && current !== Function.prototype) {\n if (current === base) return true;\n current = Object.getPrototypeOf(current);\n }\n\n return false;\n}\n\nfunction nameOf(value: unknown): string {\n return (value as { name?: string })?.name ?? String(value);\n}\n\n/**\n * A model class, structurally.\n *\n * Structural rather than `instanceof Model` on purpose: this module sits below\n * `Model.ts` in the import graph, and importing it here to answer a question\n * about shape would put a cycle between the registry, the policy hook and the\n * model base for no gain. `$schema` carrying a `name` is what every operation\n * already relies on.\n *\n * A module namespace holds anything the author exported — types erase, but\n * constants, helpers and re-exported values do not — so everything that is not\n * a model class is skipped rather than treated as an error.\n */\nfunction asModelClass(value: unknown): ModelClass | null {\n if (typeof value !== \"function\") return null;\n\n const schema = (value as { $schema?: ModelSchema }).$schema;\n if (schema === undefined || typeof schema.name !== \"string\") return null;\n\n return value as unknown as ModelClass;\n}\n"
8
8
  ],
9
9
  "mappings": ";wMAyBA,FAAM,HAAwB,CAAC,QAAS,OAAQ,MAAM,EAChD,GAAuB,CAAC,KAAM,OAAO,EAsBpC,SAAS,CAAuB,CACrC,EACmB,CACnB,OAAO,IAAS,OAAS,GAAwB,GAgB5C,SAAS,CAAc,CAC5B,EACA,EACS,CACT,IAAM,EAAO,OAAO,KAAK,CAAK,EAC9B,OAAO,EAAK,OAAS,GAAK,EAAK,MAAM,CAAC,IAAQ,EAAU,SAAS,CAAG,CAAC,EAYhE,IAAM,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SAAS,EAAK,CAAC,EAAc,EAAmC,CAC9D,GAAI,EAAQ,SAAW,EAAG,OAAO,EAAQ,GAEzC,IAAM,EAAU,EAAQ,OAAO,CAAC,IAAc,CAAC,GAAgB,CAAS,CAAC,EACnE,EAAW,EAAQ,OAAS,EAAI,EAAU,EAEhD,GAAI,EAAS,SAAW,EAAG,OAAO,EAAS,GAE3C,IAAM,EAAQ,EAAS,OAAO,CAAC,IAC7B,EAAS,MACP,CAAC,IAAU,IAAU,GAAa,EAAa,EAAO,CAAS,CACjE,CACF,EAEA,GAAI,EAAM,SAAW,EAAG,OAAO,EAAM,GAErC,MAAM,IAAI,GACR,EACA,EAAS,IAAI,CAAC,IAAc,EAAO,CAAS,CAAC,CAC/C,EAqCF,SAAS,EAAe,CAAC,EAAgC,CAKvD,GAAI,eAAgB,EAClB,OACE,OAAO,OAAO,EAAW,YAAY,GACpC,EAAuC,aAAe,GAI3D,OAAO,OAAO,OAAO,EAAW,SAAS,EAQ3C,SAAS,CAAY,CAAC,EAAkB,EAAwB,CAC9D,IAAI,EAAU,OAAO,eAAe,CAAO,EAE3C,MAAO,IAAY,MAAQ,IAAY,SAAS,UAAW,CACzD,GAAI,IAAY,EAAM,MAAO,GAC7B,EAAU,OAAO,eAAe,CAAO,EAGzC,MAAO,GAGT,SAAS,CAAM,CAAC,EAAwB,CACtC,OAAQ,GAA6B,MAAQ,OAAO,CAAK,EAgB3D,SAAS,EAAY,CAAC,EAAmC,CACvD,GAAI,OAAO,IAAU,WAAY,OAAO,KAExC,IAAM,EAAU,EAAoC,QACpD,GAAI,IAAW,QAAa,OAAO,EAAO,OAAS,SAAU,OAAO,KAEpE,OAAO",
10
- "debugId": "E1DDFE8375E3A3DC64756E2164756E21",
10
+ "debugId": "2C618B73A1149D9F64756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ka as B,la as C,na as E}from"./chunk-5ad8era8.js";import{rd as x,td as z,ud as A}from"./chunk-q0waxxz5.js";function M(b,f={}){let j=B(b,f.sourceLocale);return G(E(b),j,(q)=>C(b,q,j))}function N(b,f){let j=Object.keys(f);return G(b,j,(q)=>{let v=f[q]??f[j[0]];if(!v)return{};return v().then((k)=>k.default)})}function G(b,f,j){let q={id:b,locales:f,load:j};x(q);let v=()=>x(q);return{id:b,locales:f,load:(k)=>{return v(),z(b,k)},loadForRender:(k)=>{return v(),A(b,k)},get:(k)=>{v();let w=z(b,k);if(w instanceof Promise){w.catch(()=>{});return}return w}}}
2
+ import{ka as B,la as C,na as E}from"./chunk-5ad8era8.js";import{Ad as z,Bd as A,yd as x}from"./chunk-n2zmg475.js";function M(b,f={}){let j=B(b,f.sourceLocale);return G(E(b),j,(q)=>C(b,q,j))}function N(b,f){let j=Object.keys(f);return G(b,j,(q)=>{let v=f[q]??f[j[0]];if(!v)return{};return v().then((k)=>k.default)})}function G(b,f,j){let q={id:b,locales:f,load:j};x(q);let v=()=>x(q);return{id:b,locales:f,load:(k)=>{return v(),z(b,k)},loadForRender:(k)=>{return v(),A(b,k)},get:(k)=>{v();let w=z(b,k);if(w instanceof Promise){w.catch(()=>{});return}return w}}}
3
3
  export{M as aa,N as ba};
4
4
 
5
- //# debugId=1AA0AA71ECBDA10D64756E2164756E21
5
+ //# debugId=E19C726DB57A1DD264756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "import {\n dictionaryId,\n dictionaryLocales,\n localeStrings,\n type DictionaryTranslations,\n type LocaleStrings,\n} from \"./dictionaryShape\";\nimport {\n loadDictionary,\n loadDictionaryForRender,\n registerDictionary,\n} from \"./dictionaryRegistry\";\n\ndeclare const brand: unique symbol;\n\nexport interface DictionaryHandle<\n T extends DictionaryTranslations = DictionaryTranslations,\n> {\n readonly id: string;\n /** Locales this dictionary declares, source language first. */\n readonly locales: readonly string[];\n /**\n * Strings for `locale`. Synchronous when they are already in memory —\n * always, for an unbundled dictionary; after a preload or the SSR seed, for a\n * bundled one.\n */\n load(locale: string): LocaleStrings | Promise<LocaleStrings>;\n /**\n * `load`, but never rejecting — safe to hand React's `use()`. A failed locale\n * chunk resolves to no strings so the component degrades to rendering keys\n * instead of unmounting into an error boundary.\n */\n loadForRender(locale: string): LocaleStrings | Promise<LocaleStrings>;\n get(locale: string): LocaleStrings | undefined;\n /** Type-only: carries the literal's shape through to `useDictionary`. */\n readonly [brand]?: T;\n}\n\n/**\n * Declare the strings a component needs, next to the component.\n *\n * ```ts\n * export const homeDict = defineDictionary({\n * title: { \"en-US\": \"Welcome {{name}}\", \"tr-TR\": \"Hoş geldin {{name}}\" },\n * });\n * ```\n *\n * As written this holds every locale. Under gemi's Vite plugin the call is\n * rewritten so each locale becomes its own chunk and a page downloads only the\n * one it renders in — but the plugin is strictly an optimization, and the\n * behaviour is identical without it (in `bun test`, and in server code that\n * does not go through the bundler).\n *\n * The first locale in the literal is the source language: a key missing from\n * another locale falls back to it rather than rendering as its own key.\n */\nexport interface DefineDictionaryOptions {\n /**\n * The locale this dictionary is authored in. Keys missing from another locale\n * fall back to it, and it is what renders when the app has no locale\n * configured.\n *\n * Optional, but worth setting on any dictionary that is not uniformly\n * translated: without it the source language is whichever locale appears\n * first in the literal, so adding a key at the top can re-point every\n * fallback in the dictionary.\n */\n sourceLocale?: string;\n}\n\nexport function defineDictionary<const T extends DictionaryTranslations>(\n translations: T,\n options: DefineDictionaryOptions = {},\n): DictionaryHandle<T> {\n const locales = dictionaryLocales(translations, options.sourceLocale);\n return createHandle(dictionaryId(translations), locales, (locale) =>\n localeStrings(translations, locale, locales),\n );\n}\n\n/**\n * The rewritten form of a `defineDictionary` call — emitted by\n * `packages/gemi/vite/dictionaryPlugin.ts`, never written by hand. `loaders`\n * holds one dynamic import per locale so the bundler emits one chunk per\n * locale and the untaken ones never reach the browser.\n */\nexport function __gemi_dict__<\n const T extends DictionaryTranslations = DictionaryTranslations,\n>(\n id: string,\n loaders: Record<string, () => Promise<{ default: LocaleStrings }>>,\n): DictionaryHandle<T> {\n const locales = Object.keys(loaders);\n return createHandle(id, locales, (locale) => {\n // An unknown locale falls back to the source language, matching what\n // `localeStrings` does per key on the unbundled path.\n const load = loaders[locale] ?? loaders[locales[0]];\n if (!load) {\n return {};\n }\n return load().then((mod) => mod.default);\n });\n}\n\nfunction createHandle<T extends DictionaryTranslations>(\n id: string,\n locales: string[],\n load: (locale: string) => LocaleStrings | Promise<LocaleStrings>,\n): DictionaryHandle<T> {\n const entry = { id, locales, load };\n registerDictionary(entry);\n\n // Re-asserted on every read rather than only at construction. A handle is\n // created once, at module scope, but the registry it delegates to can be\n // emptied under it — a test's `afterEach` reset, an HMR boundary — and the\n // handle would then be permanently orphaned, throwing \"Unknown dictionary\"\n // for a dictionary the caller is holding. `registerDictionary` is a no-op\n // when the id is already there, so this costs one Map lookup.\n const ensure = () => registerDictionary(entry);\n\n return {\n id,\n locales,\n // Routed through the registry rather than calling `load` directly so\n // concurrent readers share one in-flight import and results are cached.\n load: (locale: string) => {\n ensure();\n return loadDictionary(id, locale);\n },\n loadForRender: (locale: string) => {\n ensure();\n return loadDictionaryForRender(id, locale);\n },\n get: (locale: string) => {\n ensure();\n const strings = loadDictionary(id, locale);\n if (strings instanceof Promise) {\n // Nothing downstream awaits this one — `get` is the synchronous peek,\n // and the caller is about to discard it. An unattached rejection (a\n // locale chunk that 404s mid-deploy) would surface as an\n // `unhandledRejection`, which under Node's default handler takes the\n // process down over one missing translation file. The load itself is\n // still cached and still retried through `loadDictionary`.\n strings.catch(() => {});\n return undefined;\n }\n return strings;\n },\n };\n}\n\n"
6
6
  ],
7
7
  "mappings": ";wHAsEO,GAAS,CAAwD,CACtE,EACA,EAAmC,CAAC,EACf,CACrB,IAAM,EAAU,EAAkB,EAAc,EAAQ,YAAY,EACpE,OAAO,EAAa,EAAa,CAAY,EAAG,EAAS,CAAC,IACxD,EAAc,EAAc,EAAQ,CAAO,CAC7C,EASK,SAAS,CAEf,CACC,EACA,EACqB,CACrB,IAAM,EAAU,OAAO,KAAK,CAAO,EACnC,OAAO,EAAa,EAAI,EAAS,CAAC,IAAW,CAG3C,IAAM,EAAO,EAAQ,IAAW,EAAQ,EAAQ,IAChD,GAAI,CAAC,EACH,MAAO,CAAC,EAEV,OAAO,EAAK,EAAE,KAAK,CAAC,IAAQ,EAAI,OAAO,EACxC,EAGH,SAAS,CAA8C,CACrD,EACA,EACA,EACqB,CACrB,IAAM,EAAQ,CAAE,KAAI,UAAS,MAAK,EAClC,EAAmB,CAAK,EAQxB,IAAM,EAAS,IAAM,EAAmB,CAAK,EAE7C,MAAO,CACL,KACA,UAGA,KAAM,CAAC,IAAmB,CAExB,OADA,EAAO,EACA,EAAe,EAAI,CAAM,GAElC,cAAe,CAAC,IAAmB,CAEjC,OADA,EAAO,EACA,EAAwB,EAAI,CAAM,GAE3C,IAAK,CAAC,IAAmB,CACvB,EAAO,EACP,IAAM,EAAU,EAAe,EAAI,CAAM,EACzC,GAAI,aAAmB,QAAS,CAO9B,EAAQ,MAAM,IAAM,EAAE,EACtB,OAEF,OAAO,EAEX",
8
- "debugId": "1AA0AA71ECBDA10D64756E2164756E21",
8
+ "debugId": "E19C726DB57A1DD264756E2164756E21",
9
9
  "names": []
10
10
  }