orez 0.0.52 → 0.0.53
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 +47 -27
- package/dist/admin/ui.d.ts.map +1 -1
- package/dist/admin/ui.js +48 -40
- package/dist/admin/ui.js.map +1 -1
- package/dist/cli.js +35 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/admin/ui.ts +48 -40
- package/src/cli.ts +36 -1
- package/src/index.ts +42 -3
- package/src/replication/tcp-replication.test.ts +23 -14
package/README.md
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# oreZ
|
|
2
2
|
|
|
3
|
-
[Zero](https://zero.rocicorp.dev) is
|
|
3
|
+
[Zero](https://zero.rocicorp.dev) is amazing, but getting started can take a lot - setting up Postgres, approving native SQLite, and then configuring the two to work together.
|
|
4
|
+
|
|
5
|
+
oreZ is an experiment at making Zero work on [PGlite](https://pglite.dev) and SQLite-wasm, and then packing the two together so running them is as simple as possible. It's intended as a dev-mode tool, with a CLI, programmatic API, and Vite plugin.
|
|
4
6
|
|
|
5
7
|
```
|
|
6
8
|
bunx orez
|
|
7
9
|
```
|
|
8
10
|
|
|
9
|
-
**What
|
|
11
|
+
**What oreZ handles automatically:**
|
|
10
12
|
|
|
11
13
|
- **Memory management** — auto-sizes Node heap based on system RAM, purges consumed WAL, batches restores with CHECKPOINTs to prevent WASM OOM
|
|
12
|
-
- **
|
|
14
|
+
- **Real-time replication** — changes sync instantly via pg_notify triggers, with adaptive polling as fallback; auto-tracks tables created at runtime
|
|
13
15
|
- **Auto-recovery** — resets on replication errors, finds available ports if configured ones are busy, cleans stale locks while preserving cache
|
|
14
16
|
- **PGlite compatibility** — rewrites unsupported queries, fakes wire protocol responses, filters unsupported column types, cleans session state between connections
|
|
15
|
-
- **
|
|
17
|
+
- **Admin dashboard** — live zero-cache logs, restart/reset controls, connection info (`--admin`)
|
|
18
|
+
- **Production restores** — `pg_dump`/`pg_restore` with COPY→INSERT conversion, skips unsupported extensions, handles oversized rows, auto-restarts zero-cache
|
|
16
19
|
- **Zero-cache workarounds** — fixes concurrent COPY bug, disables query planner (WASM infinite loop), respects publication filtering
|
|
17
20
|
- **Extensions** — pgvector and pg_trgm enabled by default
|
|
18
21
|
|
|
@@ -43,6 +46,23 @@ bunx orez
|
|
|
43
46
|
|
|
44
47
|
Ports auto-increment if already in use.
|
|
45
48
|
|
|
49
|
+
## Admin Dashboard
|
|
50
|
+
|
|
51
|
+
Start the admin dashboard with `--admin`:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
bunx orez --admin
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Open `http://localhost:6477` for a real-time dashboard with:
|
|
58
|
+
|
|
59
|
+
- **Logs** — live-streaming logs from zero-cache, PGlite, proxy, and oreZ, filterable by source and level
|
|
60
|
+
- **HTTP** — request log showing method, path, status, duration, and response size with expandable headers
|
|
61
|
+
- **Env** — environment variables passed to zero-cache
|
|
62
|
+
- **Actions** — restart zero-cache, reset (wipe replica + resync), clear logs
|
|
63
|
+
|
|
64
|
+
The dashboard polls every second for new logs and updates uptime/port status every 5 seconds.
|
|
65
|
+
|
|
46
66
|
## Programmatic
|
|
47
67
|
|
|
48
68
|
```
|
|
@@ -99,11 +119,11 @@ export default {
|
|
|
99
119
|
}
|
|
100
120
|
```
|
|
101
121
|
|
|
102
|
-
Starts
|
|
122
|
+
Starts oreZ when vite dev server starts, stops on close. Supports all `startZeroLite` options plus `s3` and `s3Port` for local S3.
|
|
103
123
|
|
|
104
124
|
## How it works
|
|
105
125
|
|
|
106
|
-
|
|
126
|
+
oreZ starts three things:
|
|
107
127
|
|
|
108
128
|
1. Three PGlite instances (full PostgreSQL 16 running in-process via WASM) — one for each database zero-cache expects (upstream, CVR, change)
|
|
109
129
|
2. A TCP proxy that speaks the PostgreSQL wire protocol, routing connections to the correct PGlite instance and handling logical replication
|
|
@@ -113,7 +133,7 @@ orez starts three things:
|
|
|
113
133
|
|
|
114
134
|
zero-cache expects three separate databases: `postgres` (app data), `zero_cvr` (client view records), and `zero_cdb` (change-streamer state). In real PostgreSQL these are independent databases with separate connection pools and transaction contexts.
|
|
115
135
|
|
|
116
|
-
|
|
136
|
+
oreZ creates a separate PGlite instance for each database, each with its own data directory and mutex. This is critical because PGlite is single-session — all proxy connections to the same instance share one session. Without isolation, transactions on the CVR database get corrupted by queries on the postgres database (zero-cache's view-syncer detects this as `ConcurrentModificationException` and crashes). Separate instances eliminate cross-database interference entirely.
|
|
117
137
|
|
|
118
138
|
The proxy routes connections based on the database name in the startup message:
|
|
119
139
|
|
|
@@ -127,9 +147,9 @@ Each instance has its own mutex for serializing queries. Extensions (pgvector, p
|
|
|
127
147
|
|
|
128
148
|
### Replication
|
|
129
149
|
|
|
130
|
-
zero-cache needs logical replication to stay in sync with the upstream database. PGlite doesn't support logical replication natively, so
|
|
150
|
+
zero-cache needs logical replication to stay in sync with the upstream database. PGlite doesn't support logical replication natively, so oreZ fakes it. Every mutation is captured by triggers into a changes table, then encoded into the pgoutput binary protocol and streamed to zero-cache through the replication connection. zero-cache can't tell the difference.
|
|
131
151
|
|
|
132
|
-
|
|
152
|
+
Change notifications are **real-time via pg_notify** — triggers fire a notification on every write, waking the replication handler immediately. Polling is only a fallback for edge cases (e.g., bulk restores that bypass triggers). Fallback polling is adaptive: 20ms when catching up, 500ms when idle. Batch size is 2000 changes per poll. Consumed changes are purged every 10 cycles to prevent the `_zero_changes` table from growing unbounded.
|
|
133
153
|
|
|
134
154
|
Tables created at runtime (e.g., zero-cache's shard schema tables like `chat_0.clients` and `chat_0.mutations`) are automatically detected via a DDL event trigger and enrolled in change tracking without a restart.
|
|
135
155
|
|
|
@@ -137,7 +157,7 @@ The replication handler also tracks shard schema tables so that `.server` promis
|
|
|
137
157
|
|
|
138
158
|
### Zero native dependencies
|
|
139
159
|
|
|
140
|
-
The whole point of
|
|
160
|
+
The whole point of oreZ is that `bunx orez` works everywhere with no native compilation step. Postgres runs in-process as WASM via PGlite. zero-cache also needs SQLite, and `@rocicorp/zero-sqlite3` ships as a compiled C addon — so orez ships [bedrock-sqlite](https://www.npmjs.com/package/bedrock-sqlite), SQLite's [bedrock branch](https://sqlite.org/src/timeline?t=begin-concurrent) recompiled to WASM with BEGIN CONCURRENT and WAL2 support. At startup, oreZ patches `@rocicorp/zero-sqlite3` to load bedrock-sqlite instead of the native C addon. Both databases run as WASM — nothing to compile, nothing platform-specific. Just `bun install` and go.
|
|
141
161
|
|
|
142
162
|
### Auto heap sizing
|
|
143
163
|
|
|
@@ -147,7 +167,7 @@ The CLI detects system memory on startup and re-spawns the process with `--max-o
|
|
|
147
167
|
|
|
148
168
|
Your entire environment is forwarded to the zero-cache child process. This means any `ZERO_*` env vars you set are passed through automatically.
|
|
149
169
|
|
|
150
|
-
|
|
170
|
+
oreZ provides sensible defaults for a few variables:
|
|
151
171
|
|
|
152
172
|
| Variable | Default | Overridable |
|
|
153
173
|
| -------------------------------------- | ------------------- | ----------- |
|
|
@@ -157,17 +177,17 @@ orez provides sensible defaults for a few variables:
|
|
|
157
177
|
| `ZERO_ENABLE_QUERY_PLANNER` | `false` | yes |
|
|
158
178
|
| `ZERO_INITIAL_SYNC_TABLE_COPY_WORKERS` | `999` | yes |
|
|
159
179
|
| `ZERO_AUTO_RESET` | `true` | yes |
|
|
160
|
-
| `ZERO_UPSTREAM_DB` | _(managed by
|
|
161
|
-
| `ZERO_CVR_DB` | _(managed by
|
|
162
|
-
| `ZERO_CHANGE_DB` | _(managed by
|
|
163
|
-
| `ZERO_REPLICA_FILE` | _(managed by
|
|
164
|
-
| `ZERO_PORT` | _(managed by
|
|
180
|
+
| `ZERO_UPSTREAM_DB` | _(managed by oreZ)_ | no |
|
|
181
|
+
| `ZERO_CVR_DB` | _(managed by oreZ)_ | no |
|
|
182
|
+
| `ZERO_CHANGE_DB` | _(managed by oreZ)_ | no |
|
|
183
|
+
| `ZERO_REPLICA_FILE` | _(managed by oreZ)_ | no |
|
|
184
|
+
| `ZERO_PORT` | _(managed by oreZ)_ | no |
|
|
165
185
|
|
|
166
186
|
The `--log-level` flag controls both zero-cache (`ZERO_LOG_LEVEL`) and PGlite's debug output. Default is `warn` to keep output quiet. Set to `info` or `debug` for troubleshooting.
|
|
167
187
|
|
|
168
188
|
`ZERO_INITIAL_SYNC_TABLE_COPY_WORKERS` is set high to work around a postgres.js bug where concurrent COPY TO STDOUT on reused connections hangs. This gives each table its own connection during initial sync. `ZERO_AUTO_RESET` lets zero-cache recover from replication errors (e.g. after `pg_restore`) by wiping and resyncing instead of crashing. `ZERO_ENABLE_QUERY_PLANNER` is disabled because it causes freezes with both WASM and native SQLite.
|
|
169
189
|
|
|
170
|
-
The layering is:
|
|
190
|
+
The layering is: oreZ defaults → your env → oreZ-managed connection vars. So setting `ZERO_LOG_LEVEL=debug` in your shell overrides the `--log-level` default, but you can't override the database connection strings (oreZ needs to point zero-cache at its own proxy).
|
|
171
191
|
|
|
172
192
|
Common vars you might want to set:
|
|
173
193
|
|
|
@@ -196,7 +216,7 @@ The pgoutput encoder produces spec-compliant binary messages: Begin, Relation, I
|
|
|
196
216
|
|
|
197
217
|
## Workarounds
|
|
198
218
|
|
|
199
|
-
A lot of things don't "just work" when you replace Postgres with PGlite and native SQLite with WASM. Here's what
|
|
219
|
+
A lot of things don't "just work" when you replace Postgres with PGlite and native SQLite with WASM. Here's what oreZ does to make it seamless.
|
|
200
220
|
|
|
201
221
|
### TCP proxy: raw wire protocol instead of pg-gateway
|
|
202
222
|
|
|
@@ -204,7 +224,7 @@ The proxy implements the PostgreSQL wire protocol from scratch using raw TCP soc
|
|
|
204
224
|
|
|
205
225
|
### Session state bleed between connections
|
|
206
226
|
|
|
207
|
-
PGlite is single-session — all proxy connections share one session. If `pg_restore` sets `search_path = ''`, every subsequent connection inherits that. On disconnect,
|
|
227
|
+
PGlite is single-session — all proxy connections share one session. If `pg_restore` sets `search_path = ''`, every subsequent connection inherits that. On disconnect, oreZ resets `search_path`, `statement_timeout`, `lock_timeout`, and `idle_in_transaction_session_timeout`, and rolls back any open transaction. Without this, the next connection gets a corrupted session.
|
|
208
228
|
|
|
209
229
|
### Event loop starvation from mutex chains
|
|
210
230
|
|
|
@@ -216,7 +236,7 @@ When `execProtocolRaw` throws (PGlite internal error), the proxy sends a proper
|
|
|
216
236
|
|
|
217
237
|
### SQLite shim via ESM loader hooks
|
|
218
238
|
|
|
219
|
-
zero-cache imports `@rocicorp/zero-sqlite3` (a native C addon) via ESM `import`.
|
|
239
|
+
zero-cache imports `@rocicorp/zero-sqlite3` (a native C addon) via ESM `import`. oreZ uses Node's `module.register()` API with `--import` to intercept resolution — ESM `resolve` and `load` hooks redirect `@rocicorp/zero-sqlite3` to bedrock-sqlite WASM at runtime. The hook templates live in `src/shim/` and are written to tmpdir with the resolved bedrock-sqlite path substituted.
|
|
220
240
|
|
|
221
241
|
The shim also polyfills the better-sqlite3 API surface zero-cache expects: `unsafeMode()`, `defaultSafeIntegers()`, `serialize()`, `backup()`, and `scanStatus`/`scanStatusV2`/`scanStatusReset` on Statement prototypes (zero-cache's query planner calls these for scan statistics, which WASM doesn't support).
|
|
222
242
|
|
|
@@ -254,11 +274,11 @@ The restore parser tracks `$$` and `$tag$` blocks to correctly identify statemen
|
|
|
254
274
|
|
|
255
275
|
### Restore: broken trigger cleanup
|
|
256
276
|
|
|
257
|
-
After restore,
|
|
277
|
+
After restore, oreZ drops triggers whose backing functions don't exist. This happens when a filtered `pg_dump` includes triggers on public-schema tables that reference functions from excluded schemas. The triggers survive TOC filtering because they're associated with public tables, but the functions they reference weren't included.
|
|
258
278
|
|
|
259
279
|
### Restore: wire protocol auto-detection
|
|
260
280
|
|
|
261
|
-
`pg_restore` tries connecting via wire protocol first (for restoring into a running
|
|
281
|
+
`pg_restore` tries connecting via wire protocol first (for restoring into a running oreZ instance). If the connection fails, it falls back to direct PGlite access. But if the connection succeeds and the restore itself fails, it does _not_ fall back — the error is real and should be reported, not masked by a retry.
|
|
262
282
|
|
|
263
283
|
### Callback-based message loop
|
|
264
284
|
|
|
@@ -273,7 +293,7 @@ bun run test # orez tests
|
|
|
273
293
|
cd sqlite-wasm && bunx vitest run # bedrock-sqlite tests
|
|
274
294
|
```
|
|
275
295
|
|
|
276
|
-
The
|
|
296
|
+
The oreZ test suite includes a zero-cache compatibility layer that decodes pgoutput messages into the same typed format that zero-cache's PgoutputParser produces, validating end-to-end compatibility.
|
|
277
297
|
|
|
278
298
|
The bedrock-sqlite tests cover Database/Statement API, transactions, WAL/WAL2 modes, BEGIN CONCURRENT, FTS5, JSON functions, custom functions, aggregates, bigint handling, and file persistence.
|
|
279
299
|
|
|
@@ -339,7 +359,7 @@ pg_restore options:
|
|
|
339
359
|
--clean drop and recreate public schema before restoring
|
|
340
360
|
```
|
|
341
361
|
|
|
342
|
-
`pg_restore` also supports connecting to a running
|
|
362
|
+
`pg_restore` also supports connecting to a running oreZ instance via wire protocol — just pass `--pg-port`:
|
|
343
363
|
|
|
344
364
|
```
|
|
345
365
|
bunx orez pg_restore backup.sql --pg-port 6434
|
|
@@ -360,9 +380,9 @@ Restore streams the dump file line-by-line so it can handle large dumps without
|
|
|
360
380
|
- **PostgreSQL 18+ artifacts**: `SET transaction_timeout` silently skipped
|
|
361
381
|
- **psql meta-commands**: `\restrict` and similar silently skipped
|
|
362
382
|
|
|
363
|
-
This means you can take a `pg_dump` from a production Postgres database and restore it directly into
|
|
383
|
+
This means you can take a `pg_dump` from a production Postgres database and restore it directly into oreZ — incompatible statements are handled automatically.
|
|
364
384
|
|
|
365
|
-
When
|
|
385
|
+
When oreZ is not running, `pg_restore` opens PGlite directly. When oreZ is running, pass `--pg-port` to restore through the wire protocol. Standard Postgres tools (`pg_dump`, `pg_restore`, `psql`) also work against the running proxy since oreZ presents a standard PostgreSQL 16.4 version string over the wire.
|
|
366
386
|
|
|
367
387
|
## Extra: orez/s3
|
|
368
388
|
|
package/dist/admin/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/admin/ui.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/admin/ui.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,IAAI,MAAM,CAmrBrC"}
|
package/dist/admin/ui.js
CHANGED
|
@@ -4,23 +4,23 @@ export function getAdminHtml() {
|
|
|
4
4
|
'<head>\n' +
|
|
5
5
|
'<meta charset="utf-8">\n' +
|
|
6
6
|
'<meta name="viewport" content="width=device-width, initial-scale=1">\n' +
|
|
7
|
-
'<title>
|
|
7
|
+
'<title>oreZ admin</title>\n' +
|
|
8
8
|
'<style>\n' +
|
|
9
9
|
':root {\n' +
|
|
10
|
-
' --bg: #
|
|
11
|
-
' --surface: #
|
|
12
|
-
' --border: #
|
|
13
|
-
' --text: #
|
|
14
|
-
' --text-dim: #
|
|
15
|
-
' --accent: #
|
|
16
|
-
' --green: #
|
|
17
|
-
' --yellow: #
|
|
18
|
-
' --red: #
|
|
19
|
-
' --purple: #
|
|
10
|
+
' --bg: #000;\n' +
|
|
11
|
+
' --surface: #0a0a0a;\n' +
|
|
12
|
+
' --border: #222;\n' +
|
|
13
|
+
' --text: #fff;\n' +
|
|
14
|
+
' --text-dim: #666;\n' +
|
|
15
|
+
' --accent: #fff;\n' +
|
|
16
|
+
' --green: #888;\n' +
|
|
17
|
+
' --yellow: #999;\n' +
|
|
18
|
+
' --red: #f55;\n' +
|
|
19
|
+
' --purple: #aaa;\n' +
|
|
20
20
|
'}\n' +
|
|
21
21
|
'* { margin: 0; padding: 0; box-sizing: border-box; }\n' +
|
|
22
22
|
'body {\n' +
|
|
23
|
-
' font-family:
|
|
23
|
+
' font-family: -apple-system, BlinkMacSystemFont, "SF Pro", system-ui, sans-serif;\n' +
|
|
24
24
|
' background: var(--bg);\n' +
|
|
25
25
|
' color: var(--text);\n' +
|
|
26
26
|
' height: 100vh;\n' +
|
|
@@ -33,7 +33,7 @@ export function getAdminHtml() {
|
|
|
33
33
|
' align-items: center;\n' +
|
|
34
34
|
' padding: 12px 16px;\n' +
|
|
35
35
|
' background: var(--surface);\n' +
|
|
36
|
-
' border-bottom:
|
|
36
|
+
' border-bottom: 0.5px solid var(--border);\n' +
|
|
37
37
|
' gap: 12px;\n' +
|
|
38
38
|
' flex-shrink: 0;\n' +
|
|
39
39
|
'}\n' +
|
|
@@ -49,7 +49,7 @@ export function getAdminHtml() {
|
|
|
49
49
|
' padding: 2px 8px;\n' +
|
|
50
50
|
' border-radius: 12px;\n' +
|
|
51
51
|
' font-size: 11px;\n' +
|
|
52
|
-
' border:
|
|
52
|
+
' border: 0.5px solid var(--border);\n' +
|
|
53
53
|
' color: var(--text-dim);\n' +
|
|
54
54
|
' gap: 4px;\n' +
|
|
55
55
|
'}\n' +
|
|
@@ -64,7 +64,7 @@ export function getAdminHtml() {
|
|
|
64
64
|
' display: flex;\n' +
|
|
65
65
|
' padding: 0 16px;\n' +
|
|
66
66
|
' background: var(--surface);\n' +
|
|
67
|
-
' border-bottom:
|
|
67
|
+
' border-bottom: 0.5px solid var(--border);\n' +
|
|
68
68
|
' gap: 2px;\n' +
|
|
69
69
|
' flex-shrink: 0;\n' +
|
|
70
70
|
'}\n' +
|
|
@@ -91,7 +91,7 @@ export function getAdminHtml() {
|
|
|
91
91
|
' align-items: center;\n' +
|
|
92
92
|
' padding: 8px 16px;\n' +
|
|
93
93
|
' gap: 10px;\n' +
|
|
94
|
-
' border-bottom:
|
|
94
|
+
' border-bottom: 0.5px solid var(--border);\n' +
|
|
95
95
|
' flex-shrink: 0;\n' +
|
|
96
96
|
'}\n' +
|
|
97
97
|
'.toolbar label {\n' +
|
|
@@ -103,7 +103,7 @@ export function getAdminHtml() {
|
|
|
103
103
|
'.toolbar select {\n' +
|
|
104
104
|
' background: var(--surface);\n' +
|
|
105
105
|
' color: var(--text);\n' +
|
|
106
|
-
' border:
|
|
106
|
+
' border: 0.5px solid var(--border);\n' +
|
|
107
107
|
' border-radius: 6px;\n' +
|
|
108
108
|
' padding: 4px 8px;\n' +
|
|
109
109
|
' font-size: 12px;\n' +
|
|
@@ -114,7 +114,7 @@ export function getAdminHtml() {
|
|
|
114
114
|
'.toolbar input[type="text"] {\n' +
|
|
115
115
|
' background: var(--surface);\n' +
|
|
116
116
|
' color: var(--text);\n' +
|
|
117
|
-
' border:
|
|
117
|
+
' border: 0.5px solid var(--border);\n' +
|
|
118
118
|
' border-radius: 6px;\n' +
|
|
119
119
|
' padding: 4px 8px;\n' +
|
|
120
120
|
' font-size: 12px;\n' +
|
|
@@ -136,14 +136,14 @@ export function getAdminHtml() {
|
|
|
136
136
|
' white-space: nowrap;\n' +
|
|
137
137
|
'}\n' +
|
|
138
138
|
'.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }\n' +
|
|
139
|
-
'.action-btn.blue { color: var(--accent); border-color: #
|
|
140
|
-
'.action-btn.blue:hover:not(:disabled) { background: #
|
|
141
|
-
'.action-btn.orange { color: var(--yellow); border-color: #
|
|
142
|
-
'.action-btn.orange:hover:not(:disabled) { background: #
|
|
143
|
-
'.action-btn.red { color: var(--red); border-color: #
|
|
144
|
-
'.action-btn.red:hover:not(:disabled) { background: #
|
|
145
|
-
'.action-btn.gray { color: var(--text-dim); border-color: #
|
|
146
|
-
'.action-btn.gray:hover:not(:disabled) { background: #
|
|
139
|
+
'.action-btn.blue { color: var(--accent); border-color: #ffffff22; }\n' +
|
|
140
|
+
'.action-btn.blue:hover:not(:disabled) { background: #ffffff11; border-color: var(--accent); }\n' +
|
|
141
|
+
'.action-btn.orange { color: var(--yellow); border-color: #ffffff22; }\n' +
|
|
142
|
+
'.action-btn.orange:hover:not(:disabled) { background: #ffffff11; border-color: var(--yellow); }\n' +
|
|
143
|
+
'.action-btn.red { color: var(--red); border-color: #ff555522; }\n' +
|
|
144
|
+
'.action-btn.red:hover:not(:disabled) { background: #ff555511; border-color: var(--red); }\n' +
|
|
145
|
+
'.action-btn.gray { color: var(--text-dim); border-color: #ffffff22; }\n' +
|
|
146
|
+
'.action-btn.gray:hover:not(:disabled) { background: #ffffff11; border-color: var(--text-dim); }\n' +
|
|
147
147
|
'.content-area {\n' +
|
|
148
148
|
' flex: 1;\n' +
|
|
149
149
|
' overflow: hidden;\n' +
|
|
@@ -170,7 +170,7 @@ export function getAdminHtml() {
|
|
|
170
170
|
'.log-line .src.pglite { color: var(--green); }\n' +
|
|
171
171
|
'.log-line .src.proxy { color: var(--yellow); }\n' +
|
|
172
172
|
'.log-line .src.orez { color: var(--accent); }\n' +
|
|
173
|
-
'.log-line .src.s3 { color: #
|
|
173
|
+
'.log-line .src.s3 { color: #888; }\n' +
|
|
174
174
|
'.log-line.level-error .msg { color: var(--red); }\n' +
|
|
175
175
|
'.log-line.level-warn .msg { color: var(--yellow); }\n' +
|
|
176
176
|
'.log-line.level-info .msg { color: var(--text); }\n' +
|
|
@@ -205,7 +205,7 @@ export function getAdminHtml() {
|
|
|
205
205
|
' text-align: left;\n' +
|
|
206
206
|
' padding: 6px 12px;\n' +
|
|
207
207
|
' color: var(--text-dim);\n' +
|
|
208
|
-
' border-bottom:
|
|
208
|
+
' border-bottom: 0.5px solid var(--border);\n' +
|
|
209
209
|
' font-weight: 500;\n' +
|
|
210
210
|
' text-transform: uppercase;\n' +
|
|
211
211
|
' font-size: 10px;\n' +
|
|
@@ -213,11 +213,11 @@ export function getAdminHtml() {
|
|
|
213
213
|
'}\n' +
|
|
214
214
|
'.env-table td {\n' +
|
|
215
215
|
' padding: 6px 12px;\n' +
|
|
216
|
-
' border-bottom:
|
|
216
|
+
' border-bottom: 0.5px solid var(--border);\n' +
|
|
217
217
|
'}\n' +
|
|
218
218
|
'.env-table td:first-child { color: var(--accent); white-space: nowrap; }\n' +
|
|
219
219
|
'.env-table td:last-child { color: var(--text); word-break: break-all; }\n' +
|
|
220
|
-
'.env-table tr:hover td { background: #
|
|
220
|
+
'.env-table tr:hover td { background: #111; }\n' +
|
|
221
221
|
// http view
|
|
222
222
|
'.http-view {\n' +
|
|
223
223
|
' height: 100%;\n' +
|
|
@@ -230,7 +230,7 @@ export function getAdminHtml() {
|
|
|
230
230
|
' text-align: left;\n' +
|
|
231
231
|
' padding: 6px 12px;\n' +
|
|
232
232
|
' color: var(--text-dim);\n' +
|
|
233
|
-
' border-bottom:
|
|
233
|
+
' border-bottom: 0.5px solid var(--border);\n' +
|
|
234
234
|
' font-weight: 500;\n' +
|
|
235
235
|
' text-transform: uppercase;\n' +
|
|
236
236
|
' font-size: 10px;\n' +
|
|
@@ -242,17 +242,17 @@ export function getAdminHtml() {
|
|
|
242
242
|
'}\n' +
|
|
243
243
|
'.http-table td {\n' +
|
|
244
244
|
' padding: 5px 12px;\n' +
|
|
245
|
-
' border-bottom:
|
|
245
|
+
' border-bottom: 0.5px solid var(--border);\n' +
|
|
246
246
|
' white-space: nowrap;\n' +
|
|
247
247
|
'}\n' +
|
|
248
248
|
'.http-table tr.http-row { cursor: pointer; }\n' +
|
|
249
|
-
'.http-table tr.http-row:hover td { background: #
|
|
249
|
+
'.http-table tr.http-row:hover td { background: #111; }\n' +
|
|
250
250
|
'.http-table .method { font-weight: 600; }\n' +
|
|
251
251
|
'.http-table .method.get { color: var(--green); }\n' +
|
|
252
252
|
'.http-table .method.post { color: var(--yellow); }\n' +
|
|
253
253
|
'.http-table .method.put { color: var(--accent); }\n' +
|
|
254
254
|
'.http-table .method.delete { color: var(--red); }\n' +
|
|
255
|
-
'.http-table .method.patch { color: #
|
|
255
|
+
'.http-table .method.patch { color: #888; }\n' +
|
|
256
256
|
'.http-table .method.ws { color: var(--purple); }\n' +
|
|
257
257
|
'.http-table .status.s2 { color: var(--green); }\n' +
|
|
258
258
|
'.http-table .status.s3 { color: var(--yellow); }\n' +
|
|
@@ -267,8 +267,8 @@ export function getAdminHtml() {
|
|
|
267
267
|
'.http-detail.open { display: table-row; }\n' +
|
|
268
268
|
'.http-detail td {\n' +
|
|
269
269
|
' padding: 8px 12px 12px 24px;\n' +
|
|
270
|
-
' background: #
|
|
271
|
-
' border-bottom:
|
|
270
|
+
' background: #080808;\n' +
|
|
271
|
+
' border-bottom: 0.5px solid var(--border);\n' +
|
|
272
272
|
'}\n' +
|
|
273
273
|
'.http-detail .hdr-section { margin-bottom: 8px; }\n' +
|
|
274
274
|
'.http-detail .hdr-title {\n' +
|
|
@@ -289,7 +289,7 @@ export function getAdminHtml() {
|
|
|
289
289
|
// actions panel
|
|
290
290
|
'.actions-panel {\n' +
|
|
291
291
|
' flex-shrink: 0;\n' +
|
|
292
|
-
' border-top:
|
|
292
|
+
' border-top: 0.5px solid var(--border);\n' +
|
|
293
293
|
' background: var(--surface);\n' +
|
|
294
294
|
' padding: 8px 16px;\n' +
|
|
295
295
|
'}\n' +
|
|
@@ -315,7 +315,7 @@ export function getAdminHtml() {
|
|
|
315
315
|
' padding: 10px 16px;\n' +
|
|
316
316
|
' border-radius: 8px;\n' +
|
|
317
317
|
' background: var(--surface);\n' +
|
|
318
|
-
' border:
|
|
318
|
+
' border: 0.5px solid var(--border);\n' +
|
|
319
319
|
' color: var(--text);\n' +
|
|
320
320
|
' font-size: 12px;\n' +
|
|
321
321
|
' font-family: inherit;\n' +
|
|
@@ -332,7 +332,7 @@ export function getAdminHtml() {
|
|
|
332
332
|
'</head>\n' +
|
|
333
333
|
'<body>\n' +
|
|
334
334
|
' <div class="header">\n' +
|
|
335
|
-
' <span class="logo">◆
|
|
335
|
+
' <span class="logo">◆ oreZ admin</span>\n' +
|
|
336
336
|
' <div class="spacer"></div>\n' +
|
|
337
337
|
' <span class="badge"><span class="dot"></span> pg <span id="pg-port">-</span></span>\n' +
|
|
338
338
|
' <span class="badge"><span class="dot"></span> zero <span id="zero-port">-</span></span>\n' +
|
|
@@ -353,10 +353,11 @@ export function getAdminHtml() {
|
|
|
353
353
|
' <div class="toolbar" id="toolbar">\n' +
|
|
354
354
|
' <label>Level</label>\n' +
|
|
355
355
|
' <select id="level-filter">\n' +
|
|
356
|
-
' <option value=""
|
|
356
|
+
' <option value="">all levels</option>\n' +
|
|
357
357
|
' <option value="error">error only</option>\n' +
|
|
358
358
|
' <option value="warn">warn+</option>\n' +
|
|
359
359
|
' <option value="info">info+</option>\n' +
|
|
360
|
+
' <option value="debug">debug+</option>\n' +
|
|
360
361
|
' </select>\n' +
|
|
361
362
|
' </div>\n' +
|
|
362
363
|
'\n' +
|
|
@@ -409,6 +410,7 @@ export function getAdminHtml() {
|
|
|
409
410
|
'<script>\n' +
|
|
410
411
|
'var activeSource = "";\n' +
|
|
411
412
|
'var activeLevel = "";\n' +
|
|
413
|
+
'var levelSetByUser = false;\n' +
|
|
412
414
|
'var lastCursor = 0;\n' +
|
|
413
415
|
'var autoScroll = true;\n' +
|
|
414
416
|
'var envLoaded = false;\n' +
|
|
@@ -459,6 +461,7 @@ export function getAdminHtml() {
|
|
|
459
461
|
'\n' +
|
|
460
462
|
'document.getElementById("level-filter").addEventListener("change", function(e) {\n' +
|
|
461
463
|
' activeLevel = e.target.value;\n' +
|
|
464
|
+
' levelSetByUser = true;\n' +
|
|
462
465
|
' lastCursor = 0;\n' +
|
|
463
466
|
' logView.innerHTML = "";\n' +
|
|
464
467
|
' fetchLogs();\n' +
|
|
@@ -624,6 +627,11 @@ export function getAdminHtml() {
|
|
|
624
627
|
' document.querySelectorAll("[data-zero-action]").forEach(function(btn) {\n' +
|
|
625
628
|
' btn.disabled = zeroDisabled;\n' +
|
|
626
629
|
' });\n' +
|
|
630
|
+
' // set initial level filter to match --log-level (user can change to see more)\n' +
|
|
631
|
+
' if (!levelSetByUser && data.logLevel && activeLevel !== data.logLevel) {\n' +
|
|
632
|
+
' activeLevel = data.logLevel;\n' +
|
|
633
|
+
' document.getElementById("level-filter").value = data.logLevel;\n' +
|
|
634
|
+
' }\n' +
|
|
627
635
|
' }).catch(function() {});\n' +
|
|
628
636
|
'}\n' +
|
|
629
637
|
'\n' +
|
package/dist/admin/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/admin/ui.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY;IAC1B,OAAO,CACL,mBAAmB;QACnB,oBAAoB;QACpB,UAAU;QACV,0BAA0B;QAC1B,wEAAwE;QACxE,6BAA6B;QAC7B,WAAW;QACX,WAAW;QACX,
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/admin/ui.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY;IAC1B,OAAO,CACL,mBAAmB;QACnB,oBAAoB;QACpB,UAAU;QACV,0BAA0B;QAC1B,wEAAwE;QACxE,6BAA6B;QAC7B,WAAW;QACX,WAAW;QACX,iBAAiB;QACjB,yBAAyB;QACzB,qBAAqB;QACrB,mBAAmB;QACnB,uBAAuB;QACvB,qBAAqB;QACrB,oBAAoB;QACpB,qBAAqB;QACrB,kBAAkB;QAClB,qBAAqB;QACrB,KAAK;QACL,wDAAwD;QACxD,UAAU;QACV,sFAAsF;QACtF,4BAA4B;QAC5B,yBAAyB;QACzB,oBAAoB;QACpB,oBAAoB;QACpB,6BAA6B;QAC7B,uBAAuB;QACvB,KAAK;QACL,aAAa;QACb,oBAAoB;QACpB,0BAA0B;QAC1B,yBAAyB;QACzB,iCAAiC;QACjC,+CAA+C;QAC/C,gBAAgB;QAChB,qBAAqB;QACrB,KAAK;QACL,mBAAmB;QACnB,sBAAsB;QACtB,uBAAuB;QACvB,2BAA2B;QAC3B,6BAA6B;QAC7B,KAAK;QACL,YAAY;QACZ,2BAA2B;QAC3B,0BAA0B;QAC1B,uBAAuB;QACvB,0BAA0B;QAC1B,sBAAsB;QACtB,wCAAwC;QACxC,6BAA6B;QAC7B,eAAe;QACf,KAAK;QACL,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,yBAAyB;QACzB,+BA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AoD;QACpD,oEAAoE;QACpE,KAAK;QACL,IAAI;QACJ,gBAAgB;QAChB,kBAAkB;QAClB,4BAA4B;QAC5B,kCAAkC;QAClC,iCAAiC;QACjC,sCAAsC;QACtC,aAAa;QACb,2EAA2E;QAC3E,8DAA8D;QAC9D,kCAAkC;QAClC,iCAAiC;QACjC,sCAAsC;QACtC,oBAAoB;QACpB,OAAO;QACP,aAAa;QACb,WAAW;QACX,SAAS,CACV,CAAA;AACH,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
|
-
import { existsSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { resolve } from 'node:path';
|
|
5
5
|
import { defineCommand, runMain } from 'citty';
|
|
6
6
|
import { deparseSync, loadModule, parseSync } from 'pgsql-parser';
|
|
@@ -516,6 +516,39 @@ async function tryWireRestore(opts) {
|
|
|
516
516
|
await cleanupBrokenTriggers(db);
|
|
517
517
|
await db.exec('SET search_path TO public');
|
|
518
518
|
log.orez(`restored ${opts.sqlFile} via wire protocol (${executed} statements, ${skipped} skipped)`);
|
|
519
|
+
// clear zero replica so it does a fresh sync from restored upstream
|
|
520
|
+
// this is critical: without it, zero-cache will have stale table list
|
|
521
|
+
const orezDir = resolve(opts.dataDir);
|
|
522
|
+
for (const file of [
|
|
523
|
+
'zero-replica.db',
|
|
524
|
+
'zero-replica.db-shm',
|
|
525
|
+
'zero-replica.db-wal',
|
|
526
|
+
'zero-replica.db-wal2',
|
|
527
|
+
]) {
|
|
528
|
+
try {
|
|
529
|
+
unlinkSync(resolve(orezDir, file));
|
|
530
|
+
}
|
|
531
|
+
catch { }
|
|
532
|
+
}
|
|
533
|
+
// also clear CVR/CDB state
|
|
534
|
+
const { rmSync } = await import('node:fs');
|
|
535
|
+
for (const dir of ['pgdata-cvr', 'pgdata-cdb']) {
|
|
536
|
+
try {
|
|
537
|
+
rmSync(resolve(orezDir, dir), { recursive: true, force: true });
|
|
538
|
+
}
|
|
539
|
+
catch { }
|
|
540
|
+
}
|
|
541
|
+
log.orez('cleared zero replica');
|
|
542
|
+
// signal the running orez process to restart zero-cache
|
|
543
|
+
const pidFile = resolve(orezDir, 'orez.pid');
|
|
544
|
+
try {
|
|
545
|
+
const pid = parseInt(readFileSync(pidFile, 'utf-8').trim(), 10);
|
|
546
|
+
process.kill(pid, 'SIGUSR1');
|
|
547
|
+
log.orez('signaled orez to restart zero-cache');
|
|
548
|
+
}
|
|
549
|
+
catch {
|
|
550
|
+
log.orez('(restart orez to pick up changes)');
|
|
551
|
+
}
|
|
519
552
|
return true;
|
|
520
553
|
}
|
|
521
554
|
finally {
|
|
@@ -617,6 +650,7 @@ const pgRestoreCommand = defineCommand({
|
|
|
617
650
|
password: args['pg-password'],
|
|
618
651
|
clean: args.clean,
|
|
619
652
|
sqlFile,
|
|
653
|
+
dataDir: args['data-dir'],
|
|
620
654
|
});
|
|
621
655
|
if (restored)
|
|
622
656
|
return;
|