@prisma/dev 0.22.3 → 0.23.1
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-62DM64XC.js +1 -0
- package/dist/{chunk-CW5JFXGL.js → chunk-GPEZQZD3.js} +1 -1
- package/dist/chunk-ZSBTZQZ3.js +84 -0
- package/dist/daemon.cjs +17 -17
- package/dist/daemon.js +1 -1
- package/dist/db.cjs +13 -13
- package/dist/db.js +1 -1
- package/dist/index.cjs +17 -17
- package/dist/index.js +1 -1
- 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.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 +2 -0
- package/dist/runtime-assets.cjs +1 -1
- package/dist/runtime-assets.d.cts +1 -0
- package/dist/runtime-assets.d.ts +1 -0
- package/dist/runtime-assets.js +1 -1
- package/package.json +8 -8
- package/dist/chunk-NKHRQQEV.js +0 -84
- package/dist/chunk-NXMFOBF6.js +0 -1
package/dist/runtime-assets.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var z=Object.create;var
|
|
1
|
+
"use strict";var z=Object.create;var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},p=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of v(t))!T.call(e,i)&&i!==n&&m(e,i,{get:()=>t[i],enumerable:!(s=E(t,i))||s.enumerable});return e};var G=(e,t,n)=>(n=e!=null?z(x(e)):{},p(t||!e||!e.__esModule?m(n,"default",{value:e,enumerable:!0}):n,e)),I=e=>p(m({},"__esModule",{value:!0}),e);var H={};D(H,{copyPrismaDevRuntimeAssets:()=>O,getPGliteRuntimeAssets:()=>W,getPrismaDevRuntimeAssetManifest:()=>L,registerBundledPGliteRuntimeAssetSources:()=>C,resolveBundledRuntimeAssetSource:()=>u});module.exports=I(H);var N=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,l=N();var o=require("fs"),a=require("fs/promises"),w=require("module"),A=require("path"),r=require("url"),k=(0,w.createRequire)(l),M=["initdb.wasm","pglite.data","pglite.wasm"],P={amcheck:"amcheck.tar.gz",bloom:"bloom.tar.gz",btree_gin:"btree_gin.tar.gz",btree_gist:"btree_gist.tar.gz",citext:"citext.tar.gz",cube:"cube.tar.gz",dict_int:"dict_int.tar.gz",dict_xsyn:"dict_xsyn.tar.gz",earthdistance:"earthdistance.tar.gz",file_fdw:"file_fdw.tar.gz",fuzzystrmatch:"fuzzystrmatch.tar.gz",hstore:"hstore.tar.gz",intarray:"intarray.tar.gz",isn:"isn.tar.gz",lo:"lo.tar.gz",ltree:"ltree.tar.gz",pageinspect:"pageinspect.tar.gz",pg_buffercache:"pg_buffercache.tar.gz",pg_freespacemap:"pg_freespacemap.tar.gz",pg_surgery:"pg_surgery.tar.gz",pg_trgm:"pg_trgm.tar.gz",pg_visibility:"pg_visibility.tar.gz",pg_walinspect:"pg_walinspect.tar.gz",seg:"seg.tar.gz",tablefunc:"tablefunc.tar.gz",tcn:"tcn.tar.gz",tsm_system_rows:"tsm_system_rows.tar.gz",tsm_system_time:"tsm_system_time.tar.gz",unaccent:"unaccent.tar.gz",uuid_ossp:"uuid-ossp.tar.gz",vector:"vector.tar.gz"},U=[...M.map(e=>({fileName:e,kind:"core",name:e})),...Object.entries(P).map(([e,t])=>({fileName:t,kind:"extension",name:e}))],d=new Map,h=Symbol.for("@prisma/dev/bundled-pglite-runtime-asset-sources"),c=null;async function O(e){let t=f(e),n=(0,r.fileURLToPath)(t);await(0,a.mkdir)(n,{recursive:!0});let s=[];for(let i of L()){let g=new URL(i.fileName,t),R=(0,r.fileURLToPath)(g);await(0,a.copyFile)(i.sourcePath,R),s.push({...i,destinationPath:R})}return s}function L(){let e=_();return U.map(t=>({...t,sourcePath:(0,r.fileURLToPath)(new URL(t.fileName,e))}))}async function W(){await K();let e=S();if(e)return await J(e),await F(e);let t=q(),n=t.href,s=d.get(n);return s||(s=j(t),d.set(n,s)),await s}function C(e){let t=globalThis;t[h]={extensions:Object.fromEntries(Object.entries(e.extensions).map(([n,s])=>[n,u(s)])),fsBundle:u(e.fsBundle),initdbWasm:u(e.initdbWasm),wasmModule:u(e.wasmModule)}}function u(e,t=l){return e instanceof URL?e:/^(?:https?:|data:|file:)/.test(e)?new URL(e):e.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(e)?(0,r.pathToFileURL)(e):new URL(e,t)}async function F(e){let t=`bundled:${e.wasmModule.href}:${e.fsBundle.href}`,n=d.get(t);return n||(n=$(e),d.set(t,n)),await n}async function j(e){let[t,n]=await Promise.all([(0,a.readFile)(new URL("pglite.data",e)),(0,a.readFile)(new URL("pglite.wasm",e))]),s=B();return{extensions:Object.fromEntries(Object.entries(P).map(([i,g])=>[i,new URL(g,e)])),fsBundle:new Blob([Uint8Array.from(t)]),wasmModule:await s.compile(n)}}async function $(e){let[t,n]=await Promise.all([b(e.fsBundle),b(e.wasmModule)]),s=B();return{extensions:e.extensions,fsBundle:new Blob([Uint8Array.from(t)]),wasmModule:await s.compile(n)}}async function J(e){if(e.initdbWasm.protocol!=="file:")return;let t=new URL("initdb.wasm",f(new URL("./",e.initdbWasm))),n=(0,r.fileURLToPath)(t);(0,o.existsSync)(n)||await(0,a.copyFile)((0,r.fileURLToPath)(e.initdbWasm),n)}function f(e){return e instanceof URL?y(e):y((0,r.pathToFileURL)(e))}function y(e){return e.href.endsWith("/")?e:new URL(`${e.href}/`)}function _(){let e=k.resolve("@electric-sql/pglite");return f((0,A.dirname)(e))}function q(){let e=f(new URL("./",l));if(Y(e))return e;if(X())return _();throw new Error("Unable to locate PGlite runtime assets. If you bundled @prisma/dev, copy them next to the bundle with copyPrismaDevRuntimeAssets().")}function Y(e){return U.every(t=>(0,o.existsSync)((0,r.fileURLToPath)(new URL(t.fileName,e))))}function S(){return globalThis[h]??null}async function K(){!Z()||S()||(c||(c=import("./runtime-assets-manifest.bun.js").then(()=>{}).catch(e=>{throw c=null,e})),await c)}function X(){let e=(0,r.fileURLToPath)(new URL("../package.json",l));if(!(0,o.existsSync)(e))return!1;try{return JSON.parse((0,o.readFileSync)(e,"utf8")).name==="@prisma/dev"}catch{return!1}}function Z(){return typeof globalThis.Bun<"u"}function B(){let e=globalThis.WebAssembly;if(!e)throw new Error("WebAssembly is not available in this runtime.");return e}async function b(e){if(e.protocol==="file:")return await(0,a.readFile)(e);let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch runtime asset ${e.href}: ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())}0&&(module.exports={copyPrismaDevRuntimeAssets,getPGliteRuntimeAssets,getPrismaDevRuntimeAssetManifest,registerBundledPGliteRuntimeAssetSources,resolveBundledRuntimeAssetSource});
|
|
@@ -18,6 +18,7 @@ declare function getPGliteRuntimeAssets(): Promise<PGliteRuntimeAssets>;
|
|
|
18
18
|
declare function registerBundledPGliteRuntimeAssetSources(sources: {
|
|
19
19
|
extensions: Record<string, string | URL>;
|
|
20
20
|
fsBundle: string | URL;
|
|
21
|
+
initdbWasm: string | URL;
|
|
21
22
|
wasmModule: string | URL;
|
|
22
23
|
}): void;
|
|
23
24
|
declare function resolveBundledRuntimeAssetSource(source: string | URL, baseURL?: string): URL;
|
package/dist/runtime-assets.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare function getPGliteRuntimeAssets(): Promise<PGliteRuntimeAssets>;
|
|
|
18
18
|
declare function registerBundledPGliteRuntimeAssetSources(sources: {
|
|
19
19
|
extensions: Record<string, string | URL>;
|
|
20
20
|
fsBundle: string | URL;
|
|
21
|
+
initdbWasm: string | URL;
|
|
21
22
|
wasmModule: string | URL;
|
|
22
23
|
}): void;
|
|
23
24
|
declare function resolveBundledRuntimeAssetSource(source: string | URL, baseURL?: string): URL;
|
package/dist/runtime-assets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-62DM64XC.js";export{a as copyPrismaDevRuntimeAssets,c as getPGliteRuntimeAssets,b as getPrismaDevRuntimeAssetManifest,d as registerBundledPGliteRuntimeAssetSources,e as resolveBundledRuntimeAssetSource};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/dev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
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)",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"common-stuff": "^0.0.0"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@electric-sql/pglite": "0.
|
|
81
|
-
"@electric-sql/pglite-socket": "0.
|
|
82
|
-
"@electric-sql/pglite-tools": "0.
|
|
80
|
+
"@electric-sql/pglite": "0.4.1",
|
|
81
|
+
"@electric-sql/pglite-socket": "0.1.1",
|
|
82
|
+
"@electric-sql/pglite-tools": "0.3.1",
|
|
83
83
|
"@hono/node-server": "1.19.11",
|
|
84
84
|
"@mrleebo/prisma-ast": "0.15.0",
|
|
85
85
|
"@prisma/get-platform": "7.2.0",
|
|
@@ -96,12 +96,12 @@
|
|
|
96
96
|
"zeptomatch": "2.1.0"
|
|
97
97
|
},
|
|
98
98
|
"scripts": {
|
|
99
|
-
"build": "tsup && node ./scripts/generate-bun-runtime-assets.mjs --dist",
|
|
99
|
+
"build": "node ./scripts/generate-bun-runtime-assets.mjs && tsup && node ./scripts/generate-bun-runtime-assets.mjs --dist",
|
|
100
100
|
"check:exports": "attw . --pack --profile node16",
|
|
101
|
-
"dev": "tsup --watch",
|
|
101
|
+
"dev": "node ./scripts/generate-bun-runtime-assets.mjs && tsup --watch",
|
|
102
|
+
"init": "node ./scripts/generate-bun-runtime-assets.mjs",
|
|
102
103
|
"lint": "eslint --fix .",
|
|
103
|
-
"postinstall": "node ./scripts/generate-bun-runtime-assets.mjs",
|
|
104
104
|
"test": "node ./scripts/generate-bun-runtime-assets.mjs && vitest run",
|
|
105
|
-
"typecheck": "tsc --noEmit"
|
|
105
|
+
"typecheck": "node ./scripts/generate-bun-runtime-assets.mjs && tsc --noEmit"
|
|
106
106
|
}
|
|
107
107
|
}
|
package/dist/chunk-NKHRQQEV.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import{c as g}from"./chunk-NXMFOBF6.js";import{g as w}from"./chunk-OTI5SWIV.js";import{e as f}from"./chunk-DGKV2DPF.js";import{filename as k}from"pathe/utils";import{protocol as G}from"@electric-sql/pglite";var u="_prisma_dev_wal",p="events",R="install_all_triggers",N="capture_event",S="prisma_dev_wal_capture",E=new WeakMap,W=new Set(["ALTER","COMMIT","COPY","CREATE","DELETE","DROP","INSERT","MERGE","TRUNCATE","UPDATE"]);async function T(e,t){let o=E.get(e);if(o&&!o.closed)return o.bridge;let r=e.execProtocolRaw.bind(e),n={bridge:{close:async()=>{n.closed||(n.closed=!0,n.subscribers.clear(),e.execProtocolRaw===s&&(e.execProtocolRaw=r),await n.pollPromise,E.delete(e))},poll:async()=>{await _(n,e)},subscribe:d=>(n.subscribers.add(d),()=>{n.subscribers.delete(d)})},closed:!1,ensureInfrastructurePromise:null,pendingPoll:!1,pollPromise:null,subscribers:new Set,suppressDepth:0},s=async(d,l)=>{let a=await r(d,l);return!n.closed&&n.suppressDepth===0&&D(a)&&_(n,e),a};return e.execProtocolRaw=s,E.set(e,n),await v(n,e),n.bridge}async function A(e){let t=E.get(e);t&&await t.bridge.close()}function L(e){for(let t of e){if(t.name!=="commandComplete"||typeof t.text!="string")continue;let o=t.text.split(/\s+/,1)[0]?.toUpperCase();if(o&&W.has(o))return!0}return!1}function D(e){if(e.length===0)return!1;let t=[];return new G.Parser().parse(e,r=>{t.push(r)}),L(t)}async function v(e,t){e.ensureInfrastructurePromise??=P(e,t,async()=>{await t.exec(`CREATE SCHEMA IF NOT EXISTS "${u}"`),await t.exec(`
|
|
2
|
-
CREATE TABLE IF NOT EXISTS "${u}"."${p}" (
|
|
3
|
-
id BIGSERIAL PRIMARY KEY,
|
|
4
|
-
txid BIGINT NOT NULL DEFAULT txid_current(),
|
|
5
|
-
schema_name TEXT NOT NULL,
|
|
6
|
-
table_name TEXT NOT NULL,
|
|
7
|
-
op TEXT NOT NULL,
|
|
8
|
-
row_data JSONB,
|
|
9
|
-
old_row_data JSONB,
|
|
10
|
-
created_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp()
|
|
11
|
-
)
|
|
12
|
-
`),await t.exec(`
|
|
13
|
-
CREATE OR REPLACE FUNCTION "${u}"."${N}"()
|
|
14
|
-
RETURNS trigger
|
|
15
|
-
LANGUAGE plpgsql
|
|
16
|
-
AS $$
|
|
17
|
-
BEGIN
|
|
18
|
-
IF TG_TABLE_SCHEMA = '${u}' THEN
|
|
19
|
-
RETURN COALESCE(NEW, OLD);
|
|
20
|
-
END IF;
|
|
21
|
-
|
|
22
|
-
INSERT INTO "${u}"."${p}" (
|
|
23
|
-
txid,
|
|
24
|
-
schema_name,
|
|
25
|
-
table_name,
|
|
26
|
-
op,
|
|
27
|
-
row_data,
|
|
28
|
-
old_row_data
|
|
29
|
-
)
|
|
30
|
-
VALUES (
|
|
31
|
-
txid_current(),
|
|
32
|
-
TG_TABLE_SCHEMA,
|
|
33
|
-
TG_TABLE_NAME,
|
|
34
|
-
lower(TG_OP),
|
|
35
|
-
CASE WHEN TG_OP IN ('INSERT', 'UPDATE') THEN to_jsonb(NEW) ELSE NULL END,
|
|
36
|
-
CASE WHEN TG_OP IN ('UPDATE', 'DELETE') THEN to_jsonb(OLD) ELSE NULL END
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
RETURN COALESCE(NEW, OLD);
|
|
40
|
-
END;
|
|
41
|
-
$$;
|
|
42
|
-
`),await t.exec(`
|
|
43
|
-
CREATE OR REPLACE FUNCTION "${u}"."${R}"()
|
|
44
|
-
RETURNS void
|
|
45
|
-
LANGUAGE plpgsql
|
|
46
|
-
AS $$
|
|
47
|
-
DECLARE
|
|
48
|
-
target REGCLASS;
|
|
49
|
-
BEGIN
|
|
50
|
-
FOR target IN
|
|
51
|
-
SELECT c.oid::regclass
|
|
52
|
-
FROM pg_class AS c
|
|
53
|
-
JOIN pg_namespace AS n ON n.oid = c.relnamespace
|
|
54
|
-
WHERE c.relkind IN ('r', 'p')
|
|
55
|
-
AND n.nspname NOT IN ('${u}', 'information_schema', 'pg_catalog')
|
|
56
|
-
AND n.nspname NOT LIKE 'pg_temp_%'
|
|
57
|
-
AND n.nspname NOT LIKE 'pg_toast%'
|
|
58
|
-
LOOP
|
|
59
|
-
IF EXISTS (
|
|
60
|
-
SELECT 1
|
|
61
|
-
FROM pg_trigger
|
|
62
|
-
WHERE tgrelid = target
|
|
63
|
-
AND tgname = '${S}'
|
|
64
|
-
) THEN
|
|
65
|
-
CONTINUE;
|
|
66
|
-
END IF;
|
|
67
|
-
|
|
68
|
-
EXECUTE format(
|
|
69
|
-
'CREATE TRIGGER %I AFTER INSERT OR UPDATE OR DELETE ON %s FOR EACH ROW EXECUTE FUNCTION "${u}"."${N}"()',
|
|
70
|
-
'${S}',
|
|
71
|
-
target::text
|
|
72
|
-
);
|
|
73
|
-
END LOOP;
|
|
74
|
-
END;
|
|
75
|
-
$$;
|
|
76
|
-
`),await y(e,t)}),await e.ensureInfrastructurePromise}async function y(e,t){await P(e,t,async()=>{await t.query(`SELECT "${u}"."${R}"()`)})}async function M(e,t){await v(e,t),await y(e,t);let o=await P(e,t,async()=>await t.query(`
|
|
77
|
-
WITH drained AS (
|
|
78
|
-
DELETE FROM "${u}"."${p}"
|
|
79
|
-
RETURNING txid, schema_name, table_name, op, row_data, old_row_data, id
|
|
80
|
-
)
|
|
81
|
-
SELECT txid, schema_name, table_name, op, row_data, old_row_data
|
|
82
|
-
FROM drained
|
|
83
|
-
ORDER BY id
|
|
84
|
-
`));if(o.rows.length===0||e.subscribers.size===0)return;let r=o.rows.map(U);for(let n of e.subscribers)queueMicrotask(()=>{if(!e.closed&&e.subscribers.has(n))try{n(r)}catch(s){console.error("[WAL bridge] subscriber failed",s)}})}async function _(e,t){if(!e.closed){if(e.pollPromise){e.pendingPoll=!0,await e.pollPromise;return}e.pollPromise=(async()=>{do e.pendingPoll=!1,await M(e,t);while(e.pendingPoll&&!e.closed)})().finally(()=>{e.pollPromise=null}),await e.pollPromise}}async function P(e,t,o){e.suppressDepth+=1;try{return await o()}finally{e.suppressDepth-=1,e.suppressDepth===0&&!e.closed&&E.get(t)!==e&&(e.closed=!0)}}function U(e){return{oldRecord:e.old_row_data,record:e.row_data,schema:e.schema_name,table:e.table_name,txid:String(e.txid),type:F(e.op)}}function F(e){switch(e.toLowerCase()){case"delete":return"delete";case"insert":return"insert";case"update":return"update";default:throw new Error(`Unsupported WAL bridge operation: ${e}`)}}var H=10,i={connectionLimit:H,connectTimeout:0,database:"template1",maxIdleConnectionLifetime:0,password:"postgres",poolTimeout:0,socketTimeout:0,sslMode:"disable",username:"postgres"},q=`postgres://${i.username}:${i.password}@localhost`,O=new URLSearchParams({sslmode:i.sslMode}),X=new URLSearchParams({...Object.fromEntries(O.entries()),connection_limit:String(i.connectionLimit),connect_timeout:String(i.connectTimeout),max_idle_connection_lifetime:String(i.maxIdleConnectionLifetime),pool_timeout:String(i.poolTimeout),socket_timeout:String(i.socketTimeout)});async function re(e,t){let o=e==="database"?t.databasePort:t.shadowDatabasePort;if(t.dryRun)return I(e,t,{db:null,port:o,server:null});let{debug:r}=t,s=await(e==="shadow_database"?Y:B)(t.pgliteDataDirPath,r);r&&s.onNotification((c,m)=>{console.debug(`[${e}][${c}] ${m}`)});let{PGLiteSocketServer:d}=await import("@electric-sql/pglite-socket"),l=e==="shadow_database"?t.shadowDatabaseIdleTimeoutMillis:t.databaseIdleTimeoutMillis,a=new d({db:s,debug:r,idleTimeout:Number.isFinite(l)?l:0,inspect:r,maxConnections:i.connectionLimit,port:o});r&&(a.addEventListener("listening",c=>{let{detail:m}=c;console.debug(`[${e}] server listening on ${JSON.stringify(m)}`)}),a.addEventListener("connection",c=>{let{clientAddress:m,clientPort:$}=c.detail;console.debug(`[${e}] client connected from ${m}:${$}`)}),a.addEventListener("error",c=>{let{detail:m}=c;console.error(`[${e}] server error:`,m)}));try{await a.start()}catch(c){throw c instanceof Error&&"code"in c&&c.code==="EADDRINUSE"?new w(o):c}let b=Number(a.getServerConn().split(":").at(1));return t[e==="database"?"databasePort":"shadowDatabasePort"]=b,I(e,t,{db:s,port:b,server:a})}function I(e,t,o){let{debug:r}=t,{db:n,port:s,server:d}=o||{};return r&&console.debug(`[${e}] server started on port ${s}`),{...i,attachWalEventBridge:async()=>{if(e!=="database"||!n)throw new Error("WAL bridge is only available for the primary database server");return await T(n)},close:async()=>{let l=[];try{await d?.stop(),r&&console.debug(`[${e}] server stopped on port ${s}`)}catch(a){console.error(`[${e}] server stop error`,a),l.push(a)}if(e==="database"){try{n&&await A(n),r&&console.debug(`[${e}] closed WAL bridge`)}catch(a){console.error(`[${e}] WAL bridge close error`,a),l.push(a)}try{await n?.syncToFs(),r&&console.debug(`[${e}] synced to filesystem`)}catch(a){console.error(`[${e}] sync error`,a),l.push(a)}}try{await n?.close(),r&&console.debug(`[${e}] closed`)}catch(a){console.error(`[${e}] close error`,a),l.push(a)}if(l.length>0)throw new AggregateError(l,`Failed to close ${e} properly`)},connectionString:h(s,O),dump:async l=>{e==="shadow_database"||!n||await Q({db:n,debug:r,destinationPath:l})},port:s,prismaORMConnectionString:h(s,X),terminalCommand:`PGPASSWORD=${i.password} PGSSLMODE=${i.sslMode} psql -h localhost -p ${s} -U ${i.username} -d ${i.database}`}}function h(e,t){return`${q}:${e}/${i.database}?${t.toString()}`}async function B(e,t){let{PGlite:o}=await import("@electric-sql/pglite"),r=await g();return await o.create({database:i.database,dataDir:e,debug:t?5:void 0,extensions:r.extensions,fsBundle:r.fsBundle,relaxedDurability:!1,wasmModule:r.wasmModule,username:i.username})}async function Y(e,t){let{PGlite:o}=await import("@electric-sql/pglite"),r=await g();return await o.create({database:i.database,dataDir:"memory://",debug:t?5:void 0,extensions:r.extensions,fsBundle:r.fsBundle,relaxedDurability:!1,wasmModule:r.wasmModule,username:i.username})}async function Q(e){let{dataDir:t,db:o,debug:r,destinationPath:n}=e,s=o||await B(t,r),{pgDump:d}=await import("@electric-sql/pglite-tools/pg_dump"),l=await d({args:["--schema-only","--no-owner"],fileName:n?k(n):void 0,pg:await s.clone()});return n?(r&&console.debug(`[DB] Dumping database to ${n}`),await f(l,n)):(r&&console.debug("[DB] Dumping database to memory"),await l.text())}export{T as a,L as b,D as c,re as d,Q as e};
|
package/dist/chunk-NXMFOBF6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as R,readFileSync as U}from"fs";import{copyFile as _,mkdir as S,readFile as m}from"fs/promises";import{createRequire as L}from"module";import{dirname as B}from"path";import{fileURLToPath as r,pathToFileURL as p}from"url";var z=L(import.meta.url),E=["pglite.data","pglite.wasm"],y={amcheck:"amcheck.tar.gz",bloom:"bloom.tar.gz",btree_gin:"btree_gin.tar.gz",btree_gist:"btree_gist.tar.gz",citext:"citext.tar.gz",cube:"cube.tar.gz",dict_int:"dict_int.tar.gz",dict_xsyn:"dict_xsyn.tar.gz",earthdistance:"earthdistance.tar.gz",file_fdw:"file_fdw.tar.gz",fuzzystrmatch:"fuzzystrmatch.tar.gz",hstore:"hstore.tar.gz",intarray:"intarray.tar.gz",isn:"isn.tar.gz",lo:"lo.tar.gz",ltree:"ltree.tar.gz",pageinspect:"pageinspect.tar.gz",pg_buffercache:"pg_buffercache.tar.gz",pg_freespacemap:"pg_freespacemap.tar.gz",pg_surgery:"pg_surgery.tar.gz",pg_trgm:"pg_trgm.tar.gz",pg_visibility:"pg_visibility.tar.gz",pg_walinspect:"pg_walinspect.tar.gz",seg:"seg.tar.gz",tablefunc:"tablefunc.tar.gz",tcn:"tcn.tar.gz",tsm_system_rows:"tsm_system_rows.tar.gz",tsm_system_time:"tsm_system_time.tar.gz",unaccent:"unaccent.tar.gz",uuid_ossp:"uuid-ossp.tar.gz",vector:"vector.tar.gz"},A=[...E.map(e=>({fileName:e,kind:"core",name:e})),...Object.entries(y).map(([e,t])=>({fileName:t,kind:"extension",name:e}))],o=new Map,w=Symbol.for("@prisma/dev/bundled-pglite-runtime-asset-sources"),a=null;async function q(e){let t=c(e),s=r(t);await S(s,{recursive:!0});let n=[];for(let i of v()){let l=new URL(i.fileName,t),d=r(l);await _(i.sourcePath,d),n.push({...i,destinationPath:d})}return n}function v(){let e=b();return A.map(t=>({...t,sourcePath:r(new URL(t.fileName,e))}))}async function Y(){await k();let e=P();if(e)return await x(e);let t=G(),s=t.href,n=o.get(s);return n||(n=D(t),o.set(s,n)),await n}function K(e){let t=globalThis;t[w]={extensions:Object.fromEntries(Object.entries(e.extensions).map(([s,n])=>[s,u(n)])),fsBundle:u(e.fsBundle),wasmModule:u(e.wasmModule)}}function u(e,t=import.meta.url){return e instanceof URL?e:/^(?:https?:|data:|file:)/.test(e)?new URL(e):e.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(e)?p(e):new URL(e,t)}async function x(e){let t=`bundled:${e.wasmModule.href}:${e.fsBundle.href}`,s=o.get(t);return s||(s=T(e),o.set(t,s)),await s}async function D(e){let[t,s]=await Promise.all([m(new URL("pglite.data",e)),m(new URL("pglite.wasm",e))]),n=h();return{extensions:Object.fromEntries(Object.entries(y).map(([i,l])=>[i,new URL(l,e)])),fsBundle:new Blob([Uint8Array.from(t)]),wasmModule:await n.compile(s)}}async function T(e){let[t,s]=await Promise.all([f(e.fsBundle),f(e.wasmModule)]),n=h();return{extensions:e.extensions,fsBundle:new Blob([Uint8Array.from(t)]),wasmModule:await n.compile(s)}}function c(e){return e instanceof URL?g(e):g(p(e))}function g(e){return e.href.endsWith("/")?e:new URL(`${e.href}/`)}function b(){let e=z.resolve("@electric-sql/pglite");return c(B(e))}function G(){let e=c(new URL("./",import.meta.url));if(M(e))return e;if(N())return b();throw new Error("Unable to locate PGlite runtime assets. If you bundled @prisma/dev, copy them next to the bundle with copyPrismaDevRuntimeAssets().")}function M(e){return A.every(t=>R(r(new URL(t.fileName,e))))}function P(){return globalThis[w]??null}async function k(){!O()||P()||(a||(a=import("./runtime-assets-manifest.bun.js").then(()=>{}).catch(e=>{throw a=null,e})),await a)}function N(){let e=r(new URL("../package.json",import.meta.url));if(!R(e))return!1;try{return JSON.parse(U(e,"utf8")).name==="@prisma/dev"}catch{return!1}}function O(){return typeof globalThis.Bun<"u"}function h(){let e=globalThis.WebAssembly;if(!e)throw new Error("WebAssembly is not available in this runtime.");return e}async function f(e){if(e.protocol==="file:")return await m(e);let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch runtime asset ${e.href}: ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())}export{q as a,v as b,Y as c,K as d,u as e};
|