@prisma/dev 0.20.0 → 0.22.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/{accelerate-EEKAFGN3.js → accelerate-HABH6RJU.js} +1 -1
- package/dist/{chunk-7NDL3ECU.js → chunk-6ORCLJD5.js} +1 -1
- package/dist/chunk-DZGCLGSX.js +84 -0
- package/dist/{chunk-LKYVOPH3.js → chunk-FIY24ARL.js} +1 -1
- package/dist/chunk-UZK2DL6R.js +1 -0
- package/dist/daemon.cjs +88 -5
- package/dist/daemon.d.cts +3 -2
- package/dist/daemon.d.ts +3 -2
- package/dist/daemon.js +1 -1
- package/dist/db.cjs +84 -1
- package/dist/db.d.cts +31 -1
- package/dist/db.d.ts +31 -1
- package/dist/db.js +1 -1
- package/dist/index.cjs +88 -5
- package/dist/index.d.cts +54 -9
- package/dist/index.d.ts +54 -9
- package/dist/index.js +1 -1
- package/dist/state.d.cts +7 -9
- package/dist/state.d.ts +7 -9
- package/dist/state.js +1 -1
- package/package.json +7 -5
- package/dist/chunk-RJ42AYBU.js +0 -1
- package/dist/chunk-XMKRRRGB.js +0 -1
- /package/dist/{chunk-ITQ6ILGR.js → chunk-DGKV2DPF.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,55 @@
|
|
|
1
1
|
import { Exports, ServerOptions } from './state.js';
|
|
2
2
|
export { ServerAlreadyRunningError } from './state.js';
|
|
3
|
-
import { DBServerPurpose } from './db.js';
|
|
3
|
+
import { WalEvent, DBServerPurpose } from './db.js';
|
|
4
4
|
import 'valibot';
|
|
5
5
|
import '@electric-sql/pglite';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A readonly batch of WAL events emitted together.
|
|
9
|
+
*
|
|
10
|
+
* @experimental This API may change without notice.
|
|
11
|
+
*/
|
|
12
|
+
type ExperimentalWalEventBatch = readonly WalEvent[];
|
|
13
|
+
/**
|
|
14
|
+
* Callback invoked when a batch of WAL events is available.
|
|
15
|
+
*
|
|
16
|
+
* @experimental This API may change without notice.
|
|
17
|
+
*/
|
|
18
|
+
type ExperimentalWalEventCallback = (events: ExperimentalWalEventBatch) => void;
|
|
19
|
+
/**
|
|
20
|
+
* The experimental public WAL event API returned from `startPrismaDevServer()`.
|
|
21
|
+
*
|
|
22
|
+
* @experimental This API may change without notice.
|
|
23
|
+
*/
|
|
24
|
+
interface ExperimentalWalEvents {
|
|
25
|
+
/**
|
|
26
|
+
* Subscribe to WAL event batches. The returned function unsubscribes the callback.
|
|
27
|
+
*/
|
|
28
|
+
subscribe(callback: ExperimentalWalEventCallback): () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Create an async iterator that yields WAL event batches as they arrive.
|
|
31
|
+
*/
|
|
32
|
+
stream(): AsyncIterableIterator<ExperimentalWalEventBatch>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Experimental capabilities exposed on the public programmatic server.
|
|
36
|
+
*
|
|
37
|
+
* @experimental This API may change without notice.
|
|
38
|
+
*/
|
|
39
|
+
interface ExperimentalServerFeatures {
|
|
40
|
+
readonly wal: ExperimentalWalEvents;
|
|
41
|
+
}
|
|
42
|
+
interface ProgrammaticServer extends Exports {
|
|
43
|
+
close(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Experimental capabilities that may change without notice.
|
|
46
|
+
*
|
|
47
|
+
* @experimental
|
|
48
|
+
*/
|
|
49
|
+
experimental: ExperimentalServerFeatures;
|
|
50
|
+
name: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
7
53
|
declare const DEFAULT_DATABASE_PORT = 51214;
|
|
8
54
|
declare const DEFAULT_SERVER_PORT = 51213;
|
|
9
55
|
declare const DEFAULT_SHADOW_DATABASE_PORT = 51215;
|
|
@@ -14,20 +60,19 @@ declare class PortNotAvailableError extends Error {
|
|
|
14
60
|
constructor(port: number);
|
|
15
61
|
}
|
|
16
62
|
|
|
17
|
-
|
|
18
|
-
close(): Promise<void>;
|
|
19
|
-
name: string;
|
|
20
|
-
}
|
|
21
|
-
type ReadonlyServer = Omit<Server, "close">;
|
|
63
|
+
type ReadonlyServer = Omit<ProgrammaticServer, "close">;
|
|
22
64
|
/**
|
|
23
65
|
* Starts a `prisma dev` server instance programmatically.
|
|
24
66
|
*
|
|
25
67
|
* DO NOT USE IN PRODUCTION. This is only intended for development and testing purposes.
|
|
68
|
+
*
|
|
69
|
+
* The returned server also includes experimental capabilities under `server.experimental`,
|
|
70
|
+
* including WAL event subscriptions at `server.experimental.wal`.
|
|
26
71
|
*/
|
|
27
|
-
declare function startPrismaDevServer(options?: ServerOptions): Promise<
|
|
72
|
+
declare function startPrismaDevServer(options?: ServerOptions): Promise<ProgrammaticServer>;
|
|
28
73
|
/**
|
|
29
74
|
* @deprecated use {@link startPrismaDevServer} instead.
|
|
30
75
|
*/
|
|
31
|
-
declare function unstable_startServer(options?: ServerOptions): Promise<
|
|
76
|
+
declare function unstable_startServer(options?: ServerOptions): Promise<ProgrammaticServer>;
|
|
32
77
|
|
|
33
|
-
export { DEFAULT_DATABASE_PORT, DEFAULT_SERVER_PORT, DEFAULT_SHADOW_DATABASE_PORT, type PortAssignableService, PortNotAvailableError, type ReadonlyServer, type Server, ServerOptions, startPrismaDevServer, unstable_startServer };
|
|
78
|
+
export { DEFAULT_DATABASE_PORT, DEFAULT_SERVER_PORT, DEFAULT_SHADOW_DATABASE_PORT, type ExperimentalServerFeatures, WalEvent as ExperimentalWalEvent, type ExperimentalWalEventBatch, type ExperimentalWalEvents, type PortAssignableService, PortNotAvailableError, type ReadonlyServer, type ProgrammaticServer as Server, ServerOptions, startPrismaDevServer, unstable_startServer };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f,b as g}from"./chunk-
|
|
1
|
+
import{a as f,b as g}from"./chunk-UZK2DL6R.js";import"./chunk-DZGCLGSX.js";import{g as e}from"./chunk-FIY24ARL.js";import{a,b,c,g as d}from"./chunk-OTI5SWIV.js";import"./chunk-6ORCLJD5.js";import"./chunk-DGKV2DPF.js";export{a as DEFAULT_DATABASE_PORT,b as DEFAULT_SERVER_PORT,c as DEFAULT_SHADOW_DATABASE_PORT,d as PortNotAvailableError,e as ServerAlreadyRunningError,f as startPrismaDevServer,g as unstable_startServer};
|
package/dist/state.d.cts
CHANGED
|
@@ -51,21 +51,19 @@ interface ServerOptions {
|
|
|
51
51
|
/**
|
|
52
52
|
* Connection timeout in milliseconds for pending database connections.
|
|
53
53
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
54
|
+
* This option is currently not enforced by the multiplexed
|
|
55
|
+
* `@electric-sql/pglite-socket` server used by `@prisma/dev`.
|
|
56
|
+
* It is kept for API compatibility until upstream exposes a queue-timeout
|
|
57
|
+
* equivalent again.
|
|
56
58
|
*
|
|
57
59
|
* Default is 1 minute (60,000 milliseconds).
|
|
58
|
-
*
|
|
59
|
-
* Use it with caution, as it may lead to unexpected behavior. Best used with
|
|
60
|
-
* a pool client that retries connections.
|
|
61
60
|
*/
|
|
62
61
|
databaseConnectTimeoutMillis?: number;
|
|
63
62
|
/**
|
|
64
|
-
* Idle timeout in milliseconds for
|
|
63
|
+
* Idle timeout in milliseconds for open database connections.
|
|
65
64
|
*
|
|
66
|
-
* Re-starts ticking after each message received on
|
|
67
|
-
*
|
|
68
|
-
* client connection is closed, and a pending connection is promoted to active.
|
|
65
|
+
* Re-starts ticking after each message received on a connection. When exceeded,
|
|
66
|
+
* that client connection is closed by the socket server.
|
|
69
67
|
*
|
|
70
68
|
* Is not applied by default.
|
|
71
69
|
*
|
package/dist/state.d.ts
CHANGED
|
@@ -51,21 +51,19 @@ interface ServerOptions {
|
|
|
51
51
|
/**
|
|
52
52
|
* Connection timeout in milliseconds for pending database connections.
|
|
53
53
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
54
|
+
* This option is currently not enforced by the multiplexed
|
|
55
|
+
* `@electric-sql/pglite-socket` server used by `@prisma/dev`.
|
|
56
|
+
* It is kept for API compatibility until upstream exposes a queue-timeout
|
|
57
|
+
* equivalent again.
|
|
56
58
|
*
|
|
57
59
|
* Default is 1 minute (60,000 milliseconds).
|
|
58
|
-
*
|
|
59
|
-
* Use it with caution, as it may lead to unexpected behavior. Best used with
|
|
60
|
-
* a pool client that retries connections.
|
|
61
60
|
*/
|
|
62
61
|
databaseConnectTimeoutMillis?: number;
|
|
63
62
|
/**
|
|
64
|
-
* Idle timeout in milliseconds for
|
|
63
|
+
* Idle timeout in milliseconds for open database connections.
|
|
65
64
|
*
|
|
66
|
-
* Re-starts ticking after each message received on
|
|
67
|
-
*
|
|
68
|
-
* client connection is closed, and a pending connection is promoted to active.
|
|
65
|
+
* Re-starts ticking after each message received on a connection. When exceeded,
|
|
66
|
+
* that client connection is closed by the socket server.
|
|
69
67
|
*
|
|
70
68
|
* Is not applied by default.
|
|
71
69
|
*
|
package/dist/state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g}from"./chunk-FIY24ARL.js";import"./chunk-OTI5SWIV.js";import"./chunk-DGKV2DPF.js";export{g as ServerAlreadyRunningError,a as ServerState,f as ServerStateAlreadyExistsError,b as deleteServer,c as getServerStatus,d as isServerRunning,e as killServer};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/dev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "A local Prisma Postgres server for development and testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Igal Klebanov <igalklebanov@gmail.com> (https://github.com/igalklebanov)",
|
|
@@ -66,8 +66,10 @@
|
|
|
66
66
|
"@arethetypeswrong/cli": "0.18.2",
|
|
67
67
|
"@types/node": "25.0.9",
|
|
68
68
|
"@types/pako": "2.0.4",
|
|
69
|
+
"@types/pg": "8.15.6",
|
|
69
70
|
"@types/proper-lockfile": "4.1.4",
|
|
70
71
|
"env-paths": "3.0.0",
|
|
72
|
+
"pg": "8.16.0",
|
|
71
73
|
"pkg-types": "2.3.0",
|
|
72
74
|
"tsup": "8.5.1",
|
|
73
75
|
"typescript": "5.9.3",
|
|
@@ -75,9 +77,9 @@
|
|
|
75
77
|
"common-stuff": "^0.0.0"
|
|
76
78
|
},
|
|
77
79
|
"dependencies": {
|
|
78
|
-
"@electric-sql/pglite": "0.3.
|
|
79
|
-
"@electric-sql/pglite-socket": "0.0.
|
|
80
|
-
"@electric-sql/pglite-tools": "0.2.
|
|
80
|
+
"@electric-sql/pglite": "0.3.16",
|
|
81
|
+
"@electric-sql/pglite-socket": "0.0.22",
|
|
82
|
+
"@electric-sql/pglite-tools": "0.2.21",
|
|
81
83
|
"@hono/node-server": "1.19.9",
|
|
82
84
|
"@mrleebo/prisma-ast": "0.13.1",
|
|
83
85
|
"@prisma/get-platform": "7.2.0",
|
|
@@ -98,7 +100,7 @@
|
|
|
98
100
|
"check:exports": "attw . --pack --profile node16",
|
|
99
101
|
"dev": "tsup --watch",
|
|
100
102
|
"lint": "eslint --fix .",
|
|
101
|
-
"test": "",
|
|
103
|
+
"test": "vitest run",
|
|
102
104
|
"typecheck": "tsc --noEmit"
|
|
103
105
|
}
|
|
104
106
|
}
|
package/dist/chunk-RJ42AYBU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as d}from"./chunk-XMKRRRGB.js";import{a as P}from"./chunk-LKYVOPH3.js";import{g as u}from"./chunk-OTI5SWIV.js";import{a as f,c as v,d as g}from"./chunk-7NDL3ECU.js";import{createServer as A}from"http";import{promisify as R}from"util";import T from"@prisma/get-platform";async function y(o,e){let{port:r}=e;if(e.dryRun)return w(r,null);let n=await D(o,e),{promise:m,reject:l,resolve:a}=v(),{serve:c}=await import("@hono/node-server"),i=c({createServer:A,fetch:n.fetch,overrideGlobalObjects:!1,port:r},a);i.on("error",s=>{if(typeof s=="object"&&"code"in s&&s.code==="EADDRINUSE")return l(new u(r));console.error("[Accelerate]",s)});let{port:t}=await m;return e.port=t,w(t,i)}function w(o,e){return{async close(){e&&await Promise.allSettled([R(e.close.bind(e))(),g.stopAll()])},port:o,url:`http://localhost:${o}`}}async function D(o,e){let{debug:r}=e,[{Hono:n},{accelerateRoute:m},{utilityRoute:l}]=await Promise.all([import("hono/tiny"),import("./accelerate-EEKAFGN3.js"),import("./utility-Q5A254LJ.js")]),a=new n,c=await T.getPlatformInfo();if(r&&console.debug("[Accelerate] platform info: %s",JSON.stringify(c)),r){let{logger:t}=await import("hono/logger");a.use("*",t((...s)=>console.log("[Accelerate]",...s)))}a.use("*",async(t,s)=>(t.set("databaseDumpPath",e.databaseDumpPath),t.set("db",o),t.set("debug",!!r),t.set("name",e.name),t.set("platform",c),t.set("shadowDBPort",e.shadowDatabasePort),await s()));let i=new n;return i.route("/",m),i.route("/",l),a.route("/",i),a}async function E(o){let e=await P.createExclusively(o),[r,n]=await Promise.all([d("database",e),d("shadow_database",e)]),m=await y(r,e),l=`prisma+postgres://localhost:${m.port}/?${new URLSearchParams({api_key:f({databaseUrl:r.prismaORMConnectionString,name:e.name,shadowDatabaseUrl:n.prismaORMConnectionString})}).toString()}`,a={database:{connectionString:r.connectionString,prismaORMConnectionString:r.prismaORMConnectionString,terminalCommand:r.terminalCommand},http:{url:m.url},ppg:{url:l},shadowDatabase:{connectionString:n.prismaORMConnectionString,prismaORMConnectionString:n.prismaORMConnectionString,terminalCommand:n.terminalCommand}};return await e.writeServerDump(a),{...a,close:()=>c(e,[m,r,n]),name:e.name};async function c(i,t){let S=(await Promise.allSettled(t.map(p=>p.close()))).filter(p=>p.status==="rejected").map(p=>new Error(p.reason));try{await i.close()}catch(p){S.push(p)}if(S.length>0)throw new AggregateError(S,"Failed to close some servers")}}async function J(o){return await E(o)}export{E as a,J as b};
|
package/dist/chunk-XMKRRRGB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as b}from"./chunk-OTI5SWIV.js";import{e as g}from"./chunk-ITQ6ILGR.js";import{filename as S}from"pathe/utils";var o={connectionLimit:1,connectTimeout:0,database:"template1",maxIdleConnectionLifetime:0,password:"postgres",poolTimeout:0,socketTimeout:0,sslMode:"disable",username:"postgres"},h=`postgres://${o.username}:${o.password}@localhost`,y=new URLSearchParams({sslmode:o.sslMode}),T=new URLSearchParams({...Object.fromEntries(y.entries()),connection_limit:String(o.connectionLimit),connect_timeout:String(o.connectTimeout),max_idle_connection_lifetime:String(o.maxIdleConnectionLifetime),pool_timeout:String(o.poolTimeout),single_use_connections:"true",socket_timeout:String(o.socketTimeout)});async function x(e,t){let r=e==="database"?t.databasePort:t.shadowDatabasePort;if(t.dryRun)return f(e,t,{db:null,port:r,server:null});let{debug:n}=t,a=await(e==="shadow_database"?v:_)(t.pgliteDataDirPath,n);n&&a.onNotification((d,l)=>{console.debug(`[${e}][${d}] ${l}`)});let{PGLiteSocketHandler:m,PGLiteSocketServer:s}=await import("@electric-sql/pglite-socket"),c=e==="shadow_database"?t.shadowDatabaseIdleTimeoutMillis:t.databaseIdleTimeoutMillis;E(c,a,m);let u=new s({connectionQueueTimeout:e==="shadow_database"?t.shadowDatabaseConnectTimeoutMillis:t.databaseConnectTimeoutMillis,db:a,debug:n,inspect:n,port:r});n&&(u.addEventListener("listening",d=>{let{detail:l}=d;console.debug(`[${e}] server listening on ${JSON.stringify(l)}`)}),u.addEventListener("connection",d=>{let{clientAddress:l,clientPort:P}=d.detail;console.debug(`[${e}] client connected from ${l}:${P}`)}),u.addEventListener("error",d=>{let{detail:l}=d;console.error(`[${e}] server error:`,l)}));try{await u.start()}catch(d){throw d instanceof Error&&"code"in d&&d.code==="EADDRINUSE"?new b(r):d}let p=Number(u.getServerConn().split(":").at(1));return t[e==="database"?"databasePort":"shadowDatabasePort"]=p,f(e,t,{db:a,port:p,server:u})}function f(e,t,r){let{debug:n}=t,{db:i,port:a,server:m}=r||{};return n&&console.debug(`[${e}] server started on port ${a}`),{...o,close:async()=>{let s=[];try{await m?.stop(),n&&console.debug(`[${e}] server stopped on port ${a}`)}catch(c){console.error(`[${e}] server stop error`,c),s.push(c)}if(e==="database")try{await i?.syncToFs(),n&&console.debug(`[${e}] synced to filesystem`)}catch(c){console.error(`[${e}] sync error`,c),s.push(c)}try{await i?.close(),n&&console.debug(`[${e}] closed`)}catch(c){console.error(`[${e}] close error`,c),s.push(c)}if(s.length>0)throw new AggregateError(s,`Failed to close ${e} properly`)},connectionString:D(a,y),dump:async s=>{e==="shadow_database"||!i||await $({db:i,debug:n,destinationPath:s})},port:a,prismaORMConnectionString:D(a,T),terminalCommand:`PGPASSWORD=${o.password} PGSSLMODE=${o.sslMode} psql -h localhost -p ${a} -U ${o.username} -d ${o.database}`}}function D(e,t){return`${h}:${e}/${o.database}?${t.toString()}`}async function _(e,t){let{PGlite:r}=await import("@electric-sql/pglite");return await r.create({database:o.database,dataDir:e,debug:t?5:void 0,extensions:await w(),relaxedDurability:!1,username:o.username})}async function v(e,t){let{PGlite:r}=await import("@electric-sql/pglite");return await r.create({database:o.database,dataDir:"memory://",debug:t?5:void 0,extensions:await w(),relaxedDurability:!1,username:o.username})}async function w(){let e=await Promise.all([import("@electric-sql/pglite/contrib/amcheck"),import("@electric-sql/pglite/contrib/bloom"),import("@electric-sql/pglite/contrib/btree_gin"),import("@electric-sql/pglite/contrib/btree_gist"),import("@electric-sql/pglite/contrib/citext"),import("@electric-sql/pglite/contrib/cube"),import("@electric-sql/pglite/contrib/dict_int"),import("@electric-sql/pglite/contrib/dict_xsyn"),import("@electric-sql/pglite/contrib/earthdistance"),import("@electric-sql/pglite/contrib/file_fdw"),import("@electric-sql/pglite/contrib/fuzzystrmatch"),import("@electric-sql/pglite/contrib/hstore"),import("@electric-sql/pglite/contrib/intarray"),import("@electric-sql/pglite/contrib/isn"),import("@electric-sql/pglite/contrib/lo"),import("@electric-sql/pglite/contrib/ltree"),import("@electric-sql/pglite/contrib/pageinspect"),import("@electric-sql/pglite/contrib/pg_buffercache"),import("@electric-sql/pglite/contrib/pg_freespacemap"),import("@electric-sql/pglite/contrib/pg_surgery"),import("@electric-sql/pglite/contrib/pg_trgm"),import("@electric-sql/pglite/contrib/pg_visibility"),import("@electric-sql/pglite/contrib/pg_walinspect"),import("@electric-sql/pglite/contrib/seg"),import("@electric-sql/pglite/contrib/tablefunc"),import("@electric-sql/pglite/contrib/tcn"),import("@electric-sql/pglite/contrib/tsm_system_rows"),import("@electric-sql/pglite/contrib/tsm_system_time"),import("@electric-sql/pglite/contrib/unaccent"),import("@electric-sql/pglite/contrib/uuid_ossp"),import("@electric-sql/pglite/vector")]);return Object.assign({},...e)}function E(e,t,r){if(t.__IDLE_TIMEOUT__=e,r.prototype.__ATTACH_OVERRIDDEN__)return;r.prototype.__ATTACH_OVERRIDDEN__=!0;let n=r.prototype.attach;r.prototype.attach=async function(i){let a=await n.call(this,i);if(!Number.isFinite(this.db.__IDLE_TIMEOUT__))return a;let m=null,s=()=>{m!=null&&(clearTimeout(m),m=null)},c=()=>{s(),m=setTimeout(()=>{this.dispatchEvent(new CustomEvent("close")),this.detach(!1)},this.db.__IDLE_TIMEOUT__)};return i.on("error",()=>{s()}),i.on("data",()=>{c()}),i.on("close",()=>{s()}),c(),a}}async function $(e){let{dataDir:t,db:r,debug:n,destinationPath:i}=e,a=r||await _(t,n),{pgDump:m}=await import("@electric-sql/pglite-tools/pg_dump"),s=await m({args:["--schema-only","--no-owner"],fileName:i?S(i):void 0,pg:await a.clone()});return i?(n&&console.debug(`[DB] Dumping database to ${i}`),await g(s,i)):(n&&console.debug("[DB] Dumping database to memory"),await s.text())}export{x as a,$ as b};
|
|
File without changes
|