@prisma/dev 0.0.0-dev.202505221535 → 0.0.0-dev.202505221907
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/index.d.ts +38 -22
- package/dist/index.js +5 -4
- package/package.json +9 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
declare const DEFAULT_DATABASE_PORT = 51214;
|
|
3
|
-
declare const DEFAULT_SHADOW_DATABASE_PORT = 51215;
|
|
4
|
-
type PortAssignableService = "accelerate" | "database" | "shadow_database";
|
|
5
|
-
declare class PortNotAvailableError extends Error {
|
|
6
|
-
port: number;
|
|
7
|
-
service: PortAssignableService;
|
|
8
|
-
name: string;
|
|
9
|
-
constructor(port: number, service: PortAssignableService);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface StartServerOptions {
|
|
13
|
-
/**
|
|
14
|
-
* The port the Accelerate server will listen on.
|
|
15
|
-
*
|
|
16
|
-
* Defaults to `51213`.
|
|
17
|
-
*
|
|
18
|
-
* An error is thrown if the port is already in use.
|
|
19
|
-
*/
|
|
20
|
-
acceleratePort?: number;
|
|
1
|
+
interface ServerOptions {
|
|
21
2
|
/**
|
|
22
3
|
* The port the database server will listen on.
|
|
23
4
|
*
|
|
@@ -38,6 +19,26 @@ interface StartServerOptions {
|
|
|
38
19
|
* Defaults to `false`.
|
|
39
20
|
*/
|
|
40
21
|
dryRun?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The name of the server.
|
|
24
|
+
*
|
|
25
|
+
* Defaults to `default`.
|
|
26
|
+
*/
|
|
27
|
+
name?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The persistence mode of the server.
|
|
30
|
+
*
|
|
31
|
+
* Default is `stateless`.
|
|
32
|
+
*/
|
|
33
|
+
persistenceMode?: PersistenceMode;
|
|
34
|
+
/**
|
|
35
|
+
* The port the server will listen on.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to `51213`.
|
|
38
|
+
*
|
|
39
|
+
* An error is thrown if the port is already in use.
|
|
40
|
+
*/
|
|
41
|
+
port?: number;
|
|
41
42
|
/**
|
|
42
43
|
* The port the shadow database server will listen on.
|
|
43
44
|
*
|
|
@@ -47,6 +48,21 @@ interface StartServerOptions {
|
|
|
47
48
|
*/
|
|
48
49
|
shadowDatabasePort?: number;
|
|
49
50
|
}
|
|
51
|
+
type PersistenceMode = "stateless" | "stateful";
|
|
52
|
+
|
|
53
|
+
type DBServerPurpose = "database" | "shadow_database";
|
|
54
|
+
|
|
55
|
+
declare const DEFAULT_DATABASE_PORT = 51214;
|
|
56
|
+
declare const DEFAULT_SERVER_PORT = 51213;
|
|
57
|
+
declare const DEFAULT_SHADOW_DATABASE_PORT = 51215;
|
|
58
|
+
type PortAssignableService = DBServerPurpose | "server";
|
|
59
|
+
declare class PortNotAvailableError extends Error {
|
|
60
|
+
port: number;
|
|
61
|
+
service: PortAssignableService;
|
|
62
|
+
name: string;
|
|
63
|
+
constructor(port: number, service: PortAssignableService);
|
|
64
|
+
}
|
|
65
|
+
|
|
50
66
|
interface Server {
|
|
51
67
|
accelerate: {
|
|
52
68
|
url: string;
|
|
@@ -62,6 +78,6 @@ interface Server {
|
|
|
62
78
|
connectionString: string;
|
|
63
79
|
};
|
|
64
80
|
}
|
|
65
|
-
declare function unstable_startServer(options?:
|
|
81
|
+
declare function unstable_startServer(options?: ServerOptions): Promise<Server>;
|
|
66
82
|
|
|
67
|
-
export {
|
|
83
|
+
export { DEFAULT_DATABASE_PORT, DEFAULT_SERVER_PORT, DEFAULT_SHADOW_DATABASE_PORT, type PortAssignableService, PortNotAvailableError, type Server, unstable_startServer };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{createServer as
|
|
3
|
-
`).find(
|
|
4
|
-
Received data: ${i}`));
|
|
2
|
+
import{createServer as et}from"http";import{promisify as tt}from"util";import{serve as rt}from"@hono/node-server";import nt from"@prisma/get-platform";import{logger as ot}from"hono/logger";import{Hono as pe}from"hono/tiny";import{validator as S}from"hono/validator";import{process as st}from"std-env";import{HTTPException as E}from"hono/http-exception";import{object as he,optional as be,parseJson as ye,pipe as x,regex as U,safeParse as we,string as $,url as N}from"valibot";var q=/^(postgres|postgresql):\/\//,Se=x($(),ye(),he({databaseUrl:x($(),N(),U(q)),shadowDatabaseUrl:be(x($(),N(),U(q)))}));function V(t){return Buffer.from(JSON.stringify(t),"utf8").toString("base64url")}function Pe(t){let e=Buffer.from(t,"base64url").toString("utf8"),{issues:r,output:n,success:o}=we(Se,e,{abortEarly:!0});return o?[null,n]:[r]}var p=(t,e)=>{let{authorization:r}=t;if(!r)throw new E(401,{message:"Missing API Key"});let[n,o="",s]=r.split(" ");if(n!=="Bearer"||s)throw new E(401,{message:"Invalid API Key"});let[a,i]=Pe(o);if(a)throw new E(401,{message:"Invalid API Key",cause:a.join(", ")});let{databaseUrl:c}=i;if(c!==e.var.db.connectionString)throw new E(401,{message:"Unauthorized"});return{decodedAPIKey:i}};import{array as ve,literal as Ee,minLength as De,object as Ae,pipe as Te,safeParse as Re,string as Oe,union as xe}from"valibot";var $e=Ae({tags:xe([Te(ve(Oe()),De(1)),Ee("all")])});async function K(t){let{output:e,success:r}=Re($e,await t.req.json(),{abortEarly:!0});return r?e:t.text("Invalid input",400)}import{spawn as Ne}from"child_process";import{once as qe}from"events";import{mkdir as Ve}from"fs/promises";import{join as Ke}from"path";import{process as Ge}from"std-env";import{createWriteStream as Ie,WriteStream as ke}from"fs";import{access as He,chmod as _e,constants as Be,readFile as Ce,stat as Le,unlink as Me,writeFile as Fe}from"fs/promises";import je from"env-paths";import{inflate as Ue}from"pako";var G=je("prisma-dev");function z(t,e){return`${G.cache}/engine/${t}/${e}`}function J(t){return`${G.data}/${t}`}async function D(t){try{return await He(t,Be.F_OK),!0}catch(e){if(k(e))return!1;throw e}}async function Q(t,e){let r=Ue(t);await Fe(e,r),await _e(e,"755")}async function W(t,e){await t.stream().pipeTo(ke.toWeb(Ie(e,{encoding:"utf-8"})))}async function X(t){try{return await Me(t),!0}catch{return!1}}async function I(t){try{return(await Le(t)).mtimeMs}catch(e){if(k(e))return-1/0;throw e}}function k(t){return t!=null&&typeof t=="object"&&"code"in t&&t.code==="ENOENT"}async function Y(t){try{return await Ce(t,{encoding:"utf-8"})}catch(e){if(k(e))return null;throw e}}function A(){let t,e,r=new Promise((n,o)=>{t=n,e=o});return{fail:e,promise:r,succeed:t}}var y=class t{static#r=new Map;#e;#t;constructor(e){this.#e=e,this.#t=null}static async get(e){let r=`${e.schemaHash}:${e.clientVersion}`;try{let n=t.#r.get(r);if(n)return n;let o=new t(e);return t.#r.set(r,o),e.debug&&console.debug("starting engine...",e),await o.start(),e.debug&&console.debug("engine started!"),o}finally{t.stopAll(r)}}static async stopAll(e){let n=(await Promise.allSettled(Array.from(t.#r.entries()).filter(([o])=>o!==e).map(async([o,s])=>{try{await s.stop()}finally{t.#r.delete(o)}}))).filter(o=>o.status==="rejected").map(o=>o.reason);if(n.length>0)throw new AggregateError(n,"Failed to stop engines")}async commitTransaction(e,r){return await this.#i(e,r,"commit")}async request(e,r){let{url:n}=await this.#t,o=this.#n(r),s=await fetch(n,{body:typeof e=="string"?e:JSON.stringify(e),headers:{...o,"Content-Type":"application/json"},method:"POST"});if(!s.ok)throw await g.fromResponse(s);return await s.text()}async rollbackTransaction(e,r){return await this.#i(e,r,"rollback")}async startTransaction(e,r){let{url:n}=await this.#t,o=this.#n(r),s=await fetch(`${n}/transaction/start`,{body:JSON.stringify(e),headers:{...o,"Content-Type":"application/json"},method:"POST"});if(!s.ok)throw await g.fromResponse(s);return await s.json()}async start(){if(this.#t!=null)return;let{fail:e,promise:r,succeed:n}=A();this.#t=r;let o=await this.#s();this.#e.debug&&console.debug("spinning up engine at path...",o);let s=Ne(o,["--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});s.stderr.setEncoding("utf8"),s.stdout.setEncoding("utf8");let a=i=>{let c=i.split(`
|
|
3
|
+
`).find(u=>u.includes("Started query engine http server"));if(!c)return;s.stdout.removeListener("data",a);let{fields:l}=JSON.parse(c);if(l==null)return e(new Error(`Unexpected data during initialization, "fields" are missing: ${i}`));let{ip:b,port:m}=l;if(b==null||m==null)return e(new Error(`This version of query-engine is not compatible with minippg, "ip" and "port" are missing in the startup log entry.
|
|
4
|
+
Received data: ${i}`));n({childProcess:s,url:`http://${b}:${m}`})};s.once("error",i=>{this.#t=null,e(new w(String(i)))}),s.once("exit",(i,c)=>{this.#t=null,e(new w(`Query Engine exited with code ${i} and signal ${c}`))}),s.stdout.on("data",a),s.stderr.on("data",i=>{console.error(i)}),await this.#t}async stop(){if(this.#t==null)return;let{childProcess:e}=await this.#t;e.exitCode==null&&e.signalCode==null&&(e.kill(),await qe(e,"exit"))}async#s(){this.#e.debug&&console.debug("getting engine commit hash...");let e=await this.#o();this.#e.debug&&console.debug("got engine commit hash",e);let r=z(this.#e.clientVersion,e);this.#e.debug&&console.debug("cache directory path",r),await Ve(r,{recursive:!0});let{platform:n}=this.#e.platform,o=n==="windows"?".exe":"",s=Ke(r,`query-engine-${n}${o}`);return this.#e.debug&&console.debug("engine binary path",s),(Ge.env.PRISMA_DEV_FORCE_ENGINE_DOWNLOAD==="1"||await D(s)===!1)&&await this.#a({commitHash:e,extension:o,engineBinaryPath:s}),s}async#o(){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 n=(await e.json()).devDependencies?.["@prisma/engines-version"];if(!n)throw new Error("Couldn't find engines version in package.json");let o=n.split(".").at(-1);if(!o)throw new Error("Couldn't find commit hash in engines version");return o}async#a(e){let{commitHash:r,extension:n,engineBinaryPath:o}=e,{binaryTarget:s}=this.#e.platform,a=`https://binaries.prisma.sh/all_commits/${r}/${s}/query-engine${n}.gz`;this.#e.debug&&console.debug("downloading engine from url",a);let i=await fetch(a);if(!i.ok)throw new Error(`Couldn't download engine. URL: ${a}, status code: ${i.status}`);await Q(await i.arrayBuffer(),o),this.#e.debug&&console.debug("engine downloaded and saved at",o)}#n(e){let r={};for(let[n,o]of Object.entries(e))o!=null&&(r[n]=o);return r}async#i(e,r,n){let{url:o}=await this.#t,s=this.#n(r),a=await fetch(`${o}/transaction/${e}/${n}`,{headers:{...s,"Content-Type":"application/json"},method:"POST"});if(!a.ok)throw await g.fromResponse(a);try{return await a.json()}catch{return{}}}};function T(t,e){return console.error(t),t instanceof w?e.json({EngineNotStarted:{reason:{EngineStartupError:{logs:[],msg:t.message}}}},500):t instanceof g?e.text(t.responseBody,t.statusCode):e.body(null,500)}var w=class extends Error{name="EngineStartError"},g=class t extends Error{constructor(r,n,o){super(`${r}: Query Engine response status ${n}, body: ${o}`);this.action=r;this.statusCode=n;this.responseBody=o}name="EngineHttpError";static async fromResponse(r){let n=new URL(r.url),o=await r.text();return new t(n.pathname,r.status,o)}};var Z=51214,ee=51213,te=51215,f=class extends Error{constructor(r,n){super(`Port number \`${r}\` is not available for service ${n}.`);this.port=r;this.service=n}name="PortNotAvailableError"};import{Buffer as re}from"buffer";var R=new Map;async function H(t){let r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}function ne(t){let e=t.req.param("schemaHash"),r=R.get(e);return r==null?t.json({EngineNotStarted:{reason:"SchemaMissing"}},404):{schemaHash:e,schemas:r}}var ze=/datasource\s+db\s+\{\s*provider\s*=\s*"postgres(!?ql)?"\s+url\s*=\s*.+\s*\}/;async function oe(t,e){let r=re.from(t,"base64").toString("utf8"),n=`datasource db {
|
|
5
5
|
provider = "postgresql"
|
|
6
6
|
url = "${e}"
|
|
7
|
-
}`,o=
|
|
7
|
+
}`,o=r.replace(ze,n),s=await H(o);return{base64Override:re.from(o,"utf8").toString("base64"),overrideHash:s}}function O(t){let{req:e}=t;return{traceparent:e.header("traceparent"),"X-capture-telemetry":e.header("X-capture-telemetry")}}import{integer as se,looseObject as Je,minValue as ae,number as _,object as Qe,optional as We,pipe as ie,safeParse as ce,string as de,union as Xe}from"valibot";var Ye=Qe({isolation_level:We(de()),max_wait:ie(_(),se(),ae(0)),timeout:ie(_(),se(),ae(0))});async function ue(t){let{issues:e,output:r,success:n}=ce(Ye,await t.req.json(),{abortEarly:!0});return n?r:t.json({EngineNotStarted:{reason:"InvalidRequest",issues:e}},400)}var Ze=Je({id:Xe([de(),_()])});function le(t,e){let{output:r,success:n}=ce(Ze,t);return n?r:e.json({EngineMalfunction:{}},500)}async function ge(t,e){let{port:r}=e;if(e.dryRun)return me(r,null);let n=await at(r,t,e),{fail:o,promise:s,succeed:a}=A(),i=rt({createServer:et,fetch:n.fetch,port:r},()=>{a()});return i.on("error",c=>{if(typeof c=="object"&&"code"in c&&c.code==="EADDRINUSE")return o(new f(r,"server"));console.error(c)}),await s,me(r,i)}function me(t,e){return{async close(){e&&await Promise.allSettled([tt(e.close.bind(e))(),y.stopAll()])},port:t,url:`http://localhost:${t}`}}async function at(t,e,r){let{debug:n}=r,o=new pe,s=await nt.getPlatformInfo();return n&&console.debug("platform info: %s",JSON.stringify(s)),n&&o.use("*",ot()),o.use("*",async(a,i)=>(a.set("db",e),a.set("debug",!!n),a.set("platform",s),a.set("port",t),a.set("protocol","http"),a.set("serverState",r),await i())),o.route("/",P),o}var P=new pe;P.get("/health",t=>t.json({name:t.get("serverState").name}));P.post("/invalidate",S("header",p),async t=>{let e=await K(t);return e instanceof Response?e:t.body(null)});var it="/:clientVersion/:schemaHash",v=P.basePath(it);P.route("/",v);var ct=["/graphql","/itx/:transactionId/graphql"];v.on("POST",[...ct],S("header",p),async t=>{let{req:e}=t;try{let r=await B(t);if(r instanceof Response)return r;let n=await e.text(),o=e.param("transactionId"),s=await r.request(n,{...O(t),"X-transaction-id":o});return t.text(s)}catch(r){return T(r,t)}});v.basePath("/itx/:transactionId").on("POST",["/commit","/rollback"],S("header",p),async t=>{let{req:e}=t;try{let r=await B(t);if(r instanceof Response)return r;let o=`${e.routePath.split("/").filter(Boolean).at(-1)}Transaction`,s=e.param("transactionId"),a=await r[o](s,O(t));return t.json(a)}catch(r){return T(r,t)}});v.put("/schema",S("header",p),async t=>{let{req:e}=t,r=await e.text();if(!r)return t.text("Missing schema",400);let n=e.param("schemaHash"),o=R.get(n);if(o==null){if(n!==await H(r))return t.text("Schema hash mismatch",400);let s=await oe(r,t.get("db").connectionString);return R.set(n,{base64Original:r,...s}),t.text(n)}return r!==o.base64Original?t.text("Schema mismatch",400):t.text(n)});v.post("/transaction/start",S("header",p),async t=>{let{req:e}=t,r=await ue(t);if(r instanceof Response)return r;try{let n=await B(t);if(n instanceof Response)return n;let o=await n.startTransaction(r,O(t)),s=le(o,t);if(s instanceof Response)return s;let{id:a}=s,i=e.param("clientVersion"),c=t.get("port"),l=t.get("protocol"),b=e.param("schemaHash");return t.json({...o,"data-proxy":{endpoint:`${l}://localhost:${c}/${i}/${b}/itx/${a}`}})}catch(n){return T(n,t)}});async function B(t){let{req:e}=t,r=ne(t);if(r instanceof Response)return r;let{base64Override:n,overrideHash:o}=r.schemas;return await y.get({base64Schema:n,clientVersion:st.env.PRISMA_DEV_FORCE_CLIENT_VERSION||e.param("clientVersion"),debug:t.get("debug"),platform:t.get("platform"),schemaHash:o})}import{PGlite as dt}from"@electric-sql/pglite";import{PGLiteSocketServer as ut}from"@electric-sql/pglite-socket";import{pgDump as lt}from"@electric-sql/pglite-tools/pg_dump";var d={connectionLimit:1,connectTimeout:0,database:"postgres",maxIdleConnectionLifetime:0,password:"postgres",poolTimeout:0,socketTimeout:0,sslMode:"disable",username:"postgres"},mt=`postgres://${d.username}:${d.password}@localhost`,pt=new URLSearchParams({connection_limit:String(d.connectionLimit),connect_timeout:String(d.connectTimeout),max_idle_connection_lifetime:String(d.maxIdleConnectionLifetime),pool_timeout:String(d.poolTimeout),socket_timeout:String(d.socketTimeout),sslmode:d.sslMode});async function C(t,e){let r=t==="database"?e.databasePort:e.shadowDatabasePort;if(e.dryRun)return fe(t,e,{db:null,port:r,server:null});let{debug:n}=e,o=await dt.create({database:d.database,dataDir:"memory://",debug:n?5:void 0,defaultDataTransferContainer:"file",username:d.username});await o.waitReady,t==="database"&&await gt(o,e);let s=new ut({db:o,inspect:n,port:r});try{await s.start()}catch(a){throw a instanceof Error&&"code"in a&&a.code==="EADDRINUSE"?new f(r,t):a}return fe(t,e,{db:o,port:r,server:s})}function fe(t,e,r){let{debug:n}=e,{db:o,port:s,server:a}=r||{};return n&&console.debug(`${t} server started on port ${s}`),{...d,close:async()=>{let i=[];try{await a?.stop(),n&&console.debug(`${t} server stopped on port ${s}`)}catch(c){console.error("server stop error",c),i.push(c)}if(t==="database")try{await ft(o,e),n&&console.debug(`${t} state saved`)}catch(c){console.error("dump error",c),i.push(c)}try{await o?.close(),n&&console.debug(`${t} closed`)}catch(c){console.error("db close error",c),i.push(c)}if(i.length>0)throw new AggregateError(i,`Failed to close ${t} properly`)},connectionString:ht(s),port:s}}async function gt(t,e){let r=await e.readDatabaseDump();r&&(await t.exec(`${r}; set search_path to public;`),e.debug&&console.debug("successfully loaded database state from a dump file"))}async function ft(t,e){await e.writeDatabaseDump(()=>lt({args:[],pg:t}))}function ht(t){return`${mt}:${t}/${d.database}?${pt.toString()}`}import{copyFile as bt,mkdir as yt,writeFile as wt}from"fs/promises";import{join as L}from"pathe";import{lock as St}from"proper-lockfile";import{read as Pt}from"read-last-lines";import{process as vt}from"std-env";var j=Symbol("initialize"),h=class{databasePort;debug;dryRun;name;persistenceMode;port;shadowDatabasePort;constructor(e){this.databasePort=e.databasePort??51214,this.debug=e.debug??!1,this.dryRun=e.dryRun??!1,this.name=e.name??"default",this.persistenceMode=e.persistenceMode,this.port=e.port??51213,this.shadowDatabasePort=e.shadowDatabasePort??51215}static async get(e){let r=e?.dryRun!==!0&&e?.persistenceMode!=="stateless"?new F(e):new M(e);return await r[j](),r}},M=class extends h{constructor(e){super({...e,persistenceMode:"stateless"})}async[j](){}async close(){}readDatabaseDump(){return Promise.resolve(null)}async writeDatabaseDump(){}async writeServerDump(){}},F=class extends h{#r;#e;#t;#s;#o=null;constructor(e){super({...e,persistenceMode:"stateful"}),this.#r=J(this.name),this.#e=L(this.#r,"ppg.sql"),this.#t=`${this.#e}.bak`,this.#s=L(this.#r,"server.json")}async[j](){await yt(this.#r,{recursive:!0}),this.debug&&console.debug(`using data directory: ${this.#r}`);try{this.#o=await St(this.#r,{lockfilePath:L(this.#r,".lock")}),this.debug&&console.debug(`obtained lock on: ${this.#r}`),await this.writeServerDump()}catch(e){throw e instanceof Error&&"code"in e&&e.code==="ELOCKED"?new Error(`A server with the name "${this.name}" is already running. `):e}}async close(){this.#o!=null&&(await this.#o(),this.debug&&console.debug(`released lock on: ${this.#r}`))}async readDatabaseDump(){let[e,r]=await Promise.all([I(this.#e),I(this.#t)]),n=Number.isFinite(e)?this.#e:null,o=Number.isFinite(r)?this.#t:null,s=(e>=r?[n,o]:[o,n]).filter(Boolean);for(let a of s){if(!await this.#a(a)){this.debug&&console.debug(`database dump not completed at: ${a}`);continue}let i=await Y(a);if(!i){this.debug&&console.debug(`database dump no longer available at: ${a}`);continue}if(!this.#n(i)){this.debug&&console.debug(`database dump no longer completed at: ${a}`);continue}return this.debug&&console.debug(`using database dump from: ${a}`),i}return this.debug&&console.debug("no completed database dumps found"),null}async writeDatabaseDump(e){let r=!1;await this.#a(this.#e)&&(await bt(this.#e,this.#t),r=!0,this.debug&&console.debug(`backed up dump to: ${this.#t}`));let n=await e();if(await W(n,this.#e),this.debug&&console.debug(`dumped database to: ${this.#e}`),!r)return;let o=await X(this.#t);this.debug&&o&&console.debug(`deleted backup dump: ${this.#t}`)}async writeServerDump(e){await wt(this.#s,`${JSON.stringify({name:this.name,version:"1",pid:vt.pid,port:this.port,databasePort:this.databasePort,shadowDatabasePort:this.shadowDatabasePort,exports:e},null,2)}
|
|
8
|
+
`,{encoding:"utf-8"})}async#a(e){if(!await D(e))return!1;let r=await Pt(e,5,"utf-8");return this.debug&&console.debug(`last lines of checked dump: ${r}`),this.#n(r)}#n(e){return e.includes("-- PostgreSQL database dump complete")}};async function $r(t){let e=await h.get(t),[r,n]=await Promise.all([C("database",e),C("shadow_database",e)]),o=await ge(r,e),s=`prisma+postgres://localhost:${o.port}/?${new URLSearchParams({api_key:V({databaseUrl:r.connectionString,shadowDatabaseUrl:n.connectionString})}).toString()}`,a={accelerate:{url:o.url},database:{connectionString:r.connectionString},ppg:{url:s},shadowDatabase:{connectionString:n.connectionString}};return await e.writeServerDump(a),{...a,close:()=>i(e,[o,r,n])};async function i(c,l){let m=(await Promise.allSettled(l.map(u=>u.close()))).filter(u=>u.status==="rejected").map(u=>new Error(u.reason));try{await c.close()}catch(u){m.push(u)}if(m.length>0)throw new AggregateError(m,"Failed to close some servers")}}export{Z as DEFAULT_DATABASE_PORT,ee as DEFAULT_SERVER_PORT,te as DEFAULT_SHADOW_DATABASE_PORT,f as PortNotAvailableError,$r as unstable_startServer};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/dev",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.202505221907",
|
|
4
4
|
"description": "A local Prisma Postgres server for development and testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,19 +30,25 @@
|
|
|
30
30
|
"@arethetypeswrong/cli": "0.17.4",
|
|
31
31
|
"@types/node": "22.3.0",
|
|
32
32
|
"@types/pako": "2.0.3",
|
|
33
|
+
"@types/proper-lockfile": "4.1.4",
|
|
33
34
|
"pkg-types": "2.1.0",
|
|
34
35
|
"tsup": "8.0.2",
|
|
35
36
|
"typescript": "5.8.3",
|
|
36
37
|
"vitest": "3.1.3"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@electric-sql/pglite": "0.3.
|
|
40
|
-
"@electric-sql/pglite-socket": "0.0.
|
|
40
|
+
"@electric-sql/pglite": "0.3.2",
|
|
41
|
+
"@electric-sql/pglite-socket": "0.0.6",
|
|
42
|
+
"@electric-sql/pglite-tools": "0.2.7",
|
|
41
43
|
"@hono/node-server": "1.14.1",
|
|
42
44
|
"@prisma/get-platform": "6.7.0",
|
|
43
45
|
"env-paths": "3.0.0",
|
|
44
46
|
"hono": "4.7.8",
|
|
45
47
|
"pako": "2.1.0",
|
|
48
|
+
"pathe": "2.0.3",
|
|
49
|
+
"proper-lockfile": "4.1.2",
|
|
50
|
+
"read-last-lines": "1.8.0",
|
|
51
|
+
"std-env": "3.8.1",
|
|
46
52
|
"valibot": "1.1.0"
|
|
47
53
|
},
|
|
48
54
|
"scripts": {
|