@prisma/dev 0.0.0-dev.202601192211 → 0.0.0-dev.202607271058
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/README.md +259 -0
- package/dist/accelerate-TRR43YJ5.js +11 -0
- package/dist/chunk-662IKR3V.js +1 -0
- package/dist/chunk-A5B4L65Y.js +1 -0
- package/dist/chunk-ANHBRJRZ.js +1 -0
- package/dist/chunk-DOJAPHLY.js +1 -0
- package/dist/{chunk-ITQ6ILGR.js → chunk-DWY47FQV.js} +1 -1
- package/dist/chunk-EDFHV3AK.js +1 -0
- package/dist/chunk-HFONW2ZS.js +3 -0
- package/dist/chunk-KWCQYPJI.js +1 -0
- package/dist/chunk-MTR5KBPH.js +1 -0
- package/dist/chunk-PP43TGA5.js +107 -0
- package/dist/chunk-SW3J2PL2.js +1 -0
- package/dist/daemon.cjs +121 -5
- package/dist/daemon.d.cts +21 -6
- package/dist/daemon.d.ts +21 -6
- package/dist/daemon.js +1 -1
- package/dist/db-BzbLAxLn.d.cts +126 -0
- package/dist/db-HU7BFiFV.d.ts +126 -0
- package/dist/db.cjs +107 -1
- package/dist/db.d.cts +3 -39
- package/dist/db.d.ts +3 -39
- package/dist/db.js +1 -1
- package/dist/engine-YTEOPVUP.js +3 -0
- package/dist/index.cjs +121 -5
- package/dist/index.d.cts +64 -12
- package/dist/index.d.ts +64 -12
- package/dist/index.js +1 -1
- package/dist/query-plan-executor-ZS4544O3.js +1 -0
- package/dist/runtime-assets/amcheck.tar.gz +0 -0
- package/dist/runtime-assets/bloom.tar.gz +0 -0
- package/dist/runtime-assets/btree_gin.tar.gz +0 -0
- package/dist/runtime-assets/btree_gist.tar.gz +0 -0
- package/dist/runtime-assets/citext.tar.gz +0 -0
- package/dist/runtime-assets/cube.tar.gz +0 -0
- package/dist/runtime-assets/dict_int.tar.gz +0 -0
- package/dist/runtime-assets/dict_xsyn.tar.gz +0 -0
- package/dist/runtime-assets/earthdistance.tar.gz +0 -0
- package/dist/runtime-assets/file_fdw.tar.gz +0 -0
- package/dist/runtime-assets/fuzzystrmatch.tar.gz +0 -0
- package/dist/runtime-assets/hstore.tar.gz +0 -0
- package/dist/runtime-assets/initdb.wasm +0 -0
- package/dist/runtime-assets/intarray.tar.gz +0 -0
- package/dist/runtime-assets/isn.tar.gz +0 -0
- package/dist/runtime-assets/lo.tar.gz +0 -0
- package/dist/runtime-assets/ltree.tar.gz +0 -0
- package/dist/runtime-assets/pageinspect.tar.gz +0 -0
- package/dist/runtime-assets/pg_buffercache.tar.gz +0 -0
- package/dist/runtime-assets/pg_freespacemap.tar.gz +0 -0
- package/dist/runtime-assets/pg_surgery.tar.gz +0 -0
- package/dist/runtime-assets/pg_trgm.tar.gz +0 -0
- package/dist/runtime-assets/pg_visibility.tar.gz +0 -0
- package/dist/runtime-assets/pg_walinspect.tar.gz +0 -0
- package/dist/runtime-assets/pglite-seed.tar.gz +0 -0
- package/dist/runtime-assets/pglite.data +0 -0
- package/dist/runtime-assets/pglite.wasm +0 -0
- package/dist/runtime-assets/seg.tar.gz +0 -0
- package/dist/runtime-assets/tablefunc.tar.gz +0 -0
- package/dist/runtime-assets/tcn.tar.gz +0 -0
- package/dist/runtime-assets/tsm_system_rows.tar.gz +0 -0
- package/dist/runtime-assets/tsm_system_time.tar.gz +0 -0
- package/dist/runtime-assets/unaccent.tar.gz +0 -0
- package/dist/runtime-assets/uuid-ossp.tar.gz +0 -0
- package/dist/runtime-assets/vector.tar.gz +0 -0
- package/dist/runtime-assets-manifest.bun.js +79 -0
- package/dist/runtime-assets.cjs +1 -0
- package/dist/runtime-assets.d.cts +28 -0
- package/dist/runtime-assets.d.ts +28 -0
- package/dist/runtime-assets.js +1 -0
- package/dist/server-QR7P25DP.js +1 -0
- package/dist/state-CNKFAMiX.d.cts +256 -0
- package/dist/state-CNKFAMiX.d.ts +256 -0
- package/dist/state.cjs +3 -3
- package/dist/state.d.cts +2 -216
- package/dist/state.d.ts +2 -216
- package/dist/state.js +1 -1
- package/dist/utility-YEFNU35E.js +1 -0
- package/dist/vite.cjs +121 -0
- package/dist/vite.d.cts +186 -0
- package/dist/vite.d.ts +184 -0
- package/dist/vite.js +1 -0
- package/package.json +34 -12
- package/dist/accelerate-EEKAFGN3.js +0 -1
- package/dist/chunk-7NDL3ECU.js +0 -3
- package/dist/chunk-LKYVOPH3.js +0 -3
- package/dist/chunk-OTI5SWIV.js +0 -1
- package/dist/chunk-RJ42AYBU.js +0 -1
- package/dist/chunk-XMKRRRGB.js +0 -1
- package/dist/utility-Q5A254LJ.js +0 -1
package/dist/vite.d.cts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { P as PersistenceMode } from './state-CNKFAMiX.cjs';
|
|
3
|
+
import 'valibot';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Names of the environment variables the plugin writes.
|
|
7
|
+
*
|
|
8
|
+
* Set an entry to `false` to skip that variable, or to a string to rename it.
|
|
9
|
+
*/
|
|
10
|
+
interface PrismaDevEnvOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Direct TCP connection string for the main database.
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `DATABASE_URL`.
|
|
15
|
+
*/
|
|
16
|
+
databaseUrl?: false | string;
|
|
17
|
+
/**
|
|
18
|
+
* The `prisma+postgres://` HTTP connection string, matching how a deployed
|
|
19
|
+
* Prisma Postgres database is addressed.
|
|
20
|
+
*
|
|
21
|
+
* Disabled by default, because it embeds an API key. Set a name to opt in.
|
|
22
|
+
*/
|
|
23
|
+
prismaPostgresUrl?: false | string;
|
|
24
|
+
/**
|
|
25
|
+
* Direct TCP connection string for the shadow database, used by
|
|
26
|
+
* `prisma migrate`.
|
|
27
|
+
*
|
|
28
|
+
* Defaults to `SHADOW_DATABASE_URL`.
|
|
29
|
+
*/
|
|
30
|
+
shadowDatabaseUrl?: false | string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The running database, handed to {@link PrismaDevPluginOptions.onDatabaseReady}.
|
|
35
|
+
*/
|
|
36
|
+
interface PrismaDevDatabase {
|
|
37
|
+
/**
|
|
38
|
+
* Direct TCP connection string for the main database.
|
|
39
|
+
*/
|
|
40
|
+
readonly databaseUrl: string;
|
|
41
|
+
/**
|
|
42
|
+
* The variables this plugin manages, mapped to the local database, ready to
|
|
43
|
+
* spread into a subprocess environment.
|
|
44
|
+
*
|
|
45
|
+
* These always describe the local database, even for a variable the plugin
|
|
46
|
+
* declined to write because the environment already defined it. That matters:
|
|
47
|
+
* without `overrideExistingEnv`, an `.env` pointing `DATABASE_URL` at a
|
|
48
|
+
* deployed database is left alone, so a migration inheriting the ambient
|
|
49
|
+
* `process.env` would run against that deployed database. Spreading this
|
|
50
|
+
* instead keeps the migration local whatever `overrideExistingEnv` is set to.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* await execa("prisma", ["migrate", "deploy"], { env: { ...process.env, ...database.env } });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Variables disabled through the `env` option are absent here.
|
|
57
|
+
*/
|
|
58
|
+
readonly env: Readonly<Record<string, string>>;
|
|
59
|
+
/**
|
|
60
|
+
* The server name, matching the `name` option.
|
|
61
|
+
*/
|
|
62
|
+
readonly name: string;
|
|
63
|
+
/**
|
|
64
|
+
* Whether this process started the database, as opposed to attaching to one
|
|
65
|
+
* that `prisma dev` was already running.
|
|
66
|
+
*/
|
|
67
|
+
readonly owned: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The `prisma+postgres://` HTTP connection string. Carries an API key.
|
|
70
|
+
*/
|
|
71
|
+
readonly prismaPostgresUrl: string;
|
|
72
|
+
/**
|
|
73
|
+
* Direct TCP connection string for the shadow database, which
|
|
74
|
+
* `prisma migrate dev` requires.
|
|
75
|
+
*/
|
|
76
|
+
readonly shadowDatabaseUrl: string;
|
|
77
|
+
}
|
|
78
|
+
interface PrismaDevPluginOptions {
|
|
79
|
+
/**
|
|
80
|
+
* The port the database server listens on.
|
|
81
|
+
*
|
|
82
|
+
* Defaults to `51214`, falling back to another free port when taken.
|
|
83
|
+
*/
|
|
84
|
+
databasePort?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Whether to log the runtime's own debug output.
|
|
87
|
+
*
|
|
88
|
+
* Defaults to `false`.
|
|
89
|
+
*/
|
|
90
|
+
debug?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Boot a database when the config is loaded by Vitest.
|
|
93
|
+
*
|
|
94
|
+
* Defaults to `false`. Vitest reads `vite.config.ts`, so leaving this off
|
|
95
|
+
* keeps a plain test run from starting a database as a config side effect.
|
|
96
|
+
*/
|
|
97
|
+
enableInTest?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Which environment variables to write, and under what names.
|
|
100
|
+
*/
|
|
101
|
+
env?: PrismaDevEnvOptions;
|
|
102
|
+
/**
|
|
103
|
+
* Name of the server, which determines where its data is persisted.
|
|
104
|
+
*
|
|
105
|
+
* Defaults to `default`. Set this per project to keep data isolated.
|
|
106
|
+
*/
|
|
107
|
+
name?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Prepares the database before Vite finishes starting, typically by applying
|
|
110
|
+
* migrations and seeding.
|
|
111
|
+
*
|
|
112
|
+
* Runs after the environment variables have been written, and before any
|
|
113
|
+
* application or framework code has executed, so nothing can observe an
|
|
114
|
+
* unprepared database. `vite dev` waits for it, so a slow migration delays
|
|
115
|
+
* startup.
|
|
116
|
+
*
|
|
117
|
+
* Runs on every start, including a config restart and the case where the
|
|
118
|
+
* plugin attached to a database `prisma dev` already had running. Make it
|
|
119
|
+
* idempotent -- `prisma migrate deploy` already is.
|
|
120
|
+
*
|
|
121
|
+
* If it rejects, the database is shut down and Vite fails to start rather than
|
|
122
|
+
* serving against a half-prepared database.
|
|
123
|
+
*
|
|
124
|
+
* Prefer `database.env` over the ambient `process.env` when spawning a
|
|
125
|
+
* subprocess. See {@link PrismaDevDatabase.env} for why.
|
|
126
|
+
*/
|
|
127
|
+
onDatabaseReady?: (this: void, database: PrismaDevDatabase) => Promise<void> | void;
|
|
128
|
+
/**
|
|
129
|
+
* Whether the database survives between runs.
|
|
130
|
+
*
|
|
131
|
+
* Defaults to `stateful`: data is persisted under `name` and survives dev
|
|
132
|
+
* server restarts.
|
|
133
|
+
*
|
|
134
|
+
* `stateless` keeps the database in memory and discards it on every shutdown,
|
|
135
|
+
* which gives a clean database on each start. Useful with `enableInTest`. Be
|
|
136
|
+
* aware that editing `vite.config.ts` or an `.env` file restarts the dev
|
|
137
|
+
* server, so it also discards the data.
|
|
138
|
+
*
|
|
139
|
+
* A `stateless` database is invisible to `prisma dev ls`, cannot be shared with
|
|
140
|
+
* a running `prisma dev`, and takes any free port rather than the documented
|
|
141
|
+
* defaults unless you set the port options explicitly.
|
|
142
|
+
*/
|
|
143
|
+
persistenceMode?: PersistenceMode;
|
|
144
|
+
/**
|
|
145
|
+
* Overwrite environment variables that already hold a value.
|
|
146
|
+
*
|
|
147
|
+
* Defaults to `false`, so an existing `.env` entry or shell export wins and
|
|
148
|
+
* the plugin logs a warning instead.
|
|
149
|
+
*/
|
|
150
|
+
overrideExistingEnv?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* The port the Prisma Dev HTTP server listens on.
|
|
153
|
+
*
|
|
154
|
+
* Defaults to `51213`, falling back to another free port when taken.
|
|
155
|
+
*/
|
|
156
|
+
port?: number;
|
|
157
|
+
/**
|
|
158
|
+
* The port the shadow database server listens on.
|
|
159
|
+
*
|
|
160
|
+
* Defaults to `51215`, falling back to another free port when taken.
|
|
161
|
+
*/
|
|
162
|
+
shadowDatabasePort?: number;
|
|
163
|
+
/**
|
|
164
|
+
* The port the colocated Prisma Streams server listens on.
|
|
165
|
+
*
|
|
166
|
+
* Defaults to `51216`, falling back to another free port when taken.
|
|
167
|
+
*/
|
|
168
|
+
streamsPort?: number;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Runs a local Prisma Postgres database for the lifetime of the Vite dev server
|
|
172
|
+
* and exposes its connection strings through `process.env`.
|
|
173
|
+
*
|
|
174
|
+
* The database runs in the Vite process, so it cannot outlive it. Production
|
|
175
|
+
* builds and `vite preview` are unaffected.
|
|
176
|
+
*
|
|
177
|
+
* Connection strings are never exposed to client code. They are written to
|
|
178
|
+
* `process.env` only, which is what server-side code and Prisma Client read.
|
|
179
|
+
* Routing them through `define` or `import.meta.env` would inline database
|
|
180
|
+
* credentials into browser assets.
|
|
181
|
+
*/
|
|
182
|
+
declare function prismaDev(options?: PrismaDevPluginOptions): Plugin;
|
|
183
|
+
|
|
184
|
+
// @ts-ignore
|
|
185
|
+
export = prismaDev;
|
|
186
|
+
export { type PrismaDevDatabase, type PrismaDevEnvOptions, type PrismaDevPluginOptions, prismaDev };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { P as PersistenceMode } from './state-CNKFAMiX.js';
|
|
3
|
+
import 'valibot';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Names of the environment variables the plugin writes.
|
|
7
|
+
*
|
|
8
|
+
* Set an entry to `false` to skip that variable, or to a string to rename it.
|
|
9
|
+
*/
|
|
10
|
+
interface PrismaDevEnvOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Direct TCP connection string for the main database.
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `DATABASE_URL`.
|
|
15
|
+
*/
|
|
16
|
+
databaseUrl?: false | string;
|
|
17
|
+
/**
|
|
18
|
+
* The `prisma+postgres://` HTTP connection string, matching how a deployed
|
|
19
|
+
* Prisma Postgres database is addressed.
|
|
20
|
+
*
|
|
21
|
+
* Disabled by default, because it embeds an API key. Set a name to opt in.
|
|
22
|
+
*/
|
|
23
|
+
prismaPostgresUrl?: false | string;
|
|
24
|
+
/**
|
|
25
|
+
* Direct TCP connection string for the shadow database, used by
|
|
26
|
+
* `prisma migrate`.
|
|
27
|
+
*
|
|
28
|
+
* Defaults to `SHADOW_DATABASE_URL`.
|
|
29
|
+
*/
|
|
30
|
+
shadowDatabaseUrl?: false | string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The running database, handed to {@link PrismaDevPluginOptions.onDatabaseReady}.
|
|
35
|
+
*/
|
|
36
|
+
interface PrismaDevDatabase {
|
|
37
|
+
/**
|
|
38
|
+
* Direct TCP connection string for the main database.
|
|
39
|
+
*/
|
|
40
|
+
readonly databaseUrl: string;
|
|
41
|
+
/**
|
|
42
|
+
* The variables this plugin manages, mapped to the local database, ready to
|
|
43
|
+
* spread into a subprocess environment.
|
|
44
|
+
*
|
|
45
|
+
* These always describe the local database, even for a variable the plugin
|
|
46
|
+
* declined to write because the environment already defined it. That matters:
|
|
47
|
+
* without `overrideExistingEnv`, an `.env` pointing `DATABASE_URL` at a
|
|
48
|
+
* deployed database is left alone, so a migration inheriting the ambient
|
|
49
|
+
* `process.env` would run against that deployed database. Spreading this
|
|
50
|
+
* instead keeps the migration local whatever `overrideExistingEnv` is set to.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* await execa("prisma", ["migrate", "deploy"], { env: { ...process.env, ...database.env } });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Variables disabled through the `env` option are absent here.
|
|
57
|
+
*/
|
|
58
|
+
readonly env: Readonly<Record<string, string>>;
|
|
59
|
+
/**
|
|
60
|
+
* The server name, matching the `name` option.
|
|
61
|
+
*/
|
|
62
|
+
readonly name: string;
|
|
63
|
+
/**
|
|
64
|
+
* Whether this process started the database, as opposed to attaching to one
|
|
65
|
+
* that `prisma dev` was already running.
|
|
66
|
+
*/
|
|
67
|
+
readonly owned: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The `prisma+postgres://` HTTP connection string. Carries an API key.
|
|
70
|
+
*/
|
|
71
|
+
readonly prismaPostgresUrl: string;
|
|
72
|
+
/**
|
|
73
|
+
* Direct TCP connection string for the shadow database, which
|
|
74
|
+
* `prisma migrate dev` requires.
|
|
75
|
+
*/
|
|
76
|
+
readonly shadowDatabaseUrl: string;
|
|
77
|
+
}
|
|
78
|
+
interface PrismaDevPluginOptions {
|
|
79
|
+
/**
|
|
80
|
+
* The port the database server listens on.
|
|
81
|
+
*
|
|
82
|
+
* Defaults to `51214`, falling back to another free port when taken.
|
|
83
|
+
*/
|
|
84
|
+
databasePort?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Whether to log the runtime's own debug output.
|
|
87
|
+
*
|
|
88
|
+
* Defaults to `false`.
|
|
89
|
+
*/
|
|
90
|
+
debug?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Boot a database when the config is loaded by Vitest.
|
|
93
|
+
*
|
|
94
|
+
* Defaults to `false`. Vitest reads `vite.config.ts`, so leaving this off
|
|
95
|
+
* keeps a plain test run from starting a database as a config side effect.
|
|
96
|
+
*/
|
|
97
|
+
enableInTest?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Which environment variables to write, and under what names.
|
|
100
|
+
*/
|
|
101
|
+
env?: PrismaDevEnvOptions;
|
|
102
|
+
/**
|
|
103
|
+
* Name of the server, which determines where its data is persisted.
|
|
104
|
+
*
|
|
105
|
+
* Defaults to `default`. Set this per project to keep data isolated.
|
|
106
|
+
*/
|
|
107
|
+
name?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Prepares the database before Vite finishes starting, typically by applying
|
|
110
|
+
* migrations and seeding.
|
|
111
|
+
*
|
|
112
|
+
* Runs after the environment variables have been written, and before any
|
|
113
|
+
* application or framework code has executed, so nothing can observe an
|
|
114
|
+
* unprepared database. `vite dev` waits for it, so a slow migration delays
|
|
115
|
+
* startup.
|
|
116
|
+
*
|
|
117
|
+
* Runs on every start, including a config restart and the case where the
|
|
118
|
+
* plugin attached to a database `prisma dev` already had running. Make it
|
|
119
|
+
* idempotent -- `prisma migrate deploy` already is.
|
|
120
|
+
*
|
|
121
|
+
* If it rejects, the database is shut down and Vite fails to start rather than
|
|
122
|
+
* serving against a half-prepared database.
|
|
123
|
+
*
|
|
124
|
+
* Prefer `database.env` over the ambient `process.env` when spawning a
|
|
125
|
+
* subprocess. See {@link PrismaDevDatabase.env} for why.
|
|
126
|
+
*/
|
|
127
|
+
onDatabaseReady?: (this: void, database: PrismaDevDatabase) => Promise<void> | void;
|
|
128
|
+
/**
|
|
129
|
+
* Whether the database survives between runs.
|
|
130
|
+
*
|
|
131
|
+
* Defaults to `stateful`: data is persisted under `name` and survives dev
|
|
132
|
+
* server restarts.
|
|
133
|
+
*
|
|
134
|
+
* `stateless` keeps the database in memory and discards it on every shutdown,
|
|
135
|
+
* which gives a clean database on each start. Useful with `enableInTest`. Be
|
|
136
|
+
* aware that editing `vite.config.ts` or an `.env` file restarts the dev
|
|
137
|
+
* server, so it also discards the data.
|
|
138
|
+
*
|
|
139
|
+
* A `stateless` database is invisible to `prisma dev ls`, cannot be shared with
|
|
140
|
+
* a running `prisma dev`, and takes any free port rather than the documented
|
|
141
|
+
* defaults unless you set the port options explicitly.
|
|
142
|
+
*/
|
|
143
|
+
persistenceMode?: PersistenceMode;
|
|
144
|
+
/**
|
|
145
|
+
* Overwrite environment variables that already hold a value.
|
|
146
|
+
*
|
|
147
|
+
* Defaults to `false`, so an existing `.env` entry or shell export wins and
|
|
148
|
+
* the plugin logs a warning instead.
|
|
149
|
+
*/
|
|
150
|
+
overrideExistingEnv?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* The port the Prisma Dev HTTP server listens on.
|
|
153
|
+
*
|
|
154
|
+
* Defaults to `51213`, falling back to another free port when taken.
|
|
155
|
+
*/
|
|
156
|
+
port?: number;
|
|
157
|
+
/**
|
|
158
|
+
* The port the shadow database server listens on.
|
|
159
|
+
*
|
|
160
|
+
* Defaults to `51215`, falling back to another free port when taken.
|
|
161
|
+
*/
|
|
162
|
+
shadowDatabasePort?: number;
|
|
163
|
+
/**
|
|
164
|
+
* The port the colocated Prisma Streams server listens on.
|
|
165
|
+
*
|
|
166
|
+
* Defaults to `51216`, falling back to another free port when taken.
|
|
167
|
+
*/
|
|
168
|
+
streamsPort?: number;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Runs a local Prisma Postgres database for the lifetime of the Vite dev server
|
|
172
|
+
* and exposes its connection strings through `process.env`.
|
|
173
|
+
*
|
|
174
|
+
* The database runs in the Vite process, so it cannot outlive it. Production
|
|
175
|
+
* builds and `vite preview` are unaffected.
|
|
176
|
+
*
|
|
177
|
+
* Connection strings are never exposed to client code. They are written to
|
|
178
|
+
* `process.env` only, which is what server-side code and Prisma Client read.
|
|
179
|
+
* Routing them through `define` or `import.meta.env` would inline database
|
|
180
|
+
* credentials into browser assets.
|
|
181
|
+
*/
|
|
182
|
+
declare function prismaDev(options?: PrismaDevPluginOptions): Plugin;
|
|
183
|
+
|
|
184
|
+
export { type PrismaDevDatabase, type PrismaDevEnvOptions, type PrismaDevPluginOptions, prismaDev as default, prismaDev };
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-MTR5KBPH.js";import"./chunk-662IKR3V.js";import"./chunk-PP43TGA5.js";import"./chunk-KWCQYPJI.js";import{h as y,i as b,l as w}from"./chunk-HFONW2ZS.js";import"./chunk-ANHBRJRZ.js";import"./chunk-EDFHV3AK.js";import"./chunk-DWY47FQV.js";import"./chunk-DOJAPHLY.js";var M="DATABASE_URL",I="SHADOW_DATABASE_URL";function P(e){return{databaseUrl:e.database.prismaORMConnectionString??e.database.connectionString,prismaPostgresUrl:e.ppg.url,shadowDatabaseUrl:e.shadowDatabase.prismaORMConnectionString??e.shadowDatabase.connectionString}}function A(e,r={}){let{databaseUrl:n=M,prismaPostgresUrl:a=!1,shadowDatabaseUrl:s=I}=r,t=P(e);return[[n,t.databaseUrl],[s,t.shadowDatabaseUrl],[a,t.prismaPostgresUrl]].filter(d=>typeof d[0]=="string"&&d[0].length>0).map(([d,i])=>({name:d,value:i}))}function x(e,r,n={}){let a=[],s=[];for(let t of e){let o=r[t.name];if(!n.override&&o!=null&&o!==""){s.push(t);continue}r[t.name]=t.value,a.push(t)}return{applied:a,skipped:s}}import{setTimeout as C}from"timers/promises";var N="default",k=15e3,B=250;async function R(e){let{lockRetryTimeoutMillis:r=k,persistenceMode:n="stateful",...a}=e??{};if(n==="stateless"){let{server:t}=await f({...a,persistenceMode:n});return h(t)}let s=Date.now()+r;for(;;)try{let{server:t}=await f({...a,persistenceMode:"stateful"});return h(t)}catch(t){if(!(t instanceof w))throw t;let o=await V(a.name,a.debug);if(o)return o;if(Date.now()>=s)throw t;await C(B)}}function h(e){return{close:()=>e.close(),database:e.database,http:e.http,name:e.name,owned:!0,ppg:e.ppg,server:e,shadowDatabase:e.shadowDatabase}}async function V(e,r){let n=await y(e??N,{debug:r});return!b(n)||!n.exports?null:{...n.exports,close:()=>Promise.resolve(),experimental:n.experimental,name:n.name,owned:!1}}var l=new Map;async function U(e){let{name:r}=e;await D(r);let n=R(e);l.set(r,n);let a;try{a=await n}catch(s){throw l.get(r)===n&&l.delete(r),s}return{release:async()=>{l.get(r)===n&&await D(r)},server:a}}async function E(){await Promise.allSettled([...l.keys()].map(e=>D(e)))}async function D(e){let r=l.get(e);if(!r)return;l.delete(e),await(await r).close()}var q=["SIGINT","SIGTERM"],O=!1;function T(){if(!O){O=!0,process.once("beforeExit",()=>{E()});for(let e of q)process.once(e,()=>{E().finally(()=>{process.kill(process.pid,e)})})}}var u="prisma-dev",$="default",G={info:e=>console.info(e),warn:e=>console.warn(e)};function F(e={}){let{debug:r,enableInTest:n=!1,env:a,name:s=$,onDatabaseReady:t,overrideExistingEnv:o=!1,persistenceMode:d="stateful"}=e,i=null;return{apply(m,v){return v.command==="serve"&&v.isPreview!==!0&&(n||!H())},async config(m){let v=m.customLogger??G;T(),i=await U({databasePort:e.databasePort,debug:r,name:s,persistenceMode:d,port:e.port,shadowDatabasePort:e.shadowDatabasePort,streamsPort:e.streamsPort});let S=A(i.server,a),{applied:L,skipped:_}=x(S,process.env,{override:o});return Y(v,i.server,L.length,_),t&&await K(t,W(i.server,S),v,g),{}},async closeBundle(){await g()},configureServer(m){m.httpServer?.once("close",()=>{g()})},name:u};async function g(){let m=i;i=null,await m?.release()}}var me=F;function W(e,r){return{...P(e),env:Object.fromEntries(r.map(({name:n,value:a})=>[n,a])),name:e.name,owned:e.owned}}async function K(e,r,n,a){try{await e(r)}catch(s){throw n.warn(`[${u}] \`onDatabaseReady\` failed, shutting the database down`,{timestamp:!0}),await a(),s}}function H(){return process.env.VITEST!=null||process.env.VITEST_WORKER_ID!=null}function Y(e,r,n,a){let s=r.owned?"started":"attached to already-running";e.info(`[${u}] ${s} database "${r.name}", set ${n} environment variable(s)`,{timestamp:!0});for(let{name:t}of a)e.warn(`[${u}] ${t} is already set, leaving it untouched. Pass \`overrideExistingEnv: true\` to let the local database win.`,{timestamp:!0})}export{me as default,F as prismaDev};
|
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.202607271058",
|
|
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)",
|
|
@@ -50,6 +50,16 @@
|
|
|
50
50
|
"types": "./dist/state.d.cts",
|
|
51
51
|
"default": "./dist/state.cjs"
|
|
52
52
|
}
|
|
53
|
+
},
|
|
54
|
+
"./vite": {
|
|
55
|
+
"import": {
|
|
56
|
+
"types": "./dist/vite.d.ts",
|
|
57
|
+
"default": "./dist/vite.js"
|
|
58
|
+
},
|
|
59
|
+
"require": {
|
|
60
|
+
"types": "./dist/vite.d.cts",
|
|
61
|
+
"default": "./dist/vite.cjs"
|
|
62
|
+
}
|
|
53
63
|
}
|
|
54
64
|
},
|
|
55
65
|
"keywords": [
|
|
@@ -62,30 +72,40 @@
|
|
|
62
72
|
"testing"
|
|
63
73
|
],
|
|
64
74
|
"license": "ISC",
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
77
|
+
},
|
|
78
|
+
"peerDependenciesMeta": {
|
|
79
|
+
"vite": {
|
|
80
|
+
"optional": true
|
|
81
|
+
}
|
|
82
|
+
},
|
|
65
83
|
"devDependencies": {
|
|
66
84
|
"@arethetypeswrong/cli": "0.18.2",
|
|
85
|
+
"@electric-sql/pglite-prepopulatedfs": "0.0.3",
|
|
67
86
|
"@types/node": "25.0.9",
|
|
68
87
|
"@types/pako": "2.0.4",
|
|
88
|
+
"@types/pg": "8.15.6",
|
|
69
89
|
"@types/proper-lockfile": "4.1.4",
|
|
70
90
|
"env-paths": "3.0.0",
|
|
91
|
+
"pg": "8.16.0",
|
|
71
92
|
"pkg-types": "2.3.0",
|
|
72
93
|
"tsup": "8.5.1",
|
|
73
94
|
"typescript": "5.9.3",
|
|
95
|
+
"vite": "8.1.5",
|
|
74
96
|
"vitest": "4.0.17",
|
|
75
97
|
"common-stuff": "^0.0.0"
|
|
76
98
|
},
|
|
77
99
|
"dependencies": {
|
|
78
|
-
"@electric-sql/pglite": "0.3
|
|
79
|
-
"@electric-sql/pglite-socket": "0.
|
|
80
|
-
"@electric-sql/pglite-tools": "0.
|
|
81
|
-
"@hono/node-server": "1.19.9",
|
|
82
|
-
"@mrleebo/prisma-ast": "0.13.1",
|
|
100
|
+
"@electric-sql/pglite": "0.4.3",
|
|
101
|
+
"@electric-sql/pglite-socket": "0.1.3",
|
|
102
|
+
"@electric-sql/pglite-tools": "0.3.3",
|
|
83
103
|
"@prisma/get-platform": "7.2.0",
|
|
84
104
|
"@prisma/query-plan-executor": "7.2.0",
|
|
105
|
+
"@prisma/streams-local": "0.1.11",
|
|
106
|
+
"find-my-way": "9.7.0",
|
|
85
107
|
"foreground-child": "3.3.1",
|
|
86
108
|
"get-port-please": "3.2.0",
|
|
87
|
-
"hono": "4.11.4",
|
|
88
|
-
"http-status-codes": "2.3.0",
|
|
89
109
|
"pathe": "2.0.3",
|
|
90
110
|
"proper-lockfile": "4.1.2",
|
|
91
111
|
"remeda": "2.33.4",
|
|
@@ -94,11 +114,13 @@
|
|
|
94
114
|
"zeptomatch": "2.1.0"
|
|
95
115
|
},
|
|
96
116
|
"scripts": {
|
|
97
|
-
"build": "tsup",
|
|
117
|
+
"build": "node ./scripts/generate-bun-runtime-assets.mjs && tsup && node ./scripts/generate-bun-runtime-assets.mjs --dist",
|
|
98
118
|
"check:exports": "attw . --pack --profile node16",
|
|
99
|
-
"dev": "tsup --watch",
|
|
119
|
+
"dev": "node ./scripts/generate-bun-runtime-assets.mjs && tsup --watch",
|
|
120
|
+
"init": "node ./scripts/generate-bun-runtime-assets.mjs",
|
|
100
121
|
"lint": "eslint --fix .",
|
|
101
|
-
"test": "",
|
|
102
|
-
"
|
|
122
|
+
"test": "node ./scripts/generate-bun-runtime-assets.mjs && vitest run",
|
|
123
|
+
"test:e2e": "node ./scripts/generate-bun-runtime-assets.mjs && vitest run e2e.test",
|
|
124
|
+
"typecheck": "node ./scripts/generate-bun-runtime-assets.mjs && tsc --noEmit"
|
|
103
125
|
}
|
|
104
126
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as i,d as x,e as d}from"./chunk-7NDL3ECU.js";import"./chunk-ITQ6ILGR.js";import{HTTPException as re}from"hono/http-exception";import{Hono as ae}from"hono/tiny";import{validator as c}from"hono/validator";import{array as L,literal as k,minLength as B,object as U,pipe as N,safeParse as D,string as F,union as Q}from"valibot";var X=U({tags:Q([N(L(F()),B(1)),k("all")])});async function E(e){let{output:n,success:t}=D(X,await e.req.json(),{abortEarly:!0});return t?n:e.text("Invalid input",400)}import{parseDuration as v,parseSize as Y,Server as z}from"@prisma/query-plan-executor";import{version as P}from"@prisma/query-plan-executor";var T;async function O(e){return T===void 0&&(T=await z.create({databaseUrl:e.get("db").connectionString,maxResponseSize:Y("128 MiB"),queryTimeout:v("PT5M"),maxTransactionTimeout:v("PT5M"),maxTransactionWaitTime:v("PT5M"),perRequestLogContext:{logFormat:"text",logLevel:e.get("debug")?"debug":"off"}})),T}import{Buffer as I}from"buffer";import{getSchema as G,printSchema as W}from"@mrleebo/prisma-ast";var l=new Map;async function H(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}function C(e){let n=e.req.param("schemaHash"),t=l.get(n);return t==null?e.json({EngineNotStarted:{reason:"SchemaMissing"}},404):{schemaHash:n,schemas:t}}async function R(e,n,t){let r=I.from(e,"base64").toString("utf8"),a=G(r),o=a.list.find(f=>f.type==="datasource");if(!o)throw new Error("No datasource block found in schema.");let s=o.assignments.find(f=>f.type==="assignment"&&f.key==="url");s?s.value=`"${n.toString()}"`:o.assignments.push({key:"url",type:"assignment",value:`"${n.toString()}"`});let m=W(a);t&&console.log("[Accelerate] schema with override:",m);let S=await H(m);return{base64Override:I.from(m,"utf8").toString("base64"),overrideHash:S}}function g(e){let{req:n}=e;return{traceparent:n.header("traceparent"),"X-capture-telemetry":n.header("X-capture-telemetry")}}import{integer as q,looseObject as K,minValue as A,number as w,object as J,optional as Z,pipe as _,safeParse as M,string as $,union as ee}from"valibot";var te=J({isolation_level:Z($()),max_wait:_(w(),q(),A(0)),timeout:_(w(),q(),A(0))});async function V(e){let{issues:n,output:t,success:r}=M(te,await e.req.json(),{abortEarly:!0});return r?t:e.json({EngineNotStarted:{reason:"InvalidRequest",issues:n}},400)}var ne=K({id:ee([$(),w()])});function j(e,n){let{output:t,success:r}=M(ne,e);return r?t:n.json({EngineMalfunction:{}},500)}var y=new ae;y.post("/invalidate",c("header",i),async e=>{let n=await E(e);return n instanceof Response?n:e.body(null)});var oe="/:clientVersion/:schemaHash",h=y.basePath(oe);y.route("/",h);var se=["/graphql","/itx/:transactionId/graphql"];h.on("POST",[...se],c("header",i),async e=>{let{req:n}=e;try{let t=await b(e);if(t instanceof Response)return t;let r=await n.text(),a=n.param("transactionId"),o=await t.request(r,{...g(e),"X-transaction-id":a});return e.text(o)}catch(t){return d(t,e)}});h.basePath("/itx/:transactionId").on("POST",["/commit","/rollback"],c("header",i),async e=>{let{req:n}=e;try{let t=await b(e);if(t instanceof Response)return t;let a=`${n.routePath.split("/").filter(Boolean).at(-1)}Transaction`,o=n.param("transactionId"),s=await t[a](o,g(e));return e.json(s)}catch(t){return d(t,e)}});h.put("/schema",c("header",i),async e=>{let{req:n}=e,t=await n.text();if(!t)return e.text("Missing schema",400);let r=n.param("schemaHash"),a=l.get(r);if(a==null){if(r!==await H(t))return e.text("Schema hash mismatch",400);let o=await R(t,e.get("db").prismaORMConnectionString,e.get("debug"));return l.set(r,{base64Original:t,...o}),e.text(r)}return t!==a.base64Original?e.text("Schema mismatch",400):e.text(r)});h.post("/transaction/start",c("header",i),async e=>{let{req:n}=e,t=await V(e);if(t instanceof Response)return t;try{let r=await b(e);if(r instanceof Response)return r;let a=await r.startTransaction(t,g(e)),o=j(a,e);if(o instanceof Response)return o;let{id:s}=o,m=n.param("clientVersion"),S=n.param("schemaHash");return e.json({...a,"data-proxy":{endpoint:`${new URL(n.url).origin}/${m}/${S}/itx/${s}`}})}catch(r){return d(r,e)}});async function b(e){let{req:n}=e,t=C(e);if(t instanceof Response)return t;let{base64Override:r,overrideHash:a}=t.schemas;return await x.get({base64Schema:r,clientVersion:process.env.PRISMA_DEV_FORCE_CLIENT_VERSION||n.param("clientVersion"),debug:e.get("debug"),platform:e.get("platform"),schemaHash:a})}var ie=[["/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 ie)y.on(n,e,c("header",i),async t=>{let r=t.req.header("prisma-engine-hash");if(r!=="0.0.0"&&r!==P)throw new re(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 ${P}.`});return await(await O(t)).fetch(t.req.raw)});export{y as accelerateRoute};
|
package/dist/chunk-7NDL3ECU.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as P,c as b,d as v}from"./chunk-ITQ6ILGR.js";import{minLength as B,object as j,optional as K,parseJson as L,pipe as y,regex as R,safeParse as _,string as w,url as A}from"valibot";var S=/^(postgres|postgresql):\/\//,N=y(w(),L(),j({databaseUrl:y(w(),A(),R(S)),name:K(y(w(),B(1))),shadowDatabaseUrl:y(w(),A(),R(S))}));function Y(r){return Buffer.from(JSON.stringify(Object.fromEntries(Object.entries(r).sort(([[e],[n]])=>e.localeCompare(n)))),"utf8").toString("base64url")}function Q(r){let e=Buffer.from(r,"base64url").toString("utf8"),{issues:n,output:s,success:t}=_(N,e,{abortEarly:!0});return t?[null,s]:[n]}var X=async(r,e)=>{let{authorization:n}=r,{HTTPException:s}=await import("hono/http-exception");if(!n)throw new s(401,{message:"Missing API Key"});let[t,o="",i]=n.split(" ");if(t!=="Bearer"||i)throw new s(401,{message:"Invalid API Key"});let[a,m]=Q(o);if(a)throw new s(401,{message:"Invalid API Key",cause:a.join(", ")});let{databaseUrl:h,name:c,shadowDatabaseUrl:d}=m,l=e.get("name"),g=new URL(e.req.url).port;if(!c)throw new s(401,{message:`Wrong API Key; The Prisma Dev server running at port ${g} requires an API Key from a newer version of \`prisma dev\`. Check the "${l}" server's output for the updated \`DATABASE_URL\` value.`});if(c!==l)throw new s(401,{message:`Wrong API Key; The Prisma Dev server running at port ${g} is named "${l}", but the API Key is for "${c}"`});let{hostname:f,port:E}=new URL(h),{port:$}=e.get("db"),{hostname:C,port:D}=new URL(d),H=e.get("shadowDBPort");if(f!=="localhost"||Number(E)!==$||C!=="localhost"||Number(D)!==H)throw new s(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:m}};import{spawn as U}from"child_process";import{once as F}from"events";import{mkdir as V}from"fs/promises";import{join as q}from"path";import{setTimeout as z}from"timers/promises";function O(r){let e,n,s=new Promise((i,a)=>{e=i,n=a}),t=i=>{t=o=null,n(i),r?.onRejected?.(i),r?.onFulfilled?.()},o=i=>{o=t=null,e(i),r?.onResolved?.(i),r?.onFulfilled?.()};return{isFulfilled:()=>o===t,promise:s,reject:i=>t?.(i),resolve:i=>o?.(i)}}import{process as M}from"std-env";var{PRISMA_DEV_FORCE_ENGINE_BINARY_DOWNLOAD:J,PRISMA_DEV_FORCE_ENGINE_BINARY_PATH:G,PRISMA_DEV_FORCE_NETWORK_DELAY_MS:I}=M.env,x=class r{static#t=new Map;#e;#n;constructor(e){this.#e=e,this.#n=null}static async get(e){let{debug:n}=e,s=`${e.schemaHash}:${e.clientVersion}`;try{let t=r.#t.get(s);if(t)return t;let o=new r(e);return r.#t.set(s,o),n&&console.debug("[Query Engine] starting...",e),await o.start(),n&&console.debug("[Query Engine] started!"),o}finally{r.stopAll(s)}}static async stopAll(e){let s=(await Promise.allSettled(Array.from(r.#t.entries()).filter(([t])=>t!==e).map(async([t,o])=>{try{await o.stop()}finally{r.#t.delete(t)}}))).filter(t=>t.status==="rejected").map(t=>t.reason);if(s.length>0)throw new AggregateError(s,"Failed to stop engines")}async commitTransaction(e,n){return await this.#i(e,n,"commit")}async request(e,n){let{url:s}=await this.start(),t=this.#s(n),o=await fetch(s,{body:typeof e=="string"?e:JSON.stringify(e),headers:{...t,"Content-Type":"application/json"},method:"POST"});if(!o.ok)throw await u.fromResponse(o);return await o.text()}async rollbackTransaction(e,n){return await this.#i(e,n,"rollback")}async startTransaction(e,n){let{url:s}=await this.start(),t=this.#s(n),o=await fetch(`${s}/transaction/start`,{body:JSON.stringify(e),headers:{...t,"Content-Type":"application/json"},method:"POST"});if(!o.ok)throw await u.fromResponse(o);return await o.json()}async start(){if(this.#n!=null)return await this.#n;let{promise:e,reject:n,resolve:s}=O();this.#n=e;let t=G||await this.#o();this.#e.debug&&console.debug("[Query Engine] spinning up at path...",t);let{proxySignals:o}=await import("foreground-child/proxy-signals"),i=U(t,["--enable-raw-queries","--enable-telemetry-in-response","--port","0"],{env:{LOG_QUERIES:"y",PRISMA_DML:this.#e.base64Schema,QE_LOG_LEVEL:"TRACE",RUST_BACKTRACE:"1",RUST_LOG:"info"},stdio:["ignore","pipe","pipe"],windowsHide:!0});o(i),i.stderr.setEncoding("utf8"),i.stdout.setEncoding("utf8");let a=c=>{let d=c.split(`
|
|
2
|
-
`).find(E=>E.includes("Started query engine http server"));if(!d)return;i.stdout.removeListener("data",a);let{fields:l}=JSON.parse(d);if(l==null)return n(new Error(`Unexpected data during initialization, "fields" are missing: ${c}`));let{ip:g,port:f}=l;if(g==null||f==null)return n(new Error(`This version of query-engine is not compatible with minippg, "ip" and "port" are missing in the startup log entry.
|
|
3
|
-
Received data: ${c}`));s({childProcess:i,url:`http://${g}:${f}`})},m=c=>{this.#n=null,n(new p(String(c))),i.removeListener("exit",h),i.kill()};i.once("error",m);let h=(c,d)=>{this.#n=null,n(new p(`Query Engine exited with code ${c} and signal ${d}`))};return i.once("exit",h),i.stdout.on("data",a),this.#e.debug&&(i.stderr.on("data",console.error.bind(console,"[Query Engine]")),i.stdout.on("data",console.debug.bind(console,"[Query Engine]"))),await this.#n}async stop(){if(this.#n==null)return;let{childProcess:e}=await this.#n;e.exitCode==null&&e.signalCode==null&&(this.#n=null,e.kill(),await F(e,"exit"))}async#o(){this.#e.debug&&console.debug("[Query Engine] getting engine commit hash...");let e=await this.#r();this.#e.debug&&console.debug("[Query Engine] got engine commit hash",e);let n=P(this.#e.clientVersion,e);this.#e.debug&&console.debug("[Query Engine] cache directory path",n),await V(n,{recursive:!0});let{binaryTarget:s}=this.#e.platform,t=s==="windows"?".exe":"",o=q(n,`query-engine-${s}${t}`);return this.#e.debug&&console.debug("[Query Engine] binary path",o),(J==="1"||await b(o)===!1)&&await this.#a({commitHash:e,extension:t,engineBinaryPath:o}),o}async#r(){let e=await fetch(`https://registry.npmjs.org/@prisma/client/${this.#e.clientVersion}`);if(!e.ok)throw new Error(`Couldn't fetch package.json from npm registry, status code: ${e.status}`);let s=(await e.json()).devDependencies?.["@prisma/engines-version"];if(!s)throw new Error("Couldn't find engines version in package.json");let t=s.split(".").at(-1);if(!t)throw new Error("Couldn't find commit hash in engines version");return t}async#a(e){let{commitHash:n,extension:s,engineBinaryPath:t}=e,{binaryTarget:o}=this.#e.platform,i=`https://binaries.prisma.sh/all_commits/${n}/${o}/query-engine${s}.gz`;this.#e.debug&&console.debug("[Query Engine] downloading engine from url",i);let a=await fetch(i);if(!a.ok)throw new Error(`Couldn't download engine. URL: ${i}, status code: ${a.status}`);I&&await z(Number(I)),await v(await a.arrayBuffer(),t),this.#e.debug&&console.debug("[Query Engine] downloaded and saved at",t)}#s(e){let n={};for(let[s,t]of Object.entries(e))t!=null&&(n[s]=t);return n}async#i(e,n,s){let{url:t}=await this.#n,o=this.#s(n),i=await fetch(`${t}/transaction/${e}/${s}`,{headers:{...o,"Content-Type":"application/json"},method:"POST"});if(!i.ok)throw await u.fromResponse(i);try{return await i.json()}catch{return{}}}};function ue(r,e){return console.error(r),r instanceof p?e.json({EngineNotStarted:{reason:{EngineStartupError:{logs:[],msg:r.message}}}},500):r instanceof u?e.text(r.responseBody,r.statusCode):e.body(null,500)}var p=class extends Error{name="EngineStartError"},u=class r extends Error{constructor(n,s,t){super(`${n}: Query Engine response status ${s}, body: ${t}`);this.action=n;this.statusCode=s;this.responseBody=t}name="EngineHttpError";static async fromResponse(n){let s=new URL(n.url),t=await n.text();return new r(s.pathname,n.status,t)}};export{Y as a,X as b,O as c,x as d,ue as e};
|
package/dist/chunk-LKYVOPH3.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{d as h,e as f,f as y}from"./chunk-OTI5SWIV.js";import{b as l,f as O,g as V,h as N,i as C}from"./chunk-ITQ6ILGR.js";import{writeFile as Q}from"fs/promises";import{join as c}from"pathe";import{check as W,lock as X,unlock as ee}from"proper-lockfile";import{process as j}from"std-env";import{integer as F,literal as te,minLength as re,minValue as q,number as H,object as v,optional as g,parseJson as se,pipe as m,safeParse as ae,string as w,url as oe}from"valibot";import{setTimeout as z}from"timers/promises";import{process as P}from"std-env";function x(r,e){if(r==null)return!1;try{return P.kill?.(r,0)??!0}catch(t){return e&&console.error(`Error checking if process with PID ${r} exists:`,t),!1}}async function A(r,e){if(!P.kill)return!1;try{P.kill(r,"SIGTERM")}catch(s){return e&&console.error(`Error killing process with PID ${r}:`,s),!1}let t=0;do{if(!x(r,e))return!0;await z(100)}while(++t<50);try{return P.kill(r,"SIGKILL")}catch(s){return e&&console.error(`Error forcefully killing process with PID ${r}:`,s),!1}}var _=m(w(),oe()),L=v({connectionString:_,prismaORMConnectionString:g(_),terminalCommand:g(w())}),J=v({url:_}),M=m(H(),F(),q(1)),ie=v({database:L,http:J,ppg:J,shadowDatabase:L}),ne=v({databasePort:M,exports:g(ie),name:m(w(),re(1)),pid:g(m(H(),F(),q(0))),port:M,shadowDatabasePort:M,version:te("1")}),E=Symbol("initialize"),k="default",u=class{_databasePort;databaseConnectTimeoutMillis;databaseIdleTimeoutMillis;debug;dryRun;name;persistenceMode;pid;shadowDatabaseConnectTimeoutMillis;shadowDatabaseIdleTimeoutMillis;_port;_shadowDatabasePort;constructor(e){this._databasePort=e.databasePort??f,this.databaseConnectTimeoutMillis=e.databaseConnectTimeoutMillis??6e4,this.databaseIdleTimeoutMillis=e.databaseIdleTimeoutMillis??1/0,this.debug=e.debug??!1,this.dryRun=e.dryRun??!1,this.name=e.name??k,this.persistenceMode=e.persistenceMode,this.pid=e.pid??j.pid,this.shadowDatabaseConnectTimeoutMillis=e.shadowDatabaseConnectTimeoutMillis??this.databaseConnectTimeoutMillis,this.shadowDatabaseIdleTimeoutMillis=e.shadowDatabaseIdleTimeoutMillis??this.databaseIdleTimeoutMillis,this._port=e.port??f,this._shadowDatabasePort=e.shadowDatabasePort??f}static async createExclusively(e){let t=e?.dryRun!==!0&&e?.persistenceMode==="stateful"?new p(e):new I(e);return await t[E](),t}static async fromServerDump(e){let{debug:t,name:s=k}=e??{},o=l(s),i=p.getServerDumpPath(o),a=await O(i);if(a==null)return t&&console.debug(`[State] No server dump file found at: ${i}`),null;t&&(console.debug(`[State] server dump file found at "${i}":`),console.debug(a));let{issues:n,output:d,success:b}=ae(m(w(),se(),ne),a);if(!b)throw t&&console.debug(`[State] Invalid server dump file at "${i}":
|
|
2
|
-
${JSON.stringify(n,null,2)}`),new Error(`Invalid Prisma Dev state for "${s}".`);return new p({databasePort:d.databasePort,debug:t,dryRun:!1,name:s,pid:d.pid,port:d.port,serverDump:d,shadowDatabasePort:d.shadowDatabasePort})}static async scan(e){let{debug:t,globs:s}=e??{},o=c(l(k),"..");t&&console.debug(`[State] scanning for server states in: ${o}`);let i=await N(o,s);return t&&console.debug(`[State] found server names: ${JSON.stringify(i)}`),await Promise.all(i.map(a=>K(a,e)))}get databasePort(){return this._databasePort}set databasePort(e){this.#t("databasePort",e)}get port(){return this._port}set port(e){this.#t("port",e)}get shadowDatabasePort(){return this._shadowDatabasePort}set shadowDatabasePort(e){this.#t("shadowDatabasePort",e)}#t(e,t){if(t<0||!Number.isInteger(t))throw new Error(`Invalid port number: ${t}`);let s=`_${e}`;if(this[s]!==h&&this[s]!==t)throw new Error(`\`${e}\` is already set to ${this[s]}, cannot change it to ${t}`);this[s]=t}},I=class extends u{constructor(e){super({...e,databasePort:e?.databasePort||h,persistenceMode:"stateless",port:e?.port||h,shadowDatabasePort:e?.shadowDatabasePort||h})}get databaseDumpPath(){return"<DUMP_PATH>"}get pgliteDataDirPath(){return"memory://"}async[E](){let e;try{e=await u.scan({debug:this.debug,onlyMetadata:!0})}catch(s){this.debug&&console.warn("[State] failed to scan for existing servers, assuming filesystem does not exist or other reasons.",s),e=[]}let t=await y({debug:this.debug,name:this.dryRun?this.name:"",requestedPorts:{databasePort:this.databasePort,port:this.port,shadowDatabasePort:this.shadowDatabasePort},servers:e});this._databasePort=t.databasePort,this._port=t.port,this._shadowDatabasePort=t.shadowDatabasePort}async close(){}async writeServerDump(){}},p=class r extends u{#t;#e;#s;#o;#i;#a;#r;constructor(e){super({...e,persistenceMode:"stateful"}),this.#a=!1,this.#e=l(this.name),this.#t=c(this.#e,"db_dump.bak"),this.#s=c(this.#e,".lock"),this.#o=c(this.#e,".pglite"),this.#r=e?.serverDump??null,this.#i=r.getServerDumpPath(this.#e)}static getServerDumpPath(e){return c(e,"server.json")}get databaseDumpPath(){return this.#t}get exports(){return this.#r?.exports}get pgliteDataDirPath(){return this.#o}async[E](){await V(this.#e),this.debug&&console.debug(`[State] using data directory: ${this.#e}`);try{await X(this.#e,{lockfilePath:this.#s}),this.debug&&console.debug(`[State] obtained lock on: ${this.#e}`);let e=await u.scan({debug:this.debug,onlyMetadata:!0}),t=await y({debug:this.debug,name:this.name,requestedPorts:{databasePort:this.databasePort,port:this.port,shadowDatabasePort:this.shadowDatabasePort},servers:e});this._databasePort=t.databasePort,this._port=t.port,this._shadowDatabasePort=t.shadowDatabasePort,await this.writeServerDump()}catch(e){throw e instanceof Error&&"code"in e&&e.code==="ELOCKED"?new T(this):e}}async close(){if(!this.#a)try{await ee(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:j.pid,port:this.port,databasePort:this.databasePort,shadowDatabasePort:this.shadowDatabasePort,exports:e},await Q(this.#i,`${JSON.stringify(this.#r,null,2)}
|
|
3
|
-
`,{encoding:"utf-8"})}};async function Se(r,e){await de(r,e);let t=l(typeof r=="string"?r:r.name);await C(t)}async function K(r,e){let{debug:t,onlyMetadata:s}=e||{},o=typeof r=="string"?r:r.name,i=typeof r!="string"?r:void 0,a={databasePort:i?.databasePort??-1,exports:i?.exports,name:o,pid:i?.pid,port:i?.port??-1,shadowDatabasePort:i?.shadowDatabasePort??-1,version:"1"};try{let n=i||await u.fromServerDump({debug:t,name:o});if(!n)return t&&console.debug(`[State] no server state found for name: ${o}`),{...a,status:"no_such_server"};a.databasePort=n.databasePort,a.exports=n.exports,a.pid=n.pid,a.port=n.port,a.shadowDatabasePort=n.shadowDatabasePort;let{exports:d,pid:b}=n;if(s)return{...a,status:"unknown"};if(!x(b,t))return t&&console.debug(`[State] server state for "${o}" has no running process with PID: ${b}`),{...a,status:"not_running"};let R=l(o);try{if(!await W(R,{lockfilePath:c(R,".lock")}))return t&&console.debug(`[State] server state for "${o}" is not locked, indicating it is not running.`),{...a,status:"starting_up"}}catch(G){t&&console.error(`[State] server state for "${o}" failed to check lock:`,G)}if(!d)return{...a,status:"starting_up"};let{http:Y}=d,{hc:B}=await import("hono/client"),D=await B(Y.url).health.$get();if(!D.ok)return t&&console.debug(`[State] server state for "${o}" is not live: ${JSON.stringify(D)}`),{...a,status:"not_running"};let S=await D.json();return S.name!==r?(t&&console.debug(`[State] server state for "${o}" has mismatched health response: ${JSON.stringify(S)}`),{...a,status:"unknown"}):(t&&console.debug(`[State] server state for "${r}" is live: ${JSON.stringify(S)}`),{...a,status:"running"})}catch(n){return t&&console.error(`[State] failed to get server status for "${o}":`,n),{...a,status:"error"}}}function ue(r){let{status:e}=r;return e==="running"||e==="starting_up"}async function de(r,e){let{pid:t,...s}=typeof r=="string"?await K(r,{debug:e}):r;if(!ue(s))return!1;let o=await u.fromServerDump({debug:e,name:s.name});if(t==null){e&&console.debug(`[State] No PID found for server "${s.name}" to kill.`);try{await o?.close()}catch{}return!1}let i=await A(t,e);try{await o?.close()}catch{}return i}var $=class extends Error{name="ServerStateAlreadyExistsError";constructor(e){super(`A Prisma Dev server with the name "${e}" is already running.`)}},T=class extends ${#t;name="ServerAlreadyRunningError";constructor(e){super(e.name),this.#t=e}get server(){return u.fromServerDump({debug:this.#t.debug,name:this.#t.name})}};export{u as a,Se as b,K as c,ue as d,de as e,$ as f,T as g};
|
package/dist/chunk-OTI5SWIV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{checkPort as w,getPort as m,isUnsafePort as O}from"get-port-please";import{difference as T,range as $}from"remeda";var v=51214,h=51213,S=51215,p=65535,k=0,P=-1/0;async function E(o){let{debug:t,name:r,requestedPorts:n,servers:u}=o,{portsUsedByOtherServers:e,portsUsedByThisServerLastTime:a}=B(r,u);t&&(console.debug(`ports used by other servers: ${Object.keys(e).join(", ")}`),console.debug(`ports used by "${r}" server last time: ${JSON.stringify(a)}`));let i={databasePort:P,port:P,shadowDatabasePort:P},s=["port","databasePort","shadowDatabasePort"];for(let c of s){let d=await x({debug:t,portKey:c,portsUsedByOtherServers:e,portsUsedByThisServerLastTime:a,requestedPorts:n})??await U({debug:t,pickedPorts:i,portKey:c,portsUsedByOtherServers:e,portsUsedByThisServerLastTime:a});t&&console.debug(`Got port for "${c}": ${d}`),i[c]=d}return t&&console.debug(`Picked ports: ${JSON.stringify(i)}`),i}async function x(o){let{debug:t,portKey:r,portsUsedByOtherServers:n,portsUsedByThisServerLastTime:u,requestedPorts:e}=o,{[r]:a,...i}=e;if(g(a))return await R({debug:t,otherRequestedPorts:i,portKey:r,portsUsedByOtherServers:n,requestedPort:a}),a;let s=u?.[r]??P;if(!g(s))return t&&console.debug(`No port specified for "${r}". Trying to pick a new port.`),null;let c=s in n;return c||Object.values(i).includes(s)?(t&&console.debug(`Port ${s} that was used last time for this server, ${c?"is also used by another server":"has been requested for another service"}. Trying to pick a new port.`),null):await w(s)===!1?(t&&console.debug(`Port ${s}, that was used last time for this server, is not available. Trying to pick a new port.`),null):(t&&console.debug(`Using port ${s} for "${r}" as it was used last time and is available.`),s)}async function U(o){let{debug:t,pickedPorts:r,portKey:n,portsUsedByOtherServers:u,portsUsedByThisServerLastTime:e}=o,a=Math.max(v,h,S)+1,i=[...Object.values(r),...Object.keys(u).map(Number),...Object.values(e||{})],s=Math.min(Math.max(a,...i)+100,p),c=T($(a,s),i),d={port:h,databasePort:v,shadowDatabasePort:S}[n];try{return await m({port:d in u||Object.values(r).includes(d)||Object.values(e||{}).includes(d)?void 0:d,ports:c})}catch(b){if(b instanceof Error&&b.name==="GetPortError"&&s+1<=p)return t&&console.debug(`Expanding port lookup to range [${s+1}, ${p}].`),await m({portRange:[s+1,p]});throw b}}function g(o){return Number.isFinite(o)&&o>=0}function B(o,t){let r={},n;for(let u of t){let{databasePort:e,port:a,shadowDatabasePort:i}=u;if(u.name===o){n={databasePort:e,port:a,shadowDatabasePort:i};continue}r[e]=!0,r[a]=!0,r[i]=!0}return{portsUsedByOtherServers:r,portsUsedByThisServerLastTime:n}}async function R(o){let{debug:t,otherRequestedPorts:r,portKey:n,portsUsedByOtherServers:u,requestedPort:e}=o;if(e!==k){if(e in u)throw t&&console.error(`Port ${e} was requested for "${n}", but is already used by another server.`),new y(e);if(Object.values(r).includes(e))throw t&&console.error(`Port ${e} was requested for "${n}", but also for another key.`),new l(e);if(O(e))throw t&&console.error(`Port ${e} was requested for "${n}", but is unsafe.`),new f(e);if(await w(e)===!1)throw t&&console.error(`Port ${e} was requested for "${n}", but is not available.`),new f(e)}}var f=class extends Error{constructor(r){super(`Port \`${r}\` is not available.`);this.port=r}name="PortNotAvailableError"},l=class extends Error{constructor(r){super(`Port number \`${r}\` was requested twice. Please choose a different port for each service.`);this.port=r}name="PortRequestedTwiceError"},y=class extends Error{constructor(r){super(`Port number \`${r}\` belongs to another Prisma Dev server. Please choose a different port.`);this.port=r}name="PortBelongsToAnotherServerError"};export{v as a,h as b,S as c,k as d,P as e,E as f,f as g};
|
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};
|
package/dist/utility-Q5A254LJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Hono as n}from"hono/tiny";import{StatusCodes as p}from"http-status-codes";var o=new n;o.post("/database/dump",async t=>{let a=t.get("db"),e=t.get("databaseDumpPath");return await a.dump(e),t.json({dumpPath:e},p.CREATED)});var u=o.get("/health",t=>t.json({name:t.get("name")}));export{o as utilityRoute};
|