@prisma/dev 0.24.14 → 0.24.15

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/daemon.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-FB4QA6EA.js";import"./chunk-662IKR3V.js";import"./chunk-PP43TGA5.js";import"./chunk-KWCQYPJI.js";import"./chunk-HFONW2ZS.js";import"./chunk-ANHBRJRZ.js";import"./chunk-EDFHV3AK.js";import"./chunk-DWY47FQV.js";import"./chunk-DOJAPHLY.js";import{setTimeout as o}from"timers/promises";var e;process.once("SIGTERM",()=>{console.log("SIGTERM received, shutting down..."),process.removeAllListeners("SIGINT"),process.exitCode=143,e?.close().finally(()=>process.exit())});process.once("SIGINT",()=>{console.log("SIGINT received, shutting down..."),process.removeAllListeners("SIGTERM"),process.exitCode=130,e?.close().finally(()=>process.exit())});async function n(){let[,,t]=process.argv;if(!t)return process.send?.({type:"error",error:'Missing "name" argument, server cannot be started'},void 0),process.exit(1);try{e=await a({debug:!0,persistenceMode:"stateful",name:t});let r=e.experimental.queryInsights,s={database:e.database,experimental:{queryInsights:{serverUrl:r.serverUrl,sqlitePath:r.sqlitePath,streamName:r.streamName,url:r.url},streams:e.experimental.streams},http:e.http,name:e.name,ppg:e.ppg,shadowDatabase:e.shadowDatabase};process.send?.({type:"started",server:s},void 0)}catch(r){console.error(r);let s=r instanceof Error?r.message:String(r);process.send?.({type:"error",error:s},void 0),await o(1e3),process.exit(1)}}n();
1
+ import{a as o}from"./chunk-RN4YJIL3.js";import"./chunk-DEMTR4W3.js";import"./chunk-WQHUHPVC.js";import"./chunk-HM357TKK.js";import"./chunk-GT33FFME.js";import"./chunk-I2OHVRST.js";import"./chunk-UEE5SWKL.js";import"./chunk-MN4XKQ55.js";import"./chunk-T6L5TENJ.js";import{d as a}from"./chunk-JLSS5G22.js";a();import{setTimeout as n}from"timers/promises";var e;process.once("SIGTERM",()=>{console.log("SIGTERM received, shutting down..."),process.removeAllListeners("SIGINT"),process.exitCode=143,e?.close().finally(()=>process.exit())});process.once("SIGINT",()=>{console.log("SIGINT received, shutting down..."),process.removeAllListeners("SIGTERM"),process.exitCode=130,e?.close().finally(()=>process.exit())});async function i(){let[,,t]=process.argv;if(!t)return process.send?.({type:"error",error:'Missing "name" argument, server cannot be started'},void 0),process.exit(1);try{e=await o({debug:!0,persistenceMode:"stateful",name:t});let r=e.experimental.queryInsights,s={database:e.database,experimental:{queryInsights:{serverUrl:r.serverUrl,sqlitePath:r.sqlitePath,streamName:r.streamName,url:r.url},streams:e.experimental.streams},http:e.http,name:e.name,ppg:e.ppg,shadowDatabase:e.shadowDatabase};process.send?.({type:"started",server:s},void 0)}catch(r){console.error(r);let s=r instanceof Error?r.message:String(r);process.send?.({type:"error",error:s},void 0),await n(1e3),process.exit(1)}}i();
package/dist/db.js CHANGED
@@ -1 +1 @@
1
- import{c as a,d as b,e as c,f as d,g as e,h as f}from"./chunk-PP43TGA5.js";import"./chunk-KWCQYPJI.js";import"./chunk-EDFHV3AK.js";import"./chunk-DWY47FQV.js";export{a as attachWalEventBridge,f as dumpDB,b as shouldPollWalAfterMessages,c as shouldPollWalAfterResponse,d as startDBServer,e as startLazyShadowDBServer};
1
+ import{c as a,d as b,e as c,f as d,g as e,h as f}from"./chunk-WQHUHPVC.js";import"./chunk-HM357TKK.js";import"./chunk-UEE5SWKL.js";import"./chunk-MN4XKQ55.js";import"./chunk-JLSS5G22.js";export{a as attachWalEventBridge,f as dumpDB,b as shouldPollWalAfterMessages,c as shouldPollWalAfterResponse,d as startDBServer,e as startLazyShadowDBServer};
@@ -0,0 +1,3 @@
1
+ import{b as w,d as y,e as E}from"./chunk-MN4XKQ55.js";import{a as v,b,c as R}from"./chunk-T6L5TENJ.js";import{d as g}from"./chunk-JLSS5G22.js";g();import{spawn as H}from"child_process";import{once as C}from"events";import{mkdir as A}from"fs/promises";import{join as j}from"path";import{setTimeout as B}from"timers/promises";g();function P(r){let e,t,s=new Promise((i,a)=>{e=i,t=a}),n=i=>{n=o=null,t(i),r?.onRejected?.(i),r?.onFulfilled?.()},o=i=>{o=n=null,e(i),r?.onResolved?.(i),r?.onFulfilled?.()};return{isFulfilled:()=>o===n,promise:s,reject:i=>n?.(i),resolve:i=>o?.(i)}}import{process as L}from"std-env";var{PRISMA_DEV_FORCE_ENGINE_BINARY_DOWNLOAD:N,PRISMA_DEV_FORCE_ENGINE_BINARY_PATH:Q,PRISMA_DEV_FORCE_NETWORK_DELAY_MS:S}=L.env,T=class r{static#t=new Map;#e;#n;constructor(e){this.#e=e,this.#n=null}static async get(e){let{debug:t}=e,s=`${e.schemaHash}:${e.clientVersion}`;try{let n=r.#t.get(s);if(n)return n;let o=new r(e);return r.#t.set(s,o),t&&console.debug("[Query Engine] starting...",e),await o.start(),t&&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(([n])=>n!==e).map(async([n,o])=>{try{await o.stop()}finally{r.#t.delete(n)}}))).filter(n=>n.status==="rejected").map(n=>n.reason);if(s.length>0)throw new AggregateError(s,"Failed to stop engines")}async commitTransaction(e,t){return await this.#s(e,t,"commit")}async request(e,t){let{url:s}=await this.start(),n=this.#i(t),o=await fetch(s,{body:typeof e=="string"?e:JSON.stringify(e),headers:{...n,"Content-Type":"application/json"},method:"POST"});if(!o.ok)throw await l.fromResponse(o);return await o.text()}async rollbackTransaction(e,t){return await this.#s(e,t,"rollback")}async startTransaction(e,t){let{url:s}=await this.start(),n=this.#i(t),o=await fetch(`${s}/transaction/start`,{body:JSON.stringify(e),headers:{...n,"Content-Type":"application/json"},method:"POST"});if(!o.ok)throw await l.fromResponse(o);return await o.json()}async start(){if(this.#n!=null)return await this.#n;let{promise:e,reject:t,resolve:s}=P();this.#n=e;let n=Q||await this.#o();this.#e.debug&&console.debug("[Query Engine] spinning up at path...",n);let{proxySignals:o}=await import("foreground-child/proxy-signals"),i=H(n,["--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 u=c.split(`
2
+ `).find(O=>O.includes("Started query engine http server"));if(!u)return;i.stdout.removeListener("data",a);let{fields:m}=JSON.parse(u);if(m==null)return t(new Error(`Unexpected data during initialization, "fields" are missing: ${c}`));let{ip:h,port:f}=m;if(h==null||f==null)return t(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://${h}:${f}`})},k=c=>{this.#n=null,t(new d(String(c))),i.removeListener("exit",p),i.kill()};i.once("error",k);let p=(c,u)=>{this.#n=null,t(new d(`Query Engine exited with code ${c} and signal ${u}`))};return i.once("exit",p),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 C(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 t=w(this.#e.clientVersion,e);this.#e.debug&&console.debug("[Query Engine] cache directory path",t),await A(t,{recursive:!0});let{binaryTarget:s}=this.#e.platform,n=s==="windows"?".exe":"",o=j(t,`query-engine-${s}${n}`);return this.#e.debug&&console.debug("[Query Engine] binary path",o),(N==="1"||await y(o)===!1)&&await this.#a({commitHash:e,extension:n,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 n=s.split(".").at(-1);if(!n)throw new Error("Couldn't find commit hash in engines version");return n}async#a(e){let{commitHash:t,extension:s,engineBinaryPath:n}=e,{binaryTarget:o}=this.#e.platform,i=`https://binaries.prisma.sh/all_commits/${t}/${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}`);S&&await B(Number(S)),await E(await a.arrayBuffer(),n),this.#e.debug&&console.debug("[Query Engine] downloaded and saved at",n)}#i(e){let t={};for(let[s,n]of Object.entries(e))n!=null&&(t[s]=n);return t}async#s(e,t,s){let{url:n}=await this.#n,o=this.#i(t),i=await fetch(`${n}/transaction/${e}/${s}`,{headers:{...o,"Content-Type":"application/json"},method:"POST"});if(!i.ok)throw await l.fromResponse(i);try{return await i.json()}catch{return{}}}};function W(r,e){if(console.error(r),r instanceof d){v(e,{EngineNotStarted:{reason:{EngineStartupError:{logs:[],msg:r.message}}}},500);return}if(r instanceof l){b(e,r.responseBody,r.statusCode);return}R(e,500)}var d=class extends Error{name="EngineStartError"},l=class r extends Error{constructor(t,s,n){super(`${t}: Query Engine response status ${s}, body: ${n}`);this.action=t;this.statusCode=s;this.responseBody=n}name="EngineHttpError";static async fromResponse(t){let s=new URL(t.url),n=await t.text();return new r(s.pathname,t.status,n)}};export{T as Engine,W as handleEngineError};