refactor(storage): replace better-sqlite3 with PGlite adapter

Eliminates the `prebuild-install` deprecation warning that appears during
`mosaic gateway install` by removing `better-sqlite3` from the dependency
graph entirely and replacing the SqliteAdapter with a PGlite-based adapter
that mirrors the same interface and test coverage.

- New `PgliteAdapter` in `packages/storage/src/adapters/pglite.ts` using
  `@electric-sql/pglite` with JSONB columns and pg-style `$N` placeholders
- Ported all 18 adapter tests to `pglite.test.ts` (in-memory PGlite instances)
- Deleted `sqlite.ts` and `sqlite.test.ts`
- Updated `StorageConfig` discriminated union: `sqlite` → `pglite` with optional
  `dataDir` (absent = in-memory)
- `packages/storage/index.ts` re-exports `PgliteAdapter` and registers it
- CLI install wizard writes `{ type: 'pglite', dataDir: '…/storage-pglite' }`
- Removed `better-sqlite3` and `@types/better-sqlite3` from storage deps;
  added `@electric-sql/pglite@^0.2.17`
- Removed `pnpm.onlyBuiltDependencies: ["better-sqlite3"]` from root package.json
- Bump `@mosaic/storage` 0.0.2 → 0.0.3
- Bump `@mosaic/gateway` 0.0.3 → 0.1.0 (minor — storage dialect change)

Breaking: local-tier `data.db` SQLite files are not migrated. Clean break.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jarvis
2026-04-04 16:44:48 -05:00
parent 30c0fb1308
commit 72e365438c
10 changed files with 349 additions and 323 deletions

62
pnpm-lock.yaml generated
View File

@@ -606,19 +606,16 @@ importers:
packages/storage:
dependencies:
'@electric-sql/pglite':
specifier: ^0.2.17
version: 0.2.17
'@mosaic/db':
specifier: workspace:^
version: link:../db
'@mosaic/types':
specifier: workspace:*
version: link:../types
better-sqlite3:
specifier: ^12.8.0
version: 12.8.0
devDependencies:
'@types/better-sqlite3':
specifier: ^7.6.13
version: 7.6.13
typescript:
specifier: ^5.8.0
version: 5.9.3
@@ -10236,6 +10233,7 @@ snapshots:
'@types/better-sqlite3@7.6.13':
dependencies:
'@types/node': 22.19.15
optional: true
'@types/bunyan@1.8.11':
dependencies:
@@ -10667,6 +10665,7 @@ snapshots:
dependencies:
bindings: 1.5.0
prebuild-install: 7.1.3
optional: true
bidi-js@1.0.3:
dependencies:
@@ -10677,12 +10676,14 @@ snapshots:
bindings@1.5.0:
dependencies:
file-uri-to-path: 1.0.0
optional: true
bl@4.1.0:
dependencies:
buffer: 5.7.1
inherits: 2.0.4
readable-stream: 3.6.2
optional: true
body-parser@2.2.2:
dependencies:
@@ -10744,6 +10745,7 @@ snapshots:
dependencies:
base64-js: 1.5.1
ieee754: 1.2.1
optional: true
bullmq@5.71.0:
dependencies:
@@ -10806,7 +10808,8 @@ snapshots:
dependencies:
readdirp: 5.0.0
chownr@1.1.4: {}
chownr@1.1.4:
optional: true
chownr@3.0.0: {}
@@ -10965,10 +10968,12 @@ snapshots:
decompress-response@6.0.0:
dependencies:
mimic-response: 3.1.0
optional: true
deep-eql@5.0.2: {}
deep-extend@0.6.0: {}
deep-extend@0.6.0:
optional: true
deep-is@0.1.4: {}
@@ -11386,7 +11391,8 @@ snapshots:
signal-exit: 4.1.0
strip-final-newline: 3.0.0
expand-template@2.0.3: {}
expand-template@2.0.3:
optional: true
expect-type@1.3.0: {}
@@ -11552,7 +11558,8 @@ snapshots:
transitivePeerDependencies:
- supports-color
file-uri-to-path@1.0.0: {}
file-uri-to-path@1.0.0:
optional: true
fill-range@7.1.1:
dependencies:
@@ -11614,7 +11621,8 @@ snapshots:
fresh@2.0.0: {}
fs-constants@1.0.0: {}
fs-constants@1.0.0:
optional: true
fsevents@2.3.2:
optional: true
@@ -11709,7 +11717,8 @@ snapshots:
transitivePeerDependencies:
- supports-color
github-from-package@0.0.0: {}
github-from-package@0.0.0:
optional: true
glob-parent@6.0.2:
dependencies:
@@ -11895,7 +11904,8 @@ snapshots:
inherits@2.0.4: {}
ini@1.3.8: {}
ini@1.3.8:
optional: true
ink-spinner@5.0.0(ink@5.2.1(@types/react@18.3.28)(react@18.3.1))(react@18.3.1):
dependencies:
@@ -12603,7 +12613,8 @@ snapshots:
mimic-function@5.0.1: {}
mimic-response@3.1.0: {}
mimic-response@3.1.0:
optional: true
minimatch@10.2.4:
dependencies:
@@ -12617,7 +12628,8 @@ snapshots:
dependencies:
brace-expansion: 2.0.2
minimist@1.2.8: {}
minimist@1.2.8:
optional: true
minipass@7.1.3: {}
@@ -12625,7 +12637,8 @@ snapshots:
dependencies:
minipass: 7.1.3
mkdirp-classic@0.5.3: {}
mkdirp-classic@0.5.3:
optional: true
module-details-from-path@1.0.4: {}
@@ -12672,7 +12685,8 @@ snapshots:
nanostores@1.1.1: {}
napi-build-utils@2.0.0: {}
napi-build-utils@2.0.0:
optional: true
natural-compare@1.4.0: {}
@@ -12711,6 +12725,7 @@ snapshots:
node-abi@3.89.0:
dependencies:
semver: 7.7.4
optional: true
node-abort-controller@3.1.1: {}
@@ -13074,6 +13089,7 @@ snapshots:
simple-get: 4.0.1
tar-fs: 2.1.4
tunnel-agent: 0.6.0
optional: true
prelude-ls@1.2.1: {}
@@ -13163,6 +13179,7 @@ snapshots:
ini: 1.3.8
minimist: 1.2.8
strip-json-comments: 2.0.1
optional: true
react-dom@19.2.4(react@19.2.4):
dependencies:
@@ -13214,6 +13231,7 @@ snapshots:
inherits: 2.0.4
string_decoder: 1.1.1
util-deprecate: 1.0.2
optional: true
readdirp@5.0.0: {}
@@ -13468,13 +13486,15 @@ snapshots:
signal-exit@4.1.0: {}
simple-concat@1.0.1: {}
simple-concat@1.0.1:
optional: true
simple-get@4.0.1:
dependencies:
decompress-response: 6.0.0
once: 1.4.0
simple-concat: 1.0.1
optional: true
sisteransi@1.0.5: {}
@@ -13639,7 +13659,8 @@ snapshots:
strip-final-newline@3.0.0: {}
strip-json-comments@2.0.1: {}
strip-json-comments@2.0.1:
optional: true
strip-json-comments@3.1.1: {}
@@ -13684,6 +13705,7 @@ snapshots:
mkdirp-classic: 0.5.3
pump: 3.0.4
tar-stream: 2.2.0
optional: true
tar-stream@2.2.0:
dependencies:
@@ -13692,6 +13714,7 @@ snapshots:
fs-constants: 1.0.0
inherits: 2.0.4
readable-stream: 3.6.2
optional: true
tar@7.5.13:
dependencies:
@@ -13808,6 +13831,7 @@ snapshots:
tunnel-agent@0.6.0:
dependencies:
safe-buffer: 5.2.1
optional: true
turbo-darwin-64@2.8.16:
optional: true