@porulle/adapter-pglite 0.63.0 → 0.65.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/index.d.ts.map +1 -1
- package/dist/index.js +2 -15
- package/package.json +2 -2
- package/src/index.ts +2 -14
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyD,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAG5G,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CACjC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,eAAe,CAAC,CAsB1B"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PGlite } from "@electric-sql/pglite";
|
|
2
2
|
import { drizzle } from "drizzle-orm/pglite";
|
|
3
|
-
import { ensureDefaultOrg, pushSchema } from "@porulle/core";
|
|
3
|
+
import { createPGliteTransaction, ensureDefaultOrg, pushSchema } from "@porulle/core";
|
|
4
4
|
import * as schema from "@porulle/core/schema";
|
|
5
5
|
/**
|
|
6
6
|
* A zero-infrastructure `DatabaseAdapter` backed by PGlite — real PostgreSQL
|
|
@@ -33,20 +33,7 @@ export async function pgliteAdapter(options = {}) {
|
|
|
33
33
|
if (options.seedDefaultOrg !== false) {
|
|
34
34
|
await ensureDefaultOrg(db);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
// BEGIN/COMMIT/ROLLBACK on the raw instance is reliable.
|
|
38
|
-
async function transaction(fn) {
|
|
39
|
-
await pg.exec("BEGIN");
|
|
40
|
-
try {
|
|
41
|
-
const result = await fn(db);
|
|
42
|
-
await pg.exec("COMMIT");
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
await pg.exec("ROLLBACK");
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
36
|
+
const { transaction } = createPGliteTransaction(pg, db);
|
|
50
37
|
// Signal the runtime to push any plugin-declared tables at boot: PGlite has
|
|
51
38
|
// no separate migration step, and plugin schemas aren't known until plugins
|
|
52
39
|
// run in defineConfig (after this adapter was constructed). Honors `migrate`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@porulle/adapter-pglite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@electric-sql/pglite": "^0.3.15",
|
|
15
15
|
"drizzle-kit": "^0.31.9",
|
|
16
16
|
"drizzle-orm": "^0.45.1",
|
|
17
|
-
"@porulle/core": "0.
|
|
17
|
+
"@porulle/core": "0.65.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^24.5.2",
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PGlite } from "@electric-sql/pglite";
|
|
2
2
|
import { drizzle } from "drizzle-orm/pglite";
|
|
3
|
-
import { ensureDefaultOrg, pushSchema, type DatabaseAdapter } from "@porulle/core";
|
|
3
|
+
import { createPGliteTransaction, ensureDefaultOrg, pushSchema, type DatabaseAdapter } from "@porulle/core";
|
|
4
4
|
import * as schema from "@porulle/core/schema";
|
|
5
5
|
|
|
6
6
|
export interface PgliteAdapterOptions {
|
|
@@ -57,19 +57,7 @@ export async function pgliteAdapter(
|
|
|
57
57
|
await ensureDefaultOrg(db);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
// BEGIN/COMMIT/ROLLBACK on the raw instance is reliable.
|
|
62
|
-
async function transaction<T>(fn: (tx: unknown) => Promise<T>): Promise<T> {
|
|
63
|
-
await pg.exec("BEGIN");
|
|
64
|
-
try {
|
|
65
|
-
const result = await fn(db);
|
|
66
|
-
await pg.exec("COMMIT");
|
|
67
|
-
return result;
|
|
68
|
-
} catch (error) {
|
|
69
|
-
await pg.exec("ROLLBACK");
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
60
|
+
const { transaction } = createPGliteTransaction(pg, db);
|
|
73
61
|
|
|
74
62
|
// Signal the runtime to push any plugin-declared tables at boot: PGlite has
|
|
75
63
|
// no separate migration step, and plugin schemas aren't known until plugins
|