@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.
Files changed (48) hide show
  1. package/README.md +23 -360
  2. package/dist/{MuiTimePicker-BjywwrRm.js → MuiTimePicker-DRqT6ByZ.js} +1 -1
  3. package/dist/PipelineEditor-Ch_i6OAc.js +10537 -0
  4. package/dist/core.js +339 -78
  5. package/dist/explain.js +356 -0
  6. package/dist/index.js +119 -100
  7. package/dist/issueLocation-Y1iaP_Cs.js +1108 -0
  8. package/dist/mui-date-pickers-host.js +1 -1
  9. package/dist/mui-date-pickers.js +1 -1
  10. package/dist/mui.js +95 -84
  11. package/dist/params-kc6eNrpu.js +2223 -0
  12. package/dist/{schema-DFC26AhZ.js → schema-KDJ1rpG5.js} +334 -271
  13. package/dist/sql-import.js +1 -1
  14. package/dist/sqlGen-Crgheqys.js +903 -0
  15. package/dist/style.css +1 -1
  16. package/dist/tokens-DV5rTGMj.js +171 -0
  17. package/dist/types/core/components/flow/NodeActionFrame.d.ts +20 -0
  18. package/dist/types/core/components/flow/useNodeActions.d.ts +18 -0
  19. package/dist/types/core/existsMenu.d.ts +4 -3
  20. package/dist/types/core/i18n/defaultMessages.d.ts +15 -0
  21. package/dist/types/core/i18n/messages.d.ts +11 -0
  22. package/dist/types/core/pipelineFlow.d.ts +1 -1
  23. package/dist/types/core/planFindings.d.ts +27 -0
  24. package/dist/types/core/queryHelpers.d.ts +1 -1
  25. package/dist/types/core/schema.d.ts +68 -24
  26. package/dist/types/core/scopeQuery.d.ts +2 -2
  27. package/dist/types/core/theme/appearance.d.ts +27 -0
  28. package/dist/types/core/theme/looks.d.ts +14 -0
  29. package/dist/types/core/theme/tokens.d.ts +9 -1
  30. package/dist/types/core-api.d.ts +2 -1
  31. package/dist/types/explain/explainQuery.d.ts +59 -0
  32. package/dist/types/explain/mySqlPlan.d.ts +4 -0
  33. package/dist/types/explain/planPlaces.d.ts +27 -0
  34. package/dist/types/explain/postgresPlan.d.ts +4 -0
  35. package/dist/types/explain/sqlServerPlan.d.ts +4 -0
  36. package/dist/types/explain/xml.d.ts +7 -0
  37. package/dist/types/explain.d.ts +2 -0
  38. package/dist/types/features/queryEditor/CanvasBackground.d.ts +2 -0
  39. package/dist/types/features/queryEditor/ExplainButton.d.ts +13 -0
  40. package/dist/types/features/queryEditor/IssuesButton.d.ts +14 -6
  41. package/dist/types/features/queryEditor/PipelineEditor.d.ts +15 -0
  42. package/dist/types/features/queryEditor/planText.d.ts +8 -0
  43. package/dist/types/index.d.ts +2 -0
  44. package/package.json +14 -1
  45. package/dist/PipelineEditor-DtT1TPgd.js +0 -10214
  46. package/dist/core-api-jaQDPXVK.js +0 -1171
  47. package/dist/issueLocation-DEIwB1DW.js +0 -3290
  48. package/dist/tokens-BTaVMSOx.js +0 -95
package/dist/core.js CHANGED
@@ -1,80 +1,341 @@
1
- import { D as e, E as r, M as o, b as n, f as i, a as d, h as t, i as u, v as l } from "./schema-DFC26AhZ.js";
2
- import { M as m, a as E, b as T, Q as y, I as c, S as h, d as p, p as Q, e as _, f as U, g as b, c as A, h as M, K as N, B as D, q as I, k as B, t as f, v, m as L, G as C, H as R, w as F, r as G, x as q, i as x, C as H, E as P, F as g, y as k, s as O, z as X, A as Y, j, o as J, l as w, n as K, u as z, J as W } from "./issueLocation-DEIwB1DW.js";
3
- import { c as Z, f as $, i as aa } from "./calendarDate-CYlr9TvX.js";
4
- import { D as ea, q as ra, Q as oa, n as na, S as ia, c as da, d as ta, e as ua, f as la, g as Sa, a as ma, b as Ea, h as Ta, o as ya, r as ca, i as ha, p as pa, s as Qa, j as _a, k as Ua, l as ba, m as Aa, u as Ma } from "./core-api-jaQDPXVK.js";
1
+ var N = Object.defineProperty;
2
+ var I = (e, t, r) => t in e ? N(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var E = (e, t, r) => I(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { l as T, q as A, t as B, h as O } from "./schema-KDJ1rpG5.js";
5
+ import { D as le, E as pe, M as ce, b as de, f as ye, a as fe, c as me, i as he, r as be, s as Se, v as we } from "./schema-KDJ1rpG5.js";
6
+ import { au as D, t as L, av as Q, F as M, $ as U, p as d, al as _, aw as i, ah as j } from "./params-kc6eNrpu.js";
7
+ import { M as Ee, a as Te, b as ve, d as Ne, e as Ie, f as Ae, g as Be, c as Oe, h as De, k as Le, m as Qe, q as Me, r as Ue, i as _e, s as je, j as qe, o as xe, l as Ce, n as Re, u as $e } from "./params-kc6eNrpu.js";
8
+ import { c as Ge, f as Je, i as Fe } from "./calendarDate-CYlr9TvX.js";
9
+ import { Q as He, l as Xe, S as Ye, a as We, n as Ke, f as Ve, j as ze, m as Ze, b as et, k as tt, r as rt, c as at, g as nt, h as st, i as it, s as ot, d as ut, e as lt, v as pt } from "./issueLocation-Y1iaP_Cs.js";
10
+ import { D as dt, c as yt, S as ft, a as mt, b as ht, s as bt, u as St } from "./sqlGen-Crgheqys.js";
11
+ const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), v = {
12
+ /** A column: `expr.field('orders', 'status')`. */
13
+ field: (e, t) => ({ type: "field", table: e, column: t }),
14
+ /** A literal value, written into the SQL (as a bound parameter by
15
+ * astToParameterizedSql). `''` is marked as the empty text (see
16
+ * LiteralNode's `empty`), since code means it. */
17
+ value: (e) => e === "" ? { type: "literal", value: e, empty: !0 } : { type: "literal", value: e },
18
+ /** A named value the application supplies when generating the SQL
19
+ * (astToParameterizedSql's `values`). With `relative`, a date relative
20
+ * to when the query runs, which the application computes (issue 140):
21
+ * `expr.param('sale_from', { relative: { unit: 'day', offset: -30 } })`. */
22
+ param: (e, t = {}) => t.relative ? { type: "param", name: e, relative: t.relative } : { type: "param", name: e },
23
+ /** `left <operator> right`. */
24
+ compare: (e, t, r) => ({
25
+ type: "binary",
26
+ operator: t,
27
+ left: e,
28
+ right: r
29
+ }),
30
+ /** `operand IS NULL`. */
31
+ isNull: (e) => ({
32
+ type: "binary",
33
+ operator: "IS NULL",
34
+ left: e
35
+ }),
36
+ /** `operand IS NOT NULL`. */
37
+ isNotNull: (e) => ({
38
+ type: "binary",
39
+ operator: "IS NOT NULL",
40
+ left: e
41
+ }),
42
+ /** `left = right`. */
43
+ eq: (e, t) => ({
44
+ type: "binary",
45
+ operator: "=",
46
+ left: e,
47
+ right: t
48
+ }),
49
+ and: (...e) => ({
50
+ type: "logical",
51
+ operator: "AND",
52
+ operands: e
53
+ }),
54
+ or: (...e) => ({
55
+ type: "logical",
56
+ operator: "OR",
57
+ operands: e
58
+ }),
59
+ not: (e) => ({ type: "not", operand: e }),
60
+ /** A function call: `expr.fn('LOWER', expr.field('users', 'email'))`. */
61
+ fn: (e, ...t) => ({
62
+ type: "function",
63
+ name: e,
64
+ args: t
65
+ }),
66
+ /** Whether the outer row has related rows: `EXISTS (SELECT 1 FROM …
67
+ * WHERE <link> AND <where>)`. `link` matches them to the outer row;
68
+ * `where` names the subquery's own tables only. NOT EXISTS:
69
+ * `expr.not(expr.exists(…))`. */
70
+ exists: (e, t) => ({ type: "exists", query: { joins: [], ...e }, link: t }),
71
+ /** `left IN (…)`: the values (`[1, 2, 3]`, or a list of expressions
72
+ * such as params: `expr.list(…)`), or a sub query (`expr.subquery`).
73
+ * NOT IN: `expr.not(expr.in(…))`. */
74
+ in: (e, t) => ({
75
+ type: "binary",
76
+ operator: "IN",
77
+ left: e,
78
+ right: Array.isArray(t) ? v.list(...t) : t
79
+ }),
80
+ /** `left BETWEEN low AND high` (issue 169), both bounds included: each a
81
+ * value or an expression (a param, a relative date). NOT BETWEEN:
82
+ * `expr.not(expr.between(…))`. */
83
+ between: (e, t, r) => ({
84
+ type: "binary",
85
+ operator: "BETWEEN",
86
+ left: e,
87
+ right: v.list(t, r)
88
+ }),
89
+ /** IN's values: each a value (`expr.list(1, 2)`) or an expression
90
+ * (`expr.list(expr.param('a'), expr.param('b'))`). */
91
+ list: (...e) => ({
92
+ type: "list",
93
+ items: e.map((t) => q(t) ? t : { type: "literal", value: t })
94
+ }),
95
+ /** A query of its own for IN to compare with, selecting `select` — one
96
+ * column. Its tables are its own: it sees nothing of the query around
97
+ * it. `expr.in(expr.field('customer', 'id'), expr.subquery({ from: {
98
+ * table: 'sale_transaction' }, select: expr.field('sale_transaction',
99
+ * 'customer_id') }))`. */
100
+ subquery: ({ select: e, ...t }) => ({
101
+ type: "subquery",
102
+ id: T(),
103
+ query: { joins: [], ...t, select: [{ id: T(), expression: e }] }
104
+ })
105
+ };
106
+ function W(e, t, r) {
107
+ return i(e, t, { type: "setBaseTable", table: r });
108
+ }
109
+ function K(e, t, r, a = {}) {
110
+ const n = { type: "addJoin", table: r, ...a };
111
+ return i(e, t, n);
112
+ }
113
+ function V(e, t, r) {
114
+ return i(e, t, { type: "removeJoin", joinId: r });
115
+ }
116
+ function x(e, t, r, a = {}) {
117
+ const n = D(t), s = L(r);
118
+ if (n && s.some((l) => l !== n.alias)) {
119
+ if (s.includes(n.alias))
120
+ throw new Error("addCondition: a condition names both the union and tables of its branches: add it in two parts");
121
+ return n.query.union.forEach((l) => {
122
+ const m = l.from.table, h = new Set(A(l).map(B)), b = Q(e, m), w = s.find((g) => !h.has(g) && !b.has(g));
123
+ if (w)
124
+ throw new Error(`addCondition: "${w}" can't be reached from "${m}", one of the union's tables: a condition must reach every branch`);
125
+ }), n.query.union.reduce((l, m, h) => M(
126
+ l,
127
+ [U(n.id, h)],
128
+ (b) => x(e, b, r, a)
129
+ ), t);
130
+ }
131
+ const u = a.operator ?? "AND", { where: o } = t;
132
+ let y;
133
+ return o ? o.type === "logical" && o.operator === u ? y = { ...o, operands: [...o.operands, r] } : y = { type: "logical", operator: u, operands: [o, r] } : y = r, d(e, t, _(e, t, y));
134
+ }
135
+ function z(e, t, r, a) {
136
+ const n = i(e, t, { type: "addSelectItem" }), s = n.select[n.select.length - 1].id, u = i(e, n, {
137
+ type: "setSelectExpression",
138
+ selectId: s,
139
+ expression: r
140
+ }), o = a === void 0 ? u : i(e, u, { type: "setSelectAlias", selectId: s, alias: a });
141
+ return d(e, t, o);
142
+ }
143
+ function Z(e, t, r) {
144
+ const a = i(e, t, { type: "addGroupByItem" }), { id: n } = a.groupBy[a.groupBy.length - 1], s = i(e, a, {
145
+ type: "setGroupByExpression",
146
+ groupById: n,
147
+ expression: r
148
+ });
149
+ return d(e, t, s);
150
+ }
151
+ function ee(e, t, r) {
152
+ return d(e, t, j(e, t, r));
153
+ }
154
+ function te(e, t, r, a = "asc") {
155
+ const n = i(e, t, { type: "addOrderByItem" }), { id: s } = n.orderBy[n.orderBy.length - 1], u = i(e, n, {
156
+ type: "setOrderByExpression",
157
+ orderById: s,
158
+ expression: r
159
+ }), o = i(e, u, {
160
+ type: "setOrderByDirection",
161
+ orderById: s,
162
+ direction: a
163
+ });
164
+ return d(e, t, o);
165
+ }
166
+ function re(e, t, r) {
167
+ let a = t;
168
+ return "limit" in r && (a = i(e, a, { type: "setLimit", limit: r.limit })), "offset" in r && (a = i(e, a, { type: "setOffset", offset: r.offset })), a;
169
+ }
170
+ function ae(e, t, r) {
171
+ return i(e, t, { type: "setDistinct", distinct: r });
172
+ }
173
+ function ne(e) {
174
+ if (!O(e)) throw new Error(`query "${e.id}" has no base table yet`);
175
+ return e;
176
+ }
177
+ const S = 4;
178
+ class p extends Error {
179
+ constructor(r, a) {
180
+ super(a);
181
+ E(this, "kind");
182
+ this.name = "QueryFormatError", this.kind = r;
183
+ }
184
+ }
185
+ const c = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
186
+ function C(e) {
187
+ const t = [];
188
+ let r = 0;
189
+ for (; r < e.length; ) {
190
+ for (; e[r] === " "; ) r += 1;
191
+ if (e[r] === "'") {
192
+ let a = "";
193
+ for (r += 1; r < e.length && !(e[r] === "'" && e[r + 1] !== "'"); )
194
+ a += e[r], r += e[r] === "'" ? 2 : 1;
195
+ t.push(a);
196
+ const n = e.indexOf(",", r);
197
+ r = n === -1 ? e.length : n + 1;
198
+ } else {
199
+ const a = e.indexOf(",", r), n = e.slice(r, a === -1 ? void 0 : a).trim();
200
+ n !== "" && t.push(/^-?\d+(\.\d+)?$/.test(n) ? Number(n) : n), r = a === -1 ? e.length : a + 1;
201
+ }
202
+ }
203
+ return t;
204
+ }
205
+ function R(e) {
206
+ const t = (r) => {
207
+ if (Array.isArray(r)) return r.map(t);
208
+ if (!c(r)) return r;
209
+ const a = Object.fromEntries(Object.entries(r).map(([u, o]) => [u, t(o)])), { right: n } = a;
210
+ if (a.type !== "binary" || a.operator !== "IN" || !c(n) || n.type === "subquery" || n.type === "list") return a;
211
+ const s = n.type === "literal" && typeof n.value == "string" ? C(n.value).map((u) => ({ type: "literal", value: u })) : [n];
212
+ return { ...a, right: { type: "list", items: s } };
213
+ };
214
+ return t(e);
215
+ }
216
+ const $ = (e) => e, k = (e) => e, G = [R, $, k];
217
+ function J(e, t, r) {
218
+ return r.slice(t - 1).reduce((a, n) => n(a), e);
219
+ }
220
+ function f(e, t) {
221
+ return Array.isArray(e) ? e.map((r) => f(r, t)) : c(e) ? e.type === "literal" ? t(e) : Object.fromEntries(Object.entries(e).map(([r, a]) => [r, f(a, t)])) : e;
222
+ }
223
+ function F(e) {
224
+ return e.value instanceof Date ? { ...e, value: e.value.toISOString(), valueType: "date" } : typeof e.value == "bigint" ? { ...e, value: String(e.value), valueType: "bigint" } : e;
225
+ }
226
+ function P(e) {
227
+ if (e.valueType === void 0) return e;
228
+ const { valueType: t, ...r } = e, a = String(r.value);
229
+ let n;
230
+ if (t === "date") {
231
+ if (n = new Date(a), Number.isNaN(n.getTime()))
232
+ throw new p("invalid", `not a date: ${JSON.stringify(a)}`);
233
+ } else if (t === "bigint" && /^-?\d+$/.test(a))
234
+ n = BigInt(a);
235
+ else {
236
+ const s = String(t);
237
+ throw new p("invalid", `can't read a ${s} from ${JSON.stringify(a)}`);
238
+ }
239
+ return { ...r, value: n };
240
+ }
241
+ function se(e) {
242
+ return {
243
+ version: S,
244
+ query: f(e, F)
245
+ };
246
+ }
247
+ function ie(e) {
248
+ if (!c(e))
249
+ throw new p("invalid", "a stored query is an object");
250
+ const { version: t } = e;
251
+ if (typeof t != "number" || !Number.isInteger(t) || t < 1)
252
+ throw new p("invalid", "a stored query has a whole-number version from 1");
253
+ if (t > S)
254
+ throw new p(
255
+ "newerVersion",
256
+ `stored in format ${t}; this version reads up to ${S}`
257
+ );
258
+ const r = J(e.query, t, G);
259
+ if (!c(r) || typeof r.id != "string")
260
+ throw new p("invalid", "a stored query has a query with a string id");
261
+ return f(r, P);
262
+ }
5
263
  export {
6
- e as DEFAULT_FUNCTIONS,
7
- ea as DIALECTS,
8
- ra as DIALECT_LABELS,
9
- r as EMPTY_SCHEMA,
10
- o as MAX_NAME_LENGTH,
11
- m as MAX_NUMBER_DIGITS,
12
- E as MAX_TEXT_LENGTH,
13
- T as MAX_TYPE_NAME_LENGTH,
14
- oa as QUERY_FORMAT_VERSION,
15
- y as QUERY_ISSUE_KINDS,
16
- c as QUERY_WARNING_KINDS,
17
- na as QueryFormatError,
18
- ia as ScopeError,
19
- h as SharedBaseError,
20
- da as addCondition,
21
- ta as addGroupBy,
22
- ua as addJoin,
23
- p as addMeasure,
24
- la as addOrderBy,
25
- Sa as addSelectItem,
26
- Q as addSharedQuery,
27
- _ as addUnionBranch,
28
- U as addUnionJoin,
29
- b as addUnionTable,
30
- ma as astToParameterizedSql,
31
- Ea as astToSql,
32
- n as branchesOf,
33
- Z as calendarDay,
34
- A as createEmptyQuery,
35
- M as createUnion,
36
- Ta as expr,
37
- i as filterSchema,
38
- $ as fromIsoDay,
39
- d as functionsForDialect,
40
- t as hasBaseTable,
41
- u as isUnion,
42
- aa as isoDay,
43
- N as issueLocation,
44
- D as joinMultiplicity,
45
- I as joinSharedQuery,
46
- B as keepMeasuresInStep,
47
- ya as loadQuery,
48
- f as makeShared,
49
- v as makeSubQuery,
50
- L as measureFacts,
51
- C as queryParams,
52
- R as relativeDateLabel,
53
- ca as removeJoin,
54
- F as removeSharedQuery,
55
- G as removeUnionTable,
56
- q as renameSharedQuery,
57
- x as renameUnionColumn,
58
- H as repeatedReads,
59
- P as repeatedTables,
60
- ha as requireBaseTable,
61
- g as rowsPerBase,
62
- pa as saveQuery,
63
- Qa as scopeQuery,
64
- _a as setBaseTable,
65
- Ua as setDistinct,
66
- ba as setHaving,
67
- Aa as setPaging,
68
- k as setSharedBase,
69
- O as setUnionAll,
70
- X as sharedQueryName,
71
- Y as sharedUses,
72
- j as unionName,
73
- J as unionTableColumns,
74
- w as unionWithQuery,
75
- K as unionableTables,
76
- Ma as unscopedBodies,
77
- z as unwrapUnion,
78
- W as validateQuery,
79
- l as validateSchema
264
+ le as DEFAULT_FUNCTIONS,
265
+ dt as DIALECTS,
266
+ yt as DIALECT_LABELS,
267
+ pe as EMPTY_SCHEMA,
268
+ ce as MAX_NAME_LENGTH,
269
+ Ee as MAX_NUMBER_DIGITS,
270
+ Te as MAX_TEXT_LENGTH,
271
+ ve as MAX_TYPE_NAME_LENGTH,
272
+ S as QUERY_FORMAT_VERSION,
273
+ He as QUERY_ISSUE_KINDS,
274
+ Xe as QUERY_WARNING_KINDS,
275
+ p as QueryFormatError,
276
+ ft as ScopeError,
277
+ Ye as SharedBaseError,
278
+ x as addCondition,
279
+ Z as addGroupBy,
280
+ K as addJoin,
281
+ Ne as addMeasure,
282
+ te as addOrderBy,
283
+ z as addSelectItem,
284
+ We as addSharedQuery,
285
+ Ie as addUnionBranch,
286
+ Ae as addUnionJoin,
287
+ Be as addUnionTable,
288
+ mt as astToParameterizedSql,
289
+ ht as astToSql,
290
+ de as branchesOf,
291
+ Ge as calendarDay,
292
+ Oe as createEmptyQuery,
293
+ De as createUnion,
294
+ v as expr,
295
+ ye as filterSchema,
296
+ fe as findJoinPath,
297
+ Je as fromIsoDay,
298
+ me as functionsForDialect,
299
+ O as hasBaseTable,
300
+ he as isUnion,
301
+ Fe as isoDay,
302
+ Ke as issueLocation,
303
+ Ve as joinMultiplicity,
304
+ ze as joinSharedQuery,
305
+ Le as keepMeasuresInStep,
306
+ ie as loadQuery,
307
+ Ze as makeShared,
308
+ et as makeSubQuery,
309
+ Qe as measureFacts,
310
+ Me as queryParams,
311
+ be as reachableTables,
312
+ tt as relativeDateLabel,
313
+ V as removeJoin,
314
+ rt as removeSharedQuery,
315
+ Ue as removeUnionTable,
316
+ at as renameSharedQuery,
317
+ _e as renameUnionColumn,
318
+ nt as repeatedReads,
319
+ st as repeatedTables,
320
+ ne as requireBaseTable,
321
+ it as rowsPerBase,
322
+ se as saveQuery,
323
+ bt as scopeQuery,
324
+ W as setBaseTable,
325
+ ae as setDistinct,
326
+ ee as setHaving,
327
+ re as setPaging,
328
+ ot as setSharedBase,
329
+ je as setUnionAll,
330
+ ut as sharedQueryName,
331
+ lt as sharedUses,
332
+ Se as suggestJoin,
333
+ qe as unionName,
334
+ xe as unionTableColumns,
335
+ Ce as unionWithQuery,
336
+ Re as unionableTables,
337
+ St as unscopedBodies,
338
+ $e as unwrapUnion,
339
+ pt as validateQuery,
340
+ we as validateSchema
80
341
  };