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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mikhail Demidoff
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 ADDED
@@ -0,0 +1,254 @@
1
+ # symmetria-kit
2
+
3
+ Migration and development tools for the
4
+ [Symmetria](https://www.npmjs.com/package/symmetria) PostgreSQL query builder on
5
+ Node.js 24.11+ or Bun 1.4.4+.
6
+
7
+ ```sh
8
+ bun add symmetria
9
+ bun add -d symmetria-kit
10
+ bunx --package symmetria-kit symmetria init
11
+ ```
12
+
13
+ The package installs the **`symmetria`** command. Run it without arguments in a
14
+ terminal to open the dashboard. Use matching runtime and Kit versions. On
15
+ Node.js, install with npm and run `npx --package symmetria-kit symmetria`. The
16
+ CLI uses Node.js by default; `bunx --bun` selects Bun. Kit includes `pg`. The
17
+ CLI resolves extensionless relative imports in `symmetria.config.ts` on Node;
18
+ application modules that Node runs directly keep their `.ts` extensions.
19
+
20
+ ```ts
21
+ // symmetria.config.ts
22
+ import { defineMigrationConfig } from "symmetria-kit";
23
+ import { appSchema } from "./src/database/schema";
24
+
25
+ export default defineMigrationConfig({
26
+ schema: appSchema,
27
+ directory: "./migrations",
28
+ databaseUrl: process.env.DATABASE_URL,
29
+ });
30
+ ```
31
+
32
+ <picture>
33
+ <source media="(prefers-reduced-motion: reduce)" srcset="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/kit-migrations.png">
34
+ <img src="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/kit-migrations.webp" width="1280" alt="A migration is generated, applied, inspected in the history, then rolled back in an isolated database.">
35
+ </picture>
36
+
37
+ ## Commands
38
+
39
+ | Command | Purpose |
40
+ | ------------------ | ------------------------------------------------------------------- |
41
+ | `init [directory]` | Create missing scaffold files; preserve existing projects |
42
+ | `pull [file]` | Write a schema module for an existing database (default: schema.ts) |
43
+ | `graph [file]` | Print or write a Mermaid entity-relationship diagram |
44
+ | `inspect [table]` | Browse columns, relations (including condition ones), indexes, SQL |
45
+ | `diff` | Compare source schema to the latest local snapshot |
46
+ | `lint` | Check saved SQL and ungenerated changes; fail on unsafe findings |
47
+ | `generate <name>` | Generate migration SQL and metadata |
48
+ | `migrate` | Apply pending migrations atomically |
49
+ | `status` | Show applied/pending migrations |
50
+ | `rollback` | Revert the latest migration |
51
+ | `drift` | Compare the live database with the latest local snapshot |
52
+ | `squash <name>` | Collapse local migration history into a baseline |
53
+ | `adopt` | Adopt a matching baseline without replaying its SQL |
54
+ | `profile` | Browse live request traces and query timings |
55
+ | `verify` | Test installation, upgrades and rollbacks in disposable databases |
56
+ | `repair <id>` | Verify and resolve an incomplete migration |
57
+ | `recover` | Recover files after a crashed generator |
58
+
59
+ Use `--help` for options. `--json` produces machine-readable output;
60
+ `--no-interactive` disables prompts. `diff --sql` prints SQL. Config paths
61
+ resolve relative to the config file. SQL lives in `migrations/<id>/`; metadata
62
+ lives in `migrations/meta/snapshot.json` and `migrations/meta/migration.json`.
63
+ Commit SQL and both JSON files together. `diff` compares snapshots, not live DB
64
+ drift.
65
+
66
+ <picture>
67
+ <source media="(prefers-reduced-motion: reduce)" srcset="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/kit-schema.png">
68
+ <img src="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/kit-schema.webp" width="1280" alt="The schema browser explores tables and relations, follows a foreign key, and previews indexes and DDL.">
69
+ </picture>
70
+
71
+ The snapshot holds the latest generated schema. The journal holds IDs, parents
72
+ and schema hashes for the whole chain, without historical snapshot copies.
73
+ Generation updates the same two files; migrate/rollback only change database
74
+ history and use `up.sql`/`down.sql`. `generate --json` reports the SQL and
75
+ metadata directories.
76
+
77
+ The database journal defaults to `public._symmetria_migrations`.
78
+ `metadataSchema` and `metadataTable` configure its location; migrations create a
79
+ missing journal schema transactionally. Application tables follow the
80
+ connection's `search_path`, and `drift` inspects `current_schema()`
81
+ independently of the journal.
82
+
83
+ ## Schema diagrams
84
+
85
+ `symmetria graph` prints a Mermaid `erDiagram` of the declared schema (or of the
86
+ latest migration snapshot) with keys, nullable columns and relation
87
+ cardinalities; `graph docs/schema.md` writes it inside a `mermaid` fence that
88
+ GitHub renders. `--compact` leaves out column lists; `--json` returns the tables
89
+ and edges; `schemaGraph()` and `renderMermaid()` expose the same
90
+ programmatically.
91
+
92
+ ```mermaid
93
+ erDiagram
94
+ users {
95
+ integer id PK "identity"
96
+ text email UK
97
+ }
98
+ posts {
99
+ integer id PK "identity"
100
+ integer author_id FK
101
+ integer editor_id FK "nullable"
102
+ text title
103
+ }
104
+
105
+ users ||..o{ posts : author
106
+ users |o..o{ posts : editor
107
+ ```
108
+
109
+ ## Adopting an existing database
110
+
111
+ `symmetria pull` reads the connection's `current_schema()` and writes a schema
112
+ module in the Symmetria DSL: tables, columns, defaults, identities, enums,
113
+ foreign keys as relations (including keys to unique columns and columns not
114
+ named `*_id`, through `.by()` and `.column()`), junction tables, primary keys,
115
+ unique columns, indexes (including expression, partial, `INCLUDE` and non-btree
116
+ indexes) and CHECK constraints.
117
+
118
+ ```sh
119
+ symmetria pull src/database/schema.ts --database-url "$DATABASE_URL"
120
+ ```
121
+
122
+ Everything the DSL cannot express is kept as close as possible and listed for
123
+ review: constraints with non-conventional names (with the `RENAME CONSTRAINT`
124
+ that fixes them), serial columns, `GENERATED BY DEFAULT` identities, types
125
+ without a builder such as `money` (declared through `customType()`), enums
126
+ shared by several columns, multi-column unique constraints (declared as unique
127
+ indexes), composite or deferrable foreign keys and indexes with operator
128
+ classes. The same list is in `--json` output under `warnings`, each with a
129
+ `code` and, when one exists, a `fix`. The file is never overwritten without
130
+ `--force`.
131
+
132
+ Then point `symmetria.config.ts` at the module, run `drift` until the remaining
133
+ findings are intended, generate the first migration with `generate initial` and
134
+ record it on the existing database with `adopt`.
135
+
136
+ <picture>
137
+ <source media="(prefers-reduced-motion: reduce)" srcset="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/migration-safety.png">
138
+ <img src="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/migration-safety.gif" width="1280" alt="Generation rejects an implicit rename, an explicit rename keeps the row, and lint detects a saved DROP COLUMN.">
139
+ </picture>
140
+
141
+ ## Deployment controls
142
+
143
+ - `generate` requires explicit rename hints or `--allow-destructive` for dropped
144
+ tables/columns. Declared column order is preserved; snapshot hashes are
145
+ order-independent.
146
+ - `lint` checks actual `up.sql` even after generation and fails for destructive
147
+ or blocking findings. `--strict` also fails for cautionary findings;
148
+ `--pending` selects unapplied migrations using database history.
149
+ - `migrate --plan --json` shows SQL and transaction groups. `batch` is the
150
+ atomic default; `generate --transaction each|none` opts into other boundaries.
151
+ - `--online` generates concurrent indexes, phased constraint validation and
152
+ additive enum changes with commit boundaries. Incomplete nontransactional work
153
+ persists in the journal and requires explicit `repair`.
154
+ - DDL lock, statement and advisory-lock timeouts are configurable.
155
+ SIGINT/SIGTERM cancel CLI work; the API accepts an abort signal and
156
+ statement-level events.
157
+ - `drift` checks defaults, identities, PK/FK/UNIQUE/CHECK definitions, FK
158
+ actions, enums, indexes and validation state. `adopt` verifies the live schema
159
+ before rewriting history.
160
+ - `verify --verify-url "$VERIFY_DATABASE_URL"` uses real disposable PostgreSQL
161
+ databases; the connection needs `CREATEDB`. Config/API hooks add
162
+ representative rows and assert data invariants during upgrade, rollback and
163
+ reapplication.
164
+
165
+ <picture>
166
+ <source media="(prefers-reduced-motion: reduce)" srcset="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/migration-verification.png">
167
+ <img src="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/migration-verification.gif" width="1280" alt="Verification asserts that an existing user survives upgrade and rollback; drift detects a removed default; adoption succeeds once reconciled.">
168
+ </picture>
169
+
170
+ <picture>
171
+ <source media="(prefers-reduced-motion: reduce)" srcset="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/migration-recovery.png">
172
+ <img src="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/migration-recovery.gif" width="1280" alt="A concurrent unique index fails on duplicates, the migration stays incomplete, and a verified repair permits the retry.">
173
+ </picture>
174
+
175
+ See the
176
+ [migration reference](https://github.com/nokturnal3301/symmetria/blob/main/docs/reference.md#execution-modes-timeouts-and-plans)
177
+ for timeout defaults, historical verification, online workflows and recovery.
178
+
179
+ ## Profiling and inspection
180
+
181
+ Enable `createProfiler()` in the application, pass it to
182
+ `postgres({ url, profiler })`, wrap the request handler with
183
+ `profiler.fetch(handler)`, and call `await profiler.serve()`.
184
+ `symmetria profile` connects to `http://127.0.0.1:7331`; `--profile-url`
185
+ overrides it. Enter opens a request/query, `e` estimates a plan, `a` explicitly
186
+ runs ANALYZE, Escape goes back and `q` exits.
187
+
188
+ The loopback endpoint checks Host and browser origin and requires the server's
189
+ token on every request. Export `SYMMETRIA_PROFILE_TOKEN` for both the
190
+ application and the CLI, or pass `--profile-token` with the value returned by
191
+ `profiler.serve()`.
192
+
193
+ The runtime's `query.inspect()` loads this package for its interactive SQL,
194
+ Parameters, Results and Explain tabs. Neither inspector analyzes a query unless
195
+ requested. Offline SQL inspection works without a database.
196
+
197
+ <picture>
198
+ <source media="(prefers-reduced-motion: reduce)" srcset="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/profiler.png">
199
+ <img src="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/profiler.webp" width="1280" alt="The live profiler opens a request, shows its SQL and timings, and explains a query plan.">
200
+ </picture>
201
+
202
+ <picture>
203
+ <source media="(prefers-reduced-motion: reduce)" srcset="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/query-inspector.png">
204
+ <img src="https://raw.githubusercontent.com/nokturnal3301/symmetria/main/docs/assets/query-inspector.webp" width="1280" alt="The query inspector: generated SQL, bound parameters, nested results and PostgreSQL EXPLAIN plans.">
205
+ </picture>
206
+
207
+ ## Programmatic migrations
208
+
209
+ Exports: `defineMigrationConfig`, `migrationSnapshot`, `parseMigrationSnapshot`,
210
+ `snapshotHash`, `emptySnapshot`, `createSchemaSQL`, `diffSchemas`,
211
+ `generateMigration`, `loadMigrations`, `loadMigrationState`, `squashMigrations`,
212
+ `lintMigration`, `lintMigrationSQL`, `detectDrift`, `verifyMigrations`,
213
+ `recoverMigrationFiles`, `pullSchema`, their formatting helpers, and `migrator`
214
+ with their associated types. `pullSchema({ execute })` returns the generated
215
+ source, the declared tables and the review warnings without touching the file
216
+ system. `loadMigrationState` returns `{ migrations, snapshot }`; only the
217
+ current schema snapshot is stored. Generated and squashed migrations include
218
+ their new snapshot.
219
+
220
+ ```ts
221
+ import { postgres } from "symmetria/driver";
222
+ import { migrator } from "symmetria-kit";
223
+
224
+ const driver = postgres({ url: process.env.DATABASE_URL! });
225
+
226
+ try {
227
+ await migrator({ driver, directory: "./migrations" }).migrate();
228
+ } finally {
229
+ await driver.close();
230
+ }
231
+ ```
232
+
233
+ ## Isolated test databases
234
+
235
+ `symmetria-kit/testing` creates a unique PostgreSQL schema, creates the declared
236
+ tables and returns a typed database. Closing it drops that schema and its data.
237
+
238
+ ```ts
239
+ import { testDatabase } from "symmetria-kit/testing";
240
+ import { appSchema } from "./src/database/schema";
241
+
242
+ const fixture = await testDatabase({
243
+ url: process.env.SYMMETRIA_TEST_DATABASE_URL!,
244
+ schema: appSchema,
245
+ });
246
+
247
+ try {
248
+ await fixture.database.users((user) => ({ id: user.id }));
249
+ } finally {
250
+ await fixture.close();
251
+ }
252
+ ```
253
+
254
+ [MIT](https://opensource.org/license/mit).
@@ -0,0 +1,7 @@
1
+ import { QueryInspectionController } from "symmetria/internal";
2
+ //#region src/cli/screens/query-inspector.d.ts
3
+ export declare const inspectValue: (value: unknown, expanded?: boolean) => string;
4
+ export declare const explainLines: (plan: readonly Record<string, unknown>[]) => string[];
5
+ export declare const inspectQueryScreen: (inspection: QueryInspectionController, color?: boolean) => Promise<void>;
6
+ //#endregion
7
+ //# sourceMappingURL=query-inspect.d.ts.map
@@ -0,0 +1,283 @@
1
+ import { _ as supportsColor, b as wrapLines, d as withScreen, p as fitLine, t as highlightSQL, y as theme } from "../schema-browser-data-BVymL_xf.js";
2
+ import stringWidth from "string-width";
3
+ import { emitKeypressEvents } from "node:readline";
4
+ import { inspect, stripVTControlCharacters } from "node:util";
5
+ //#region src/cli/screens/query-inspector.ts
6
+ /**
7
+ * Query inspector (`symmetria-kit/inspect`): shows compiled SQL, parameters, decoded rows and EXPLAIN output
8
+ * for a query value, both as a one-off dump and as an interactive screen.
9
+ */
10
+ const tabs = [
11
+ "SQL",
12
+ "Parameters",
13
+ "Results",
14
+ "Explain"
15
+ ];
16
+ const terminalText = (text) => stripVTControlCharacters(text).replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "");
17
+ const inspectValue = (value, expanded = false) => terminalText(inspect(value, {
18
+ colors: false,
19
+ depth: expanded ? null : 5,
20
+ compact: !expanded,
21
+ breakLength: expanded ? 72 : Infinity,
22
+ maxArrayLength: expanded ? null : 20,
23
+ customInspect: false,
24
+ getters: false
25
+ }));
26
+ const explainLines = (plan) => {
27
+ const lines = [];
28
+ const visit = (node, prefix, branch) => {
29
+ const label = [
30
+ node["Node Type"],
31
+ node["Relation Name"],
32
+ node["Index Name"] ? `using ${node["Index Name"]}` : void 0
33
+ ].filter(Boolean).join(" ");
34
+ const actual = node["Actual Total Time"] === void 0 ? "" : ` · actual ${node["Actual Total Time"]} ms × ${node["Actual Loops"] ?? 1}`;
35
+ lines.push(`${prefix}${branch}${label} · rows ${node["Plan Rows"] ?? "?"} · cost ${node["Total Cost"] ?? "?"}${actual}`);
36
+ const continuation = prefix + (branch === "├─ " ? "│ " : branch ? " " : "");
37
+ for (const name of [
38
+ "Index Cond",
39
+ "Hash Cond",
40
+ "Merge Cond",
41
+ "Join Filter",
42
+ "Filter",
43
+ "Sort Key",
44
+ "Group Key",
45
+ "Rows Removed by Filter",
46
+ "Shared Hit Blocks",
47
+ "Shared Read Blocks"
48
+ ]) if (node[name] !== void 0) lines.push(`${continuation} ${name}: ${Array.isArray(node[name]) ? node[name].join(", ") : String(node[name])}`);
49
+ const children = Array.isArray(node.Plans) ? node.Plans : [];
50
+ children.forEach((child, index) => {
51
+ if (child && typeof child === "object") visit(child, continuation, index === children.length - 1 ? "╰─ " : "├─ ");
52
+ });
53
+ };
54
+ for (const entry of plan) {
55
+ if (entry.Plan && typeof entry.Plan === "object") visit(entry.Plan, "", "");
56
+ for (const name of ["Planning Time", "Execution Time"]) if (entry[name] !== void 0) lines.push(`${name}: ${entry[name]} ms`);
57
+ }
58
+ return lines.length ? lines.map(terminalText) : [inspectValue(plan, true)];
59
+ };
60
+ const inspectQueryScreen = async (inspection, color = supportsColor()) => {
61
+ if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("symmetria: interactive query inspection requires a terminal");
62
+ let pending;
63
+ await withScreen(() => new Promise((resolve, reject) => {
64
+ const { style, brand } = theme(color);
65
+ const { report } = inspection;
66
+ const errors = /* @__PURE__ */ new Map();
67
+ let tab = "SQL";
68
+ let busy;
69
+ let offset = 0;
70
+ let columnOffset = 0;
71
+ let expanded = false;
72
+ let detailOffset = 0;
73
+ let pageSize = 1;
74
+ let maximum = 0;
75
+ let finished = false;
76
+ let previousLines = [];
77
+ const wasRaw = process.stdin.isRaw;
78
+ const wasFlowing = process.stdin.readableFlowing === true;
79
+ const align = (line, width) => {
80
+ const clipped = fitLine(line, width);
81
+ return clipped + " ".repeat(Math.max(0, width - stringWidth(clipped)));
82
+ };
83
+ const load = (force = false, analyze = false) => {
84
+ if (finished || busy || tab !== "Results" && tab !== "Explain") return;
85
+ const requested = tab;
86
+ if (!inspection.connected) {
87
+ errors.set(tab, "Configure a query executor or driver to use this tab.");
88
+ return draw();
89
+ }
90
+ if (!force && (tab === "Results" ? report.results : report.explanation) || !force && errors.has(tab)) return;
91
+ errors.delete(tab);
92
+ busy = tab;
93
+ draw();
94
+ pending = (requested === "Results" ? inspection.execute() : inspection.explain(analyze)).catch((error) => {
95
+ errors.set(requested, error instanceof Error ? error.message : String(error));
96
+ }).finally(() => {
97
+ busy = void 0;
98
+ if (finished) return;
99
+ draw();
100
+ if (tab !== requested) load();
101
+ });
102
+ };
103
+ const render = () => {
104
+ const width = Math.max(1, Math.min(process.stdout.columns || 88, 160) - 4);
105
+ const height = process.stdout.rows || 24;
106
+ if (width < 32 || height < 12) return [
107
+ " symmetria / query",
108
+ fitLine(" Enlarge terminal to inspect", width),
109
+ " Esc to close"
110
+ ].map((line) => fitLine(line, width));
111
+ const innerWidth = width - 4;
112
+ pageSize = height - 9;
113
+ let body = [];
114
+ let status = "";
115
+ let lines = [];
116
+ const error = errors.get(tab);
117
+ if (error) lines = wrapLines(style(terminalText(error), "danger"), innerWidth);
118
+ else if (busy === tab) lines = [style(`Running ${tab === "Results" ? "query" : "EXPLAIN"}…`, "pink")];
119
+ else if (tab === "SQL") lines = wrapLines(highlightSQL(terminalText(report.sql), color), innerWidth - 5).map((line, index) => `${style(String(index + 1).padStart(3), "muted")} ${line}`);
120
+ else if (tab === "Parameters") {
121
+ lines = report.parameters.flatMap((value, index) => [
122
+ style(`$${index + 1} ${value === null ? "null" : value instanceof Date ? "Date" : Array.isArray(value) ? "array" : typeof value}`, "violet"),
123
+ ...wrapLines(inspectValue(value, true), innerWidth).map((line) => style(line, "text")),
124
+ ""
125
+ ]);
126
+ if (!lines.length) lines = [style("No bound parameters", "muted")];
127
+ } else if (tab === "Explain") {
128
+ lines = report.explanation ? wrapLines(expanded ? inspectValue(report.explanation.plan, true) : explainLines(report.explanation.plan).join("\n"), innerWidth) : ["No plan loaded"];
129
+ if (report.explanation) status = `${report.explanation.analyzed ? "ANALYZE · actual execution" : "Estimated plan"} · ${report.explanation.durationMs.toFixed(2)} ms`;
130
+ } else if (report.results) {
131
+ const rows = report.results.rows;
132
+ offset = Math.max(0, Math.min(offset, rows.length - 1));
133
+ status = `${rows.length} rows · ${report.results.durationMs.toFixed(2)} ms including decoding`;
134
+ if (!rows.length) lines = [style("Query returned no rows", "muted")];
135
+ else if (expanded) {
136
+ lines = wrapLines(inspectValue(rows[offset], true), innerWidth);
137
+ status = `Row ${offset + 1}/${rows.length} · ${status}`;
138
+ } else {
139
+ const columns = Object.keys(rows[0]);
140
+ columnOffset = Math.max(0, Math.min(columnOffset, columns.length - 1));
141
+ const visible = [];
142
+ let remaining = innerWidth - 2;
143
+ for (const name of columns.slice(columnOffset)) {
144
+ const preferred = Math.min(30, Math.max(10, stringWidth(name), ...rows.slice(offset, offset + pageSize).map((row) => stringWidth(inspectValue(row[name])))));
145
+ if (visible.length && remaining < Math.min(preferred, 12)) break;
146
+ const size = Math.min(preferred, remaining);
147
+ visible.push({
148
+ name,
149
+ width: size
150
+ });
151
+ remaining -= size + 2;
152
+ if (remaining < 1) break;
153
+ }
154
+ const rowLine = (row, header = false) => visible.map(({ name, width }) => align(header ? name : inspectValue(row[name]), width)).join(" ");
155
+ const available = pageSize - 2;
156
+ const start = Math.max(0, Math.min(offset - available + 1, rows.length - available));
157
+ body = [
158
+ style(` ${rowLine({}, true)}`, "accent"),
159
+ style("─".repeat(innerWidth), "border"),
160
+ ...rows.slice(start, start + available).map((row, index) => {
161
+ const line = `${start + index === offset ? "›" : " "} ${rowLine(row)}`;
162
+ return start + index === offset ? style(align(line, innerWidth), "selected") : line;
163
+ })
164
+ ];
165
+ maximum = Math.max(0, rows.length - 1);
166
+ status = `Row ${offset + 1}/${rows.length} · columns ${columnOffset + 1}–${columnOffset + visible.length}/${columns.length} · ${report.results.durationMs.toFixed(2)} ms`;
167
+ }
168
+ }
169
+ if (!body.length) {
170
+ maximum = Math.max(0, lines.length - pageSize);
171
+ if (expanded && tab === "Results") detailOffset = Math.min(detailOffset, maximum);
172
+ else offset = Math.min(offset, maximum);
173
+ const start = expanded && tab === "Results" ? detailOffset : offset;
174
+ body = lines.slice(start, start + pageSize);
175
+ if (!status) status = `${tab} · ${lines.length} lines`;
176
+ }
177
+ while (body.length < pageSize) body.push("");
178
+ const labels = tabs.map((name, index) => style(tab === name ? `[${index + 1} ${name}]` : `${index + 1} ${name}`, tab === name ? "pink" : "muted")).join(" ");
179
+ const tabLine = stringWidth(labels) <= width ? labels : `${style(`‹ ${tab} ›`, "pink")} ${style(`${tabs.indexOf(tab) + 1}/4`, "muted")}`;
180
+ const hint = width >= 100 ? `←→ tabs · ${tab === "Results" ? "↑↓ rows · h/l columns · Enter details · r run again" : tab === "Explain" ? "↑↓ scroll · Enter JSON · a analyze · r estimate" : "↑↓ scroll · PgUp/PgDn page"} · Esc close` : width >= 64 ? `←→ tabs · ${tab === "Results" ? "↑↓ rows · h/l cols · Enter expand" : tab === "Explain" ? "↑↓ scroll · a analyze · Enter JSON" : "↑↓ scroll · PgUp/PgDn"} · Esc close` : "←→ tabs · ↑↓ scroll · Esc close";
181
+ return [
182
+ ` ${brand()} ${style("/ query inspector", "muted")}`,
183
+ ` ${style("●", inspection.connected ? "connected" : "muted")} ${style(`${inspection.connected ? "Executor ready" : "Offline"} · SQL ${report.compileMs.toFixed(3)} ms · ${report.parameters.length} parameters`, "muted")}`,
184
+ "",
185
+ ` ${tabLine}`,
186
+ ` ${style(`╭${"─".repeat(width - 2)}╮`, "border")}`,
187
+ ...body.map((line) => ` ${style("│", "border")} ${align(line, innerWidth)} ${style("│", "border")}`),
188
+ ` ${style(`╰${"─".repeat(width - 2)}╯`, "border")}`,
189
+ ` ${style(fitLine(status || `${tab} · ready`, width), "violet")}`,
190
+ ` ${style(fitLine(hint, width), "muted")}`
191
+ ].map((line) => fitLine(line, width + 2));
192
+ };
193
+ const draw = () => {
194
+ if (finished) return;
195
+ try {
196
+ const lines = render();
197
+ const changes = lines.flatMap((line, index) => line === previousLines[index] ? [] : [`\u001b[${index + 1};1H\u001b[2K${line}`]);
198
+ for (let index = lines.length; index < previousLines.length; index++) changes.push(`\u001b[${index + 1};1H\u001b[2K`);
199
+ process.stdout.write(changes.join(""));
200
+ previousLines = lines;
201
+ } catch (error) {
202
+ finish(error);
203
+ }
204
+ };
205
+ const resize = () => {
206
+ previousLines = [];
207
+ process.stdout.write("\x1B[H\x1B[2J");
208
+ draw();
209
+ };
210
+ const finish = (error) => {
211
+ if (finished) return;
212
+ finished = true;
213
+ process.stdin.off("keypress", keypress);
214
+ process.stdin.off("end", end);
215
+ process.stdout.off("resize", resize);
216
+ process.stdin.setRawMode(wasRaw);
217
+ if (!wasFlowing) process.stdin.pause();
218
+ if (error) reject(error);
219
+ else resolve();
220
+ };
221
+ const end = () => finish();
222
+ const keypress = (input, key) => {
223
+ if (key.ctrl && ["c", "d"].includes(key.name ?? "") || key.name === "escape" || input === "q") return finish();
224
+ if ([
225
+ "left",
226
+ "right",
227
+ "tab"
228
+ ].includes(key.name ?? "") || /^[1-4]$/.test(input)) {
229
+ tab = tabs[/^[1-4]$/.test(input) ? Number(input) - 1 : (tabs.indexOf(tab) + (key.name === "left" || key.name === "tab" && key.shift ? -1 : 1) + tabs.length) % tabs.length];
230
+ offset = 0;
231
+ detailOffset = 0;
232
+ expanded = false;
233
+ draw();
234
+ load();
235
+ return;
236
+ }
237
+ if (input === "r") {
238
+ offset = 0;
239
+ detailOffset = 0;
240
+ load(true);
241
+ return;
242
+ }
243
+ if (input === "a" && tab === "Explain") {
244
+ offset = 0;
245
+ load(true, true);
246
+ return;
247
+ }
248
+ if (key.name === "return" && ["Results", "Explain"].includes(tab)) {
249
+ expanded = !expanded;
250
+ detailOffset = 0;
251
+ if (tab === "Explain") offset = 0;
252
+ } else if ((input === "h" || input === "l") && tab === "Results" && !expanded) columnOffset += input === "h" ? -1 : 1;
253
+ else if ([
254
+ "up",
255
+ "down",
256
+ "pageup",
257
+ "pagedown",
258
+ "home",
259
+ "end"
260
+ ].includes(key.name ?? "")) {
261
+ const current = expanded && tab === "Results" ? detailOffset : offset;
262
+ const amount = key.name === "up" ? -1 : key.name === "down" ? 1 : key.name === "pageup" ? -pageSize : pageSize;
263
+ const next = Math.max(0, Math.min(maximum, key.name === "home" ? 0 : key.name === "end" ? maximum : current + amount));
264
+ if (expanded && tab === "Results") detailOffset = next;
265
+ else offset = next;
266
+ } else return;
267
+ draw();
268
+ };
269
+ emitKeypressEvents(process.stdin);
270
+ process.stdin.setRawMode(true);
271
+ process.stdin.resume();
272
+ process.stdin.on("keypress", keypress);
273
+ process.stdin.once("end", end);
274
+ process.stdout.on("resize", resize);
275
+ process.stdout.write("\x1B[?25l");
276
+ resize();
277
+ }));
278
+ await pending;
279
+ };
280
+ //#endregion
281
+ export { explainLines, inspectQueryScreen, inspectValue };
282
+
283
+ //# sourceMappingURL=query-inspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-inspect.js","names":[],"sources":["../../src/cli/screens/query-inspector.ts"],"sourcesContent":["/**\n * Query inspector (`symmetria-kit/inspect`): shows compiled SQL, parameters, decoded rows and EXPLAIN output\n * for a query value, both as a one-off dump and as an interactive screen.\n */\nimport stringWidth from \"string-width\";\nimport { emitKeypressEvents } from \"node:readline\";\nimport { inspect, stripVTControlCharacters } from \"node:util\";\nimport type { QueryInspectionController } from \"symmetria/internal\";\nimport { highlightSQL } from \"./schema-browser-data\";\nimport { fitLine, supportsColor, theme, wrapLines } from \"../ui/style\";\nimport { withScreen } from \"../ui/terminal\";\n\nconst tabs = [\"SQL\", \"Parameters\", \"Results\", \"Explain\"] as const;\ntype Tab = (typeof tabs)[number];\n\nconst terminalText = (text: string): string =>\n stripVTControlCharacters(text).replace(/[\\x00-\\x08\\x0b-\\x1f\\x7f]/g, \"\");\n\nexport const inspectValue = (value: unknown, expanded = false): string =>\n terminalText(\n inspect(value, {\n colors: false,\n depth: expanded ? null : 5,\n compact: !expanded,\n breakLength: expanded ? 72 : Infinity,\n maxArrayLength: expanded ? null : 20,\n customInspect: false,\n getters: false,\n }),\n );\n\nexport const explainLines = (\n plan: readonly Record<string, unknown>[],\n): string[] => {\n const lines: string[] = [];\n\n const visit = (\n node: Record<string, unknown>,\n prefix: string,\n branch: string,\n ) => {\n const label = [\n node[\"Node Type\"],\n node[\"Relation Name\"],\n node[\"Index Name\"] ? `using ${node[\"Index Name\"]}` : undefined,\n ]\n .filter(Boolean)\n .join(\" \");\n const actual =\n node[\"Actual Total Time\"] === undefined\n ? \"\"\n : ` · actual ${node[\"Actual Total Time\"]} ms × ${node[\"Actual Loops\"] ?? 1}`;\n lines.push(\n `${prefix}${branch}${label} · rows ${node[\"Plan Rows\"] ?? \"?\"} · cost ${node[\"Total Cost\"] ?? \"?\"}${actual}`,\n );\n const continuation =\n prefix + (branch === \"├─ \" ? \"│ \" : branch ? \" \" : \"\");\n\n for (const name of [\n \"Index Cond\",\n \"Hash Cond\",\n \"Merge Cond\",\n \"Join Filter\",\n \"Filter\",\n \"Sort Key\",\n \"Group Key\",\n \"Rows Removed by Filter\",\n \"Shared Hit Blocks\",\n \"Shared Read Blocks\",\n ]) {\n if (node[name] !== undefined) {\n lines.push(\n `${continuation} ${name}: ${Array.isArray(node[name]) ? node[name].join(\", \") : String(node[name])}`,\n );\n }\n }\n\n const children = Array.isArray(node.Plans) ? node.Plans : [];\n children.forEach((child, index) => {\n if (child && typeof child === \"object\") {\n visit(\n child,\n continuation,\n index === children.length - 1 ? \"╰─ \" : \"├─ \",\n );\n }\n });\n };\n\n for (const entry of plan) {\n if (entry.Plan && typeof entry.Plan === \"object\") {\n visit(entry.Plan as Record<string, unknown>, \"\", \"\");\n }\n\n for (const name of [\"Planning Time\", \"Execution Time\"]) {\n if (entry[name] !== undefined) {\n lines.push(`${name}: ${entry[name]} ms`);\n }\n }\n }\n\n return lines.length ? lines.map(terminalText) : [inspectValue(plan, true)];\n};\n\nexport const inspectQueryScreen = async (\n inspection: QueryInspectionController,\n color = supportsColor(),\n): Promise<void> => {\n if (!process.stdin.isTTY || !process.stdout.isTTY) {\n throw new Error(\n \"symmetria: interactive query inspection requires a terminal\",\n );\n }\n\n let pending: Promise<void> | undefined;\n await withScreen(\n () =>\n new Promise<void>((resolve, reject) => {\n const { style, brand } = theme(color);\n const { report } = inspection;\n const errors = new Map<Tab, string>();\n let tab: Tab = \"SQL\";\n let busy: Tab | undefined;\n let offset = 0;\n let columnOffset = 0;\n let expanded = false;\n let detailOffset = 0;\n let pageSize = 1;\n let maximum = 0;\n let finished = false;\n let previousLines: string[] = [];\n const wasRaw = process.stdin.isRaw;\n const wasFlowing = process.stdin.readableFlowing === true;\n\n const align = (line: string, width: number) => {\n const clipped = fitLine(line, width);\n\n return (\n clipped + \" \".repeat(Math.max(0, width - stringWidth(clipped)))\n );\n };\n\n const load = (force = false, analyze = false) => {\n if (finished || busy || (tab !== \"Results\" && tab !== \"Explain\")) {\n return;\n }\n\n const requested = tab;\n\n if (!inspection.connected) {\n errors.set(\n tab,\n \"Configure a query executor or driver to use this tab.\",\n );\n\n return draw();\n }\n\n if (\n (!force &&\n (tab === \"Results\" ? report.results : report.explanation)) ||\n (!force && errors.has(tab))\n ) {\n return;\n }\n\n errors.delete(tab);\n busy = tab;\n draw();\n pending = (\n requested === \"Results\"\n ? inspection.execute()\n : inspection.explain(analyze)\n )\n .catch((error: unknown) => {\n errors.set(\n requested,\n error instanceof Error ? error.message : String(error),\n );\n })\n .finally(() => {\n busy = undefined;\n\n if (finished) {\n return;\n }\n\n draw();\n\n if (tab !== requested) {\n load();\n }\n });\n };\n\n const render = (): string[] => {\n const width = Math.max(\n 1,\n Math.min(process.stdout.columns || 88, 160) - 4,\n );\n const height = process.stdout.rows || 24;\n\n if (width < 32 || height < 12) {\n return [\n \" symmetria / query\",\n fitLine(\" Enlarge terminal to inspect\", width),\n \" Esc to close\",\n ].map((line) => fitLine(line, width));\n }\n\n const innerWidth = width - 4;\n pageSize = height - 9;\n let body: string[] = [];\n let status = \"\";\n let lines: string[] = [];\n const error = errors.get(tab);\n\n if (error) {\n lines = wrapLines(style(terminalText(error), \"danger\"), innerWidth);\n } else if (busy === tab) {\n lines = [\n style(\n `Running ${tab === \"Results\" ? \"query\" : \"EXPLAIN\"}…`,\n \"pink\",\n ),\n ];\n } else if (tab === \"SQL\") {\n lines = wrapLines(\n highlightSQL(terminalText(report.sql), color),\n innerWidth - 5,\n ).map(\n (line, index) =>\n `${style(String(index + 1).padStart(3), \"muted\")} ${line}`,\n );\n } else if (tab === \"Parameters\") {\n lines = report.parameters.flatMap((value, index) => [\n style(\n `$${index + 1} ${value === null ? \"null\" : value instanceof Date ? \"Date\" : Array.isArray(value) ? \"array\" : typeof value}`,\n \"violet\",\n ),\n ...wrapLines(inspectValue(value, true), innerWidth).map((line) =>\n style(line, \"text\"),\n ),\n \"\",\n ]);\n\n if (!lines.length) {\n lines = [style(\"No bound parameters\", \"muted\")];\n }\n } else if (tab === \"Explain\") {\n lines = report.explanation\n ? wrapLines(\n expanded\n ? inspectValue(report.explanation.plan, true)\n : explainLines(report.explanation.plan).join(\"\\n\"),\n innerWidth,\n )\n : [\"No plan loaded\"];\n\n if (report.explanation) {\n status = `${report.explanation.analyzed ? \"ANALYZE · actual execution\" : \"Estimated plan\"} · ${report.explanation.durationMs.toFixed(2)} ms`;\n }\n } else if (report.results) {\n const rows = report.results.rows;\n offset = Math.max(0, Math.min(offset, rows.length - 1));\n status = `${rows.length} rows · ${report.results.durationMs.toFixed(2)} ms including decoding`;\n\n if (!rows.length) {\n lines = [style(\"Query returned no rows\", \"muted\")];\n } else if (expanded) {\n lines = wrapLines(inspectValue(rows[offset], true), innerWidth);\n status = `Row ${offset + 1}/${rows.length} · ${status}`;\n } else {\n const columns = Object.keys(rows[0]!);\n columnOffset = Math.max(\n 0,\n Math.min(columnOffset, columns.length - 1),\n );\n const visible: { name: string; width: number }[] = [];\n let remaining = innerWidth - 2;\n\n for (const name of columns.slice(columnOffset)) {\n const preferred = Math.min(\n 30,\n Math.max(\n 10,\n stringWidth(name),\n ...rows\n .slice(offset, offset + pageSize)\n .map((row) => stringWidth(inspectValue(row[name]))),\n ),\n );\n\n if (visible.length && remaining < Math.min(preferred, 12)) {\n break;\n }\n\n const size = Math.min(preferred, remaining);\n visible.push({ name, width: size });\n remaining -= size + 2;\n\n if (remaining < 1) {\n break;\n }\n }\n\n const rowLine = (row: Record<string, unknown>, header = false) =>\n visible\n .map(({ name, width }) =>\n align(header ? name : inspectValue(row[name]), width),\n )\n .join(\" \");\n\n const available = pageSize - 2;\n const start = Math.max(\n 0,\n Math.min(offset - available + 1, rows.length - available),\n );\n body = [\n style(` ${rowLine({}, true)}`, \"accent\"),\n style(\"─\".repeat(innerWidth), \"border\"),\n ...rows.slice(start, start + available).map((row, index) => {\n const line = `${start + index === offset ? \"›\" : \" \"} ${rowLine(row)}`;\n\n return start + index === offset\n ? style(align(line, innerWidth), \"selected\")\n : line;\n }),\n ];\n maximum = Math.max(0, rows.length - 1);\n status = `Row ${offset + 1}/${rows.length} · columns ${columnOffset + 1}–${columnOffset + visible.length}/${columns.length} · ${report.results.durationMs.toFixed(2)} ms`;\n }\n }\n\n if (!body.length) {\n maximum = Math.max(0, lines.length - pageSize);\n\n if (expanded && tab === \"Results\") {\n detailOffset = Math.min(detailOffset, maximum);\n } else {\n offset = Math.min(offset, maximum);\n }\n\n const start = expanded && tab === \"Results\" ? detailOffset : offset;\n body = lines.slice(start, start + pageSize);\n\n if (!status) {\n status = `${tab} · ${lines.length} lines`;\n }\n }\n\n while (body.length < pageSize) {\n body.push(\"\");\n }\n\n const labels = tabs\n .map((name, index) =>\n style(\n tab === name\n ? `[${index + 1} ${name}]`\n : `${index + 1} ${name}`,\n tab === name ? \"pink\" : \"muted\",\n ),\n )\n .join(\" \");\n const tabLine =\n stringWidth(labels) <= width\n ? labels\n : `${style(`‹ ${tab} ›`, \"pink\")} ${style(`${tabs.indexOf(tab) + 1}/4`, \"muted\")}`;\n const hints =\n tab === \"Results\"\n ? \"↑↓ rows · h/l columns · Enter details · r run again\"\n : tab === \"Explain\"\n ? \"↑↓ scroll · Enter JSON · a analyze · r estimate\"\n : \"↑↓ scroll · PgUp/PgDn page\";\n const hint =\n width >= 100\n ? `←→ tabs · ${hints} · Esc close`\n : width >= 64\n ? `←→ tabs · ${tab === \"Results\" ? \"↑↓ rows · h/l cols · Enter expand\" : tab === \"Explain\" ? \"↑↓ scroll · a analyze · Enter JSON\" : \"↑↓ scroll · PgUp/PgDn\"} · Esc close`\n : \"←→ tabs · ↑↓ scroll · Esc close\";\n\n return [\n ` ${brand()} ${style(\"/ query inspector\", \"muted\")}`,\n ` ${style(\"●\", inspection.connected ? \"connected\" : \"muted\")} ${style(`${inspection.connected ? \"Executor ready\" : \"Offline\"} · SQL ${report.compileMs.toFixed(3)} ms · ${report.parameters.length} parameters`, \"muted\")}`,\n \"\",\n ` ${tabLine}`,\n ` ${style(`╭${\"─\".repeat(width - 2)}╮`, \"border\")}`,\n ...body.map(\n (line) =>\n ` ${style(\"│\", \"border\")} ${align(line, innerWidth)} ${style(\"│\", \"border\")}`,\n ),\n ` ${style(`╰${\"─\".repeat(width - 2)}╯`, \"border\")}`,\n ` ${style(fitLine(status || `${tab} · ready`, width), \"violet\")}`,\n ` ${style(fitLine(hint, width), \"muted\")}`,\n ].map((line) => fitLine(line, width + 2));\n };\n\n const draw = () => {\n if (finished) {\n return;\n }\n\n try {\n const lines = render();\n const changes = lines.flatMap((line, index) =>\n line === previousLines[index]\n ? []\n : [`\\u001b[${index + 1};1H\\u001b[2K${line}`],\n );\n\n for (\n let index = lines.length;\n index < previousLines.length;\n index++\n ) {\n changes.push(`\\u001b[${index + 1};1H\\u001b[2K`);\n }\n\n process.stdout.write(changes.join(\"\"));\n previousLines = lines;\n } catch (error) {\n finish(error);\n }\n };\n\n const resize = () => {\n previousLines = [];\n process.stdout.write(\"\\u001b[H\\u001b[2J\");\n draw();\n };\n\n const finish = (error?: unknown) => {\n if (finished) {\n return;\n }\n\n finished = true;\n process.stdin.off(\"keypress\", keypress);\n process.stdin.off(\"end\", end);\n process.stdout.off(\"resize\", resize);\n process.stdin.setRawMode(wasRaw);\n\n if (!wasFlowing) {\n process.stdin.pause();\n }\n\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n };\n\n const end = () => finish();\n\n const keypress = (\n input: string,\n key: { name?: string; ctrl?: boolean; shift?: boolean },\n ) => {\n if (\n (key.ctrl && [\"c\", \"d\"].includes(key.name ?? \"\")) ||\n key.name === \"escape\" ||\n input === \"q\"\n ) {\n return finish();\n }\n\n if (\n [\"left\", \"right\", \"tab\"].includes(key.name ?? \"\") ||\n /^[1-4]$/.test(input)\n ) {\n tab =\n tabs[\n /^[1-4]$/.test(input)\n ? Number(input) - 1\n : (tabs.indexOf(tab) +\n (key.name === \"left\" || (key.name === \"tab\" && key.shift)\n ? -1\n : 1) +\n tabs.length) %\n tabs.length\n ]!;\n offset = 0;\n detailOffset = 0;\n expanded = false;\n draw();\n load();\n\n return;\n }\n\n if (input === \"r\") {\n offset = 0;\n detailOffset = 0;\n load(true);\n\n return;\n }\n\n if (input === \"a\" && tab === \"Explain\") {\n offset = 0;\n load(true, true);\n\n return;\n }\n\n if (key.name === \"return\" && [\"Results\", \"Explain\"].includes(tab)) {\n expanded = !expanded;\n detailOffset = 0;\n\n if (tab === \"Explain\") {\n offset = 0;\n }\n } else if (\n (input === \"h\" || input === \"l\") &&\n tab === \"Results\" &&\n !expanded\n ) {\n columnOffset += input === \"h\" ? -1 : 1;\n } else if (\n [\"up\", \"down\", \"pageup\", \"pagedown\", \"home\", \"end\"].includes(\n key.name ?? \"\",\n )\n ) {\n const current =\n expanded && tab === \"Results\" ? detailOffset : offset;\n const amount =\n key.name === \"up\"\n ? -1\n : key.name === \"down\"\n ? 1\n : key.name === \"pageup\"\n ? -pageSize\n : pageSize;\n const next = Math.max(\n 0,\n Math.min(\n maximum,\n key.name === \"home\"\n ? 0\n : key.name === \"end\"\n ? maximum\n : current + amount,\n ),\n );\n\n if (expanded && tab === \"Results\") {\n detailOffset = next;\n } else {\n offset = next;\n }\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\", end);\n process.stdout.on(\"resize\", resize);\n process.stdout.write(\"\\u001b[?25l\");\n resize();\n }),\n );\n // Keep a surrounding transaction alive until an already-started request finishes.\n await pending;\n};\n"],"mappings":";;;;;;;;;AAYA,MAAM,OAAO;CAAC;CAAO;CAAc;CAAW;AAAS;AAGvD,MAAM,gBAAgB,SACpB,yBAAyB,IAAI,CAAC,CAAC,QAAQ,6BAA6B,EAAE;AAExE,MAAa,gBAAgB,OAAgB,WAAW,UACtD,aACE,QAAQ,OAAO;CACb,QAAQ;CACR,OAAO,WAAW,OAAO;CACzB,SAAS,CAAC;CACV,aAAa,WAAW,KAAK;CAC7B,gBAAgB,WAAW,OAAO;CAClC,eAAe;CACf,SAAS;AACX,CAAC,CACH;AAEF,MAAa,gBACX,SACa;CACb,MAAM,QAAkB,CAAC;CAEzB,MAAM,SACJ,MACA,QACA,WACG;EACH,MAAM,QAAQ;GACZ,KAAK;GACL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