@prisma/dev 0.0.0-dev.202512121158 → 0.0.0-dev.202512121230
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-B4RDPMOM.js +1 -0
- package/dist/chunk-GUJALUTC.js +3 -0
- package/dist/chunk-HQQF73SD.js +82 -0
- package/dist/chunk-KUHNXXCE.js +1 -0
- package/dist/chunk-NLG6WPCX.js +1 -0
- package/dist/chunk-RODR7QVK.js +1 -0
- package/dist/chunk-UZV6WD53.js +3 -0
- package/dist/chunk-ZPA6K2XO.js +1 -0
- package/dist/daemon.cjs +86 -5
- package/dist/daemon.js +1 -1
- package/dist/db.js +1 -1
- package/dist/index.cjs +86 -5
- package/dist/index.js +1 -1
- package/dist/state.js +1 -1
- package/dist/utility-2R6QXHRL.js +1 -0
- package/package.json +2 -2
- package/dist/accelerate-MVW5ZKXM.js +0 -1
- package/dist/chunk-7EOUKLQR.js +0 -3
- package/dist/chunk-EPFUMVT3.js +0 -1
- package/dist/chunk-FZ7JBZR6.js +0 -3
- package/dist/chunk-LMPFMHCB.js +0 -1
- package/dist/chunk-RBVZVBDC.js +0 -1
- package/dist/chunk-WZW6H4YB.js +0 -1
- package/dist/utility-YJ4TFSMW.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as c,d as b,e as f}from"./chunk-UZV6WD53.js";import"./chunk-ZPA6K2XO.js";import{d as s}from"./chunk-RODR7QVK.js";s();import{HTTPException as oe}from"hono/http-exception";import{Hono as ae}from"hono/tiny";import{validator as p}from"hono/validator";s();import{array as U,literal as k,minLength as D,object as F,pipe as N,safeParse as Q,string as X,union as Y}from"valibot";var z=F({tags:Y([N(U(X()),D(1)),k("all")])});async function E(e){let{output:n,success:t}=Q(z,await e.req.json(),{abortEarly:!0});return t?n:e.text("Invalid input",400)}s();import{parseDuration as S,parseSize as G,Server as W}from"@prisma/query-plan-executor";import{version as T}from"@prisma/query-plan-executor";var y;async function O(e){return y===void 0&&(y=await W.create({databaseUrl:e.get("db").connectionString,maxResponseSize:G("128 MiB"),queryTimeout:S("PT5M"),maxTransactionTimeout:S("PT5M"),maxTransactionWaitTime:S("PT5M"),perRequestLogContext:{logFormat:"text",logLevel:e.get("debug")?"debug":"off"}})),y}s();import{Buffer as w}from"buffer";import{produceSchema as K}from"@mrleebo/prisma-ast";var d=new Map;async function v(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}function x(e){let n=e.req.param("schemaHash"),t=d.get(n);return t==null?e.json({EngineNotStarted:{reason:"SchemaMissing"}},404):{schemaHash:n,schemas:t}}async function I(e,n,t){let r=w.from(e,"base64").toString("utf8"),o=K(r,i=>{i.datasource('"postgresql"',n.toString())});t&&console.log("[Accelerate] schema with override:",o);let a=await v(o);return{base64Override:w.from(o,"utf8").toString("base64"),overrideHash:a}}s();function l(e){let{req:n}=e;return{traceparent:n.header("traceparent"),"X-capture-telemetry":n.header("X-capture-telemetry")}}s();import{integer as C,looseObject as J,minValue as q,number as P,object as Z,optional as ee,pipe as R,safeParse as A,string as _,union as te}from"valibot";var ne=Z({isolation_level:ee(_()),max_wait:R(P(),C(),q(0)),timeout:R(P(),C(),q(0))});async function M(e){let{issues:n,output:t,success:r}=A(ne,await e.req.json(),{abortEarly:!0});return r?t:e.json({EngineNotStarted:{reason:"InvalidRequest",issues:n}},400)}var re=J({id:te([_(),P()])});function V(e,n){let{output:t,success:r}=A(re,e);return r?t:n.json({EngineMalfunction:{}},500)}var g=new ae;g.post("/invalidate",p("header",c),async e=>{let n=await E(e);return n instanceof Response?n:e.body(null)});var se="/:clientVersion/:schemaHash",h=g.basePath(se);g.route("/",h);var ie=["/graphql","/itx/:transactionId/graphql"];h.on("POST",[...ie],p("header",c),async e=>{let{req:n}=e;try{let t=await H(e);if(t instanceof Response)return t;let r=await n.text(),o=n.param("transactionId"),a=await t.request(r,{...l(e),"X-transaction-id":o});return e.text(a)}catch(t){return f(t,e)}});h.basePath("/itx/:transactionId").on("POST",["/commit","/rollback"],p("header",c),async e=>{let{req:n}=e;try{let t=await H(e);if(t instanceof Response)return t;let o=`${n.routePath.split("/").filter(Boolean).at(-1)}Transaction`,a=n.param("transactionId"),i=await t[o](a,l(e));return e.json(i)}catch(t){return f(t,e)}});h.put("/schema",p("header",c),async e=>{let{req:n}=e,t=await n.text();if(!t)return e.text("Missing schema",400);let r=n.param("schemaHash"),o=d.get(r);if(o==null){if(r!==await v(t))return e.text("Schema hash mismatch",400);let a=await I(t,e.get("db").prismaORMConnectionString,e.get("debug"));return d.set(r,{base64Original:t,...a}),e.text(r)}return t!==o.base64Original?e.text("Schema mismatch",400):e.text(r)});h.post("/transaction/start",p("header",c),async e=>{let{req:n}=e,t=await M(e);if(t instanceof Response)return t;try{let r=await H(e);if(r instanceof Response)return r;let o=await r.startTransaction(t,l(e)),a=V(o,e);if(a instanceof Response)return a;let{id:i}=a,$=n.param("clientVersion"),j=e.get("port"),L=e.get("protocol"),B=n.param("schemaHash");return e.json({...o,"data-proxy":{endpoint:`${L}://localhost:${j}/${$}/${B}/itx/${i}`}})}catch(r){return f(r,e)}});async function H(e){let{req:n}=e,t=x(e);if(t instanceof Response)return t;let{base64Override:r,overrideHash:o}=t.schemas;return await b.get({base64Schema:r,clientVersion:process.env.PRISMA_DEV_FORCE_CLIENT_VERSION||n.param("clientVersion"),debug:e.get("debug"),platform:e.get("platform"),schemaHash:o})}var ce=[["/connection-info","GET"],["/query","POST"],["/transaction/start","POST"],["/transaction/:transactionId/commit","POST"],["/transaction/:transactionId/query","POST"],["/transaction/:transactionId/rollback","POST"]];for(let[e,n]of ce)g.on(n,e,p("header",c),async t=>{let r=t.req.header("prisma-engine-hash");if(r!=="0.0.0"&&r!==T)throw new oe(400,{message:`Using an HTTP connection string is not supported with Prisma Client version ${r} by this version of \`prisma dev\`. Please either use a direct TCP connection string or upgrade your client to version ${T}.`});return await(await O(t)).fetch(t.req.raw)});export{g as accelerateRoute};
|
|
@@ -0,0 +1,3 @@
|
|
|
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};
|