@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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AwesomeDog
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,254 @@
1
- # Temporary Holding Version
1
+ # dbjack — a single-binary web database client for MySQL, PostgreSQL, SQLite, MongoDB, Redis and more
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![GitHub stars for dbjack](https://img.shields.io/github/stars/AwesomeDog/dbjack?style=flat-square&logo=github)](https://github.com/AwesomeDog/dbjack/stargazers)
4
+ [![Built with Go 1.27](https://img.shields.io/badge/Go-1.27-00ADD8?style=flat-square&logo=go&logoColor=white)](https://github.com/AwesomeDog/dbjack/blob/main/go.mod)
5
+ [![dbjack Docker image on GHCR](https://img.shields.io/badge/ghcr.io-awesomedog%2Fdbjack-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/AwesomeDog/dbjack/pkgs/container/dbjack)
6
+ [![Runs on Linux, macOS and Windows, amd64 and arm64](https://img.shields.io/badge/Linux%20%7C%20macOS%20%7C%20Windows-amd64%20%7C%20arm64-blue?style=flat-square)](#quick-start)
7
+ [![8 SQL and NoSQL database engines](https://img.shields.io/badge/8%20engines-SQL%20%2B%20NoSQL-7B61FF?style=flat-square)](#supported-databases)
8
+
9
+ **Every database. One tab.** dbjack is a self-hosted web database console and SQL GUI that connects directly to **MySQL / MariaDB, PostgreSQL, SQLite, SQL Server, Oracle, Elasticsearch, MongoDB, and Redis**. It ships as one pure-Go binary with the React frontend embedded: no Java, no cgo, no PHP, no account system, no external dump tools.
10
+
11
+ Run it on your laptop, put it behind a reverse proxy as a shared **database admin panel**, or mount it as an `http.Handler` at `/admin/db` inside your Go app. If you are looking for a lightweight **alternative to DataGrip, phpMyAdmin or a hand-written CRUD back office**, this is the shape of it: a familiar Query Console and Data Editor in the browser, with eight engines side by side in one Database Explorer.
12
+
13
+ ![dbjack web database console: Database Explorer across multiple data sources, an SQL Query Console, and a result grid](docs/img/dark.svg)
14
+
15
+ ## Contents
16
+
17
+ - [At a glance](#at-a-glance)
18
+ - [Supported databases](#supported-databases)
19
+ - [Features](#features)
20
+ - [Installation](#installation)
21
+ - [Quick start](#quick-start)
22
+ - [Configuration](#configuration)
23
+ - [Deployment and security](#deployment-and-security)
24
+ - [How dbjack compares](#how-dbjack-compares)
25
+ - [FAQ](#faq)
26
+ - [What dbjack does not do](#what-dbjack-does-not-do)
27
+ - [Development](#development)
28
+ - [Documentation](#documentation)
29
+
30
+ ## At a glance
31
+
32
+ | | |
33
+ |---|---|
34
+ | **What it is** | A browser-based database client: Database Explorer, Query Console, Data Editor, DDL viewer, result grid, import / export |
35
+ | **Engines** | 8: MySQL / MariaDB, PostgreSQL, SQLite, SQL Server, Oracle, Elasticsearch, MongoDB, Redis |
36
+ | **Distribution** | One static binary (Linux / macOS / Windows × amd64 / arm64) via Homebrew, winget, npm or [Releases](https://github.com/AwesomeDog/dbjack/releases); Docker image `ghcr.io/awesomedog/dbjack`; or Go library `github.com/AwesomeDog/dbjack` (built from a clone) |
37
+ | **Setup** | Zero config to start: pass native connection URIs as arguments. Three configuration keys total: `listen`, `base_path`, `datasources` |
38
+ | **Performance** | Cold start under 1 s; 100k-row results scroll smoothly; 1 GB SQL scripts import by streaming with flat memory |
39
+ | **Formats** | SQL, CSV, JSON / ndjson, Redis command files; gzip for one object, zip for many |
40
+ | **By design** | No login of its own, no app-level read-only mode, no helper objects created in your databases, credentials never sent to the browser |
41
+
42
+ ## Supported databases
43
+
44
+ All data sources are native URIs. The same binary handles every engine; capabilities such as transactions, cancellation and DDL generation follow what the engine supports.
45
+
46
+ | Engine | URI scheme | Query language | Notes |
47
+ |---|---|---|---|
48
+ | MySQL / MariaDB | `mysql://` | Multi-statement SQL | `SHOW CREATE` DDL, `EXPLAIN ANALYZE`, `KILL QUERY`, stored procedures (5.7+ / 10.3+) |
49
+ | PostgreSQL | `postgres://` · `postgresql://` | Multi-statement SQL | Schemas and `search_path`, COPY, NOTICE, DDL rebuilt from catalogs (12+) |
50
+ | SQLite | `file:` | Multi-statement SQL | One file per data source, pure-Go driver, no cgo |
51
+ | SQL Server | `sqlserver://` | T-SQL, `GO` batches | Databases / schemas, `SHOWPLAN_XML` (2012+) |
52
+ | Oracle | `oracle://` | SQL, PL/SQL blocks ending in `/` | `DBMS_METADATA` DDL, `DBMS_XPLAN` (12.2+) |
53
+ | Elasticsearch | `http://` · `https://` | ES SQL (read-only) | Indices as tables, aliases as views, mapping as DDL (7.10+ with SQL enabled) |
54
+ | MongoDB | `mongodb://` · `mongodb+srv://` | mongo shell subset, `db.runCommand({})` | Tree / Table / Text views, Extended JSON editing (4.4+) |
55
+ | Redis | `redis://` · `rediss://` | redis-cli commands, one per line | SCAN-based prefix tree, type-aware editors, cluster aware (5+, ACL 6+) |
56
+
57
+ **Protocol-compatible services** use the same URI scheme and are treated as that engine — no special detection or adaptation, but a convenient way to get a web GUI for a hosted or distributed database. Engine-specific capabilities may differ:
58
+
59
+ - `mysql://`: **TiDB, OceanBase** (MySQL mode), **PolarDB-MySQL / TDSQL-C, Aurora MySQL, Percona, PlanetScale / Vitess, Doris / StarRocks**
60
+ - `postgres://`: **Supabase, Neon, TimescaleDB, Citus, Aurora PostgreSQL, PolarDB-PG, YugabyteDB**
61
+
62
+ ## Features
63
+
64
+ Six jobs, and nothing else: **connect, find objects, read data, edit data, change schema, move data.** The interface follows a desktop GUI database client — Query Console, Data Editor, Services, Live Templates — so existing muscle memory carries over to the browser.
65
+
66
+ ### Query Console and SQL editor
67
+
68
+ Per-engine syntax highlighting and completion (alias-aware SQL columns, Mongo methods and operators, Redis commands); `Ctrl/Cmd+Enter` runs the statement at the caret, the selection, or everything. Multi-statement results, Explain Plan / Explain Analyse, transactions (Tx: Auto / Manual), cancellation that reaches the engine, Query History, and Execute to File for results too large for the browser.
69
+
70
+ ### Data Editor and result grid
71
+
72
+ Browse with pagination, sorting and SQL `WHERE` / Mongo filter / Redis `MATCH`. Stage cell edits, add, clone or delete rows, then Submit or Revert; Preview Pending Changes is optional. Value Editor for text, JSON, hex and images. Results use virtual scrolling and copy a selection as TSV, CSV, JSON, SQL Inserts, Markdown or an `IN (…)` list.
73
+
74
+ ### Database Explorer and schema changes
75
+
76
+ One lazy, cached tree across all data sources, with Speed Search and double-Shift Search Everywhere (objects, actions, Live Templates). Create / Modify Table and Create / Modify Database share one non-modal dialog; every generated statement — SQLite table rebuilds included — can be previewed, edited and executed. Go to DDL opens a read-only definition tab.
77
+
78
+ ### Import, export and data movement
79
+
80
+ Export Data, Import Data from File, Run Script and Copy Table to are all streamed in the browser, with progress and cancellation. No `mysqldump`, `pg_dump`, `mongodump` or `redis-cli` on the host. Copy Table to moves tables, collections or Redis key prefixes within a data source or across data sources of the same engine — the "pull the test database down to local" workflow.
81
+
82
+ ### Deep links and Live Templates
83
+
84
+ The URL is the state: `/{base}/{tab}/{datasource}/{namespace}/{object}?filter=…&order=…&page=…&size=…` addresses any table, filter, sort or DDL, and `?q=` prefills a query without ever auto-executing it. Built-in Live Templates replace admin UIs with per-engine snippets for process lists, lock waits, table bloat, slow logs, big keys, grants, `VACUUM` and more. A Terminal tool window provides a shell on the dbjack host per tab.
85
+
86
+ ## Installation
87
+
88
+ ```sh
89
+ # Windows (winget)
90
+ winget install AwesomeDog.dbjack
91
+
92
+ # macOS (Homebrew)
93
+ brew install AwesomeDog/tap/dbjack
94
+
95
+ # Linux, or any platform with Node.js
96
+ npm install -g @awesomedog/dbjack
97
+
98
+ # Direct binary (Linux amd64; all six builds: https://github.com/AwesomeDog/dbjack/releases)
99
+ curl -fsSL https://github.com/AwesomeDog/dbjack/releases/latest/download/dbjack-linux-amd64 -o dbjack
100
+ chmod +x dbjack && sudo mv dbjack /usr/local/bin/
101
+
102
+ # Docker — put a reverse proxy in front before anyone else can reach it; WORKDIR /data, amd64 + arm64
103
+ docker run --rm -p 1618:1618 \
104
+ -e DBJACK_LISTEN=0.0.0.0:1618 \
105
+ ghcr.io/awesomedog/dbjack \
106
+ "postgres://user:pass@host.docker.internal:5432/app"
107
+
108
+ # Check the install
109
+ dbjack --version
110
+ ```
111
+
112
+ **Spring Boot sidecar** — copy the binary into your own image or route it as a sidecar; see [§5.4.4 Embedded, other stacks](docs/specs/prd.md) in the PRD for the config.
113
+
114
+ **Go library** — mount the `http.Handler` behind your own middleware; see [§5.4.3 Embedded, Go](docs/specs/prd.md) in the PRD for the build commands and example.
115
+
116
+ ## Quick start
117
+
118
+ ```sh
119
+ # Fetch sample SQL and build demo.db and start dbjack on it
120
+ curl -fsSL https://raw.githubusercontent.com/AwesomeDog/dbjack/main/testdata/sqlite.sql | sqlite3 demo.db
121
+ dbjack file:demo.db
122
+
123
+ # Start with your own db
124
+ dbjack file:./app.db mysql://root@127.0.0.1:3306/app redis://127.0.0.1:6379
125
+ ```
126
+
127
+ dbjack listens on `127.0.0.1:1618` by default and opens your browser automatically on loopback. `dbjack --help` lists all options.
128
+
129
+ ## Configuration
130
+
131
+ Three keys, every one optional. Data sources are **predefined only** — a config file, positional CLI arguments, or environment variables. The UI never adds or edits them, and changes take effect after a restart.
132
+
133
+ | Key | Default | Notes |
134
+ |---|---|---|
135
+ | `listen` | `127.0.0.1:1618` | Any `host:port` |
136
+ | `base_path` | `/` | Mount under a prefix such as `/admin/db` |
137
+ | `datasources[]` | — | `name` (display only), `uri` (required, native URI), `color` (`red` … `purple`) |
138
+
139
+ ```yaml
140
+ # dbjack.yaml — looked up as --config / DBJACK_CONFIG, then ./dbjack.yaml,
141
+ # then $XDG_CONFIG_HOME/dbjack/config.yaml
142
+ listen: 127.0.0.1:1618
143
+ base_path: /admin/db
144
+ datasources:
145
+ - name: main
146
+ uri: "postgres://user:pass@localhost:5432/app?sslmode=disable"
147
+ color: blue
148
+ - name: local
149
+ uri: "file:./app.db"
150
+ ```
151
+
152
+ Environment variables mirror the flags: `DBJACK_LISTEN`, `DBJACK_BASE_PATH`, `DBJACK_CONFIG`, and `DBJACK_DATASOURCE[_<NAME>]` for data sources (e.g. `DBJACK_DATASOURCE_PROD`). Scalars take command line > environment > config file > defaults; data sources from all three origins are combined. TLS, timeouts, read preference and similar options travel as URI parameters (`sslmode`, `tls`, `tlsCAFile`, `rediss://`), not as UI settings.
153
+
154
+ Duplicate URIs are a startup error; parsing is strict and names the offending field. Data sources are identified in links by the first 8 hex digits of the SHA-256 of the URI — credentials never appear in a URL.
155
+
156
+ ## Deployment and security
157
+
158
+ Choose the mode by what sits in front of dbjack; **all modes have identical features**.
159
+
160
+ 1. **Local** — single binary, zero config, loopback only, browser opens automatically.
161
+ 2. **Server** (recommended when others can reach it) — container behind a reverse proxy that handles authentication and TLS; `DBJACK_BASE_PATH` lets it share a domain with your app.
162
+ 3. **Embedded in Go** — in-process `http.Handler` behind the host app's middleware.
163
+ 4. **Sidecar** — separate process routed to by any other stack, so its middleware applies.
164
+
165
+ ```sh
166
+ docker run -p 1618:1618 \
167
+ -e DBJACK_LISTEN=0.0.0.0:1618 \
168
+ -e DBJACK_BASE_PATH=/admin/db \
169
+ -e DBJACK_DATASOURCE_TEST="postgres://dev:***@pg-test:5432/app" \
170
+ -e DBJACK_DATASOURCE_PROD="mysql://ro_user:***@10.0.0.5:3306/shop" \
171
+ ghcr.io/awesomedog/dbjack
172
+ ```
173
+
174
+ **dbjack has no authentication, access gate or network-exposure restriction of its own.** Who can reach it is the deployer's job (reverse proxy or host app). What a user can run depends only on the database identity behind the connection: for read-only access, connect with a read-only database user. Connection URIs stay on the Go side, logs are masked, cell content is never rendered as HTML, and dbjack never creates helper tables, schemas or keys in a target database.
175
+
176
+ ## How dbjack compares
177
+
178
+ Lighter than an IDE, broader than a single-engine admin, easier to deploy than all of them.
179
+
180
+ | Tool | Where dbjack fits |
181
+ |---|---|
182
+ | **DataGrip** / desktop GUI clients | Adds web access, single-binary deployment, embedding and deep links; drops IDE features (refactoring, VCS, debugging, ER design) |
183
+ | **phpMyAdmin** | Eight engines instead of one, less UI, streaming import / export, no PHP stack |
184
+ | **Django Admin** and similar CRUD back offices | No framework or ORM lock-in and no model registration code — it connects directly to any data store |
185
+
186
+ ## FAQ
187
+
188
+ ### Is dbjack a phpMyAdmin alternative?
189
+
190
+ For self-hosted, browser-based database administration, yes: it covers the same daily work (browse tables, run queries, edit rows, change schemas, import and export) across eight engines, from one Go binary with no runtime dependencies. It deliberately has no user management UI, BI, charts or plugin system.
191
+
192
+ ### Is dbjack a DataGrip alternative?
193
+
194
+ For developers who want a lightweight multi-engine database client in a browser, yes — same terms and interactions (Query Console, Data Editor, Services, Live Templates), plus shareable deep links and mounting inside an app. It is not an IDE: no refactoring, VCS, debugging or ER diagrams.
195
+
196
+ ### Can I use it as a self-hosted admin panel for my app?
197
+
198
+ Yes. Mount the Go `http.Handler` at `/admin/db`, or run the binary as a sidecar and route that path through your gateway, so the host app's authentication applies. No ORM, model registration or generated CRUD code is needed.
199
+
200
+ ### Does dbjack have authentication, users or a read-only mode?
201
+
202
+ No, by design. Authentication and TLS termination belong to your reverse proxy or host app; read/write permissions belong to the database user in the connection URI. There is no app-level statement filtering, timeout or fetch-size limit.
203
+
204
+ ### Does dbjack write anything into my databases?
205
+
206
+ Only the objects and rows you explicitly create or change. It never creates helper tables, schemas or keys, and it never shells out to `mysqldump` / `pg_dump` / `mongodump` / `redis-cli` — import and export are built in and streamed to the browser.
207
+
208
+ ### Which hosted databases does it work with?
209
+
210
+ Anything using the MySQL or PostgreSQL protocol with the same URI scheme is treated as that engine: Supabase, Neon, TimescaleDB, Aurora, TiDB, PlanetScale / Vitess, Doris / StarRocks and friends. There is no per-service adaptation, so engine-specific features may differ. See [Supported databases](#supported-databases).
211
+
212
+ ### Do deep links expose credentials?
213
+
214
+ No. A deep link addresses a data source by `name@id`, where `id` is a short hash of the URI; credentials stay on the server and never appear in a link or log. A `?q=` parameter on a console link only prefills the editor, it never runs the query.
215
+
216
+ ### Is Elasticsearch editable?
217
+
218
+ No — Elasticsearch is read-only through ES SQL. Query Console, browsing, Explain and CSV / JSON export work; Data Editor editing, Modify, Import, Copy Table to and Run Script do not.
219
+
220
+ ## What dbjack does not do
221
+
222
+ DBA operations (replication, binlog, HA, backup scheduling, monitoring), admin panels for server sessions, built-in accounts and RBAC, BI / reports / charts / ER diagrams, Explain visualization, IDE features, theme customization, custom keymaps, a plugin system, long-tail import formats, Mongo JS scripts / transactions / GridFS, and Redis modules. Settings, Query History and custom Live Templates live locally in the browser; the server keeps only in-process session and execution state.
223
+
224
+ ## Development
225
+
226
+ ```sh
227
+ # Install dependencies
228
+ pnpm -C web install
229
+ go mod download
230
+
231
+ # Build (the frontend is embedded, so build it first)
232
+ pnpm -C web build
233
+ go build -o dbjack ./cmd/dbjack
234
+
235
+ # Develop: test databases with sample data
236
+ docker compose up -d
237
+ go run ./cmd/dbjack --config testdata/dbjack.yaml
238
+ docker compose down
239
+
240
+ # Release: bump version & trigger CI
241
+ v=v1.2.3 && git tag -a "$v" -m "Release $v" && git push origin "$v"
242
+ ```
243
+
244
+ `compose.yaml` starts MySQL, PostgreSQL, SQLite, MongoDB, Redis, SQL Server, Oracle and Elasticsearch with seeded sample data; `testdata/dbjack.yaml` points dbjack at all of them.
245
+
246
+ Publishing the release that CI drafted also publishes the npm packages: `publish-npm.yml` pushes `@awesomedog/dbjack` and the six platform packages over OIDC.
247
+
248
+ ## Documentation
249
+
250
+ - [Product requirements and full specification](docs/specs/prd.md) — the canonical reference, including the engine capability matrix, configuration lookup order, deep-link format and embedding examples
251
+ - [Landing page](https://awesomedog.github.io/dbjack/) ([source](docs/index.html))
252
+ - [Releases and downloads](https://github.com/AwesomeDog/dbjack/releases)
253
+
254
+ dbjack — a single-binary web database console for eight engines. Point it at a database; that's the setup.
package/bin/dbjack.js ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+ const { accessSync, constants } = require("node:fs");
6
+ const os = require("node:os");
7
+
8
+ const { name, homepage, optionalDependencies } = require("../package.json");
9
+ const platforms = Object.keys(optionalDependencies).map((dep) => dep.slice(name.length + 1));
10
+ const platform = `${process.platform}-${process.arch}`;
11
+
12
+ const fail = (message) => {
13
+ console.error(`dbjack: ${message}`);
14
+ process.exit(1);
15
+ };
16
+
17
+ if (!optionalDependencies[`${name}-${platform}`])
18
+ fail(`no build for ${platform}. Supported: ${platforms.join(", ")}. Download one from ${homepage}/releases`);
19
+
20
+ let binary;
21
+ try {
22
+ binary = require.resolve(`${name}-${platform}/bin/${process.platform === "win32" ? "dbjack.exe" : "dbjack"}`);
23
+ } catch {
24
+ fail(`${name}-${platform} is missing. Reinstall with optional dependencies: npm install -g ${name}`);
25
+ }
26
+
27
+ // execve aborts instead of throwing when it fails on Node < 26.1, so catch a lost exec bit here.
28
+ try {
29
+ accessSync(binary, constants.X_OK);
30
+ } catch {
31
+ fail(`${binary} is not executable. Reinstall with: npm install -g ${name}`);
32
+ }
33
+
34
+ const args = process.argv.slice(2);
35
+
36
+ // Node >= 22.15, POSIX only: replace this process outright. No parent node holding ~40MB, and
37
+ // signals, terminal control, and exit codes reach dbjack untouched. args[0] becomes dbjack's argv[0];
38
+ // nothing may be pending on stdio at this point.
39
+ if (typeof process.execve === "function") {
40
+ try {
41
+ process.execve(binary, [binary, ...args], { ...process.env });
42
+ } catch {}
43
+ }
44
+
45
+ if (process.platform !== "win32") process.on("SIGINT", () => {});
46
+
47
+ const { status, signal, error } = spawnSync(binary, args, { stdio: "inherit" });
48
+ if (error) fail(error.message);
49
+ if (signal) {
50
+ process.removeAllListeners(signal);
51
+ try {
52
+ process.kill(process.pid, signal);
53
+ } catch {}
54
+ process.exit(128 + (os.constants.signals[signal] ?? 0)); // Signals node ignores, such as SIGPIPE.
55
+ }
56
+ process.exit(status ?? 1);