symmetria-kit 1.0.0
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 +254 -0
- package/dist/cli/query-inspect.d.ts +7 -0
- package/dist/cli/query-inspect.js +283 -0
- package/dist/cli/query-inspect.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1656 -0
- package/dist/cli.js.map +1 -0
- package/dist/ddl-BpRIXfCw.js +284 -0
- package/dist/ddl-BpRIXfCw.js.map +1 -0
- package/dist/diff-ConfLt63.js +380 -0
- package/dist/diff-ConfLt63.js.map +1 -0
- package/dist/index.d.ts +372 -0
- package/dist/index.js +4 -0
- package/dist/schema-browser-data-BVymL_xf.js +470 -0
- package/dist/schema-browser-data-BVymL_xf.js.map +1 -0
- package/dist/src-C2mBlLSB.js +2797 -0
- package/dist/src-C2mBlLSB.js.map +1 -0
- package/dist/testing.d.ts +39 -0
- package/dist/testing.js +69 -0
- package/dist/testing.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { g as migrationSnapshot, i as enumerationSQL, o as foreignKeySQL, s as indexSQL, u as tableSQL } from "./ddl-BpRIXfCw.js";
|
|
2
|
+
import stringWidth from "string-width";
|
|
3
|
+
import { emitKeypressEvents } from "node:readline";
|
|
4
|
+
import { createInterface } from "node:readline/promises";
|
|
5
|
+
//#region src/cli/ui/style.ts
|
|
6
|
+
/**
|
|
7
|
+
* Terminal styling primitives: colour detection, theme, width fitting, panels, headings, errors and wrapping.
|
|
8
|
+
*/
|
|
9
|
+
const supportsColor = () => !!process.stdout.isTTY && process.env.NO_COLOR === void 0 && process.env.TERM !== "dumb";
|
|
10
|
+
const brandGradient = [
|
|
11
|
+
[
|
|
12
|
+
137,
|
|
13
|
+
180,
|
|
14
|
+
250
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
190,
|
|
18
|
+
160,
|
|
19
|
+
255
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
245,
|
|
23
|
+
168,
|
|
24
|
+
216
|
|
25
|
+
]
|
|
26
|
+
];
|
|
27
|
+
const palette = {
|
|
28
|
+
accent: `38;2;${brandGradient[0].join(";")}`,
|
|
29
|
+
violet: `38;2;${brandGradient[1].join(";")}`,
|
|
30
|
+
pink: `38;2;${brandGradient[2].join(";")}`,
|
|
31
|
+
connected: "38;2;126;226;168",
|
|
32
|
+
success: "38;2;158;195;255",
|
|
33
|
+
warning: "38;2;232;180;250",
|
|
34
|
+
danger: "38;2;255;126;171",
|
|
35
|
+
muted: "38;2;163;170;202",
|
|
36
|
+
border: "38;2;95;100;154",
|
|
37
|
+
text: "38;2;217;222;247",
|
|
38
|
+
strong: "1;38;2;217;222;247",
|
|
39
|
+
selected: "1;38;2;245;220;255;48;2;65;55;100"
|
|
40
|
+
};
|
|
41
|
+
const theme = (enabled = supportsColor()) => {
|
|
42
|
+
const style = (text, tone) => enabled ? `\u001b[${palette[tone]}m${text}\u001b[0m` : text;
|
|
43
|
+
return {
|
|
44
|
+
style,
|
|
45
|
+
brand: (frame = -10) => style("◇", "accent") + " " + [..."symmetria"].map((letter, position) => {
|
|
46
|
+
if (!enabled) return letter;
|
|
47
|
+
const progress = position / 4;
|
|
48
|
+
const segment = Math.min(1, Math.floor(progress));
|
|
49
|
+
const highlightPosition = 4 - 6 * Math.cos(frame * Math.PI / 32);
|
|
50
|
+
const highlight = frame < 0 ? 0 : .85 * Math.exp(-((position - highlightPosition) ** 2) / 3);
|
|
51
|
+
return `\u001b[38;2;${brandGradient[segment].map((channel, channelIndex) => {
|
|
52
|
+
const interpolated = channel + (brandGradient[segment + 1][channelIndex] - channel) * (progress - segment);
|
|
53
|
+
return Math.round(interpolated + (255 - interpolated) * highlight);
|
|
54
|
+
}).join(";")}m${letter}\u001b[0m`;
|
|
55
|
+
}).join("")
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const terminalWidth = () => Math.max(1, Math.min(process.stdout.columns || 88, 96) - 4);
|
|
59
|
+
const graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
60
|
+
/** Keep ANSI styling and wide characters intact while clipping a single terminal line. */
|
|
61
|
+
const fitLine = (text, width = terminalWidth()) => {
|
|
62
|
+
text = text.replace(/[\r\n\t]/g, " ");
|
|
63
|
+
if (width <= 0) return "";
|
|
64
|
+
if (stringWidth(text) <= width) return text;
|
|
65
|
+
let result = "";
|
|
66
|
+
let length = 0;
|
|
67
|
+
for (const part of text.split(/(\u001b\[[\d;]*m)/)) {
|
|
68
|
+
if (part.startsWith("\x1B[")) {
|
|
69
|
+
result += part;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
for (const { segment } of graphemes.segment(part)) {
|
|
73
|
+
const size = stringWidth(segment);
|
|
74
|
+
if (length + size > width - 1) return `${result}…${text.includes("\x1B[") ? "\x1B[0m" : ""}`;
|
|
75
|
+
result += segment;
|
|
76
|
+
length += size;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
const panel = (lines, color = false) => {
|
|
82
|
+
const { style } = theme(color);
|
|
83
|
+
const width = terminalWidth();
|
|
84
|
+
if (width < 12) return lines.map((line) => ` ${fitLine(line, width)}`).join("\n");
|
|
85
|
+
return [
|
|
86
|
+
` ${style(`╭${"─".repeat(width - 2)}╮`, "border")}`,
|
|
87
|
+
...lines.map((line) => {
|
|
88
|
+
const content = fitLine(line, width - 4);
|
|
89
|
+
return ` ${style("│", "border")} ${content}${" ".repeat(width - 4 - stringWidth(content))} ${style("│", "border")}`;
|
|
90
|
+
}),
|
|
91
|
+
` ${style(`╰${"─".repeat(width - 2)}╯`, "border")}`
|
|
92
|
+
].join("\n");
|
|
93
|
+
};
|
|
94
|
+
const heading = (title, subtitle, color = false) => {
|
|
95
|
+
const { style } = theme(color);
|
|
96
|
+
return `\n ${style("◇", "accent")} ${style(title, "strong")}${subtitle ? ` ${style(subtitle, "muted")}` : ""}\n`;
|
|
97
|
+
};
|
|
98
|
+
const formatError = (message, color = false) => {
|
|
99
|
+
if (!color) return message;
|
|
100
|
+
const { style } = theme(color);
|
|
101
|
+
return `\n ${style("✕", "danger")} ${message.split("\n").map((line) => style(line, "danger")).join("\n ")}\n`;
|
|
102
|
+
};
|
|
103
|
+
const wrapLines = (text, width = terminalWidth()) => {
|
|
104
|
+
const lines = [];
|
|
105
|
+
let activeStyle = "";
|
|
106
|
+
for (const original of text.split("\n")) {
|
|
107
|
+
let line = activeStyle;
|
|
108
|
+
let length = 0;
|
|
109
|
+
for (const part of original.replace(/[\r\t]/g, " ").split(/(\u001b\[[\d;]*m)/)) {
|
|
110
|
+
if (part.startsWith("\x1B[")) {
|
|
111
|
+
line += part;
|
|
112
|
+
activeStyle = part === "\x1B[0m" ? "" : activeStyle + part;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
for (const { segment } of graphemes.segment(part)) {
|
|
116
|
+
const size = stringWidth(segment);
|
|
117
|
+
if (length + size > width && length) {
|
|
118
|
+
lines.push(line + (activeStyle ? "\x1B[0m" : ""));
|
|
119
|
+
line = activeStyle;
|
|
120
|
+
length = 0;
|
|
121
|
+
}
|
|
122
|
+
line += segment;
|
|
123
|
+
length += size;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
lines.push(line + (activeStyle ? "\x1B[0m" : ""));
|
|
127
|
+
}
|
|
128
|
+
return lines;
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/cli/ui/terminal.ts
|
|
132
|
+
/**
|
|
133
|
+
* Interactive terminal primitives: single-choice menus, full-screen views, prompts and spinners with
|
|
134
|
+
* raw-mode handling and cancellation.
|
|
135
|
+
*/
|
|
136
|
+
const choose = (question, choices, options = {}) => new Promise((resolve) => {
|
|
137
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("symmetria: interactive selection requires a terminal");
|
|
138
|
+
if (!choices.length) return resolve(void 0);
|
|
139
|
+
const { style } = theme(options.color ?? supportsColor());
|
|
140
|
+
let selected = 0;
|
|
141
|
+
let renderedLines = 0;
|
|
142
|
+
let finished = false;
|
|
143
|
+
let headerHeight = 0;
|
|
144
|
+
let headerLines = [];
|
|
145
|
+
let frame = 0;
|
|
146
|
+
const wasRaw = process.stdin.isRaw;
|
|
147
|
+
emitKeypressEvents(process.stdin);
|
|
148
|
+
process.stdin.setRawMode(true);
|
|
149
|
+
process.stdin.resume();
|
|
150
|
+
process.stdout.write(`${options.header ? "" : "\n"}\u001b[?25l`);
|
|
151
|
+
const draw = () => {
|
|
152
|
+
const visibleCount = Math.min(choices.length, Math.max(1, (process.stdout.rows || 24) - headerHeight - 8));
|
|
153
|
+
const start = Math.min(Math.max(0, selected - visibleCount + 1), choices.length - visibleCount);
|
|
154
|
+
const width = terminalWidth();
|
|
155
|
+
const lines = [
|
|
156
|
+
` ${style(fitLine(question, width), "strong")}`,
|
|
157
|
+
"",
|
|
158
|
+
...choices.slice(start, start + visibleCount).map((choice, position) => {
|
|
159
|
+
const index = start + position;
|
|
160
|
+
const label = fitLine(`${index === selected ? "›" : " "} ${index + 1} ${choice}`, width);
|
|
161
|
+
return ` ${style(label, index === selected ? "selected" : "text")}`;
|
|
162
|
+
}),
|
|
163
|
+
"",
|
|
164
|
+
...options.descriptions ? [` ${style(fitLine(options.descriptions[selected] ?? "", width), "pink")}`] : [],
|
|
165
|
+
` ${style(fitLine("↑ ↓ navigate · enter select · esc exit", width), "muted")}`
|
|
166
|
+
];
|
|
167
|
+
const cursor = options.header ? `\u001b[${headerHeight + 2};1H` : renderedLines ? `\u001b[${renderedLines}A\r` : "";
|
|
168
|
+
renderedLines = lines.length;
|
|
169
|
+
process.stdout.write(cursor + lines.map((line) => `\u001b[2K${line}`).join("\n") + "\n\x1B[J");
|
|
170
|
+
};
|
|
171
|
+
const resize = () => {
|
|
172
|
+
if (options.header) {
|
|
173
|
+
headerLines = options.header(frame).split("\n").slice(0, Math.max(1, (process.stdout.rows || 24) - 9));
|
|
174
|
+
headerHeight = headerLines.length;
|
|
175
|
+
process.stdout.write("\x1B[H\x1B[2J" + headerLines.join("\n"));
|
|
176
|
+
renderedLines = 0;
|
|
177
|
+
}
|
|
178
|
+
draw();
|
|
179
|
+
};
|
|
180
|
+
const finish = (choice) => {
|
|
181
|
+
if (finished) return;
|
|
182
|
+
finished = true;
|
|
183
|
+
if (animationTimer) clearInterval(animationTimer);
|
|
184
|
+
process.stdin.off("keypress", keypress);
|
|
185
|
+
process.stdin.off("end", end);
|
|
186
|
+
process.stdout.off("resize", resize);
|
|
187
|
+
process.off("SIGTERM", terminate);
|
|
188
|
+
process.stdin.setRawMode(wasRaw);
|
|
189
|
+
process.stdin.pause();
|
|
190
|
+
process.stdout.write(`${options.header ? `\u001b[${headerHeight + 2};1H` : `\u001b[${renderedLines}A\r`}\u001b[J\u001b[?25h`);
|
|
191
|
+
process.stdout.write(` ${style(choice === void 0 ? "○" : "◆", "accent")} ${choice === void 0 ? style("Closed", "muted") : choices[choice]}\n\n`);
|
|
192
|
+
resolve(choice);
|
|
193
|
+
};
|
|
194
|
+
const end = () => finish();
|
|
195
|
+
const terminate = () => {
|
|
196
|
+
finish();
|
|
197
|
+
process.exit(143);
|
|
198
|
+
};
|
|
199
|
+
const keypress = (input, key) => {
|
|
200
|
+
if (key.name === "escape" || key.ctrl && ["c", "d"].includes(key.name ?? "")) return finish();
|
|
201
|
+
if (key.name === "return") return finish(selected);
|
|
202
|
+
if (key.name === "up") selected = (selected + choices.length - 1) % choices.length;
|
|
203
|
+
else if (key.name === "down" || key.name === "tab") selected = (selected + 1) % choices.length;
|
|
204
|
+
else if (key.name === "home") selected = 0;
|
|
205
|
+
else if (key.name === "end") selected = choices.length - 1;
|
|
206
|
+
else if (/^[1-9]$/.test(input) && Number(input) <= choices.length) return finish(Number(input) - 1);
|
|
207
|
+
else return;
|
|
208
|
+
draw();
|
|
209
|
+
};
|
|
210
|
+
process.stdin.on("keypress", keypress);
|
|
211
|
+
process.stdin.once("end", end);
|
|
212
|
+
process.stdout.on("resize", resize);
|
|
213
|
+
process.once("SIGTERM", terminate);
|
|
214
|
+
const animationTimer = options.header && options.animation && (options.color ?? supportsColor()) ? setInterval(() => {
|
|
215
|
+
const next = options.header(++frame).split("\n").slice(0, headerHeight);
|
|
216
|
+
const updates = next.flatMap((line, position) => line === headerLines[position] ? [] : [`\u001b[${position + 1};1H\u001b[2K${line}`]);
|
|
217
|
+
if (updates.length) process.stdout.write(`\u001b[s${updates.join("")}\u001b[u`);
|
|
218
|
+
headerLines = next;
|
|
219
|
+
}, 50) : void 0;
|
|
220
|
+
resize();
|
|
221
|
+
});
|
|
222
|
+
/** Keep the dashboard in one terminal screen and restore the shell on every exit. */
|
|
223
|
+
const withScreen = async (operation) => {
|
|
224
|
+
const wasRaw = process.stdin.isRaw;
|
|
225
|
+
let restored = false;
|
|
226
|
+
const restore = () => {
|
|
227
|
+
if (restored) return;
|
|
228
|
+
restored = true;
|
|
229
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(wasRaw);
|
|
230
|
+
process.stdout.write("\x1B[0m\x1B[?25h\x1B[?1049l");
|
|
231
|
+
};
|
|
232
|
+
const interrupt = () => process.exit(130);
|
|
233
|
+
const terminate = () => process.exit(143);
|
|
234
|
+
process.once("exit", restore);
|
|
235
|
+
process.once("SIGINT", interrupt);
|
|
236
|
+
process.once("SIGTERM", terminate);
|
|
237
|
+
process.stdout.write("\x1B[?1049h\x1B[H\x1B[2J");
|
|
238
|
+
try {
|
|
239
|
+
await operation();
|
|
240
|
+
} finally {
|
|
241
|
+
process.off("exit", restore);
|
|
242
|
+
process.off("SIGINT", interrupt);
|
|
243
|
+
process.off("SIGTERM", terminate);
|
|
244
|
+
restore();
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
/** A scrollable action result in the dashboard's existing screen. */
|
|
248
|
+
const view = (title, content, color) => new Promise((resolve) => {
|
|
249
|
+
const { style, brand } = theme(color);
|
|
250
|
+
const wasRaw = process.stdin.isRaw;
|
|
251
|
+
let offset = 0;
|
|
252
|
+
let lines = [];
|
|
253
|
+
let pageSize = 1;
|
|
254
|
+
let finished = false;
|
|
255
|
+
const draw = () => {
|
|
256
|
+
pageSize = Math.max(1, (process.stdout.rows || 24) - 5);
|
|
257
|
+
lines = wrapLines(content);
|
|
258
|
+
offset = Math.min(offset, Math.max(0, lines.length - pageSize));
|
|
259
|
+
const page = lines.slice(offset, offset + pageSize);
|
|
260
|
+
const footer = `↑ ↓ scroll · enter / esc back${lines.length > pageSize ? ` · ${offset + 1}–${offset + page.length}/${lines.length}` : ""}`;
|
|
261
|
+
process.stdout.write([
|
|
262
|
+
"\x1B[H\x1B[2J",
|
|
263
|
+
` ${brand()} ${style(`/ ${title}`, "muted")}\n\n`,
|
|
264
|
+
page.join("\n"),
|
|
265
|
+
`\u001b[${Math.max(1, (process.stdout.rows || 24) - 1)};1H ${style(fitLine(footer), "muted")}`
|
|
266
|
+
].join(""));
|
|
267
|
+
};
|
|
268
|
+
const finish = () => {
|
|
269
|
+
if (finished) return;
|
|
270
|
+
finished = true;
|
|
271
|
+
process.stdin.off("keypress", keypress);
|
|
272
|
+
process.stdin.off("end", finish);
|
|
273
|
+
process.stdout.off("resize", draw);
|
|
274
|
+
process.stdin.setRawMode(wasRaw);
|
|
275
|
+
process.stdin.pause();
|
|
276
|
+
process.stdout.write("\x1B[?25h");
|
|
277
|
+
resolve();
|
|
278
|
+
};
|
|
279
|
+
const keypress = (_input, key) => {
|
|
280
|
+
if (["escape", "return"].includes(key.name ?? "") || key.ctrl && key.name === "c") return finish();
|
|
281
|
+
if (key.name === "up") offset = Math.max(0, offset - 1);
|
|
282
|
+
else if (key.name === "down") offset++;
|
|
283
|
+
else if (key.name === "pageup") offset = Math.max(0, offset - pageSize);
|
|
284
|
+
else if (key.name === "pagedown" || key.name === "space") offset += pageSize;
|
|
285
|
+
else if (key.name === "home") offset = 0;
|
|
286
|
+
else if (key.name === "end") offset = lines.length;
|
|
287
|
+
else return;
|
|
288
|
+
draw();
|
|
289
|
+
};
|
|
290
|
+
emitKeypressEvents(process.stdin);
|
|
291
|
+
process.stdin.setRawMode(true);
|
|
292
|
+
process.stdin.resume();
|
|
293
|
+
process.stdin.on("keypress", keypress);
|
|
294
|
+
process.stdin.once("end", finish);
|
|
295
|
+
process.stdout.on("resize", draw);
|
|
296
|
+
process.stdout.write("\x1B[?25l");
|
|
297
|
+
draw();
|
|
298
|
+
});
|
|
299
|
+
const ask = async (question, color = supportsColor()) => {
|
|
300
|
+
const terminal = createInterface({
|
|
301
|
+
input: process.stdin,
|
|
302
|
+
output: process.stdout
|
|
303
|
+
});
|
|
304
|
+
const { style } = theme(color);
|
|
305
|
+
try {
|
|
306
|
+
return (await terminal.question(` ${style("◆", "violet")} ${style(question, "strong")} `)).trim();
|
|
307
|
+
} finally {
|
|
308
|
+
terminal.close();
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
/** Animate only real work, then erase the transient line before printing its result. */
|
|
312
|
+
const withSpinner = async (label, operation, options) => {
|
|
313
|
+
if (!options.enabled || !process.stdout.isTTY || process.env.TERM === "dumb") return operation();
|
|
314
|
+
const { style } = theme(options.color);
|
|
315
|
+
const frames = [
|
|
316
|
+
"⠋",
|
|
317
|
+
"⠙",
|
|
318
|
+
"⠹",
|
|
319
|
+
"⠸",
|
|
320
|
+
"⠼",
|
|
321
|
+
"⠴",
|
|
322
|
+
"⠦",
|
|
323
|
+
"⠧",
|
|
324
|
+
"⠇",
|
|
325
|
+
"⠏"
|
|
326
|
+
];
|
|
327
|
+
const started = performance.now();
|
|
328
|
+
let frame = 0;
|
|
329
|
+
const draw = () => {
|
|
330
|
+
const elapsed = `${((performance.now() - started) / 1e3).toFixed(1)}s`;
|
|
331
|
+
const line = `${style(options.animation ? frames[frame++ % frames.length] : "◇", frame % 8 < 4 ? "accent" : "violet")} ${label} ${style(elapsed, "muted")}`;
|
|
332
|
+
process.stdout.write(`\r\u001b[2K ${fitLine(line)}`);
|
|
333
|
+
};
|
|
334
|
+
const restore = () => process.stdout.write("\r\x1B[2K\x1B[?25h");
|
|
335
|
+
const interrupt = () => {
|
|
336
|
+
restore();
|
|
337
|
+
process.exit(130);
|
|
338
|
+
};
|
|
339
|
+
const terminate = () => {
|
|
340
|
+
restore();
|
|
341
|
+
process.exit(143);
|
|
342
|
+
};
|
|
343
|
+
process.once("SIGINT", interrupt);
|
|
344
|
+
process.once("SIGTERM", terminate);
|
|
345
|
+
process.stdout.write("\x1B[?25l");
|
|
346
|
+
draw();
|
|
347
|
+
const timer = options.animation ? setInterval(draw, 80) : void 0;
|
|
348
|
+
try {
|
|
349
|
+
return await operation();
|
|
350
|
+
} finally {
|
|
351
|
+
if (timer) clearInterval(timer);
|
|
352
|
+
process.off("SIGINT", interrupt);
|
|
353
|
+
process.off("SIGTERM", terminate);
|
|
354
|
+
restore();
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/cli/screens/schema-browser-data.ts
|
|
359
|
+
const inspectTabs = [
|
|
360
|
+
"Columns",
|
|
361
|
+
"Relations",
|
|
362
|
+
"Indexes",
|
|
363
|
+
"Checks",
|
|
364
|
+
"SQL"
|
|
365
|
+
];
|
|
366
|
+
const defaultLabel = (column) => {
|
|
367
|
+
if (!column.default) return;
|
|
368
|
+
if (column.default.kind === "sql") return column.default.sql;
|
|
369
|
+
return typeof column.default.value === "bigint" ? String(column.default.value) : JSON.stringify(column.default.value, (_name, value) => typeof value === "bigint" ? String(value) : value);
|
|
370
|
+
};
|
|
371
|
+
const inspectEntries = (table, tab) => {
|
|
372
|
+
if (tab === "Columns") return table.columns.map((column) => {
|
|
373
|
+
const defaultValue = defaultLabel(column);
|
|
374
|
+
const identity = column.default?.kind === "sql" && column.default.sql === "identity";
|
|
375
|
+
return {
|
|
376
|
+
name: column.name,
|
|
377
|
+
kind: column.sqlType,
|
|
378
|
+
badges: [
|
|
379
|
+
column.primaryKey || table.primaryKey?.includes(column.sqlName) ? "PK" : "",
|
|
380
|
+
column.references ? "FK" : "",
|
|
381
|
+
column.unique ? "UNIQUE" : "",
|
|
382
|
+
!column.notNull ? "NULL" : "",
|
|
383
|
+
identity ? "AUTO" : defaultValue === void 0 ? "" : "DEFAULT"
|
|
384
|
+
].filter(Boolean),
|
|
385
|
+
description: [
|
|
386
|
+
`${table.sqlName}.${column.sqlName} · ${column.sqlType} · ${column.notNull ? "NOT NULL" : "NULLABLE"}`,
|
|
387
|
+
defaultValue === void 0 ? "" : identity ? "GENERATED ALWAYS AS IDENTITY" : `Default: ${defaultValue}`,
|
|
388
|
+
column.enumerationValues ? `Values: ${column.enumerationValues.join(" · ")}` : "",
|
|
389
|
+
column.references ? `→ ${column.references.table}.${column.references.column} · ON DELETE ${column.references.onDelete.toUpperCase()}\nEnter to follow this foreign key` : ""
|
|
390
|
+
].filter(Boolean).join("\n"),
|
|
391
|
+
...column.references ? { target: {
|
|
392
|
+
table: column.references.table,
|
|
393
|
+
column: column.references.column
|
|
394
|
+
} } : {}
|
|
395
|
+
};
|
|
396
|
+
});
|
|
397
|
+
if (tab === "Relations") return table.relations.map((relation) => {
|
|
398
|
+
if (relation.kind === "condition") {
|
|
399
|
+
const declaring = relation.reverse ? relation.target : table.name;
|
|
400
|
+
return {
|
|
401
|
+
name: relation.name,
|
|
402
|
+
kind: relation.many ? "many" : "one",
|
|
403
|
+
badges: ["CONDITION", ...relation.reverse ? ["REVERSE"] : []],
|
|
404
|
+
description: `${table.name}.${relation.name} → ${relation.target}\nJoined by the predicate declared in ${declaring}.relations()\nEnter to open ${relation.target}`,
|
|
405
|
+
target: { table: relation.target }
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
const column = relation.kind === "through" ? void 0 : table.columns.find((column) => column.name === relation.foreignKey);
|
|
409
|
+
return {
|
|
410
|
+
name: relation.name,
|
|
411
|
+
kind: relation.kind === "through" ? "many ↔ many" : relation.kind,
|
|
412
|
+
badges: relation.kind === "through" ? ["JUNCTION"] : relation.reverse ? ["REVERSE"] : relation.nullable ? ["OPTIONAL"] : [],
|
|
413
|
+
description: `${table.name}.${relation.name} → ${relation.target}\n${relation.kind === "through" ? `Through ${relation.junction} (${relation.sourceForeignKey} → ${relation.targetForeignKey})` : `Foreign key: ${relation.reverse ? relation.target : table.name}.${relation.foreignKey}`}\nEnter to open ${relation.target}`,
|
|
414
|
+
target: {
|
|
415
|
+
table: relation.target,
|
|
416
|
+
...relation.kind === "through" ? {} : relation.reverse ? { column: relation.foreignKey } : column?.references ? { column: column.references.column } : {}
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
});
|
|
420
|
+
if (tab === "Indexes") return (table.indexes ?? []).map((index) => ({
|
|
421
|
+
name: index.sqlName,
|
|
422
|
+
kind: index.method,
|
|
423
|
+
badges: index.unique ? ["UNIQUE"] : [],
|
|
424
|
+
description: [
|
|
425
|
+
index.sqlName,
|
|
426
|
+
`Keys: ${index.keys.join(", ")}`,
|
|
427
|
+
index.include.length ? `Include: ${index.include.join(", ")}` : "",
|
|
428
|
+
index.where ? `Where: ${index.where}` : ""
|
|
429
|
+
].filter(Boolean).join("\n")
|
|
430
|
+
}));
|
|
431
|
+
if (tab === "Checks") return (table.checks ?? []).map((check) => ({
|
|
432
|
+
name: check.sqlName,
|
|
433
|
+
kind: "check",
|
|
434
|
+
badges: [],
|
|
435
|
+
description: `${check.sqlName}\nCHECK (${check.expression})`
|
|
436
|
+
}));
|
|
437
|
+
return [];
|
|
438
|
+
};
|
|
439
|
+
const matchesEntry = (entry, search) => `${entry.name} ${entry.kind} ${entry.description} ${entry.badges.join(" ")}`.toLowerCase().includes(search.toLowerCase());
|
|
440
|
+
const matchesTableName = (table, search) => `${table.name} ${table.sqlName}`.toLowerCase().includes(search.toLowerCase());
|
|
441
|
+
const matchingTables = (snapshot, search) => snapshot.tables.filter((table) => matchesTableName(table, search) || inspectTabs.some((tab) => inspectEntries(table, tab).some((entry) => matchesEntry(entry, search))));
|
|
442
|
+
/** Use the migration compiler so the preview includes enums, constraints and indexes. */
|
|
443
|
+
const inspectTableSQL = (snapshot, table) => {
|
|
444
|
+
const migration = migrationSnapshot(snapshot);
|
|
445
|
+
const definition = migration.tables.find((candidate) => candidate.name === table.sqlName);
|
|
446
|
+
const enumerations = new Set(definition.columns.flatMap((column) => column.enumeration ? [column.enumeration] : []));
|
|
447
|
+
return [
|
|
448
|
+
...migration.enumerations.filter((enumeration) => enumerations.has(enumeration.name)).map((enumeration) => enumerationSQL(enumeration.name, enumeration.values)),
|
|
449
|
+
tableSQL(definition),
|
|
450
|
+
...definition.columns.filter((column) => column.references).map((column) => foreignKeySQL(definition, column)),
|
|
451
|
+
...definition.indexes.map((index) => indexSQL(definition, index))
|
|
452
|
+
].map((statement) => `${statement};`).join("\n\n");
|
|
453
|
+
};
|
|
454
|
+
const sqlKeywords = new Set("CREATE TABLE TYPE AS ENUM ALTER ADD CONSTRAINT PRIMARY KEY FOREIGN REFERENCES ON DELETE UPDATE CASCADE RESTRICT SET NULL NOT DEFAULT GENERATED ALWAYS BY IDENTITY UNIQUE CHECK INDEX USING INCLUDE WHERE ASC DESC AND OR TRUE FALSE IS IN LIKE BETWEEN SELECT FROM NO ACTION MATCH FULL PARTIAL SIMPLE DEFERRABLE INITIALLY DEFERRED IMMEDIATE LEFT RIGHT INNER OUTER CROSS JOIN GROUP ORDER HAVING LIMIT OFFSET DISTINCT EXISTS RETURNING INSERT INTO VALUES CONFLICT DO NOTHING UNION ALL WITH FOR SHARE SKIP LOCKED NOWAIT EXPLAIN ANALYZE BUFFERS FORMAT JSON NULLS FIRST LAST".split(" "));
|
|
455
|
+
const highlightSQL = (sql, color) => {
|
|
456
|
+
if (!color) return sql;
|
|
457
|
+
const { style } = theme(color);
|
|
458
|
+
return sql.replace(/--[^\n]*|\/\*[\s\S]*?\*\/|(\$(?:[a-z_][\w]*)?\$)[\s\S]*?\1|\$\d+|\bE'(?:\\.|''|[^'])*'|'(?:''|[^'])*'|"(?:""|[^"])*"|\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b|\b[a-z_][\w]*\b/gi, (token) => {
|
|
459
|
+
if (token.startsWith("--") || token.startsWith("/*")) return style(token, "muted");
|
|
460
|
+
if (token.startsWith("\"")) return style(token, "accent");
|
|
461
|
+
if (/^(?:E?'|\$)/i.test(token)) return style(token, "pink");
|
|
462
|
+
if (sqlKeywords.has(token.toUpperCase())) return style(token, "violet");
|
|
463
|
+
if (/^\d/.test(token)) return style(token, "pink");
|
|
464
|
+
return token;
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
//#endregion
|
|
468
|
+
export { supportsColor as _, matchesEntry as a, wrapLines as b, ask as c, withScreen as d, withSpinner as f, panel as g, heading as h, inspectTabs as i, choose as l, formatError as m, inspectEntries as n, matchesTableName as o, fitLine as p, inspectTableSQL as r, matchingTables as s, highlightSQL as t, view as u, terminalWidth as v, theme as y };
|
|
469
|
+
|
|
470
|
+
//# sourceMappingURL=schema-browser-data-BVymL_xf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-browser-data-BVymL_xf.js","names":[],"sources":["../src/cli/ui/style.ts","../src/cli/ui/terminal.ts","../src/cli/screens/schema-browser-data.ts"],"sourcesContent":["/**\n * Terminal styling primitives: colour detection, theme, width fitting, panels, headings, errors and wrapping.\n */\nimport stringWidth from \"string-width\";\n\nexport const supportsColor = (): boolean =>\n !!process.stdout.isTTY &&\n process.env.NO_COLOR === undefined &&\n process.env.TERM !== \"dumb\";\n\nconst brandGradient = [\n [137, 180, 250],\n [190, 160, 255],\n [245, 168, 216],\n] as const;\n\nconst palette = {\n accent: `38;2;${brandGradient[0].join(\";\")}`,\n violet: `38;2;${brandGradient[1].join(\";\")}`,\n pink: `38;2;${brandGradient[2].join(\";\")}`,\n connected: \"38;2;126;226;168\",\n success: \"38;2;158;195;255\",\n warning: \"38;2;232;180;250\",\n danger: \"38;2;255;126;171\",\n muted: \"38;2;163;170;202\",\n border: \"38;2;95;100;154\",\n text: \"38;2;217;222;247\",\n strong: \"1;38;2;217;222;247\",\n selected: \"1;38;2;245;220;255;48;2;65;55;100\",\n} as const;\n\nexport const theme = (enabled = supportsColor()) => {\n const style = (text: string, tone: keyof typeof palette): string =>\n enabled ? `\\u001b[${palette[tone]}m${text}\\u001b[0m` : text;\n\n return {\n style,\n brand: (frame = -10) =>\n style(\"◇\", \"accent\") +\n \" \" +\n [...\"symmetria\"]\n .map((letter, position) => {\n if (!enabled) {\n return letter;\n }\n\n const progress = position / 4;\n const segment = Math.min(1, Math.floor(progress));\n const highlightPosition = 4 - 6 * Math.cos((frame * Math.PI) / 32);\n const highlight =\n frame < 0\n ? 0\n : 0.85 * Math.exp(-((position - highlightPosition) ** 2) / 3);\n const channels = brandGradient[segment]!.map(\n (channel, channelIndex) => {\n const interpolated =\n channel +\n (brandGradient[segment + 1]![channelIndex]! - channel) *\n (progress - segment);\n\n return Math.round(\n interpolated + (255 - interpolated) * highlight,\n );\n },\n );\n\n return `\\u001b[38;2;${channels.join(\";\")}m${letter}\\u001b[0m`;\n })\n .join(\"\"),\n };\n};\n\nexport const terminalWidth = (): number =>\n Math.max(1, Math.min(process.stdout.columns || 88, 96) - 4);\n\nconst graphemes = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\n\n/** Keep ANSI styling and wide characters intact while clipping a single terminal line. */\nexport const fitLine = (text: string, width = terminalWidth()): string => {\n text = text.replace(/[\\r\\n\\t]/g, \" \");\n\n if (width <= 0) {\n return \"\";\n }\n\n if (stringWidth(text) <= width) {\n return text;\n }\n\n let result = \"\";\n let length = 0;\n\n for (const part of text.split(/(\\u001b\\[[\\d;]*m)/)) {\n if (part.startsWith(\"\\u001b[\")) {\n result += part;\n continue;\n }\n\n for (const { segment } of graphemes.segment(part)) {\n const size = stringWidth(segment);\n\n if (length + size > width - 1) {\n return `${result}…${text.includes(\"\\u001b[\") ? \"\\u001b[0m\" : \"\"}`;\n }\n\n result += segment;\n length += size;\n }\n }\n\n return result;\n};\n\nexport const panel = (lines: readonly string[], color = false): string => {\n const { style } = theme(color);\n const width = terminalWidth();\n\n if (width < 12) {\n return lines.map((line) => ` ${fitLine(line, width)}`).join(\"\\n\");\n }\n\n return [\n ` ${style(`╭${\"─\".repeat(width - 2)}╮`, \"border\")}`,\n ...lines.map((line) => {\n const content = fitLine(line, width - 4);\n\n return ` ${style(\"│\", \"border\")} ${content}${\" \".repeat(width - 4 - stringWidth(content))} ${style(\"│\", \"border\")}`;\n }),\n ` ${style(`╰${\"─\".repeat(width - 2)}╯`, \"border\")}`,\n ].join(\"\\n\");\n};\n\nexport const heading = (\n title: string,\n subtitle: string,\n color = false,\n): string => {\n const { style } = theme(color);\n\n return `\\n ${style(\"◇\", \"accent\")} ${style(title, \"strong\")}${subtitle ? ` ${style(subtitle, \"muted\")}` : \"\"}\\n`;\n};\n\nexport const formatError = (message: string, color = false): string => {\n if (!color) {\n return message;\n }\n\n const { style } = theme(color);\n\n return `\\n ${style(\"✕\", \"danger\")} ${message\n .split(\"\\n\")\n .map((line) => style(line, \"danger\"))\n .join(\"\\n \")}\\n`;\n};\n\nexport const wrapLines = (text: string, width = terminalWidth()): string[] => {\n const lines: string[] = [];\n let activeStyle = \"\";\n\n for (const original of text.split(\"\\n\")) {\n let line = activeStyle;\n let length = 0;\n\n for (const part of original\n .replace(/[\\r\\t]/g, \" \")\n .split(/(\\u001b\\[[\\d;]*m)/)) {\n if (part.startsWith(\"\\u001b[\")) {\n line += part;\n activeStyle = part === \"\\u001b[0m\" ? \"\" : activeStyle + part;\n continue;\n }\n\n for (const { segment } of graphemes.segment(part)) {\n const size = stringWidth(segment);\n\n if (length + size > width && length) {\n lines.push(line + (activeStyle ? \"\\u001b[0m\" : \"\"));\n line = activeStyle;\n length = 0;\n }\n\n line += segment;\n length += size;\n }\n }\n\n lines.push(line + (activeStyle ? \"\\u001b[0m\" : \"\"));\n }\n\n return lines;\n};\n","/**\n * Interactive terminal primitives: single-choice menus, full-screen views, prompts and spinners with\n * raw-mode handling and cancellation.\n */\nimport { emitKeypressEvents } from \"node:readline\";\nimport { createInterface } from \"node:readline/promises\";\nimport {\n fitLine,\n supportsColor,\n terminalWidth,\n theme,\n wrapLines,\n} from \"./style\";\n\nexport type Choose = (\n question: string,\n choices: readonly string[],\n) => Promise<number | undefined>;\n\ntype ChoiceOptions = {\n color?: boolean;\n descriptions?: readonly string[];\n header?: (frame: number) => string;\n animation?: boolean;\n};\n\nexport const choose = (\n question: string,\n choices: readonly string[],\n options: ChoiceOptions = {},\n): Promise<number | undefined> =>\n new Promise((resolve) => {\n if (!process.stdin.isTTY || !process.stdout.isTTY) {\n throw new Error(\"symmetria: interactive selection requires a terminal\");\n }\n\n if (!choices.length) {\n return resolve(undefined);\n }\n\n const { style } = theme(options.color ?? supportsColor());\n let selected = 0;\n let renderedLines = 0;\n let finished = false;\n let headerHeight = 0;\n let headerLines: string[] = [];\n let frame = 0;\n const wasRaw = process.stdin.isRaw;\n emitKeypressEvents(process.stdin);\n process.stdin.setRawMode(true);\n process.stdin.resume();\n process.stdout.write(`${options.header ? \"\" : \"\\n\"}\\u001b[?25l`);\n\n const draw = () => {\n // Leave room for the title, description and keyboard hint on short terminals.\n const visibleCount = Math.min(\n choices.length,\n Math.max(1, (process.stdout.rows || 24) - headerHeight - 8),\n );\n const start = Math.min(\n Math.max(0, selected - visibleCount + 1),\n choices.length - visibleCount,\n );\n const width = terminalWidth();\n const lines = [\n ` ${style(fitLine(question, width), \"strong\")}`,\n \"\",\n ...choices\n .slice(start, start + visibleCount)\n .map((choice, position) => {\n const index = start + position;\n const label = fitLine(\n `${index === selected ? \"›\" : \" \"} ${index + 1} ${choice}`,\n width,\n );\n\n return ` ${style(label, index === selected ? \"selected\" : \"text\")}`;\n }),\n \"\",\n ...(options.descriptions\n ? [\n ` ${style(fitLine(options.descriptions[selected] ?? \"\", width), \"pink\")}`,\n ]\n : []),\n ` ${style(fitLine(\"↑ ↓ navigate · enter select · esc exit\", width), \"muted\")}`,\n ];\n const cursor = options.header\n ? `\\u001b[${headerHeight + 2};1H`\n : renderedLines\n ? `\\u001b[${renderedLines}A\\r`\n : \"\";\n renderedLines = lines.length;\n process.stdout.write(\n cursor +\n lines.map((line) => `\\u001b[2K${line}`).join(\"\\n\") +\n \"\\n\\u001b[J\",\n );\n };\n\n const resize = () => {\n if (options.header) {\n headerLines = options\n .header(frame)\n .split(\"\\n\")\n .slice(0, Math.max(1, (process.stdout.rows || 24) - 9));\n headerHeight = headerLines.length;\n process.stdout.write(\"\\u001b[H\\u001b[2J\" + headerLines.join(\"\\n\"));\n renderedLines = 0;\n }\n\n draw();\n };\n\n const finish = (choice?: number) => {\n if (finished) {\n return;\n }\n\n finished = true;\n\n if (animationTimer) {\n clearInterval(animationTimer);\n }\n\n process.stdin.off(\"keypress\", keypress);\n process.stdin.off(\"end\", end);\n process.stdout.off(\"resize\", resize);\n process.off(\"SIGTERM\", terminate);\n process.stdin.setRawMode(wasRaw);\n process.stdin.pause();\n process.stdout.write(\n `${options.header ? `\\u001b[${headerHeight + 2};1H` : `\\u001b[${renderedLines}A\\r`}\\u001b[J\\u001b[?25h`,\n );\n process.stdout.write(\n ` ${style(choice === undefined ? \"○\" : \"◆\", \"accent\")} ${choice === undefined ? style(\"Closed\", \"muted\") : choices[choice]}\\n\\n`,\n );\n resolve(choice);\n };\n\n const end = () => finish();\n\n const terminate = () => {\n finish();\n process.exit(143);\n };\n\n const keypress = (\n input: string,\n key: { name?: string; ctrl?: boolean },\n ) => {\n if (\n key.name === \"escape\" ||\n (key.ctrl && [\"c\", \"d\"].includes(key.name ?? \"\"))\n ) {\n return finish();\n }\n\n if (key.name === \"return\") {\n return finish(selected);\n }\n\n if (key.name === \"up\") {\n selected = (selected + choices.length - 1) % choices.length;\n } else if (key.name === \"down\" || key.name === \"tab\") {\n selected = (selected + 1) % choices.length;\n } else if (key.name === \"home\") {\n selected = 0;\n } else if (key.name === \"end\") {\n selected = choices.length - 1;\n } else if (/^[1-9]$/.test(input) && Number(input) <= choices.length) {\n return finish(Number(input) - 1);\n } else {\n return;\n }\n\n draw();\n };\n\n process.stdin.on(\"keypress\", keypress);\n process.stdin.once(\"end\", end);\n process.stdout.on(\"resize\", resize);\n process.once(\"SIGTERM\", terminate);\n const animationTimer =\n options.header && options.animation && (options.color ?? supportsColor())\n ? setInterval(() => {\n const next = options.header!(++frame)\n .split(\"\\n\")\n .slice(0, headerHeight);\n const updates = next.flatMap((line, position) =>\n line === headerLines[position]\n ? []\n : [`\\u001b[${position + 1};1H\\u001b[2K${line}`],\n );\n\n if (updates.length) {\n process.stdout.write(`\\u001b[s${updates.join(\"\")}\\u001b[u`);\n }\n\n headerLines = next;\n }, 50)\n : undefined;\n resize();\n });\n\n/** Keep the dashboard in one terminal screen and restore the shell on every exit. */\nexport const withScreen = async (\n operation: () => Promise<void>,\n): Promise<void> => {\n const wasRaw = process.stdin.isRaw;\n let restored = false;\n\n const restore = () => {\n if (restored) {\n return;\n }\n\n restored = true;\n\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(wasRaw);\n }\n\n process.stdout.write(\"\\u001b[0m\\u001b[?25h\\u001b[?1049l\");\n };\n\n const interrupt = () => process.exit(130);\n\n const terminate = () => process.exit(143);\n\n process.once(\"exit\", restore);\n process.once(\"SIGINT\", interrupt);\n process.once(\"SIGTERM\", terminate);\n process.stdout.write(\"\\u001b[?1049h\\u001b[H\\u001b[2J\");\n\n try {\n await operation();\n } finally {\n process.off(\"exit\", restore);\n process.off(\"SIGINT\", interrupt);\n process.off(\"SIGTERM\", terminate);\n restore();\n }\n};\n\n/** A scrollable action result in the dashboard's existing screen. */\nexport const view = (\n title: string,\n content: string,\n color: boolean,\n): Promise<void> =>\n new Promise((resolve) => {\n const { style, brand } = theme(color);\n const wasRaw = process.stdin.isRaw;\n let offset = 0;\n let lines: string[] = [];\n let pageSize = 1;\n let finished = false;\n\n const draw = () => {\n pageSize = Math.max(1, (process.stdout.rows || 24) - 5);\n lines = wrapLines(content);\n offset = Math.min(offset, Math.max(0, lines.length - pageSize));\n const page = lines.slice(offset, offset + pageSize);\n const footer = `↑ ↓ scroll · enter / esc back${lines.length > pageSize ? ` · ${offset + 1}–${offset + page.length}/${lines.length}` : \"\"}`;\n process.stdout.write(\n [\n \"\\u001b[H\\u001b[2J\",\n ` ${brand()} ${style(`/ ${title}`, \"muted\")}\\n\\n`,\n page.join(\"\\n\"),\n `\\u001b[${Math.max(1, (process.stdout.rows || 24) - 1)};1H ${style(fitLine(footer), \"muted\")}`,\n ].join(\"\"),\n );\n };\n\n const finish = () => {\n if (finished) {\n return;\n }\n\n finished = true;\n process.stdin.off(\"keypress\", keypress);\n process.stdin.off(\"end\", finish);\n process.stdout.off(\"resize\", draw);\n process.stdin.setRawMode(wasRaw);\n process.stdin.pause();\n process.stdout.write(\"\\u001b[?25h\");\n resolve();\n };\n\n const keypress = (\n _input: string,\n key: { name?: string; ctrl?: boolean },\n ) => {\n if (\n [\"escape\", \"return\"].includes(key.name ?? \"\") ||\n (key.ctrl && key.name === \"c\")\n ) {\n return finish();\n }\n\n if (key.name === \"up\") {\n offset = Math.max(0, offset - 1);\n } else if (key.name === \"down\") {\n offset++;\n } else if (key.name === \"pageup\") {\n offset = Math.max(0, offset - pageSize);\n } else if (key.name === \"pagedown\" || key.name === \"space\") {\n offset += pageSize;\n } else if (key.name === \"home\") {\n offset = 0;\n } else if (key.name === \"end\") {\n offset = lines.length;\n } else {\n return;\n }\n\n draw();\n };\n\n emitKeypressEvents(process.stdin);\n process.stdin.setRawMode(true);\n process.stdin.resume();\n process.stdin.on(\"keypress\", keypress);\n process.stdin.once(\"end\", finish);\n process.stdout.on(\"resize\", draw);\n process.stdout.write(\"\\u001b[?25l\");\n draw();\n });\n\nexport const ask = async (\n question: string,\n color = supportsColor(),\n): Promise<string> => {\n const terminal = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n const { style } = theme(color);\n\n try {\n return (\n await terminal.question(\n ` ${style(\"◆\", \"violet\")} ${style(question, \"strong\")} `,\n )\n ).trim();\n } finally {\n terminal.close();\n }\n};\n\n/** Animate only real work, then erase the transient line before printing its result. */\nexport const withSpinner = async <Result>(\n label: string,\n operation: () => Promise<Result>,\n options: { enabled: boolean; color: boolean; animation: boolean },\n): Promise<Result> => {\n if (\n !options.enabled ||\n !process.stdout.isTTY ||\n process.env.TERM === \"dumb\"\n ) {\n return operation();\n }\n\n const { style } = theme(options.color);\n const frames = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\n const started = performance.now();\n let frame = 0;\n\n const draw = () => {\n const elapsed = `${((performance.now() - started) / 1000).toFixed(1)}s`;\n const line = `${style(options.animation ? frames[frame++ % frames.length]! : \"◇\", frame % 8 < 4 ? \"accent\" : \"violet\")} ${label} ${style(elapsed, \"muted\")}`;\n process.stdout.write(`\\r\\u001b[2K ${fitLine(line)}`);\n };\n\n const restore = () => process.stdout.write(\"\\r\\u001b[2K\\u001b[?25h\");\n\n const interrupt = () => {\n restore();\n process.exit(130);\n };\n\n const terminate = () => {\n restore();\n process.exit(143);\n };\n\n process.once(\"SIGINT\", interrupt);\n process.once(\"SIGTERM\", terminate);\n process.stdout.write(\"\\u001b[?25l\");\n draw();\n const timer = options.animation ? setInterval(draw, 80) : undefined;\n\n try {\n return await operation();\n } finally {\n if (timer) {\n clearInterval(timer);\n }\n\n process.off(\"SIGINT\", interrupt);\n process.off(\"SIGTERM\", terminate);\n restore();\n }\n};\n","/**\n * Data model behind the schema browser: tabs, searchable entries, table matching and SQL highlighting.\n */\nimport type { ColumnSnapshot, SchemaSnapshot, TableSnapshot } from \"symmetria\";\nimport {\n enumerationSQL,\n foreignKeySQL,\n indexSQL,\n tableSQL,\n} from \"../../migrations/ddl\";\nimport { migrationSnapshot } from \"../../migrations/snapshot\";\nimport { theme } from \"../ui/style\";\n\nexport const inspectTabs = [\n \"Columns\",\n \"Relations\",\n \"Indexes\",\n \"Checks\",\n \"SQL\",\n] as const;\nexport type InspectTab = (typeof inspectTabs)[number];\ntype InspectEntry = {\n name: string;\n kind: string;\n badges: string[];\n description: string;\n target?: { table: string; column?: string };\n};\n\nconst defaultLabel = (column: ColumnSnapshot): string | undefined => {\n if (!column.default) {\n return undefined;\n }\n\n if (column.default.kind === \"sql\") {\n return column.default.sql;\n }\n\n return typeof column.default.value === \"bigint\"\n ? String(column.default.value)\n : JSON.stringify(column.default.value, (_name, value) =>\n typeof value === \"bigint\" ? String(value) : value,\n );\n};\n\nexport const inspectEntries = (\n table: TableSnapshot,\n tab: InspectTab,\n): InspectEntry[] => {\n if (tab === \"Columns\") {\n return table.columns.map((column) => {\n const defaultValue = defaultLabel(column);\n const identity =\n column.default?.kind === \"sql\" && column.default.sql === \"identity\";\n\n return {\n name: column.name,\n kind: column.sqlType,\n badges: [\n column.primaryKey || table.primaryKey?.includes(column.sqlName)\n ? \"PK\"\n : \"\",\n column.references ? \"FK\" : \"\",\n column.unique ? \"UNIQUE\" : \"\",\n !column.notNull ? \"NULL\" : \"\",\n identity ? \"AUTO\" : defaultValue === undefined ? \"\" : \"DEFAULT\",\n ].filter(Boolean),\n description: [\n `${table.sqlName}.${column.sqlName} · ${column.sqlType} · ${column.notNull ? \"NOT NULL\" : \"NULLABLE\"}`,\n defaultValue === undefined\n ? \"\"\n : identity\n ? \"GENERATED ALWAYS AS IDENTITY\"\n : `Default: ${defaultValue}`,\n column.enumerationValues\n ? `Values: ${column.enumerationValues.join(\" · \")}`\n : \"\",\n column.references\n ? `→ ${column.references.table}.${column.references.column} · ON DELETE ${column.references.onDelete.toUpperCase()}\\nEnter to follow this foreign key`\n : \"\",\n ]\n .filter(Boolean)\n .join(\"\\n\"),\n ...(column.references\n ? {\n target: {\n table: column.references.table,\n column: column.references.column,\n },\n }\n : {}),\n };\n });\n }\n\n if (tab === \"Relations\") {\n return table.relations.map((relation) => {\n if (relation.kind === \"condition\") {\n const declaring = relation.reverse ? relation.target : table.name;\n\n return {\n name: relation.name,\n kind: relation.many ? \"many\" : \"one\",\n badges: [\"CONDITION\", ...(relation.reverse ? [\"REVERSE\"] : [])],\n description: `${table.name}.${relation.name} → ${relation.target}\\nJoined by the predicate declared in ${declaring}.relations()\\nEnter to open ${relation.target}`,\n target: { table: relation.target },\n };\n }\n\n const column =\n relation.kind === \"through\"\n ? undefined\n : table.columns.find((column) => column.name === relation.foreignKey);\n\n return {\n name: relation.name,\n kind: relation.kind === \"through\" ? \"many ↔ many\" : relation.kind,\n badges:\n relation.kind === \"through\"\n ? [\"JUNCTION\"]\n : relation.reverse\n ? [\"REVERSE\"]\n : relation.nullable\n ? [\"OPTIONAL\"]\n : [],\n description: `${table.name}.${relation.name} → ${relation.target}\\n${relation.kind === \"through\" ? `Through ${relation.junction} (${relation.sourceForeignKey} → ${relation.targetForeignKey})` : `Foreign key: ${relation.reverse ? relation.target : table.name}.${relation.foreignKey}`}\\nEnter to open ${relation.target}`,\n target: {\n table: relation.target,\n ...(relation.kind === \"through\"\n ? {}\n : relation.reverse\n ? { column: relation.foreignKey }\n : column?.references\n ? { column: column.references.column }\n : {}),\n },\n };\n });\n }\n\n if (tab === \"Indexes\") {\n return (table.indexes ?? []).map((index) => ({\n name: index.sqlName,\n kind: index.method,\n badges: index.unique ? [\"UNIQUE\"] : [],\n description: [\n index.sqlName,\n `Keys: ${index.keys.join(\", \")}`,\n index.include.length ? `Include: ${index.include.join(\", \")}` : \"\",\n index.where ? `Where: ${index.where}` : \"\",\n ]\n .filter(Boolean)\n .join(\"\\n\"),\n }));\n }\n\n if (tab === \"Checks\") {\n return (table.checks ?? []).map((check) => ({\n name: check.sqlName,\n kind: \"check\",\n badges: [],\n description: `${check.sqlName}\\nCHECK (${check.expression})`,\n }));\n }\n\n return [];\n};\n\nexport const matchesEntry = (entry: InspectEntry, search: string): boolean =>\n `${entry.name} ${entry.kind} ${entry.description} ${entry.badges.join(\" \")}`\n .toLowerCase()\n .includes(search.toLowerCase());\n\nexport const matchesTableName = (\n table: TableSnapshot,\n search: string,\n): boolean =>\n `${table.name} ${table.sqlName}`.toLowerCase().includes(search.toLowerCase());\n\nexport const matchingTables = (\n snapshot: SchemaSnapshot,\n search: string,\n): TableSnapshot[] =>\n snapshot.tables.filter(\n (table) =>\n matchesTableName(table, search) ||\n inspectTabs.some((tab) =>\n inspectEntries(table, tab).some((entry) => matchesEntry(entry, search)),\n ),\n );\n\n/** Use the migration compiler so the preview includes enums, constraints and indexes. */\nexport const inspectTableSQL = (\n snapshot: SchemaSnapshot,\n table: TableSnapshot,\n): string => {\n const migration = migrationSnapshot(snapshot);\n const definition = migration.tables.find(\n (candidate) => candidate.name === table.sqlName,\n )!;\n const enumerations = new Set(\n definition.columns.flatMap((column) =>\n column.enumeration ? [column.enumeration] : [],\n ),\n );\n\n return [\n ...migration.enumerations\n .filter((enumeration) => enumerations.has(enumeration.name))\n .map((enumeration) =>\n enumerationSQL(enumeration.name, enumeration.values),\n ),\n tableSQL(definition),\n ...definition.columns\n .filter((column) => column.references)\n .map((column) => foreignKeySQL(definition, column)),\n ...definition.indexes.map((index) => indexSQL(definition, index)),\n ]\n .map((statement) => `${statement};`)\n .join(\"\\n\\n\");\n};\n\nconst sqlKeywords = new Set(\n \"CREATE TABLE TYPE AS ENUM ALTER ADD CONSTRAINT PRIMARY KEY FOREIGN REFERENCES ON DELETE UPDATE CASCADE RESTRICT SET NULL NOT DEFAULT GENERATED ALWAYS BY IDENTITY UNIQUE CHECK INDEX USING INCLUDE WHERE ASC DESC AND OR TRUE FALSE IS IN LIKE BETWEEN SELECT FROM NO ACTION MATCH FULL PARTIAL SIMPLE DEFERRABLE INITIALLY DEFERRED IMMEDIATE LEFT RIGHT INNER OUTER CROSS JOIN GROUP ORDER HAVING LIMIT OFFSET DISTINCT EXISTS RETURNING INSERT INTO VALUES CONFLICT DO NOTHING UNION ALL WITH FOR SHARE SKIP LOCKED NOWAIT EXPLAIN ANALYZE BUFFERS FORMAT JSON NULLS FIRST LAST\".split(\n \" \",\n ),\n);\n\nexport const highlightSQL = (sql: string, color: boolean): string => {\n if (!color) {\n return sql;\n }\n\n const { style } = theme(color);\n\n return sql.replace(\n /--[^\\n]*|\\/\\*[\\s\\S]*?\\*\\/|(\\$(?:[a-z_][\\w]*)?\\$)[\\s\\S]*?\\1|\\$\\d+|\\bE'(?:\\\\.|''|[^'])*'|'(?:''|[^'])*'|\"(?:\"\"|[^\"])*\"|\\b\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?\\b|\\b[a-z_][\\w]*\\b/gi,\n (token) => {\n if (token.startsWith(\"--\") || token.startsWith(\"/*\")) {\n return style(token, \"muted\");\n }\n\n if (token.startsWith('\"')) {\n return style(token, \"accent\");\n }\n\n if (/^(?:E?'|\\$)/i.test(token)) {\n return style(token, \"pink\");\n }\n\n if (sqlKeywords.has(token.toUpperCase())) {\n return style(token, \"violet\");\n }\n\n if (/^\\d/.test(token)) {\n return style(token, \"pink\");\n }\n\n return token;\n },\n );\n};\n"],"mappings":";;;;;;;;AAKA,MAAa,sBACX,CAAC,CAAC,QAAQ,OAAO,SACjB,QAAQ,IAAI,aAAa,KAAA,KACzB,QAAQ,IAAI,SAAS;AAEvB,MAAM,gBAAgB;CACpB;EAAC;EAAK;EAAK;CAAG;CACd;EAAC;EAAK;EAAK;CAAG;CACd;EAAC;EAAK;EAAK;CAAG;AAChB;AAEA,MAAM,UAAU;CACd,QAAQ,QAAQ,cAAc,EAAE,CAAC,KAAK,GAAG;CACzC,QAAQ,QAAQ,cAAc,EAAE,CAAC,KAAK,GAAG;CACzC,MAAM,QAAQ,cAAc,EAAE,CAAC,KAAK,GAAG;CACvC,WAAW;CACX,SAAS;CACT,SAAS;CACT,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,UAAU;AACZ;AAEA,MAAa,SAAS,UAAU,cAAc,MAAM;CAClD,MAAM,SAAS,MAAc,SAC3B,UAAU,UAAU,QAAQ,MAAM,GAAG,KAAK,aAAa;CAEzD,OAAO;EACL;EACA,QAAQ,QAAQ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