pgserve 2.2.0 → 2.2.2

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/bin/pgserve-wrapper.cjs +1 -0
  3. package/console/dist/app.js +121 -0
  4. package/console/dist/index.html +13 -0
  5. package/package.json +12 -6
  6. package/scripts/postinstall.cjs +60 -0
  7. package/scripts/test-bun-self-heal.sh +163 -0
  8. package/scripts/test-npx.sh +60 -0
  9. package/src/cli-install.cjs +14 -0
  10. package/src/cli-ui.cjs +19 -2
  11. package/src/upgrade/index.js +65 -0
  12. package/src/upgrade/runner.js +23 -0
  13. package/src/upgrade/steps/binary-cache-flush.js +67 -0
  14. package/src/upgrade/steps/consumer-signal.js +40 -0
  15. package/src/upgrade/steps/env-refresh.js +89 -0
  16. package/src/upgrade/steps/health-validate.js +53 -0
  17. package/src/upgrade/steps/plpgsql-resolve.js +66 -0
  18. package/src/upgrade/steps/port-reconcile.js +52 -0
  19. package/console/README.md +0 -131
  20. package/console/api.js +0 -173
  21. package/console/app.jsx +0 -483
  22. package/console/components.jsx +0 -167
  23. package/console/data.jsx +0 -350
  24. package/console/index.html +0 -31
  25. package/console/screens/databases.jsx +0 -5
  26. package/console/screens/health.jsx +0 -5
  27. package/console/screens/ingress.jsx +0 -5
  28. package/console/screens/optimizer.jsx +0 -5
  29. package/console/screens/rlm-sim.jsx +0 -5
  30. package/console/screens/rlm-trace.jsx +0 -5
  31. package/console/screens/security.jsx +0 -5
  32. package/console/screens/settings.jsx +0 -611
  33. package/console/screens/sql.jsx +0 -5
  34. package/console/screens/sync.jsx +0 -5
  35. package/console/screens/tables.jsx +0 -5
  36. package/console/tweaks-panel.jsx +0 -425
  37. /package/console/{colors_and_type.css → dist/colors_and_type.css} +0 -0
  38. /package/console/{console.css → dist/console.css} +0 -0
@@ -1,611 +0,0 @@
1
- /* screens/settings.jsx — autopg console Settings vertical.
2
- *
3
- * Renders the 6-section settings schema (server / runtime / sync / supervision
4
- * / postgres / ui) read from `GET /api/settings`. Type-aware controls dispatch
5
- * on the schema descriptor's `type` (int → number input, bool → toggle, enum
6
- * → segmented control, string → text input). The postgres section also exposes
7
- * a raw passthrough panel (`postgres._extra`) with add/remove rows.
8
- *
9
- * Cross-cutting concerns:
10
- * - sources[key] starting with "env:" → yellow OVERRIDDEN BY ENV chip
11
- * - server-returned validation errors render inline beneath the offending row
12
- * - 409 ETAG_MISMATCH responses surface a banner offering "reload" rather
13
- * than overwriting the on-disk state
14
- * - "Save & Restart" PUTs then POSTs /api/restart sequentially
15
- *
16
- * The schema descriptors are mirrored here from src/settings-schema.cjs. The
17
- * UI lives at the boundary so it can render labels without an extra round-trip
18
- * — the server is still the source of truth for validation. If the schema
19
- * shape changes, this mirror needs updating in lockstep (Group 1's schema
20
- * file ships as `version: 1`; this is the v1 view).
21
- */
22
-
23
- const SETTINGS_SCHEMA_VIEW = {
24
- server: {
25
- label: 'server',
26
- hint: 'router · postgres backend',
27
- fields: [
28
- { key: 'port', type: 'int', label: 'router port', hint: 'TCP port clients connect to' },
29
- { key: 'host', type: 'string', label: 'bind host', hint: 'router listen address' },
30
- { key: 'pgPort', type: 'int', label: 'backend port', hint: 'internal postgres TCP port' },
31
- { key: 'pgSocketPath', type: 'string', label: 'backend socket', hint: 'unix socket path (blank = TCP only)', allowEmpty: true },
32
- { key: 'pgUser', type: 'string', label: 'backend user', hint: 'postgres superuser' },
33
- { key: 'pgPassword', type: 'password', label: 'backend password', hint: 'stored at chmod 0600' },
34
- ],
35
- },
36
- runtime: {
37
- label: 'runtime',
38
- hint: 'observability · cluster · auto-provisioning',
39
- fields: [
40
- { key: 'logLevel', type: 'enum', label: 'log level', options: ['debug', 'info', 'warn', 'error'] },
41
- { key: 'autoProvision', type: 'bool', label: 'auto-provision', hint: 'auto-create missing databases on first connect' },
42
- { key: 'enablePgvector', type: 'bool', label: 'enable pgvector', hint: 'load pgvector on database create' },
43
- { key: 'dataDir', type: 'string', label: 'data dir', hint: 'PG cluster dir (blank = <configDir>/data)', allowEmpty: true },
44
- { key: 'cluster', type: 'enum', label: 'cluster mode', options: ['auto', 'on', 'off'], hint: 'auto = on for multi-core hosts (--cluster / --no-cluster)' },
45
- { key: 'workers', type: 'int', label: 'workers', hint: '0 = CPU cores; explicit count overrides (--workers)' },
46
- { key: 'ramMode', type: 'bool', label: 'ram mode', hint: 'Linux only · /dev/shm storage, ~2x faster (--ram)' },
47
- { key: 'statsDashboard', type: 'bool', label: 'TTY stats dashboard', hint: 'show live stats when running in foreground (--stats / --no-stats)' },
48
- ],
49
- },
50
- sync: {
51
- label: 'sync',
52
- hint: 'logical replication',
53
- fields: [
54
- { key: 'enabled', type: 'bool', label: 'enable sync', hint: 'WAL-based logical replication; pairs with WAL GUCs below' },
55
- { key: 'url', type: 'password', label: 'upstream URL', hint: 'postgresql://user:pass@host:port/db (--sync-to)', allowEmpty: true },
56
- { key: 'databases', type: 'string', label: 'databases', hint: 'glob patterns, comma-separated (--sync-databases)' },
57
- ],
58
- },
59
- supervision: {
60
- label: 'supervision',
61
- hint: 'pm2 lifecycle',
62
- fields: [
63
- { key: 'maxMemory', type: 'string', label: 'max memory', hint: 'pm2 memory ceiling (e.g. 4G)' },
64
- { key: 'maxRestarts', type: 'int', label: 'max restarts', hint: 'pm2 rapid-restart cap' },
65
- { key: 'minUptimeMs', type: 'int', label: 'min uptime (ms)', hint: 'window for healthy-start tracking' },
66
- { key: 'restartDelayMs', type: 'int', label: 'restart delay (ms)', hint: 'pm2 fixed delay between restarts' },
67
- { key: 'expBackoffRestartDelayMs', type: 'int', label: 'backoff start (ms)', hint: 'initial exponential-backoff delay' },
68
- { key: 'expBackoffMaxMs', type: 'int', label: 'backoff cap (ms)', hint: 'maximum exponential-backoff value' },
69
- { key: 'killTimeoutMs', type: 'int', label: 'kill timeout (ms)', hint: 'graceful shutdown window before SIGKILL' },
70
- { key: 'logDateFormat', type: 'string', label: 'log date format', hint: 'pm2 log timestamp pattern' },
71
- ],
72
- },
73
- security: {
74
- label: 'security',
75
- hint: 'control-socket peer auth',
76
- fields: [
77
- { key: 'handshakeDeadlineMs', type: 'int', label: 'handshake deadline (ms)', hint: 'force-close peers stuck in pre-handshake state' },
78
- ],
79
- },
80
- audit: {
81
- label: 'audit',
82
- hint: 'event sink',
83
- fields: [
84
- { key: 'target', type: 'string', label: 'audit target', hint: 'JSONL file path or HTTP endpoint (blank = disabled)', allowEmpty: true },
85
- ],
86
- },
87
- postgres: {
88
- label: 'postgres GUCs',
89
- hint: 'curated 14 + raw passthrough',
90
- fields: [
91
- { key: 'max_connections', type: 'int', label: 'max_connections' },
92
- { key: 'shared_buffers', type: 'string', label: 'shared_buffers' },
93
- { key: 'work_mem', type: 'string', label: 'work_mem' },
94
- { key: 'maintenance_work_mem', type: 'string', label: 'maintenance_work_mem' },
95
- { key: 'effective_cache_size', type: 'string', label: 'effective_cache_size' },
96
- { key: 'wal_level', type: 'enum', label: 'wal_level', options: ['minimal', 'replica', 'logical'] },
97
- { key: 'max_replication_slots', type: 'int', label: 'max_replication_slots' },
98
- { key: 'max_wal_senders', type: 'int', label: 'max_wal_senders' },
99
- { key: 'wal_keep_size', type: 'string', label: 'wal_keep_size' },
100
- { key: 'log_statement', type: 'enum', label: 'log_statement', options: ['none', 'ddl', 'mod', 'all'] },
101
- { key: 'log_min_duration_statement', type: 'int', label: 'log_min_duration_statement' },
102
- { key: 'statement_timeout', type: 'int', label: 'statement_timeout' },
103
- { key: 'idle_in_transaction_session_timeout', type: 'int', label: 'idle_in_transaction_session_timeout' },
104
- { key: 'autovacuum', type: 'bool', label: 'autovacuum' },
105
- ],
106
- },
107
- ui: {
108
- label: 'console',
109
- hint: 'theme · density · phosphor',
110
- fields: [
111
- { key: 'theme', type: 'enum', label: 'theme', options: ['mdr', 'lumon'] },
112
- { key: 'phosphor', type: 'enum', label: 'phosphor', options: ['amber', 'green', 'white'] },
113
- { key: 'density', type: 'enum', label: 'density', options: ['compact', 'comfortable', 'spacious'] },
114
- { key: 'crt', type: 'bool', label: 'crt scanlines' },
115
- ],
116
- },
117
- };
118
-
119
- const GUC_NAME_REGEX_VIEW = /^[a-z][a-z0-9_]*$/;
120
-
121
- function deepClone(value) {
122
- if (value === null || value === undefined) return value;
123
- if (typeof value !== 'object') return value;
124
- if (Array.isArray(value)) return value.map(deepClone);
125
- const out = {};
126
- for (const [k, v] of Object.entries(value)) out[k] = deepClone(v);
127
- return out;
128
- }
129
-
130
- function ScreenSettings({ theme: parentTheme, setTheme: parentSetTheme }) {
131
- const [loaded, setLoaded] = useState(null);
132
- const [form, setForm] = useState(null);
133
- const [errors, setErrors] = useState({});
134
- const [banner, setBanner] = useState(null); // { kind, text }
135
- const [conflict, setConflict] = useState(false);
136
- const [busy, setBusy] = useState(false);
137
- const [extraRows, setExtraRows] = useState([]);
138
- const [bootError, setBootError] = useState(null);
139
-
140
- const reload = React.useCallback(async () => {
141
- setBusy(true);
142
- setBanner(null);
143
- setConflict(false);
144
- setBootError(null);
145
- try {
146
- const data = await window.AutopgApi.getSettings();
147
- setLoaded(data);
148
- setForm(deepClone(data.settings));
149
- setErrors({});
150
- // Materialize _extra map → array of rows for UI editing.
151
- const extraMap = data?.settings?.postgres?._extra || {};
152
- const rows = Object.entries(extraMap).map(([k, v]) => ({
153
- id: `${k}-${Math.random().toString(36).slice(2, 6)}`,
154
- name: k,
155
- value: typeof v === 'string' ? v : String(v),
156
- }));
157
- setExtraRows(rows);
158
- } catch (err) {
159
- setBootError(err.message || String(err));
160
- } finally {
161
- setBusy(false);
162
- }
163
- }, []);
164
-
165
- useEffect(() => {
166
- if (!window.AutopgApi) return;
167
- reload();
168
- }, [reload]);
169
-
170
- const dirty = useMemo(() => {
171
- if (!loaded || !form) return false;
172
- if (JSON.stringify(stripExtra(loaded.settings)) !== JSON.stringify(stripExtra(form))) return true;
173
- return !sameExtraMap(loaded.settings?.postgres?._extra || {}, rowsToMap(extraRows));
174
- }, [loaded, form, extraRows]);
175
-
176
- const sources = loaded?.sources || {};
177
-
178
- const setField = (section, key, value) => {
179
- setForm((prev) => {
180
- const next = deepClone(prev);
181
- if (!next[section]) next[section] = {};
182
- next[section][key] = value;
183
- return next;
184
- });
185
- // Clear the field's stale error on edit.
186
- setErrors((prev) => {
187
- const dotted = `${section}.${key}`;
188
- if (!(dotted in prev)) return prev;
189
- const out = { ...prev };
190
- delete out[dotted];
191
- return out;
192
- });
193
- };
194
-
195
- const buildPatch = () => {
196
- if (!form) return {};
197
- const patch = deepClone(stripExtra(form));
198
- patch.postgres = patch.postgres || {};
199
- patch.postgres._extra = rowsToMap(extraRows);
200
- return patch;
201
- };
202
-
203
- const validateExtraClient = () => {
204
- const out = {};
205
- const seen = new Set();
206
- for (const row of extraRows) {
207
- const trimmed = (row.name || '').trim();
208
- const dotted = `postgres._extra.${trimmed || row.id}`;
209
- if (!trimmed) {
210
- out[dotted] = { code: 'INVALID_GUC_NAME', message: 'name is required' };
211
- continue;
212
- }
213
- if (!GUC_NAME_REGEX_VIEW.test(trimmed)) {
214
- out[dotted] = {
215
- code: 'INVALID_GUC_NAME',
216
- message: 'must match /^[a-z][a-z0-9_]*$/',
217
- };
218
- continue;
219
- }
220
- if (seen.has(trimmed)) {
221
- out[dotted] = { code: 'INVALID_GUC_NAME', message: 'duplicate key' };
222
- continue;
223
- }
224
- seen.add(trimmed);
225
- if (typeof row.value === 'string' && /[\n\r\0]/.test(row.value)) {
226
- out[dotted] = { code: 'INVALID_GUC_VALUE', message: 'value contains forbidden control character' };
227
- }
228
- if (typeof row.value === 'string' && row.value.startsWith('-')) {
229
- out[dotted] = { code: 'INVALID_GUC_VALUE', message: 'value must not start with "-"' };
230
- }
231
- }
232
- return out;
233
- };
234
-
235
- const handleSave = async ({ thenRestart = false } = {}) => {
236
- setBusy(true);
237
- setBanner(null);
238
-
239
- const clientErrors = validateExtraClient();
240
- if (Object.keys(clientErrors).length) {
241
- setErrors((prev) => ({ ...prev, ...clientErrors }));
242
- setBanner({ kind: 'err', text: 'fix highlighted fields before saving' });
243
- setBusy(false);
244
- return;
245
- }
246
-
247
- try {
248
- const patch = buildPatch();
249
- const res = await window.AutopgApi.putSettings(patch);
250
- setBanner({ kind: 'ok', text: thenRestart ? 'saved · restarting…' : 'saved' });
251
- // Optimistically refresh the loaded baseline + etag so the dirty
252
- // flag clears without a second full reload.
253
- const next = { ...loaded, settings: deepClone(form), etag: res.etag };
254
- next.settings.postgres = next.settings.postgres || {};
255
- next.settings.postgres._extra = rowsToMap(extraRows);
256
- setLoaded(next);
257
- setErrors({});
258
- setConflict(false);
259
-
260
- if (thenRestart) {
261
- try {
262
- await window.AutopgApi.restart();
263
- setBanner({ kind: 'ok', text: 'saved · restart triggered' });
264
- } catch (err) {
265
- setBanner({ kind: 'err', text: `restart failed: ${err.message || err.code}` });
266
- }
267
- }
268
- // Always re-fetch so sources/etag are canonical.
269
- await reload();
270
- } catch (err) {
271
- if (err.code === 'ETAG_MISMATCH') {
272
- setConflict(true);
273
- setBanner({ kind: 'warn', text: 'settings changed on disk — reload before saving' });
274
- } else if (err.field) {
275
- setErrors((prev) => ({ ...prev, [err.field]: { code: err.code, message: err.message } }));
276
- setBanner({ kind: 'err', text: `${err.code}: ${err.field}` });
277
- } else {
278
- setBanner({ kind: 'err', text: err.message || String(err) });
279
- }
280
- } finally {
281
- setBusy(false);
282
- }
283
- };
284
-
285
- const handleDiscard = () => {
286
- if (!loaded) return;
287
- setForm(deepClone(loaded.settings));
288
- const extraMap = loaded?.settings?.postgres?._extra || {};
289
- const rows = Object.entries(extraMap).map(([k, v]) => ({
290
- id: `${k}-${Math.random().toString(36).slice(2, 6)}`,
291
- name: k,
292
- value: typeof v === 'string' ? v : String(v),
293
- }));
294
- setExtraRows(rows);
295
- setErrors({});
296
- setBanner(null);
297
- };
298
-
299
- if (bootError) {
300
- return (
301
- <div className="page">
302
- <div className="page-head"><h1>settings</h1></div>
303
- <div className="panel" style={{ padding: 16, color: 'var(--err, #d66)' }}>
304
- could not load settings · {bootError}
305
- </div>
306
- </div>
307
- );
308
- }
309
- if (!loaded || !form) {
310
- return (
311
- <div className="page">
312
- <div className="page-head"><h1>settings</h1></div>
313
- <div className="panel" style={{ padding: 16 }}>loading…</div>
314
- </div>
315
- );
316
- }
317
-
318
- return (
319
- <div className="page" style={{ maxWidth: 960 }}>
320
- <div className="page-head">
321
- <h1>settings</h1>
322
- <span className="crumb">/ {loaded.path || '~/.autopg/settings.json'}</span>
323
- <div className="right">
324
- <Btn onClick={handleDiscard}>discard</Btn>
325
- <Btn onClick={() => handleSave({ thenRestart: false })} title="persist to ~/.autopg/settings.json">save</Btn>
326
- <Btn kind="primary" onClick={() => handleSave({ thenRestart: true })}>save &amp; restart</Btn>
327
- </div>
328
- </div>
329
-
330
- {banner && (
331
- <Alert
332
- kind={banner.kind === 'ok' ? 'ok' : banner.kind === 'warn' ? 'warn' : 'err'}
333
- label={banner.kind === 'ok' ? 'ok' : banner.kind === 'warn' ? 'note' : 'error'}
334
- actions={conflict ? <Btn kind="primary" onClick={reload}>reload</Btn> : null}
335
- >
336
- {banner.text}
337
- </Alert>
338
- )}
339
-
340
- {Object.entries(SETTINGS_SCHEMA_VIEW).map(([section, view]) => (
341
- <SettingsSection
342
- key={section}
343
- section={section}
344
- view={view}
345
- values={form[section] || {}}
346
- sources={sources}
347
- errors={errors}
348
- onChange={setField}
349
- />
350
- ))}
351
-
352
- <ExtraPanel
353
- rows={extraRows}
354
- setRows={setExtraRows}
355
- sources={sources}
356
- errors={errors}
357
- clearError={(name) => setErrors((p) => {
358
- const dotted = `postgres._extra.${name}`;
359
- if (!(dotted in p)) return p;
360
- const out = { ...p };
361
- delete out[dotted];
362
- return out;
363
- })}
364
- />
365
-
366
- <div style={{
367
- marginTop: 32, paddingTop: 18, borderTop: '1px solid var(--line)',
368
- display: 'flex', justifyContent: 'space-between',
369
- fontSize: 11, color: 'var(--text-dim)',
370
- }}>
371
- <span>autopg · settings v1 · {dirty ? <span style={{ color: 'var(--accent)' }}>dirty</span> : 'clean'}</span>
372
- <span>etag · <span style={{ color: 'var(--accent)' }}>{(loaded.etag || '').slice(0, 14)}…</span></span>
373
- </div>
374
- </div>
375
- );
376
- }
377
-
378
- function SettingsSection({ section, view, values, sources, errors, onChange }) {
379
- return (
380
- <div style={{ marginBottom: 24 }}>
381
- <BracketH hint={view.hint}>{view.label}</BracketH>
382
- <div className="panel">
383
- {view.fields.map((field) => (
384
- <SettingsRow
385
- key={field.key}
386
- section={section}
387
- field={field}
388
- value={values[field.key]}
389
- source={sources[`${section}.${field.key}`]}
390
- error={errors[`${section}.${field.key}`]}
391
- onChange={onChange}
392
- />
393
- ))}
394
- </div>
395
- </div>
396
- );
397
- }
398
-
399
- function SettingsRow({ section, field, value, source, error, onChange }) {
400
- const dotted = `${section}.${field.key}`;
401
- const overridden = typeof source === 'string' && source.startsWith('env:');
402
- return (
403
- <div style={{ padding: '12px 0', borderBottom: '1px dashed var(--line)' }}>
404
- <div style={{
405
- display: 'grid', gridTemplateColumns: '220px 1fr', gap: 16, alignItems: 'center',
406
- }}>
407
- <div>
408
- <div style={{ fontSize: 12, color: 'var(--text-primary)' }}>
409
- {field.label}
410
- {overridden && (
411
- <span
412
- title={`source: ${source}`}
413
- style={{
414
- marginLeft: 8, padding: '1px 6px', fontSize: 9,
415
- letterSpacing: '0.08em', textTransform: 'uppercase',
416
- background: 'var(--c-audit, #D6A574)', color: '#1f1a0c',
417
- borderRadius: 3,
418
- }}
419
- >
420
- overridden by env
421
- </span>
422
- )}
423
- </div>
424
- {field.hint && <div style={{ fontSize: 11, color: 'var(--text-dim)', marginTop: 2 }}>{field.hint}</div>}
425
- </div>
426
- <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
427
- <FieldControl
428
- field={field}
429
- value={value}
430
- disabled={overridden}
431
- onChange={(v) => onChange(section, field.key, v)}
432
- />
433
- <span style={{ fontSize: 10, color: 'var(--text-dim)', marginLeft: 'auto' }}>
434
- {source || 'default'}
435
- </span>
436
- </div>
437
- </div>
438
- {error && (
439
- <div style={{
440
- marginTop: 6, marginLeft: 236, fontSize: 11, color: 'var(--err, #d66)',
441
- }}>
442
- {error.code}: {error.message}
443
- </div>
444
- )}
445
- </div>
446
- );
447
- }
448
-
449
- function FieldControl({ field, value, disabled, onChange }) {
450
- if (field.type === 'bool') {
451
- return (
452
- <Seg
453
- value={value ? 'on' : 'off'}
454
- onChange={(v) => onChange(v === 'on')}
455
- options={[{ value: 'off', label: 'OFF' }, { value: 'on', label: 'ON' }]}
456
- />
457
- );
458
- }
459
- if (field.type === 'enum') {
460
- return (
461
- <Seg
462
- value={value}
463
- onChange={onChange}
464
- options={field.options.map((o) => ({ value: o, label: o.toUpperCase() }))}
465
- />
466
- );
467
- }
468
- if (field.type === 'int') {
469
- return (
470
- <input
471
- className="input"
472
- type="number"
473
- value={value ?? ''}
474
- disabled={disabled}
475
- style={{ width: 160 }}
476
- onChange={(e) => {
477
- const raw = e.target.value;
478
- if (raw === '') return onChange(null);
479
- const n = Number.parseInt(raw, 10);
480
- if (Number.isFinite(n)) onChange(n);
481
- }}
482
- />
483
- );
484
- }
485
- if (field.type === 'password') {
486
- return (
487
- <input
488
- className="input"
489
- type="password"
490
- value={value ?? ''}
491
- disabled={disabled}
492
- style={{ width: 240 }}
493
- onChange={(e) => onChange(e.target.value)}
494
- />
495
- );
496
- }
497
- return (
498
- <input
499
- className="input"
500
- type="text"
501
- value={value ?? ''}
502
- disabled={disabled}
503
- style={{ width: 240 }}
504
- onChange={(e) => onChange(e.target.value)}
505
- />
506
- );
507
- }
508
-
509
- function ExtraPanel({ rows, setRows, sources, errors, clearError }) {
510
- const addRow = () => {
511
- setRows((prev) => [
512
- ...prev,
513
- { id: `new-${Math.random().toString(36).slice(2, 8)}`, name: '', value: '' },
514
- ]);
515
- };
516
- const removeRow = (id) => setRows((prev) => prev.filter((r) => r.id !== id));
517
- const updateRow = (id, patch) => setRows((prev) => prev.map((r) => (r.id === id ? { ...r, ...patch } : r)));
518
-
519
- return (
520
- <div style={{ marginBottom: 24 }}>
521
- <BracketH hint="raw -c key=value passthrough; validated against /^[a-z][a-z0-9_]*$/">postgres._extra</BracketH>
522
- <div className="panel">
523
- {rows.length === 0 && (
524
- <div style={{ padding: '12px 0', color: 'var(--text-dim)', fontSize: 11 }}>
525
- no raw GUCs configured. add one to forward an unsupported `-c key=value` to postgres.
526
- </div>
527
- )}
528
- {rows.map((row) => {
529
- const dotted = `postgres._extra.${row.name}`;
530
- const error = errors[dotted];
531
- const source = sources[dotted];
532
- const overridden = typeof source === 'string' && source.startsWith('env:');
533
- return (
534
- <div key={row.id} style={{ padding: '8px 0', borderBottom: '1px dashed var(--line)' }}>
535
- <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
536
- <input
537
- className="input"
538
- type="text"
539
- placeholder="guc_name"
540
- value={row.name}
541
- style={{ width: 240 }}
542
- onChange={(e) => {
543
- clearError(row.name);
544
- updateRow(row.id, { name: e.target.value });
545
- }}
546
- />
547
- <span style={{ color: 'var(--text-dim)' }}>=</span>
548
- <input
549
- className="input"
550
- type="text"
551
- placeholder="value"
552
- value={row.value}
553
- style={{ flex: 1 }}
554
- onChange={(e) => {
555
- clearError(row.name);
556
- updateRow(row.id, { value: e.target.value });
557
- }}
558
- />
559
- {overridden && (
560
- <span style={{
561
- padding: '1px 6px', fontSize: 9, letterSpacing: '0.08em', textTransform: 'uppercase',
562
- background: 'var(--c-audit, #D6A574)', color: '#1f1a0c', borderRadius: 3,
563
- }}>overridden by env</span>
564
- )}
565
- <Btn size="sm" onClick={() => removeRow(row.id)}>remove</Btn>
566
- </div>
567
- {error && (
568
- <div style={{ marginTop: 4, fontSize: 11, color: 'var(--err, #d66)' }}>
569
- {error.code}: {error.message}
570
- </div>
571
- )}
572
- </div>
573
- );
574
- })}
575
- <div style={{ paddingTop: 12 }}>
576
- <Btn size="sm" onClick={addRow}>+ add row</Btn>
577
- </div>
578
- </div>
579
- </div>
580
- );
581
- }
582
-
583
- function stripExtra(settings) {
584
- if (!settings) return settings;
585
- const out = deepClone(settings);
586
- if (out.postgres) delete out.postgres._extra;
587
- return out;
588
- }
589
-
590
- function rowsToMap(rows) {
591
- const out = {};
592
- for (const row of rows) {
593
- const name = (row.name || '').trim();
594
- if (!name) continue;
595
- out[name] = row.value;
596
- }
597
- return out;
598
- }
599
-
600
- function sameExtraMap(a, b) {
601
- const ak = Object.keys(a).sort();
602
- const bk = Object.keys(b).sort();
603
- if (ak.length !== bk.length) return false;
604
- for (let i = 0; i < ak.length; i++) {
605
- if (ak[i] !== bk[i]) return false;
606
- if (String(a[ak[i]]) !== String(b[bk[i]])) return false;
607
- }
608
- return true;
609
- }
610
-
611
- window.ScreenSettings = ScreenSettings;
@@ -1,5 +0,0 @@
1
- /* screens/sql.jsx — placeholder. */
2
- function ScreenSQL() {
3
- return window.ComingSoon({ title: 'sql editor', crumb: '/ multi-tab · history · explain' });
4
- }
5
- window.ScreenSQL = ScreenSQL;
@@ -1,5 +0,0 @@
1
- /* screens/sync.jsx — placeholder. */
2
- function ScreenSync() {
3
- return window.ComingSoon({ title: 'sync & backups', crumb: '/ logical replication · snapshots' });
4
- }
5
- window.ScreenSync = ScreenSync;
@@ -1,5 +0,0 @@
1
- /* screens/tables.jsx — placeholder. */
2
- function ScreenTables() {
3
- return window.ComingSoon({ title: 'tables', crumb: '/ schema · columns · indexes' });
4
- }
5
- window.ScreenTables = ScreenTables;