@prisma/dev 0.0.0-dev.202512121242 → 0.0.0-dev.202512121402
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/accelerate-MVW5ZKXM.js +1 -0
- package/dist/chunk-7EOUKLQR.js +3 -0
- package/dist/chunk-EPFUMVT3.js +1 -0
- package/dist/chunk-FZ7JBZR6.js +3 -0
- package/dist/chunk-GW6BCATQ.js +1 -0
- package/dist/chunk-LMPFMHCB.js +1 -0
- package/dist/chunk-RBVZVBDC.js +1 -0
- package/dist/daemon.cjs +5 -86
- package/dist/daemon.js +1 -1
- package/dist/db.js +1 -1
- package/dist/index.cjs +5 -86
- package/dist/index.js +1 -1
- package/dist/state.js +1 -1
- package/dist/utility-YJ4TFSMW.js +1 -0
- package/package.json +2 -2
- package/dist/accelerate-B4RDPMOM.js +0 -1
- package/dist/chunk-ABDUHDM7.js +0 -82
- package/dist/chunk-GUJALUTC.js +0 -3
- package/dist/chunk-KUHNXXCE.js +0 -1
- package/dist/chunk-NLG6WPCX.js +0 -1
- package/dist/chunk-RODR7QVK.js +0 -1
- package/dist/chunk-UZV6WD53.js +0 -3
- package/dist/chunk-ZPA6K2XO.js +0 -1
- package/dist/utility-2R6QXHRL.js +0 -1
package/dist/chunk-GUJALUTC.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as N,b as L,c as F,d as b,e as J}from"./chunk-NLG6WPCX.js";import{b as d,f as I,g as A,h as T,i as V}from"./chunk-ZPA6K2XO.js";import{d as f}from"./chunk-RODR7QVK.js";f();import{writeFile as ee}from"fs/promises";import{join as l}from"pathe";import{check as te,lock as re,unlock as se}from"proper-lockfile";import{process as C}from"std-env";import{integer as H,literal as ae,minLength as oe,minValue as K,number as q,object as v,optional as P,parseJson as ne,pipe as h,safeParse as ie,string as S,url as ue}from"valibot";f();import{setTimeout as X}from"timers/promises";import{process as g}from"std-env";function w(t,e){if(t==null)return!1;try{return g.kill?.(t,0)??!0}catch(r){return e&&console.error(`Error checking if process with PID ${t} exists:`,r),!1}}async function U(t,e){if(!g.kill)return!1;try{g.kill(t,"SIGTERM")}catch(n){return e&&console.error(`Error killing process with PID ${t}:`,n),!1}let r=0;do{if(!w(t,e))return!0;await X(100)}while(++r<50);try{return g.kill(t,"SIGKILL")}catch(n){return e&&console.error(`Error forcefully killing process with PID ${t}:`,n),!1}}var k=h(S(),ue()),j=v({connectionString:k,prismaORMConnectionString:P(k),terminalCommand:P(S())}),B=v({url:k}),x=h(q(),H(),K(1)),ce=v({database:j,http:B,ppg:B,shadowDatabase:j}),de=v({databasePort:x,exports:P(ce),name:h(S(),oe(1)),pid:P(h(q(),H(),K(0))),port:x,shadowDatabasePort:x,version:ae("1")}),M=Symbol("initialize"),_="default",c=class{_databasePort;debug;dryRun;name;persistenceMode;pid;_port;_shadowDatabasePort;constructor(e){this._databasePort=e.databasePort??b,this.debug=e.debug??!1,this.dryRun=e.dryRun??!1,this.name=e.name??_,this.persistenceMode=e.persistenceMode,this.pid=e.pid??C.pid,this._port=e.port??b,this._shadowDatabasePort=e.shadowDatabasePort??b}static async createExclusively(e){let r=e?.dryRun!==!0&&e?.persistenceMode!=="stateless"?new p(e):new $(e);return await r[M](),r}static async fromServerDump(e){let{debug:r,name:n=_}=e??{},a=d(n),o=p.getServerDumpPath(a),s=await I(o);if(s==null)return r&&console.debug(`[State] No server dump file found at: ${o}`),null;r&&(console.debug(`[State] server dump file found at "${o}":`),console.debug(s));let{issues:i,output:u,success:m}=ie(h(S(),ne(),de),s);if(!m)throw r&&console.debug(`[State] Invalid server dump file at "${o}":
|
|
2
|
-
${JSON.stringify(i,null,2)}`),new Error(`Invalid Prisma Dev state for "${n}".`);return new p({databasePort:u.databasePort,debug:r,dryRun:!1,name:n,pid:u.pid,port:u.port,serverDump:u,shadowDatabasePort:u.shadowDatabasePort})}static async scan(e){let{debug:r,globs:n}=e??{},a=l(d(_),"..");r&&console.debug(`[State] scanning for server states in: ${a}`);let o=await T(a,n);return r&&console.debug(`[State] found server names: ${JSON.stringify(o)}`),await Promise.all(o.map(s=>G(s,e)))}get databasePort(){return this._databasePort}get port(){return this._port}get shadowDatabasePort(){return this._shadowDatabasePort}},$=class extends c{constructor(e){super({...e,databasePort:e?.databasePort??N,persistenceMode:"stateless",port:e?.port??L,shadowDatabasePort:e?.shadowDatabasePort??F})}get databaseDumpPath(){return"<DUMP_PATH>"}get pgliteDataDirPath(){return"memory://"}async[M](){}async close(){}async writeServerDump(){}},p=class t extends c{#t;#e;#s;#o;#n;#a;#r;constructor(e){super({...e,persistenceMode:"stateful"}),this.#a=!1,this.#e=d(this.name),this.#t=l(this.#e,"db_dump.bak"),this.#s=l(this.#e,".lock"),this.#o=l(this.#e,".pglite"),this.#r=e?.serverDump??null,this.#n=t.getServerDumpPath(this.#e)}static getServerDumpPath(e){return l(e,"server.json")}get databaseDumpPath(){return this.#t}get exports(){return this.#r?.exports}get pgliteDataDirPath(){return this.#o}async[M](){await A(this.#e),this.debug&&console.debug(`[State] using data directory: ${this.#e}`);try{await re(this.#e,{lockfilePath:this.#s}),this.debug&&console.debug(`[State] obtained lock on: ${this.#e}`);let e=await c.scan({debug:this.debug,onlyMetadata:!0}),r=await J({debug:this.debug,name:this.name,requestedPorts:{databasePort:this.databasePort,port:this.port,shadowDatabasePort:this.shadowDatabasePort},servers:e});this._databasePort=r.databasePort,this._port=r.port,this._shadowDatabasePort=r.shadowDatabasePort,await this.writeServerDump()}catch(e){throw e instanceof Error&&"code"in e&&e.code==="ELOCKED"?new R(this):e}}async close(){if(!this.#a)try{await se(this.#e,{lockfilePath:this.#s}),this.#a=!0,this.debug&&console.debug(`[State] released lock on: ${this.#e}`)}catch(e){throw this.debug&&console.error(`[State] failed to release lock on: ${this.#e}`,e),e}}async writeServerDump(e){this.#r={name:this.name,version:"1",pid:C.pid,port:this.port,databasePort:this.databasePort,shadowDatabasePort:this.shadowDatabasePort,exports:e},await ee(this.#n,`${JSON.stringify(this.#r,null,2)}
|
|
3
|
-
`,{encoding:"utf-8"})}};async function _e(t,e){await pe(t,e);let r=d(typeof t=="string"?t:t.name);await V(r)}async function G(t,e){let{debug:r,onlyMetadata:n}=e||{},a=typeof t=="string"?t:t.name,o=typeof t!="string"?t:void 0,s={databasePort:o?.databasePort??-1,exports:o?.exports,name:a,pid:o?.pid,port:o?.port??-1,shadowDatabasePort:o?.shadowDatabasePort??-1,version:"1"};try{let i=o||await c.fromServerDump({debug:r,name:a});if(!i)return r&&console.debug(`[State] no server state found for name: ${a}`),{...s,status:"no_such_server"};s.databasePort=i.databasePort,s.exports=i.exports,s.pid=i.pid,s.port=i.port,s.shadowDatabasePort=i.shadowDatabasePort;let{exports:u,pid:m}=i;if(n)return{...s,status:"unknown"};if(!w(m,r))return r&&console.debug(`[State] server state for "${a}" has no running process with PID: ${m}`),{...s,status:"not_running"};let O=d(a);try{if(!await te(O,{lockfilePath:l(O,".lock")}))return r&&console.debug(`[State] server state for "${a}" is not locked, indicating it is not running.`),{...s,status:"starting_up"}}catch(z){r&&console.error(`[State] server state for "${a}" failed to check lock:`,z)}if(!u)return{...s,status:"starting_up"};let{http:Y}=u,{hc:Z}=await import("hono/client"),D=await Z(Y.url).health.$get();if(!D.ok)return r&&console.debug(`[State] server state for "${a}" is not live: ${JSON.stringify(D)}`),{...s,status:"not_running"};let y=await D.json();return y.name!==t?(r&&console.debug(`[State] server state for "${a}" has mismatched health response: ${JSON.stringify(y)}`),{...s,status:"unknown"}):(r&&console.debug(`[State] server state for "${t}" is live: ${JSON.stringify(y)}`),{...s,status:"running"})}catch(i){return r&&console.error(`[State] failed to get server status for "${a}":`,i),{...s,status:"error"}}}function le(t){let{status:e}=t;return e==="running"||e==="starting_up"}async function pe(t,e){let{pid:r,...n}=typeof t=="string"?await G(t,{debug:e}):t;if(!le(n))return!1;let a=await c.fromServerDump({debug:e,name:n.name});if(r==null){e&&console.debug(`[State] No PID found for server "${n.name}" to kill.`);try{await a?.close()}catch{}return!1}let o=await U(r,e);try{await a?.close()}catch{}return o}var E=class extends Error{name="ServerStateAlreadyExistsError";constructor(e){super(`A Prisma Dev server with the name "${e}" is already running.`)}},R=class extends E{#t;name="ServerAlreadyRunningError";constructor(e){super(e.name),this.#t=e}get server(){return c.fromServerDump({debug:this.#t.debug,name:this.#t.name})}};export{c as a,_e as b,G as c,le as d,pe as e,E as f,R as g};
|
package/dist/chunk-KUHNXXCE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as g}from"./chunk-NLG6WPCX.js";import{e as u}from"./chunk-ZPA6K2XO.js";import{d as m}from"./chunk-RODR7QVK.js";m();import{filename as P}from"pathe/utils";var n={connectionLimit:1,connectTimeout:0,database:"template1",maxIdleConnectionLifetime:0,password:"postgres",poolTimeout:0,socketTimeout:0,sslMode:"disable",username:"postgres"},w=`postgres://${n.username}:${n.password}@localhost`,f=new URLSearchParams({sslmode:n.sslMode}),y=new URLSearchParams({...Object.fromEntries(f.entries()),connection_limit:String(n.connectionLimit),connect_timeout:String(n.connectTimeout),max_idle_connection_lifetime:String(n.maxIdleConnectionLifetime),pool_timeout:String(n.poolTimeout),single_use_connections:"true",socket_timeout:String(n.socketTimeout)});async function T(e,o){let i=e==="database"?o.databasePort:o.shadowDatabasePort;if(o.dryRun)return b(e,o,{db:null,port:i,server:null});let{debug:a}=o,s=await(e==="shadow_database"?v:p)(o.pgliteDataDirPath,a);a&&s.onNotification((t,d)=>{console.debug(`[${e}][${t}] ${d}`)});let{PGLiteSocketServer:l}=await import("@electric-sql/pglite-socket"),r=new l({db:s,debug:a,inspect:a,port:i});a&&(r.addEventListener("listening",t=>{let{detail:d}=t;console.debug(`[${e}] server listening on ${JSON.stringify(d)}`)}),r.addEventListener("connection",t=>{let{clientAddress:d,clientPort:D}=t.detail;console.debug(`[${e}] client connected from ${d}:${D}`)}),r.addEventListener("error",t=>{let{detail:d}=t;console.error(`[${e}] server error:`,d)}));try{await r.start()}catch(t){throw t instanceof Error&&"code"in t&&t.code==="EADDRINUSE"?new g(i):t}return b(e,o,{db:s,port:i,server:r})}function b(e,o,i){let{debug:a}=o,{db:c,port:s,server:l}=i||{};return a&&console.debug(`[${e}] server started on port ${s}`),{...n,close:async()=>{let r=[];try{await l?.stop(),a&&console.debug(`[${e}] server stopped on port ${s}`)}catch(t){console.error(`[${e}] server stop error`,t),r.push(t)}if(e==="database")try{await c?.syncToFs(),a&&console.debug(`[${e}] synced to filesystem`)}catch(t){console.error(`[${e}] sync error`,t),r.push(t)}try{await c?.close(),a&&console.debug(`[${e}] closed`)}catch(t){console.error(`[${e}] close error`,t),r.push(t)}if(r.length>0)throw new AggregateError(r,`Failed to close ${e} properly`)},connectionString:S(s,f),dump:async r=>{e==="shadow_database"||!c||await $({db:c,debug:a,destinationPath:r})},port:s,prismaORMConnectionString:S(s,y),terminalCommand:`PGPASSWORD=${n.password} PGSSLMODE=${n.sslMode} psql -h localhost -p ${s} -U ${n.username} -d ${n.database}`}}function S(e,o){return`${w}:${e}/${n.database}?${o.toString()}`}async function p(e,o){let{PGlite:i}=await import("@electric-sql/pglite");return await i.create({database:n.database,dataDir:e,debug:o?5:void 0,relaxedDurability:!1,username:n.username})}async function v(e,o){let{PGlite:i}=await import("@electric-sql/pglite");return await i.create({database:n.database,dataDir:"memory://",debug:o?5:void 0,relaxedDurability:!1,username:n.username})}async function $(e){let{dataDir:o,db:i,debug:a,destinationPath:c}=e,s=i||await p(o,a),{pgDump:l}=await import("@electric-sql/pglite-tools/pg_dump"),r=await l({args:["--schema-only","--no-owner"],fileName:c?P(c):void 0,pg:await s.clone()});return c?(a&&console.debug(`[DB] Dumping database to ${c}`),await u(r,c)):(a&&console.debug("[DB] Dumping database to memory"),await r.text())}export{T as a,$ as b};
|
package/dist/chunk-NLG6WPCX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as m}from"./chunk-RODR7QVK.js";m();import{checkPort as O,getPort as v,isUnsafePort as T}from"get-port-please";import{difference as $,range as k}from"remeda";var h=51214,S=51213,g=51215,p=65535,P=-1/0;async function _(s){let{debug:t,name:e,requestedPorts:n,servers:u}=s,{portsUsedByOtherServers:r,portsUsedByThisServerLastTime:a}=B(e,u);t&&(console.debug(`ports used by other servers: ${Object.keys(r).join(", ")}`),console.debug(`ports used by "${e}" server last time: ${JSON.stringify(a)}`));let i={databasePort:P,port:P,shadowDatabasePort:P},o=["port","databasePort","shadowDatabasePort"];for(let c of o){let d=await U({debug:t,portKey:c,portsUsedByOtherServers:r,portsUsedByThisServerLastTime:a,requestedPorts:n})??await x({debug:t,pickedPorts:i,portKey:c,portsUsedByOtherServers:r,portsUsedByThisServerLastTime:a});t&&console.debug(`Got port for "${c}": ${d}`),i[c]=d}return t&&console.debug(`Picked ports: ${JSON.stringify(i)}`),i}async function U(s){let{debug:t,portKey:e,portsUsedByOtherServers:n,portsUsedByThisServerLastTime:u,requestedPorts:r}=s,{[e]:a,...i}=r;if(w(a))return await q({debug:t,otherRequestedPorts:i,portKey:e,portsUsedByOtherServers:n,requestedPort:a}),a;let o=u?.[e]??P;if(!w(o))return t&&console.debug(`No port specified for "${e}". Trying to pick a new port.`),null;let c=o in n;return c||Object.values(i).includes(o)?(t&&console.debug(`Port ${o} that was used last time for this server, ${c?"is also used by another server":"has been requested for another service"}. Trying to pick a new port.`),null):await O(o)===!1?(t&&console.debug(`Port ${o}, that was used last time for this server, is not available. Trying to pick a new port.`),null):(t&&console.debug(`Using port ${o} for "${e}" as it was used last time and is available.`),o)}async function x(s){let{debug:t,pickedPorts:e,portKey:n,portsUsedByOtherServers:u,portsUsedByThisServerLastTime:r}=s,a=Math.max(h,S,g)+1,i=[...Object.values(e),...Object.keys(u).map(Number),...Object.values(r||{})],o=Math.min(Math.max(a,...i)+100,p),c=$(k(a,o),i),d={port:S,databasePort:h,shadowDatabasePort:g}[n];try{return await v({port:d in u||Object.values(e).includes(d)||Object.values(r||{}).includes(d)?void 0:d,ports:c})}catch(b){if(b instanceof Error&&b.name==="GetPortError"&&o+1<=p)return t&&console.debug(`Expanding port lookup to range [${o+1}, ${p}].`),await v({portRange:[o+1,p]});throw b}}function w(s){return s>=0}function B(s,t){let e={},n;for(let u of t){let{databasePort:r,port:a,shadowDatabasePort:i}=u;if(u.name===s){n={databasePort:r,port:a,shadowDatabasePort:i};continue}e[r]=!0,e[a]=!0,e[i]=!0}return{portsUsedByOtherServers:e,portsUsedByThisServerLastTime:n}}async function q(s){let{debug:t,otherRequestedPorts:e,portKey:n,portsUsedByOtherServers:u,requestedPort:r}=s;if(r in u)throw t&&console.error(`Port ${r} was requested for "${n}", but is already used by another server.`),new y(r);if(Object.values(e).includes(r))throw t&&console.error(`Port ${r} was requested for "${n}", but also for another key.`),new l(r);if(T(r))throw t&&console.error(`Port ${r} was requested for "${n}", but is unsafe.`),new f(r);if(await O(r)===!1)throw t&&console.error(`Port ${r} was requested for "${n}", but is not available.`),new f(r)}var f=class extends Error{constructor(e){super(`Port \`${e}\` is not available.`);this.port=e}name="PortNotAvailableError"},l=class extends Error{constructor(e){super(`Port number \`${e}\` was requested twice. Please choose a different port for each service.`);this.port=e}name="PortRequestedTwiceError"},y=class extends Error{constructor(e){super(`Port number \`${e}\` belongs to another Prisma Dev server. Please choose a different port.`);this.port=e}name="PortBelongsToAnotherServerError"};export{h as a,S as b,g as c,P as d,_ as e,f};
|
package/dist/chunk-RODR7QVK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var n=Object.create;var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var d=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var s=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of p(e))!f.call(t,m)&&m!==o&&i(t,m,{get:()=>e[m],enumerable:!(r=a(e,m))||r.enumerable});return t};var h=(t,e,o)=>(o=t!=null?n(c(t)):{},s(e||!t||!t.__esModule?i(o,"default",{value:t,enumerable:!0}):o,t));import D from"path";import{fileURLToPath as L}from"url";var _=l(()=>{"use strict"});export{d as a,g as b,h as c,_ as d};
|
package/dist/chunk-UZV6WD53.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as b,c as v,d as R}from"./chunk-ZPA6K2XO.js";import{d as u}from"./chunk-RODR7QVK.js";u();import{minLength as j,object as B,optional as K,parseJson as L,pipe as w,regex as S,safeParse as _,string as E,url as A}from"valibot";var T=/^(postgres|postgresql):\/\//,N=w(E(),L(),B({databaseUrl:w(E(),A(),S(T)),name:K(w(E(),j(1))),shadowDatabaseUrl:w(E(),A(),S(T))}));function Y(r){return Buffer.from(JSON.stringify(Object.fromEntries(Object.entries(r).sort(([[e],[n]])=>e.localeCompare(n)))),"utf8").toString("base64url")}function Q(r){let e=Buffer.from(r,"base64url").toString("utf8"),{issues:n,output:s,success:t}=_(N,e,{abortEarly:!0});return t?[null,s]:[n]}var X=async(r,e)=>{let{authorization:n}=r,{HTTPException:s}=await import("hono/http-exception");if(!n)throw new s(401,{message:"Missing API Key"});let[t,o="",i]=n.split(" ");if(t!=="Bearer"||i)throw new s(401,{message:"Invalid API Key"});let[a,m]=Q(o);if(a)throw new s(401,{message:"Invalid API Key",cause:a.join(", ")});let{databaseUrl:h,name:c,shadowDatabaseUrl:l}=m,{name:d}=e.get("serverState");if(!c)throw new s(401,{message:`Wrong API Key; The Prisma Dev server running at port ${e.get("port")} requires an API Key from a newer version of \`prisma dev\`. Check the "${d}" server's output for the updated \`DATABASE_URL\` value.`});if(c!==d)throw new s(401,{message:`Wrong API Key; The Prisma Dev server running at port ${e.get("port")} is named "${d}", but the API Key is for "${c}"`});let{hostname:f,port:y}=new URL(h),{port:P}=e.get("db"),{hostname:C,port:H}=new URL(l),D=e.get("shadowDBPort");if(f!=="localhost"||Number(y)!==P||C!=="localhost"||Number(H)!==D)throw new s(401,{message:"Wrong API Key; Check your Prisma schema's `provider.url` value (probably defined in `.env`'s `DATABASE_URL` environment variable) is aligned with `prisma dev`'s output"});return{decodedAPIKey:m}};u();import{spawn as F}from"child_process";import{once as U}from"events";import{mkdir as V}from"fs/promises";import{join as z}from"path";import{setTimeout as M}from"timers/promises";u();function I(r){let e,n,s=new Promise((i,a)=>{e=i,n=a}),t=i=>{t=o=null,n(i),r?.onRejected?.(i),r?.onFulfilled?.()},o=i=>{o=t=null,e(i),r?.onResolved?.(i),r?.onFulfilled?.()};return{isFulfilled:()=>o===t,promise:s,reject:i=>t?.(i),resolve:i=>o?.(i)}}import{process as q}from"std-env";var{PRISMA_DEV_FORCE_ENGINE_BINARY_DOWNLOAD:J,PRISMA_DEV_FORCE_ENGINE_BINARY_PATH:G,PRISMA_DEV_FORCE_NETWORK_DELAY_MS:x}=q.env,$=class r{static#t=new Map;#e;#n;constructor(e){this.#e=e,this.#n=null}static async get(e){let{debug:n}=e,s=`${e.schemaHash}:${e.clientVersion}`;try{let t=r.#t.get(s);if(t)return t;let o=new r(e);return r.#t.set(s,o),n&&console.debug("[Query Engine] starting...",e),await o.start(),n&&console.debug("[Query Engine] started!"),o}finally{r.stopAll(s)}}static async stopAll(e){let s=(await Promise.allSettled(Array.from(r.#t.entries()).filter(([t])=>t!==e).map(async([t,o])=>{try{await o.stop()}finally{r.#t.delete(t)}}))).filter(t=>t.status==="rejected").map(t=>t.reason);if(s.length>0)throw new AggregateError(s,"Failed to stop engines")}async commitTransaction(e,n){return await this.#i(e,n,"commit")}async request(e,n){let{url:s}=await this.start(),t=this.#s(n),o=await fetch(s,{body:typeof e=="string"?e:JSON.stringify(e),headers:{...t,"Content-Type":"application/json"},method:"POST"});if(!o.ok)throw await g.fromResponse(o);return await o.text()}async rollbackTransaction(e,n){return await this.#i(e,n,"rollback")}async startTransaction(e,n){let{url:s}=await this.start(),t=this.#s(n),o=await fetch(`${s}/transaction/start`,{body:JSON.stringify(e),headers:{...t,"Content-Type":"application/json"},method:"POST"});if(!o.ok)throw await g.fromResponse(o);return await o.json()}async start(){if(this.#n!=null)return await this.#n;let{promise:e,reject:n,resolve:s}=I();this.#n=e;let t=G||await this.#o();this.#e.debug&&console.debug("[Query Engine] spinning up at path...",t);let{proxySignals:o}=await import("foreground-child/proxy-signals"),i=F(t,["--enable-raw-queries","--enable-telemetry-in-response","--port","0"],{env:{LOG_QUERIES:"y",PRISMA_DML:this.#e.base64Schema,QE_LOG_LEVEL:"TRACE",RUST_BACKTRACE:"1",RUST_LOG:"info"},stdio:["ignore","pipe","pipe"],windowsHide:!0});o(i),i.stderr.setEncoding("utf8"),i.stdout.setEncoding("utf8");let a=c=>{let l=c.split(`
|
|
2
|
-
`).find(P=>P.includes("Started query engine http server"));if(!l)return;i.stdout.removeListener("data",a);let{fields:d}=JSON.parse(l);if(d==null)return n(new Error(`Unexpected data during initialization, "fields" are missing: ${c}`));let{ip:f,port:y}=d;if(f==null||y==null)return n(new Error(`This version of query-engine is not compatible with minippg, "ip" and "port" are missing in the startup log entry.
|
|
3
|
-
Received data: ${c}`));s({childProcess:i,url:`http://${f}:${y}`})},m=c=>{this.#n=null,n(new p(String(c))),i.removeListener("exit",h),i.kill()};i.once("error",m);let h=(c,l)=>{this.#n=null,n(new p(`Query Engine exited with code ${c} and signal ${l}`))};return i.once("exit",h),i.stdout.on("data",a),this.#e.debug&&(i.stderr.on("data",console.error.bind(console,"[Query Engine]")),i.stdout.on("data",console.debug.bind(console,"[Query Engine]"))),await this.#n}async stop(){if(this.#n==null)return;let{childProcess:e}=await this.#n;e.exitCode==null&&e.signalCode==null&&(this.#n=null,e.kill(),await U(e,"exit"))}async#o(){this.#e.debug&&console.debug("[Query Engine] getting engine commit hash...");let e=await this.#r();this.#e.debug&&console.debug("[Query Engine] got engine commit hash",e);let n=b(this.#e.clientVersion,e);this.#e.debug&&console.debug("[Query Engine] cache directory path",n),await V(n,{recursive:!0});let{binaryTarget:s}=this.#e.platform,t=s==="windows"?".exe":"",o=z(n,`query-engine-${s}${t}`);return this.#e.debug&&console.debug("[Query Engine] binary path",o),(J==="1"||await v(o)===!1)&&await this.#a({commitHash:e,extension:t,engineBinaryPath:o}),o}async#r(){let e=await fetch(`https://registry.npmjs.org/@prisma/client/${this.#e.clientVersion}`);if(!e.ok)throw new Error(`Couldn't fetch package.json from npm registry, status code: ${e.status}`);let s=(await e.json()).devDependencies?.["@prisma/engines-version"];if(!s)throw new Error("Couldn't find engines version in package.json");let t=s.split(".").at(-1);if(!t)throw new Error("Couldn't find commit hash in engines version");return t}async#a(e){let{commitHash:n,extension:s,engineBinaryPath:t}=e,{binaryTarget:o}=this.#e.platform,i=`https://binaries.prisma.sh/all_commits/${n}/${o}/query-engine${s}.gz`;this.#e.debug&&console.debug("[Query Engine] downloading engine from url",i);let a=await fetch(i);if(!a.ok)throw new Error(`Couldn't download engine. URL: ${i}, status code: ${a.status}`);x&&await M(Number(x)),await R(await a.arrayBuffer(),t),this.#e.debug&&console.debug("[Query Engine] downloaded and saved at",t)}#s(e){let n={};for(let[s,t]of Object.entries(e))t!=null&&(n[s]=t);return n}async#i(e,n,s){let{url:t}=await this.#n,o=this.#s(n),i=await fetch(`${t}/transaction/${e}/${s}`,{headers:{...o,"Content-Type":"application/json"},method:"POST"});if(!i.ok)throw await g.fromResponse(i);try{return await i.json()}catch{return{}}}};function ue(r,e){return console.error(r),r instanceof p?e.json({EngineNotStarted:{reason:{EngineStartupError:{logs:[],msg:r.message}}}},500):r instanceof g?e.text(r.responseBody,r.statusCode):e.body(null,500)}var p=class extends Error{name="EngineStartError"},g=class r extends Error{constructor(n,s,t){super(`${n}: Query Engine response status ${s}, body: ${t}`);this.action=n;this.statusCode=s;this.responseBody=t}name="EngineHttpError";static async fromResponse(n){let s=new URL(n.url),t=await n.text();return new r(s.pathname,n.status,t)}};export{Y as a,X as b,I as c,$ as d,ue as e};
|
package/dist/chunk-ZPA6K2XO.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as c}from"./chunk-RODR7QVK.js";c();import{createWriteStream as A,WriteStream as D}from"fs";import{access as x,chmod as P,constants as E,mkdir as T,readdir as _,readFile as F,rm as O,writeFile as v}from"fs/promises";import{promisify as L}from"util";import{unzip as C}from"zlib";c();import o from"path";import l from"os";import a from"process";var n=l.homedir(),p=l.tmpdir(),{env:e}=a,y=r=>{let t=o.join(n,"Library");return{data:o.join(t,"Application Support",r),config:o.join(t,"Preferences",r),cache:o.join(t,"Caches",r),log:o.join(t,"Logs",r),temp:o.join(p,r)}},j=r=>{let t=e.APPDATA||o.join(n,"AppData","Roaming"),i=e.LOCALAPPDATA||o.join(n,"AppData","Local");return{data:o.join(i,r,"Data"),config:o.join(t,r,"Config"),cache:o.join(i,r,"Cache"),log:o.join(i,r,"Log"),temp:o.join(p,r)}},w=r=>{let t=o.basename(n);return{data:o.join(e.XDG_DATA_HOME||o.join(n,".local","share"),r),config:o.join(e.XDG_CONFIG_HOME||o.join(n,".config"),r),cache:o.join(e.XDG_CACHE_HOME||o.join(n,".cache"),r),log:o.join(e.XDG_STATE_HOME||o.join(n,".local","state"),r),temp:o.join(p,t,r)}};function u(r,{suffix:t="nodejs"}={}){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);return t&&(r+=`-${t}`),a.platform==="darwin"?y(r):a.platform==="win32"?j(r):w(r)}import G from"zeptomatch";var m=u("prisma-dev"),$=L(C);function I(r,t){return`${m.cache}/engine/${r}/${t}`}function J(r){return`${m.data}/${r}`}async function K(r){try{return await x(r,E.F_OK),!0}catch(t){if(f(t))return!1;throw t}}async function q(r,t){let i=await $(r);await v(t,i),await P(t,"755")}async function Q(r,t){await r.stream().pipeTo(D.toWeb(A(t,{encoding:"utf-8"})))}function f(r){return r!=null&&typeof r=="object"&&"code"in r&&r.code==="ENOENT"}async function U(r){try{return await F(r,{encoding:"utf-8"})}catch(t){if(f(t))return null;throw t}}async function V(r){await T(r,{recursive:!0})}async function Y(r,t){try{return(await _(r,{withFileTypes:!0})).reduce((g,s)=>(s.isDirectory()&&!s.name.startsWith(".")&&(!t||G(t,s.name))&&g.push(s.name),g),[])}catch(i){if(f(i))return[];throw i}}async function Z(r){await O(r,{force:!0,recursive:!0})}export{I as a,J as b,K as c,q as d,Q as e,U as f,V as g,Y as h,Z as i};
|
package/dist/utility-2R6QXHRL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as a}from"./chunk-RODR7QVK.js";a();import{Hono as n}from"hono/tiny";import{StatusCodes as s}from"http-status-codes";var o=new n;o.post("/database/dump",async t=>{let r=t.get("db"),e=t.get("serverState");return await r.dump(e.databaseDumpPath),t.json({dumpPath:e.databaseDumpPath},s.CREATED)});var d=o.get("/health",t=>t.json({name:t.get("serverState").name}));export{o as utilityRoute};
|