gemi 0.200.0 → 0.202.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.
- package/dist/ai/Agent.d.ts +48 -1
- package/dist/ai/Agent.d.ts.map +1 -1
- package/dist/ai/AgentProvider.d.ts +12 -0
- package/dist/ai/AgentProvider.d.ts.map +1 -1
- package/dist/ai/index.d.ts +2 -2
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +3 -3
- package/dist/ai/index.js.map +4 -4
- package/dist/ai/providers/request.d.ts +4 -0
- package/dist/ai/providers/request.d.ts.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-6xa5yqrw.js → chunk-07qjfj2c.js} +2 -2
- package/dist/{chunk-6xa5yqrw.js.map → chunk-07qjfj2c.js.map} +1 -1
- package/dist/{chunk-zpqcawmq.js → chunk-0a5png2z.js} +2 -2
- package/dist/{chunk-xb0k1br9.js.map → chunk-0a5png2z.js.map} +1 -1
- package/dist/{chunk-s9z0xxth.js → chunk-2816nz5e.js} +2 -2
- package/dist/{chunk-s9z0xxth.js.map → chunk-2816nz5e.js.map} +1 -1
- package/dist/{chunk-e7bb26fb.js → chunk-2n98hczh.js} +2 -2
- package/dist/{chunk-e7bb26fb.js.map → chunk-2n98hczh.js.map} +1 -1
- package/dist/{chunk-yw9mn5w7.js → chunk-3cd30c7k.js} +2 -2
- package/dist/{chunk-yw9mn5w7.js.map → chunk-3cd30c7k.js.map} +1 -1
- package/dist/{chunk-v2pt8h42.js → chunk-4jbrazr4.js} +2 -2
- package/dist/{chunk-v2pt8h42.js.map → chunk-4jbrazr4.js.map} +1 -1
- package/dist/{chunk-qf4fhwc9.js → chunk-5msb5ev6.js} +2 -2
- package/dist/{chunk-qf4fhwc9.js.map → chunk-5msb5ev6.js.map} +1 -1
- package/dist/{chunk-ahss6dcp.js → chunk-65r1ne8r.js} +2 -2
- package/dist/{chunk-ahss6dcp.js.map → chunk-65r1ne8r.js.map} +1 -1
- package/dist/{chunk-w84ke0bp.js → chunk-6a7kp98d.js} +2 -2
- package/dist/{chunk-w84ke0bp.js.map → chunk-6a7kp98d.js.map} +1 -1
- package/dist/{chunk-rh84xq17.js → chunk-6eywgbfz.js} +2 -2
- package/dist/{chunk-rh84xq17.js.map → chunk-6eywgbfz.js.map} +1 -1
- package/dist/{chunk-97g2qc7j.js → chunk-781k79x8.js} +1 -1
- package/dist/{chunk-rcnpjwp4.js → chunk-7881fdej.js} +2 -2
- package/dist/{chunk-rcnpjwp4.js.map → chunk-7881fdej.js.map} +1 -1
- package/dist/{chunk-2cyd3h4h.js → chunk-7gmkcgq0.js} +2 -2
- package/dist/{chunk-2cyd3h4h.js.map → chunk-7gmkcgq0.js.map} +1 -1
- package/dist/{chunk-n9k29mrs.js → chunk-7xwr52d8.js} +2 -2
- package/dist/{chunk-n9k29mrs.js.map → chunk-7xwr52d8.js.map} +1 -1
- package/dist/{chunk-wxb2pqqz.js → chunk-87f4gan9.js} +2 -2
- package/dist/{chunk-wxb2pqqz.js.map → chunk-87f4gan9.js.map} +1 -1
- package/dist/{chunk-206n0q1f.js → chunk-9k3axdsb.js} +2 -2
- package/dist/{chunk-206n0q1f.js.map → chunk-9k3axdsb.js.map} +1 -1
- package/dist/{chunk-tyvc46ns.js → chunk-9kmh038f.js} +2 -2
- package/dist/{chunk-tyvc46ns.js.map → chunk-9kmh038f.js.map} +1 -1
- package/dist/{chunk-zwbpcch0.js → chunk-a2ybf4jf.js} +1 -1
- package/dist/{chunk-42b6zzg2.js → chunk-a5fvqc4k.js} +2 -2
- package/dist/{chunk-42b6zzg2.js.map → chunk-a5fvqc4k.js.map} +1 -1
- package/dist/{chunk-xxep62yg.js → chunk-a6hac7pd.js} +1 -1
- package/dist/{chunk-w09wtxr6.js → chunk-a9cztxee.js} +3 -3
- package/dist/{chunk-w09wtxr6.js.map → chunk-a9cztxee.js.map} +1 -1
- package/dist/{chunk-ct1vh28z.js → chunk-bs6nxaqa.js} +2 -2
- package/dist/{chunk-ct1vh28z.js.map → chunk-bs6nxaqa.js.map} +1 -1
- package/dist/{chunk-tjsv6e3a.js → chunk-bz3527wx.js} +2 -2
- package/dist/{chunk-tjsv6e3a.js.map → chunk-bz3527wx.js.map} +1 -1
- package/dist/{chunk-6ftdsrkq.js → chunk-c8041bgj.js} +2 -2
- package/dist/{chunk-6ftdsrkq.js.map → chunk-c8041bgj.js.map} +1 -1
- package/dist/{chunk-xb0k1br9.js → chunk-cwxjqfkx.js} +2 -2
- package/dist/{chunk-zpqcawmq.js.map → chunk-cwxjqfkx.js.map} +1 -1
- package/dist/{chunk-8nmcyavt.js → chunk-dh8jqx0k.js} +2 -2
- package/dist/{chunk-8nmcyavt.js.map → chunk-dh8jqx0k.js.map} +1 -1
- package/dist/{chunk-ff22412e.js → chunk-e3bwytc2.js} +4 -4
- package/dist/{chunk-ff22412e.js.map → chunk-e3bwytc2.js.map} +1 -1
- package/dist/{chunk-mxt88hhp.js → chunk-e9w2yzd2.js} +2 -2
- package/dist/{chunk-mxt88hhp.js.map → chunk-e9w2yzd2.js.map} +1 -1
- package/dist/{chunk-50nex9wg.js → chunk-evaeb75q.js} +3 -3
- package/dist/{chunk-50nex9wg.js.map → chunk-evaeb75q.js.map} +1 -1
- package/dist/{chunk-nnaz5djg.js → chunk-fdcay8np.js} +2 -2
- package/dist/{chunk-nnaz5djg.js.map → chunk-fdcay8np.js.map} +1 -1
- package/dist/{chunk-gx2fhmnx.js → chunk-h1fqgz82.js} +3 -3
- package/dist/{chunk-gx2fhmnx.js.map → chunk-h1fqgz82.js.map} +1 -1
- package/dist/{chunk-93j09zw7.js → chunk-h2ysbsax.js} +1 -1
- package/dist/{chunk-drb6gpgv.js → chunk-h7h8ra65.js} +1 -1
- package/dist/{chunk-c9259a9e.js → chunk-hd8gymeg.js} +2 -2
- package/dist/{chunk-c9259a9e.js.map → chunk-hd8gymeg.js.map} +1 -1
- package/dist/{chunk-n3p16jpb.js → chunk-hra8evrw.js} +3 -3
- package/dist/{chunk-n3p16jpb.js.map → chunk-hra8evrw.js.map} +1 -1
- package/dist/{chunk-dqgn4wgf.js → chunk-j43hftgw.js} +2 -2
- package/dist/{chunk-dqgn4wgf.js.map → chunk-j43hftgw.js.map} +1 -1
- package/dist/{chunk-txbram9h.js → chunk-m3nhdg9v.js} +2 -2
- package/dist/{chunk-txbram9h.js.map → chunk-m3nhdg9v.js.map} +1 -1
- package/dist/{chunk-bdbg2dt6.js → chunk-mq82r0qp.js} +2 -2
- package/dist/{chunk-bdbg2dt6.js.map → chunk-mq82r0qp.js.map} +1 -1
- package/dist/{chunk-pab6ye4d.js → chunk-n7bz2283.js} +2 -2
- package/dist/{chunk-pab6ye4d.js.map → chunk-n7bz2283.js.map} +1 -1
- package/dist/{chunk-e603nm1c.js → chunk-p96z3yb6.js} +2 -2
- package/dist/{chunk-e603nm1c.js.map → chunk-p96z3yb6.js.map} +1 -1
- package/dist/{chunk-0kfrwbhg.js → chunk-phszs9ea.js} +4 -4
- package/dist/{chunk-0kfrwbhg.js.map → chunk-phszs9ea.js.map} +1 -1
- package/dist/{chunk-503ce1t9.js → chunk-ptbrbp80.js} +2 -2
- package/dist/{chunk-503ce1t9.js.map → chunk-ptbrbp80.js.map} +1 -1
- package/dist/{chunk-8fzcs8dv.js → chunk-qz7v6271.js} +2 -2
- package/dist/{chunk-8fzcs8dv.js.map → chunk-qz7v6271.js.map} +1 -1
- package/dist/{chunk-kz15j07h.js → chunk-sw7c95nh.js} +2 -2
- package/dist/{chunk-kz15j07h.js.map → chunk-sw7c95nh.js.map} +1 -1
- package/dist/{chunk-61mcmhjp.js → chunk-tbt2j0rf.js} +1 -1
- package/dist/{chunk-6nr97atn.js → chunk-wn9e8bjn.js} +2 -2
- package/dist/{chunk-6nr97atn.js.map → chunk-wn9e8bjn.js.map} +1 -1
- package/dist/chunk-wxcbfqkd.js +5 -0
- package/dist/chunk-wxcbfqkd.js.map +13 -0
- package/dist/{chunk-2kkv8515.js → chunk-x2zw82xg.js} +26 -26
- package/dist/{chunk-2kkv8515.js.map → chunk-x2zw82xg.js.map} +3 -3
- package/dist/{chunk-q1zj3a0e.js → chunk-x41vw44z.js} +2 -2
- package/dist/{chunk-q1zj3a0e.js.map → chunk-x41vw44z.js.map} +1 -1
- package/dist/chunk-xhky6kyf.js +5 -0
- package/dist/chunk-xhky6kyf.js.map +10 -0
- package/dist/{chunk-y167pt0p.js → chunk-y0gaw9ez.js} +2 -2
- package/dist/{chunk-y167pt0p.js.map → chunk-y0gaw9ez.js.map} +1 -1
- package/dist/{chunk-84stff4t.js → chunk-y9ktwyrx.js} +1 -1
- package/dist/{chunk-6brwvyrz.js → chunk-zgg2xsxp.js} +2 -2
- package/dist/{chunk-6brwvyrz.js.map → chunk-zgg2xsxp.js.map} +1 -1
- package/dist/{chunk-4reyxar1.js → chunk-zhmc2jm4.js} +1 -1
- package/dist/{chunk-xhc16pv1.js → chunk-zmj4fj4n.js} +1 -1
- package/dist/chunks/{RealtimeClient-DmBC8zxt.js → RealtimeClient-BnNSz8AK.js} +2 -2
- package/dist/chunks/{RealtimeClient-DmBC8zxt.js.map → RealtimeClient-BnNSz8AK.js.map} +1 -1
- package/dist/chunks/{ThemeProvider-BTVQYl5O.js → ThemeProvider-CoQ-vnvy.js} +9 -6
- package/dist/chunks/{ThemeProvider-BTVQYl5O.js.map → ThemeProvider-CoQ-vnvy.js.map} +1 -1
- package/dist/chunks/{fetchFileRequest-BHCSZqKL.js → fetchFileRequest-Bhp0oJ0T.js} +2 -2
- package/dist/chunks/{fetchFileRequest-BHCSZqKL.js.map → fetchFileRequest-Bhp0oJ0T.js.map} +1 -1
- package/dist/chunks/{live-DIj7rF0t.js → live-Dt8sq9W4.js} +3 -3
- package/dist/chunks/{live-DIj7rF0t.js.map → live-Dt8sq9W4.js.map} +1 -1
- package/dist/chunks/{mutationExtras-BRFfb6-L.js → mutationExtras-ChOGPZlY.js} +2 -2
- package/dist/chunks/{mutationExtras-BRFfb6-L.js.map → mutationExtras-ChOGPZlY.js.map} +1 -1
- package/dist/chunks/{subscriptionStream-CRRgUXJp.js → subscriptionStream-DDl_H-QM.js} +2 -2
- package/dist/chunks/{subscriptionStream-CRRgUXJp.js.map → subscriptionStream-DDl_H-QM.js.map} +1 -1
- package/dist/client/index.js +4 -4
- package/dist/client/scrollRestoration.d.ts +5 -2
- package/dist/client/scrollRestoration.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +1 -1
- package/dist/database/index.js +1 -1
- package/dist/email/index.js +1 -1
- package/dist/facades/index.js +1 -1
- package/dist/foundation/Application.d.ts +23 -3
- package/dist/foundation/Application.d.ts.map +1 -1
- package/dist/foundation/index.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/i18n/dictionaryRuntime.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/kernel/Kernel.d.ts.map +1 -1
- package/dist/kernel/index.js +3 -3
- package/dist/kernel/index.js.map +3 -3
- package/dist/orm/index.js +1 -1
- package/dist/probe/index.js +2 -2
- package/dist/probe/index.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +2 -2
- package/dist/server/shutdown.d.ts +35 -0
- package/dist/server/shutdown.d.ts.map +1 -1
- package/dist/services/index.js +2 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/queue/WorkerProcess.d.ts.map +1 -1
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +3 -3
- package/dist/stats/route-table.js +1 -1
- package/dist/support/Service.d.ts +21 -0
- package/dist/support/Service.d.ts.map +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +3 -3
- package/dist/testing/index.js +2 -2
- package/dist/vitest/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-1yq2b55s.js +0 -5
- package/dist/chunk-1yq2b55s.js.map +0 -10
- package/dist/chunk-jkf5kjaz.js +0 -5
- package/dist/chunk-jkf5kjaz.js.map +0 -13
- /package/dist/{chunk-97g2qc7j.js.map → chunk-781k79x8.js.map} +0 -0
- /package/dist/{chunk-zwbpcch0.js.map → chunk-a2ybf4jf.js.map} +0 -0
- /package/dist/{chunk-xxep62yg.js.map → chunk-a6hac7pd.js.map} +0 -0
- /package/dist/{chunk-93j09zw7.js.map → chunk-h2ysbsax.js.map} +0 -0
- /package/dist/{chunk-drb6gpgv.js.map → chunk-h7h8ra65.js.map} +0 -0
- /package/dist/{chunk-61mcmhjp.js.map → chunk-tbt2j0rf.js.map} +0 -0
- /package/dist/{chunk-84stff4t.js.map → chunk-y9ktwyrx.js.map} +0 -0
- /package/dist/{chunk-4reyxar1.js.map → chunk-zhmc2jm4.js.map} +0 -0
- /package/dist/{chunk-xhc16pv1.js.map → chunk-zmj4fj4n.js.map} +0 -0
package/dist/kernel/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Fa as E}from"../chunk-81m95se9.js";import{ab as
|
|
2
|
+
import{Fa as E}from"../chunk-81m95se9.js";import{ab as l}from"../chunk-y9ktwyrx.js";import{bb as H}from"../chunk-ccpp45dm.js";import{Cb as L,Db as Q,Eb as T,Ib as U,Jb as y,Kb as F,Lb as C,Mb as D,Nb as I,Qb as b,Tb as f,Ub as k,Vb as m,ob as g,pb as W,qb as _,rb as p,sb as P,tb as u,ub as $,vb as V,wb as q,xb as B,yb as K}from"../chunk-e9w2yzd2.js";import"../chunk-x2zw82xg.js";import"../chunk-n7bz2283.js";import"../chunk-mndcq5z1.js";import{de as h}from"../chunk-a2ybf4jf.js";import"../chunk-mzqhn72h.js";import"../chunk-vqq0z746.js";import{Ge as d,He as s,Jg as w,Ng as A,Rg as R,af as n,bf as v}from"../chunk-e3bwytc2.js";import"../chunk-ewknbs3b.js";import"../chunk-bxxd1awv.js";import"../chunk-j43hftgw.js";import"../chunk-vpqzzrkn.js";import"../chunk-b2n74m40.js";import"../chunk-zmj4fj4n.js";import{Hj as M}from"../chunk-sw7c95nh.js";import"../chunk-sg78cmd1.js";import"../chunk-yxge0cem.js";import"../chunk-mddazdpt.js";import"../chunk-bcfcwbp4.js";import"../chunk-64hxqsqx.js";import"../chunk-t0qs2q9j.js";import"../chunk-agc5bqdt.js";import"../chunk-3cd30c7k.js";import"../chunk-t4z6rkvw.js";import{Al as J,yl as O}from"../chunk-wxcbfqkd.js";import"../chunk-ha4er085.js";import"../chunk-by0afyps.js";import"../chunk-xhky6kyf.js";import"../chunk-65r1ne8r.js";import"../chunk-y0gaw9ez.js";import"../chunk-0a5png2z.js";var N=[C,I,E,T,L,k,B,Q,D,y,_,U,f,V,F,H,b,K,q,m,$];class S{config={};providers=[];services=[];serviceInstances=[];serviceTokens=new Set;servicesBooted=!1;models=[];app=new J;boot(){if(this.models.length>0)l(...this.models);else a();this.app.config.merge(this.config),J.setInstance(this.app),this.app.registerMany([...N,...this.providers]),this.registerServices()}registerServices(){let j=this.serviceTokens;this.serviceInstances=[],this.serviceTokens=new Set,this.servicesBooted=!1;let X=new Map;for(let z of this.services){let G=typeof z==="function"?new z:z,x=G.constructor;if(!x.token)throw Error(`Service [${x.name}] is listed in \`services\` but does not declare a \`static token\`.`);let Y=X.get(x.token);if(Y)throw Error(`Services [${Y}] and [${x.name}] both declare the token "${x.token}". Tokens are the container's keys, so they must be unique.`);X.set(x.token,x.name);let Z=x;if(!j.has(x.token)&&this.app.bound(Z))throw Error(`Service [${x.name}] declares the token "${x.token}", which is already bound in the container by the framework or a provider. Binding it would replace that service everywhere, so pick a token nothing else owns.`);this.app.instance(Z,G),this.serviceInstances.push(G),this.serviceTokens.add(x.token)}this.app.setShutdownHooks(this.serviceInstances.map((z)=>({name:`${z.constructor.name}.onShutdown`,shutdown:(G)=>z.onShutdown(G)})))}async waitForBoot(){await this.app.boot(),await this.bootServices(),p(this.app)}async bootServices(){if(this.servicesBooted)return;for(let j of this.serviceInstances)await j.boot();this.servicesBooted=!0}shutdown(j){return this.run(()=>this.app.shutdown(j))}run(j){return O.run(this.app,j)}resolve(j){return this.app.make(j)}apiRoutes(){return this.app.make(A)}viewRoutes(){return this.app.make(w)}domains(){return this.app.make(R)}queue(){return this.app.make(h)}mcpHttp(){return this.app.config.get("route.mcp.remote.enabled")===!0?this.app.make(g):null}sockets(){return this.app.config.get("route.channels")?this.app.make(u):null}globalMiddleware(j){return P(j)}destroy(){if(this.app.resolved(W))this.app.make(W).stop();if(this.app.flush(),J.getInstance()===this.app)J.setInstance(void 0);O.disable()}}function a(){if(Bun.env.NODE_ENV==="production")return;let j=M();if(j.length===0)return;console.warn(`[gemi] ${j.length} model${j.length===1?" is":"s are"} registered, but Kernel.models is empty.
|
|
3
3
|
Nested relation reads resolve a model by name, so a policy on a subclass that does not own its
|
|
4
4
|
`+" name is skipped inside every include \u2014 scoped at the root, "+`unscoped in an include, with nothing
|
|
5
5
|
to notice it. Declaring the modules registers each class under its own name and audits the set:
|
|
@@ -11,6 +11,6 @@ import{Fa as E}from"../chunk-81m95se9.js";import{ab as p}from"../chunk-84stff4t.
|
|
|
11
11
|
models = [generated, models]
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
See docs/orm.md#your-model-class. Development only; this never prints in production.`)}export{
|
|
14
|
+
See docs/orm.md#your-model-class. Development only; this never prints in production.`)}export{s as oneTimeSecretMatches,d as hashOneTimeSecret,N as frameworkProviders,v as UserProvider,n as SESSION_SELECT,S as Kernel};
|
|
15
15
|
|
|
16
|
-
//# debugId=
|
|
16
|
+
//# debugId=C86FB45AFCB9BBE464756E2164756E21
|
package/dist/kernel/index.js.map
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"sources": ["../kernel/providers.ts", "../kernel/Kernel.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { ServiceProviderConstructor } from \"../foundation/Application\";\nimport { BroadcastServiceProvider } from \"../services/broadcast/BroadcastServiceProvider\";\nimport { CacheServiceProvider } from \"../services/cache/CacheServiceProvider\";\nimport { ChangeFeedServiceProvider } from \"../services/change-feed/ChangeFeedServiceProvider\";\nimport { AuthServiceProvider } from \"../auth/AuthServiceProvider\";\nimport { DatabaseServiceProvider } from \"../database/DatabaseServiceProvider\";\nimport { TranslationServiceProvider } from \"../i18n/TranslationServiceProvider\";\nimport { ScheduleServiceProvider } from \"../services/cron/ScheduleServiceProvider\";\nimport { FeaturesServiceProvider } from \"../services/features/FeaturesServiceProvider\";\nimport { MailServiceProvider } from \"../services/email/MailServiceProvider\";\nimport { EncryptionServiceProvider } from \"../services/encryption/EncryptionServiceProvider\";\nimport { EventServiceProvider } from \"../services/events/EventServiceProvider\";\nimport { FilesystemServiceProvider } from \"../services/file-storage/FilesystemServiceProvider\";\nimport { ImageServiceProvider } from \"../services/image-optimization/ImageServiceProvider\";\nimport { KernelIdServiceProvider } from \"../services/kernel-id/KernelIdServiceProvider\";\nimport { LogServiceProvider } from \"../services/logging/LogServiceProvider\";\nimport { MiddlewareServiceProvider } from \"../services/middleware/MiddlewareServiceProvider\";\nimport { QueueServiceProvider } from \"../services/queue/QueueServiceProvider\";\nimport { RateLimiterServiceProvider } from \"../services/rate-limiter/RateLimiterServiceProvider\";\nimport { RedisServiceProvider } from \"../services/redis/RedisServiceProvider\";\nimport { RouteServiceProvider } from \"../services/router/RouteServiceProvider\";\nimport { RunsServiceProvider } from \"../services/runs/RunsServiceProvider\";\n\n/**\n * The providers every gemi app boots with, in registration order. Twenty\n * providers for twenty-one services — `RouteServiceProvider` owns both the api\n * and the view dispatcher, the way Laravel's does.\n *\n * Order only matters for `boot()`; `register()` binds factories and resolves\n * nothing, so no provider here depends on an earlier one having run — with one\n * exception, which is the reason to read this before reordering anything.\n *\n * **`EventServiceProvider` must stay after `QueueServiceProvider`.** A queued\n * listener is registered with the queue as a synthetic job, and\n * `EventServiceProvider.boot()` is what hands those over. `QueueManager.useJobs`\n * — which `QueueServiceProvider.boot()` calls with whatever it discovered under\n * `app/jobs` — *replaces* the registry (`this.jobs = {}`). Move the events\n * provider up and the two boots run in the order that discards: every\n * `listener:*` entry is registered and then thrown away. Nothing errors, boot\n * succeeds, and each queued dispatch afterwards lands on `next()`'s \"Dropped a\n * queued job: nothing is registered under the name listener:SendWelcomeEmail\",\n * long after `dispatch` returned to a caller that cannot hear it.\n */\nexport const frameworkProviders: ServiceProviderConstructor[] = [\n KernelIdServiceProvider,\n MiddlewareServiceProvider,\n DatabaseServiceProvider,\n // Before anything that reads a model at boot (the features cache warm-up),\n // so a missing key for an encrypted column fails the boot with its own\n // message rather than inside someone else's query.\n EncryptionServiceProvider,\n // After the database, whose `boot()` its cache warm-up depends on, and before\n // the route dispatchers, which evaluate flags on every view request.\n FeaturesServiceProvider,\n RouteServiceProvider,\n AuthServiceProvider,\n MailServiceProvider,\n LogServiceProvider,\n FilesystemServiceProvider,\n QueueServiceProvider,\n EventServiceProvider,\n RedisServiceProvider,\n CacheServiceProvider,\n ImageServiceProvider,\n TranslationServiceProvider,\n RateLimiterServiceProvider,\n ScheduleServiceProvider,\n ChangeFeedServiceProvider,\n RunsServiceProvider,\n BroadcastServiceProvider,\n];\n",
|
|
6
|
-
"import { McpHttpServer } from \"../services/mcp/http/McpHttpServer\";\nimport { Application } from \"../foundation/Application\";\nimport type { ServiceProviderConstructor, ShutdownReport } from \"../foundation/Application\";\nimport type { ServiceToken } from \"../container/Container\";\nimport type { ConfigItems } from \"../support/Repository\";\nimport type { Service, ServiceConstructor } from \"../support/Service\";\nimport { registerModels } from \"../orm/registration\";\nimport { registeredNames } from \"../orm/registry\";\nimport { Scheduler } from \"../services/cron/Scheduler\";\nimport { QueueManager } from \"../services/queue/QueueManager\";\nimport { startClaimingIfServing } from \"../services/queue/QueueServiceProvider\";\nimport { ApiRouteDispatcher } from \"../services/router/ApiRouteDispatcher\";\nimport { ViewRouteDispatcher } from \"../services/router/ViewRouteDispatcher\";\nimport { DomainRouter } from \"../services/router/DomainRouter\";\nimport { runGlobalMiddleware } from \"../services/router/globalMiddleware\";\nimport { SocketHub } from \"../services/broadcast/SocketHub\";\nimport { kernelContext } from \"./context\";\nimport { frameworkProviders } from \"./providers\";\n\n/**\n * The app's entry point into the framework. A Kernel subclass declares what the\n * app adds — its `config` slices and any extra `providers` — and everything\n * else lives in the Application container it owns.\n */\nexport class Kernel {\n /**\n * App-level config, merged over the framework defaults. Each key is a config\n * slice: `{ mail: { ... }, route: { ... } }`, normally the modules under\n * `app/config`.\n */\n protected config: ConfigItems = {};\n\n /**\n * App-level providers, registered after the framework's own so they can\n * rebind anything the framework bound.\n */\n protected providers: ServiceProviderConstructor[] = [];\n\n /**\n * The app's own singleton services. Each is constructed during the\n * synchronous boot phase and its `boot()` awaited during the asynchronous\n * one, in the order listed — so a service whose `boot()` depends on another\n * goes after it.\n *\n * An entry is either the class itself or a configured instance from\n * `Service.with({ ... })`. Listing is explicit rather than discovered because\n * the order is load-bearing here, and because a service is always imported by\n * whatever injects it — there is no file the import graph would miss.\n */\n protected services: Array<ServiceConstructor | Service> = [];\n\n private serviceInstances: Service[] = [];\n private serviceTokens = new Set<string>();\n private servicesBooted = false;\n\n /**\n * The modules holding the app's model classes — normally\n * `[generated, models]`, the generated namespace and the barrel of subclasses\n * written over it. Every model class they export is registered under the name\n * its schema carries, later modules winning, and the whole set is audited\n * before anything else boots.\n *\n * ### Why this is a Kernel field and not a line in a file somewhere\n *\n * Registration used to be `register(\"User\", User)` next to each subclass, and\n * the failure mode of forgetting it is an authorization hole that nothing\n * reports: a relation read resolves its target by name, so an unregistered\n * policied subclass leaves the generated base owning the name and every\n * nested `include` of that model comes back unscoped. No error at the root\n * either, because `$exec`'s divergence guard begins `registered !== this` and\n * the base it is running on *is* the registered one. A model only ever read\n * through an include — a membership, a pivot, the kind that carries a tenant\n * scope — never trips anything.\n *\n * Listing the modules here says it once, in the same place the app already\n * declares its config slices and providers, and turns the mistake into a\n * failure to boot rather than a quiet cross-tenant read.\n *\n * It sees the modules it is given, so a model class in a file that no barrel\n * re-exports is still invisible. That is the residual, and it is a smaller\n * one: a barrel is a place to notice an omission, and thirteen `register`\n * lines scattered across thirteen files is not.\n */\n protected models: Array<Record<string, unknown>> = [];\n\n readonly app = new Application();\n\n /**\n * Phase one, synchronous: every provider is constructed and its `register()`\n * runs. Only bindings are recorded here — no service is instantiated, so this\n * is safe to call from a synchronous constructor (`new App({ kernel })`).\n * Phase two is `waitForBoot()`.\n */\n boot() {\n // Before the container, deliberately. This throws on a model whose policies\n // would be skipped, and the useful moment for that is the one where nothing\n // has been constructed and no request can be in flight.\n if (this.models.length > 0) registerModels(...this.models);\n else warnIfModelsAreRegisteredButUndeclared();\n\n this.app.config.merge(this.config);\n Application.setInstance(this.app);\n this.app.registerMany([...frameworkProviders, ...this.providers]);\n this.registerServices();\n }\n\n /**\n * Constructs every listed service and binds it into the container. Runs after\n * the providers have registered, so a provider's `boot()` can `inject()` one;\n * a `Service` constructor does no I/O, so doing this synchronously costs\n * nothing beyond the field initializers.\n */\n private registerServices() {\n // What a previous pass bound, so re-running this on the same kernel is not\n // mistaken for a collision with something else.\n const ours = this.serviceTokens;\n\n this.serviceInstances = [];\n this.serviceTokens = new Set();\n this.servicesBooted = false;\n\n const owners = new Map<string, string>();\n\n for (const declaration of this.services) {\n const instance =\n typeof declaration === \"function\" ? new declaration() : declaration;\n const ctor = instance.constructor as ServiceConstructor;\n\n if (!ctor.token) {\n throw new Error(\n `Service [${ctor.name}] is listed in \\`services\\` but does not declare a \\`static token\\`.`,\n );\n }\n\n // Two services under one token is the failure this refuses to have\n // silently: the second would replace the first in the container, and\n // every `inject()` written against either would hand back whichever was\n // listed last.\n const owner = owners.get(ctor.token);\n if (owner) {\n throw new Error(\n `Services [${owner}] and [${ctor.name}] both declare the token \"${ctor.token}\". Tokens are the container's keys, so they must be unique.`,\n );\n }\n owners.set(ctor.token, ctor.name);\n\n // The same failure one level out. `Container.instance()` writes into\n // `instances`, which `make()` consults before `bindings`, so a token that\n // is already spoken for is not shared with its owner — it replaces it, for\n // every `app()` and `inject()` in the process. An app service that named\n // itself \"mail\" would leave `Mail.send()` resolving to an object with no\n // `send`, and the boot that caused it would report nothing. Providers have\n // all registered by now, so anything bound here belongs to somebody else.\n const token = ctor as unknown as ServiceToken<Service>;\n if (!ours.has(ctor.token) && this.app.bound(token)) {\n throw new Error(\n `Service [${ctor.name}] declares the token \"${ctor.token}\", which is already bound in the container by the framework or a provider. Binding it would replace that service everywhere, so pick a token nothing else owns.`,\n );\n }\n\n this.app.instance(token, instance);\n this.serviceInstances.push(instance);\n this.serviceTokens.add(ctor.token);\n }\n }\n\n /**\n * Phase two, asynchronous: every provider's `boot()` runs, in registration\n * order, after all of them have registered. Idempotent.\n */\n async waitForBoot() {\n await this.app.boot();\n await this.bootServices();\n // Last, once every job — queued listeners included — is registered.\n startClaimingIfServing(this.app);\n }\n\n /**\n * Phase two for services, after every provider's `boot()` — so a service may\n * use the facades and anything else a provider owns. Idempotent, like the\n * provider phase it follows.\n */\n private async bootServices() {\n if (this.servicesBooted) {\n return;\n }\n for (const service of this.serviceInstances) {\n await service.boot();\n }\n this.servicesBooted = true;\n }\n\n /**\n * Every provider's `shutdown()`, in reverse registration order, inside the\n * application context — so a hook may use the facades, as a cron tick or a\n * request would. See `Application.shutdown` for the deadline and the\n * report. Idempotent.\n */\n shutdown(options?: { timeoutMs?: number }): Promise<ShutdownReport> {\n return this.run(() => this.app.shutdown(options));\n }\n\n run<T>(cb: () => T) {\n return kernelContext.run(this.app, cb);\n }\n\n /**\n * Resolve a service by token. Callers outside this module should prefer the\n * named accessors below or `app()`; this exists for tooling that holds a\n * Kernel but no ambient context.\n */\n resolve<T>(token: ServiceToken<T>): T {\n return this.app.make(token);\n }\n\n // Named accessors. `app/App.ts` goes through these rather than importing the\n // service classes itself — see the note in that file about the two copies of\n // gemi that coexist at build time.\n apiRoutes(): ApiRouteDispatcher {\n return this.app.make(ApiRouteDispatcher);\n }\n\n viewRoutes(): ViewRouteDispatcher {\n return this.app.make(ViewRouteDispatcher);\n }\n\n domains(): DomainRouter {\n return this.app.make(DomainRouter);\n }\n\n queue(): QueueManager {\n return this.app.make(QueueManager);\n }\n\n /** The MCP endpoint, or `null` when `route.mcp.remote` is not enabled. */\n mcpHttp(): McpHttpServer | null {\n return this.app.config.get(\"route.mcp.remote.enabled\") === true\n ? this.app.make(McpHttpServer)\n : null;\n }\n\n /**\n * The broadcast WebSocket endpoint, or `null` when the app declares no\n * `route.channels` (nothing could be subscribed to, so nothing is upgraded).\n */\n sockets(): SocketHub | null {\n return this.app.config.get(\"route.channels\") ? this.app.make(SocketHub) : null;\n }\n\n /** The `global` middleware list for one request. Call it inside `run`. */\n globalMiddleware(req: Request) {\n return runGlobalMiddleware(req);\n }\n\n destroy() {\n // Only touch services that were actually resolved — resolving one here\n // would construct it purely to tear it down.\n if (this.app.resolved(Scheduler)) {\n this.app.make(Scheduler).stop();\n }\n\n this.app.flush();\n\n if (Application.getInstance() === this.app) {\n Application.setInstance(undefined);\n }\n\n kernelContext.disable();\n }\n}\n\n/**\n * Says something to an application that has models and has not declared them.\n *\n * Without this the fix for #316 defaults to off. `models` is `[]`, `boot()`\n * no-ops, and an app upgrading from 0.48 is in exactly the state the issue\n * describes until somebody edits their Kernel by hand — while the only place\n * that says to is the **Setup** section of `docs/orm.md`, which an existing app\n * read once and will not read again. #316 was filed by an app mid-migration\n * with a 79-model schema, which is precisely the reader who never sees it.\n *\n * The condition is what makes this worth printing. A populated registry with an\n * empty `models` means the generated `index.ts` was imported and its bases are\n * what every nested read resolves to — so if any policy lives on a subclass, it\n * is being skipped inside includes right now. A Kernel with no ORM at all has\n * an empty registry and hears nothing.\n *\n * Development only, and a warning rather than a throw: an app in this state is\n * running today, and turning a working deploy into a failure to start over an\n * arrangement that *might* be fine is not a patch-level thing to do. The\n * failure it points at is silent, so the fix for it has to be noisy somewhere,\n * and the terminal an author is already looking at is the cheapest somewhere\n * there is.\n */\nfunction warnIfModelsAreRegisteredButUndeclared(): void {\n if (process.env.NODE_ENV === \"production\") return;\n\n const registered = registeredNames();\n if (registered.length === 0) return;\n\n console.warn(\n `[gemi] ${registered.length} model${registered.length === 1 ? \" is\" : \"s are\"} ` +\n `registered, but Kernel.models is empty.\\n` +\n ` Nested relation reads resolve a model by name, so a policy on a ` +\n `subclass that does not own its\\n` +\n ` name is skipped inside every include — scoped at the root, ` +\n `unscoped in an include, with nothing\\n` +\n ` to notice it. Declaring the modules registers each class under ` +\n `its own name and audits the set:\\n\\n` +\n ` import * as generated from \"../models/generated\"\\n` +\n ` import * as models from \"../models\"\\n\\n` +\n ` export default class extends Kernel {\\n` +\n ` models = [generated, models]\\n` +\n ` }\\n\\n` +\n ` See docs/orm.md#your-model-class. Development only; this never ` +\n `prints in production.`,\n );\n}\n"
|
|
6
|
+
"import { McpHttpServer } from \"../services/mcp/http/McpHttpServer\";\nimport { Application } from \"../foundation/Application\";\nimport type { ServiceProviderConstructor, ShutdownReport } from \"../foundation/Application\";\nimport type { ServiceToken } from \"../container/Container\";\nimport type { ConfigItems } from \"../support/Repository\";\nimport type { Service, ServiceConstructor } from \"../support/Service\";\nimport { registerModels } from \"../orm/registration\";\nimport { registeredNames } from \"../orm/registry\";\nimport { Scheduler } from \"../services/cron/Scheduler\";\nimport { QueueManager } from \"../services/queue/QueueManager\";\nimport { startClaimingIfServing } from \"../services/queue/QueueServiceProvider\";\nimport { ApiRouteDispatcher } from \"../services/router/ApiRouteDispatcher\";\nimport { ViewRouteDispatcher } from \"../services/router/ViewRouteDispatcher\";\nimport { DomainRouter } from \"../services/router/DomainRouter\";\nimport { runGlobalMiddleware } from \"../services/router/globalMiddleware\";\nimport { SocketHub } from \"../services/broadcast/SocketHub\";\nimport { kernelContext } from \"./context\";\nimport { frameworkProviders } from \"./providers\";\n\n/**\n * The app's entry point into the framework. A Kernel subclass declares what the\n * app adds — its `config` slices and any extra `providers` — and everything\n * else lives in the Application container it owns.\n */\nexport class Kernel {\n /**\n * App-level config, merged over the framework defaults. Each key is a config\n * slice: `{ mail: { ... }, route: { ... } }`, normally the modules under\n * `app/config`.\n */\n protected config: ConfigItems = {};\n\n /**\n * App-level providers, registered after the framework's own so they can\n * rebind anything the framework bound.\n */\n protected providers: ServiceProviderConstructor[] = [];\n\n /**\n * The app's own singleton services. Each is constructed during the\n * synchronous boot phase and its `boot()` awaited during the asynchronous\n * one, in the order listed — so a service whose `boot()` depends on another\n * goes after it.\n *\n * An entry is either the class itself or a configured instance from\n * `Service.with({ ... })`. Listing is explicit rather than discovered because\n * the order is load-bearing here, and because a service is always imported by\n * whatever injects it — there is no file the import graph would miss.\n */\n protected services: Array<ServiceConstructor | Service> = [];\n\n private serviceInstances: Service[] = [];\n private serviceTokens = new Set<string>();\n private servicesBooted = false;\n\n /**\n * The modules holding the app's model classes — normally\n * `[generated, models]`, the generated namespace and the barrel of subclasses\n * written over it. Every model class they export is registered under the name\n * its schema carries, later modules winning, and the whole set is audited\n * before anything else boots.\n *\n * ### Why this is a Kernel field and not a line in a file somewhere\n *\n * Registration used to be `register(\"User\", User)` next to each subclass, and\n * the failure mode of forgetting it is an authorization hole that nothing\n * reports: a relation read resolves its target by name, so an unregistered\n * policied subclass leaves the generated base owning the name and every\n * nested `include` of that model comes back unscoped. No error at the root\n * either, because `$exec`'s divergence guard begins `registered !== this` and\n * the base it is running on *is* the registered one. A model only ever read\n * through an include — a membership, a pivot, the kind that carries a tenant\n * scope — never trips anything.\n *\n * Listing the modules here says it once, in the same place the app already\n * declares its config slices and providers, and turns the mistake into a\n * failure to boot rather than a quiet cross-tenant read.\n *\n * It sees the modules it is given, so a model class in a file that no barrel\n * re-exports is still invisible. That is the residual, and it is a smaller\n * one: a barrel is a place to notice an omission, and thirteen `register`\n * lines scattered across thirteen files is not.\n */\n protected models: Array<Record<string, unknown>> = [];\n\n readonly app = new Application();\n\n /**\n * Phase one, synchronous: every provider is constructed and its `register()`\n * runs. Only bindings are recorded here — no service is instantiated, so this\n * is safe to call from a synchronous constructor (`new App({ kernel })`).\n * Phase two is `waitForBoot()`.\n */\n boot() {\n // Before the container, deliberately. This throws on a model whose policies\n // would be skipped, and the useful moment for that is the one where nothing\n // has been constructed and no request can be in flight.\n if (this.models.length > 0) registerModels(...this.models);\n else warnIfModelsAreRegisteredButUndeclared();\n\n this.app.config.merge(this.config);\n Application.setInstance(this.app);\n this.app.registerMany([...frameworkProviders, ...this.providers]);\n this.registerServices();\n }\n\n /**\n * Constructs every listed service and binds it into the container. Runs after\n * the providers have registered, so a provider's `boot()` can `inject()` one;\n * a `Service` constructor does no I/O, so doing this synchronously costs\n * nothing beyond the field initializers.\n */\n private registerServices() {\n // What a previous pass bound, so re-running this on the same kernel is not\n // mistaken for a collision with something else.\n const ours = this.serviceTokens;\n\n this.serviceInstances = [];\n this.serviceTokens = new Set();\n this.servicesBooted = false;\n\n const owners = new Map<string, string>();\n\n for (const declaration of this.services) {\n const instance =\n typeof declaration === \"function\" ? new declaration() : declaration;\n const ctor = instance.constructor as ServiceConstructor;\n\n if (!ctor.token) {\n throw new Error(\n `Service [${ctor.name}] is listed in \\`services\\` but does not declare a \\`static token\\`.`,\n );\n }\n\n // Two services under one token is the failure this refuses to have\n // silently: the second would replace the first in the container, and\n // every `inject()` written against either would hand back whichever was\n // listed last.\n const owner = owners.get(ctor.token);\n if (owner) {\n throw new Error(\n `Services [${owner}] and [${ctor.name}] both declare the token \"${ctor.token}\". Tokens are the container's keys, so they must be unique.`,\n );\n }\n owners.set(ctor.token, ctor.name);\n\n // The same failure one level out. `Container.instance()` writes into\n // `instances`, which `make()` consults before `bindings`, so a token that\n // is already spoken for is not shared with its owner — it replaces it, for\n // every `app()` and `inject()` in the process. An app service that named\n // itself \"mail\" would leave `Mail.send()` resolving to an object with no\n // `send`, and the boot that caused it would report nothing. Providers have\n // all registered by now, so anything bound here belongs to somebody else.\n const token = ctor as unknown as ServiceToken<Service>;\n if (!ours.has(ctor.token) && this.app.bound(token)) {\n throw new Error(\n `Service [${ctor.name}] declares the token \"${ctor.token}\", which is already bound in the container by the framework or a provider. Binding it would replace that service everywhere, so pick a token nothing else owns.`,\n );\n }\n\n this.app.instance(token, instance);\n this.serviceInstances.push(instance);\n this.serviceTokens.add(ctor.token);\n }\n this.app.setShutdownHooks(\n this.serviceInstances.map((service) => ({\n name: `${service.constructor.name}.onShutdown`,\n shutdown: (options) => service.onShutdown(options),\n })),\n );\n }\n\n /**\n * Phase two, asynchronous: every provider's `boot()` runs, in registration\n * order, after all of them have registered. Idempotent.\n */\n async waitForBoot() {\n await this.app.boot();\n await this.bootServices();\n // Last, once every job — queued listeners included — is registered.\n startClaimingIfServing(this.app);\n }\n\n /**\n * Phase two for services, after every provider's `boot()` — so a service may\n * use the facades and anything else a provider owns. Idempotent, like the\n * provider phase it follows.\n */\n private async bootServices() {\n if (this.servicesBooted) {\n return;\n }\n for (const service of this.serviceInstances) {\n await service.boot();\n }\n this.servicesBooted = true;\n }\n\n /**\n * Every provider's `shutdown()`, in reverse registration order, inside the\n * application context — so a hook may use the facades, as a cron tick or a\n * request would. See `Application.shutdown` for the deadline and the\n * report. Idempotent.\n */\n shutdown(options?: { timeoutMs?: number }): Promise<ShutdownReport> {\n return this.run(() => this.app.shutdown(options));\n }\n\n run<T>(cb: () => T) {\n return kernelContext.run(this.app, cb);\n }\n\n /**\n * Resolve a service by token. Callers outside this module should prefer the\n * named accessors below or `app()`; this exists for tooling that holds a\n * Kernel but no ambient context.\n */\n resolve<T>(token: ServiceToken<T>): T {\n return this.app.make(token);\n }\n\n // Named accessors. `app/App.ts` goes through these rather than importing the\n // service classes itself — see the note in that file about the two copies of\n // gemi that coexist at build time.\n apiRoutes(): ApiRouteDispatcher {\n return this.app.make(ApiRouteDispatcher);\n }\n\n viewRoutes(): ViewRouteDispatcher {\n return this.app.make(ViewRouteDispatcher);\n }\n\n domains(): DomainRouter {\n return this.app.make(DomainRouter);\n }\n\n queue(): QueueManager {\n return this.app.make(QueueManager);\n }\n\n /** The MCP endpoint, or `null` when `route.mcp.remote` is not enabled. */\n mcpHttp(): McpHttpServer | null {\n return this.app.config.get(\"route.mcp.remote.enabled\") === true\n ? this.app.make(McpHttpServer)\n : null;\n }\n\n /**\n * The broadcast WebSocket endpoint, or `null` when the app declares no\n * `route.channels` (nothing could be subscribed to, so nothing is upgraded).\n */\n sockets(): SocketHub | null {\n return this.app.config.get(\"route.channels\") ? this.app.make(SocketHub) : null;\n }\n\n /** The `global` middleware list for one request. Call it inside `run`. */\n globalMiddleware(req: Request) {\n return runGlobalMiddleware(req);\n }\n\n destroy() {\n // Only touch services that were actually resolved — resolving one here\n // would construct it purely to tear it down.\n if (this.app.resolved(Scheduler)) {\n this.app.make(Scheduler).stop();\n }\n\n this.app.flush();\n\n if (Application.getInstance() === this.app) {\n Application.setInstance(undefined);\n }\n\n kernelContext.disable();\n }\n}\n\n/**\n * Says something to an application that has models and has not declared them.\n *\n * Without this the fix for #316 defaults to off. `models` is `[]`, `boot()`\n * no-ops, and an app upgrading from 0.48 is in exactly the state the issue\n * describes until somebody edits their Kernel by hand — while the only place\n * that says to is the **Setup** section of `docs/orm.md`, which an existing app\n * read once and will not read again. #316 was filed by an app mid-migration\n * with a 79-model schema, which is precisely the reader who never sees it.\n *\n * The condition is what makes this worth printing. A populated registry with an\n * empty `models` means the generated `index.ts` was imported and its bases are\n * what every nested read resolves to — so if any policy lives on a subclass, it\n * is being skipped inside includes right now. A Kernel with no ORM at all has\n * an empty registry and hears nothing.\n *\n * Development only, and a warning rather than a throw: an app in this state is\n * running today, and turning a working deploy into a failure to start over an\n * arrangement that *might* be fine is not a patch-level thing to do. The\n * failure it points at is silent, so the fix for it has to be noisy somewhere,\n * and the terminal an author is already looking at is the cheapest somewhere\n * there is.\n */\nfunction warnIfModelsAreRegisteredButUndeclared(): void {\n if (process.env.NODE_ENV === \"production\") return;\n\n const registered = registeredNames();\n if (registered.length === 0) return;\n\n console.warn(\n `[gemi] ${registered.length} model${registered.length === 1 ? \" is\" : \"s are\"} ` +\n `registered, but Kernel.models is empty.\\n` +\n ` Nested relation reads resolve a model by name, so a policy on a ` +\n `subclass that does not own its\\n` +\n ` name is skipped inside every include — scoped at the root, ` +\n `unscoped in an include, with nothing\\n` +\n ` to notice it. Declaring the modules registers each class under ` +\n `its own name and audits the set:\\n\\n` +\n ` import * as generated from \"../models/generated\"\\n` +\n ` import * as models from \"../models\"\\n\\n` +\n ` export default class extends Kernel {\\n` +\n ` models = [generated, models]\\n` +\n ` }\\n\\n` +\n ` See docs/orm.md#your-model-class. Development only; this never ` +\n `prints in production.`,\n );\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";u9CA2CO,DAAM,HAAmD,JAC9D,HACA,HACA,HAIA,HAGA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,HACA,JACF,HC9CO,CAAM,JAAO,JAMR,EAAsB,JAAC,HAMvB,KAA0C,JAAC,EAa3C,SAAgD,CAAC,EAEnD,iBAA8B,CAAC,EAC/B,cAAgB,IAAI,IACpB,eAAiB,GA8Bf,OAAyC,CAAC,EAE3C,IAAM,IAAI,EAQnB,IAAI,EAAG,CAIL,GAAI,KAAK,OAAO,OAAS,EAAG,EAAe,GAAG,KAAK,MAAM,EACpD,OAAuC,EAE5C,KAAK,IAAI,OAAO,MAAM,KAAK,MAAM,EACjC,EAAY,YAAY,KAAK,GAAG,EAChC,KAAK,IAAI,aAAa,CAAC,GAAG,EAAoB,GAAG,KAAK,SAAS,CAAC,EAChE,KAAK,iBAAiB,EAShB,gBAAgB,EAAG,CAGzB,IAAM,EAAO,KAAK,cAElB,KAAK,iBAAmB,CAAC,EACzB,KAAK,cAAgB,IAAI,IACzB,KAAK,eAAiB,GAEtB,IAAM,EAAS,IAAI,IAEnB,QAAW,KAAe,KAAK,SAAU,CACvC,IAAM,EACJ,OAAO,IAAgB,WAAa,IAAI,EAAgB,EACpD,EAAO,EAAS,YAEtB,GAAI,CAAC,EAAK,MACR,MAAU,MACR,YAAY,EAAK,0EACnB,EAOF,IAAM,EAAQ,EAAO,IAAI,EAAK,KAAK,EACnC,GAAI,EACF,MAAU,MACR,aAAa,WAAe,EAAK,iCAAiC,EAAK,kEACzE,EAEF,EAAO,IAAI,EAAK,MAAO,EAAK,IAAI,EAShC,IAAM,EAAQ,EACd,GAAI,CAAC,EAAK,IAAI,EAAK,KAAK,GAAK,KAAK,IAAI,MAAM,CAAK,EAC/C,MAAU,MACR,YAAY,EAAK,6BAA6B,EAAK,sKACrD,EAGF,KAAK,IAAI,SAAS,EAAO,CAAQ,EACjC,KAAK,iBAAiB,KAAK,CAAQ,EACnC,KAAK,cAAc,IAAI,EAAK,KAAK,
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": "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",
|
|
9
|
+
"debugId": "C86FB45AFCB9BBE464756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/orm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ca as v6}from"../chunk-drb6gpgv.js";import{$a as w6,Ga as J9,Ha as Y9,Ia as l,Ja as b9,Ka as b3,La as S6,Ma as b6,Na as q0,Oa as e5,Pa as q3,Qa as q6,Ra as Z3,Sa as I0,Ta as e4,Ua as $7,Va as Z7,Wa as d5,Xa as X7,Ya as z7,Za as J7,_a as E6,ab as x6}from"../chunk-84stff4t.js";import{ph as U6,qh as N6,rh as F6,sh as O6,th as A6}from"../chunk-ewknbs3b.js";import{Ah as R,Bh as x,Ch as c,Dh as Q6,Eh as _6,Fh as z5,Gh as C6,Hh as u3,Ih as k,Jh as L6,Kh as T6,Lh as R6,Mh as I6,Nh as a5,uh as A0,vh as o,wh as j,xh as n}from"../chunk-bxxd1awv.js";import"../chunk-b2n74m40.js";import{Ej as H6,Fj as a,Gj as d,Hj as D3,Ij as y0,Kj as j6,Lj as K6,Qj as l4,Rj as o4,Sj as t4,Tj as r4,Uj as a4}from"../chunk-kz15j07h.js";import{$j as e8,Vj as K,Wj as T,Xj as k0,Yj as g,Zj as a8,_j as $0,ak as c5,bk as $6,ck as C5,dk as Z6,fk as X6,gk as s5,hk as z6,ik as J6,jk as i5,kk as T3,lk as f0,mk as d3,nk as c3,ok as s,pk as Y6,qk as g0,rk as n5}from"../chunk-sg78cmd1.js";import{Ak as T0,Bk as O3,Ek as M6,Gk as B6,Hk as D6,Ik as l5,Jk as o5,Kk as m5,Lk as A3,Mk as P6,Nk as t5,Ok as r5,yk as W6,zk as $3}from"../chunk-64hxqsqx.js";import{$k as G6,Zk as V6,bl as p5}from"../chunk-t0qs2q9j.js";import{Bl as u5}from"../chunk-jkf5kjaz.js";import"../chunk-ha4er085.js";import"../chunk-zpqcawmq.js";function N0($,Z,X,z,J,Y){let H=X0($,Z),G=B0($,H,Z,Y),V=X.quoteIdent(z),W=`${V}.`,M=G.parentFields.map((Q,C)=>{let F=`${W}${X.quoteIdent(X3(H,Z,G.childFields[C]))}`,N=`${J}${X.quoteIdent(X3($,Z,Q))}`;return`${F} = ${N}`}).join(" and ");if(!G.join)return{child:H,source:`${X.quoteIdent(H.table)} as ${V}`,correlation:M,qualifier:W};let B=`${W}${X.quoteIdent(X3(H,Z,G.childFields[0]))}`,D=`${J}${X.quoteIdent(X3($,Z,G.parentFields[0]))}`,P=X.quoteIdent(`${z}j`);return{child:H,source:`${X.quoteIdent(H.table)} as ${V} join ${X.quoteIdent(G.join.table)} as ${P} on ${P}.${X.quoteIdent(G.join.childColumn)} = ${B}`,correlation:`${P}.${X.quoteIdent(G.join.parentColumn)} = ${D}`,qualifier:W}}function X3($,Z,X){let z=$.fields[X];if(!z)throw new s($.name,Z.name,`it joins on '${X}', which is not a field on ${$.name}.`);return z.column}function u($,Z,X){let z=z3($);if(typeof Z!=="object"||Z===null||Array.isArray(Z))throw X9($,X,z);let J=Object.keys(Z).filter((H)=>Z[H]!==void 0),Y=Z;for(let H of z){if(H.length===1&&J.includes(H[0]))return Z9($,X,H[0],Y[H[0]]),H;let G=H.join("_");if(H.length>1&&J.includes(G)){let V=Y[G];if(V&&typeof V==="object"&&!Array.isArray(V))for(let W of H)Z9($,X,`${G}.${W}`,V[W]);return H}}throw X9($,X,z)}function v3($){if($===null||$===void 0)return!1;let Z=typeof $;if(Z!=="object")return Z!=="function"&&Z!=="symbol";if(Array.isArray($))return!1;if($ instanceof Date||ArrayBuffer.isView($))return!0;let X=Object.getPrototypeOf($);return X!==Object.prototype&&X!==null}function Z9($,Z,X,z){if(z===void 0||v3(z))return;throw new T(`${Z.argument}.${X}`,Z.model,Z.operation,`A unique key takes a plain value to match, not ${z===null?"null":Array.isArray(z)?"an array":"a filter object"}. Use findFirst/findMany (or updateMany/deleteMany) to filter on ${$.name}.${X.split(".").pop()}.`)}function k3($,Z,X){u($,Z,{model:$.name,operation:X,argument:"where"})}function z3($){let Z=[];if($.primaryKey.length>0)Z.push($.primaryKey);for(let X of $.uniques)Z.push(X);return Z}function X9($,Z,X){let z=X.map((H)=>H.length===1?H[0]:H.join("_")).join(", "),Y=Z.argument.startsWith("data.")?`Name it by one of those, or reach it through the ${$.name} model directly.`:`Use ${Z.operation==="delete"||Z.operation==="update"?`${Z.operation}Many`:"findFirst"} to query on anything else.`;return new K(Z.argument,Z.model,Z.operation,`${$.name} needs a unique field here. It declares: ${z}. ${Y}`)}function y($,Z,X){let z=Z.castParameter($);if(!z)return n(X);return n((J,Y)=>{let H=X(J,Y);if(H===null||H===void 0)return null;let G=k(H);if(G==="db")return null;if(G==="json")return"null";if(G==="any")throw Error("gemi ORM bug: Prisma.AnyNull reached the parameter binder. It is a filter operand only, and both the filter and write paths are supposed to have handled it before this point.");return JSON.stringify(H)},z)}function f($,Z,X,z){if(Z===void 0||Z===null)return null;if(typeof Z!=="object"||Array.isArray(Z))throw new T("where",$.name,X.operation,"Expected an object.");let J=[];for(let Y of Object.keys(Z).sort()){let H=Z[Y];if(H===void 0)continue;let G=(W)=>z(W)?.[Y];if(Y==="AND"||Y==="OR"){let W=z9($,H,X,G,Y);if(W)J.push(W);continue}if(Y===z0){J.push(K7($,H,X,G));continue}if(Y==="NOT"){let W=z9($,H,X,G,"AND");if(W)J.push(R(j("not "),w0(W)));continue}if(Y in $.relations){let W=D7($,$.relations[Y],H,X,G);if(W)J.push(W);continue}let V=$.fields[Y];if(!V){let W=j7($,Y,H,X,G);if(W){J.push(W);continue}throw new g(Y,$.name,Object.keys($.fields))}J.push(m3($,V,H,X,G))}if(J.length===0)return null;if(J.length===1)return J[0];return t(J," and ")}function D7($,Z,X,z,J){let Y=J9(Z.kind),H=P7($,Z,X,Y,z),G=z.relationDepth??0,V=z.dialect,W=z.qualifier??`${V.quoteIdent($.table)}.`,M=N0($,Z,V,`_r${G}`,W,z.operation),B=M.child,D=j(M.correlation),P={...z,qualifier:M.qualifier,relationDepth:G+1},Q=[];for(let C of Y){if(!(C in H))continue;let F=H[C],N=(I)=>H.direct?J(I):J(I)?.[C];if(F===null){Q.push(f3(M,D,null,C==="is"));continue}let L=f(B,F,P,N);if(C==="every"){if(!L)continue;Q.push(f3(M,D,R(j("not "),w0(L)),!0));continue}let _=C==="none"||C==="isNot";Q.push(f3(M,D,L,_))}if(Q.length===0)return null;if(Q.length===1)return Q[0];return t(Q," and ")}function f3($,Z,X,z){let J=[j(`${z?"not ":""}exists (select 1 from ${$.source} where `),Z];if(X)J.push(j(" and "),X);return J.push(j(")")),R(...J)}function P7($,Z,X,z,J){let Y=`where.${Z.name}`,H=Z.kind==="many";if(X===null){if(H)throw new K(Y,$.name,J.operation,`${Z.name} is a to-many relation, so null is not a filter for it. Use { none: {} } for "has no related rows".`);return{is:null,direct:!0}}if(typeof X!=="object"||Array.isArray(X))throw new T(Y,$.name,J.operation,H?`Expected an object holding ${z.join(", ")}.`:"Expected an object, or null.");if(Y9(X,z))return X;if(H)throw new K(Y,$.name,J.operation,`Expected one of ${z.join(", ")}. A to-many relation has no `+"single reading of a bare filter \u2014 { some: \u2026 } and { every: \u2026 } mean "+"different things.");return{is:X,direct:!0}}function j7($,Z,X,z,J){let Y=z3($).find((V)=>V.length>1&&V.join("_")===Z);if(!Y)return null;if(typeof X!=="object"||X===null||Array.isArray(X))throw new T(`where.${Z}`,$.name,z.operation,`Expected an object holding ${Y.join(" and ")}.`);let H=X,G=[];for(let V of Y){if(H[V]===void 0)throw new K(`where.${Z}`,$.name,z.operation,`Missing '${V}'. A composite key needs all of ${Y.join(", ")}.`);if(!v3(H[V]))throw new T(`where.${Z}.${V}`,$.name,z.operation,`A composite key takes a plain value for each of ${Y.join(", ")}, not a filter, an array or null.`);G.push(m3($,$.fields[V],H[V],z,(W)=>J(W)?.[V]))}return G.length===1?G[0]:t(G," and ")}function z9($,Z,X,z,J){let Y=[];if(Array.isArray(Z))for(let H=0;H<Z.length;H++){let G=f($,Z[H],X,(V)=>z(V)?.[H]);if(G)Y.push(G)}else{let H=f($,Z,X,z);if(H)Y.push(H)}if(Y.length===0)return J==="AND"?null:H9;if(Y.length===1)return Y[0];return t(Y,J==="AND"?" and ":" or ")}var H9=j("false");function t($,Z){return R(j("("),x($,Z),j(")"))}function w0($){return $.text.startsWith("(")?$:t([$],"")}var h3=new Set(["equals","not","in","notIn","lt","lte","gt","gte","contains","startsWith","endsWith","mode"]),V9={lt:"<",lte:"<=",gt:">",gte:">="},z0="$compositeIn",G9=Symbol("gemi.orm.compositeInFromPlanner");function W9($,Z){return{[G9]:!0,fields:$,values:Z}}function K7($,Z,X,z){let{dialect:J}=X,H=Q7($,Z,X).map((V)=>{let W=$.fields[V];if(!W)throw new g(V,$.name,Object.keys($.fields));return W}),G=H.map((V)=>`${X.qualifier??""}${J.quoteIdent(V.column)}`);return J.compositeIn(G,H.map((V)=>V.type),(V)=>z(V).values)}function Q7($,Z,X){let z=()=>{throw new g(z0,$.name,Object.keys($.fields))};if(typeof Z!=="object"||Z===null||Array.isArray(Z))return z();if(Z[G9]!==!0)return z();let J=(G)=>{throw new K(z0,$.name,X.operation,G)},{fields:Y,values:H}=Z;if(!Array.isArray(Y)||Y.length===0)return J(`the planner built a '${z0}' with no fields.`);if(!Y.every((G)=>typeof G==="string"))return J(`the planner built a '${z0}' with a non-string field.`);if(!Array.isArray(H))return J(`the planner built a '${z0}' with no values.`);if(!H.every((G)=>Array.isArray(G)&&G.length===Y.length))return J(`the planner built a '${z0}' whose tuples do not all have ${Y.length} value(s).`);return Y}var _7=["equals","has","hasEvery","hasSome","isEmpty"],g3=new Set(_7);function C7($,Z,X,z,J,Y){let{dialect:H}=J;if(O0($,Z,`where.${Z.name}`,J.operation,H),Array.isArray(z))throw new T(`where.${Z.name}`,$.name,J.operation,`'${Z.name}' is a scalar list, and a bare array is not a filter on `+"one \u2014 Prisma rejects it here too. Say which comparison you mean: "+`{ ${Z.name}: { equals: [...] } } for the whole list, or { ${Z.name}: { hasEvery: [...] } } for "contains all of these". A bare array *is* accepted as a value in \`data\`.`);if(!p3(z))throw new T(`where.${Z.name}`,$.name,J.operation,`'${Z.name}' is a scalar list. Expected an object holding ${[...g3].sort().join(", ")}; received ${z===null?"null":typeof z}.`);let G=z,V=[];for(let W of Object.keys(G).sort()){let M=G[W];if(M===void 0)continue;if(!g3.has(W))throw new T(`where.${Z.name}.${W}`,$.name,J.operation,`'${Z.name}' is a scalar list, and a list filter takes ${[...g3].sort().join(", ")}. The scalar operators \u2014 `+`${[...h3].sort().join(", ")} \u2014 apply to a single value and `+"Prisma does not offer them here.");let B=(D)=>Y(D)?.[W];V.push(L7($,Z,X,W,M,J,B))}if(V.length===0)return j("true");if(V.length===1)return V[0];return t(V," and ")}function L7($,Z,X,z,J,Y,H){let{dialect:G}=Y;if(z==="equals")return T7($,Z,X,J,Y,H);if(z==="isEmpty"){if(typeof J!=="boolean")throw new T(`where.${Z.name}.isEmpty`,$.name,Y.operation,`Expected true or false, received ${J===null?"null":typeof J}.`);return G.listIsEmpty(X,J)}if(z==="has"){let W=R7(Z);return G.listHas(X,y(W,G,F0(W,G,H)))}if(!Array.isArray(J))throw new T(`where.${Z.name}.${z}`,$.name,Y.operation,`Expected an array, received ${J===null?"null":typeof J}.`);let V=y(Z,G,F0(Z,G,H));return z==="hasEvery"?G.listHasEvery(X,V):G.listHasSome(X,V)}function T7($,Z,X,z,J,Y){let{dialect:H}=J;if(z===null)return j(`${X} is null`);if(!Array.isArray(z))throw new T(`where.${Z.name}.equals`,$.name,J.operation,`'${Z.name}' is a scalar list, so it compares against an array. Received ${typeof z}. For "is this element present", use { ${Z.name}: { has: \u2026 } }.`);return R(j(`${X} = `),y(Z,H,F0(Z,H,Y)))}function R7($){return{...$,isList:!1}}function O0($,Z,X,z,J){if(J.listFilters.size>0)return;throw new K(X,$.name,z,`'${Z.name}' is a scalar list, and ${J.name} has no array type to hold one. Prisma refuses the column itself on ${J.name} \u2014 `+'"the current connector does not support lists of primitive types" \u2014 so '+`this is a difference between the databases rather than a gap in the ORM. The generated artifact is dialect-agnostic, which is why this surfaces here rather than at \`prisma generate\`: the schema was generated against Postgres and DATABASE_URL names a ${J.name} database, which has no '${Z.column}' column either. It works on postgres.`)}var I7=["equals","not","string_contains","string_starts_with","string_ends_with","array_contains","lt","lte","gt","gte"],y3=new Set(I7),U7=["has_key","has_some_keys","has_every_key"],J3=new Set(U7);function M9($,Z,X,z,J,Y,H,G){let V=z!=="has_key",W=`where.${Z.name}.${z}`,M=(D)=>{if(!(V?Array.isArray(D)&&D.every((Q)=>typeof Q==="string"):typeof D==="string"))throw new T(W,$.name,Y.operation,V?"Expected an array of key names, like ['a', 'b'].":"Expected a key name, like 'a'.");return D};M(J);let B=(D,P)=>M(G(D,P));return Y.dialect.jsonHasKeys(X,H,B,z==="has_key"?"one":z==="has_some_keys"?"some":"every",Array.isArray(J)?J.length:0)}function N7($,Z,X,z,J,Y){let{dialect:H}=J;if(Z.type!=="Json")throw new K(`${Z.name}.path`,$.name,J.operation,`A 'path' filter reads inside a JSON document, and '${Z.name}' is a ${Z.type} column.`);S7($,Z,z.path,J);let G=(M)=>Y(M)?.path,V=Object.keys(z).filter((M)=>M!=="path"&&z[M]!==void 0).sort();if(V.length===0)throw new K(`${Z.name}.path`,$.name,J.operation,`A 'path' needs a filter beside it \u2014 ${[...y3,...J3].sort().join(", ")}. Prisma refuses a bare path too.`);let W=[];for(let M of V){if(J3.has(M)){W.push(M9($,Z,X,M,z[M],J,G,(P)=>Y(P)?.[M]));continue}if(!y3.has(M))throw new K(`${Z.name}.${M}`,$.name,J.operation,`A JSON path filter takes ${[...y3,...J3].sort().join(", ")}.`);if(!H.jsonFilters.has(M))throw new K(`${Z.name}.${M}`,$.name,J.operation,`'${M}' on a JSON path is not available on ${H.name}. Prisma refuses it here too, so this is a difference between the databases rather than a gap in the ORM. It works on postgres.`);let B=z[M],D=B===null?"json":k(B);if(D&&(M==="equals"||M==="not")){W.push(F7(D,X,G,Z,H,M==="not"));continue}if(D&&B!==null){let P=M==="array_contains"?"'array_contains' tests containment against a document, and a sentinel is not one":`'${M}' compares an extracted value against a scalar, and a sentinel is not one`;throw new T(`where.${Z.name}.${M}`,$.name,J.operation,`${x0(D)} asks which kind of null a value is, which `+`only 'equals' and 'not' can express \u2014 ${P}. Prisma refuses it under this operator too. Write { ${Z.name}: { path: [\u2026], equals: ${x0(D)} } }, `+"or filter the column itself \u2014 "+`{ ${Z.name}: { equals: ${x0(D)} } }.`)}if(B9(B))throw new T(`where.${Z.name}.${M}`,$.name,J.operation,"Prisma.AnyNull is a question rather than a value \u2014 'either kind of "+"null' \u2014 so it cannot appear inside a document. Ask it directly: "+`{ ${Z.name}: { path: [\u2026], equals: Prisma.AnyNull } }.`);O7(M,B,$,Z,J),W.push(A7(M,X,G,Z,H,(P)=>Y(P)?.[M]))}return W.length===1?W[0]:t(W," and ")}function F7($,Z,X,z,J,Y){let H=()=>R(J.jsonValueAt(Z,X),j(Y?" is not null":" is null")),G=()=>R(J.jsonValueAt(Z,X),j(Y?" <> ":" = "),y(z,J,()=>J.encode(u3,z)));if($==="db")return H();if($==="json")return G();return t([G(),H()],Y?" and ":" or ")}function O7($,Z,X,z,J){let Y=$==="string_contains"||$==="string_starts_with"||$==="string_ends_with";if(Y&&typeof Z!=="string")throw new T(`where.${z.name}.${$}`,X.name,J.operation,`Expected a string, received ${Z===null?"null":typeof Z}. Prisma raises here too \u2014 without this the pattern becomes `+`'%${String(Z)}%', which runs and returns the wrong rows.`);if(Z===null)throw new T(`where.${z.name}.${$}`,X.name,J.operation,$==="array_contains"?"null cannot be tested for containment through a JSON path: the operand binds as SQL NULL rather than as the JSON value, and "+"'x @> NULL' is NULL rather than true \u2014 the query would run and "+`match nothing. A null *inside* the document is an ordinary value and still compiles: { ${z.name}: { path: [\u2026], array_contains: [null] } }.`:`null cannot be compared through a JSON path with '${$}', which `+"compares the extracted value as a number \u2014 the comparison against "+`NULL is NULL rather than true, so the query would run and match nothing. Prisma refuses it here too. For "the value at this path is a JSON null", use equals or not: { ${z.name}: { path: [\u2026], equals: null } }.`);if($==="array_contains"||Y)return;if(typeof Z==="object")throw new K(`where.${z.name}.${$}`,X.name,J.operation,`'${$}' on a JSON path compares the extracted value as a scalar, so `+"an object or array operand cannot be expressed \u2014 it would bind as "+`'${String(Z)}' and match nothing. Prisma accepts one here; gemi does not yet. Use array_contains for containment, or narrow the path until it names a scalar.`)}function A7($,Z,X,z,J,Y){if($==="array_contains")return J.jsonArrayContains(Z,X,Y);let H=$==="string_contains"||$==="string_starts_with"||$==="string_ends_with",G=J.jsonExtract(Z,X,!0);if(H){let B=$==="string_contains"?(D)=>`%${D}%`:$==="string_starts_with"?(D)=>`${D}%`:(D)=>`%${D}`;return R(j("("),G,j(") like "),n((D,P)=>{let Q=Y(D,P);return Q===null||Q===void 0?null:B(String(Q))}))}let V=$==="equals"?"=":$==="not"?"<>":V9[$],W=$!=="equals"&&$!=="not",M=W?R(j("cast(("),G,j(") as real)")):R(j("("),G,j(")"));return R(M,j(` ${V} `),n((B,D)=>{let P=Y(B,D);if(P===null||P===void 0)return null;if(W)return Number(P);return J.jsonComparesAsText?String(P):P}))}function S7($,Z,X,z){let{dialect:J}=z,Y=J.jsonPathSyntax==="array"?"array":"jsonpath",H=Array.isArray(X)?"array":typeof X==="string"?"jsonpath":"other";if(Array.isArray(X)&&X.length===0||X==="")throw new K(`${Z.name}.path`,$.name,z.operation,`A JSON path cannot be empty. ${J.jsonPathSyntax==="array"?`On ${J.name} an empty array selects the whole document, `+"which is a filter on the column rather than on a path \u2014 write "+`{ ${Z.name}: { equals: \u2026 } } if that is what you meant.`:`On ${J.name} an empty string raises inside json_extract.`}`);if(H===Y){if(Y!=="array")return;let V=X.findIndex((B)=>typeof B!=="string");if(V===-1)return;let W=X[V],M=W===null?"null":W===void 0?"undefined":Array.isArray(W)?"an array":typeof W==="object"?"an object":`a ${typeof W}`;throw new K(`${Z.name}.path`,$.name,z.operation,`A JSON path is an array of strings, and path[${V}] is ${M}. `+(typeof W==="number"?'An array index is a key too \u2014 write ["items", "0"] rather than '+`["items", 0]; it reaches the same element, because ${J.name} takes the path as text. Prisma's path is string[] and its client refuses a number here too.`:"Prisma's path is string[] too."))}throw new K(`${Z.name}.path`,$.name,z.operation,J.jsonPathSyntax==="array"?`On ${J.name} a JSON path is an array of keys \u2014 ["a", "b"] \u2014 `+"not a JSONPath string. Prisma splits them the same way, and refuses the other form on each database.":`On ${J.name} a JSON path is a JSONPath string \u2014 "$.a.b" \u2014 not `+"an array of keys. Prisma splits them the same way, and refuses the other form on each database.")}function m3($,Z,X,z,J){let{dialect:Y}=z,H=`${z.qualifier??""}${Y.quoteIdent(Z.column)}`,G=k(X);if(G)throw new T(`where.${Z.name}`,$.name,z.operation,`${x0(G)} is not a filter on `+"its own \u2014 Prisma rejects it here too. Write it as an explicit "+`comparison: { ${Z.name}: { equals: ${x0(G)} } }.`);if(Z.isList)return C7($,Z,H,X,z,J);if(!p3(X))return Y3(H,Z,X,Y,J);let V=X,W=Object.keys(V).sort();if(V.path!==void 0)return N7($,Z,H,V,z,J);let M=V.mode==="insensitive";if(V.mode!==void 0&&V.mode!=="default"){if(!M)throw new T(`mode: ${JSON.stringify(V.mode)}`,$.name,z.operation,"Prisma takes 'default' or 'insensitive'.");if(!Y.supportsInsensitiveMode)throw new K('mode: "insensitive"',$.name,z.operation,`The ${Y.name} dialect cannot express it \u2014 Prisma rejects it `+"here too. Note SQLite's LIKE is already case-insensitive for ASCII.")}let B=[];for(let D of W){let P=V[D];if(P===void 0||D==="mode")continue;if(Z.type==="Json"&&J3.has(D)){B.push(M9($,Z,H,D,P,z,void 0,(C)=>J(C)?.[D]));continue}if(!h3.has(D))throw new T(`where.${Z.name}.${D}`,$.name,z.operation,`A scalar filter takes ${[...h3].sort().join(", ")}.`);if(D!=="equals"&&D!=="not"&&B9(P))throw new T(`where.${Z.name}.${D}`,$.name,z.operation,`Prisma.AnyNull means 'either kind of null', which only 'equals' and 'not' can express. Write { ${Z.name}: { equals: Prisma.AnyNull } }, or name the one you mean with Prisma.DbNull or Prisma.JsonNull.`);let Q=(C)=>J(C)?.[D];switch(D){case"equals":B.push(Y3(H,Z,P,Y,Q));break;case"not":B.push(b7($,Z,P,z,Q,H));break;case"in":case"notIn":B.push(E7($,H,Z,P,z,Q,D==="notIn"));break;case"lt":case"lte":case"gt":case"gte":B.push(R(j(`${H} ${V9[D]} `),y(Z,Y,F0(Z,Y,Q))));break;case"contains":case"startsWith":case"endsWith":if(typeof P!=="string")throw new T(`where.${Z.name}.${D}`,$.name,z.operation,`Expected a string, received ${P===null?"null":typeof P}.`);if(Z.type!=="String")throw new K(`where.${Z.name}.${D}`,$.name,z.operation,`'${Z.name}' is a ${Z.type}, and ${D} only applies to strings.`);B.push(Y.like(H,M,w7(D,Q)));break}}if(B.length===0)return j("true");if(B.length===1)return B[0];return t(B," and ")}function x0($){return`Prisma.${$==="db"?"DbNull":$==="json"?"JsonNull":"AnyNull"}`}function B9($){if(k($)==="any")return!0;return Array.isArray($)&&$.some((Z)=>k(Z)==="any")}function b7($,Z,X,z,J,Y){if(X===null||k(X)==="db")return j(`${Y} is not null`);if(k(X)==="json")return R(j("not "),w0(Y3(Y,Z,X,z.dialect,J)));if(k(X)==="any")return R(j("not "),w0(Y3(Y,Z,X,z.dialect,J)));if(!p3(X))return R(j(`${Y} <> `),y(Z,z.dialect,F0(Z,z.dialect,J)));let H=m3($,Z,X,z,J);return R(j("not "),w0(H))}function Y3($,Z,X,z,J){if(X===null||k(X)==="db")return j(`${$} is null`);if(k(X)==="any")return t([j(`${$} is null`),q7($,Z,z)]," or ");return R(j(`${$} = `),y(Z,z,F0(Z,z,J)))}function q7($,Z,X){return R(j(`${$} = `),y(Z,X,()=>X.encode(u3,Z)))}function E7($,Z,X,z,J,Y,H){let{dialect:G}=J;if(!Array.isArray(z))throw new T(`where.${X.name}.${H?"notIn":"in"}`,$.name,J.operation,"Expected an array.");if(z.length===0)return H?j("true"):H9;return G.inList(Z,H,z.length,(V)=>{return Y(V).map((M)=>G.encode(M,X))})}function w7($,Z){return(X)=>{let z=String(Z(X));if($==="contains")return`%${z}%`;if($==="startsWith")return`${z}%`;return`%${z}`}}function F0($,Z,X){return(z)=>Z.encode(X(z),$)}function p3($){return typeof $==="object"&&$!==null&&!Array.isArray($)&&!($ instanceof Date)&&!ArrayBuffer.isView($)}function D9($,Z,X,z,J,Y,H){let G=`orderBy.${Z.name}`;if(typeof X!=="object"||X===null||Array.isArray(X))throw new T(G,$.name,z,Z.kind==="many"?'Expected { _count: "asc" | "desc" }.':`Expected an object naming one field of ${Z.model}.`);let V=X,W=Object.keys(V).filter((C)=>C!=="where");if(W.length!==1)throw new K(G,$.name,z,W.length===0?"Name the field to order by.":`Name exactly one field to order by; got ${W.join(", ")}. `+"Order by several with an array: [{ a: \u2026 }, { b: \u2026 }].");let[M]=W,B=N0($,Z,J,`_o${H}`,`${J.quoteIdent($.table)}.`,z),D=x7($,Z,B.child,M,V[M],z,B.qualifier,J),P=f(B.child,V.where,{dialect:J,operation:z,qualifier:B.qualifier},(C)=>Y(C)?.where),Q=[j(`(select ${D.expression} from ${B.source} where ${B.correlation}`)];if(P)Q.push(j(" and "),P);return Q.push(j(")")),{expression:R(...Q),direction:D.direction,nulls:D.nulls}}function x7($,Z,X,z,J,Y,H,G){let V=`orderBy.${Z.name}.${z}`,{direction:W,nulls:M}=v7($,V,J,Y);if(z===l){if(Z.kind!=="many")throw new K(V,$.name,Y,`${Z.name} is a to-one relation, so its count is 0 or 1. Order by one of ${X.name}'s fields instead.`);return{expression:"count(*)",direction:W,nulls:M}}if(Z.kind==="many")throw new K(V,$.name,Y,`${Z.name} is a to-many relation, so ordering by '${z}' has no single answer for a parent with several children. Only `+"{ _count: \u2026 } is supported.");let B=X.fields[z];if(!B)throw new K(V,$.name,Y,`'${z}' is not a field on ${X.name}. Known fields: ${Object.keys(X.fields).join(", ")}.`);return{expression:`${H}${G.quoteIdent(B.column)}`,direction:W,nulls:M}}function v7($,Z,X,z){if(X==="asc"||X==="desc")return{direction:X};if(typeof X==="object"&&X!==null){let{sort:J,nulls:Y}=X;if(J!=="asc"&&J!=="desc")throw new T(Z,$.name,z,'Expected "asc" or "desc".');if(Y===void 0)return{direction:J};if(Y!=="first"&&Y!=="last")throw new K(`${Z}.nulls`,$.name,z,'Expected "first" or "last".');return{direction:J,nulls:Y}}throw new K(Z,$.name,z,'Expected "asc", "desc", or { sort, nulls }.')}var k7=new Set(["asc","desc"]),f7=new Set(["first","last"]);function D0($,Z,X,z){if(Z===void 0||Z===null)return[];let J=Array.isArray(Z),Y=J?Z:[Z],H=[];for(let G=0;G<Y.length;G++){let V=Y[G],W=(M)=>{let B=z?.locate(M);return J?B?.[G]:B};if(typeof V!=="object"||V===null)throw new T("orderBy",$.name,X,"Expected an object or an array of objects.");for(let[M,B]of Object.entries(V)){if(B===void 0)continue;if(M in $.relations){if(!z)throw new K(`orderBy.${M}`,$.name,X,"Ordering by a relation is not implemented here.");let P=D9($,$.relations[M],B,X,z.dialect,(Q)=>W(Q)?.[M],H.length);H.push({column:M,direction:P.direction,...P.nulls?{nulls:P.nulls}:{},expression:P.expression});continue}let D=$.fields[M];if(!D)throw new g(M,$.name,Object.keys($.fields));H.push({column:D.column,...P9($,M,B,X)})}}return H}function P9($,Z,X,z){if(typeof X==="string"){if(!k7.has(X))throw new T(`orderBy.${Z}: ${JSON.stringify(X)}`,$.name,z,'Expected "asc" or "desc".');return{direction:X}}if(typeof X==="object"&&X!==null){let{sort:J,nulls:Y}=X,H=P9($,Z,J,z).direction;if(Y===void 0)return{direction:H};if(typeof Y!=="string"||!f7.has(Y))throw new K(`orderBy.${Z}.nulls: ${JSON.stringify(Y)}`,$.name,z,'Expected "first" or "last".');return{direction:H,nulls:Y}}throw new K(`orderBy.${Z}`,$.name,z,'Expected "asc", "desc", or { sort, nulls }.')}function H3($){return $.map((Z)=>({...Z,direction:Z.direction==="asc"?"desc":"asc",...Z.nulls?{nulls:Z.nulls==="first"?"last":"first"}:{}}))}function r($,Z,X){if($.length===0)return null;return x($.map((z)=>{let J=` ${z.direction}`+(z.nulls?` nulls ${z.nulls}`:"");if(z.expression)return x([z.expression,j(J)],"");return j(`${X??""}${Z.quoteIdent(z.column)}${J}`)}),", ")}function V3($,Z,X,z,J){if(typeof J!=="number"||!Number.isInteger(J))throw new T(X,$,Z,`Expected an integer, got ${JSON.stringify(J)}.`);if(z==="skip"&&J<0)throw new T(X,$,Z,"A 'skip' counts rows to pass over, so it cannot be negative. Prisma rejects one too.")}function Q0($,Z,X,z,J,Y=!1){if(X?.take!==void 0)V3($.name,Z,"take","take",X.take);if(X?.skip!==void 0)V3($.name,Z,"skip","skip",X.skip);let H=Y?1:X?.take,G=X?.skip,V=J;if((H!==void 0||G!==void 0)&&V.length===0&&!Y)V=$.primaryKey.map((P)=>({column:$.fields[P]?.column??P,direction:"asc"}));let M=typeof H==="number"&&H<0;if(M)V=H3(V);let B=H===void 0?null:Y?()=>1:(P)=>Math.abs(Number(P?.take)),D=G===void 0?null:(P)=>Number(P?.skip);return{clause:z.paginate(B,D),terms:V,reversed:M}}function J0($,Z,X){let z=Z?.select,J=Z?.omit;if(z!==void 0&&Z?.include!==void 0)throw new K("select + include",$.name,X,"Prisma allows only one of them on the same query.");if(z!==void 0&&J!==void 0)throw new K("select + omit",$.name,X,"'select' names what to keep and 'omit' what to drop, so the two describe different column lists. Prisma allows only one of them on "+"the same query. Drop the 'omit' \u2014 a 'select' already excludes "+"everything it does not name.");if(z===void 0||z===null)return g7($,J,X);if(typeof z!=="object"||Array.isArray(z))throw new T("select",$.name,X,"Expected an object.");let Y=[];for(let[G,V]of Object.entries($.fields))if(z[G]===!0)Y.push(V);let H=0;for(let G of Object.keys(z)){let V=z[G];if(V===void 0)continue;if(G in $.relations){if(V!==!1)H++;continue}if(G===l){if(V!==!1)H++;continue}if(!(G in $.fields))throw new g(G,$.name,Object.keys($.fields));if(typeof V!=="boolean")throw new T(`select.${G}`,$.name,X,"Expected true or false.")}if(Y.length===0&&H===0)throw new K("select",$.name,X,"At least one field must be selected.");return Y}function g7($,Z,X){if(Z===void 0||Z===null)return Object.values($.fields);if(typeof Z!=="object"||Array.isArray(Z))throw new T("omit",$.name,X,"Expected an object of fields.");let z=new Set;for(let Y of Object.keys(Z)){let H=Z[Y];if(H===void 0)continue;if(Y in $.relations)throw new K(`omit.${Y}`,$.name,X,`'${Y}' is a relation, not a column. A relation is already absent unless an 'include' asks for it.`);if(!(Y in $.fields))throw new g(Y,$.name,Object.keys($.fields));if(typeof H!=="boolean")throw new T(`omit.${Y}`,$.name,X,"Expected true or false.");if(H)z.add(Y)}let J=Object.values($.fields).filter((Y)=>!z.has(Y.name));if(J.length===0)throw new K("omit",$.name,X,`It omits every field on ${$.name}, which leaves no column to select. Prisma rejects that too.`);return J}function G3($,Z,X){if(X.length===0)return{fields:Z};let z=new Set(Z.map((H)=>H.name)),J=X.filter((H)=>!z.has(H));if(J.length===0)return{fields:Z};let Y=new Set([...z,...J]);return{fields:Object.values($.fields).filter((H)=>Y.has(H.name)),hidden:J}}var j9=new Set(["where","orderBy","select","omit","include","take","skip"]),K9=new Set(["where","select","omit","include"]),B3=10;function h0($){return[...new Set($.map((Z)=>Z.strategy))].sort()}function S0($,Z,X,z,J=P0){let Y=u0($,Z,z);if(Y.length===0)return{plans:[],keyFields:[]};let H=[],G=new Set;for(let V of Y){T9($,V,z);let W=U9($,V);R9(W,V.node,z,2);let M=J.plan({parent:$,child:W,relation:V.relation,as:V.as,node:V.node,locate:V.locate,dialect:X,operation:z});H.push(M);for(let B of M.parentFields)G.add(B)}return{plans:H,keyFields:[...G]}}async function P3($,Z,X,z,J){let Y=Array.isArray(X)?X:X===null||X===void 0?[]:[X];if(Y.length===0)return;for(let H of $){if(H.root)continue;await H.load(Y,z,J)}if(Z&&Z.length>0)for(let H of Y)for(let G of Z)delete H[G]}function u0($,Z,X){if(Z===void 0||Z===null)return[];let{include:z,select:J}=Z;L9($,z,J,X);let Y=[];if(z!==void 0&&z!==null){if(typeof z!=="object"||Array.isArray(z))throw new T("include",$.name,X,"Expected an object.");for(let H of Object.keys(z).sort()){let G=z[H];if(G===void 0||G===!1)continue;if(H===l)continue;let V=$.relations[H];if(!V)throw new f0(H,$.name,Object.keys($.relations));Y.push({as:H,relation:V,node:G,locate:(W)=>W?.include?.[H]})}return Y}if(J!==void 0&&J!==null&&typeof J==="object")for(let H of Object.keys(J).sort()){let G=J[H];if(G===void 0||G===!1)continue;let V=$.relations[H];if(!V)continue;Y.push({as:H,relation:V,node:G,locate:(W)=>W?.select?.[H]})}return Y}function L9($,Z,X,z,J){if(Z===void 0||X===void 0)return;throw new K(J?`${J}: select + include`:"select + include",$.name,z,"Prisma allows only one of them on the same query, at any level.")}function T9($,Z,X){let z=Z.node;if(z===!0)return;if(typeof z!=="object"||z===null||Array.isArray(z))throw new T(Z.as,$.name,X,"Expected true or an object of relation arguments.");let J=z;L9($,J.include,J.select,X,Z.as);let Y=Z.relation.kind==="many";for(let H of Object.keys(J).sort()){if(J[H]===void 0)continue;if(Y&&(H==="take"||H==="skip")){y7($,Z,X,H,J[H]);continue}if(Y?j9.has(H):K9.has(H))continue;if(H==="lock")throw new k0(`${Z.as}.lock`,$.name,X,"'lock' locks the rows of the model being queried, not an included relation's. Lock the related rows with their own locking read in the same transaction.");if(H==="orderBy"&&!Y)throw new K(`${Z.as}.orderBy`,$.name,X,"Prisma does not accept 'orderBy' on a to-one relation \u2014 there is at "+"most one row to order.");if(H==="take"||H==="skip")throw new K(`${Z.as}.${H}`,$.name,X,`Prisma does not accept '${H}' on a to-one relation.`);throw new K(`${Z.as}.${H}`,$.name,X,`A relation node takes ${[...Y?j9:K9].sort().join(", ")}.`)}}function y7($,Z,X,z,J){V3($.name,X,`${Z.as}.${z}`,z,J)}function s3($,Z){let X=$.node;if(typeof X!=="object"||X===null||Array.isArray(X))return;for(let z of["take","skip"]){if(X[z]===void 0)continue;throw new K(`${$.as}.${z}`,$.parent.name,$.operation,`A '${z}' inside a to-many relation is per parent, and the batched `+"relation planner serves every parent from one query \u2014 so the only "+`limit it could emit would page every parent's children as one set. Only the lateral join strategy can express it, by paginating inside a subquery that already runs once per parent row, and it needs Postgres: ${Z}. Load '${$.as}' as its own query, or narrow it with 'where'.`)}}function R9($,Z,X,z){if(typeof Z!=="object"||Z===null||Array.isArray(Z))return;if(Z.select!==void 0)J0($,Z,X);let J=u0($,Z,X);if(J.length===0)return;if(z>B3)throw new d3($.name,B3);for(let Y of J)T9($,Y,X),R9(U9($,Y),Y.node,X,z+1)}function I9($,Z,X,z){if($.parentFields.length!==1)throw new K(X.name,Z.name,z,`${X.name} joins on ${$.parentFields.length} fields (${$.parentFields.join(", ")}), and it is planned through a join table, which links two models by a single primary key each side. Prisma does not build an implicit many-to-many over a composite key.`);return{parentField:$.parentFields[0],childField:$.childFields[0],join:$.join}}function B0($,Z,X,z){if(X.joinTable)return u7($,Z,X);if(X.from.length>0)return Q9($,X,X.from,X.to,z);let J=h7($,Z,X);if(J.from.length===0)throw new s($.name,X.name,`neither ${$.name}.${X.name} nor ${Z.name}.${J.name} holds the foreign key.`);return Q9($,X,J.to,J.from,z)}function Q9($,Z,X,z,J){if(X.length===0)throw new K(Z.name,$.name,J,`${Z.name} names no join fields.`);if(X.length!==z.length)throw new s($.name,Z.name,`it joins ${X.length} field(s) to ${z.length}: ${X.join(", ")} against ${z.join(", ")}.`);return{parentFields:X,childFields:z}}function h7($,Z,X){let z=Object.values(Z.relations).filter((J)=>J.relationName===X.relationName&&!(Z.name===$.name&&J.name===X.name));if(z.length!==1)throw new s($.name,X.name,z.length===0?`${Z.name} declares no relation named '${X.relationName}'.`:`${Z.name} declares ${z.length} relations named '${X.relationName}'.`);return z[0]}function u7($,Z,X){let{table:z,a:J,b:Y}=X.joinTable;if(J===Y){let G=X.joinTable.ownerColumn;if(!G)throw new K(X.name,$.name,"include",`${X.name} is a self-referential implicit many-to-many, and the generated artifact predates support for one. Re-run \`prisma generate\`.`);return{parentFields:[W3($,X)],childFields:[W3(Z,X)],join:{table:z,parentColumn:G,childColumn:G==="A"?"B":"A"}}}if($.name!==J&&$.name!==Y)throw new s($.name,X.name,`the join table '${z}' connects ${J} and ${Y}, neither of which is ${$.name}.`);let H=$.name===J?"A":"B";return{parentFields:[W3($,X)],childFields:[W3(Z,X)],join:{table:z,parentColumn:H,childColumn:H==="A"?"B":"A"}}}function W3($,Z){if($.primaryKey.length!==1)throw new s($.name,Z.name,`an implicit many-to-many joins on ${$.name}'s primary key, which has ${$.primaryKey.length} fields.`);return $.primaryKey[0]}function M3($,Z,X){let z=$.fields[X];if(!z)throw new s($.name,Z.name,`it joins on '${X}', which is not a field on ${$.name}.`);return z}function U9($,Z){return X0($,Z.relation,Z.as)}function X0($,Z,X=Z.name){let z=Z.model;if(!a(z))throw new c3($.name,X,z,D3());let J=d(z)?.$schema;if(!J)throw new g0(z);return J}var _9="batched",P0={name:_9,plan($){s3($,"this query planned with the batched strategy");let Z=B0($.parent,$.child,$.relation,$.operation);for(let Y of Z.parentFields)C9($.parent,$.relation,M3($.parent,$.relation,Y));for(let Y of Z.childFields)C9($.child,$.relation,M3($.child,$.relation,Y));let X=M3($.parent,$.relation,Z.parentFields[0]),z=M3($.child,$.relation,Z.childFields[0]),J=$.relation.kind==="many";return{as:$.as,model:$.relation.model,kind:$.relation.kind,parentFields:Z.parentFields,strategy:_9,load(Y,H,G){let V={parentKeyField:X,childKeyField:z,many:J,parents:Y,args:H,executor:G};return Z.join?p7($,Z,V):m7($,Z,V)}}}};async function m7($,Z,X){let{keys:z,byKey:J}=O9(X.parents,Z.parentFields);if(z.length===0)return;let Y=$.locate(X.args),H=N9(Y,Z.childFields,z,$.child,$.dialect),G=await X.executor.exec($.relation.model,"findMany",H.args,!0);for(let V of G){let W=J.get(v0(Z.childFields.map((M)=>V[M])));if(!W)continue;for(let M of W)F9(M,$.as,V,X.many)}if(H.hidden)for(let V of G)for(let W of Z.childFields)delete V[W]}async function p7($,Z,X){let{keys:z,byKey:J}=O9(X.parents,Z.parentFields);if(z.length===0)return;let{dialect:Y}=$,H=Z.join,G=await d7(Y,H,z.map((P)=>Y.encode(P[0],X.parentKeyField)),X.executor),V=new Map,W=[];for(let P of G){let Q=v0([Y.decode(P[H.parentColumn],X.parentKeyField)]),C=J.get(Q);if(!C)continue;let F=Y.decode(P[H.childColumn],X.childKeyField),N=v0([F]),L=V.get(N);if(L===void 0)L=[],V.set(N,L),W.push([F]);for(let _ of C)L.push(_)}if(W.length===0)return;let M=$.locate(X.args),B=N9(M,Z.childFields,W,$.child,$.dialect),D=await X.executor.exec($.relation.model,"findMany",B.args,!0);for(let P of D){let Q=V.get(v0([P[Z.childFields[0]]]));if(!Q)continue;for(let C of Q)F9(C,$.as,P,X.many)}if(B.hidden)for(let P of D)delete P[Z.childFields[0]]}async function d7($,Z,X,z){let J=R(j(`select ${$.quoteIdent(Z.parentColumn)}, ${$.quoteIdent(Z.childColumn)} from ${$.quoteIdent(Z.table)} where `),$.inList($.quoteIdent(Z.parentColumn),!1,X.length,()=>X)),{text:Y,binders:H}=c(J,$,{model:Z.table,operation:"include"}),G=A0();return z.query(Y,H.map((V)=>V(void 0,G)))}function N9($,Z,X,z,J){let Y=$===!0||$===null||typeof $!=="object"?{}:$,H=Z.length===1?{[Z[0]]:{in:X.map((B)=>B[0])}}:c7(z,Z,X,J),G={where:Y.where===void 0?H:{AND:[Y.where,H]}};if(Y.orderBy!==void 0)G.orderBy=Y.orderBy;if(Y.include!==void 0)G.include=Y.include;let V=Y.omit;if(V!==void 0){let B=Z.filter((D)=>V[D]===!0);if(B.length===0)G.omit=V;else{let D={...V};for(let P of B)delete D[P];return G.omit=D,{args:G,hidden:!0}}}let W=Y.select;if(W===void 0)return{args:G,hidden:!1};let M=Z.filter((B)=>W[B]!==!0);if(M.length===0)return G.select=W,{args:G,hidden:!1};G.select={...W};for(let B of M)G.select[B]=!0;return{args:G,hidden:!0}}function c7($,Z,X,z){let J=Z.map((Y)=>$.fields[Y]?.type);if(J.every((Y)=>Y!==void 0)&&z.canBindCompositeIn(J))return{[z0]:W9(Z,X)};return{OR:X.map((Y)=>Object.fromEntries(Z.map((H,G)=>[H,Y[G]])))}}function v0($){return JSON.stringify($.map(s7))}function F9($,Z,X,z){if(z){$[Z].push(X);return}if($[Z]===null)$[Z]=X}function O9($,Z){let X=new Map,z=[];for(let J of $){let Y=Z.map((V)=>J[V]);if(Y.some((V)=>V===null||V===void 0))continue;let H=v0(Y),G=X.get(H);if(G===void 0)G=[],X.set(H,G),z.push(Y);G.push(J)}return{keys:z,byKey:X}}function s7($){if(typeof $!=="object"||$===null)return $;if($ instanceof Date)return $.getTime();if(ArrayBuffer.isView($)){let Z=new Uint8Array($.buffer,$.byteOffset,$.byteLength),X="";for(let z of Z)X+=z.toString(16).padStart(2,"0");return`bytes:${X}`}throw Error(`Cannot key a relation stitch on ${Object.prototype.toString.call($)}.`)}function C9($,Z,X){if(X.isList)throw new s($.name,Z.name,`it joins on '${X.name}', a ${X.type} list \u2014 which decodes to a new `+"array per row and so cannot be compared between the two sides.");if(X.type!=="Json")return;throw new s($.name,Z.name,`it joins on '${X.name}', a ${X.type} \u2014 which decodes to a new object `+"per row and so cannot be compared between the two sides.")}var A9=(()=>{try{return Function("return 1")()===1}catch{return!1}})(),S9=!0;function i7($){S9=$}function n7(){return A9}function m0($,Z,X=[]){if(A9&&S9)return l7($,Z,X);return i3($,Z,X)}function i3($,Z,X=[]){let z=$.map((G)=>({key:G.name,column:G.column,field:G,decode:Z.needsDecode(G)})),J=z.length,Y=X.map((G)=>({key:G.key,many:G.kind==="many"})),H=Y.length;return(G)=>{let V=[];for(let W=0;W<G.length;W++){let M=G[W],B={};for(let D=0;D<J;D++){let P=z[D],Q=M[P.column];B[P.key]=P.decode?Z.decode(Q,P.field):Q??null}for(let D=0;D<H;D++)B[Y[D].key]=Y[D].many?[]:null;V.push(B)}return V}}function l7($,Z,X){let z=[];for(let Y=0;Y<$.length;Y++){let H=$[Y],G=JSON.stringify(H.name),V=JSON.stringify(H.column);z.push(Z.needsDecode(H)?`${G}: d.decode(row[${V}], f[${Y}])`:`${G}: row[${V}] ?? null`)}for(let Y of X)z.push(`${JSON.stringify(Y.key)}: ${Y.kind==="many"?"[]":"null"}`);let J=`
|
|
2
|
+
import{ca as v6}from"../chunk-h7h8ra65.js";import{$a as w6,Ga as J9,Ha as Y9,Ia as l,Ja as b9,Ka as b3,La as S6,Ma as b6,Na as q0,Oa as e5,Pa as q3,Qa as q6,Ra as Z3,Sa as I0,Ta as e4,Ua as $7,Va as Z7,Wa as d5,Xa as X7,Ya as z7,Za as J7,_a as E6,ab as x6}from"../chunk-y9ktwyrx.js";import{ph as U6,qh as N6,rh as F6,sh as O6,th as A6}from"../chunk-ewknbs3b.js";import{Ah as R,Bh as x,Ch as c,Dh as Q6,Eh as _6,Fh as z5,Gh as C6,Hh as u3,Ih as k,Jh as L6,Kh as T6,Lh as R6,Mh as I6,Nh as a5,uh as A0,vh as o,wh as j,xh as n}from"../chunk-bxxd1awv.js";import"../chunk-b2n74m40.js";import{Ej as H6,Fj as a,Gj as d,Hj as D3,Ij as y0,Kj as j6,Lj as K6,Qj as l4,Rj as o4,Sj as t4,Tj as r4,Uj as a4}from"../chunk-sw7c95nh.js";import{$j as e8,Vj as K,Wj as T,Xj as k0,Yj as g,Zj as a8,_j as $0,ak as c5,bk as $6,ck as C5,dk as Z6,fk as X6,gk as s5,hk as z6,ik as J6,jk as i5,kk as T3,lk as f0,mk as d3,nk as c3,ok as s,pk as Y6,qk as g0,rk as n5}from"../chunk-sg78cmd1.js";import{Ak as T0,Bk as O3,Ek as M6,Gk as B6,Hk as D6,Ik as l5,Jk as o5,Kk as m5,Lk as A3,Mk as P6,Nk as t5,Ok as r5,yk as W6,zk as $3}from"../chunk-64hxqsqx.js";import{$k as G6,Zk as V6,bl as p5}from"../chunk-t0qs2q9j.js";import{Bl as u5}from"../chunk-wxcbfqkd.js";import"../chunk-ha4er085.js";import"../chunk-0a5png2z.js";function N0($,Z,X,z,J,Y){let H=X0($,Z),G=B0($,H,Z,Y),V=X.quoteIdent(z),W=`${V}.`,M=G.parentFields.map((Q,C)=>{let F=`${W}${X.quoteIdent(X3(H,Z,G.childFields[C]))}`,N=`${J}${X.quoteIdent(X3($,Z,Q))}`;return`${F} = ${N}`}).join(" and ");if(!G.join)return{child:H,source:`${X.quoteIdent(H.table)} as ${V}`,correlation:M,qualifier:W};let B=`${W}${X.quoteIdent(X3(H,Z,G.childFields[0]))}`,D=`${J}${X.quoteIdent(X3($,Z,G.parentFields[0]))}`,P=X.quoteIdent(`${z}j`);return{child:H,source:`${X.quoteIdent(H.table)} as ${V} join ${X.quoteIdent(G.join.table)} as ${P} on ${P}.${X.quoteIdent(G.join.childColumn)} = ${B}`,correlation:`${P}.${X.quoteIdent(G.join.parentColumn)} = ${D}`,qualifier:W}}function X3($,Z,X){let z=$.fields[X];if(!z)throw new s($.name,Z.name,`it joins on '${X}', which is not a field on ${$.name}.`);return z.column}function u($,Z,X){let z=z3($);if(typeof Z!=="object"||Z===null||Array.isArray(Z))throw X9($,X,z);let J=Object.keys(Z).filter((H)=>Z[H]!==void 0),Y=Z;for(let H of z){if(H.length===1&&J.includes(H[0]))return Z9($,X,H[0],Y[H[0]]),H;let G=H.join("_");if(H.length>1&&J.includes(G)){let V=Y[G];if(V&&typeof V==="object"&&!Array.isArray(V))for(let W of H)Z9($,X,`${G}.${W}`,V[W]);return H}}throw X9($,X,z)}function v3($){if($===null||$===void 0)return!1;let Z=typeof $;if(Z!=="object")return Z!=="function"&&Z!=="symbol";if(Array.isArray($))return!1;if($ instanceof Date||ArrayBuffer.isView($))return!0;let X=Object.getPrototypeOf($);return X!==Object.prototype&&X!==null}function Z9($,Z,X,z){if(z===void 0||v3(z))return;throw new T(`${Z.argument}.${X}`,Z.model,Z.operation,`A unique key takes a plain value to match, not ${z===null?"null":Array.isArray(z)?"an array":"a filter object"}. Use findFirst/findMany (or updateMany/deleteMany) to filter on ${$.name}.${X.split(".").pop()}.`)}function k3($,Z,X){u($,Z,{model:$.name,operation:X,argument:"where"})}function z3($){let Z=[];if($.primaryKey.length>0)Z.push($.primaryKey);for(let X of $.uniques)Z.push(X);return Z}function X9($,Z,X){let z=X.map((H)=>H.length===1?H[0]:H.join("_")).join(", "),Y=Z.argument.startsWith("data.")?`Name it by one of those, or reach it through the ${$.name} model directly.`:`Use ${Z.operation==="delete"||Z.operation==="update"?`${Z.operation}Many`:"findFirst"} to query on anything else.`;return new K(Z.argument,Z.model,Z.operation,`${$.name} needs a unique field here. It declares: ${z}. ${Y}`)}function y($,Z,X){let z=Z.castParameter($);if(!z)return n(X);return n((J,Y)=>{let H=X(J,Y);if(H===null||H===void 0)return null;let G=k(H);if(G==="db")return null;if(G==="json")return"null";if(G==="any")throw Error("gemi ORM bug: Prisma.AnyNull reached the parameter binder. It is a filter operand only, and both the filter and write paths are supposed to have handled it before this point.");return JSON.stringify(H)},z)}function f($,Z,X,z){if(Z===void 0||Z===null)return null;if(typeof Z!=="object"||Array.isArray(Z))throw new T("where",$.name,X.operation,"Expected an object.");let J=[];for(let Y of Object.keys(Z).sort()){let H=Z[Y];if(H===void 0)continue;let G=(W)=>z(W)?.[Y];if(Y==="AND"||Y==="OR"){let W=z9($,H,X,G,Y);if(W)J.push(W);continue}if(Y===z0){J.push(K7($,H,X,G));continue}if(Y==="NOT"){let W=z9($,H,X,G,"AND");if(W)J.push(R(j("not "),w0(W)));continue}if(Y in $.relations){let W=D7($,$.relations[Y],H,X,G);if(W)J.push(W);continue}let V=$.fields[Y];if(!V){let W=j7($,Y,H,X,G);if(W){J.push(W);continue}throw new g(Y,$.name,Object.keys($.fields))}J.push(m3($,V,H,X,G))}if(J.length===0)return null;if(J.length===1)return J[0];return t(J," and ")}function D7($,Z,X,z,J){let Y=J9(Z.kind),H=P7($,Z,X,Y,z),G=z.relationDepth??0,V=z.dialect,W=z.qualifier??`${V.quoteIdent($.table)}.`,M=N0($,Z,V,`_r${G}`,W,z.operation),B=M.child,D=j(M.correlation),P={...z,qualifier:M.qualifier,relationDepth:G+1},Q=[];for(let C of Y){if(!(C in H))continue;let F=H[C],N=(I)=>H.direct?J(I):J(I)?.[C];if(F===null){Q.push(f3(M,D,null,C==="is"));continue}let L=f(B,F,P,N);if(C==="every"){if(!L)continue;Q.push(f3(M,D,R(j("not "),w0(L)),!0));continue}let _=C==="none"||C==="isNot";Q.push(f3(M,D,L,_))}if(Q.length===0)return null;if(Q.length===1)return Q[0];return t(Q," and ")}function f3($,Z,X,z){let J=[j(`${z?"not ":""}exists (select 1 from ${$.source} where `),Z];if(X)J.push(j(" and "),X);return J.push(j(")")),R(...J)}function P7($,Z,X,z,J){let Y=`where.${Z.name}`,H=Z.kind==="many";if(X===null){if(H)throw new K(Y,$.name,J.operation,`${Z.name} is a to-many relation, so null is not a filter for it. Use { none: {} } for "has no related rows".`);return{is:null,direct:!0}}if(typeof X!=="object"||Array.isArray(X))throw new T(Y,$.name,J.operation,H?`Expected an object holding ${z.join(", ")}.`:"Expected an object, or null.");if(Y9(X,z))return X;if(H)throw new K(Y,$.name,J.operation,`Expected one of ${z.join(", ")}. A to-many relation has no `+"single reading of a bare filter \u2014 { some: \u2026 } and { every: \u2026 } mean "+"different things.");return{is:X,direct:!0}}function j7($,Z,X,z,J){let Y=z3($).find((V)=>V.length>1&&V.join("_")===Z);if(!Y)return null;if(typeof X!=="object"||X===null||Array.isArray(X))throw new T(`where.${Z}`,$.name,z.operation,`Expected an object holding ${Y.join(" and ")}.`);let H=X,G=[];for(let V of Y){if(H[V]===void 0)throw new K(`where.${Z}`,$.name,z.operation,`Missing '${V}'. A composite key needs all of ${Y.join(", ")}.`);if(!v3(H[V]))throw new T(`where.${Z}.${V}`,$.name,z.operation,`A composite key takes a plain value for each of ${Y.join(", ")}, not a filter, an array or null.`);G.push(m3($,$.fields[V],H[V],z,(W)=>J(W)?.[V]))}return G.length===1?G[0]:t(G," and ")}function z9($,Z,X,z,J){let Y=[];if(Array.isArray(Z))for(let H=0;H<Z.length;H++){let G=f($,Z[H],X,(V)=>z(V)?.[H]);if(G)Y.push(G)}else{let H=f($,Z,X,z);if(H)Y.push(H)}if(Y.length===0)return J==="AND"?null:H9;if(Y.length===1)return Y[0];return t(Y,J==="AND"?" and ":" or ")}var H9=j("false");function t($,Z){return R(j("("),x($,Z),j(")"))}function w0($){return $.text.startsWith("(")?$:t([$],"")}var h3=new Set(["equals","not","in","notIn","lt","lte","gt","gte","contains","startsWith","endsWith","mode"]),V9={lt:"<",lte:"<=",gt:">",gte:">="},z0="$compositeIn",G9=Symbol("gemi.orm.compositeInFromPlanner");function W9($,Z){return{[G9]:!0,fields:$,values:Z}}function K7($,Z,X,z){let{dialect:J}=X,H=Q7($,Z,X).map((V)=>{let W=$.fields[V];if(!W)throw new g(V,$.name,Object.keys($.fields));return W}),G=H.map((V)=>`${X.qualifier??""}${J.quoteIdent(V.column)}`);return J.compositeIn(G,H.map((V)=>V.type),(V)=>z(V).values)}function Q7($,Z,X){let z=()=>{throw new g(z0,$.name,Object.keys($.fields))};if(typeof Z!=="object"||Z===null||Array.isArray(Z))return z();if(Z[G9]!==!0)return z();let J=(G)=>{throw new K(z0,$.name,X.operation,G)},{fields:Y,values:H}=Z;if(!Array.isArray(Y)||Y.length===0)return J(`the planner built a '${z0}' with no fields.`);if(!Y.every((G)=>typeof G==="string"))return J(`the planner built a '${z0}' with a non-string field.`);if(!Array.isArray(H))return J(`the planner built a '${z0}' with no values.`);if(!H.every((G)=>Array.isArray(G)&&G.length===Y.length))return J(`the planner built a '${z0}' whose tuples do not all have ${Y.length} value(s).`);return Y}var _7=["equals","has","hasEvery","hasSome","isEmpty"],g3=new Set(_7);function C7($,Z,X,z,J,Y){let{dialect:H}=J;if(O0($,Z,`where.${Z.name}`,J.operation,H),Array.isArray(z))throw new T(`where.${Z.name}`,$.name,J.operation,`'${Z.name}' is a scalar list, and a bare array is not a filter on `+"one \u2014 Prisma rejects it here too. Say which comparison you mean: "+`{ ${Z.name}: { equals: [...] } } for the whole list, or { ${Z.name}: { hasEvery: [...] } } for "contains all of these". A bare array *is* accepted as a value in \`data\`.`);if(!p3(z))throw new T(`where.${Z.name}`,$.name,J.operation,`'${Z.name}' is a scalar list. Expected an object holding ${[...g3].sort().join(", ")}; received ${z===null?"null":typeof z}.`);let G=z,V=[];for(let W of Object.keys(G).sort()){let M=G[W];if(M===void 0)continue;if(!g3.has(W))throw new T(`where.${Z.name}.${W}`,$.name,J.operation,`'${Z.name}' is a scalar list, and a list filter takes ${[...g3].sort().join(", ")}. The scalar operators \u2014 `+`${[...h3].sort().join(", ")} \u2014 apply to a single value and `+"Prisma does not offer them here.");let B=(D)=>Y(D)?.[W];V.push(L7($,Z,X,W,M,J,B))}if(V.length===0)return j("true");if(V.length===1)return V[0];return t(V," and ")}function L7($,Z,X,z,J,Y,H){let{dialect:G}=Y;if(z==="equals")return T7($,Z,X,J,Y,H);if(z==="isEmpty"){if(typeof J!=="boolean")throw new T(`where.${Z.name}.isEmpty`,$.name,Y.operation,`Expected true or false, received ${J===null?"null":typeof J}.`);return G.listIsEmpty(X,J)}if(z==="has"){let W=R7(Z);return G.listHas(X,y(W,G,F0(W,G,H)))}if(!Array.isArray(J))throw new T(`where.${Z.name}.${z}`,$.name,Y.operation,`Expected an array, received ${J===null?"null":typeof J}.`);let V=y(Z,G,F0(Z,G,H));return z==="hasEvery"?G.listHasEvery(X,V):G.listHasSome(X,V)}function T7($,Z,X,z,J,Y){let{dialect:H}=J;if(z===null)return j(`${X} is null`);if(!Array.isArray(z))throw new T(`where.${Z.name}.equals`,$.name,J.operation,`'${Z.name}' is a scalar list, so it compares against an array. Received ${typeof z}. For "is this element present", use { ${Z.name}: { has: \u2026 } }.`);return R(j(`${X} = `),y(Z,H,F0(Z,H,Y)))}function R7($){return{...$,isList:!1}}function O0($,Z,X,z,J){if(J.listFilters.size>0)return;throw new K(X,$.name,z,`'${Z.name}' is a scalar list, and ${J.name} has no array type to hold one. Prisma refuses the column itself on ${J.name} \u2014 `+'"the current connector does not support lists of primitive types" \u2014 so '+`this is a difference between the databases rather than a gap in the ORM. The generated artifact is dialect-agnostic, which is why this surfaces here rather than at \`prisma generate\`: the schema was generated against Postgres and DATABASE_URL names a ${J.name} database, which has no '${Z.column}' column either. It works on postgres.`)}var I7=["equals","not","string_contains","string_starts_with","string_ends_with","array_contains","lt","lte","gt","gte"],y3=new Set(I7),U7=["has_key","has_some_keys","has_every_key"],J3=new Set(U7);function M9($,Z,X,z,J,Y,H,G){let V=z!=="has_key",W=`where.${Z.name}.${z}`,M=(D)=>{if(!(V?Array.isArray(D)&&D.every((Q)=>typeof Q==="string"):typeof D==="string"))throw new T(W,$.name,Y.operation,V?"Expected an array of key names, like ['a', 'b'].":"Expected a key name, like 'a'.");return D};M(J);let B=(D,P)=>M(G(D,P));return Y.dialect.jsonHasKeys(X,H,B,z==="has_key"?"one":z==="has_some_keys"?"some":"every",Array.isArray(J)?J.length:0)}function N7($,Z,X,z,J,Y){let{dialect:H}=J;if(Z.type!=="Json")throw new K(`${Z.name}.path`,$.name,J.operation,`A 'path' filter reads inside a JSON document, and '${Z.name}' is a ${Z.type} column.`);S7($,Z,z.path,J);let G=(M)=>Y(M)?.path,V=Object.keys(z).filter((M)=>M!=="path"&&z[M]!==void 0).sort();if(V.length===0)throw new K(`${Z.name}.path`,$.name,J.operation,`A 'path' needs a filter beside it \u2014 ${[...y3,...J3].sort().join(", ")}. Prisma refuses a bare path too.`);let W=[];for(let M of V){if(J3.has(M)){W.push(M9($,Z,X,M,z[M],J,G,(P)=>Y(P)?.[M]));continue}if(!y3.has(M))throw new K(`${Z.name}.${M}`,$.name,J.operation,`A JSON path filter takes ${[...y3,...J3].sort().join(", ")}.`);if(!H.jsonFilters.has(M))throw new K(`${Z.name}.${M}`,$.name,J.operation,`'${M}' on a JSON path is not available on ${H.name}. Prisma refuses it here too, so this is a difference between the databases rather than a gap in the ORM. It works on postgres.`);let B=z[M],D=B===null?"json":k(B);if(D&&(M==="equals"||M==="not")){W.push(F7(D,X,G,Z,H,M==="not"));continue}if(D&&B!==null){let P=M==="array_contains"?"'array_contains' tests containment against a document, and a sentinel is not one":`'${M}' compares an extracted value against a scalar, and a sentinel is not one`;throw new T(`where.${Z.name}.${M}`,$.name,J.operation,`${x0(D)} asks which kind of null a value is, which `+`only 'equals' and 'not' can express \u2014 ${P}. Prisma refuses it under this operator too. Write { ${Z.name}: { path: [\u2026], equals: ${x0(D)} } }, `+"or filter the column itself \u2014 "+`{ ${Z.name}: { equals: ${x0(D)} } }.`)}if(B9(B))throw new T(`where.${Z.name}.${M}`,$.name,J.operation,"Prisma.AnyNull is a question rather than a value \u2014 'either kind of "+"null' \u2014 so it cannot appear inside a document. Ask it directly: "+`{ ${Z.name}: { path: [\u2026], equals: Prisma.AnyNull } }.`);O7(M,B,$,Z,J),W.push(A7(M,X,G,Z,H,(P)=>Y(P)?.[M]))}return W.length===1?W[0]:t(W," and ")}function F7($,Z,X,z,J,Y){let H=()=>R(J.jsonValueAt(Z,X),j(Y?" is not null":" is null")),G=()=>R(J.jsonValueAt(Z,X),j(Y?" <> ":" = "),y(z,J,()=>J.encode(u3,z)));if($==="db")return H();if($==="json")return G();return t([G(),H()],Y?" and ":" or ")}function O7($,Z,X,z,J){let Y=$==="string_contains"||$==="string_starts_with"||$==="string_ends_with";if(Y&&typeof Z!=="string")throw new T(`where.${z.name}.${$}`,X.name,J.operation,`Expected a string, received ${Z===null?"null":typeof Z}. Prisma raises here too \u2014 without this the pattern becomes `+`'%${String(Z)}%', which runs and returns the wrong rows.`);if(Z===null)throw new T(`where.${z.name}.${$}`,X.name,J.operation,$==="array_contains"?"null cannot be tested for containment through a JSON path: the operand binds as SQL NULL rather than as the JSON value, and "+"'x @> NULL' is NULL rather than true \u2014 the query would run and "+`match nothing. A null *inside* the document is an ordinary value and still compiles: { ${z.name}: { path: [\u2026], array_contains: [null] } }.`:`null cannot be compared through a JSON path with '${$}', which `+"compares the extracted value as a number \u2014 the comparison against "+`NULL is NULL rather than true, so the query would run and match nothing. Prisma refuses it here too. For "the value at this path is a JSON null", use equals or not: { ${z.name}: { path: [\u2026], equals: null } }.`);if($==="array_contains"||Y)return;if(typeof Z==="object")throw new K(`where.${z.name}.${$}`,X.name,J.operation,`'${$}' on a JSON path compares the extracted value as a scalar, so `+"an object or array operand cannot be expressed \u2014 it would bind as "+`'${String(Z)}' and match nothing. Prisma accepts one here; gemi does not yet. Use array_contains for containment, or narrow the path until it names a scalar.`)}function A7($,Z,X,z,J,Y){if($==="array_contains")return J.jsonArrayContains(Z,X,Y);let H=$==="string_contains"||$==="string_starts_with"||$==="string_ends_with",G=J.jsonExtract(Z,X,!0);if(H){let B=$==="string_contains"?(D)=>`%${D}%`:$==="string_starts_with"?(D)=>`${D}%`:(D)=>`%${D}`;return R(j("("),G,j(") like "),n((D,P)=>{let Q=Y(D,P);return Q===null||Q===void 0?null:B(String(Q))}))}let V=$==="equals"?"=":$==="not"?"<>":V9[$],W=$!=="equals"&&$!=="not",M=W?R(j("cast(("),G,j(") as real)")):R(j("("),G,j(")"));return R(M,j(` ${V} `),n((B,D)=>{let P=Y(B,D);if(P===null||P===void 0)return null;if(W)return Number(P);return J.jsonComparesAsText?String(P):P}))}function S7($,Z,X,z){let{dialect:J}=z,Y=J.jsonPathSyntax==="array"?"array":"jsonpath",H=Array.isArray(X)?"array":typeof X==="string"?"jsonpath":"other";if(Array.isArray(X)&&X.length===0||X==="")throw new K(`${Z.name}.path`,$.name,z.operation,`A JSON path cannot be empty. ${J.jsonPathSyntax==="array"?`On ${J.name} an empty array selects the whole document, `+"which is a filter on the column rather than on a path \u2014 write "+`{ ${Z.name}: { equals: \u2026 } } if that is what you meant.`:`On ${J.name} an empty string raises inside json_extract.`}`);if(H===Y){if(Y!=="array")return;let V=X.findIndex((B)=>typeof B!=="string");if(V===-1)return;let W=X[V],M=W===null?"null":W===void 0?"undefined":Array.isArray(W)?"an array":typeof W==="object"?"an object":`a ${typeof W}`;throw new K(`${Z.name}.path`,$.name,z.operation,`A JSON path is an array of strings, and path[${V}] is ${M}. `+(typeof W==="number"?'An array index is a key too \u2014 write ["items", "0"] rather than '+`["items", 0]; it reaches the same element, because ${J.name} takes the path as text. Prisma's path is string[] and its client refuses a number here too.`:"Prisma's path is string[] too."))}throw new K(`${Z.name}.path`,$.name,z.operation,J.jsonPathSyntax==="array"?`On ${J.name} a JSON path is an array of keys \u2014 ["a", "b"] \u2014 `+"not a JSONPath string. Prisma splits them the same way, and refuses the other form on each database.":`On ${J.name} a JSON path is a JSONPath string \u2014 "$.a.b" \u2014 not `+"an array of keys. Prisma splits them the same way, and refuses the other form on each database.")}function m3($,Z,X,z,J){let{dialect:Y}=z,H=`${z.qualifier??""}${Y.quoteIdent(Z.column)}`,G=k(X);if(G)throw new T(`where.${Z.name}`,$.name,z.operation,`${x0(G)} is not a filter on `+"its own \u2014 Prisma rejects it here too. Write it as an explicit "+`comparison: { ${Z.name}: { equals: ${x0(G)} } }.`);if(Z.isList)return C7($,Z,H,X,z,J);if(!p3(X))return Y3(H,Z,X,Y,J);let V=X,W=Object.keys(V).sort();if(V.path!==void 0)return N7($,Z,H,V,z,J);let M=V.mode==="insensitive";if(V.mode!==void 0&&V.mode!=="default"){if(!M)throw new T(`mode: ${JSON.stringify(V.mode)}`,$.name,z.operation,"Prisma takes 'default' or 'insensitive'.");if(!Y.supportsInsensitiveMode)throw new K('mode: "insensitive"',$.name,z.operation,`The ${Y.name} dialect cannot express it \u2014 Prisma rejects it `+"here too. Note SQLite's LIKE is already case-insensitive for ASCII.")}let B=[];for(let D of W){let P=V[D];if(P===void 0||D==="mode")continue;if(Z.type==="Json"&&J3.has(D)){B.push(M9($,Z,H,D,P,z,void 0,(C)=>J(C)?.[D]));continue}if(!h3.has(D))throw new T(`where.${Z.name}.${D}`,$.name,z.operation,`A scalar filter takes ${[...h3].sort().join(", ")}.`);if(D!=="equals"&&D!=="not"&&B9(P))throw new T(`where.${Z.name}.${D}`,$.name,z.operation,`Prisma.AnyNull means 'either kind of null', which only 'equals' and 'not' can express. Write { ${Z.name}: { equals: Prisma.AnyNull } }, or name the one you mean with Prisma.DbNull or Prisma.JsonNull.`);let Q=(C)=>J(C)?.[D];switch(D){case"equals":B.push(Y3(H,Z,P,Y,Q));break;case"not":B.push(b7($,Z,P,z,Q,H));break;case"in":case"notIn":B.push(E7($,H,Z,P,z,Q,D==="notIn"));break;case"lt":case"lte":case"gt":case"gte":B.push(R(j(`${H} ${V9[D]} `),y(Z,Y,F0(Z,Y,Q))));break;case"contains":case"startsWith":case"endsWith":if(typeof P!=="string")throw new T(`where.${Z.name}.${D}`,$.name,z.operation,`Expected a string, received ${P===null?"null":typeof P}.`);if(Z.type!=="String")throw new K(`where.${Z.name}.${D}`,$.name,z.operation,`'${Z.name}' is a ${Z.type}, and ${D} only applies to strings.`);B.push(Y.like(H,M,w7(D,Q)));break}}if(B.length===0)return j("true");if(B.length===1)return B[0];return t(B," and ")}function x0($){return`Prisma.${$==="db"?"DbNull":$==="json"?"JsonNull":"AnyNull"}`}function B9($){if(k($)==="any")return!0;return Array.isArray($)&&$.some((Z)=>k(Z)==="any")}function b7($,Z,X,z,J,Y){if(X===null||k(X)==="db")return j(`${Y} is not null`);if(k(X)==="json")return R(j("not "),w0(Y3(Y,Z,X,z.dialect,J)));if(k(X)==="any")return R(j("not "),w0(Y3(Y,Z,X,z.dialect,J)));if(!p3(X))return R(j(`${Y} <> `),y(Z,z.dialect,F0(Z,z.dialect,J)));let H=m3($,Z,X,z,J);return R(j("not "),w0(H))}function Y3($,Z,X,z,J){if(X===null||k(X)==="db")return j(`${$} is null`);if(k(X)==="any")return t([j(`${$} is null`),q7($,Z,z)]," or ");return R(j(`${$} = `),y(Z,z,F0(Z,z,J)))}function q7($,Z,X){return R(j(`${$} = `),y(Z,X,()=>X.encode(u3,Z)))}function E7($,Z,X,z,J,Y,H){let{dialect:G}=J;if(!Array.isArray(z))throw new T(`where.${X.name}.${H?"notIn":"in"}`,$.name,J.operation,"Expected an array.");if(z.length===0)return H?j("true"):H9;return G.inList(Z,H,z.length,(V)=>{return Y(V).map((M)=>G.encode(M,X))})}function w7($,Z){return(X)=>{let z=String(Z(X));if($==="contains")return`%${z}%`;if($==="startsWith")return`${z}%`;return`%${z}`}}function F0($,Z,X){return(z)=>Z.encode(X(z),$)}function p3($){return typeof $==="object"&&$!==null&&!Array.isArray($)&&!($ instanceof Date)&&!ArrayBuffer.isView($)}function D9($,Z,X,z,J,Y,H){let G=`orderBy.${Z.name}`;if(typeof X!=="object"||X===null||Array.isArray(X))throw new T(G,$.name,z,Z.kind==="many"?'Expected { _count: "asc" | "desc" }.':`Expected an object naming one field of ${Z.model}.`);let V=X,W=Object.keys(V).filter((C)=>C!=="where");if(W.length!==1)throw new K(G,$.name,z,W.length===0?"Name the field to order by.":`Name exactly one field to order by; got ${W.join(", ")}. `+"Order by several with an array: [{ a: \u2026 }, { b: \u2026 }].");let[M]=W,B=N0($,Z,J,`_o${H}`,`${J.quoteIdent($.table)}.`,z),D=x7($,Z,B.child,M,V[M],z,B.qualifier,J),P=f(B.child,V.where,{dialect:J,operation:z,qualifier:B.qualifier},(C)=>Y(C)?.where),Q=[j(`(select ${D.expression} from ${B.source} where ${B.correlation}`)];if(P)Q.push(j(" and "),P);return Q.push(j(")")),{expression:R(...Q),direction:D.direction,nulls:D.nulls}}function x7($,Z,X,z,J,Y,H,G){let V=`orderBy.${Z.name}.${z}`,{direction:W,nulls:M}=v7($,V,J,Y);if(z===l){if(Z.kind!=="many")throw new K(V,$.name,Y,`${Z.name} is a to-one relation, so its count is 0 or 1. Order by one of ${X.name}'s fields instead.`);return{expression:"count(*)",direction:W,nulls:M}}if(Z.kind==="many")throw new K(V,$.name,Y,`${Z.name} is a to-many relation, so ordering by '${z}' has no single answer for a parent with several children. Only `+"{ _count: \u2026 } is supported.");let B=X.fields[z];if(!B)throw new K(V,$.name,Y,`'${z}' is not a field on ${X.name}. Known fields: ${Object.keys(X.fields).join(", ")}.`);return{expression:`${H}${G.quoteIdent(B.column)}`,direction:W,nulls:M}}function v7($,Z,X,z){if(X==="asc"||X==="desc")return{direction:X};if(typeof X==="object"&&X!==null){let{sort:J,nulls:Y}=X;if(J!=="asc"&&J!=="desc")throw new T(Z,$.name,z,'Expected "asc" or "desc".');if(Y===void 0)return{direction:J};if(Y!=="first"&&Y!=="last")throw new K(`${Z}.nulls`,$.name,z,'Expected "first" or "last".');return{direction:J,nulls:Y}}throw new K(Z,$.name,z,'Expected "asc", "desc", or { sort, nulls }.')}var k7=new Set(["asc","desc"]),f7=new Set(["first","last"]);function D0($,Z,X,z){if(Z===void 0||Z===null)return[];let J=Array.isArray(Z),Y=J?Z:[Z],H=[];for(let G=0;G<Y.length;G++){let V=Y[G],W=(M)=>{let B=z?.locate(M);return J?B?.[G]:B};if(typeof V!=="object"||V===null)throw new T("orderBy",$.name,X,"Expected an object or an array of objects.");for(let[M,B]of Object.entries(V)){if(B===void 0)continue;if(M in $.relations){if(!z)throw new K(`orderBy.${M}`,$.name,X,"Ordering by a relation is not implemented here.");let P=D9($,$.relations[M],B,X,z.dialect,(Q)=>W(Q)?.[M],H.length);H.push({column:M,direction:P.direction,...P.nulls?{nulls:P.nulls}:{},expression:P.expression});continue}let D=$.fields[M];if(!D)throw new g(M,$.name,Object.keys($.fields));H.push({column:D.column,...P9($,M,B,X)})}}return H}function P9($,Z,X,z){if(typeof X==="string"){if(!k7.has(X))throw new T(`orderBy.${Z}: ${JSON.stringify(X)}`,$.name,z,'Expected "asc" or "desc".');return{direction:X}}if(typeof X==="object"&&X!==null){let{sort:J,nulls:Y}=X,H=P9($,Z,J,z).direction;if(Y===void 0)return{direction:H};if(typeof Y!=="string"||!f7.has(Y))throw new K(`orderBy.${Z}.nulls: ${JSON.stringify(Y)}`,$.name,z,'Expected "first" or "last".');return{direction:H,nulls:Y}}throw new K(`orderBy.${Z}`,$.name,z,'Expected "asc", "desc", or { sort, nulls }.')}function H3($){return $.map((Z)=>({...Z,direction:Z.direction==="asc"?"desc":"asc",...Z.nulls?{nulls:Z.nulls==="first"?"last":"first"}:{}}))}function r($,Z,X){if($.length===0)return null;return x($.map((z)=>{let J=` ${z.direction}`+(z.nulls?` nulls ${z.nulls}`:"");if(z.expression)return x([z.expression,j(J)],"");return j(`${X??""}${Z.quoteIdent(z.column)}${J}`)}),", ")}function V3($,Z,X,z,J){if(typeof J!=="number"||!Number.isInteger(J))throw new T(X,$,Z,`Expected an integer, got ${JSON.stringify(J)}.`);if(z==="skip"&&J<0)throw new T(X,$,Z,"A 'skip' counts rows to pass over, so it cannot be negative. Prisma rejects one too.")}function Q0($,Z,X,z,J,Y=!1){if(X?.take!==void 0)V3($.name,Z,"take","take",X.take);if(X?.skip!==void 0)V3($.name,Z,"skip","skip",X.skip);let H=Y?1:X?.take,G=X?.skip,V=J;if((H!==void 0||G!==void 0)&&V.length===0&&!Y)V=$.primaryKey.map((P)=>({column:$.fields[P]?.column??P,direction:"asc"}));let M=typeof H==="number"&&H<0;if(M)V=H3(V);let B=H===void 0?null:Y?()=>1:(P)=>Math.abs(Number(P?.take)),D=G===void 0?null:(P)=>Number(P?.skip);return{clause:z.paginate(B,D),terms:V,reversed:M}}function J0($,Z,X){let z=Z?.select,J=Z?.omit;if(z!==void 0&&Z?.include!==void 0)throw new K("select + include",$.name,X,"Prisma allows only one of them on the same query.");if(z!==void 0&&J!==void 0)throw new K("select + omit",$.name,X,"'select' names what to keep and 'omit' what to drop, so the two describe different column lists. Prisma allows only one of them on "+"the same query. Drop the 'omit' \u2014 a 'select' already excludes "+"everything it does not name.");if(z===void 0||z===null)return g7($,J,X);if(typeof z!=="object"||Array.isArray(z))throw new T("select",$.name,X,"Expected an object.");let Y=[];for(let[G,V]of Object.entries($.fields))if(z[G]===!0)Y.push(V);let H=0;for(let G of Object.keys(z)){let V=z[G];if(V===void 0)continue;if(G in $.relations){if(V!==!1)H++;continue}if(G===l){if(V!==!1)H++;continue}if(!(G in $.fields))throw new g(G,$.name,Object.keys($.fields));if(typeof V!=="boolean")throw new T(`select.${G}`,$.name,X,"Expected true or false.")}if(Y.length===0&&H===0)throw new K("select",$.name,X,"At least one field must be selected.");return Y}function g7($,Z,X){if(Z===void 0||Z===null)return Object.values($.fields);if(typeof Z!=="object"||Array.isArray(Z))throw new T("omit",$.name,X,"Expected an object of fields.");let z=new Set;for(let Y of Object.keys(Z)){let H=Z[Y];if(H===void 0)continue;if(Y in $.relations)throw new K(`omit.${Y}`,$.name,X,`'${Y}' is a relation, not a column. A relation is already absent unless an 'include' asks for it.`);if(!(Y in $.fields))throw new g(Y,$.name,Object.keys($.fields));if(typeof H!=="boolean")throw new T(`omit.${Y}`,$.name,X,"Expected true or false.");if(H)z.add(Y)}let J=Object.values($.fields).filter((Y)=>!z.has(Y.name));if(J.length===0)throw new K("omit",$.name,X,`It omits every field on ${$.name}, which leaves no column to select. Prisma rejects that too.`);return J}function G3($,Z,X){if(X.length===0)return{fields:Z};let z=new Set(Z.map((H)=>H.name)),J=X.filter((H)=>!z.has(H));if(J.length===0)return{fields:Z};let Y=new Set([...z,...J]);return{fields:Object.values($.fields).filter((H)=>Y.has(H.name)),hidden:J}}var j9=new Set(["where","orderBy","select","omit","include","take","skip"]),K9=new Set(["where","select","omit","include"]),B3=10;function h0($){return[...new Set($.map((Z)=>Z.strategy))].sort()}function S0($,Z,X,z,J=P0){let Y=u0($,Z,z);if(Y.length===0)return{plans:[],keyFields:[]};let H=[],G=new Set;for(let V of Y){T9($,V,z);let W=U9($,V);R9(W,V.node,z,2);let M=J.plan({parent:$,child:W,relation:V.relation,as:V.as,node:V.node,locate:V.locate,dialect:X,operation:z});H.push(M);for(let B of M.parentFields)G.add(B)}return{plans:H,keyFields:[...G]}}async function P3($,Z,X,z,J){let Y=Array.isArray(X)?X:X===null||X===void 0?[]:[X];if(Y.length===0)return;for(let H of $){if(H.root)continue;await H.load(Y,z,J)}if(Z&&Z.length>0)for(let H of Y)for(let G of Z)delete H[G]}function u0($,Z,X){if(Z===void 0||Z===null)return[];let{include:z,select:J}=Z;L9($,z,J,X);let Y=[];if(z!==void 0&&z!==null){if(typeof z!=="object"||Array.isArray(z))throw new T("include",$.name,X,"Expected an object.");for(let H of Object.keys(z).sort()){let G=z[H];if(G===void 0||G===!1)continue;if(H===l)continue;let V=$.relations[H];if(!V)throw new f0(H,$.name,Object.keys($.relations));Y.push({as:H,relation:V,node:G,locate:(W)=>W?.include?.[H]})}return Y}if(J!==void 0&&J!==null&&typeof J==="object")for(let H of Object.keys(J).sort()){let G=J[H];if(G===void 0||G===!1)continue;let V=$.relations[H];if(!V)continue;Y.push({as:H,relation:V,node:G,locate:(W)=>W?.select?.[H]})}return Y}function L9($,Z,X,z,J){if(Z===void 0||X===void 0)return;throw new K(J?`${J}: select + include`:"select + include",$.name,z,"Prisma allows only one of them on the same query, at any level.")}function T9($,Z,X){let z=Z.node;if(z===!0)return;if(typeof z!=="object"||z===null||Array.isArray(z))throw new T(Z.as,$.name,X,"Expected true or an object of relation arguments.");let J=z;L9($,J.include,J.select,X,Z.as);let Y=Z.relation.kind==="many";for(let H of Object.keys(J).sort()){if(J[H]===void 0)continue;if(Y&&(H==="take"||H==="skip")){y7($,Z,X,H,J[H]);continue}if(Y?j9.has(H):K9.has(H))continue;if(H==="lock")throw new k0(`${Z.as}.lock`,$.name,X,"'lock' locks the rows of the model being queried, not an included relation's. Lock the related rows with their own locking read in the same transaction.");if(H==="orderBy"&&!Y)throw new K(`${Z.as}.orderBy`,$.name,X,"Prisma does not accept 'orderBy' on a to-one relation \u2014 there is at "+"most one row to order.");if(H==="take"||H==="skip")throw new K(`${Z.as}.${H}`,$.name,X,`Prisma does not accept '${H}' on a to-one relation.`);throw new K(`${Z.as}.${H}`,$.name,X,`A relation node takes ${[...Y?j9:K9].sort().join(", ")}.`)}}function y7($,Z,X,z,J){V3($.name,X,`${Z.as}.${z}`,z,J)}function s3($,Z){let X=$.node;if(typeof X!=="object"||X===null||Array.isArray(X))return;for(let z of["take","skip"]){if(X[z]===void 0)continue;throw new K(`${$.as}.${z}`,$.parent.name,$.operation,`A '${z}' inside a to-many relation is per parent, and the batched `+"relation planner serves every parent from one query \u2014 so the only "+`limit it could emit would page every parent's children as one set. Only the lateral join strategy can express it, by paginating inside a subquery that already runs once per parent row, and it needs Postgres: ${Z}. Load '${$.as}' as its own query, or narrow it with 'where'.`)}}function R9($,Z,X,z){if(typeof Z!=="object"||Z===null||Array.isArray(Z))return;if(Z.select!==void 0)J0($,Z,X);let J=u0($,Z,X);if(J.length===0)return;if(z>B3)throw new d3($.name,B3);for(let Y of J)T9($,Y,X),R9(U9($,Y),Y.node,X,z+1)}function I9($,Z,X,z){if($.parentFields.length!==1)throw new K(X.name,Z.name,z,`${X.name} joins on ${$.parentFields.length} fields (${$.parentFields.join(", ")}), and it is planned through a join table, which links two models by a single primary key each side. Prisma does not build an implicit many-to-many over a composite key.`);return{parentField:$.parentFields[0],childField:$.childFields[0],join:$.join}}function B0($,Z,X,z){if(X.joinTable)return u7($,Z,X);if(X.from.length>0)return Q9($,X,X.from,X.to,z);let J=h7($,Z,X);if(J.from.length===0)throw new s($.name,X.name,`neither ${$.name}.${X.name} nor ${Z.name}.${J.name} holds the foreign key.`);return Q9($,X,J.to,J.from,z)}function Q9($,Z,X,z,J){if(X.length===0)throw new K(Z.name,$.name,J,`${Z.name} names no join fields.`);if(X.length!==z.length)throw new s($.name,Z.name,`it joins ${X.length} field(s) to ${z.length}: ${X.join(", ")} against ${z.join(", ")}.`);return{parentFields:X,childFields:z}}function h7($,Z,X){let z=Object.values(Z.relations).filter((J)=>J.relationName===X.relationName&&!(Z.name===$.name&&J.name===X.name));if(z.length!==1)throw new s($.name,X.name,z.length===0?`${Z.name} declares no relation named '${X.relationName}'.`:`${Z.name} declares ${z.length} relations named '${X.relationName}'.`);return z[0]}function u7($,Z,X){let{table:z,a:J,b:Y}=X.joinTable;if(J===Y){let G=X.joinTable.ownerColumn;if(!G)throw new K(X.name,$.name,"include",`${X.name} is a self-referential implicit many-to-many, and the generated artifact predates support for one. Re-run \`prisma generate\`.`);return{parentFields:[W3($,X)],childFields:[W3(Z,X)],join:{table:z,parentColumn:G,childColumn:G==="A"?"B":"A"}}}if($.name!==J&&$.name!==Y)throw new s($.name,X.name,`the join table '${z}' connects ${J} and ${Y}, neither of which is ${$.name}.`);let H=$.name===J?"A":"B";return{parentFields:[W3($,X)],childFields:[W3(Z,X)],join:{table:z,parentColumn:H,childColumn:H==="A"?"B":"A"}}}function W3($,Z){if($.primaryKey.length!==1)throw new s($.name,Z.name,`an implicit many-to-many joins on ${$.name}'s primary key, which has ${$.primaryKey.length} fields.`);return $.primaryKey[0]}function M3($,Z,X){let z=$.fields[X];if(!z)throw new s($.name,Z.name,`it joins on '${X}', which is not a field on ${$.name}.`);return z}function U9($,Z){return X0($,Z.relation,Z.as)}function X0($,Z,X=Z.name){let z=Z.model;if(!a(z))throw new c3($.name,X,z,D3());let J=d(z)?.$schema;if(!J)throw new g0(z);return J}var _9="batched",P0={name:_9,plan($){s3($,"this query planned with the batched strategy");let Z=B0($.parent,$.child,$.relation,$.operation);for(let Y of Z.parentFields)C9($.parent,$.relation,M3($.parent,$.relation,Y));for(let Y of Z.childFields)C9($.child,$.relation,M3($.child,$.relation,Y));let X=M3($.parent,$.relation,Z.parentFields[0]),z=M3($.child,$.relation,Z.childFields[0]),J=$.relation.kind==="many";return{as:$.as,model:$.relation.model,kind:$.relation.kind,parentFields:Z.parentFields,strategy:_9,load(Y,H,G){let V={parentKeyField:X,childKeyField:z,many:J,parents:Y,args:H,executor:G};return Z.join?p7($,Z,V):m7($,Z,V)}}}};async function m7($,Z,X){let{keys:z,byKey:J}=O9(X.parents,Z.parentFields);if(z.length===0)return;let Y=$.locate(X.args),H=N9(Y,Z.childFields,z,$.child,$.dialect),G=await X.executor.exec($.relation.model,"findMany",H.args,!0);for(let V of G){let W=J.get(v0(Z.childFields.map((M)=>V[M])));if(!W)continue;for(let M of W)F9(M,$.as,V,X.many)}if(H.hidden)for(let V of G)for(let W of Z.childFields)delete V[W]}async function p7($,Z,X){let{keys:z,byKey:J}=O9(X.parents,Z.parentFields);if(z.length===0)return;let{dialect:Y}=$,H=Z.join,G=await d7(Y,H,z.map((P)=>Y.encode(P[0],X.parentKeyField)),X.executor),V=new Map,W=[];for(let P of G){let Q=v0([Y.decode(P[H.parentColumn],X.parentKeyField)]),C=J.get(Q);if(!C)continue;let F=Y.decode(P[H.childColumn],X.childKeyField),N=v0([F]),L=V.get(N);if(L===void 0)L=[],V.set(N,L),W.push([F]);for(let _ of C)L.push(_)}if(W.length===0)return;let M=$.locate(X.args),B=N9(M,Z.childFields,W,$.child,$.dialect),D=await X.executor.exec($.relation.model,"findMany",B.args,!0);for(let P of D){let Q=V.get(v0([P[Z.childFields[0]]]));if(!Q)continue;for(let C of Q)F9(C,$.as,P,X.many)}if(B.hidden)for(let P of D)delete P[Z.childFields[0]]}async function d7($,Z,X,z){let J=R(j(`select ${$.quoteIdent(Z.parentColumn)}, ${$.quoteIdent(Z.childColumn)} from ${$.quoteIdent(Z.table)} where `),$.inList($.quoteIdent(Z.parentColumn),!1,X.length,()=>X)),{text:Y,binders:H}=c(J,$,{model:Z.table,operation:"include"}),G=A0();return z.query(Y,H.map((V)=>V(void 0,G)))}function N9($,Z,X,z,J){let Y=$===!0||$===null||typeof $!=="object"?{}:$,H=Z.length===1?{[Z[0]]:{in:X.map((B)=>B[0])}}:c7(z,Z,X,J),G={where:Y.where===void 0?H:{AND:[Y.where,H]}};if(Y.orderBy!==void 0)G.orderBy=Y.orderBy;if(Y.include!==void 0)G.include=Y.include;let V=Y.omit;if(V!==void 0){let B=Z.filter((D)=>V[D]===!0);if(B.length===0)G.omit=V;else{let D={...V};for(let P of B)delete D[P];return G.omit=D,{args:G,hidden:!0}}}let W=Y.select;if(W===void 0)return{args:G,hidden:!1};let M=Z.filter((B)=>W[B]!==!0);if(M.length===0)return G.select=W,{args:G,hidden:!1};G.select={...W};for(let B of M)G.select[B]=!0;return{args:G,hidden:!0}}function c7($,Z,X,z){let J=Z.map((Y)=>$.fields[Y]?.type);if(J.every((Y)=>Y!==void 0)&&z.canBindCompositeIn(J))return{[z0]:W9(Z,X)};return{OR:X.map((Y)=>Object.fromEntries(Z.map((H,G)=>[H,Y[G]])))}}function v0($){return JSON.stringify($.map(s7))}function F9($,Z,X,z){if(z){$[Z].push(X);return}if($[Z]===null)$[Z]=X}function O9($,Z){let X=new Map,z=[];for(let J of $){let Y=Z.map((V)=>J[V]);if(Y.some((V)=>V===null||V===void 0))continue;let H=v0(Y),G=X.get(H);if(G===void 0)G=[],X.set(H,G),z.push(Y);G.push(J)}return{keys:z,byKey:X}}function s7($){if(typeof $!=="object"||$===null)return $;if($ instanceof Date)return $.getTime();if(ArrayBuffer.isView($)){let Z=new Uint8Array($.buffer,$.byteOffset,$.byteLength),X="";for(let z of Z)X+=z.toString(16).padStart(2,"0");return`bytes:${X}`}throw Error(`Cannot key a relation stitch on ${Object.prototype.toString.call($)}.`)}function C9($,Z,X){if(X.isList)throw new s($.name,Z.name,`it joins on '${X.name}', a ${X.type} list \u2014 which decodes to a new `+"array per row and so cannot be compared between the two sides.");if(X.type!=="Json")return;throw new s($.name,Z.name,`it joins on '${X.name}', a ${X.type} \u2014 which decodes to a new object `+"per row and so cannot be compared between the two sides.")}var A9=(()=>{try{return Function("return 1")()===1}catch{return!1}})(),S9=!0;function i7($){S9=$}function n7(){return A9}function m0($,Z,X=[]){if(A9&&S9)return l7($,Z,X);return i3($,Z,X)}function i3($,Z,X=[]){let z=$.map((G)=>({key:G.name,column:G.column,field:G,decode:Z.needsDecode(G)})),J=z.length,Y=X.map((G)=>({key:G.key,many:G.kind==="many"})),H=Y.length;return(G)=>{let V=[];for(let W=0;W<G.length;W++){let M=G[W],B={};for(let D=0;D<J;D++){let P=z[D],Q=M[P.column];B[P.key]=P.decode?Z.decode(Q,P.field):Q??null}for(let D=0;D<H;D++)B[Y[D].key]=Y[D].many?[]:null;V.push(B)}return V}}function l7($,Z,X){let z=[];for(let Y=0;Y<$.length;Y++){let H=$[Y],G=JSON.stringify(H.name),V=JSON.stringify(H.column);z.push(Z.needsDecode(H)?`${G}: d.decode(row[${V}], f[${Y}])`:`${G}: row[${V}] ?? null`)}for(let Y of X)z.push(`${JSON.stringify(Y.key)}: ${Y.kind==="many"?"[]":"null"}`);let J=`
|
|
3
3
|
return function shape(rows) {
|
|
4
4
|
const out = [];
|
|
5
5
|
for (let i = 0; i < rows.length; i++) {
|
package/dist/probe/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Yl as $}from"../chunk-65r1ne8r.js";import"../chunk-0a5png2z.js";import{existsSync as V,readFileSync as x,statSync as B}from"fs";import{join as W,resolve as T}from"path";var w=".probe",I=[".ts",".js"],O="probes.json",M="__gemiProbe__",Z="/__gemi_probe_entry__.ts",U=/^[A-Za-z0-9_-]+(\/[A-Za-z0-9_-]+)*$/;function Y(k){if(typeof k!=="string"||!U.test(k))throw Error(`A probe is named by its path under app/ without the ".probe.ts" suffix, e.g. "utils/layout". Got ${JSON.stringify(k)}.`)}function j(k,q){for(let z of I){let C=W(k,`${q}${w}${z}`);if(V(C))return C}return null}async function A(k){let q=await Bun.build({entrypoints:[Z],files:{[Z]:`import probe from ${JSON.stringify(k)};
|
|
3
3
|
${M}(probe);
|
|
4
4
|
`},target:"browser",format:"iife",minify:!0,metafile:!0,throw:!1});if(!q.success||!q.outputs[0]){let C=q.logs.map((H)=>String(H)).join(`
|
|
5
5
|
`);throw Error(`The probe ${k} does not bundle.
|
|
6
6
|
${C}`)}let z=Object.keys(q.metafile?.inputs??{}).map((C)=>T(C)).filter((C)=>C!==Z&&V(C));return{source:(await q.outputs[0].text()).trim(),inputs:z}}async function P(k){return(await A(k)).source}async function y(k){let q={};if(!V(k))return q;let C=[...new Bun.Glob(`**/*${w}.{ts,js}`).scanSync({cwd:k})].sort();for(let H of C){if(H.split("/").includes("node_modules"))continue;let G=H.replace(/\.probe\.[tj]s$/,"");if(!U.test(G)||G in q)continue;q[G]=await P(W(k,H))}return q}var Q,K=new Map;function R(){if(Q===void 0){let k=W($(),"dist","server",O);Q=V(k)?JSON.parse(x(k,"utf8")):null}return Q??null}function X(k){try{return B(k).mtimeMs}catch{return-1}}function D(k){for(let[q,z]of k)if(X(q)!==z)return!0;return!1}function E(){Q=void 0,K.clear()}async function h(k){Y(k);let q=Bun.env.NODE_ENV==="production";if(q){let J=R()?.[k];if(J!==void 0)return J}let z=K.get(k);if(z&&(z.stamps===null||!D(z.stamps)))return(await z.pending).source;let C=j(W($(),"app"),k);if(!C)throw Error(`The probe "${k}" was not found. It is a file at app/${k}${w}.ts (or .js).`);let H=Date.now(),G={pending:A(C),stamps:null};K.set(k,G);try{let J=await G.pending;if(!q)G.stamps=new Map(J.inputs.map((v)=>{let L=X(v);return[v,L>=H?-2:L]}));return J.source}catch(J){if(K.get(k)===G)K.delete(k);throw J}}function F(k,q){let z=JSON.stringify(q);if(z===void 0)throw Error("A probe's arguments must be JSON values.");return`(() => { let __gemiProbeFn__; const ${M} = (fn) => { __gemiProbeFn__ = fn; }; ${k}; return __gemiProbeFn__(...${z}); })()`}class _{name;constructor(k){this.name=k;Y(k)}source(){return h(this.name)}async expression(...k){return F(await this.source(),k)}async run(k,...q){return await k.evaluate(await this.expression(...q))}}function d(k){return new _(k)}export{E as resetProbes,h as probeSource,j as probeFile,F as probeExpression,d as probe,y as bundleProbes,P as bundleProbe,_ as Probe,w as PROBE_SUFFIX,O as PROBES_MANIFEST};
|
|
7
7
|
|
|
8
|
-
//# debugId=
|
|
8
|
+
//# debugId=AA803DD91A3A080064756E2164756E21
|
package/dist/probe/index.js.map
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"import { existsSync, readFileSync, statSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { projectRoot } from \"../support/discover\";\n\n/**\n * Browser probes (#1020): code an app runs in a headless browser's page with\n * `page.evaluate`, written as a normal module.\n *\n * `page.evaluate` sends one function's source to the browser, so it may use\n * nothing from outside itself. A probe is a module under `app/` named\n * `*.probe.ts` (or `.js`) whose default export is the function to run; it can\n * import helpers like any module. gemi bundles it into one self-contained,\n * minified IIFE for the browser and hands it to `page.evaluate` as an\n * expression that calls the default export with the given arguments.\n *\n * `gemi build` bundles every probe into `dist/server/probes.json` (name →\n * source), which `gemi start` reads. Anywhere else (dev, tests) a probe is\n * bundled on first use and kept until it, or a file it imports, changes.\n *\n * A probe is named by its path under `app/` without the suffix:\n * `app/utils/layout.probe.ts` is `\"utils/layout\"`.\n */\n\n/** The suffix that marks a file under `app` as a probe. */\nexport const PROBE_SUFFIX = \".probe\";\nconst EXTENSIONS = [\".ts\", \".js\"];\n/** Under `dist/server`. */\nexport const PROBES_MANIFEST = \"probes.json\";\n\n/** The free name the bundled IIFE hands the default export to. */\nconst DEFINE = \"__gemiProbe__\";\n/** The bundle's entry: imports the probe and hands its default export over. */\nconst ENTRY = \"/__gemi_probe_entry__.ts\";\n\n/** A name as `probe` takes it: a path under `app`, without the suffix. */\nconst NAME = /^[A-Za-z0-9_-]+(\\/[A-Za-z0-9_-]+)*$/;\n\nfunction assertName(name: string) {\n if (typeof name !== \"string\" || !NAME.test(name)) {\n throw new Error(\n `A probe is named by its path under app/ without the \".probe.ts\" suffix, e.g. \"utils/layout\". Got ${JSON.stringify(name)}.`,\n );\n }\n}\n\n/** The source file of the probe `name` under `appDir`, or `null` when there is none. */\nexport function probeFile(appDir: string, name: string): string | null {\n for (const extension of EXTENSIONS) {\n const file = join(appDir, `${name}${PROBE_SUFFIX}${extension}`);\n if (existsSync(file)) return file;\n }\n return null;\n}\n\ntype Bundled = {\n /** The IIFE: hands the probe's default export to `__gemiProbe__`. */\n source: string;\n /** Every file the bundle read, absolute, for the dev cache. */\n inputs: string[];\n};\n\n/**\n * Bundles one probe for the browser: imports inlined, minified, wrapped in an\n * IIFE that hands the default export to `__gemiProbe__`. Throws when it does\n * not bundle.\n */\nasync function bundle(file: string): Promise<Bundled> {\n const result = await Bun.build({\n entrypoints: [ENTRY],\n files: {\n [ENTRY]: `import probe from ${JSON.stringify(file)};\\n${DEFINE}(probe);\\n`,\n },\n target: \"browser\",\n format: \"iife\",\n minify: true,\n metafile: true,\n throw: false,\n });\n if (!result.success || !result.outputs[0]) {\n const logs = result.logs.map((log) => String(log)).join(\"\\n\");\n throw new Error(`The probe ${file} does not bundle.\\n${logs}`);\n }\n const inputs = Object.keys(result.metafile?.inputs ?? {})\n .map((input) => resolve(input))\n .filter((input) => input !== ENTRY && existsSync(input));\n return { source: (await result.outputs[0].text()).trim(), inputs };\n}\n\n/** One probe's bundled source (the IIFE). Throws when it does not bundle. */\nexport async function bundleProbe(file: string): Promise<string> {\n return (await bundle(file)).source;\n}\n\n/** Every probe under `appDir`, bundled: what `gemi build` writes. */\nexport async function bundleProbes(appDir: string): Promise<Record<string, string>> {\n const probes: Record<string, string> = {};\n if (!existsSync(appDir)) return probes;\n const glob = new Bun.Glob(`**/*${PROBE_SUFFIX}.{ts,js}`);\n const files = [...glob.scanSync({ cwd: appDir })].sort();\n for (const file of files) {\n if (file.split(\"/\").includes(\"node_modules\")) continue;\n const name = file.replace(/\\.probe\\.[tj]s$/, \"\");\n if (!NAME.test(name) || name in probes) continue;\n probes[name] = await bundleProbe(join(appDir, file));\n }\n return probes;\n}\n\n// `gemi start`'s manifest, read once. `undefined`: not read yet; `null`: none.\nlet built: Record<string, string> | null | undefined;\n// Bundled from source: in production once, elsewhere until an input changes.\ntype Cached = { pending: Promise<Bundled>; stamps: Map<string, number> | null };\nconst cache = new Map<string, Cached>();\n\nfunction builtProbes(): Record<string, string> | null {\n if (built === undefined) {\n const file = join(projectRoot(), \"dist\", \"server\", PROBES_MANIFEST);\n built = existsSync(file) ? JSON.parse(readFileSync(file, \"utf8\")) : null;\n }\n return built ?? null;\n}\n\nfunction mtimeOf(file: string): number {\n try {\n return statSync(file).mtimeMs;\n } catch {\n return -1;\n }\n}\n\nfunction stale(stamps: Map<string, number>): boolean {\n for (const [file, mtime] of stamps) {\n if (mtimeOf(file) !== mtime) return true;\n }\n return false;\n}\n\n/** Forgets the manifest and every bundled probe (tests). @internal */\nexport function resetProbes() {\n built = undefined;\n cache.clear();\n}\n\n/**\n * The bundled source (an IIFE) of the probe `name`.\n *\n * In production, from `dist/server/probes.json`; a name the manifest lacks\n * (or no manifest) is bundled from source once. Elsewhere it is bundled on\n * first use and again only once the probe or a file it imports has changed.\n * Throws when there is no such file or it does not bundle.\n */\nexport async function probeSource(name: string): Promise<string> {\n assertName(name);\n const production = process.env.NODE_ENV === \"production\";\n if (production) {\n const fromBuild = builtProbes()?.[name];\n if (fromBuild !== undefined) return fromBuild;\n }\n const cached = cache.get(name);\n if (cached && (cached.stamps === null || !stale(cached.stamps))) {\n return (await cached.pending).source;\n }\n const file = probeFile(join(projectRoot(), \"app\"), name);\n if (!file) {\n throw new Error(\n `The probe \"${name}\" was not found. It is a file at app/${name}${PROBE_SUFFIX}.ts (or .js).`,\n );\n }\n const startedAt = Date.now();\n const entry: Cached = { pending: bundle(file), stamps: null };\n cache.set(name, entry);\n try {\n const bundled = await entry.pending;\n if (!production) {\n // A file changed while it bundled may not be in the bundle: such a\n // stamp never matches, so the next use bundles again.\n entry.stamps = new Map(\n bundled.inputs.map((input) => {\n const mtime = mtimeOf(input);\n return [input, mtime >= startedAt ? -2 : mtime];\n }),\n );\n }\n return bundled.source;\n } catch (error) {\n if (cache.get(name) === entry) cache.delete(name);\n throw error;\n }\n}\n\n/**\n * A JavaScript expression that runs the bundled probe `source` with `args`\n * and evaluates to what it returns (a promise, for an async probe).\n */\nexport function probeExpression(source: string, args: readonly unknown[]): string {\n const json = JSON.stringify(args);\n if (json === undefined) throw new Error(\"A probe's arguments must be JSON values.\");\n // The local names start with `__gemi` so they shadow none of the page's globals the bundle may use.\n return `(() => { let __gemiProbeFn__; const ${DEFINE} = (fn) => { __gemiProbeFn__ = fn; }; ${source}; return __gemiProbeFn__(...${json}); })()`;\n}\n\n/** Anything that evaluates an expression in a page: a puppeteer or playwright `Page`. */\nexport interface ProbePage {\n evaluate(expression: string): Promise<unknown>;\n}\n\n/** The probe function, from its module's type or its own. */\ntype ProbeFunctionOf<M> = M extends { default: infer F } ? F : M;\ntype AnyFunction = (...args: any[]) => unknown;\ntype ArgsOf<F> = F extends AnyFunction ? Parameters<F> : never;\ntype ResultOf<F> = F extends AnyFunction ? Awaited<ReturnType<F>> : never;\n\nexport class Probe<M = AnyFunction> {\n constructor(readonly name: string) {\n assertName(name);\n }\n\n /** The bundled IIFE. */\n source(): Promise<string> {\n return probeSource(this.name);\n }\n\n /**\n * An expression that runs the probe with `args`, for a driver that takes a\n * script string. The arguments must be JSON values.\n */\n async expression(...args: ArgsOf<ProbeFunctionOf<M>>): Promise<string> {\n return probeExpression(await this.source(), args);\n }\n\n /** Runs the probe in `page` with `args` and returns its (awaited) result. */\n async run(page: ProbePage, ...args: ArgsOf<ProbeFunctionOf<M>>): Promise<ResultOf<ProbeFunctionOf<M>>> {\n return (await page.evaluate(await this.expression(...args))) as ResultOf<ProbeFunctionOf<M>>;\n }\n}\n\n/**\n * The probe at `app/<name>.probe.ts`, typed by its module:\n *\n * ```ts\n * const readLayout = probe<typeof import(\"@/app/utils/layout.probe\")>(\"utils/layout\");\n * const reading = await readLayout.run(page, sections);\n * ```\n */\nexport function probe<M = AnyFunction>(name: string): Probe<M> {\n return new Probe<M>(name);\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": "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",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "AA803DD91A3A080064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Server } from "./Server";
|
|
2
|
-
export { isShuttingDown, type ShutdownSettings } from "./shutdown";
|
|
2
|
+
export { holdShutdown, isShuttingDown, shutdownSignal, type ShutdownSettings, } from "./shutdown";
|
|
3
3
|
export { liveness, type Liveness } from "./health";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Da as f}from"../chunk-s0z61m9j.js";import{Ea as
|
|
2
|
+
import{Da as f}from"../chunk-s0z61m9j.js";import{Ea as A}from"../chunk-6eywgbfz.js";import{Kl as Q,Ml as q,Nl as w,Ql as Z,Rl as P,Sl as y,Tl as S,Ul as U}from"../chunk-xhky6kyf.js";import{Yl as H}from"../chunk-65r1ne8r.js";import"../chunk-y0gaw9ez.js";import{em as F}from"../chunk-0a5png2z.js";var x="/__gemi__/health",$=Symbol.for("gemi.server.health");function V(){let z=globalThis;return z[$]??={lagMs:0,consecutiveBreaches:0,degraded:!1,timer:void 0},z[$]}function W(){let z=V(),B=Q();return{healthy:!B&&!z.degraded,shuttingDown:B,lagMs:z.lagMs,consecutiveBreaches:z.consecutiveBreaches}}function E(z,B){let I=V();I.lagMs=z,I.consecutiveBreaches=z>B.maxLagMs?I.consecutiveBreaches+1:0;let J=I.consecutiveBreaches>=B.breaches;if(J&&!I.degraded)console.warn(`[gemi] Health: degraded (event-loop lag ${Math.round(z)}ms, ${I.consecutiveBreaches} samples in a row over ${B.maxLagMs}ms).`);else if(!J&&I.degraded)console.log(`[gemi] Health: recovered (event-loop lag ${Math.round(z)}ms).`);I.degraded=J}function G(z){let B=V();if(B.timer)return;let I=performance.now()+z.intervalMs;B.timer=setInterval(()=>{let J=performance.now();E(Math.max(0,J-I),z),I=J+z.intervalMs},z.intervalMs),B.timer.unref?.()}function _(z=process.env){return{paths:D(z.GEMI_HEALTH_PATH),intervalMs:O("GEMI_HEALTH_INTERVAL_MS",z.GEMI_HEALTH_INTERVAL_MS,500),maxLagMs:O("GEMI_HEALTH_MAX_LAG_MS",z.GEMI_HEALTH_MAX_LAG_MS,1000),breaches:Math.ceil(O("GEMI_HEALTH_BREACHES",z.GEMI_HEALTH_BREACHES,3))}}function D(z){if(z===void 0||z.trim()==="")return[x];if(z.trim().toLowerCase()==="off")return[];let B=z.split(",").map((J)=>J.trim()).filter(Boolean);if(B.filter((J)=>!J.startsWith("/")).length>0)throw Error(`GEMI_HEALTH_PATH: expected comma-separated paths starting with "/", or "off"; got ${JSON.stringify(z)}.`);return B}function O(z,B,I){if(B===void 0||B.trim()==="")return I;let J=Number(B);if(Number.isFinite(J)&&J>0)return J;return console.warn(`[gemi] Ignoring ${z}="${B}": expected a positive number.`),I}function j(z,B){if(B.length===0)return z;let I=new Set(B);return async(J,K)=>{if(!B.some((b)=>J.url.includes(b))||!I.has(new URL(J.url).pathname))return z(J,K);return y(R(J.method))}}function R(z){let B={"Cache-Control":"no-store","Content-Type":"text/plain; charset=utf-8"};if(z!=="GET"&&z!=="HEAD")return new Response("Method Not Allowed",{status:405,headers:{...B,Allow:"GET, HEAD"}});let{healthy:I,shuttingDown:J}=W();return new Response(z==="HEAD"?null:I?"ok":J?"shutting down":"degraded",{status:I?200:503,headers:B})}var L=Symbol.for("gemi.server.devGeneration"),X={graceMs:1e4,providerTimeoutMs:5000};class Y{app;inFlight=0;waiters=new Set;constructor(z){this.app=z}track(z){return async(B,I)=>{this.inFlight++;try{return await z(B,I)}finally{if(this.inFlight--,this.inFlight===0)this.wake()}}}get pending(){return this.inFlight}async retire({graceMs:z,providerTimeoutMs:B}){try{await this.idle(z),await Promise.resolve().then(()=>this.app.shutdown({timeoutMs:B}))}catch(I){C(I)}}idle(z){if(this.inFlight===0)return Promise.resolve();return new Promise((B)=>{let I=()=>{clearTimeout(J),this.waiters.delete(I),B()},J=setTimeout(I,z);this.waiters.add(I)})}wake(){for(let z of this.waiters)z()}}function N(z,B=X){let I=globalThis,J=I[L];if(I[L]=z,!J||J===z||typeof J.retire!=="function")return Promise.resolve();let K=J.retire.bind(J);return Promise.resolve().then(()=>K(B)).catch(C)}function C(z){console.error("[gemi] Shutting down the application a reload replaced failed:",z)}class k{app;instrumentation;handleSignals;server;stopping;settings;constructor(z){this.app=new A({kernel:z.kernel}),this.handleSignals=z.handleSignals??!0,this.instrumentation=S(z.instrumentation??((B,I)=>I(B)))}async start(){process.env.ROOT_DIR=H();let z=Bun.env.NODE_ENV==="production",B=_();if(z)G(B);let I=j(this.instrumentation,B.paths);if(z){if(this.handleSignals)U(()=>this.stop());this.settings=Z()}try{await this.app.waitForBoot()}catch(J){if(!z)this.app.shutdown({timeoutMs:X.providerTimeoutMs});throw J}if(z){let{httpProd:J}=await import("../chunk-dh8jqx0k.js");this.server=await J(this.app,I)}else{f();let{httpDev:J}=await import("../chunk-5msb5ev6.js"),K=new Y(this.app);this.server=await J(this.app,K.track(I)),N(K)}return this.server}stop(z={}){let B=this.app.sockets();return this.stopping??=P({server:this.server,closeSockets:B?()=>B.shutdown():void 0,shutdownProviders:(I)=>this.app.shutdown(I),settings:{...this.settings??Z(),...z}}),this.stopping}}export{q as shutdownSignal,W as liveness,Q as isShuttingDown,w as holdShutdown,k as Server};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=4E502727E40EE01564756E2164756E21
|
package/dist/server/index.js.map
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"import type { Instrumentation } from \"./types\";\n\n/**\n * The application `gemi dev` is serving, kept across `bun --hot` reloads so\n * the next reload can shut it down (#652).\n *\n * A reload re-evaluates the whole module graph and `Server.start()` boots a\n * fresh application, with its own providers: its own database pool, Redis\n * client, scheduler and queue. Nothing used to stop the one it replaced, so\n * every save left a pool of idle Postgres connections behind (ten, Bun's\n * default) until the server's `max_connections` ran out for every process\n * sharing it.\n *\n * On `globalThis` under a registry symbol, like `__gemiVite`, because the\n * module holding it is re-evaluated too. What is read back after a reload is\n * therefore an instance of the *previous* graph's class, so it is typed by\n * the one method called on it and checked for that method before the call.\n */\nconst CURRENT = Symbol.for(\"gemi.server.devGeneration\");\n\nexport type RetireOptions = {\n /**\n * How long to wait for the requests the replaced application is still\n * serving before its providers shut down under them.\n */\n graceMs: number;\n /** The deadline `Application.shutdown` shares between the providers. */\n providerTimeoutMs: number;\n};\n\n/**\n * Ten seconds for the old application's requests, five for its providers.\n * Nothing waits on either but the old pool staying open a little longer. A\n * request that outlives the grace — a server-sent-events stream is open for as\n * long as its tab is — loses its database under it, which after a reload it\n * would soon anyway: the page is told to refetch against the new code.\n */\nexport const devRetireDefaults: RetireOptions = { graceMs: 10_000, providerTimeoutMs: 5_000 };\n\n/** The part of `App` a reload shuts down. */\ntype Shuttable = { shutdown(options?: { timeoutMs?: number }): Promise<unknown> };\n\ntype Retiring = { retire(options: RetireOptions): Promise<void> };\n\n/**\n * One application `gemi dev` served, with a count of the requests it is\n * serving so a reload can let them finish before shutting it down.\n *\n * Counted until the handler resolves with a `Response`, not until its body\n * has been sent. Wrapping every body to see its end — Vite's module responses\n * included — is a cost paid on each of the hundreds of requests a dev page\n * load makes, for the rare stream that spans a save. A query such a stream has\n * already sent still finishes: the pool's `close()` waits for it.\n */\nexport class DevGeneration {\n private inFlight = 0;\n private waiters = new Set<() => void>();\n\n constructor(private readonly app: Shuttable) {}\n\n /** Wraps `instrumentation` so every request through it is counted. */\n track(instrumentation: Instrumentation): Instrumentation {\n return async (req, next) => {\n this.inFlight++;\n try {\n return await instrumentation(req, next);\n } finally {\n this.inFlight--;\n if (this.inFlight === 0) this.wake();\n }\n };\n }\n\n /** Requests this application is serving right now. */\n get pending(): number {\n return this.inFlight;\n }\n\n /**\n * Waits up to `graceMs` for the requests in flight, then shuts the\n * application's providers down. Never rejects: it runs detached from the\n * reload, where a rejection would surface as an unhandled one and land in\n * the browser's error overlay, for a failure in code the save replaced.\n */\n async retire({ graceMs, providerTimeoutMs }: RetireOptions): Promise<void> {\n try {\n await this.idle(graceMs);\n // `.then` so a synchronous throw from `shutdown` lands in the catch too.\n await Promise.resolve().then(() => this.app.shutdown({ timeoutMs: providerTimeoutMs }));\n } catch (error) {\n reportFailure(error);\n }\n }\n\n private idle(timeoutMs: number): Promise<void> {\n if (this.inFlight === 0) return Promise.resolve();\n return new Promise((resolve) => {\n const done = () => {\n clearTimeout(timer);\n this.waiters.delete(done);\n resolve();\n };\n const timer = setTimeout(done, timeoutMs);\n this.waiters.add(done);\n });\n }\n\n private wake() {\n // Each `done` deletes itself, which a `Set` being iterated allows.\n for (const done of this.waiters) done();\n }\n}\n\n/**\n * Records `next` as the application `gemi dev` is serving and retires the one\n * it replaced, if any. Call it once `next` is serving — after `Bun.serve` has\n * swapped the fetch handler — so that no new request reaches the application\n * being shut down, and the ones already on it can finish.\n *\n * The caller does not wait for the returned retirement: the reload is done,\n * and the old application's requests and providers finishing is no reason to\n * hold up the new one. The promise is for tests, and never rejects.\n */\nexport function replaceDevGeneration(\n next: DevGeneration,\n options: RetireOptions = devRetireDefaults,\n): Promise<void> {\n const global = globalThis as { [CURRENT]?: Partial<Retiring> };\n const previous = global[CURRENT];\n global[CURRENT] = next;\n if (!previous || previous === next || typeof previous.retire !== \"function\") {\n return Promise.resolve();\n }\n const retire = previous.retire.bind(previous);\n // Guarded like `retire` itself, because this one is the previous graph's code.\n return Promise.resolve()\n .then(() => retire(options))\n .catch(reportFailure);\n}\n\nfunction reportFailure(error: unknown) {\n console.error(\"[gemi] Shutting down the application a reload replaced failed:\", error);\n}\n\n/** Test seam: forget the application a previous test left as current. */\nexport function resetDevGeneration() {\n delete (globalThis as { [CURRENT]?: unknown })[CURRENT];\n}\n",
|
|
7
7
|
"import { App } from \"../app\";\nimport { Kernel } from \"../kernel\";\nimport { projectRoot } from \"../support/discover\";\nimport { healthSettings, serveHealth, startLivenessSampler } from \"./health\";\nimport { DevGeneration, devRetireDefaults, replaceDevGeneration } from \"./devReload\";\nimport {\n drain,\n installShutdownSignals,\n serveForShutdown,\n shutdownSettings,\n type ShutdownSettings,\n} from \"./shutdown\";\nimport { Instrumentation } from \"./types\";\nimport { watchEnv } from \"./watchEnv\";\n\nexport class Server {\n private app: App;\n private instrumentation: Instrumentation;\n private handleSignals: boolean;\n private server: Bun.Server<unknown> | undefined;\n private stopping: Promise<number> | undefined;\n private settings: ShutdownSettings | undefined;\n\n constructor(params: {\n kernel: new () => Kernel;\n instrumentation?: Instrumentation;\n /**\n * Drain on `SIGTERM`/`SIGINT` and exit — production only. `false` leaves\n * the signals to the app, which can call `stop()` itself.\n */\n handleSignals?: boolean;\n }) {\n this.app = new App({ kernel: params.kernel });\n this.handleSignals = params.handleSignals ?? true;\n this.instrumentation = serveForShutdown(\n params.instrumentation ??\n ((req: Request, next: (req: Request) => Promise<Response>) => next(req)),\n );\n }\n\n /**\n * Boots the application and starts listening. Resolves with the `Bun.Server`\n * once it is accepting requests.\n */\n async start(): Promise<Bun.Server<unknown>> {\n // Before the boot, not after: `httpDev`/`httpProd` set this too, but they\n // are imported below — after every provider's `boot()` has run — so a\n // service that resolves a path during boot used to read `undefined`\n // (`services/logging`, #423). Same rule `httpProd` computes it with, so\n // the assignment it makes a moment later is the same value.\n //\n // It doubles as the marker for \"this process is serving\": nothing else\n // sets `ROOT_DIR`, so a console command or a migration — which boot the\n // same providers through `runConsole` — can tell that it is not one, and\n // skip work that only a server should do at boot.\n process.env.ROOT_DIR = projectRoot();\n\n // Read once, ahead of the boot, so the signal handling below and the mode\n // that starts after the boot cannot disagree: whatever a provider's\n // `boot()` does to the environment, this process is the server it was\n // started as.\n const production = process.env.NODE_ENV === \"production\";\n\n // Read before the boot, so a bad `GEMI_HEALTH_PATH` fails the deploy at\n // once. The route is served in both modes; the lag sampler runs only in\n // production, where a `bun --hot` reload or a Vite compile cannot stall\n // the loop and read as an outage.\n const health = healthSettings();\n if (production) startLivenessSampler(health);\n // The outermost layer: a probe is answered ahead of the app's\n // instrumentation and the shutdown refusal (#48).\n const instrumentation = serveHealth(this.instrumentation, health.paths);\n\n if (production) {\n // Before the boot, not just before listening: the whole start-up is a\n // window in which a signal can arrive, and the slow part of it is the\n // boot — a connection pool, the config, the dictionaries. A rolling\n // update that `SIGTERM`s a pod two seconds in finds no listener\n // installed, and the default action for both signals is to kill the\n // process on the spot: no provider's `shutdown()`, no pool closed,\n // nothing flushed. Installing here makes that a drain like any other.\n // `stop()` handles a server that does not exist yet (nothing to close,\n // requests cannot be in flight) and `Application.shutdown` calls the\n // hooks of providers that registered but never booted, swallowing\n // whatever they throw — half a boot is exactly when a hook is most\n // likely to trip over something it expected `boot()` to have made.\n if (this.handleSignals) installShutdownSignals(() => this.stop());\n // Read now, so a bad value is warned about while the operator is\n // watching the deploy, not first at the shutdown it spoils — and so a\n // signal during the boot drains on the configured budget rather than on\n // whatever `stop()` reads at the time.\n this.settings = shutdownSettings();\n }\n\n // Phase two of the boot. `new App({ kernel })` already ran every provider's\n // synchronous `register()`; this awaits their `boot()` before the first\n // request is served.\n try {\n await this.app.waitForBoot();\n } catch (error) {\n // A `bun --hot` reload whose boot threw: the previous application keeps\n // serving, and this one never will, so whatever its providers opened\n // before the throw (the feature flags' warm-up, when they are on, has\n // opened the database pool by then) is closed now rather than left open\n // for good (#652). Production exits on a failed boot, which closes\n // everything anyway.\n if (!production) void this.app.shutdown({ timeoutMs: devRetireDefaults.providerTimeoutMs });\n throw error;\n }\n\n // Dynamic import so each mode only pulls in its own code: `httpDev` drags in\n // Vite (dev-only) and `httpProd` reads the built `dist/` manifests — neither\n // should load in the other environment.\n if (production) {\n const { httpProd } = await import(\"./httpProd.js\");\n this.server = await httpProd(this.app, instrumentation);\n } else {\n // Dev only: reload `.env` into process.env on change so config edits take\n // effect without restarting the dev server (Bun reads `.env` only at\n // startup, even under `--hot`). No signal handling here: `bun --hot`\n // re-runs this on every reload, and a Ctrl+C in development should stop\n // the server now, not after a drain.\n watchEnv();\n const { httpDev } = await import(\"./httpDev.js\");\n const generation = new DevGeneration(this.app);\n this.server = await httpDev(this.app, generation.track(instrumentation));\n // Only now, with the new fetch handler live, has the application this\n // reload replaced stopped receiving requests; it is shut down once the\n // ones it is serving finish (#652). Not awaited, so the reload is not\n // held up by it.\n void replaceDevGeneration(generation);\n }\n return this.server;\n }\n\n /**\n * Stops the server gracefully and resolves with the exit code it earned: 0\n * when the in-flight requests drained and every provider shut down in time,\n * 1 otherwise. Does not exit the process — the signal handler does that.\n *\n * The order is `drain` in `./shutdown`: `isShuttingDown()` turns true, the\n * listener closes, in-flight requests finish under the grace period, then\n * every provider's `shutdown()` runs in reverse registration order.\n * Idempotent: a second call returns the first call's promise. Settings\n * default to the `GEMI_SHUTDOWN_*` environment variables.\n */\n stop(settings: Partial<ShutdownSettings> = {}): Promise<number> {\n const sockets = this.app.sockets();\n this.stopping ??= drain({\n server: this.server,\n // Once the listener is closed: `bye` to every broadcast socket, which\n // the graceful stop would otherwise wait on for good.\n closeSockets: sockets ? () => sockets.shutdown() : undefined,\n shutdownProviders: (options) => this.app.shutdown(options),\n settings: { ...(this.settings ?? shutdownSettings()), ...settings },\n });\n return this.stopping;\n }\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": "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",
|
|
10
|
+
"debugId": "4E502727E40EE01564756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -13,6 +13,41 @@ import type { Instrumentation } from "./types";
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function isShuttingDown(): boolean;
|
|
15
15
|
export declare function markShuttingDown(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Aborted the moment this process is told to stop, when `isShuttingDown()`
|
|
18
|
+
* turns true (#1210). For background work that should wind down at once
|
|
19
|
+
* rather than notice at its next check: pass it where an `AbortSignal` is
|
|
20
|
+
* taken, or listen for `abort`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function shutdownSignal(): AbortSignal;
|
|
23
|
+
/**
|
|
24
|
+
* Holds the shutdown's drain until `work` settles (#1210), as an in-flight
|
|
25
|
+
* request does: background work started by a request that outlives its
|
|
26
|
+
* response (an agent run, an upload being processed), so it shares the
|
|
27
|
+
* `GEMI_SHUTDOWN_TIMEOUT` grace period instead of getting only what is left
|
|
28
|
+
* of the providers' deadline after it.
|
|
29
|
+
*
|
|
30
|
+
* Returns `work`, so it wraps where the work is started:
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* holdShutdown(runAgent(thread));
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* The drain waits for every held promise until the timeout; whatever is still
|
|
37
|
+
* running then is abandoned like a request would be, and the shutdown exits
|
|
38
|
+
* `1`. A rejection counts as settled and is not reported here. Work should
|
|
39
|
+
* stop early on `shutdownSignal()` and checkpoint, then let a `Service` or
|
|
40
|
+
* provider `shutdown()` save what is left. Outside a server's or worker's
|
|
41
|
+
* shutdown (in dev, a CLI command) it does nothing but return `work`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function holdShutdown<T>(work: Promise<T>): Promise<T>;
|
|
44
|
+
/** How many `holdShutdown` promises are still running. */
|
|
45
|
+
export declare function heldWork(): number;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves once no `holdShutdown` work is running, including work held while
|
|
48
|
+
* waiting. @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function heldWorkSettled(): Promise<void>;
|
|
16
51
|
/**
|
|
17
52
|
* The request drain is over and the providers' `shutdown()` may be running:
|
|
18
53
|
* from here on a request must not reach the app. See `serveForShutdown`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../server/shutdown.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../server/shutdown.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA6B/C;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED,wBAAgB,gBAAgB,SAI/B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ5D;AAED,0DAA0D;AAC1D,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAKrD;AAED;;;GAGG;AACH,wBAAgB,WAAW,SAE1B;AAED,wEAAwE;AACxE,wBAAgB,iBAAiB,SAMhC;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,gBAAgB,CAgBlB;AAWD,8CAA8C;AAC9C,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,sBAAsB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE;IAClC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,iBAAiB,EAAE,CAAC,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/E,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,GAAG,OAAO,CAAC,MAAM,CAAC,CAwElB;AA2CD;;;;;;;;;GASG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAUxE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,eAAe,CAUlF;AAmBD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAC3B,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAO,QA0B1C"}
|