@nongt/visql 0.8.0 → 0.10.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/README.md +23 -360
- package/dist/{MuiTimePicker-BjywwrRm.js → MuiTimePicker-DRqT6ByZ.js} +1 -1
- package/dist/PipelineEditor-Ch_i6OAc.js +10537 -0
- package/dist/core.js +339 -78
- package/dist/explain.js +356 -0
- package/dist/index.js +119 -100
- package/dist/issueLocation-Y1iaP_Cs.js +1108 -0
- package/dist/mui-date-pickers-host.js +1 -1
- package/dist/mui-date-pickers.js +1 -1
- package/dist/mui.js +95 -84
- package/dist/params-kc6eNrpu.js +2223 -0
- package/dist/{schema-DFC26AhZ.js → schema-KDJ1rpG5.js} +334 -271
- package/dist/sql-import.js +1 -1
- package/dist/sqlGen-Crgheqys.js +903 -0
- package/dist/style.css +1 -1
- package/dist/tokens-DV5rTGMj.js +171 -0
- package/dist/types/core/components/flow/NodeActionFrame.d.ts +20 -0
- package/dist/types/core/components/flow/useNodeActions.d.ts +18 -0
- package/dist/types/core/existsMenu.d.ts +4 -3
- package/dist/types/core/i18n/defaultMessages.d.ts +15 -0
- package/dist/types/core/i18n/messages.d.ts +11 -0
- package/dist/types/core/pipelineFlow.d.ts +1 -1
- package/dist/types/core/planFindings.d.ts +27 -0
- package/dist/types/core/queryHelpers.d.ts +1 -1
- package/dist/types/core/schema.d.ts +68 -24
- package/dist/types/core/scopeQuery.d.ts +2 -2
- package/dist/types/core/theme/appearance.d.ts +27 -0
- package/dist/types/core/theme/looks.d.ts +14 -0
- package/dist/types/core/theme/tokens.d.ts +9 -1
- package/dist/types/core-api.d.ts +2 -1
- package/dist/types/explain/explainQuery.d.ts +59 -0
- package/dist/types/explain/mySqlPlan.d.ts +4 -0
- package/dist/types/explain/planPlaces.d.ts +27 -0
- package/dist/types/explain/postgresPlan.d.ts +4 -0
- package/dist/types/explain/sqlServerPlan.d.ts +4 -0
- package/dist/types/explain/xml.d.ts +7 -0
- package/dist/types/explain.d.ts +2 -0
- package/dist/types/features/queryEditor/CanvasBackground.d.ts +2 -0
- package/dist/types/features/queryEditor/ExplainButton.d.ts +13 -0
- package/dist/types/features/queryEditor/IssuesButton.d.ts +14 -6
- package/dist/types/features/queryEditor/PipelineEditor.d.ts +15 -0
- package/dist/types/features/queryEditor/planText.d.ts +8 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +14 -1
- package/dist/PipelineEditor-DtT1TPgd.js +0 -10214
- package/dist/core-api-jaQDPXVK.js +0 -1171
- package/dist/issueLocation-DEIwB1DW.js +0 -3290
- package/dist/tokens-BTaVMSOx.js +0 -95
package/dist/explain.js
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { y as Y, m as G } from "./schema-KDJ1rpG5.js";
|
|
2
|
+
import { B as V } from "./params-kc6eNrpu.js";
|
|
3
|
+
import { s as Z, b as tt, a as et } from "./sqlGen-Crgheqys.js";
|
|
4
|
+
const C = (t, e) => e.reduce(
|
|
5
|
+
(s, i) => s[i],
|
|
6
|
+
t
|
|
7
|
+
);
|
|
8
|
+
function v(t, e) {
|
|
9
|
+
var i;
|
|
10
|
+
const s = typeof t.tableRows == "function" ? t.tableRows(e) : (i = t.tableRows) == null ? void 0 : i[e];
|
|
11
|
+
return s !== void 0 && s >= 0 ? s : void 0;
|
|
12
|
+
}
|
|
13
|
+
const B = (t) => t.type === "exists" ? [] : Y(t);
|
|
14
|
+
function Q(t, e, s) {
|
|
15
|
+
return t.type === "field" ? t.table === e && s.includes(t.column) : B(t).some((i) => Q(i, e, s));
|
|
16
|
+
}
|
|
17
|
+
function X(t, e, s) {
|
|
18
|
+
return t.type === "field" && t.table === e && s.add(t.column), B(t).forEach((i) => X(i, e, s)), s;
|
|
19
|
+
}
|
|
20
|
+
function $(t, e, s, i) {
|
|
21
|
+
const { where: f } = C(s.named, e.body);
|
|
22
|
+
if (!f) return;
|
|
23
|
+
const l = (o) => e.table && s.resolveName ? s.resolveName(e.table, o) : o, h = [...X(f, t, /* @__PURE__ */ new Set())].filter((o) => i(l(o)));
|
|
24
|
+
if (h.length === 0) return;
|
|
25
|
+
const c = (f.type === "logical" && f.operator === "AND" ? f.operands.map((o, a) => ({ operand: o, path: ["where", "operands", a] })) : [{ operand: f, path: ["where"] }]).filter(({ operand: o }) => Q(o, t, h)), n = c.length === 1 ? c[0].path : ["where"];
|
|
26
|
+
return { columns: h, path: [...e.body, ...n] };
|
|
27
|
+
}
|
|
28
|
+
function L(t, e, s) {
|
|
29
|
+
const i = C(e.named, t.body);
|
|
30
|
+
if (s && (i.groupBy ?? []).length > 0) return [...t.body, "groupBy"];
|
|
31
|
+
if (!s && (i.orderBy ?? []).length > 0) return [...t.body, "orderBy"];
|
|
32
|
+
}
|
|
33
|
+
function k(t) {
|
|
34
|
+
const e = /* @__PURE__ */ new Set();
|
|
35
|
+
return t.filter((s) => {
|
|
36
|
+
const i = `${s.kind}:${JSON.stringify(s.pathSegments)}`;
|
|
37
|
+
return e.has(i) ? !1 : (e.add(i), !0);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const st = ["ALL", "index"], rt = 5, A = (t) => typeof t == "object" && t !== null && !Array.isArray(t), F = (t) => typeof t.table_name == "string" && typeof t.access_type == "string";
|
|
41
|
+
function x(t) {
|
|
42
|
+
const e = typeof t == "string" ? JSON.parse(t) : t;
|
|
43
|
+
if (A(e) && A(e.query_block)) return e;
|
|
44
|
+
const s = Array.isArray(e) ? e[0] : A(e) && e.EXPLAIN;
|
|
45
|
+
if (s) return x(s);
|
|
46
|
+
throw new TypeError("explainQuery: not a MySQL plan from EXPLAIN FORMAT=JSON (explain_json_format_version 1)");
|
|
47
|
+
}
|
|
48
|
+
function j(t, e = []) {
|
|
49
|
+
return Array.isArray(t) ? t.forEach((s) => j(s, e)) : A(t) && (F(t) ? e.push(t) : Object.values(t).forEach((s) => j(s, e))), e;
|
|
50
|
+
}
|
|
51
|
+
const nt = (t, e) => new Set(
|
|
52
|
+
[...t.matchAll(/`((?:[^`]|``)+)`\.(?=`((?:[^`]|``)+)`)/g)].filter((s) => s[1].replace(/``/g, "`") === e).map((s) => s[2].replace(/``/g, "`"))
|
|
53
|
+
);
|
|
54
|
+
function it(t, e) {
|
|
55
|
+
const s = e.minRows ?? 1e4, i = [], f = (r) => {
|
|
56
|
+
const c = e.places.get(r.table_name), n = c == null ? void 0 : c.table;
|
|
57
|
+
if (!c || !n || !st.includes(r.access_type)) return;
|
|
58
|
+
const o = r.rows_examined_per_scan ?? 0;
|
|
59
|
+
if (o < s) return;
|
|
60
|
+
const a = Number(r.filtered ?? 100);
|
|
61
|
+
if (r.attached_condition && a <= rt) {
|
|
62
|
+
const u = nt(r.attached_condition, r.table_name), p = $(r.table_name, c, e, (g) => u.has(g));
|
|
63
|
+
if (p) {
|
|
64
|
+
i.push({
|
|
65
|
+
kind: "missingIndex",
|
|
66
|
+
pathSegments: p.path,
|
|
67
|
+
table: n,
|
|
68
|
+
columns: p.columns,
|
|
69
|
+
rows: o,
|
|
70
|
+
message: `${n} is read whole: no index for ${p.columns.join(", ")}`
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
i.push({
|
|
76
|
+
kind: "fullScan",
|
|
77
|
+
pathSegments: c.path,
|
|
78
|
+
table: n,
|
|
79
|
+
rows: o,
|
|
80
|
+
message: `${n} is read whole`
|
|
81
|
+
});
|
|
82
|
+
}, l = (r, c) => {
|
|
83
|
+
var g;
|
|
84
|
+
if (!r.using_filesort && !r.using_temporary_table) return;
|
|
85
|
+
const n = j(r), o = ((g = n[n.length - 1]) == null ? void 0 : g.rows_produced_per_join) ?? 0;
|
|
86
|
+
if (o < s) return;
|
|
87
|
+
const a = n.map((b) => e.places.get(b.table_name)).find((b) => b !== void 0), u = a && L(a, e, c);
|
|
88
|
+
if (!u) return;
|
|
89
|
+
const p = r.using_filesort ? "sort" : "temporaryTable";
|
|
90
|
+
i.push({
|
|
91
|
+
kind: p,
|
|
92
|
+
pathSegments: u,
|
|
93
|
+
rows: o,
|
|
94
|
+
message: p === "sort" ? `Sorts ${o} rows` : `Puts ${o} rows in a temporary table`
|
|
95
|
+
});
|
|
96
|
+
}, h = (r) => {
|
|
97
|
+
Array.isArray(r) && r.forEach(h), A(r) && (F(r) && f(r), A(r.ordering_operation) && l(r.ordering_operation, !1), A(r.grouping_operation) && l(r.grouping_operation, !0), Object.values(r).forEach(h));
|
|
98
|
+
};
|
|
99
|
+
return h(x(t)), k(i);
|
|
100
|
+
}
|
|
101
|
+
const ot = 0.05, _ = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
|
|
102
|
+
function W(t) {
|
|
103
|
+
let e = typeof t == "string" ? JSON.parse(t) : t;
|
|
104
|
+
if (Array.isArray(e) && ([e] = e), _(e) && "QUERY PLAN" in e) return W(e["QUERY PLAN"]);
|
|
105
|
+
if (_(e) && _(e.Plan)) return e.Plan;
|
|
106
|
+
throw new TypeError("explainQuery: not a PostgreSQL plan from EXPLAIN (FORMAT JSON)");
|
|
107
|
+
}
|
|
108
|
+
const at = (t) => t + Math.max(0, 1 - 0.3 * t), J = (t) => {
|
|
109
|
+
var e;
|
|
110
|
+
return t["Parallel Aware"] === !0 || ((e = t.Plans) == null ? void 0 : e[0]) !== void 0 && J(t.Plans[0]);
|
|
111
|
+
}, ct = (t) => new Set(
|
|
112
|
+
[...t.replace(/'(?:[^']|'')*'/g, " ").matchAll(/"((?:[^"]|"")+)"|([A-Za-z_][\w$]*)/g)].map((e) => (e[1] ?? e[2]).replace(/""/g, '"'))
|
|
113
|
+
);
|
|
114
|
+
function U(t, e) {
|
|
115
|
+
const s = (t["Sort Key"] ?? []).join(" ").match(/\b_qb\d+\b/);
|
|
116
|
+
return s ? e.places.get(s[0]) : t.Alias && e.places.has(t.Alias) ? e.places.get(t.Alias) : (t.Plans ?? []).map((i) => U(i, e)).find(Boolean);
|
|
117
|
+
}
|
|
118
|
+
function lt(t, e) {
|
|
119
|
+
const s = e.minRows ?? 1e4, i = [], f = (r, c) => {
|
|
120
|
+
const n = r.Alias === void 0 ? void 0 : e.places.get(r.Alias);
|
|
121
|
+
if (!n) return;
|
|
122
|
+
const o = r["Relation Name"], a = v(e, o), { table: u } = n;
|
|
123
|
+
if (r.Filter && a !== void 0 && a >= s && c <= a * ot) {
|
|
124
|
+
const g = ct(r.Filter), b = $(r.Alias, n, e, (d) => g.has(d));
|
|
125
|
+
if (b) {
|
|
126
|
+
const { columns: d, path: m } = b;
|
|
127
|
+
i.push({
|
|
128
|
+
kind: "missingIndex",
|
|
129
|
+
pathSegments: m,
|
|
130
|
+
...u !== void 0 && { table: u },
|
|
131
|
+
columns: d,
|
|
132
|
+
rows: a,
|
|
133
|
+
message: `${o} is read whole for ${r.Filter}: no index for ${d.join(", ")}`
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const p = a ?? (r.Filter ? void 0 : c);
|
|
139
|
+
(p ?? c) < s || i.push({
|
|
140
|
+
kind: "fullScan",
|
|
141
|
+
pathSegments: n.path,
|
|
142
|
+
...u !== void 0 && { table: u },
|
|
143
|
+
...p !== void 0 && { rows: p },
|
|
144
|
+
message: `${o} is read whole`
|
|
145
|
+
});
|
|
146
|
+
}, l = (r, c, n) => {
|
|
147
|
+
if (n < s) return;
|
|
148
|
+
const o = U(r, e);
|
|
149
|
+
if (!o) return;
|
|
150
|
+
const a = c !== void 0 && ["Aggregate", "Group", "Unique"].includes(c["Node Type"]), u = L(o, e, a);
|
|
151
|
+
u && i.push({
|
|
152
|
+
kind: "sort",
|
|
153
|
+
pathSegments: u,
|
|
154
|
+
rows: n,
|
|
155
|
+
message: `Sorts ${n} rows on ${(r["Sort Key"] ?? []).join(", ")}`
|
|
156
|
+
});
|
|
157
|
+
}, h = (r, c, n) => {
|
|
158
|
+
const o = Math.round((r["Plan Rows"] ?? 0) * (J(r) ? n : 1));
|
|
159
|
+
r["Node Type"] === "Seq Scan" && f(r, o), (r["Node Type"] === "Sort" || r["Node Type"] === "Incremental Sort") && l(r, c, o);
|
|
160
|
+
const a = r["Workers Planned"];
|
|
161
|
+
(r.Plans ?? []).forEach((u) => h(
|
|
162
|
+
u,
|
|
163
|
+
r,
|
|
164
|
+
a === void 0 ? n : at(a)
|
|
165
|
+
));
|
|
166
|
+
};
|
|
167
|
+
return h(W(t), void 0, 1), k(i);
|
|
168
|
+
}
|
|
169
|
+
const ft = {
|
|
170
|
+
lt: "<",
|
|
171
|
+
gt: ">",
|
|
172
|
+
amp: "&",
|
|
173
|
+
quot: '"',
|
|
174
|
+
apos: "'"
|
|
175
|
+
}, ut = /&(#x[\da-f]+|#\d+|\w+);/gi, pt = (t) => t.replace(ut, (e, s) => {
|
|
176
|
+
if (s[0] !== "#") return ft[s] ?? e;
|
|
177
|
+
const i = s[1] === "x" || s[1] === "X";
|
|
178
|
+
return String.fromCodePoint(i ? parseInt(s.slice(2), 16) : Number(s.slice(1)));
|
|
179
|
+
}), q = (t) => t.slice(t.indexOf(":") + 1), mt = new RegExp([
|
|
180
|
+
/<(\/?)([\w:.-]+)((?:\s+[\w:.-]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>/.source,
|
|
181
|
+
/<!--[\s\S]*?-->/.source,
|
|
182
|
+
/<!\[CDATA\[[\s\S]*?\]\]>/.source,
|
|
183
|
+
/<[?!][^>]*>/.source
|
|
184
|
+
].join("|"), "g"), dt = /([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
|
|
185
|
+
function ht(t) {
|
|
186
|
+
const e = { name: "", attributes: {}, children: [] }, s = [e];
|
|
187
|
+
return [...t.matchAll(mt)].forEach(([, i, f, l, h]) => {
|
|
188
|
+
if (f === void 0) return;
|
|
189
|
+
if (i) {
|
|
190
|
+
s.length > 1 && s.pop();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const r = {
|
|
194
|
+
name: q(f),
|
|
195
|
+
attributes: Object.fromEntries([...l.matchAll(dt)].map(
|
|
196
|
+
([, c, n, o]) => [q(c), pt(n ?? o)]
|
|
197
|
+
)),
|
|
198
|
+
children: []
|
|
199
|
+
};
|
|
200
|
+
s[s.length - 1].children.push(r), h || s.push(r);
|
|
201
|
+
}), e.children[0];
|
|
202
|
+
}
|
|
203
|
+
const bt = ["Table Scan", "Clustered Index Scan", "Index Scan"], S = (t) => t.startsWith("[") ? t.slice(1, -1).replace(/]]/g, "]") : t;
|
|
204
|
+
function z(t) {
|
|
205
|
+
if (typeof t == "string") return t.trimStart().startsWith("<") ? t : void 0;
|
|
206
|
+
if (!(typeof t != "object" || t === null))
|
|
207
|
+
return Object.values(t).map(z).find((e) => e !== void 0);
|
|
208
|
+
}
|
|
209
|
+
const E = (t, e, s = []) => (t.name === e && s.push(t), t.children.forEach((i) => E(i, e, s)), s), N = (t) => t.children.flatMap(
|
|
210
|
+
(e) => e.name === "RelOp" ? [e] : N(e)
|
|
211
|
+
), T = (t, e) => t.children.flatMap((s) => s.children).find((s) => s.name === e), D = (t) => {
|
|
212
|
+
const e = T(t, "OrderBy");
|
|
213
|
+
return e ? E(e, "ColumnReference") : [];
|
|
214
|
+
}, P = (t, e) => {
|
|
215
|
+
const s = t == null ? void 0 : t.attributes[e];
|
|
216
|
+
return s === void 0 ? void 0 : Math.round(Number(s));
|
|
217
|
+
};
|
|
218
|
+
function gt(t) {
|
|
219
|
+
const e = /* @__PURE__ */ new Map();
|
|
220
|
+
return E(t, "MissingIndex").forEach((s) => {
|
|
221
|
+
const i = S(s.attributes.Table), f = e.get(i) ?? /* @__PURE__ */ new Set();
|
|
222
|
+
s.children.filter((l) => l.attributes.Usage !== "INCLUDE").flatMap((l) => E(l, "Column")).forEach((l) => f.add(S(l.attributes.Name))), e.set(i, f);
|
|
223
|
+
}), e;
|
|
224
|
+
}
|
|
225
|
+
function H(t, e) {
|
|
226
|
+
const s = D(t).map((l) => l.attributes.Alias && e.places.get(S(l.attributes.Alias))).find(Boolean);
|
|
227
|
+
if (s) return s;
|
|
228
|
+
const i = T(t, "Object"), f = i == null ? void 0 : i.attributes.Alias;
|
|
229
|
+
return f && e.places.has(S(f)) ? e.places.get(S(f)) : N(t).map((l) => H(l, e)).find(Boolean);
|
|
230
|
+
}
|
|
231
|
+
function yt(t) {
|
|
232
|
+
const e = z(t), s = e === void 0 ? void 0 : ht(e);
|
|
233
|
+
if ((s == null ? void 0 : s.name) !== "ShowPlanXML")
|
|
234
|
+
throw new TypeError("explainQuery: not a SQL Server plan from SET SHOWPLAN_XML");
|
|
235
|
+
return s;
|
|
236
|
+
}
|
|
237
|
+
function wt(t, e) {
|
|
238
|
+
const s = e.minRows ?? 1e4, i = yt(t), f = gt(i), l = [], h = (n) => {
|
|
239
|
+
const o = T(n, "Object"), a = (o == null ? void 0 : o.attributes.Alias) && S(o.attributes.Alias), u = a ? e.places.get(a) : void 0;
|
|
240
|
+
if (!o || !a || !u) return;
|
|
241
|
+
const p = S(o.attributes.Table), g = P(n, "TableCardinality") ?? v(e, p) ?? P(n, "EstimateRows");
|
|
242
|
+
if (g < s) return;
|
|
243
|
+
const { table: b } = u, d = f.get(p), m = T(n, "Predicate"), O = new Set(m && d ? E(m, "ColumnReference").filter((y) => y.attributes.Alias && S(y.attributes.Alias) === a).map((y) => S(y.attributes.Column)).filter((y) => d.has(y)) : []), w = $(a, u, e, (y) => O.has(y));
|
|
244
|
+
if (w) {
|
|
245
|
+
l.push({
|
|
246
|
+
kind: "missingIndex",
|
|
247
|
+
pathSegments: w.path,
|
|
248
|
+
...b !== void 0 && { table: b },
|
|
249
|
+
columns: w.columns,
|
|
250
|
+
rows: g,
|
|
251
|
+
message: `${p} is read whole: no index for ${w.columns.join(", ")}`
|
|
252
|
+
});
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
l.push({
|
|
256
|
+
kind: "fullScan",
|
|
257
|
+
pathSegments: u.path,
|
|
258
|
+
...b !== void 0 && { table: b },
|
|
259
|
+
rows: g,
|
|
260
|
+
message: `${p} is read whole`
|
|
261
|
+
});
|
|
262
|
+
}, r = (n, o) => {
|
|
263
|
+
const a = P(N(n)[0], "EstimateRows") ?? P(n, "EstimateRows") ?? 0;
|
|
264
|
+
if (a < s) return;
|
|
265
|
+
const u = H(n, e);
|
|
266
|
+
if (!u) return;
|
|
267
|
+
const p = L(u, e, (o == null ? void 0 : o.attributes.PhysicalOp) === "Stream Aggregate");
|
|
268
|
+
if (!p) return;
|
|
269
|
+
const g = D(n).map((b) => b.attributes.Column);
|
|
270
|
+
l.push({
|
|
271
|
+
kind: "sort",
|
|
272
|
+
pathSegments: p,
|
|
273
|
+
rows: a,
|
|
274
|
+
message: `Sorts ${a} rows on ${g.join(", ")}`
|
|
275
|
+
});
|
|
276
|
+
}, c = (n, o) => {
|
|
277
|
+
const a = n.attributes.PhysicalOp;
|
|
278
|
+
bt.includes(a) && h(n), a === "Sort" && n.attributes.LogicalOp !== "Distinct Sort" && r(n, o), N(n).forEach((u) => c(u, a === "Parallelism" ? o : n));
|
|
279
|
+
};
|
|
280
|
+
return E(i, "QueryPlan").forEach((n) => N(n).forEach((o) => c(o, void 0))), k(l);
|
|
281
|
+
}
|
|
282
|
+
const I = (t) => Object.prototype.toString.call(t) === "[object Object]", St = (t) => Array.isArray(t.joins) && I(t.from);
|
|
283
|
+
function R(t, e = /* @__PURE__ */ new Set()) {
|
|
284
|
+
return Array.isArray(t) ? t.forEach((s) => R(s, e)) : I(t) && (["table", "alias", "name"].forEach((s) => {
|
|
285
|
+
typeof t[s] == "string" && e.add(t[s]);
|
|
286
|
+
}), Object.values(t).forEach((s) => R(s, e))), e;
|
|
287
|
+
}
|
|
288
|
+
function At(t) {
|
|
289
|
+
const e = R(t), s = /* @__PURE__ */ new Map();
|
|
290
|
+
let i = 0;
|
|
291
|
+
const f = () => {
|
|
292
|
+
do
|
|
293
|
+
i += 1;
|
|
294
|
+
while (e.has(`_qb${i}`));
|
|
295
|
+
return `_qb${i}`;
|
|
296
|
+
}, l = /* @__PURE__ */ new WeakMap(), h = (r, c) => {
|
|
297
|
+
if (Array.isArray(r)) return r.map((d, m) => h(d, [...c, m]));
|
|
298
|
+
if (!I(r)) return r;
|
|
299
|
+
const n = Object.fromEntries(
|
|
300
|
+
Object.entries(r).map(([d, m]) => [d, h(m, [...c, d])])
|
|
301
|
+
), o = n.type === "exists" && l.get(n.query);
|
|
302
|
+
if (o) {
|
|
303
|
+
const d = (m) => m.type === "field" && m.table !== void 0 && o.has(m.table) ? { ...m, table: o.get(m.table) } : G(m, d);
|
|
304
|
+
return { ...n, link: d(n.link) };
|
|
305
|
+
}
|
|
306
|
+
if (!St(n)) return n;
|
|
307
|
+
const a = /* @__PURE__ */ new Map(), u = Array.isArray(n.select);
|
|
308
|
+
let p = u ? n : { ...n, select: [] };
|
|
309
|
+
[p.from, ...p.joins].forEach((d, m) => {
|
|
310
|
+
const O = d.alias ?? d.table;
|
|
311
|
+
if (O === void 0) return;
|
|
312
|
+
const w = f();
|
|
313
|
+
a.set(O, w), s.set(w, {
|
|
314
|
+
path: m === 0 ? [...c, "from"] : [...c, "joins", m - 1],
|
|
315
|
+
body: c,
|
|
316
|
+
...d.table !== void 0 && { table: d.table }
|
|
317
|
+
});
|
|
318
|
+
const y = V(p, O, w);
|
|
319
|
+
p = m === 0 ? { ...y, from: { ...y.from, alias: w } } : {
|
|
320
|
+
...y,
|
|
321
|
+
joins: y.joins.map((M, K) => K === m - 1 ? { ...M, alias: w } : M)
|
|
322
|
+
};
|
|
323
|
+
});
|
|
324
|
+
const b = u ? p : (({ select: d, ...m }) => m)(p);
|
|
325
|
+
return l.set(b, a), b;
|
|
326
|
+
};
|
|
327
|
+
return { named: h(t, []), places: s };
|
|
328
|
+
}
|
|
329
|
+
function Pt(t, e, s = {}) {
|
|
330
|
+
const { scope: i, ...f } = s, { named: l, places: h } = At(t);
|
|
331
|
+
if (i && !f.schema)
|
|
332
|
+
throw new TypeError("explainQuery: `scope` needs `schema`");
|
|
333
|
+
const r = i ? Z(f.schema, l, i) : l, c = {
|
|
334
|
+
postgres: lt,
|
|
335
|
+
mssql: wt,
|
|
336
|
+
mysql: it
|
|
337
|
+
}[e], n = (p, g = {}) => c(p, {
|
|
338
|
+
places: h,
|
|
339
|
+
named: l,
|
|
340
|
+
resolveName: f.resolveName,
|
|
341
|
+
...g
|
|
342
|
+
});
|
|
343
|
+
if (e === "mssql")
|
|
344
|
+
return {
|
|
345
|
+
before: "SET SHOWPLAN_XML ON",
|
|
346
|
+
sql: tt(r, e, f),
|
|
347
|
+
params: [],
|
|
348
|
+
after: "SET SHOWPLAN_XML OFF",
|
|
349
|
+
findings: n
|
|
350
|
+
};
|
|
351
|
+
const { sql: o, params: a } = et(r, e, f);
|
|
352
|
+
return { sql: `${e === "mysql" ? "EXPLAIN FORMAT=JSON" : "EXPLAIN (FORMAT JSON)"} ${o}`, params: a, findings: n };
|
|
353
|
+
}
|
|
354
|
+
export {
|
|
355
|
+
Pt as explainQuery
|
|
356
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { D as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { D as f } from "./PipelineEditor-Ch_i6OAc.js";
|
|
2
|
+
import { P, f as v, a as B } from "./PipelineEditor-Ch_i6OAc.js";
|
|
3
|
+
import { D as R, E as I, M as k, b as C, f as O, a as q, c as H, h as G, i as Y, r as w, s as X, v as J } from "./schema-KDJ1rpG5.js";
|
|
4
|
+
import { D as j, M as V, a as z, b as K, d as Z, e as $, f as ee, g as ae, c as se, h as te, k as re, m as ne, q as oe, r as ie, i as de, s as ce, j as ue, o as le, l as me, n as fe, u as he } from "./params-kc6eNrpu.js";
|
|
5
|
+
import { c as Ee, f as Se, i as Te } from "./calendarDate-CYlr9TvX.js";
|
|
6
|
+
import { Q as Ae, l as Ne, S as _e, a as be, n as De, f as Ue, j as ye, m as Me, b as Qe, k as xe, r as Fe, c as Pe, g as ve, h as Be, i as Le, s as Re, d as Ie, e as ke, v as Ce } from "./issueLocation-Y1iaP_Cs.js";
|
|
7
|
+
import { w as h, a as p, b as E } from "./sqlGen-Crgheqys.js";
|
|
8
|
+
import { D as qe, c as He, S as Ge, s as Ye, u as we } from "./sqlGen-Crgheqys.js";
|
|
9
|
+
import { QUERY_FORMAT_VERSION as Je, QueryFormatError as We, addCondition as je, addGroupBy as Ve, addJoin as ze, addOrderBy as Ke, addSelectItem as Ze, expr as $e, loadQuery as ea, removeJoin as aa, requireBaseTable as sa, saveQuery as ta, setBaseTable as ra, setDistinct as na, setHaving as oa, setPaging as ia } from "./core.js";
|
|
10
|
+
import { D as S, N as T } from "./tokens-DV5rTGMj.js";
|
|
11
|
+
function b(n, s, e = {}) {
|
|
12
|
+
const a = { paths: [] }, t = h(a, () => e.parameterized ? p(n, s, e).sql : E(n, s, e));
|
|
10
13
|
let r = "";
|
|
11
14
|
const c = [], u = [];
|
|
12
15
|
for (let o = 0; o < t.length; o += 1) {
|
|
@@ -15,18 +18,18 @@ function T(n, s, e = {}) {
|
|
|
15
18
|
const d = t.indexOf("", o);
|
|
16
19
|
u.push({ index: Number(t.slice(o + 1, d)), start: r.length }), o = d;
|
|
17
20
|
} else if (i === "") {
|
|
18
|
-
const { index: d, start:
|
|
19
|
-
c.push({ start:
|
|
21
|
+
const { index: d, start: m } = u.pop();
|
|
22
|
+
c.push({ start: m, end: r.length, pathSegments: a.paths[d] });
|
|
20
23
|
} else
|
|
21
24
|
r += i;
|
|
22
25
|
}
|
|
23
26
|
return c.sort((o, i) => o.start - i.start || i.end - o.end || o.pathSegments.length - i.pathSegments.length), { sql: r, spans: c };
|
|
24
27
|
}
|
|
25
|
-
function
|
|
28
|
+
function D(n, s) {
|
|
26
29
|
const e = n.filter((a) => a.start <= s && s < a.end);
|
|
27
30
|
return e[e.length - 1];
|
|
28
31
|
}
|
|
29
|
-
function
|
|
32
|
+
function U(n, s) {
|
|
30
33
|
const e = n.filter((a) => s.every((t, r) => a.pathSegments[r] === t));
|
|
31
34
|
return e.filter((a, t) => !e.slice(0, t).some(
|
|
32
35
|
(r) => r.start <= a.start && a.end <= r.end
|
|
@@ -37,7 +40,7 @@ function l(n) {
|
|
|
37
40
|
for (; s.nextNode(); ) e.push(s.currentNode);
|
|
38
41
|
return e;
|
|
39
42
|
}
|
|
40
|
-
function
|
|
43
|
+
function g(n, s, e) {
|
|
41
44
|
const a = document.createRange();
|
|
42
45
|
let t = 0;
|
|
43
46
|
return l(n).forEach((r) => {
|
|
@@ -45,7 +48,7 @@ function S(n, s, e) {
|
|
|
45
48
|
s >= t && s <= c && a.setStart(r, s - t), e >= t && e <= c && a.setEnd(r, e - t), t = c;
|
|
46
49
|
}), a;
|
|
47
50
|
}
|
|
48
|
-
function
|
|
51
|
+
function y(n, s, e) {
|
|
49
52
|
const a = document.caretPositionFromPoint ? document.caretPositionFromPoint(s, e) : document.caretRangeFromPoint(s, e);
|
|
50
53
|
if (!a) return;
|
|
51
54
|
const [t, r] = "offsetNode" in a ? [a.offsetNode, a.offset] : [a.startContainer, a.startOffset], c = l(n), u = c.indexOf(t);
|
|
@@ -53,93 +56,109 @@ function _(n, s, e) {
|
|
|
53
56
|
const o = c.slice(0, u).reduce((i, d) => i + d.length, 0) + r;
|
|
54
57
|
return [o, o - 1].find((i) => {
|
|
55
58
|
if (i < 0) return !1;
|
|
56
|
-
const d =
|
|
59
|
+
const d = g(n, i, i + 1).getBoundingClientRect();
|
|
57
60
|
return s >= d.left && s <= d.right && e >= d.top && e <= d.bottom;
|
|
58
61
|
});
|
|
59
62
|
}
|
|
63
|
+
const M = { theme: S, appearance: f }, Q = {
|
|
64
|
+
theme: T,
|
|
65
|
+
appearance: {
|
|
66
|
+
edges: "smoothstep",
|
|
67
|
+
background: "lines",
|
|
68
|
+
backgroundGap: 32,
|
|
69
|
+
groupFrame: "bar",
|
|
70
|
+
actions: "hover"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
60
73
|
export {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
re as
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
74
|
+
M as CHARCOAL,
|
|
75
|
+
f as DEFAULT_APPEARANCE,
|
|
76
|
+
R as DEFAULT_FUNCTIONS,
|
|
77
|
+
j as DEFAULT_MESSAGES,
|
|
78
|
+
S as DEFAULT_THEME,
|
|
79
|
+
qe as DIALECTS,
|
|
80
|
+
He as DIALECT_LABELS,
|
|
81
|
+
I as EMPTY_SCHEMA,
|
|
82
|
+
k as MAX_NAME_LENGTH,
|
|
83
|
+
V as MAX_NUMBER_DIGITS,
|
|
84
|
+
z as MAX_TEXT_LENGTH,
|
|
85
|
+
K as MAX_TYPE_NAME_LENGTH,
|
|
86
|
+
Q as NAVY,
|
|
87
|
+
Je as QUERY_FORMAT_VERSION,
|
|
88
|
+
Ae as QUERY_ISSUE_KINDS,
|
|
89
|
+
Ne as QUERY_WARNING_KINDS,
|
|
90
|
+
P as QueryBuilder,
|
|
91
|
+
We as QueryFormatError,
|
|
92
|
+
Ge as ScopeError,
|
|
93
|
+
_e as SharedBaseError,
|
|
94
|
+
je as addCondition,
|
|
95
|
+
Ve as addGroupBy,
|
|
96
|
+
ze as addJoin,
|
|
97
|
+
Z as addMeasure,
|
|
98
|
+
Ke as addOrderBy,
|
|
99
|
+
Ze as addSelectItem,
|
|
100
|
+
be as addSharedQuery,
|
|
101
|
+
$ as addUnionBranch,
|
|
102
|
+
ee as addUnionJoin,
|
|
103
|
+
ae as addUnionTable,
|
|
104
|
+
p as astToParameterizedSql,
|
|
105
|
+
E as astToSql,
|
|
106
|
+
b as astToSqlWithSpans,
|
|
107
|
+
C as branchesOf,
|
|
108
|
+
Ee as calendarDay,
|
|
109
|
+
se as createEmptyQuery,
|
|
110
|
+
te as createUnion,
|
|
111
|
+
$e as expr,
|
|
112
|
+
O as filterSchema,
|
|
113
|
+
q as findJoinPath,
|
|
114
|
+
v as formula,
|
|
115
|
+
B as formulaText,
|
|
116
|
+
Se as fromIsoDay,
|
|
117
|
+
H as functionsForDialect,
|
|
118
|
+
G as hasBaseTable,
|
|
119
|
+
Y as isUnion,
|
|
120
|
+
Te as isoDay,
|
|
121
|
+
De as issueLocation,
|
|
122
|
+
Ue as joinMultiplicity,
|
|
123
|
+
ye as joinSharedQuery,
|
|
124
|
+
re as keepMeasuresInStep,
|
|
125
|
+
ea as loadQuery,
|
|
126
|
+
Me as makeShared,
|
|
127
|
+
Qe as makeSubQuery,
|
|
128
|
+
ne as measureFacts,
|
|
129
|
+
oe as queryParams,
|
|
130
|
+
w as reachableTables,
|
|
131
|
+
xe as relativeDateLabel,
|
|
132
|
+
aa as removeJoin,
|
|
133
|
+
Fe as removeSharedQuery,
|
|
134
|
+
ie as removeUnionTable,
|
|
135
|
+
Pe as renameSharedQuery,
|
|
136
|
+
de as renameUnionColumn,
|
|
137
|
+
ve as repeatedReads,
|
|
138
|
+
Be as repeatedTables,
|
|
139
|
+
sa as requireBaseTable,
|
|
140
|
+
Le as rowsPerBase,
|
|
141
|
+
ta as saveQuery,
|
|
142
|
+
Ye as scopeQuery,
|
|
143
|
+
ra as setBaseTable,
|
|
144
|
+
na as setDistinct,
|
|
145
|
+
oa as setHaving,
|
|
146
|
+
ia as setPaging,
|
|
147
|
+
Re as setSharedBase,
|
|
148
|
+
ce as setUnionAll,
|
|
149
|
+
Ie as sharedQueryName,
|
|
150
|
+
ke as sharedUses,
|
|
151
|
+
D as spanAt,
|
|
152
|
+
U as spansFor,
|
|
153
|
+
y as sqlOffsetAt,
|
|
154
|
+
g as sqlRangeOf,
|
|
155
|
+
X as suggestJoin,
|
|
156
|
+
ue as unionName,
|
|
157
|
+
le as unionTableColumns,
|
|
158
|
+
me as unionWithQuery,
|
|
159
|
+
fe as unionableTables,
|
|
160
|
+
we as unscopedBodies,
|
|
161
|
+
he as unwrapUnion,
|
|
162
|
+
Ce as validateQuery,
|
|
163
|
+
J as validateSchema
|
|
145
164
|
};
|