quickdbd-cli 0.1.0__py3-none-any.whl
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.
- quickdbd_cli/__init__.py +1 -0
- quickdbd_cli/__main__.py +5 -0
- quickdbd_cli/assets/Inter-Bold.ttf +0 -0
- quickdbd_cli/assets/Inter-Bold.woff2 +0 -0
- quickdbd_cli/assets/Inter-LICENSE.txt +92 -0
- quickdbd_cli/assets/Inter-Regular.ttf +0 -0
- quickdbd_cli/assets/Inter-Regular.woff2 +0 -0
- quickdbd_cli/assets/editor.js +244 -0
- quickdbd_cli/assets/elk-LICENSE.md +263 -0
- quickdbd_cli/assets/elk.bundled.js +6605 -0
- quickdbd_cli/assets/font-metrics.json +1 -0
- quickdbd_cli/assets/render.js +230 -0
- quickdbd_cli/assets/style.css +83 -0
- quickdbd_cli/assets/viewer.js +337 -0
- quickdbd_cli/cli.py +169 -0
- quickdbd_cli/export.py +79 -0
- quickdbd_cli/html.py +97 -0
- quickdbd_cli/jsrt.py +77 -0
- quickdbd_cli/layout.py +207 -0
- quickdbd_cli/measure.py +111 -0
- quickdbd_cli/model.py +107 -0
- quickdbd_cli/parser.py +717 -0
- quickdbd_cli/project.py +69 -0
- quickdbd_cli/serve.py +210 -0
- quickdbd_cli-0.1.0.dist-info/METADATA +153 -0
- quickdbd_cli-0.1.0.dist-info/RECORD +32 -0
- quickdbd_cli-0.1.0.dist-info/WHEEL +4 -0
- quickdbd_cli-0.1.0.dist-info/entry_points.txt +2 -0
- quickdbd_cli-0.1.0.dist-info/licenses/LICENSE +201 -0
- quickdbd_cli-0.1.0.dist-info/licenses/NOTICE +19 -0
- quickdbd_cli-0.1.0.dist-info/licenses/src/quickdbd_cli/assets/Inter-LICENSE.txt +92 -0
- quickdbd_cli-0.1.0.dist-info/licenses/src/quickdbd_cli/assets/elk-LICENSE.md +263 -0
quickdbd_cli/project.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Input discovery and the compile pipeline shared by every command."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from . import layout
|
|
9
|
+
from .measure import model_json
|
|
10
|
+
from .model import Schema
|
|
11
|
+
from .parser import compile_sources
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def discover(inputs: list[Path]) -> list[Path]:
|
|
15
|
+
"""Expand directories to every ``*.txt`` beneath them (recursive, sorted)."""
|
|
16
|
+
files: list[Path] = []
|
|
17
|
+
for p in inputs:
|
|
18
|
+
if p.is_dir():
|
|
19
|
+
files.extend(sorted(f for f in p.rglob("*.txt") if f.is_file()))
|
|
20
|
+
elif p.exists():
|
|
21
|
+
files.append(p)
|
|
22
|
+
else:
|
|
23
|
+
raise FileNotFoundError(f"no such file or directory: {p}")
|
|
24
|
+
seen: set[Path] = set()
|
|
25
|
+
out = []
|
|
26
|
+
for f in files:
|
|
27
|
+
r = f.resolve()
|
|
28
|
+
if r not in seen:
|
|
29
|
+
seen.add(r)
|
|
30
|
+
out.append(f)
|
|
31
|
+
return out
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def display_path(p: Path) -> str:
|
|
35
|
+
try:
|
|
36
|
+
return str(p.resolve().relative_to(Path.cwd().resolve()))
|
|
37
|
+
except ValueError:
|
|
38
|
+
return str(p)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class Project:
|
|
43
|
+
inputs: list[Path]
|
|
44
|
+
files: list[Path]
|
|
45
|
+
sidecar: Path
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def open(cls, inputs: list[Path], sidecar: Path | None = None) -> Project:
|
|
49
|
+
files = discover(inputs)
|
|
50
|
+
if not files:
|
|
51
|
+
raise FileNotFoundError("no .txt schema files found in: " + ", ".join(map(str, inputs)))
|
|
52
|
+
return cls(inputs, files, sidecar or layout.default_sidecar(files, inputs))
|
|
53
|
+
|
|
54
|
+
def sources(self) -> list[tuple[str, str]]:
|
|
55
|
+
return [(display_path(f), f.read_text(encoding="utf-8")) for f in self.files]
|
|
56
|
+
|
|
57
|
+
def compile(self) -> Schema:
|
|
58
|
+
return compile_sources(self.sources())
|
|
59
|
+
|
|
60
|
+
def build(self, schema: Schema, reset: bool = False) -> tuple[dict, dict]:
|
|
61
|
+
"""Returns (model, positions) with positions keyed by table id as [x, y]."""
|
|
62
|
+
model = model_json(schema)
|
|
63
|
+
side = {} if reset else layout.read_sidecar(self.sidecar)
|
|
64
|
+
pos = layout.resolve_positions(model, side, schema.layout, reset=reset)
|
|
65
|
+
return model, {k: [v[0], v[1]] for k, v in pos.items()}
|
|
66
|
+
|
|
67
|
+
def save_positions(self, model: dict, positions: dict) -> None:
|
|
68
|
+
by_name = {t["name"]: tuple(positions[t["id"]]) for t in model["tables"] if t["id"] in positions}
|
|
69
|
+
layout.write_sidecar(self.sidecar, by_name)
|
quickdbd_cli/serve.py
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""`qdbd serve`: local live editor.
|
|
2
|
+
|
|
3
|
+
Watches the schema files (mtime polling), recompiles on change and pushes a reload event to the
|
|
4
|
+
page over Server-Sent Events. Dragged table positions are saved to the layout sidecar; the
|
|
5
|
+
browser editor pane writes the .txt files, refusing to overwrite a file changed on disk since
|
|
6
|
+
the browser last loaded it.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import sys
|
|
13
|
+
import threading
|
|
14
|
+
import time
|
|
15
|
+
import webbrowser
|
|
16
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
from . import layout
|
|
20
|
+
from .html import render_page
|
|
21
|
+
from .project import Project, discover, display_path
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class State:
|
|
25
|
+
def __init__(self, project: Project):
|
|
26
|
+
self.project = project
|
|
27
|
+
self.lock = threading.Condition()
|
|
28
|
+
self.version = 0
|
|
29
|
+
self.model: dict = {"style": {}, "tables": [], "rels": [], "zoom": None, "position": None}
|
|
30
|
+
self.positions: dict = {}
|
|
31
|
+
self.diagnostics: list[dict] = []
|
|
32
|
+
self.files: list[Path] = []
|
|
33
|
+
# mtimes are strings: nanosecond integers exceed JavaScript's safe integer range.
|
|
34
|
+
self.mtimes: dict[str, str] = {}
|
|
35
|
+
self.reload(initial=True)
|
|
36
|
+
|
|
37
|
+
def _scan(self) -> dict[str, str]:
|
|
38
|
+
self.files = discover(self.project.inputs)
|
|
39
|
+
self.project.files = self.files
|
|
40
|
+
return {display_path(f): str(f.stat().st_mtime_ns) for f in self.files}
|
|
41
|
+
|
|
42
|
+
def reload(self, initial: bool = False) -> None:
|
|
43
|
+
mtimes = self._scan()
|
|
44
|
+
schema = self.project.compile()
|
|
45
|
+
diags = [
|
|
46
|
+
{"path": d.path, "line": d.line, "message": d.message, "severity": d.severity, "text": d.format()}
|
|
47
|
+
for d in schema.diagnostics
|
|
48
|
+
]
|
|
49
|
+
with self.lock:
|
|
50
|
+
self.mtimes = mtimes
|
|
51
|
+
self.diagnostics = diags
|
|
52
|
+
if not schema.errors:
|
|
53
|
+
from .measure import model_json
|
|
54
|
+
|
|
55
|
+
model = model_json(schema)
|
|
56
|
+
base = layout.read_sidecar(self.project.sidecar)
|
|
57
|
+
current = {
|
|
58
|
+
t["name"]: tuple(self.positions[t["id"]]) for t in self.model["tables"] if t["id"] in self.positions
|
|
59
|
+
}
|
|
60
|
+
base.update(current)
|
|
61
|
+
pos = layout.resolve_positions(model, base, schema.layout)
|
|
62
|
+
self.model = model
|
|
63
|
+
self.positions = {k: [v[0], v[1]] for k, v in pos.items()}
|
|
64
|
+
self.project.save_positions(model, self.positions)
|
|
65
|
+
self.version += 1
|
|
66
|
+
self.lock.notify_all()
|
|
67
|
+
if not initial:
|
|
68
|
+
n = len(schema.errors)
|
|
69
|
+
print(f"[qdbd] reloaded: {len(self.model['tables'])} tables" + (f", {n} error(s)" if n else ""), flush=True)
|
|
70
|
+
|
|
71
|
+
def changed(self) -> bool:
|
|
72
|
+
try:
|
|
73
|
+
return self._scan() != self.mtimes
|
|
74
|
+
except FileNotFoundError:
|
|
75
|
+
return True
|
|
76
|
+
|
|
77
|
+
def snapshot(self) -> dict:
|
|
78
|
+
with self.lock:
|
|
79
|
+
files = []
|
|
80
|
+
for f in self.files:
|
|
81
|
+
p = display_path(f)
|
|
82
|
+
try:
|
|
83
|
+
text = f.read_text(encoding="utf-8")
|
|
84
|
+
except FileNotFoundError:
|
|
85
|
+
continue
|
|
86
|
+
files.append({"path": p, "text": text, "mtime": self.mtimes.get(p)})
|
|
87
|
+
return {
|
|
88
|
+
"version": self.version,
|
|
89
|
+
"model": self.model,
|
|
90
|
+
"positions": self.positions,
|
|
91
|
+
"diagnostics": self.diagnostics,
|
|
92
|
+
"files": files,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
def save_layout(self, body: dict) -> None:
|
|
96
|
+
with self.lock:
|
|
97
|
+
by_name = {t["name"]: t["id"] for t in self.model["tables"]}
|
|
98
|
+
for name, xy in body.items():
|
|
99
|
+
if name in by_name:
|
|
100
|
+
self.positions[by_name[name]] = [int(xy[0]), int(xy[1])]
|
|
101
|
+
self.project.save_positions(self.model, self.positions)
|
|
102
|
+
|
|
103
|
+
def write_file(self, path: str, text: str, base_mtime: str | None) -> tuple[int, dict]:
|
|
104
|
+
target = next((f for f in self.files if display_path(f) == path), None)
|
|
105
|
+
if target is None:
|
|
106
|
+
return 404, {"error": "unknown file"}
|
|
107
|
+
current = str(target.stat().st_mtime_ns)
|
|
108
|
+
if base_mtime is not None and current != str(base_mtime):
|
|
109
|
+
return 409, {"error": "changed on disk", "text": target.read_text(encoding="utf-8"), "mtime": current}
|
|
110
|
+
target.write_text(text, encoding="utf-8")
|
|
111
|
+
return 200, {"mtime": str(target.stat().st_mtime_ns)}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _handler(state: State, title: str):
|
|
115
|
+
class Handler(BaseHTTPRequestHandler):
|
|
116
|
+
def log_message(self, *args) -> None: # quiet
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
def _send(self, code: int, body: bytes, ctype: str) -> None:
|
|
120
|
+
self.send_response(code)
|
|
121
|
+
self.send_header("Content-Type", ctype)
|
|
122
|
+
self.send_header("Content-Length", str(len(body)))
|
|
123
|
+
self.send_header("Cache-Control", "no-store")
|
|
124
|
+
self.end_headers()
|
|
125
|
+
self.wfile.write(body)
|
|
126
|
+
|
|
127
|
+
def _json(self, code: int, obj) -> None:
|
|
128
|
+
self._send(code, json.dumps(obj).encode(), "application/json")
|
|
129
|
+
|
|
130
|
+
def _body(self) -> dict:
|
|
131
|
+
n = int(self.headers.get("Content-Length") or 0)
|
|
132
|
+
return json.loads(self.rfile.read(n) or b"{}")
|
|
133
|
+
|
|
134
|
+
def do_GET(self) -> None:
|
|
135
|
+
if self.path == "/":
|
|
136
|
+
with state.lock:
|
|
137
|
+
page = render_page(state.model, state.positions, title, serve=True)
|
|
138
|
+
self._send(200, page.encode(), "text/html; charset=utf-8")
|
|
139
|
+
elif self.path == "/state":
|
|
140
|
+
self._json(200, state.snapshot())
|
|
141
|
+
elif self.path == "/events":
|
|
142
|
+
self.send_response(200)
|
|
143
|
+
self.send_header("Content-Type", "text/event-stream")
|
|
144
|
+
self.send_header("Cache-Control", "no-store")
|
|
145
|
+
self.end_headers()
|
|
146
|
+
seen = -1
|
|
147
|
+
try:
|
|
148
|
+
while True:
|
|
149
|
+
with state.lock:
|
|
150
|
+
state.lock.wait_for(lambda s=seen: state.version != s, timeout=15)
|
|
151
|
+
v = state.version
|
|
152
|
+
msg = f"data: {v}\n\n" if v != seen else ": ping\n\n"
|
|
153
|
+
seen = v
|
|
154
|
+
self.wfile.write(msg.encode())
|
|
155
|
+
self.wfile.flush()
|
|
156
|
+
except (BrokenPipeError, ConnectionResetError, OSError):
|
|
157
|
+
return
|
|
158
|
+
elif self.path == "/favicon.ico":
|
|
159
|
+
self._send(204, b"", "image/x-icon")
|
|
160
|
+
else:
|
|
161
|
+
self._send(404, b"not found", "text/plain")
|
|
162
|
+
|
|
163
|
+
def do_POST(self) -> None:
|
|
164
|
+
if self.path == "/layout":
|
|
165
|
+
state.save_layout(self._body())
|
|
166
|
+
self._json(200, {"ok": True})
|
|
167
|
+
else:
|
|
168
|
+
self._send(404, b"not found", "text/plain")
|
|
169
|
+
|
|
170
|
+
def do_PUT(self) -> None:
|
|
171
|
+
if self.path == "/file":
|
|
172
|
+
b = self._body()
|
|
173
|
+
code, obj = state.write_file(b.get("path", ""), b.get("text", ""), b.get("mtime"))
|
|
174
|
+
self._json(code, obj)
|
|
175
|
+
else:
|
|
176
|
+
self._send(404, b"not found", "text/plain")
|
|
177
|
+
|
|
178
|
+
return Handler
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def serve(project: Project, port: int = 8765, open_browser: bool = True) -> int:
|
|
182
|
+
state = State(project)
|
|
183
|
+
for d in state.diagnostics:
|
|
184
|
+
print(d["text"], file=sys.stderr)
|
|
185
|
+
title = project.inputs[0].stem if len(project.inputs) == 1 else "diagram"
|
|
186
|
+
server = ThreadingHTTPServer(("127.0.0.1", port), _handler(state, title))
|
|
187
|
+
server.daemon_threads = True
|
|
188
|
+
url = f"http://127.0.0.1:{server.server_address[1]}/"
|
|
189
|
+
print(f"[qdbd] serving {len(state.files)} file(s) at {url} (layout: {display_path(project.sidecar)})")
|
|
190
|
+
print("[qdbd] Ctrl+C to stop", flush=True)
|
|
191
|
+
|
|
192
|
+
def watch() -> None:
|
|
193
|
+
while True:
|
|
194
|
+
time.sleep(0.3)
|
|
195
|
+
if state.changed():
|
|
196
|
+
try:
|
|
197
|
+
state.reload()
|
|
198
|
+
except Exception as e: # keep serving on unexpected errors
|
|
199
|
+
print(f"[qdbd] reload failed: {e}", file=sys.stderr, flush=True)
|
|
200
|
+
|
|
201
|
+
threading.Thread(target=watch, daemon=True).start()
|
|
202
|
+
if open_browser:
|
|
203
|
+
threading.Timer(0.3, lambda: webbrowser.open(url)).start()
|
|
204
|
+
try:
|
|
205
|
+
server.serve_forever()
|
|
206
|
+
except KeyboardInterrupt:
|
|
207
|
+
print("\n[qdbd] stopped")
|
|
208
|
+
finally:
|
|
209
|
+
server.server_close()
|
|
210
|
+
return 0
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: quickdbd-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Compile QuickDBD-syntax schema files into interactive HTML ER diagrams, with no table limit.
|
|
5
|
+
Project-URL: Homepage, https://github.com/MarkPhamm/quickdbd-cli
|
|
6
|
+
Author: Minh (Mark) Pham
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
License-File: src/quickdbd_cli/assets/Inter-LICENSE.txt
|
|
11
|
+
License-File: src/quickdbd_cli/assets/elk-LICENSE.md
|
|
12
|
+
Keywords: database,diagram,erd,quickdbd,schema
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Database
|
|
16
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Requires-Dist: mini-racer>=0.14
|
|
19
|
+
Requires-Dist: resvg-py>=0.5
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: fonttools>=4.50; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
23
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# quickdbd-cli (`qdbd`)
|
|
27
|
+
|
|
28
|
+
Compile [QuickDBD](https://www.quickdatabasediagrams.com)-syntax schema files into **interactive HTML ER diagrams**, with no table limit, from the command line. Built to stay readable at 200+ tables.
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Customer
|
|
32
|
+
-
|
|
33
|
+
CustomerId PK int
|
|
34
|
+
Name string
|
|
35
|
+
|
|
36
|
+
Order
|
|
37
|
+
-
|
|
38
|
+
OrderId PK int
|
|
39
|
+
CustomerId int FK >- Customer.CustomerId
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pipx install quickdbd-cli # or: uvx --from quickdbd-cli qdbd ...
|
|
44
|
+
qdbd build schema.txt -o schema.html
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Not affiliated with QuickDBD. It reads the same text syntax, so schemas move freely between the two.
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- **Same syntax as QuickDBD:** tables, aliases, quoted names, all 9 relationship operators, `rel` lines, PK/FK/NULL/UNIQUE/INDEX/IDENTITY, `default=`, doc comments, `[settings]` and `[layout]` sections. Error messages are QuickDBD's own.
|
|
52
|
+
- **Interactive page:**
|
|
53
|
+
- search and jump to a table (`/`)
|
|
54
|
+
- minimap
|
|
55
|
+
- click a table to focus on it and its neighbours
|
|
56
|
+
- collapse tables: full / keys only / names only
|
|
57
|
+
- hover a column to highlight its relationship
|
|
58
|
+
- PNG/SVG export buttons
|
|
59
|
+
- **Live editing:** `qdbd serve` reloads when you save, has a browser editor pane with autosave, and remembers where you drag tables.
|
|
60
|
+
- **Many files, one diagram:** point it at a folder and foreign keys can cross files.
|
|
61
|
+
- **Pip-only install:** no Graphviz, Node or browser needed. Layout uses [ELK](https://eclipse.dev/elk/), running in an embedded V8.
|
|
62
|
+
- **CI-friendly:** builds are deterministic, and errors are `file:line: error: …` with exit code 1.
|
|
63
|
+
|
|
64
|
+
## Commands
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
qdbd check PATH... [--strict] # validate; "No errors found. Good job!"
|
|
68
|
+
qdbd build PATH... -o diagram.html # shareable interactive HTML (positions locked)
|
|
69
|
+
qdbd serve PATH... [--port 8765] # live editor + drag-to-arrange
|
|
70
|
+
qdbd export PATH... -o out.png [--focus Customer --depth 1] # PNG or SVG image
|
|
71
|
+
qdbd layout PATH... [--reset] # (re)write the layout file
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`PATH` is a `.txt` file or a folder. Every `*.txt` under a folder is read recursively.
|
|
75
|
+
|
|
76
|
+
### Table positions
|
|
77
|
+
|
|
78
|
+
The first build auto-arranges the tables. In `qdbd serve`, drag tables where you want them. Positions are saved to a sidecar file you can commit:
|
|
79
|
+
|
|
80
|
+
- `schema.txt` → `schema.layout.json`
|
|
81
|
+
- a folder → `<folder>/qdbd.layout.json`
|
|
82
|
+
- override either with `--layout FILE`
|
|
83
|
+
|
|
84
|
+
Once a layout exists, a new table is placed next to the tables it's related to, and nothing else moves. Run `qdbd layout PATH --reset` to re-arrange everything from scratch. A pasted schema's QuickDBD `[layout]` section is used for any table the sidecar doesn't cover.
|
|
85
|
+
|
|
86
|
+
`qdbd build` never writes the sidecar, so CI builds leave the working tree clean.
|
|
87
|
+
|
|
88
|
+
### Differences from QuickDBD
|
|
89
|
+
|
|
90
|
+
`qdbd` accepts a few things QuickDBD rejects, and prints a warning for each one:
|
|
91
|
+
|
|
92
|
+
- tab characters
|
|
93
|
+
- `decimal(10, 2)` (a space inside a type)
|
|
94
|
+
- an explicit `NOT NULL`
|
|
95
|
+
- indented table names
|
|
96
|
+
- `[layout]` entries for unknown tables
|
|
97
|
+
|
|
98
|
+
`qdbd check --strict` turns these warnings into errors, so a file that passes is guaranteed to paste into QuickDBD.
|
|
99
|
+
|
|
100
|
+
`default=` values keep their case, where QuickDBD lowercases them.
|
|
101
|
+
|
|
102
|
+
## CI
|
|
103
|
+
|
|
104
|
+
**pre-commit:**
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
repos:
|
|
108
|
+
- repo: https://github.com/MarkPhamm/quickdbd-cli
|
|
109
|
+
rev: v0.1.0
|
|
110
|
+
hooks:
|
|
111
|
+
- id: qdbd-check
|
|
112
|
+
files: ^schema/.*\.txt$ # point at your schema files
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**GitHub Actions:**
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
- uses: actions/setup-python@v5
|
|
119
|
+
with: { python-version: "3.12" }
|
|
120
|
+
- run: pip install quickdbd-cli
|
|
121
|
+
- run: qdbd check schema/
|
|
122
|
+
- run: qdbd build schema/ -o site/schema.html
|
|
123
|
+
- uses: actions/upload-artifact@v4
|
|
124
|
+
with: { name: schema-diagram, path: site/schema.html }
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**GitLab CI:**
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
erd:
|
|
131
|
+
image: python:3.12
|
|
132
|
+
script:
|
|
133
|
+
- pip install quickdbd-cli
|
|
134
|
+
- qdbd check schema/
|
|
135
|
+
- qdbd build schema/ -o public/schema.html
|
|
136
|
+
artifacts:
|
|
137
|
+
paths: [public/schema.html]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
uv venv && uv pip install -e ".[dev]"
|
|
144
|
+
.venv/bin/pytest
|
|
145
|
+
python scripts/gen_schema.py # regenerate examples/synthetic (200 tables)
|
|
146
|
+
python scripts/gen_font_metrics.py # regenerate font width table
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Design notes: `docs/superpowers/specs/2026-10-17-qdbd-design.md`.
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Apache-2.0. Bundled third-party files are listed in [NOTICE](NOTICE).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
quickdbd_cli/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
|
|
2
|
+
quickdbd_cli/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
|
|
3
|
+
quickdbd_cli/cli.py,sha256=lTuIOnpbsbcXhaOhByeBCKEIXFJ2XJ_-Lonb0JP26zM,5965
|
|
4
|
+
quickdbd_cli/export.py,sha256=9N6ZpLP7F2ZOJwEUURzbzSJ9xLpJjYykvRHuY7DhWU0,2482
|
|
5
|
+
quickdbd_cli/html.py,sha256=kOwdyAU5nQSpFWAuWXbvm-mHzaJArPhGVQGsibHZf5o,3703
|
|
6
|
+
quickdbd_cli/jsrt.py,sha256=f8JuDhCE0qU5YiO7JkxFVcoGbcSgMZMeUi9C6IlB_8s,2594
|
|
7
|
+
quickdbd_cli/layout.py,sha256=zMuY2ttrHoxZ5y97WO5IxrmPp30mZdUaKcT1LmzUdUg,7785
|
|
8
|
+
quickdbd_cli/measure.py,sha256=Yru-f1_MRWEvR6kmjXozHC40M4znix-RQi_3bnL0CGg,3162
|
|
9
|
+
quickdbd_cli/model.py,sha256=rL8rlhyPToPH17m3Sh4bvbIongqF98eEH0bgkOV4mgU,2798
|
|
10
|
+
quickdbd_cli/parser.py,sha256=2w6f1ZRyfPR-VCicGhDVSyUWqHUzVN6TV3gi-vVfyO8,27414
|
|
11
|
+
quickdbd_cli/project.py,sha256=3e1qvsLd1BqHI6nOuaz0qw4ZRyLwHJdRLp-T0-o4Qgw,2315
|
|
12
|
+
quickdbd_cli/serve.py,sha256=b9OjGxnCKWsQGML7HB5RGoJVsc6OVgueOXYMPsbM0qU,8350
|
|
13
|
+
quickdbd_cli/assets/Inter-Bold.ttf,sha256=KIMWCZseCkekcW0VkJgAXu98AGaSHzTjIAOT29sBlH8,420428
|
|
14
|
+
quickdbd_cli/assets/Inter-Bold.woff2,sha256=-oiBJ7baAVtlVp8DUfO1w5GtkokElR8cIOn4RiqNleo,114840
|
|
15
|
+
quickdbd_cli/assets/Inter-LICENSE.txt,sha256=JiSB6ERSGzJvXs0FPlm5jIstp4yO4b27boF0MF5Uk1o,4380
|
|
16
|
+
quickdbd_cli/assets/Inter-Regular.ttf,sha256=QNaS_OGI5EceKzy6k3vpZ4ePYxrT67vc1YdofH6-DII,411640
|
|
17
|
+
quickdbd_cli/assets/Inter-Regular.woff2,sha256=4G9rG8VTqupORmgCPtCrChRxKcMQf1Ebx9A9NhsK4IU,111268
|
|
18
|
+
quickdbd_cli/assets/editor.js,sha256=-_Kjk-kLYzn_UoV58xjPz6GudVYB5ZVfcSBQts9-wXM,8000
|
|
19
|
+
quickdbd_cli/assets/elk-LICENSE.md,sha256=Y36B9KG2tAeVNcSZ_KBeI4z3YFwf9bdtYNfafOlnAMk,14443
|
|
20
|
+
quickdbd_cli/assets/elk.bundled.js,sha256=EiLkT5U853Rq8jgB5yNwj45vQ2uLN3pqX8dVLzSjB7M,1609707
|
|
21
|
+
quickdbd_cli/assets/font-metrics.json,sha256=sXSiElxQSK8md8IEePLwh16TTdAqKt9rV140pvMlVS8,8654
|
|
22
|
+
quickdbd_cli/assets/render.js,sha256=JmnFuBLuY_t0gCwSo02KaRsgN_qfGf-8OUpu0rcmC00,10153
|
|
23
|
+
quickdbd_cli/assets/style.css,sha256=2-7Oam4iy2iJVlzIu36_Bn0_fK-fgsPwg0YIQ2PX4zw,4597
|
|
24
|
+
quickdbd_cli/assets/viewer.js,sha256=vqQi23m7-TMfLJeMuLMYWQWWs3gRGYonz5vUX78lsU4,12932
|
|
25
|
+
quickdbd_cli-0.1.0.dist-info/METADATA,sha256=chGwXKHhXxTaWYWIYTnQIXtAhHph3TN6Hh67Jpp7nsI,5171
|
|
26
|
+
quickdbd_cli-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
27
|
+
quickdbd_cli-0.1.0.dist-info/entry_points.txt,sha256=nRhiYYug-XOY95nWUmi4oanico3Zjkfqk2OHtIE6SQ0,47
|
|
28
|
+
quickdbd_cli-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
29
|
+
quickdbd_cli-0.1.0.dist-info/licenses/NOTICE,sha256=yj0trSHShGZMOuvTCYT2RgMy-h3cqGTtUP4BtW1znYQ,865
|
|
30
|
+
quickdbd_cli-0.1.0.dist-info/licenses/src/quickdbd_cli/assets/Inter-LICENSE.txt,sha256=JiSB6ERSGzJvXs0FPlm5jIstp4yO4b27boF0MF5Uk1o,4380
|
|
31
|
+
quickdbd_cli-0.1.0.dist-info/licenses/src/quickdbd_cli/assets/elk-LICENSE.md,sha256=Y36B9KG2tAeVNcSZ_KBeI4z3YFwf9bdtYNfafOlnAMk,14443
|
|
32
|
+
quickdbd_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|