@prisma/dev 0.4.0 → 0.5.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/chunk-CLIITWV6.js +2 -0
- package/dist/chunk-KSRPCQJC.js +2 -0
- package/dist/chunk-WHX3423Q.js +4 -0
- package/dist/daemon/client.d.ts +3 -1
- package/dist/db-9fHowc0q.d.ts +192 -0
- package/dist/db.d.ts +3 -0
- package/dist/db.js +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -5
- package/dist/state.d.ts +3 -0
- package/dist/state.js +2 -0
- package/package.json +12 -1
- package/dist/index-CW1pktRs.d.ts +0 -83
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{e as l,l as m}from"./chunk-KSRPCQJC.js";import{PGlite as g}from"@electric-sql/pglite";import{PGLiteSocketServer as D}from"@electric-sql/pglite-socket";import{pgDump as y}from"@electric-sql/pglite-tools/pg_dump";import{filename as w}from"pathe/utils";var a={connectionLimit:1,connectTimeout:0,database:"template1",maxIdleConnectionLifetime:0,password:"postgres",poolTimeout:0,socketTimeout:0,sslMode:"disable",username:"postgres"},P=`postgres://${a.username}:${a.password}@localhost`,S=new URLSearchParams({connection_limit:String(a.connectionLimit),connect_timeout:String(a.connectTimeout),max_idle_connection_lifetime:String(a.maxIdleConnectionLifetime),pool_timeout:String(a.poolTimeout),socket_timeout:String(a.socketTimeout),sslmode:a.sslMode});async function k(e,r){let c=e==="database"?r.databasePort:r.shadowDatabasePort;if(r.dryRun)return u(e,r,{db:null,port:c,server:null});let{debug:o}=r,s=await(e==="shadow_database"?p:b)(r.pgliteDataDirPath,o);o&&s.onNotification((t,n)=>{console.debug(`[${e}][${t}] ${n}`)});let d=new D({db:s,debug:o,inspect:o,port:c});o&&(d.addEventListener("listening",t=>{let{detail:n}=t;console.debug(`[${e}] server listening on ${JSON.stringify(n)}`)}),d.addEventListener("connection",t=>{let{clientAddress:n,clientPort:f}=t.detail;console.debug(`[${e}] client connected from ${n}:${f}`)}),d.addEventListener("error",t=>{let{detail:n}=t;console.error(`[${e}] server error:`,n)}));try{await d.start()}catch(t){throw t instanceof Error&&"code"in t&&t.code==="EADDRINUSE"?new m(c,e):t}return u(e,r,{db:s,port:c,server:d})}function u(e,r,c){let{debug:o}=r,{db:i,port:s,server:d}=c||{};return o&&console.debug(`[${e}] server started on port ${s}`),{...a,close:async()=>{let t=[];try{await d?.stop(),o&&console.debug(`[${e}] server stopped on port ${s}`)}catch(n){console.error(`[${e}] server stop error`,n),t.push(n)}if(e==="database")try{await i?.syncToFs(),o&&console.debug(`[${e}] synced to filesystem`)}catch(n){console.error(`[${e}] sync error`,n),t.push(n)}try{await i?.close(),o&&console.debug(`[${e}] closed`)}catch(n){console.error(`[${e}] close error`,n),t.push(n)}if(t.length>0)throw new AggregateError(t,`Failed to close ${e} properly`)},connectionString:v(s),dump:async t=>{e==="shadow_database"||!i||await $({db:i,debug:o,destinationPath:t})},port:s}}function v(e){return`${P}:${e}/${a.database}?${S.toString()}`}async function b(e,r){return await g.create({database:a.database,dataDir:e,debug:r?5:void 0,defaultDataTransferContainer:"file",relaxedDurability:!1,username:a.username})}async function p(e,r){return await g.create({database:a.database,dataDir:"memory://",debug:r?5:void 0,defaultDataTransferContainer:"file",relaxedDurability:!1,username:a.username})}async function $(e){let{dataDir:r,db:c,debug:o,destinationPath:i}=e,s=c||await b(r,o),d=await y({args:["--quote-all-identifiers","--schema-only"],fileName:i?w(i):void 0,pg:s});return i?(o&&console.debug(`[DB] Dumping database to ${i}`),await l(d,i)):(o&&console.debug("[DB] Dumping database to memory"),await d.text())}export{k as a,$ as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{createWriteStream as a,WriteStream as c}from"fs";import{access as u,chmod as p,constants as m,mkdir as f,readdir as l,readFile as g,writeFile as d}from"fs/promises";import x from"env-paths";import{inflate as y}from"pako";var o=x("prisma-dev");function D(r,e){return`${o.cache}/engine/${r}/${e}`}function E(r){return`${o.data}/${r}`}async function w(r){try{return await u(r,m.F_OK),!0}catch(e){if(n(e))return!1;throw e}}async function v(r,e){let t=y(r);await d(e,t),await p(e,"755")}async function F(r,e){await r.stream().pipeTo(c.toWeb(a(e,{encoding:"utf-8"})))}function n(r){return r!=null&&typeof r=="object"&&"code"in r&&r.code==="ENOENT"}async function b(r){try{return await g(r,{encoding:"utf-8"})}catch(e){if(n(e))return null;throw e}}async function S(r){await f(r,{recursive:!0})}async function _(r){try{return(await l(r,{withFileTypes:!0})).reduce((t,i)=>(i.isDirectory()&&!i.name.startsWith(".")&&t.push(i.name),t),[])}catch(e){if(n(e))return[];throw e}}var B=51214,R=51213,$=51215,s=class extends Error{constructor(t,i){super(`Port number \`${t}\` is not available for service ${i}.`);this.port=t;this.service=i}name="PortNotAvailableError"};export{D as a,E as b,w as c,v as d,F as e,b as f,S as g,_ as h,B as i,R as j,$ as k,s as l};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as c,f as w,g as x,h as O,i as $,j as E,k as _}from"./chunk-KSRPCQJC.js";import{writeFile as J}from"fs/promises";import{hc as U}from"hono/client";import{join as u}from"pathe";import{check as j,lock as B}from"proper-lockfile";import{process as m}from"std-env";import{integer as I,literal as H,minLength as C,minValue as T,number as V,object as f,optional as R,parseJson as Y,pipe as l,safeParse as Z,string as D,url as q}from"valibot";import{process as F}from"std-env";function k(r,e){if(r==null)return!1;try{return F.kill?.(r,0)??!0}catch(t){return e&&console.error(`Error checking if process with PID ${r} exists:`,t),!1}}var N=l(D(),q()),A=f({connectionString:N}),M=f({url:N}),g=l(V(),I(),T(1)),z=f({database:A,http:M,ppg:M,shadowDatabase:A}),K=f({databasePort:g,exports:R(z),name:l(D(),C(1)),pid:R(l(V(),I(),T(0))),port:g,shadowDatabasePort:g,version:H("1")}),y=Symbol("initialize"),v="default",h=class{databasePort;debug;dryRun;name;persistenceMode;pid;port;shadowDatabasePort;constructor(e){this.databasePort=e.databasePort??51214,this.debug=e.debug??!1,this.dryRun=e.dryRun??!1,this.name=e.name??v,this.persistenceMode=e.persistenceMode,this.pid=e.pid??m.pid,this.port=e.port??51213,this.shadowDatabasePort=e.shadowDatabasePort??51215}static async createExclusively(e){let t=e?.dryRun!==!0&&e?.persistenceMode!=="stateless"?new p({...e,pid:m.pid}):new P(e);return await t[y](),t}static async fromServerDump(e){let{debug:t,name:s=v}=e??{},n=c(s),a=p.getServerDumpPath(n),i=await w(a);if(i==null)return t&&console.debug(`[State] No server dump file found at: ${a}`),null;t&&(console.debug(`[State] server dump file found at "${a}":`),console.debug(i));let{issues:b,output:o,success:d}=Z(l(D(),Y(),K),i);if(!d)throw t&&console.debug(`[State] Invalid server dump file at "${a}":
|
|
3
|
+
${JSON.stringify(b,null,2)}`),new Error(`Invalid Prisma Dev state for "${s}".`);return new p({databasePort:o.databasePort,debug:t,dryRun:!1,name:s,pid:o.pid,port:o.port,serverDump:o,shadowDatabasePort:o.shadowDatabasePort})}static async scan(e){let{debug:t}=e??{},s=u(c(v),"..");t&&console.debug(`[State] scanning for server states in: ${s}`);let n=await O(s);return t&&console.debug(`[State] found server names: ${JSON.stringify(n)}`),await Promise.all(n.map(a=>W(a,t)))}},P=class extends h{constructor(e){super({...e,persistenceMode:"stateless",pid:m.pid})}get databaseDumpPath(){return"<DUMP_PATH>"}get pgliteDataDirPath(){return"memory://"}async[y](){}async close(){}async writeServerDump(){}},p=class r extends h{#s;#e;#a;#o;#t;#r=null;constructor(e){super({...e,persistenceMode:"stateful"}),this.#e=c(this.name),this.#s=u(this.#e,"db_dump.bak"),this.#a=u(this.#e,".pglite"),this.#t=e.serverDump??null,this.#o=r.getServerDumpPath(this.#e)}static getServerDumpPath(e){return u(e,"server.json")}get databaseDumpPath(){return this.#s}get exports(){return this.#t?.exports}get pgliteDataDirPath(){return this.#a}async[y](){await x(this.#e),this.debug&&console.debug(`[State] using data directory: ${this.#e}`);try{this.#r=await B(this.#e,{lockfilePath:u(this.#e,".lock")}),this.debug&&console.debug(`[State] obtained lock on: ${this.#e}`),await this.writeServerDump()}catch(e){throw e instanceof Error&&"code"in e&&e.code==="ELOCKED"?new S(this.name):e}}async close(){if(this.#r!=null)try{await this.#r(),this.#r=null,this.debug&&console.debug(`[State] released lock on: ${this.#e}`)}catch(e){throw console.error(`[State] failed to release lock on: ${this.#e}`),e}}async writeServerDump(e){this.#t={name:this.name,version:"1",pid:m.pid,port:this.port,databasePort:this.databasePort,shadowDatabasePort:this.shadowDatabasePort,exports:e},await J(this.#o,`${JSON.stringify(this.#t,null,2)}
|
|
4
|
+
`,{encoding:"utf-8"})}};async function W(r,e){let t={databasePort:-1,exports:void 0,name:r,pid:void 0,port:-1,shadowDatabasePort:-1,version:"1"};try{let s=await h.fromServerDump({debug:e,name:r});if(!s)return e&&console.debug(`[State] no server state found for name: ${r}`),{...t,status:"no_such_server"};t.databasePort=s.databasePort,t.exports=s.exports,t.pid=s.pid,t.port=s.port,t.shadowDatabasePort=s.shadowDatabasePort;let{exports:n,pid:a}=s;if(!k(a,e))return e&&console.debug(`[State] server state for "${r}" has no running process with PID: ${a}`),{...t,status:"not_running"};let i=c(r);try{if(!await j(i,{lockfilePath:u(i,".lock")}))return e&&console.debug(`[State] server state for "${r}" is not locked, indicating it is not running.`),{...t,status:"starting_up"}}catch(L){e&&console.error(`[State] server state for "${r}" failed to check lock:`,L)}if(!n)return{...t,status:"starting_up"};let{http:b}=n,o=await U(b.url).health.$get();if(!o.ok)return e&&console.debug(`[State] server state for "${r}" is not live: ${JSON.stringify(o)}`),{...t,status:"not_running"};let d=await o.json();return d.name!==r?(e&&console.debug(`[State] server state for "${r}" has mismatched health response: ${JSON.stringify(d)}`),{...t,status:"unknown"}):(e&&console.debug(`[State] server state for "${r}" is live: ${JSON.stringify(d)}`),{...t,status:"running"})}catch(s){return e&&console.error(`[State] failed to get server status for "${r}":`,s),{...t,status:"error"}}}var S=class extends Error{name="ServerStateAlreadyExistsError";constructor(e){super(`A server with the name "${e}" is already running.`)}};export{h as a,S as b};
|
package/dist/daemon/client.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as url from 'url';
|
|
2
2
|
import { SockDaemonClient } from 'sock-daemon/client';
|
|
3
|
-
import { S as ServerOptions, a as Server } from '../
|
|
3
|
+
import { S as ServerOptions, a as Server } from '../db-9fHowc0q.js';
|
|
4
4
|
import { MessageBase } from 'sock-daemon/server';
|
|
5
|
+
import '@electric-sql/pglite';
|
|
6
|
+
import 'valibot';
|
|
5
7
|
|
|
6
8
|
type Kind = "START_SERVER" | "STOP_SERVER";
|
|
7
9
|
type RequestMessage = MessageBase & {
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { PGlite } from '@electric-sql/pglite';
|
|
2
|
+
import * as valibot from 'valibot';
|
|
3
|
+
import { InferOutput } from 'valibot';
|
|
4
|
+
|
|
5
|
+
declare const DEFAULT_DATABASE_PORT = 51214;
|
|
6
|
+
declare const DEFAULT_SERVER_PORT = 51213;
|
|
7
|
+
declare const DEFAULT_SHADOW_DATABASE_PORT = 51215;
|
|
8
|
+
type PortAssignableService = DBServerPurpose | "server";
|
|
9
|
+
declare class PortNotAvailableError extends Error {
|
|
10
|
+
port: number;
|
|
11
|
+
service: PortAssignableService;
|
|
12
|
+
name: string;
|
|
13
|
+
constructor(port: number, service: PortAssignableService);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface Server extends Exports {
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
declare function unstable_startServer(options?: ServerOptions): Promise<Server>;
|
|
20
|
+
|
|
21
|
+
declare const exportsSchema: valibot.ObjectSchema<{
|
|
22
|
+
readonly database: valibot.ObjectSchema<{
|
|
23
|
+
readonly connectionString: valibot.SchemaWithPipe<readonly [valibot.StringSchema<undefined>, valibot.UrlAction<string, undefined>]>;
|
|
24
|
+
}, undefined>;
|
|
25
|
+
readonly http: valibot.ObjectSchema<{
|
|
26
|
+
readonly url: valibot.SchemaWithPipe<readonly [valibot.StringSchema<undefined>, valibot.UrlAction<string, undefined>]>;
|
|
27
|
+
}, undefined>;
|
|
28
|
+
readonly ppg: valibot.ObjectSchema<{
|
|
29
|
+
readonly url: valibot.SchemaWithPipe<readonly [valibot.StringSchema<undefined>, valibot.UrlAction<string, undefined>]>;
|
|
30
|
+
}, undefined>;
|
|
31
|
+
readonly shadowDatabase: valibot.ObjectSchema<{
|
|
32
|
+
readonly connectionString: valibot.SchemaWithPipe<readonly [valibot.StringSchema<undefined>, valibot.UrlAction<string, undefined>]>;
|
|
33
|
+
}, undefined>;
|
|
34
|
+
}, undefined>;
|
|
35
|
+
type Exports = InferOutput<typeof exportsSchema>;
|
|
36
|
+
declare const serverDumpV1Schema: valibot.ObjectSchema<{
|
|
37
|
+
readonly databasePort: valibot.SchemaWithPipe<readonly [valibot.NumberSchema<undefined>, valibot.IntegerAction<number, undefined>, valibot.MinValueAction<number, 1, undefined>]>;
|
|
38
|
+
readonly exports: valibot.OptionalSchema<valibot.ObjectSchema<{
|
|
39
|
+
readonly database: valibot.ObjectSchema<{
|
|
40
|
+
readonly connectionString: valibot.SchemaWithPipe<readonly [valibot.StringSchema<undefined>, valibot.UrlAction<string, undefined>]>;
|
|
41
|
+
}, undefined>;
|
|
42
|
+
readonly http: valibot.ObjectSchema<{
|
|
43
|
+
readonly url: valibot.SchemaWithPipe<readonly [valibot.StringSchema<undefined>, valibot.UrlAction<string, undefined>]>;
|
|
44
|
+
}, undefined>;
|
|
45
|
+
readonly ppg: valibot.ObjectSchema<{
|
|
46
|
+
readonly url: valibot.SchemaWithPipe<readonly [valibot.StringSchema<undefined>, valibot.UrlAction<string, undefined>]>;
|
|
47
|
+
}, undefined>;
|
|
48
|
+
readonly shadowDatabase: valibot.ObjectSchema<{
|
|
49
|
+
readonly connectionString: valibot.SchemaWithPipe<readonly [valibot.StringSchema<undefined>, valibot.UrlAction<string, undefined>]>;
|
|
50
|
+
}, undefined>;
|
|
51
|
+
}, undefined>, undefined>;
|
|
52
|
+
readonly name: valibot.SchemaWithPipe<readonly [valibot.StringSchema<undefined>, valibot.MinLengthAction<string, 1, undefined>]>;
|
|
53
|
+
readonly pid: valibot.OptionalSchema<valibot.SchemaWithPipe<readonly [valibot.NumberSchema<undefined>, valibot.IntegerAction<number, undefined>, valibot.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
54
|
+
readonly port: valibot.SchemaWithPipe<readonly [valibot.NumberSchema<undefined>, valibot.IntegerAction<number, undefined>, valibot.MinValueAction<number, 1, undefined>]>;
|
|
55
|
+
readonly shadowDatabasePort: valibot.SchemaWithPipe<readonly [valibot.NumberSchema<undefined>, valibot.IntegerAction<number, undefined>, valibot.MinValueAction<number, 1, undefined>]>;
|
|
56
|
+
readonly version: valibot.LiteralSchema<"1", undefined>;
|
|
57
|
+
}, undefined>;
|
|
58
|
+
type ServerDumpV1 = InferOutput<typeof serverDumpV1Schema>;
|
|
59
|
+
interface ServerOptions {
|
|
60
|
+
/**
|
|
61
|
+
* The port the database server will listen on.
|
|
62
|
+
*
|
|
63
|
+
* Defaults to `51214`.
|
|
64
|
+
*
|
|
65
|
+
* An error is thrown if the port is already in use.
|
|
66
|
+
*/
|
|
67
|
+
databasePort?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Whether to enable debug logging.
|
|
70
|
+
*
|
|
71
|
+
* Defaults to `false`.
|
|
72
|
+
*/
|
|
73
|
+
debug?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Whether to run the server in dry run mode.
|
|
76
|
+
*
|
|
77
|
+
* Defaults to `false`.
|
|
78
|
+
*/
|
|
79
|
+
dryRun?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The name of the server.
|
|
82
|
+
*
|
|
83
|
+
* Defaults to `default`.
|
|
84
|
+
*/
|
|
85
|
+
name?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The persistence mode of the server.
|
|
88
|
+
*
|
|
89
|
+
* Default is `stateless`.
|
|
90
|
+
*/
|
|
91
|
+
persistenceMode?: PersistenceMode;
|
|
92
|
+
/**
|
|
93
|
+
* The port the server will listen on.
|
|
94
|
+
*
|
|
95
|
+
* Defaults to `51213`.
|
|
96
|
+
*
|
|
97
|
+
* An error is thrown if the port is already in use.
|
|
98
|
+
*/
|
|
99
|
+
port?: number;
|
|
100
|
+
/**
|
|
101
|
+
* The port the shadow database server will listen on.
|
|
102
|
+
*
|
|
103
|
+
* Defaults to `51215`.
|
|
104
|
+
*
|
|
105
|
+
* An error is thrown if the port is already in use.
|
|
106
|
+
*/
|
|
107
|
+
shadowDatabasePort?: number;
|
|
108
|
+
}
|
|
109
|
+
type ResolvedServerOptions = Required<ServerOptions>;
|
|
110
|
+
type PersistenceMode = "stateless" | "stateful";
|
|
111
|
+
interface ScanOptions {
|
|
112
|
+
debug?: boolean;
|
|
113
|
+
}
|
|
114
|
+
declare const PRIVATE_INITIALIZE_SYMBOL: unique symbol;
|
|
115
|
+
declare abstract class ServerState implements ResolvedServerOptions {
|
|
116
|
+
readonly databasePort: number;
|
|
117
|
+
readonly debug: boolean;
|
|
118
|
+
readonly dryRun: boolean;
|
|
119
|
+
readonly name: string;
|
|
120
|
+
readonly persistenceMode: PersistenceMode;
|
|
121
|
+
readonly pid: number | undefined;
|
|
122
|
+
readonly port: number;
|
|
123
|
+
readonly shadowDatabasePort: number;
|
|
124
|
+
protected constructor(options: Omit<ServerOptions, "persistenceMode"> & {
|
|
125
|
+
persistenceMode: PersistenceMode;
|
|
126
|
+
pid: number | undefined;
|
|
127
|
+
});
|
|
128
|
+
static createExclusively(options: ServerOptions | undefined): Promise<ServerState>;
|
|
129
|
+
static fromServerDump(options?: Pick<ServerOptions, "debug" | "name">): Promise<StatefulServerState | null>;
|
|
130
|
+
static scan(options?: ScanOptions): Promise<ServerStatusV1[]>;
|
|
131
|
+
abstract get databaseDumpPath(): string;
|
|
132
|
+
abstract get pgliteDataDirPath(): string;
|
|
133
|
+
abstract [PRIVATE_INITIALIZE_SYMBOL](): Promise<void>;
|
|
134
|
+
abstract close(): Promise<void>;
|
|
135
|
+
abstract writeServerDump(exports?: Omit<Server, "close">): Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
declare class StatefulServerState extends ServerState {
|
|
138
|
+
#private;
|
|
139
|
+
constructor(options: Omit<ServerOptions, "persistenceMode"> & {
|
|
140
|
+
pid: number | undefined;
|
|
141
|
+
serverDump?: ServerDumpV1;
|
|
142
|
+
});
|
|
143
|
+
static getServerDumpPath(dataDirPath: string): string;
|
|
144
|
+
get databaseDumpPath(): string;
|
|
145
|
+
get exports(): Exports | undefined;
|
|
146
|
+
get pgliteDataDirPath(): string;
|
|
147
|
+
[PRIVATE_INITIALIZE_SYMBOL](): Promise<void>;
|
|
148
|
+
close(): Promise<void>;
|
|
149
|
+
writeServerDump(exports?: Exports): Promise<void>;
|
|
150
|
+
}
|
|
151
|
+
interface ServerStatusV1 extends ServerDumpV1 {
|
|
152
|
+
status: "running" | "starting_up" | "not_running" | "no_such_server" | "unknown" | "error";
|
|
153
|
+
}
|
|
154
|
+
declare class ServerStateAlreadyExistsError extends Error {
|
|
155
|
+
name: string;
|
|
156
|
+
constructor(name: string);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface DBServer {
|
|
160
|
+
close(): Promise<void>;
|
|
161
|
+
readonly connectionLimit: number;
|
|
162
|
+
readonly connectionString: string;
|
|
163
|
+
readonly connectTimeout: number;
|
|
164
|
+
readonly database: string;
|
|
165
|
+
dump(destinationPath: string): Promise<void>;
|
|
166
|
+
readonly maxIdleConnectionLifetime: number;
|
|
167
|
+
readonly password: string;
|
|
168
|
+
readonly poolTimeout: number;
|
|
169
|
+
readonly port: number;
|
|
170
|
+
readonly socketTimeout: number;
|
|
171
|
+
readonly sslMode: string;
|
|
172
|
+
readonly username: string;
|
|
173
|
+
}
|
|
174
|
+
interface DBDump {
|
|
175
|
+
dumpPath: string;
|
|
176
|
+
}
|
|
177
|
+
type DBServerPurpose = "database" | "shadow_database";
|
|
178
|
+
declare function startDBServer(purpose: DBServerPurpose, serverState: ServerState): Promise<DBServer>;
|
|
179
|
+
type DumpDBOptions<D extends string> = {
|
|
180
|
+
dataDir: string;
|
|
181
|
+
db?: never;
|
|
182
|
+
debug?: boolean;
|
|
183
|
+
destinationPath?: D;
|
|
184
|
+
} | {
|
|
185
|
+
dataDir?: never;
|
|
186
|
+
db: PGlite;
|
|
187
|
+
debug?: boolean;
|
|
188
|
+
destinationPath?: D;
|
|
189
|
+
};
|
|
190
|
+
declare function dumpDB<D extends string = never>(options: DumpDBOptions<D>): Promise<[D] extends [never] ? string : void>;
|
|
191
|
+
|
|
192
|
+
export { DEFAULT_DATABASE_PORT as D, type Exports as E, type PortAssignableService as P, type ResolvedServerOptions as R, type ServerOptions as S, type Server as a, DEFAULT_SERVER_PORT as b, DEFAULT_SHADOW_DATABASE_PORT as c, PortNotAvailableError as d, type ServerDumpV1 as e, type PersistenceMode as f, type ScanOptions as g, ServerState as h, type ServerStatusV1 as i, ServerStateAlreadyExistsError as j, type DBServer as k, type DBDump as l, type DBServerPurpose as m, type DumpDBOptions as n, dumpDB as o, startDBServer as s, unstable_startServer as u };
|
package/dist/db.d.ts
ADDED
package/dist/db.js
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { D as DEFAULT_DATABASE_PORT, b as DEFAULT_SERVER_PORT, c as DEFAULT_SHADOW_DATABASE_PORT, P as PortAssignableService, d as PortNotAvailableError, a as Server, u as unstable_startServer } from './
|
|
1
|
+
export { D as DEFAULT_DATABASE_PORT, b as DEFAULT_SERVER_PORT, c as DEFAULT_SHADOW_DATABASE_PORT, P as PortAssignableService, d as PortNotAvailableError, a as Server, u as unstable_startServer } from './db-9fHowc0q.js';
|
|
2
|
+
import '@electric-sql/pglite';
|
|
3
|
+
import 'valibot';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
3
|
-
`).find(
|
|
4
|
-
Received data: ${
|
|
2
|
+
import{a as H}from"./chunk-CLIITWV6.js";import{a as L}from"./chunk-WHX3423Q.js";import{a as $,c as j,d as D,i as ze,j as Ge,k as Je,l as B}from"./chunk-KSRPCQJC.js";import{HTTPException as v}from"hono/http-exception";import{object as se,optional as ie,parseJson as ae,pipe as A,regex as q,safeParse as ce,string as I,url as N}from"valibot";var V=/^(postgres|postgresql):\/\//,pe=A(I(),ae(),se({databaseUrl:A(I(),N(),q(V)),shadowDatabaseUrl:ie(A(I(),N(),q(V)))}));function U(n){return Buffer.from(JSON.stringify(n),"utf8").toString("base64url")}function ue(n){let e=Buffer.from(n,"base64url").toString("utf8"),{issues:t,output:r,success:o}=ce(pe,e,{abortEarly:!0});return o?[null,r]:[t]}var d=(n,e)=>{let{authorization:t}=n;if(!t)throw new v(401,{message:"Missing API Key"});let[r,o="",s]=t.split(" ");if(r!=="Bearer"||s)throw new v(401,{message:"Invalid API Key"});let[i,a]=ue(o);if(i)throw new v(401,{message:"Invalid API Key",cause:i.join(", ")});let{databaseUrl:c}=a;if(c!==e.var.db.connectionString)throw new v(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:a}};import{createServer as Ve}from"http";import{promisify as Ue}from"util";import{serve as Ke}from"@hono/node-server";import Me from"@prisma/get-platform";function b(){let n,e,t=new Promise((s,i)=>{n=s,e=i}),r=s=>{r=o=null,e(s)},o=s=>{o=r=null,n(s)};return{promise:t,reject:s=>r?.(s),resolve:s=>o?.(s)}}import{logger as Qe}from"hono/logger";import{Hono as ne}from"hono/tiny";import{Hono as De}from"hono/tiny";import{validator as y}from"hono/validator";import{array as le,literal as me,minLength as de,object as ge,pipe as he,safeParse as fe,string as ye,union as we}from"valibot";var Se=ge({tags:we([he(le(ye()),de(1)),me("all")])});async function K(n){let{output:e,success:t}=fe(Se,await n.req.json(),{abortEarly:!0});return t?e:n.text("Invalid input",400)}import{spawn as ve}from"child_process";import{once as be}from"events";import{mkdir as Ee}from"fs/promises";import{join as Pe}from"path";import{setTimeout as Re}from"timers/promises";import{proxySignals as Te}from"foreground-child/proxy-signals";import{process as He}from"std-env";var{PRISMA_DEV_FORCE_ENGINE_BINARY_DOWNLOAD:Ae,PRISMA_DEV_FORCE_ENGINE_BINARY_PATH:Ie,PRISMA_DEV_FORCE_NETWORK_DELAY_MS:M}=He.env,h=class n{static#n=new Map;#e;#t;constructor(e){this.#e=e,this.#t=null}static async get(e){let{debug:t}=e,r=`${e.schemaHash}:${e.clientVersion}`;try{let o=n.#n.get(r);if(o)return o;let s=new n(e);return n.#n.set(r,s),t&&console.debug("[Query Engine] starting...",e),await s.start(),t&&console.debug("[Query Engine] started!"),s}finally{n.stopAll(r)}}static async stopAll(e){let r=(await Promise.allSettled(Array.from(n.#n.entries()).filter(([o])=>o!==e).map(async([o,s])=>{try{await s.stop()}finally{n.#n.delete(o)}}))).filter(o=>o.status==="rejected").map(o=>o.reason);if(r.length>0)throw new AggregateError(r,"Failed to stop engines")}async commitTransaction(e,t){return await this.#o(e,t,"commit")}async request(e,t){let{url:r}=await this.start(),o=this.#r(t),s=await fetch(r,{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,t){return await this.#o(e,t,"rollback")}async startTransaction(e,t){let{url:r}=await this.start(),o=this.#r(t),s=await fetch(`${r}/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 await this.#t;let{promise:e,reject:t,resolve:r}=b();this.#t=e;let o=Ie||await this.#s();this.#e.debug&&console.debug("[Query Engine] spinning up at path...",o);let s=ve(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});Te(s),s.stderr.setEncoding("utf8"),s.stdout.setEncoding("utf8");let i=p=>{let l=p.split(`
|
|
3
|
+
`).find(oe=>oe.includes("Started query engine http server"));if(!l)return;s.stdout.removeListener("data",i);let{fields:m}=JSON.parse(l);if(m==null)return t(new Error(`Unexpected data during initialization, "fields" are missing: ${p}`));let{ip:u,port:_}=m;if(u==null||_==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.
|
|
4
|
+
Received data: ${p}`));r({childProcess:s,url:`http://${u}:${_}`})},a=p=>{this.#t=null,t(new f(String(p))),s.removeListener("exit",c),s.kill()};s.once("error",a);let c=(p,l)=>{this.#t=null,t(new f(`Query Engine exited with code ${p} and signal ${l}`))};return s.once("exit",c),s.stdout.on("data",i),this.#e.debug&&(s.stderr.on("data",console.error.bind(console,"[Query Engine]")),s.stdout.on("data",console.debug.bind(console,"[Query Engine]"))),await this.#t}async stop(){if(this.#t==null)return;let{childProcess:e}=await this.#t;e.exitCode==null&&e.signalCode==null&&(this.#t=null,e.kill(),await be(e,"exit"))}async#s(){this.#e.debug&&console.debug("[Query Engine] getting engine commit hash...");let e=await this.#i();this.#e.debug&&console.debug("[Query Engine] got engine commit hash",e);let t=$(this.#e.clientVersion,e);this.#e.debug&&console.debug("[Query Engine] cache directory path",t),await Ee(t,{recursive:!0});let{platform:r}=this.#e.platform,o=r==="windows"?".exe":"",s=Pe(t,`query-engine-${r}${o}`);return this.#e.debug&&console.debug("[Query Engine] binary path",s),(Ae==="1"||await j(s)===!1)&&await this.#a({commitHash:e,extension:o,engineBinaryPath:s}),s}async#i(){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 r=(await e.json()).devDependencies?.["@prisma/engines-version"];if(!r)throw new Error("Couldn't find engines version in package.json");let o=r.split(".").at(-1);if(!o)throw new Error("Couldn't find commit hash in engines version");return o}async#a(e){let{commitHash:t,extension:r,engineBinaryPath:o}=e,{binaryTarget:s}=this.#e.platform,i=`https://binaries.prisma.sh/all_commits/${t}/${s}/query-engine${r}.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}`);M&&await Re(Number(M)),await D(await a.arrayBuffer(),o),this.#e.debug&&console.debug("[Query Engine] downloaded and saved at",o)}#r(e){let t={};for(let[r,o]of Object.entries(e))o!=null&&(t[r]=o);return t}async#o(e,t,r){let{url:o}=await this.#t,s=this.#r(t),i=await fetch(`${o}/transaction/${e}/${r}`,{headers:{...s,"Content-Type":"application/json"},method:"POST"});if(!i.ok)throw await g.fromResponse(i);try{return await i.json()}catch{return{}}}};function E(n,e){return console.error(n),n instanceof f?e.json({EngineNotStarted:{reason:{EngineStartupError:{logs:[],msg:n.message}}}},500):n instanceof g?e.text(n.responseBody,n.statusCode):e.body(null,500)}var f=class extends Error{name="EngineStartError"},g=class n extends Error{constructor(t,r,o){super(`${t}: Query Engine response status ${r}, body: ${o}`);this.action=t;this.statusCode=r;this.responseBody=o}name="EngineHttpError";static async fromResponse(t){let r=new URL(t.url),o=await t.text();return new n(r.pathname,t.status,o)}};import{Buffer as Q}from"buffer";var P=new Map;async function O(n){let t=new TextEncoder().encode(n),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}function F(n){let e=n.req.param("schemaHash"),t=P.get(e);return t==null?n.json({EngineNotStarted:{reason:"SchemaMissing"}},404):{schemaHash:e,schemas:t}}var Oe=/datasource\s+db\s+\{\s*provider\s*=\s*"postgres(!?ql)?"\s+url\s*=\s*.+\s*\}/;async function z(n,e){let t=Q.from(n,"base64").toString("utf8"),r=`datasource db {
|
|
5
5
|
provider = "postgresql"
|
|
6
6
|
url = "${e.toString()}"
|
|
7
|
-
}`,o=
|
|
8
|
-
`,{encoding:"utf-8"})}async#n(e){if(!await D(e))return!1;let r=Dt(e,5).toString("utf-8");return this.debug&&console.debug(`last lines of checked dump: ${r}`),this.#s(r)}#s(e){return e.includes("-- PostgreSQL database dump complete")}};async function Lr(t){let e=await y.get(t),[r,n]=await Promise.all([C("database",e),C("shadow_database",e)]),o=await fe(r,e),s=`prisma+postgres://localhost:${o.port}/?${new URLSearchParams({api_key:K({databaseUrl:r.connectionString,shadowDatabaseUrl:n.connectionString})}).toString()}`,i={accelerate:{url:o.url},database:{connectionString:r.connectionString},ppg:{url:s},shadowDatabase:{connectionString:n.connectionString}};return await e.writeServerDump(i),{...i,close:()=>a(e,[o,r,n])};async function a(c,d){let p=(await Promise.allSettled(d.map(u=>u.close()))).filter(u=>u.status==="rejected").map(u=>new Error(u.reason));try{await c.close()}catch(u){p.push(u)}if(p.length>0)throw new AggregateError(p,"Failed to close some servers")}}export{te as DEFAULT_DATABASE_PORT,re as DEFAULT_SERVER_PORT,ne as DEFAULT_SHADOW_DATABASE_PORT,f as PortNotAvailableError,Lr as unstable_startServer};
|
|
7
|
+
}`,o=t.replace(Oe,r),s=await O(o);return{base64Override:Q.from(o,"utf8").toString("base64"),overrideHash:s}}function R(n){let{req:e}=n;return{traceparent:e.header("traceparent"),"X-capture-telemetry":e.header("X-capture-telemetry")}}import{integer as G,looseObject as xe,minValue as J,number as x,object as Ce,optional as ke,pipe as X,safeParse as Y,string as W,union as _e}from"valibot";var $e=Ce({isolation_level:ke(W()),max_wait:X(x(),G(),J(0)),timeout:X(x(),G(),J(0))});async function Z(n){let{issues:e,output:t,success:r}=Y($e,await n.req.json(),{abortEarly:!0});return r?t:n.json({EngineNotStarted:{reason:"InvalidRequest",issues:e}},400)}var je=xe({id:_e([W(),x()])});function ee(n,e){let{output:t,success:r}=Y(je,n);return r?t:e.json({EngineMalfunction:{}},500)}var w=new De;w.post("/invalidate",y("header",d),async n=>{let e=await K(n);return e instanceof Response?e:n.body(null)});var Be="/:clientVersion/:schemaHash",S=w.basePath(Be);w.route("/",S);var Le=["/graphql","/itx/:transactionId/graphql"];S.on("POST",[...Le],y("header",d),async n=>{let{req:e}=n;try{let t=await C(n);if(t instanceof Response)return t;let r=await e.text(),o=e.param("transactionId"),s=await t.request(r,{...R(n),"X-transaction-id":o});return n.text(s)}catch(t){return E(t,n)}});S.basePath("/itx/:transactionId").on("POST",["/commit","/rollback"],y("header",d),async n=>{let{req:e}=n;try{let t=await C(n);if(t instanceof Response)return t;let o=`${e.routePath.split("/").filter(Boolean).at(-1)}Transaction`,s=e.param("transactionId"),i=await t[o](s,R(n));return n.json(i)}catch(t){return E(t,n)}});S.put("/schema",y("header",d),async n=>{let{req:e}=n,t=await e.text();if(!t)return n.text("Missing schema",400);let r=e.param("schemaHash"),o=P.get(r);if(o==null){if(r!==await O(t))return n.text("Schema hash mismatch",400);let s=new URL(n.get("db").connectionString);s.searchParams.set("single_use_connections","true");let i=await z(t,s);return P.set(r,{base64Original:t,...i}),n.text(r)}return t!==o.base64Original?n.text("Schema mismatch",400):n.text(r)});S.post("/transaction/start",y("header",d),async n=>{let{req:e}=n,t=await Z(n);if(t instanceof Response)return t;try{let r=await C(n);if(r instanceof Response)return r;let o=await r.startTransaction(t,R(n)),s=ee(o,n);if(s instanceof Response)return s;let{id:i}=s,a=e.param("clientVersion"),c=n.get("port"),p=n.get("protocol"),l=e.param("schemaHash");return n.json({...o,"data-proxy":{endpoint:`${p}://localhost:${c}/${a}/${l}/itx/${i}`}})}catch(r){return E(r,n)}});async function C(n){let{req:e}=n,t=F(n);if(t instanceof Response)return t;let{base64Override:r,overrideHash:o}=t.schemas;return await h.get({base64Schema:r,clientVersion:process.env.PRISMA_DEV_FORCE_CLIENT_VERSION||e.param("clientVersion"),debug:n.get("debug"),platform:n.get("platform"),schemaHash:o})}import{Hono as qe}from"hono/tiny";import{StatusCodes as Ne}from"http-status-codes";var T=new qe;T.post("/database/dump",async n=>{let e=n.get("db"),t=n.get("serverState");return await e.dump(t.databaseDumpPath),n.json({dumpPath:t.databaseDumpPath},Ne.CREATED)});var Ot=T.get("/health",n=>n.json({name:n.get("serverState").name}));async function re(n,e){let{port:t}=e;if(e.dryRun)return te(t,null);let r=await Fe(t,n,e),{promise:o,reject:s,resolve:i}=b(),a=Ke({createServer:Ve,fetch:r.fetch,overrideGlobalObjects:!1,port:t},i);return a.on("error",c=>{if(typeof c=="object"&&"code"in c&&c.code==="EADDRINUSE")return s(new B(t,"server"));console.error("[Accelerate]",c)}),await o,te(t,a)}function te(n,e){return{async close(){e&&await Promise.allSettled([Ue(e.close.bind(e))(),h.stopAll()])},port:n,url:`http://localhost:${n}`}}async function Fe(n,e,t){let{debug:r}=t,o=new ne,s=await Me.getPlatformInfo();return r&&console.debug("[Accelerate] platform info: %s",JSON.stringify(s)),r&&o.use("*",Qe((...i)=>console.log("[Accelerate]",...i))),o.use("*",async(i,a)=>(i.set("db",e),i.set("debug",!!r),i.set("platform",s),i.set("port",n),i.set("protocol","http"),i.set("serverState",t),await a())),o.route("/",k),o}var k=new ne;k.route("/",w);k.route("/",T);async function zt(n){let e=await L.createExclusively(n),[t,r]=await Promise.all([H("database",e),H("shadow_database",e)]),o=await re(t,e),s=`prisma+postgres://localhost:${o.port}/?${new URLSearchParams({api_key:U({databaseUrl:t.connectionString,shadowDatabaseUrl:r.connectionString})}).toString()}`,i={database:{connectionString:t.connectionString},http:{url:o.url},ppg:{url:s},shadowDatabase:{connectionString:r.connectionString}};return await e.writeServerDump(i),{...i,close:()=>a(e,[o,t,r])};async function a(c,p){let m=(await Promise.allSettled(p.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{ze as DEFAULT_DATABASE_PORT,Ge as DEFAULT_SERVER_PORT,Je as DEFAULT_SHADOW_DATABASE_PORT,B as PortNotAvailableError,zt as unstable_startServer};
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import 'valibot';
|
|
2
|
+
export { E as Exports, f as PersistenceMode, R as ResolvedServerOptions, g as ScanOptions, e as ServerDumpV1, S as ServerOptions, h as ServerState, j as ServerStateAlreadyExistsError, i as ServerStatusV1 } from './db-9fHowc0q.js';
|
|
3
|
+
import '@electric-sql/pglite';
|
package/dist/state.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/dev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A local Prisma Postgres server for development and testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,6 +19,16 @@
|
|
|
19
19
|
"types": "./dist/daemon/client.d.ts",
|
|
20
20
|
"import": "./dist/daemon/client.js",
|
|
21
21
|
"default": "./dist/daemon/client.js"
|
|
22
|
+
},
|
|
23
|
+
"./internal/db": {
|
|
24
|
+
"types": "./dist/db.d.ts",
|
|
25
|
+
"import": "./dist/db.js",
|
|
26
|
+
"default": "./dist/db.js"
|
|
27
|
+
},
|
|
28
|
+
"./internal/state": {
|
|
29
|
+
"types": "./dist/state.d.ts",
|
|
30
|
+
"import": "./dist/state.js",
|
|
31
|
+
"default": "./dist/state.js"
|
|
22
32
|
}
|
|
23
33
|
},
|
|
24
34
|
"keywords": [
|
|
@@ -51,6 +61,7 @@
|
|
|
51
61
|
"env-paths": "3.0.0",
|
|
52
62
|
"foreground-child": "3.3.1",
|
|
53
63
|
"hono": "4.7.10",
|
|
64
|
+
"http-status-codes": "2.3.0",
|
|
54
65
|
"pako": "2.1.0",
|
|
55
66
|
"pathe": "2.0.3",
|
|
56
67
|
"proper-lockfile": "4.1.2",
|
package/dist/index-CW1pktRs.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
interface ServerOptions {
|
|
2
|
-
/**
|
|
3
|
-
* The port the database server will listen on.
|
|
4
|
-
*
|
|
5
|
-
* Defaults to `51214`.
|
|
6
|
-
*
|
|
7
|
-
* An error is thrown if the port is already in use.
|
|
8
|
-
*/
|
|
9
|
-
databasePort?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Whether to enable debug logging.
|
|
12
|
-
*
|
|
13
|
-
* Defaults to `false`.
|
|
14
|
-
*/
|
|
15
|
-
debug?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Whether to run the server in dry run mode.
|
|
18
|
-
*
|
|
19
|
-
* Defaults to `false`.
|
|
20
|
-
*/
|
|
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;
|
|
42
|
-
/**
|
|
43
|
-
* The port the shadow database server will listen on.
|
|
44
|
-
*
|
|
45
|
-
* Defaults to `51215`.
|
|
46
|
-
*
|
|
47
|
-
* An error is thrown if the port is already in use.
|
|
48
|
-
*/
|
|
49
|
-
shadowDatabasePort?: number;
|
|
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
|
-
|
|
66
|
-
interface Server {
|
|
67
|
-
accelerate: {
|
|
68
|
-
url: string;
|
|
69
|
-
};
|
|
70
|
-
close(): Promise<void>;
|
|
71
|
-
database: {
|
|
72
|
-
connectionString: string;
|
|
73
|
-
};
|
|
74
|
-
ppg: {
|
|
75
|
-
url: string;
|
|
76
|
-
};
|
|
77
|
-
shadowDatabase: {
|
|
78
|
-
connectionString: string;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
declare function unstable_startServer(options?: ServerOptions): Promise<Server>;
|
|
82
|
-
|
|
83
|
-
export { DEFAULT_DATABASE_PORT as D, type PortAssignableService as P, type ServerOptions as S, type Server as a, DEFAULT_SERVER_PORT as b, DEFAULT_SHADOW_DATABASE_PORT as c, PortNotAvailableError as d, unstable_startServer as u };
|