@nongt/visql 0.11.0 → 0.12.1
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/dist/{PipelineEditor-DEiKHDrr.js → PipelineEditor-DDN3mL0I.js} +3692 -3521
- package/dist/core.js +125 -116
- package/dist/explain.js +3 -3
- package/dist/fixtures.js +3 -3
- package/dist/index.js +7 -7
- package/dist/{issueLocation-Yn71qJyP.js → issueLocation-DY-vvgFF.js} +437 -423
- package/dist/mui.js +1 -1
- package/dist/{params-DVkfcD6D.js → params-Btjlj45_.js} +104 -91
- package/dist/{schema-CzKt6cN2.js → schema-DsMO9oFE.js} +133 -129
- package/dist/sql-import.js +776 -767
- package/dist/{sqlGen-BoJXaULd.js → sqlGen-DGXVba3D.js} +198 -182
- package/dist/types/core/absolutePath.d.ts +3 -0
- package/dist/types/core/ast.d.ts +15 -1
- package/dist/types/core/components/expression/ExpressionTypeSelector.d.ts +1 -1
- package/dist/types/core/components/flow/CalculationFlowNode.d.ts +5 -0
- package/dist/types/core/expressionFlow.d.ts +40 -5
- package/dist/types/core/formula.d.ts +4 -1
- package/dist/types/core/i18n/defaultMessages.d.ts +7 -0
- package/dist/types/core/i18n/messages.d.ts +5 -0
- package/dist/types/core/issueLocation.d.ts +1 -1
- package/dist/types/core/queryHelpers.d.ts +4 -1
- package/dist/types/core/sqlGen.d.ts +12 -0
- package/dist/types/core/storedQuery.d.ts +1 -1
- package/dist/types/core/valueTypes.d.ts +2 -2
- package/dist/types/core-api.d.ts +2 -2
- package/dist/types/sqlImport/context.d.ts +2 -2
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var N = Object.defineProperty;
|
|
2
2
|
var I = (e, t, r) => t in e ? N(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var v = (e, t, r) => I(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { l as w, q as B, t as A, h as O } from "./schema-
|
|
5
|
-
import { D as pe, E as ye, M as
|
|
6
|
-
import {
|
|
7
|
-
import { M as
|
|
8
|
-
import { c as
|
|
9
|
-
import { Q as
|
|
10
|
-
import { D as
|
|
4
|
+
import { l as w, q as B, t as A, h as O } from "./schema-DsMO9oFE.js";
|
|
5
|
+
import { D as pe, E as ye, M as de, b as fe, f as me, a as he, c as be, i as ge, r as Se, s as Ee, v as ve } from "./schema-DsMO9oFE.js";
|
|
6
|
+
import { av as D, t as M, aw as L, F as Q, a0 as U, p as y, am as _, ax as i, ai as j } from "./params-Btjlj45_.js";
|
|
7
|
+
import { M as Te, a as Ne, b as Ie, d as Be, e as Ae, f as Oe, g as De, c as Me, h as Le, k as Qe, m as Ue, q as _e, r as je, i as qe, s as xe, j as Ce, o as Re, l as $e, n as ke, u as Ge } from "./params-Btjlj45_.js";
|
|
8
|
+
import { c as Fe, f as Pe, i as He } from "./calendarDate-CYlr9TvX.js";
|
|
9
|
+
import { Q as Ye, l as We, S as Ke, a as Ve, n as ze, f as Ze, j as et, m as tt, b as rt, k as at, r as nt, c as st, g as it, h as ot, i as ut, s as lt, d as ct, e as pt, v as yt } from "./issueLocation-DY-vvgFF.js";
|
|
10
|
+
import { D as ft, c as mt, S as ht, a as bt, b as gt, s as St, u as Et } from "./sqlGen-DGXVba3D.js";
|
|
11
11
|
const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), T = {
|
|
12
12
|
/** A column: `expr.field('orders', 'status')`. */
|
|
13
13
|
field: (e, t) => ({ type: "field", table: e, column: t }),
|
|
@@ -27,6 +27,14 @@ const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), T =
|
|
|
27
27
|
left: e,
|
|
28
28
|
right: r
|
|
29
29
|
}),
|
|
30
|
+
/** A calculation (issue 26), `left <operator> right`:
|
|
31
|
+
* `expr.calc(price, '*', quantity)`. */
|
|
32
|
+
calc: (e, t, r) => ({
|
|
33
|
+
type: "arithmetic",
|
|
34
|
+
operator: t,
|
|
35
|
+
left: e,
|
|
36
|
+
right: r
|
|
37
|
+
}),
|
|
30
38
|
/** `operand IS NULL`. */
|
|
31
39
|
isNull: (e) => ({
|
|
32
40
|
type: "binary",
|
|
@@ -116,23 +124,23 @@ const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), T =
|
|
|
116
124
|
query: { joins: [], ...t, select: [{ id: w(), expression: e }] }
|
|
117
125
|
})
|
|
118
126
|
};
|
|
119
|
-
function
|
|
127
|
+
function V(e, t, r) {
|
|
120
128
|
return i(e, t, { type: "setBaseTable", table: r });
|
|
121
129
|
}
|
|
122
|
-
function
|
|
130
|
+
function z(e, t, r, a = {}) {
|
|
123
131
|
const n = { type: "addJoin", table: r, ...a };
|
|
124
132
|
return i(e, t, n);
|
|
125
133
|
}
|
|
126
|
-
function
|
|
134
|
+
function Z(e, t, r) {
|
|
127
135
|
return i(e, t, { type: "removeJoin", joinId: r });
|
|
128
136
|
}
|
|
129
137
|
function x(e, t, r, a = {}) {
|
|
130
|
-
const n = D(t), s =
|
|
138
|
+
const n = D(t), s = M(r);
|
|
131
139
|
if (n && s.some((l) => l !== n.alias)) {
|
|
132
140
|
if (s.includes(n.alias))
|
|
133
141
|
throw new Error("addCondition: a condition names both the union and tables of its branches: add it in two parts");
|
|
134
142
|
return n.query.union.forEach((l) => {
|
|
135
|
-
const m = l.from.table, h = new Set(B(l).map(A)), b =
|
|
143
|
+
const m = l.from.table, h = new Set(B(l).map(A)), b = L(e, m), S = s.find((E) => !h.has(E) && !b.has(E));
|
|
136
144
|
if (S)
|
|
137
145
|
throw new Error(`addCondition: "${S}" can't be reached from "${m}", one of the union's tables: a condition must reach every branch`);
|
|
138
146
|
}), n.query.union.reduce((l, m, h) => Q(
|
|
@@ -143,28 +151,28 @@ function x(e, t, r, a = {}) {
|
|
|
143
151
|
}
|
|
144
152
|
const u = a.operator ?? "AND", { where: o } = t;
|
|
145
153
|
let d;
|
|
146
|
-
return o ? o.type === "logical" && o.operator === u ? d = { ...o, operands: [...o.operands, r] } : d = { type: "logical", operator: u, operands: [o, r] } : d = r,
|
|
154
|
+
return o ? o.type === "logical" && o.operator === u ? d = { ...o, operands: [...o.operands, r] } : d = { type: "logical", operator: u, operands: [o, r] } : d = r, y(e, t, _(e, t, d));
|
|
147
155
|
}
|
|
148
|
-
function
|
|
156
|
+
function ee(e, t, r, a) {
|
|
149
157
|
const n = i(e, t, { type: "addSelectItem" }), s = n.select[n.select.length - 1].id, u = i(e, n, {
|
|
150
158
|
type: "setSelectExpression",
|
|
151
159
|
selectId: s,
|
|
152
160
|
expression: r
|
|
153
161
|
}), o = a === void 0 ? u : i(e, u, { type: "setSelectAlias", selectId: s, alias: a });
|
|
154
|
-
return
|
|
162
|
+
return y(e, t, o);
|
|
155
163
|
}
|
|
156
|
-
function
|
|
164
|
+
function te(e, t, r) {
|
|
157
165
|
const a = i(e, t, { type: "addGroupByItem" }), { id: n } = a.groupBy[a.groupBy.length - 1], s = i(e, a, {
|
|
158
166
|
type: "setGroupByExpression",
|
|
159
167
|
groupById: n,
|
|
160
168
|
expression: r
|
|
161
169
|
});
|
|
162
|
-
return
|
|
170
|
+
return y(e, t, s);
|
|
163
171
|
}
|
|
164
|
-
function
|
|
165
|
-
return
|
|
172
|
+
function re(e, t, r) {
|
|
173
|
+
return y(e, t, j(e, t, r));
|
|
166
174
|
}
|
|
167
|
-
function
|
|
175
|
+
function ae(e, t, r, a = "asc") {
|
|
168
176
|
const n = i(e, t, { type: "addOrderByItem" }), { id: s } = n.orderBy[n.orderBy.length - 1], u = i(e, n, {
|
|
169
177
|
type: "setOrderByExpression",
|
|
170
178
|
orderById: s,
|
|
@@ -174,28 +182,28 @@ function re(e, t, r, a = "asc") {
|
|
|
174
182
|
orderById: s,
|
|
175
183
|
direction: a
|
|
176
184
|
});
|
|
177
|
-
return
|
|
185
|
+
return y(e, t, o);
|
|
178
186
|
}
|
|
179
|
-
function
|
|
187
|
+
function ne(e, t, r) {
|
|
180
188
|
let a = t;
|
|
181
189
|
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;
|
|
182
190
|
}
|
|
183
|
-
function
|
|
191
|
+
function se(e, t, r) {
|
|
184
192
|
return i(e, t, { type: "setDistinct", distinct: r });
|
|
185
193
|
}
|
|
186
|
-
function
|
|
194
|
+
function ie(e) {
|
|
187
195
|
if (!O(e)) throw new Error(`query "${e.id}" has no base table yet`);
|
|
188
196
|
return e;
|
|
189
197
|
}
|
|
190
|
-
const g =
|
|
191
|
-
class
|
|
198
|
+
const g = 6;
|
|
199
|
+
class c extends Error {
|
|
192
200
|
constructor(r, a) {
|
|
193
201
|
super(a);
|
|
194
202
|
v(this, "kind");
|
|
195
203
|
this.name = "QueryFormatError", this.kind = r;
|
|
196
204
|
}
|
|
197
205
|
}
|
|
198
|
-
const
|
|
206
|
+
const p = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
|
|
199
207
|
function C(e) {
|
|
200
208
|
const t = [];
|
|
201
209
|
let r = 0;
|
|
@@ -218,142 +226,143 @@ function C(e) {
|
|
|
218
226
|
function R(e) {
|
|
219
227
|
const t = (r) => {
|
|
220
228
|
if (Array.isArray(r)) return r.map(t);
|
|
221
|
-
if (!
|
|
229
|
+
if (!p(r)) return r;
|
|
222
230
|
const a = Object.fromEntries(Object.entries(r).map(([u, o]) => [u, t(o)])), { right: n } = a;
|
|
223
|
-
if (a.type !== "binary" || a.operator !== "IN" || !
|
|
231
|
+
if (a.type !== "binary" || a.operator !== "IN" || !p(n) || n.type === "subquery" || n.type === "list") return a;
|
|
224
232
|
const s = n.type === "literal" && typeof n.value == "string" ? C(n.value).map((u) => ({ type: "literal", value: u })) : [n];
|
|
225
233
|
return { ...a, right: { type: "list", items: s } };
|
|
226
234
|
};
|
|
227
235
|
return t(e);
|
|
228
236
|
}
|
|
229
|
-
const $ = (e) => e, k = (e) => e, G = (e) => e, J = [
|
|
237
|
+
const $ = (e) => e, k = (e) => e, G = (e) => e, J = (e) => e, F = [
|
|
230
238
|
R,
|
|
231
239
|
$,
|
|
232
240
|
k,
|
|
233
|
-
G
|
|
241
|
+
G,
|
|
242
|
+
J
|
|
234
243
|
];
|
|
235
|
-
function
|
|
244
|
+
function P(e, t, r) {
|
|
236
245
|
return r.slice(t - 1).reduce((a, n) => n(a), e);
|
|
237
246
|
}
|
|
238
247
|
function f(e, t) {
|
|
239
|
-
return Array.isArray(e) ? e.map((r) => f(r, t)) :
|
|
248
|
+
return Array.isArray(e) ? e.map((r) => f(r, t)) : p(e) ? e.type === "literal" ? t(e) : Object.fromEntries(Object.entries(e).map(([r, a]) => [r, f(a, t)])) : e;
|
|
240
249
|
}
|
|
241
|
-
function
|
|
250
|
+
function H(e) {
|
|
242
251
|
return e.value instanceof Date ? { ...e, value: e.value.toISOString(), valueType: "date" } : typeof e.value == "bigint" ? { ...e, value: String(e.value), valueType: "bigint" } : e;
|
|
243
252
|
}
|
|
244
|
-
function
|
|
253
|
+
function X(e) {
|
|
245
254
|
if (e.valueType === void 0) return e;
|
|
246
255
|
const { valueType: t, ...r } = e, a = String(r.value);
|
|
247
256
|
let n;
|
|
248
257
|
if (t === "date") {
|
|
249
258
|
if (n = new Date(a), Number.isNaN(n.getTime()))
|
|
250
|
-
throw new
|
|
259
|
+
throw new c("invalid", `not a date: ${JSON.stringify(a)}`);
|
|
251
260
|
} else if (t === "bigint" && /^-?\d+$/.test(a))
|
|
252
261
|
n = BigInt(a);
|
|
253
262
|
else {
|
|
254
263
|
const s = String(t);
|
|
255
|
-
throw new
|
|
264
|
+
throw new c("invalid", `can't read a ${s} from ${JSON.stringify(a)}`);
|
|
256
265
|
}
|
|
257
266
|
return { ...r, value: n };
|
|
258
267
|
}
|
|
259
|
-
function
|
|
268
|
+
function oe(e) {
|
|
260
269
|
return {
|
|
261
270
|
version: g,
|
|
262
|
-
query: f(e,
|
|
271
|
+
query: f(e, H)
|
|
263
272
|
};
|
|
264
273
|
}
|
|
265
|
-
function
|
|
266
|
-
if (!
|
|
267
|
-
throw new
|
|
274
|
+
function ue(e) {
|
|
275
|
+
if (!p(e))
|
|
276
|
+
throw new c("invalid", "a stored query is an object");
|
|
268
277
|
const { version: t } = e;
|
|
269
278
|
if (typeof t != "number" || !Number.isInteger(t) || t < 1)
|
|
270
|
-
throw new
|
|
279
|
+
throw new c("invalid", "a stored query has a whole-number version from 1");
|
|
271
280
|
if (t > g)
|
|
272
|
-
throw new
|
|
281
|
+
throw new c(
|
|
273
282
|
"newerVersion",
|
|
274
283
|
`stored in format ${t}; this version reads up to ${g}`
|
|
275
284
|
);
|
|
276
|
-
const r =
|
|
277
|
-
if (!
|
|
278
|
-
throw new
|
|
279
|
-
return f(r,
|
|
285
|
+
const r = P(e.query, t, F);
|
|
286
|
+
if (!p(r) || typeof r.id != "string")
|
|
287
|
+
throw new c("invalid", "a stored query has a query with a string id");
|
|
288
|
+
return f(r, X);
|
|
280
289
|
}
|
|
281
290
|
export {
|
|
282
291
|
pe as DEFAULT_FUNCTIONS,
|
|
283
|
-
|
|
284
|
-
|
|
292
|
+
ft as DIALECTS,
|
|
293
|
+
mt as DIALECT_LABELS,
|
|
285
294
|
ye as EMPTY_SCHEMA,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
295
|
+
de as MAX_NAME_LENGTH,
|
|
296
|
+
Te as MAX_NUMBER_DIGITS,
|
|
297
|
+
Ne as MAX_TEXT_LENGTH,
|
|
298
|
+
Ie as MAX_TYPE_NAME_LENGTH,
|
|
290
299
|
g as QUERY_FORMAT_VERSION,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
300
|
+
Ye as QUERY_ISSUE_KINDS,
|
|
301
|
+
We as QUERY_WARNING_KINDS,
|
|
302
|
+
c as QueryFormatError,
|
|
303
|
+
ht as ScopeError,
|
|
304
|
+
Ke as SharedBaseError,
|
|
296
305
|
x as addCondition,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
306
|
+
te as addGroupBy,
|
|
307
|
+
z as addJoin,
|
|
308
|
+
Be as addMeasure,
|
|
309
|
+
ae as addOrderBy,
|
|
310
|
+
ee as addSelectItem,
|
|
311
|
+
Ve as addSharedQuery,
|
|
312
|
+
Ae as addUnionBranch,
|
|
313
|
+
Oe as addUnionJoin,
|
|
314
|
+
De as addUnionTable,
|
|
315
|
+
bt as astToParameterizedSql,
|
|
316
|
+
gt as astToSql,
|
|
317
|
+
fe as branchesOf,
|
|
318
|
+
Fe as calendarDay,
|
|
319
|
+
Me as createEmptyQuery,
|
|
311
320
|
Le as createUnion,
|
|
312
321
|
T as expr,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
322
|
+
me as filterSchema,
|
|
323
|
+
he as findJoinPath,
|
|
324
|
+
Pe as fromIsoDay,
|
|
325
|
+
be as functionsForDialect,
|
|
317
326
|
O as hasBaseTable,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
327
|
+
ge as isUnion,
|
|
328
|
+
He as isoDay,
|
|
329
|
+
ze as issueLocation,
|
|
330
|
+
Ze as joinMultiplicity,
|
|
331
|
+
et as joinSharedQuery,
|
|
332
|
+
Qe as keepMeasuresInStep,
|
|
333
|
+
ue as loadQuery,
|
|
334
|
+
tt as makeShared,
|
|
335
|
+
rt as makeSubQuery,
|
|
336
|
+
Ue as measureFacts,
|
|
337
|
+
_e as queryParams,
|
|
338
|
+
Se as reachableTables,
|
|
339
|
+
at as relativeDateLabel,
|
|
340
|
+
Z as removeJoin,
|
|
341
|
+
nt as removeSharedQuery,
|
|
342
|
+
je as removeUnionTable,
|
|
343
|
+
st as renameSharedQuery,
|
|
344
|
+
qe as renameUnionColumn,
|
|
345
|
+
it as repeatedReads,
|
|
346
|
+
ot as repeatedTables,
|
|
347
|
+
ie as requireBaseTable,
|
|
348
|
+
ut as rowsPerBase,
|
|
349
|
+
oe as saveQuery,
|
|
350
|
+
St as scopeQuery,
|
|
351
|
+
V as setBaseTable,
|
|
352
|
+
se as setDistinct,
|
|
353
|
+
re as setHaving,
|
|
354
|
+
ne as setPaging,
|
|
355
|
+
lt as setSharedBase,
|
|
356
|
+
xe as setUnionAll,
|
|
357
|
+
ct as sharedQueryName,
|
|
349
358
|
pt as sharedUses,
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
359
|
+
Ee as suggestJoin,
|
|
360
|
+
Ce as unionName,
|
|
361
|
+
Re as unionTableColumns,
|
|
362
|
+
$e as unionWithQuery,
|
|
363
|
+
ke as unionableTables,
|
|
364
|
+
Et as unscopedBodies,
|
|
365
|
+
Ge as unwrapUnion,
|
|
357
366
|
yt as validateQuery,
|
|
358
|
-
|
|
367
|
+
ve as validateSchema
|
|
359
368
|
};
|
package/dist/explain.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { y as Y, m as G } from "./schema-
|
|
2
|
-
import { B as V } from "./params-
|
|
3
|
-
import { s as Z, b as tt, a as et } from "./sqlGen-
|
|
1
|
+
import { y as Y, m as G } from "./schema-DsMO9oFE.js";
|
|
2
|
+
import { B as V } from "./params-Btjlj45_.js";
|
|
3
|
+
import { s as Z, b as tt, a as et } from "./sqlGen-DGXVba3D.js";
|
|
4
4
|
const C = (t, e) => e.reduce(
|
|
5
5
|
(s, i) => s[i],
|
|
6
6
|
t
|