@awesomedog/dbjack 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +253 -2
- package/bin/dbjack.js +56 -0
- package/docs/img/dark.svg +455 -0
- package/docs/index.html +667 -0
- package/docs/specs/prd.md +289 -0
- package/package.json +34 -4
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# dbjack · PRD
|
|
2
|
+
|
|
3
|
+
## 1. Positioning and Principles
|
|
4
|
+
|
|
5
|
+
- **What**: a single-binary web database console that connects directly to MySQL / MariaDB, PostgreSQL, SQLite, SQL Server, Oracle, Elasticsearch, MongoDB, and Redis.
|
|
6
|
+
- **Who**:
|
|
7
|
+
- Developers: view and edit data, run queries, change schemas, move data, usually against local / test / staging databases;
|
|
8
|
+
- QA: create, verify, and clean up test data; export it for review;
|
|
9
|
+
- Backend projects: mount at `/admin/db` as a ready-made admin page instead of writing a CRUD back office.
|
|
10
|
+
- Desktop client users: need a lightweight alternative to DataGrip and similar GUI clients, with multi engine support;
|
|
11
|
+
- **Architecture**: the Go backend handles only connections and sessions, execution and cancellation, metadata and DDL generation, and streaming import / export; UI, editors, and settings live in the React frontend.
|
|
12
|
+
- **Stack**: React, Tailwind, shadcn, Zustand, pnpm, and other SOTA tooling.
|
|
13
|
+
- **Differentiation**:
|
|
14
|
+
- vs. DataGrip, adds web access, single-binary deployment, embedding, and deep links and drops IDE features (refactoring, VCS, debugging, ER design);
|
|
15
|
+
- vs. phpMyAdmin, less UI, more engines;
|
|
16
|
+
- vs. Django Admin and the like, no framework or ORM lock-in and no model registration code — it connects directly to any data store.
|
|
17
|
+
- **Typical flow**: find a table in Database Explorer / Search Everywhere → open it in Data Editor and enter a WHERE → edit cells → Submit (optionally Preview Pending Changes first) → run aggregates in Query Console → Export Data to CSV.
|
|
18
|
+
|
|
19
|
+
**Principles**
|
|
20
|
+
|
|
21
|
+
1. **Six jobs only**: connect, find objects, read data, edit data, change schema, move data. Anything that doesn't fit is out.
|
|
22
|
+
2. **Follow GUI Client**: for in-scope features, reuse its terms, entry points, and interactions as-is; don't invent new ones. Generated statements behave the same way for preview, copy, edit, and execute; preview is never mandatory.
|
|
23
|
+
3. **Single binary**: pure Go, no cgo, frontend assets embedded. Never shells out to mysqldump / pg_dump / mongodump / redis-cli; import / export is built in, and the only formats are SQL, CSV, JSON / ndjson, and Redis command files.
|
|
24
|
+
4. **Hands off the target database**: dbjack itself never creates objects in a target database (databases and tables the user creates excepted).
|
|
25
|
+
5. **Permissions and limits belong to the database and the deployer**: what can be executed depends solely on the database identity of the connection. No read-only mode, no read / write statement filtering, no app-level limits on connections, statement timeouts, or fetch size. No authentication, access gate, or network-exposure restriction; who can reach dbjack is up to the deployer (reverse proxy, host app). All deployment modes have identical features.
|
|
26
|
+
6. **Engine capabilities rule**: transactions, rollback, cancellation, connection persistence, and similar behavior depend on engine support; this is not repeated below.
|
|
27
|
+
|
|
28
|
+
## 2. Interface
|
|
29
|
+
|
|
30
|
+
Layout:
|
|
31
|
+
|
|
32
|
+
- Left: Database Explorer (across data sources)
|
|
33
|
+
- Center: editor tabs (Query Console, Data Editor, DDL)
|
|
34
|
+
- Bottom: Services tool window (Output / Result), Terminal tool window
|
|
35
|
+
- Status bar: execution and import / export progress
|
|
36
|
+
|
|
37
|
+
Navigation is limited to Speed Search in Database Explorer and Search Everywhere (double Shift; searches objects, actions, and Live Templates). No separate Go to Database Object / Find Action. No shortcuts that conflict with the browser; the keymap is not customizable.
|
|
38
|
+
|
|
39
|
+
## 3. Engine Capability Matrix
|
|
40
|
+
|
|
41
|
+
| | MySQL / MariaDB | PostgreSQL | SQLite | MongoDB | Redis | SQL Server | Oracle | Elasticsearch |
|
|
42
|
+
|---|---|---|---|---|---|---|---|---|
|
|
43
|
+
| Data source | Server; the database in the URI is the default | Server; the database in the URI is the default | A single file | Server / replica set / sharded cluster (read preference from the URI); the database in the URI is the default | Standalone / cluster (auto-detected from any node); the DB index in the URI is the default | Server; `database=` in the URI is the default | Server (service name in the URI); the login user's schema is the default | Cluster over HTTP(S); read-only through ES SQL |
|
|
44
|
+
| Database Explorer hierarchy | database › tables, views, routines, triggers, events | database › schema › tables, views, materialized views, functions, sequences, types | main › tables, views, triggers | database › collections, views | DB 0–15 (cluster: 0 only) › key prefixes grouped by delimiter › keys | database › schema › tables, views, routines, triggers, sequences, types | schema › tables, views, materialized views, routines (incl. packages), triggers, sequences, types | cluster › tables (indices), views (aliases) |
|
|
45
|
+
| Query Console language | Multi-statement SQL | Multi-statement SQL | Multi-statement SQL | mongo shell subset + `db.runCommand({})` | Redis commands, one per line, batched via pipeline | Multi-statement T-SQL; `GO` ends a batch | Multi-statement SQL; PL/SQL blocks end with `/` | ES SQL |
|
|
46
|
+
| Default result view | Table | Table | Table | Tree, switchable to Table | Text / Table / Tree by type | Table | Table | Table |
|
|
47
|
+
| DDL source | `SHOW CREATE` | Rebuilt from system catalogs (tables / columns / indexes / constraints / sequences / types / views / functions, with dependencies and creation order) | `sqlite_schema.sql` | — | — | Rebuilt from system catalogs; modules from `sys.sql_modules` | `DBMS_METADATA` | Index mapping |
|
|
48
|
+
| Export / Import | SQL, CSV, JSON / ndjson | SQL, CSV (COPY), JSON / ndjson | SQL, CSV, JSON / ndjson | JSON / ndjson, CSV | Command file, JSON (import: command file only) | SQL, CSV, JSON / ndjson | SQL, CSV, JSON / ndjson | CSV, JSON / ndjson (export only) |
|
|
49
|
+
| Cancel execution | `KILL QUERY` | `pg_cancel_backend` | interrupt | `killOp` | Disconnect (session state lost) | Attention (driver) | Break (driver) | Abort the request |
|
|
50
|
+
| Explain Plan / Analyse | `EXPLAIN`; Analyse is `EXPLAIN ANALYZE` (MySQL 8.0.18+) / `ANALYZE` (MariaDB) | `EXPLAIN (FORMAT JSON)` / `(ANALYZE, FORMAT JSON)` | `EXPLAIN QUERY PLAN` | `.explain()` | — | `SHOWPLAN_XML`; Analyse is `STATISTICS XML` | `EXPLAIN PLAN` + `DBMS_XPLAN` | `EXPLAIN (PLAN EXECUTABLE)` |
|
|
51
|
+
| Transaction toolbar | Yes | Yes | Yes | — | — | Yes | Yes | — |
|
|
52
|
+
| Switch namespace | `USE` (session-scoped) | Switching database = using a session on that database; switching schema sets `search_path` | — | Switch db | `SELECT n` (not on cluster) | `USE` (session-scoped); the schema only qualifies names | `ALTER SESSION SET CURRENT_SCHEMA` | — |
|
|
53
|
+
|
|
54
|
+
**Protocol-compatible databases**: same URI scheme, treated as that engine.
|
|
55
|
+
|
|
56
|
+
- `mysql://`: TiDB, OceanBase (MySQL mode), PolarDB-MySQL / TDSQL-C, Aurora MySQL, Percona, PlanetScale / Vitess, Doris / StarRocks.
|
|
57
|
+
- `postgres://`: Supabase, Neon, TimescaleDB, Citus, Aurora PG, PolarDB-PG, YugabyteDB.
|
|
58
|
+
|
|
59
|
+
## 4. Features
|
|
60
|
+
|
|
61
|
+
### 4.1 Data Sources and Sessions
|
|
62
|
+
|
|
63
|
+
- **Data sources**: predefined only via config file / command line / environment variables (§5); changes take effect after restart. The UI never adds, edits, or deletes them. SSL / TLS, connect timeout, read preference, etc. are passed as URI parameters (PG `sslmode`, MySQL `tls`, Mongo `tlsCAFile`, Redis `rediss://`); no UI settings.
|
|
64
|
+
- **Data Sources dialog**: read-only; shows Name, masked connection info, Color, and origin (config file path / environment variable name / command line); supports Test Connection. Data Source Color applies to tabs, Database Explorer nodes, and editors.
|
|
65
|
+
- **Sessions**: each Query Console / Data Editor tab has its own session, opened on first execution. Sessions are not exposed in the UI: no creating, switching, or sharing. Operations within a session run serially; a session closes after the page has been disconnected for more than 5 minutes.
|
|
66
|
+
- **Workspace**: open tabs and unexecuted Query Console text are restored on reload / reopen. Sessions are not: a new one opens on the next execution, and prior transaction and connection state is lost.
|
|
67
|
+
- **Settings** (stored locally in the browser, not on the server): page size (default 500), confirmation policy, theme Light / Darcula, custom Live Templates.
|
|
68
|
+
|
|
69
|
+
### 4.2 Database Explorer
|
|
70
|
+
|
|
71
|
+
- **Loading**: metadata is introspected lazily and cached; Refresh a single node or everything; after DDL succeeds from Query Console or a Modify dialog, the owning namespace refreshes automatically; Speed Search filters the tree.
|
|
72
|
+
- **Search**: the first Search Everywhere against a data source fetches object names (names only) for all its namespaces at once; for Redis, only databases and prefixes are searchable.
|
|
73
|
+
- **Hover**: shows estimated row count / size from statistics, never `COUNT(*)`; hidden for engines without statistics.
|
|
74
|
+
- **Context menu**: Edit Data (same as double-click), New › Query Console (with the current context), Copy Reference, SQL Scripts (generate engine-specific SELECT / INSERT / DDL / DROP into Query Console or the clipboard), Drop, Truncate, Rename, Export Data, Import Data from File, Copy Table to. With multiple objects selected, Export Data / Copy Table to process them all at once. Dropping a database-level object (`DROP DATABASE` / `dropDatabase` / `FLUSHDB`) requires typing the database name or index.
|
|
75
|
+
- **Create / Modify** (Database / Schema / Table): Create and Modify share the same fields; non-modal; generated statements can be previewed, edited, and executed. Mongo Create Database / Collection takes only a name (creating a database also creates a collection); everything else goes through Query Console.
|
|
76
|
+
- **Other objects** (views, routines, triggers, events, sequences, types): listed only, viewed via Go to DDL. To change a definition, open its DDL in Query Console, add `OR REPLACE` / `DROP` yourself, and execute. PG materialized views: Refresh from the context menu.
|
|
77
|
+
- **Admin tasks** (server processes / active sessions and Kill, data source overview, users and privileges, server variables / status, cross-table value search) all use built-in Live Templates (§4.3); no UI.
|
|
78
|
+
|
|
79
|
+
### 4.3 Query Console
|
|
80
|
+
|
|
81
|
+
- **Editing**: per-engine highlighting and completion — SQL keywords / objects / columns (alias-aware) / functions, Redis commands and arguments, Mongo collections / methods / operators; Reformat Code, comment toggling, Find / Replace, multiple carets.
|
|
82
|
+
- **Execution**: `Ctrl/Cmd+Enter` executes the statement at the caret / the selection / everything; multiple statements yield multiple results; on error, stop or skip. Stop or a page disconnect requests cancellation; if the engine doesn't support it or cancellation fails, an explicit error is shown.
|
|
83
|
+
- **Execute to File**: executes and streams the result into a file, with the same formats and options as Export Data (§4.7), bypassing browser memory.
|
|
84
|
+
- **Namespace**: the toolbar switches MySQL database, PG database and schema, Mongo db, and Redis DB, scoped to this tab's session; switching PG database moves to a session on the target database. Data Editor is always bound to a specific object.
|
|
85
|
+
- **Transactions**: Tx: Auto / Tx: Manual and Commit / Rollback exist only for SQL engines, scoped to this tab's session.
|
|
86
|
+
- **Output**: affected rows, duration, warnings (`SHOW WARNINGS` / NOTICE); errors point to the line.
|
|
87
|
+
- **Query History**: per data source, stored locally in the browser; searchable and re-runnable.
|
|
88
|
+
- **Dangerous statements**: warnings and confirmations follow Settings; full-scan commands such as Redis `KEYS` suggest `SCAN` instead.
|
|
89
|
+
- **Live Templates**: expand via abbreviation + Tab, or insert from Search Everywhere / the menu; fill `$name$` variables one by one. Built in per engine and customizable (stored locally in the browser). Built-in ops templates replace admin UIs:
|
|
90
|
+
- MySQL: process list and Kill, largest tables, grants, variables / status, `ANALYZE / OPTIMIZE`
|
|
91
|
+
- PG: active sessions and lock waits, terminate session, table bloat, index usage, role grants, `VACUUM / REINDEX`
|
|
92
|
+
- SQLite: common `PRAGMA`s, `integrity_check`, `VACUUM`
|
|
93
|
+
- Mongo: `currentOp / killOp`, `dbStats / collStats`, `$indexStats`, profiler, `createUser`, `collMod`, `createIndex`
|
|
94
|
+
- SQL Server: active requests and `KILL`, blocking, table sizes, permissions, `sys.configurations`, `UPDATE STATISTICS` / index rebuild
|
|
95
|
+
- Oracle: `v$session` and `KILL SESSION`, blocking, segment sizes, grants, `v$parameter`, invalid objects, `DBMS_STATS`
|
|
96
|
+
- Elasticsearch: `SHOW TABLES / COLUMNS / FUNCTIONS`, top values, `MATCH`
|
|
97
|
+
- Redis: `INFO`, `SLOWLOG GET`, `CLIENT LIST`, big key scan, `ACL LIST`, `CONFIG GET`
|
|
98
|
+
- **Explain**: Explain Plan only produces the plan; Explain Analyse actually executes the statement (writes included) and is available only where the engine supports it. Results are shown as Table / JSON / Text.
|
|
99
|
+
|
|
100
|
+
### 4.4 Data Editor
|
|
101
|
+
|
|
102
|
+
- **Browsing**: pagination; column sorting (clicking a header changes ORDER BY), visibility, and width; shows the generated query, which can be opened in Query Console. By default only the current page's row count is shown; click the row counter / Last Page to get the exact total.
|
|
103
|
+
- **Filtering**: SQL uses the WHERE / ORDER BY fields; Mongo uses filter / projection / sort JSON; Redis uses MATCH within a key; context menu Filter by = / ≠ this value.
|
|
104
|
+
- **Editing**: changes are highlighted and staged; Submit sends them; Revert discards selected or all changes. Preview Pending Changes is optional; if you rewrite the generated DML, it runs separately in Query Console, not as a grid Submit. Add Row / Clone Row / Delete Rows are submitted together; Record View for form entry. Row identification, editability, and validation follow GUI Client.
|
|
105
|
+
- **Submit semantics**: for SQL engines, Submit commits under Tx: Auto; under Tx: Manual, Submit ≠ Commit — use Submit and Commit, or Rollback. Mongo / Redis Submit takes effect immediately.
|
|
106
|
+
- **Value Editor**: text, JSON (tree + edit), hex, image preview, Set NULL / Set DEFAULT; large values load on demand.
|
|
107
|
+
- **Mongo**: Tree / Table (columns flattened from sampled documents) / Text views; edit whole documents or single fields as Extended JSON; add / clone / delete documents.
|
|
108
|
+
- **Redis**: type-specific editing for string / hash / list / set / zset / stream, paginated via HSCAN / SSCAN / ZSCAN / LRANGE / XRANGE; add / edit / remove members, TTL, rename, delete; the header shows type, TTL, and length, plus encoding and memory when available.
|
|
109
|
+
|
|
110
|
+
### 4.5 Table Structure
|
|
111
|
+
|
|
112
|
+
- **View**: Database Explorer child nodes list columns (name / type / nullable / default / comment), indexes, keys and foreign keys, and triggers (indexes for Mongo). Go to DDL opens a read-only DDL tab that can be copied or opened in Query Console.
|
|
113
|
+
- **Modify**: Create / Modify Table adds, changes, and drops columns, indexes, foreign keys, and check constraints, plus table options and partitions; available fields vary by engine. The change script and any required rebuild script (including SQLite table rebuilds) can be previewed and edited before execution.
|
|
114
|
+
- **Mongo**: create indexes by writing the spec in Query Console (`createIndex` template); Drop from an index node's context menu.
|
|
115
|
+
- **Maintenance** (ANALYZE / OPTIMIZE / CHECK / VACUUM / REINDEX) uses Live Templates.
|
|
116
|
+
|
|
117
|
+
### 4.6 Result
|
|
118
|
+
|
|
119
|
+
- **Display**: virtual scrolling (smooth at 100k rows), column type icons, NULL / binary / long-text rendering; Table / Tree / Text views cover Redis RESP and Mongo documents; clicking a header sorts locally within the page; local filtering as well.
|
|
120
|
+
- **Fetching**: next page / fetch more; fetching all requires confirmation, and the dialog suggests Execute to File for large results; multiple results open in multiple tabs, with Pin Tab to keep one from being replaced. Editability and editing match Data Editor (§4.4).
|
|
121
|
+
- **Copy**: copies only the selection on the current page, through Data Extractors to the clipboard — TSV, CSV, JSON, SQL Inserts, Markdown, One-Row (usable as an `IN (…)` list). For full results, use Export Data or Execute to File (§4.7).
|
|
122
|
+
|
|
123
|
+
### 4.7 Import / Export
|
|
124
|
+
|
|
125
|
+
- **Export Data**: the source is tables / collections / databases / multiple selected objects, Data Editor's current filter, or a Result's full result set (not limited to the current page or fetched rows); Execute to File uses the same formats.
|
|
126
|
+
- SQL: structure + data / structure only / data only, multi-row INSERT, batch size
|
|
127
|
+
- CSV: separator / quotes / header / BOM
|
|
128
|
+
- JSON / ndjson
|
|
129
|
+
- Column selection; gzip for a single object, zip for multiple (one file per object); available formats vary by engine (§3)
|
|
130
|
+
- Always streamed as a download, with progress and cancellation in the browser's download manager; no server memory or disk used
|
|
131
|
+
- **Run Script**: upload / drag and drop a SQL file (SQL engines) or command file (Redis) for streaming execution; on error, stop or continue; optional single transaction. For pasted text, just use Query Console.
|
|
132
|
+
- **Import Data from File**: target an existing or new table; configure header / separator, column mapping and types (detected values are editable); preview source data, target data, and DDL. CSV → SQL table (batched INSERT / PG COPY) or Mongo collection; JSON / ndjson → Mongo (batched `insertMany`) or SQL table.
|
|
133
|
+
- **Copy Table to**: reuses the Import Data from File mapping UI; within a data source (structure / structure + data) or across data sources (same engine; tables / collections / key prefixes); multi-select in Database Explorer copies many at once — i.e. "pull the test database down to local".
|
|
134
|
+
- All three run in the current page: uploads are streamed, the status bar shows progress, and they can be canceled; a page disconnect requests cancellation; if the engine doesn't support it or cancellation fails, an explicit error is shown.
|
|
135
|
+
|
|
136
|
+
### 4.8 Engine-Specific
|
|
137
|
+
|
|
138
|
+
- **MySQL / MariaDB**: multiple result sets from stored procedure `CALL`; `SHOW WARNINGS` attached automatically when warnings exist; charset-aware; MariaDB differences absorbed by the driver.
|
|
139
|
+
- **PostgreSQL**: schemas and `search_path`; sequences, enums, and custom types displayed; COPY; NOTICE capture; psql meta-commands unsupported (Live Templates replace `\d` etc.).
|
|
140
|
+
- **SQLite**: the data source is a file path on the machine running dbjack (`file:` URI, relative to the working directory), one file per data source; `ATTACH` works in Query Console but doesn't appear in Database Explorer; pure Go driver.
|
|
141
|
+
- **MongoDB**: Query Console supports
|
|
142
|
+
- `db.<coll>.find / findOne / countDocuments / estimatedDocumentCount / distinct / aggregate / insertOne / insertMany / updateOne / updateMany / replaceOne / deleteOne / deleteMany / createIndex / dropIndex / getIndexes / drop`, chained `.sort / skip / limit / project / explain`
|
|
143
|
+
- `db.getCollection()`, `db.runCommand / adminCommand`, `use <db>`, `show dbs / collections`
|
|
144
|
+
- Arguments in relaxed JSON (unquoted keys, single quotes, trailing commas, comments) + `ObjectId / ISODate / Date / NumberLong / NumberDecimal / UUID / BinData`
|
|
145
|
+
- No variables, functions, loops, `forEach`, `print`, transactions, or GridFS
|
|
146
|
+
- **SQL Server**: databases and schemas; `GO` on its own line ends a batch (routine / trigger bodies run to it); Tx: Manual uses `IMPLICIT_TRANSACTIONS`; comments are `MS_Description` extended properties.
|
|
147
|
+
- **Oracle**: a schema is a user (Oracle-maintained schemas hidden); PL/SQL blocks and `CREATE PROCEDURE / FUNCTION / PACKAGE / TRIGGER / TYPE` end with `/`; sessions use ISO `NLS_DATE_FORMAT` / `NLS_TIMESTAMP_FORMAT`.
|
|
148
|
+
- **Elasticsearch**: the URI is the cluster's HTTP(S) endpoint as copied from the console (e.g. Elastic Cloud "Copy endpoint"; Cloud ID unsupported) plus credentials — `https://elastic:pass@host` or `https://host?api_key=<encoded key>`; TLS via `tlsCAFile` / `tlsInsecure`. Read-only through ES SQL (no Data Editor editing, Modify, Import, Copy Table, or Run Script); data paging reads past the skipped rows since ES SQL has no OFFSET.
|
|
149
|
+
- **Redis**: Query Console follows redis-cli quoting rules, one result per command. Key browsing builds a tree from SCAN + pattern + delimiter (default `:`, changeable in the Database Explorer toolbar, stored locally in the browser); node counts reflect scan progress — "Continue Scanning" rather than one full scan; type / TTL / size are fetched in pipelined batches. ACL usernames supported (`redis://user:pass@host`); modules such as RedisJSON / RediSearch unsupported.
|
|
150
|
+
|
|
151
|
+
### 4.9 Terminal
|
|
152
|
+
|
|
153
|
+
One shell on the dbjack host per tab; a default shell, others pickable from the installed ones.
|
|
154
|
+
|
|
155
|
+
## 5. Deployment, Configuration, Embedding, and Deep Links
|
|
156
|
+
|
|
157
|
+
- **Distribution**:
|
|
158
|
+
- Single binary: Linux / macOS / Windows × amd64 / arm64, cold start < 1 s
|
|
159
|
+
- Docker image: `WORKDIR /data`, no baked-in settings
|
|
160
|
+
- Go library: the host mounts an `http.Handler`; `Options` = `BasePath` + data source list; reads no config file / environment variables / command line; logs via `slog.Default()`
|
|
161
|
+
- **Configuration** has only three items: `listen`, `base_path`, and data sources. Data sources come from three origins — config file `datasources[]`, positional command-line arguments, and environment variables `DBJACK_DATASOURCE[_<NAME>]` — always as native URIs, never written back from the UI. Authentication, TLS, network exposure, and proxy timeouts are handled by the reverse proxy / host.
|
|
162
|
+
|
|
163
|
+
### 5.1 Config File
|
|
164
|
+
|
|
165
|
+
YAML; every key is optional.
|
|
166
|
+
|
|
167
|
+
- **Lookup order**: the path from `--config` / `DBJACK_CONFIG` (error if missing) → `dbjack.yaml` in the working directory → `$XDG_CONFIG_HOME/dbjack/config.yaml` (default `~/.config/…`, same on all platforms). If none exists, an empty config is used; nothing is created.
|
|
168
|
+
- **Loading**: read once at startup; no watching, no writing back, no pre-connecting. Strict parsing: unknown keys, type mismatches, or invalid URIs fail startup and name the offending field; the startup log prints the chosen file path and how it was found.
|
|
169
|
+
|
|
170
|
+
| Key | Default | Constraints |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `listen` | `127.0.0.1:1618` | `host:port`; any address allowed |
|
|
173
|
+
| `base_path` | `/` | Starts with `/`; trailing `/` stripped |
|
|
174
|
+
| `datasources[].name` | Empty | May be empty or duplicated; if non-empty, `[A-Za-z0-9_-]{1,64}`; display only |
|
|
175
|
+
| `datasources[].uri` | Required | Native URI, scheme ∈ `mysql` · `postgres` / `postgresql` · `file` · `sqlserver` · `oracle` · `http` / `https` (Elasticsearch) · `mongodb` / `mongodb+srv` · `redis` / `rediss`; `file:` relative to the working directory; credentials may be in the URI |
|
|
176
|
+
| `datasources[].color` | None | `red` `orange` `yellow` `green` `blue` `purple` |
|
|
177
|
+
|
|
178
|
+
- **Short id**: the first 8 hex digits of the SHA-256 of the full `uri`; never written to config. Credentials only feed the hash and never appear in URLs. Deep links and the workspace locate data sources by id; when the `uri` changes, so does the id, and old links and workspaces are not migrated.
|
|
179
|
+
- **Display**: Database Explorer shows `name` with the host / IP from the `uri` (the file basename if there is no host).
|
|
180
|
+
- **Conflicts**: duplicate URIs / short ids after merging the three origins are an error that lists each origin with masked connection info; the user fixes it. No automatic dedup, id change, or override.
|
|
181
|
+
|
|
182
|
+
### 5.2 Command Line and Environment Variables
|
|
183
|
+
|
|
184
|
+
`dbjack [options] [URI …]`, no subcommands.
|
|
185
|
+
|
|
186
|
+
- **Options**: `--config` `--listen` `--base-path` `--help` `--version`. Config keys, options, and environment variables map by name (`base_path` → `--base-path` → `DBJACK_BASE_PATH`); environment variables all use the `DBJACK_` prefix.
|
|
187
|
+
- **Data source names**: `<NAME>` in `DBJACK_DATASOURCE_<NAME>` is the `name` (uppercase, `-` as `_`); `DBJACK_DATASOURCE` and positional arguments have an empty `name`.
|
|
188
|
+
- **Precedence**: scalars take command line > environment variables > config file > built-in defaults; data sources from all three origins are combined.
|
|
189
|
+
- **Startup**: parse command line → environment variables → locate and read config → merge → validate; exit non-zero on error. Prints the access URL to stderr and opens the browser automatically when listening on loopback.
|
|
190
|
+
|
|
191
|
+
### 5.3 Fixed Behavior (Not Configurable)
|
|
192
|
+
|
|
193
|
+
- Sessions close 5 minutes after the page disconnects (§4.1).
|
|
194
|
+
- Logs go to `$XDG_STATE_HOME/dbjack/dbjack.log` (default `~/.local/state/…`, same on all platforms), masked, fixed level; stderr prints startup info.
|
|
195
|
+
|
|
196
|
+
### 5.4 Examples
|
|
197
|
+
|
|
198
|
+
Pick by what sits in front of dbjack, which has no authentication of its own (§1 principle 5).
|
|
199
|
+
|
|
200
|
+
#### 5.4.1 **Local** — just you, on your machine: single binary, zero config, loopback, browser opens automatically:
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
dbjack file:./app.db mysql://root@127.0.0.1:3306/app redis://127.0.0.1:6379
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
#### 5.4.2 **Server** (recommended whenever others can reach it) — standalone container behind a reverse proxy that handles authentication; `DBJACK_BASE_PATH` lets it share a domain with an app:
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
docker run -p 1618:1618 \
|
|
210
|
+
-e DBJACK_LISTEN=0.0.0.0:1618 \
|
|
211
|
+
-e DBJACK_BASE_PATH=/admin/db \
|
|
212
|
+
-e DBJACK_DATASOURCE_TEST="postgres://dev:***@pg-test:5432/app" \
|
|
213
|
+
-e DBJACK_DATASOURCE_PROD="mysql://ro_user:***@10.0.0.5:3306/shop" \
|
|
214
|
+
ghcr.io/awesomedog/dbjack
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### 5.4.3 **Embedded, Go** — in-process `http.Handler` mounted by the host app, behind its middleware:
|
|
218
|
+
|
|
219
|
+
```sh
|
|
220
|
+
# web/dist is embedded but not committed, so `go get` alone cannot build: build it in a clone and replace
|
|
221
|
+
git clone --depth 1 https://github.com/AwesomeDog/dbjack ../dbjack
|
|
222
|
+
pnpm -C ../dbjack/web install && pnpm -C ../dbjack/web build
|
|
223
|
+
go mod edit -replace github.com/AwesomeDog/dbjack=../dbjack && go mod tidy
|
|
224
|
+
# Optional: go mod vendor — copies the built frontend into vendor/, so CI needs neither the clone nor Node
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
```go
|
|
228
|
+
import "github.com/AwesomeDog/dbjack"
|
|
229
|
+
|
|
230
|
+
// DataSource has the same three fields as datasources[]
|
|
231
|
+
h, err := dbjack.New(dbjack.Options{BasePath: "/admin/db",
|
|
232
|
+
DataSources: []dbjack.DataSource{{Name: "main", URI: os.Getenv("MAIN_DB_URI")}}})
|
|
233
|
+
if err != nil { log.Fatal(err) }
|
|
234
|
+
mux.Handle("/admin/db/", h)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
#### 5.4.4 **Embedded, other stacks** (supported; prefer Server) — sidecar process routed by the host app, so its middleware applies. Spring Boot example; needs Spring Cloud Gateway Server MVC 5.1+ and `spring-boot-starter-websocket`:
|
|
238
|
+
|
|
239
|
+
```dockerfile
|
|
240
|
+
COPY --from=ghcr.io/awesomedog/dbjack:latest /dbjack /usr/local/bin/dbjack
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
```java
|
|
244
|
+
ProcessBuilder pb = new ProcessBuilder("dbjack", "--listen", "127.0.0.1:1618", "--base-path", "/admin/db");
|
|
245
|
+
pb.environment().put("DBJACK_DATASOURCE_MAIN", System.getenv("MAIN_DB_URI")); // env, not argv: keeps credentials out of ps
|
|
246
|
+
pb.inheritIO().start();
|
|
247
|
+
|
|
248
|
+
@Bean
|
|
249
|
+
RouterFunction<ServerResponse> dbjack() {
|
|
250
|
+
return route("dbjack").route(path("/admin/db", "/admin/db/**"), http()) // keep the prefix; proxies WebSocket too
|
|
251
|
+
.before(uri("http://127.0.0.1:1618"))
|
|
252
|
+
.before(removeRequestHeader("Origin")) // dbjack checks Origin against the proxied Host
|
|
253
|
+
.build();
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### 5.5 Deep Links
|
|
258
|
+
|
|
259
|
+
The URL is the state: `{base}/{tab}/{datasource}/{namespace…}/{object}?{state}`
|
|
260
|
+
|
|
261
|
+
- `base`: the `base_path`
|
|
262
|
+
- `tab`: `data` | `ddl` | `console` (console paths stop at the namespace)
|
|
263
|
+
- `datasource`: `name@id`; the server locates by `id` only; `name` is just a hint and can be anything; generated links use the current display name
|
|
264
|
+
- `namespace`: MySQL `{db}` · PG / SQL Server `{db}/{schema}` · SQLite / Oracle `{schema}` · Elasticsearch `{cluster}` · Mongo `{db}` · Redis `{dbIndex}`
|
|
265
|
+
- `state`: data uses `filter` `order` `page` `size`; console uses `q` (prefilled only, never auto-executed). Parameter names are shared across all engines; values are the raw text of the engine's corresponding input field
|
|
266
|
+
|
|
267
|
+
| Scenario | URL (illustrative ids, not URL-encoded) |
|
|
268
|
+
|---|---|
|
|
269
|
+
| Orders for user 42 (PG) | `/admin/db/data/main@6f3a9c21/app/public/orders?filter=user_id = 42&order=created_at DESC` |
|
|
270
|
+
| Same (Mongo) | `/admin/db/data/events@2b81de40/shop/orders?filter={userId: 42}&order={createdAt: -1}` |
|
|
271
|
+
| Session key (Redis) | `/admin/db/data/cache@7c05af13/0/session:42` |
|
|
272
|
+
| Table DDL (SQLite, empty name) | `/admin/db/ddl/@9e42b7ac/main/users` |
|
|
273
|
+
| Prefilled aggregate query | `/admin/db/console/main@6f3a9c21/app/public?q=SELECT count(*) FROM orders` |
|
|
274
|
+
|
|
275
|
+
## 6. Runtime and Constraints
|
|
276
|
+
|
|
277
|
+
- **Security**: credentials stay on the Go side and are never sent to the browser; cell content is never rendered as HTML.
|
|
278
|
+
- **Runtime**: single-process HTTP server; modern browsers, JS required.
|
|
279
|
+
- **Storage**: data sources in configuration (§5); Settings, Query History, custom Live Templates, and the workspace stored locally in the browser; the server holds only in-process session and execution state, cleared on restart.
|
|
280
|
+
- **Engine versions**: MySQL 5.7+ / MariaDB 10.3+; PostgreSQL 12+; SQLite bundled with the driver; SQL Server 2012+; Oracle 12.2+; Elasticsearch 7.10+ with SQL enabled; MongoDB 4.4+ (driver compatible down to 3.6); Redis 5+ (ACL requires 6+).
|
|
281
|
+
- **Performance**: a 1 GB SQL file imports via streaming with flat memory; 100k-row results scroll smoothly.
|
|
282
|
+
|
|
283
|
+
## 7. Out of Scope
|
|
284
|
+
|
|
285
|
+
- **Ops and administration**: DBA operations (replication, binlog, HA, backup scheduling, monitoring and alerting); admin panels for server sessions / overview (use Live Templates); user management UI.
|
|
286
|
+
- **Sessions and security**: dbjack session management (creating / switching / sharing sessions); authentication / access gate / TLS termination; app-level read-only mode and timeouts; built-in accounts and RBAC.
|
|
287
|
+
- **Analytics and modeling**: BI / reports / charts / aggregate views; ETL / sync; ER diagrams; Explain visualization.
|
|
288
|
+
- **Editor and IDE**: User Parameters; foreign key navigation; IDE features (refactoring, VCS, debugging, copy as code); theme customization; custom keymaps; plugin system.
|
|
289
|
+
- **Formats and engines**: long-tail import / export formats; Mongo JS scripts / transactions / GridFS; Redis modules.
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesomedog/dbjack",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "A single-binary web database console for eight SQL and NoSQL engines.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/AwesomeDog/dbjack.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/AwesomeDog/dbjack",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"database",
|
|
13
|
+
"sql",
|
|
14
|
+
"gui",
|
|
15
|
+
"console",
|
|
16
|
+
"cli"
|
|
17
|
+
],
|
|
18
|
+
"bin": {
|
|
19
|
+
"dbjack": "bin/dbjack.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin",
|
|
23
|
+
"docs"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=18"
|
|
27
|
+
},
|
|
28
|
+
"optionalDependencies": {
|
|
29
|
+
"@awesomedog/dbjack-darwin-arm64": "0.1.1",
|
|
30
|
+
"@awesomedog/dbjack-darwin-x64": "0.1.1",
|
|
31
|
+
"@awesomedog/dbjack-linux-arm64": "0.1.1",
|
|
32
|
+
"@awesomedog/dbjack-linux-x64": "0.1.1",
|
|
33
|
+
"@awesomedog/dbjack-win32-arm64": "0.1.1",
|
|
34
|
+
"@awesomedog/dbjack-win32-x64": "0.1.1"
|
|
35
|
+
}
|
|
36
|
+
}
|