@nongt/visql 0.6.0 → 0.7.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 +11 -1
- package/dist/{PipelineEditor-6fohlut2.js → PipelineEditor-9-9xOJcB.js} +4026 -3892
- package/dist/{core-api-Bg_I2ak0.js → core-api-BsEMnDQ1.js} +21 -21
- package/dist/core.js +3 -3
- package/dist/index.js +5 -5
- package/dist/{issueLocation-CD9XckYv.js → issueLocation-732-e0B8.js} +819 -804
- package/dist/mui.js +225 -207
- package/dist/{schema-z95dxLxu.js → schema-DFC26AhZ.js} +142 -126
- package/dist/sql-import.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/adapters/mui/components.d.ts +8 -1
- package/dist/types/core/DialectContext.d.ts +1 -2
- package/dist/types/core/dialectSupport.d.ts +6 -0
- package/dist/types/core/i18n/defaultMessages.d.ts +2 -0
- package/dist/types/core/i18n/messages.d.ts +1 -0
- package/dist/types/core/schema.d.ts +19 -0
- package/dist/types/core/tablePickerOptions.d.ts +75 -0
- package/dist/types/core/ui/index.d.ts +6 -0
- package/dist/types/core/ui/types.d.ts +16 -0
- package/dist/types/core-api.d.ts +1 -1
- package/dist/types/features/queryEditor/PipelineEditor.d.ts +15 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -43,15 +43,15 @@ function Q(e) {
|
|
|
43
43
|
}
|
|
44
44
|
function T(e, t) {
|
|
45
45
|
if (!v(e)) return t(e, 0);
|
|
46
|
-
const r = e.union.map((a,
|
|
47
|
-
return r.every((a,
|
|
46
|
+
const r = e.union.map((a, i) => t(a, i));
|
|
47
|
+
return r.every((a, i) => a === e.union[i]) ? e : { ...e, union: r };
|
|
48
48
|
}
|
|
49
49
|
function K(e, t) {
|
|
50
50
|
if (!e.shared) return e;
|
|
51
51
|
let r = !1;
|
|
52
|
-
const a = e.shared.map((
|
|
53
|
-
const n = t(
|
|
54
|
-
return n ===
|
|
52
|
+
const a = e.shared.map((i) => {
|
|
53
|
+
const n = t(i.query, i);
|
|
54
|
+
return n === i.query ? i : (r = !0, { ...i, query: n });
|
|
55
55
|
});
|
|
56
56
|
return r ? { ...e, shared: a } : e;
|
|
57
57
|
}
|
|
@@ -135,20 +135,20 @@ function ee(e) {
|
|
|
135
135
|
];
|
|
136
136
|
}
|
|
137
137
|
function S(e, t, r = (a) => S(a, t)) {
|
|
138
|
-
var n,
|
|
139
|
-
const a = t, { shared:
|
|
138
|
+
var n, s;
|
|
139
|
+
const a = t, { shared: i } = e;
|
|
140
140
|
return {
|
|
141
141
|
...e,
|
|
142
|
-
...
|
|
143
|
-
shared:
|
|
142
|
+
...i ? {
|
|
143
|
+
shared: i.map((l) => ({ ...l, query: T(l.query, r) }))
|
|
144
144
|
} : {},
|
|
145
145
|
from: e.from.query ? { ...e.from, query: T(e.from.query, r) } : e.from,
|
|
146
146
|
where: e.where && a(e.where),
|
|
147
|
-
joins: e.joins.map((
|
|
148
|
-
select: e.select.map((
|
|
149
|
-
groupBy: (n = e.groupBy) == null ? void 0 : n.map((
|
|
147
|
+
joins: e.joins.map((l) => l.query ? { ...l, on: l.on && a(l.on), query: T(l.query, r) } : { ...l, on: l.on && a(l.on) }),
|
|
148
|
+
select: e.select.map((l) => ({ ...l, expression: a(l.expression) })),
|
|
149
|
+
groupBy: (n = e.groupBy) == null ? void 0 : n.map((l) => ({ ...l, expression: a(l.expression) })),
|
|
150
150
|
having: e.having && a(e.having),
|
|
151
|
-
orderBy: (
|
|
151
|
+
orderBy: (s = e.orderBy) == null ? void 0 : s.map((l) => ({ ...l, expression: a(l.expression) }))
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
function w(e, t) {
|
|
@@ -169,7 +169,7 @@ const te = {
|
|
|
169
169
|
"date-expr": ["date", "dateTime"],
|
|
170
170
|
"num-expr": ["integer", "decimal"],
|
|
171
171
|
"str-expr": ["varchar"]
|
|
172
|
-
},
|
|
172
|
+
}, u = { type: "field" }, Y = [
|
|
173
173
|
"YEAR",
|
|
174
174
|
"QUARTER",
|
|
175
175
|
"MONTH",
|
|
@@ -205,32 +205,32 @@ const d = (e, t = "DAY") => ({
|
|
|
205
205
|
label: "value",
|
|
206
206
|
kind: "expr",
|
|
207
207
|
optional: !0,
|
|
208
|
-
default:
|
|
208
|
+
default: u
|
|
209
209
|
}]
|
|
210
210
|
},
|
|
211
211
|
SUM: {
|
|
212
212
|
name: "SUM",
|
|
213
213
|
returns: "number",
|
|
214
214
|
aggregate: !0,
|
|
215
|
-
args: [{ label: "value", kind: "num-expr", default:
|
|
215
|
+
args: [{ label: "value", kind: "num-expr", default: u }]
|
|
216
216
|
},
|
|
217
217
|
AVG: {
|
|
218
218
|
name: "AVG",
|
|
219
219
|
returns: "number",
|
|
220
220
|
aggregate: !0,
|
|
221
|
-
args: [{ label: "value", kind: "num-expr", default:
|
|
221
|
+
args: [{ label: "value", kind: "num-expr", default: u }]
|
|
222
222
|
},
|
|
223
223
|
MIN: {
|
|
224
224
|
name: "MIN",
|
|
225
225
|
returns: "arg",
|
|
226
226
|
aggregate: !0,
|
|
227
|
-
args: [{ label: "value", kind: "expr", default:
|
|
227
|
+
args: [{ label: "value", kind: "expr", default: u }]
|
|
228
228
|
},
|
|
229
229
|
MAX: {
|
|
230
230
|
name: "MAX",
|
|
231
231
|
returns: "arg",
|
|
232
232
|
aggregate: !0,
|
|
233
|
-
args: [{ label: "value", kind: "expr", default:
|
|
233
|
+
args: [{ label: "value", kind: "expr", default: u }]
|
|
234
234
|
},
|
|
235
235
|
// A group's values joined into one text (issue 137). Written in each
|
|
236
236
|
// dialect's own form (see sqlGen); `distinct` on the call joins the
|
|
@@ -242,7 +242,7 @@ const d = (e, t = "DAY") => ({
|
|
|
242
242
|
aggregate: !0,
|
|
243
243
|
aliases: ["GROUP_CONCAT", "LISTAGG"],
|
|
244
244
|
args: [
|
|
245
|
-
{ label: "value", kind: "expr", default:
|
|
245
|
+
{ label: "value", kind: "expr", default: u },
|
|
246
246
|
{
|
|
247
247
|
label: "separator",
|
|
248
248
|
kind: "fixed-text",
|
|
@@ -256,7 +256,7 @@ const d = (e, t = "DAY") => ({
|
|
|
256
256
|
name: "DATE_ADD",
|
|
257
257
|
returns: "arg",
|
|
258
258
|
args: [
|
|
259
|
-
{ label: "date", kind: "date-expr", default:
|
|
259
|
+
{ label: "date", kind: "date-expr", default: u },
|
|
260
260
|
{ label: "amount", kind: "num-expr", default: { type: "literal", value: 1 } },
|
|
261
261
|
d("unit")
|
|
262
262
|
]
|
|
@@ -265,7 +265,7 @@ const d = (e, t = "DAY") => ({
|
|
|
265
265
|
name: "DATE_SUB",
|
|
266
266
|
returns: "arg",
|
|
267
267
|
args: [
|
|
268
|
-
{ label: "date", kind: "date-expr", default:
|
|
268
|
+
{ label: "date", kind: "date-expr", default: u },
|
|
269
269
|
{ label: "amount", kind: "num-expr", default: { type: "literal", value: 1 } },
|
|
270
270
|
d("unit")
|
|
271
271
|
]
|
|
@@ -275,8 +275,8 @@ const d = (e, t = "DAY") => ({
|
|
|
275
275
|
name: "DATEDIFF",
|
|
276
276
|
returns: "integer",
|
|
277
277
|
args: [
|
|
278
|
-
{ label: "start", kind: "date-expr", default:
|
|
279
|
-
{ label: "end", kind: "date-expr", default:
|
|
278
|
+
{ label: "start", kind: "date-expr", default: u },
|
|
279
|
+
{ label: "end", kind: "date-expr", default: u },
|
|
280
280
|
d("unit")
|
|
281
281
|
]
|
|
282
282
|
},
|
|
@@ -285,7 +285,7 @@ const d = (e, t = "DAY") => ({
|
|
|
285
285
|
name: "EXTRACT",
|
|
286
286
|
returns: "integer",
|
|
287
287
|
args: [
|
|
288
|
-
{ label: "date", kind: "date-expr", default:
|
|
288
|
+
{ label: "date", kind: "date-expr", default: u },
|
|
289
289
|
d("unit", "YEAR")
|
|
290
290
|
]
|
|
291
291
|
},
|
|
@@ -293,7 +293,7 @@ const d = (e, t = "DAY") => ({
|
|
|
293
293
|
name: "DATE_TRUNC",
|
|
294
294
|
returns: "arg",
|
|
295
295
|
args: [
|
|
296
|
-
{ label: "date", kind: "date-expr", default:
|
|
296
|
+
{ label: "date", kind: "date-expr", default: u },
|
|
297
297
|
d("unit")
|
|
298
298
|
]
|
|
299
299
|
},
|
|
@@ -301,7 +301,7 @@ const d = (e, t = "DAY") => ({
|
|
|
301
301
|
CAST: {
|
|
302
302
|
name: "CAST",
|
|
303
303
|
args: [
|
|
304
|
-
{ label: "value", kind: "expr", default:
|
|
304
|
+
{ label: "value", kind: "expr", default: u },
|
|
305
305
|
{
|
|
306
306
|
label: "type",
|
|
307
307
|
kind: "type-name",
|
|
@@ -318,7 +318,7 @@ const d = (e, t = "DAY") => ({
|
|
|
318
318
|
label: "value",
|
|
319
319
|
kind: "expr",
|
|
320
320
|
variadic: !0,
|
|
321
|
-
default:
|
|
321
|
+
default: u
|
|
322
322
|
}
|
|
323
323
|
]
|
|
324
324
|
},
|
|
@@ -326,7 +326,7 @@ const d = (e, t = "DAY") => ({
|
|
|
326
326
|
name: "IFNULL",
|
|
327
327
|
returns: "arg",
|
|
328
328
|
args: [
|
|
329
|
-
{ label: "value", kind: "expr", default:
|
|
329
|
+
{ label: "value", kind: "expr", default: u },
|
|
330
330
|
{ label: "fallback", kind: "expr", default: { type: "literal", value: null } }
|
|
331
331
|
]
|
|
332
332
|
},
|
|
@@ -334,7 +334,7 @@ const d = (e, t = "DAY") => ({
|
|
|
334
334
|
name: "NULLIF",
|
|
335
335
|
returns: "arg",
|
|
336
336
|
args: [
|
|
337
|
-
{ label: "value", kind: "expr", default:
|
|
337
|
+
{ label: "value", kind: "expr", default: u },
|
|
338
338
|
{ label: "compare", kind: "expr", default: { type: "literal", value: "" } }
|
|
339
339
|
]
|
|
340
340
|
},
|
|
@@ -347,7 +347,7 @@ const d = (e, t = "DAY") => ({
|
|
|
347
347
|
label: "value",
|
|
348
348
|
kind: "str-expr",
|
|
349
349
|
variadic: !0,
|
|
350
|
-
default:
|
|
350
|
+
default: u
|
|
351
351
|
}
|
|
352
352
|
]
|
|
353
353
|
},
|
|
@@ -355,7 +355,7 @@ const d = (e, t = "DAY") => ({
|
|
|
355
355
|
name: "SUBSTR",
|
|
356
356
|
returns: "text",
|
|
357
357
|
args: [
|
|
358
|
-
{ label: "string", kind: "str-expr", default:
|
|
358
|
+
{ label: "string", kind: "str-expr", default: u },
|
|
359
359
|
{ label: "start", kind: "num-expr", default: { type: "literal", value: 1 } },
|
|
360
360
|
{
|
|
361
361
|
label: "length",
|
|
@@ -369,7 +369,7 @@ const d = (e, t = "DAY") => ({
|
|
|
369
369
|
name: "REPLACE",
|
|
370
370
|
returns: "text",
|
|
371
371
|
args: [
|
|
372
|
-
{ label: "string", kind: "str-expr", default:
|
|
372
|
+
{ label: "string", kind: "str-expr", default: u },
|
|
373
373
|
{ label: "find", kind: "str-expr", default: { type: "literal", value: "" } },
|
|
374
374
|
{ label: "replace", kind: "str-expr", default: { type: "literal", value: "" } }
|
|
375
375
|
]
|
|
@@ -379,7 +379,7 @@ const d = (e, t = "DAY") => ({
|
|
|
379
379
|
name: "ROUND",
|
|
380
380
|
returns: "number",
|
|
381
381
|
args: [
|
|
382
|
-
{ label: "value", kind: "num-expr", default:
|
|
382
|
+
{ label: "value", kind: "num-expr", default: u },
|
|
383
383
|
{
|
|
384
384
|
label: "decimals",
|
|
385
385
|
kind: "num-expr",
|
|
@@ -392,7 +392,7 @@ const d = (e, t = "DAY") => ({
|
|
|
392
392
|
name: "MOD",
|
|
393
393
|
returns: "number",
|
|
394
394
|
args: [
|
|
395
|
-
{ label: "value", kind: "num-expr", default:
|
|
395
|
+
{ label: "value", kind: "num-expr", default: u },
|
|
396
396
|
{ label: "divisor", kind: "num-expr", default: { type: "literal", value: 1 } }
|
|
397
397
|
]
|
|
398
398
|
},
|
|
@@ -401,21 +401,21 @@ const d = (e, t = "DAY") => ({
|
|
|
401
401
|
name: "ABS",
|
|
402
402
|
returns: "arg",
|
|
403
403
|
args: [
|
|
404
|
-
{ label: "value", kind: "num-expr", default:
|
|
404
|
+
{ label: "value", kind: "num-expr", default: u }
|
|
405
405
|
]
|
|
406
406
|
},
|
|
407
407
|
CEIL: {
|
|
408
408
|
name: "CEIL",
|
|
409
409
|
returns: "integer",
|
|
410
410
|
args: [
|
|
411
|
-
{ label: "value", kind: "num-expr", default:
|
|
411
|
+
{ label: "value", kind: "num-expr", default: u }
|
|
412
412
|
]
|
|
413
413
|
},
|
|
414
414
|
FLOOR: {
|
|
415
415
|
name: "FLOOR",
|
|
416
416
|
returns: "integer",
|
|
417
417
|
args: [
|
|
418
|
-
{ label: "value", kind: "num-expr", default:
|
|
418
|
+
{ label: "value", kind: "num-expr", default: u }
|
|
419
419
|
]
|
|
420
420
|
},
|
|
421
421
|
// ---- String (single-arg) ----
|
|
@@ -423,42 +423,42 @@ const d = (e, t = "DAY") => ({
|
|
|
423
423
|
name: "LENGTH",
|
|
424
424
|
returns: "integer",
|
|
425
425
|
args: [
|
|
426
|
-
{ label: "string", kind: "str-expr", default:
|
|
426
|
+
{ label: "string", kind: "str-expr", default: u }
|
|
427
427
|
]
|
|
428
428
|
},
|
|
429
429
|
LOWER: {
|
|
430
430
|
name: "LOWER",
|
|
431
431
|
returns: "text",
|
|
432
432
|
args: [
|
|
433
|
-
{ label: "string", kind: "str-expr", default:
|
|
433
|
+
{ label: "string", kind: "str-expr", default: u }
|
|
434
434
|
]
|
|
435
435
|
},
|
|
436
436
|
UPPER: {
|
|
437
437
|
name: "UPPER",
|
|
438
438
|
returns: "text",
|
|
439
439
|
args: [
|
|
440
|
-
{ label: "string", kind: "str-expr", default:
|
|
440
|
+
{ label: "string", kind: "str-expr", default: u }
|
|
441
441
|
]
|
|
442
442
|
},
|
|
443
443
|
LTRIM: {
|
|
444
444
|
name: "LTRIM",
|
|
445
445
|
returns: "text",
|
|
446
446
|
args: [
|
|
447
|
-
{ label: "string", kind: "str-expr", default:
|
|
447
|
+
{ label: "string", kind: "str-expr", default: u }
|
|
448
448
|
]
|
|
449
449
|
},
|
|
450
450
|
RTRIM: {
|
|
451
451
|
name: "RTRIM",
|
|
452
452
|
returns: "text",
|
|
453
453
|
args: [
|
|
454
|
-
{ label: "string", kind: "str-expr", default:
|
|
454
|
+
{ label: "string", kind: "str-expr", default: u }
|
|
455
455
|
]
|
|
456
456
|
},
|
|
457
457
|
TRIM: {
|
|
458
458
|
name: "TRIM",
|
|
459
459
|
returns: "text",
|
|
460
460
|
args: [
|
|
461
|
-
{ label: "string", kind: "str-expr", default:
|
|
461
|
+
{ label: "string", kind: "str-expr", default: u }
|
|
462
462
|
]
|
|
463
463
|
},
|
|
464
464
|
// ---- String (multi-arg) ----
|
|
@@ -466,7 +466,7 @@ const d = (e, t = "DAY") => ({
|
|
|
466
466
|
name: "INSTR",
|
|
467
467
|
returns: "integer",
|
|
468
468
|
args: [
|
|
469
|
-
{ label: "string", kind: "str-expr", default:
|
|
469
|
+
{ label: "string", kind: "str-expr", default: u },
|
|
470
470
|
{ label: "substring", kind: "str-expr", default: { type: "literal", value: "" } }
|
|
471
471
|
]
|
|
472
472
|
},
|
|
@@ -474,7 +474,7 @@ const d = (e, t = "DAY") => ({
|
|
|
474
474
|
name: "LEFT",
|
|
475
475
|
returns: "text",
|
|
476
476
|
args: [
|
|
477
|
-
{ label: "string", kind: "str-expr", default:
|
|
477
|
+
{ label: "string", kind: "str-expr", default: u },
|
|
478
478
|
{ label: "length", kind: "num-expr", default: { type: "literal", value: 1 } }
|
|
479
479
|
]
|
|
480
480
|
},
|
|
@@ -482,7 +482,7 @@ const d = (e, t = "DAY") => ({
|
|
|
482
482
|
name: "RIGHT",
|
|
483
483
|
returns: "text",
|
|
484
484
|
args: [
|
|
485
|
-
{ label: "string", kind: "str-expr", default:
|
|
485
|
+
{ label: "string", kind: "str-expr", default: u },
|
|
486
486
|
{ label: "length", kind: "num-expr", default: { type: "literal", value: 1 } }
|
|
487
487
|
]
|
|
488
488
|
},
|
|
@@ -490,7 +490,7 @@ const d = (e, t = "DAY") => ({
|
|
|
490
490
|
name: "SUBSTRING",
|
|
491
491
|
returns: "text",
|
|
492
492
|
args: [
|
|
493
|
-
{ label: "string", kind: "str-expr", default:
|
|
493
|
+
{ label: "string", kind: "str-expr", default: u },
|
|
494
494
|
{ label: "start", kind: "num-expr", default: { type: "literal", value: 1 } },
|
|
495
495
|
{
|
|
496
496
|
label: "length",
|
|
@@ -504,7 +504,7 @@ const d = (e, t = "DAY") => ({
|
|
|
504
504
|
CONVERT: {
|
|
505
505
|
name: "CONVERT",
|
|
506
506
|
args: [
|
|
507
|
-
{ label: "value", kind: "expr", default:
|
|
507
|
+
{ label: "value", kind: "expr", default: u },
|
|
508
508
|
{ label: "type", kind: "type-name", default: { type: "literal", value: "INTEGER" } }
|
|
509
509
|
]
|
|
510
510
|
},
|
|
@@ -524,56 +524,56 @@ const d = (e, t = "DAY") => ({
|
|
|
524
524
|
name: "DATE",
|
|
525
525
|
returns: "date",
|
|
526
526
|
args: [
|
|
527
|
-
{ label: "expr", kind: "date-expr", default:
|
|
527
|
+
{ label: "expr", kind: "date-expr", default: u }
|
|
528
528
|
]
|
|
529
529
|
},
|
|
530
530
|
TIME: {
|
|
531
531
|
name: "TIME",
|
|
532
532
|
returns: "time",
|
|
533
533
|
args: [
|
|
534
|
-
{ label: "expr", kind: "date-expr", default:
|
|
534
|
+
{ label: "expr", kind: "date-expr", default: u }
|
|
535
535
|
]
|
|
536
536
|
},
|
|
537
537
|
DAY: {
|
|
538
538
|
name: "DAY",
|
|
539
539
|
returns: "integer",
|
|
540
540
|
args: [
|
|
541
|
-
{ label: "date", kind: "date-expr", default:
|
|
541
|
+
{ label: "date", kind: "date-expr", default: u }
|
|
542
542
|
]
|
|
543
543
|
},
|
|
544
544
|
MONTH: {
|
|
545
545
|
name: "MONTH",
|
|
546
546
|
returns: "integer",
|
|
547
547
|
args: [
|
|
548
|
-
{ label: "date", kind: "date-expr", default:
|
|
548
|
+
{ label: "date", kind: "date-expr", default: u }
|
|
549
549
|
]
|
|
550
550
|
},
|
|
551
551
|
YEAR: {
|
|
552
552
|
name: "YEAR",
|
|
553
553
|
returns: "integer",
|
|
554
554
|
args: [
|
|
555
|
-
{ label: "date", kind: "date-expr", default:
|
|
555
|
+
{ label: "date", kind: "date-expr", default: u }
|
|
556
556
|
]
|
|
557
557
|
},
|
|
558
558
|
HOUR: {
|
|
559
559
|
name: "HOUR",
|
|
560
560
|
returns: "integer",
|
|
561
561
|
args: [
|
|
562
|
-
{ label: "time", kind: "date-expr", default:
|
|
562
|
+
{ label: "time", kind: "date-expr", default: u }
|
|
563
563
|
]
|
|
564
564
|
},
|
|
565
565
|
MINUTE: {
|
|
566
566
|
name: "MINUTE",
|
|
567
567
|
returns: "integer",
|
|
568
568
|
args: [
|
|
569
|
-
{ label: "time", kind: "date-expr", default:
|
|
569
|
+
{ label: "time", kind: "date-expr", default: u }
|
|
570
570
|
]
|
|
571
571
|
},
|
|
572
572
|
SECOND: {
|
|
573
573
|
name: "SECOND",
|
|
574
574
|
returns: "integer",
|
|
575
575
|
args: [
|
|
576
|
-
{ label: "time", kind: "date-expr", default:
|
|
576
|
+
{ label: "time", kind: "date-expr", default: u }
|
|
577
577
|
]
|
|
578
578
|
}
|
|
579
579
|
};
|
|
@@ -583,8 +583,8 @@ function k(e, t = h) {
|
|
|
583
583
|
function ne(e, t) {
|
|
584
584
|
const r = e.toUpperCase();
|
|
585
585
|
return k(e, t) ?? Object.values(t).find((a) => {
|
|
586
|
-
var
|
|
587
|
-
return (
|
|
586
|
+
var i;
|
|
587
|
+
return (i = a.aliases) == null ? void 0 : i.some((n) => n.toUpperCase() === r);
|
|
588
588
|
});
|
|
589
589
|
}
|
|
590
590
|
function j(e = h) {
|
|
@@ -608,8 +608,8 @@ function E(e, t) {
|
|
|
608
608
|
if (e === t) return !0;
|
|
609
609
|
if (e instanceof Date && t instanceof Date) return e.getTime() === t.getTime();
|
|
610
610
|
if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
|
|
611
|
-
const r = e, a = t,
|
|
612
|
-
return
|
|
611
|
+
const r = e, a = t, i = Object.keys(r).filter((s) => r[s] !== void 0), n = Object.keys(a).filter((s) => a[s] !== void 0);
|
|
612
|
+
return i.length === n.length && i.every((s) => E(r[s], a[s]));
|
|
613
613
|
}
|
|
614
614
|
function F() {
|
|
615
615
|
const e = globalThis.crypto.getRandomValues(new Uint8Array(12));
|
|
@@ -625,17 +625,17 @@ function p(e, t) {
|
|
|
625
625
|
function O(e, t) {
|
|
626
626
|
return e.type === "function" && e.name.trim() !== "" && k(e.name, t) === void 0;
|
|
627
627
|
}
|
|
628
|
-
function
|
|
629
|
-
return e ? O(e, t) || b(e).some((r) =>
|
|
628
|
+
function M(e, t) {
|
|
629
|
+
return e ? O(e, t) || b(e).some((r) => M(r, t)) : !1;
|
|
630
630
|
}
|
|
631
631
|
function g(e, t, r) {
|
|
632
632
|
return t.some((a) => E(a, e)) ? !0 : e.type === "field" ? !e.column : e.type === "exists" ? G(e).every((a) => g(a, t, r)) : N(e, r) || O(e, r) ? !0 : b(e).every((a) => g(a, t, r));
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function D(e, t) {
|
|
635
635
|
return (e.groupBy ?? []).length > 0 || e.having !== void 0 || [...e.select, ...e.orderBy ?? []].some((r) => p(r.expression, t));
|
|
636
636
|
}
|
|
637
637
|
function oe(e, t) {
|
|
638
|
-
if (
|
|
638
|
+
if (D(e, t))
|
|
639
639
|
return (e.groupBy ?? []).flatMap(({ expression: r }) => r.type === "field" && r.table && r.column ? [`${r.table}.${r.column}`] : []);
|
|
640
640
|
}
|
|
641
641
|
function H(e, t) {
|
|
@@ -645,16 +645,16 @@ function fe(e, t) {
|
|
|
645
645
|
return e.select.some((r) => p(r.expression, t));
|
|
646
646
|
}
|
|
647
647
|
function ce(e, t) {
|
|
648
|
-
const r = e.groupBy ?? [], a = r.filter((o) => o.fromSelect === void 0),
|
|
648
|
+
const r = e.groupBy ?? [], a = r.filter((o) => o.fromSelect === void 0), i = H(e, t), n = a.map((o) => o.expression), s = i ? e.select.filter((o) => p(o.expression, t) || M(o.expression, t) || g(o.expression, n, t) ? !1 : (n.push(o.expression), !0)) : [], l = new Map(r.filter((o) => o.fromSelect !== void 0).map((o) => [o.fromSelect, o])), f = [];
|
|
649
649
|
r.forEach((o) => {
|
|
650
650
|
if (o.fromSelect === void 0) {
|
|
651
651
|
f.push(o);
|
|
652
652
|
return;
|
|
653
653
|
}
|
|
654
|
-
const m =
|
|
654
|
+
const m = s.find((U) => U.id === o.fromSelect);
|
|
655
655
|
m && f.push(E(o.expression, m.expression) ? o : { ...o, expression: m.expression });
|
|
656
656
|
});
|
|
657
|
-
const c =
|
|
657
|
+
const c = s.filter((o) => !l.has(o.id)).map((o) => ({
|
|
658
658
|
id: F(),
|
|
659
659
|
expression: o.expression,
|
|
660
660
|
fromSelect: o.id
|
|
@@ -663,78 +663,93 @@ function ce(e, t) {
|
|
|
663
663
|
}
|
|
664
664
|
function pe(e, t) {
|
|
665
665
|
const r = (e.groupBy ?? []).map((n) => n.expression), a = e.orderBy ?? [];
|
|
666
|
-
if (!
|
|
666
|
+
if (!D(e, t))
|
|
667
667
|
return {
|
|
668
668
|
select: [],
|
|
669
669
|
selectAll: !1,
|
|
670
670
|
orderBy: [],
|
|
671
671
|
having: !1
|
|
672
672
|
};
|
|
673
|
-
const
|
|
673
|
+
const i = (n) => n.filter((s) => !g(s.expression, r, t)).map((s) => s.id);
|
|
674
674
|
return {
|
|
675
|
-
select:
|
|
675
|
+
select: i(e.select),
|
|
676
676
|
selectAll: e.select.length === 0,
|
|
677
|
-
orderBy:
|
|
677
|
+
orderBy: i(a),
|
|
678
678
|
having: e.having !== void 0 && !g(e.having, r, t)
|
|
679
679
|
};
|
|
680
680
|
}
|
|
681
681
|
const me = { tables: [], relations: [] };
|
|
682
682
|
function de(e, t, r) {
|
|
683
683
|
if (!t && !r) return e;
|
|
684
|
-
const a = e.tables.filter((n) => !t || t(n)).map((n) => r ? { ...n, columns: n.columns.filter((
|
|
684
|
+
const a = e.tables.filter((n) => !t || t(n)).map((n) => r ? { ...n, columns: n.columns.filter((s) => r(n, s)) } : n), i = new Set(a.map((n) => n.name));
|
|
685
685
|
return {
|
|
686
686
|
tables: a,
|
|
687
|
-
relations: e.relations.filter((n) =>
|
|
687
|
+
relations: e.relations.filter((n) => i.has(n.fromTable) && i.has(n.toTable))
|
|
688
688
|
};
|
|
689
689
|
}
|
|
690
690
|
function ge(e) {
|
|
691
691
|
return [...e.tables].sort((t, r) => t.label.localeCompare(r.label));
|
|
692
692
|
}
|
|
693
|
+
function be(e, t = (a) => a.group, r = e) {
|
|
694
|
+
const a = /* @__PURE__ */ new Map();
|
|
695
|
+
r.forEach((n) => {
|
|
696
|
+
const s = t(n) || void 0;
|
|
697
|
+
s !== void 0 && !a.has(s) && a.set(s, []);
|
|
698
|
+
}), e.forEach((n) => {
|
|
699
|
+
const s = t(n) || void 0;
|
|
700
|
+
a.set(s, [...a.get(s) ?? [], n]);
|
|
701
|
+
});
|
|
702
|
+
const i = (n) => [...n].sort((s, l) => s.label.localeCompare(l.label));
|
|
703
|
+
return [
|
|
704
|
+
...[...a].filter(([n]) => n !== void 0),
|
|
705
|
+
...[...a].filter(([n]) => n === void 0)
|
|
706
|
+
].filter(([, n]) => n.length > 0).map(([n, s]) => ({ group: n, tables: i(s) }));
|
|
707
|
+
}
|
|
693
708
|
function _(e, t) {
|
|
694
709
|
return e.tables.find((r) => r.name === t);
|
|
695
710
|
}
|
|
696
711
|
function $(e, t, r) {
|
|
697
712
|
return e.relations.find((a) => a.fromTable === t && a.toTable === r || a.fromTable === r && a.toTable === t);
|
|
698
713
|
}
|
|
699
|
-
function
|
|
714
|
+
function he(e, t, r) {
|
|
700
715
|
if (t.includes(r)) return [];
|
|
701
|
-
const a = /* @__PURE__ */ new Map(),
|
|
702
|
-
for (; n.length > 0 && !
|
|
716
|
+
const a = /* @__PURE__ */ new Map(), i = new Set(t), n = [...t];
|
|
717
|
+
for (; n.length > 0 && !i.has(r); ) {
|
|
703
718
|
const f = n.shift();
|
|
704
719
|
e.relations.filter((c) => c.fromTable === f || c.toTable === f).map((c) => c.fromTable === f ? c.toTable : c.fromTable).forEach((c) => {
|
|
705
|
-
|
|
720
|
+
i.has(c) || (i.add(c), a.set(c, f), n.push(c));
|
|
706
721
|
});
|
|
707
722
|
}
|
|
708
|
-
if (!
|
|
709
|
-
const
|
|
710
|
-
let
|
|
711
|
-
for (; !t.includes(
|
|
712
|
-
|
|
713
|
-
return
|
|
714
|
-
}
|
|
715
|
-
function
|
|
716
|
-
const r = /* @__PURE__ */ new Map(), a = (
|
|
717
|
-
e.relations.forEach((
|
|
718
|
-
a(
|
|
723
|
+
if (!i.has(r)) return;
|
|
724
|
+
const s = [];
|
|
725
|
+
let l = r;
|
|
726
|
+
for (; !t.includes(l); )
|
|
727
|
+
s.unshift(l), l = a.get(l);
|
|
728
|
+
return s;
|
|
729
|
+
}
|
|
730
|
+
function xe(e, t) {
|
|
731
|
+
const r = /* @__PURE__ */ new Map(), a = (s, l) => r.set(s, [...r.get(s) ?? [], l]);
|
|
732
|
+
e.relations.forEach((s) => {
|
|
733
|
+
a(s.fromTable, s.toTable), a(s.toTable, s.fromTable);
|
|
719
734
|
});
|
|
720
|
-
const
|
|
721
|
-
for (let
|
|
722
|
-
(r.get(
|
|
723
|
-
|
|
735
|
+
const i = new Set(t), n = [...t];
|
|
736
|
+
for (let s = n.shift(); s !== void 0; s = n.shift())
|
|
737
|
+
(r.get(s) ?? []).forEach((l) => {
|
|
738
|
+
i.has(l) || (i.add(l), n.push(l));
|
|
724
739
|
});
|
|
725
|
-
return
|
|
740
|
+
return i;
|
|
726
741
|
}
|
|
727
|
-
function
|
|
728
|
-
var
|
|
742
|
+
function Te(e, t, r) {
|
|
743
|
+
var l;
|
|
729
744
|
const a = t.map((f) => $(e, f, r)).find((f) => f !== void 0);
|
|
730
745
|
if (!a) return;
|
|
731
|
-
const
|
|
746
|
+
const i = (l = _(e, a.fromTable)) == null ? void 0 : l.columns.find((f) => f.name === a.fromColumn), n = i != null && i.nullable ? "left" : "inner", s = {
|
|
732
747
|
type: "binary",
|
|
733
748
|
operator: "=",
|
|
734
749
|
left: { type: "field", table: a.fromTable, column: a.fromColumn },
|
|
735
750
|
right: { type: "field", table: a.toTable, column: a.toColumn }
|
|
736
751
|
};
|
|
737
|
-
return { joinType: n, on:
|
|
752
|
+
return { joinType: n, on: s };
|
|
738
753
|
}
|
|
739
754
|
const A = (e, t) => `${e}.${t}`;
|
|
740
755
|
function P({ type: e, format: t }) {
|
|
@@ -746,70 +761,71 @@ function P({ type: e, format: t }) {
|
|
|
746
761
|
if (e === "time" && r.some((a) => a === "YYYY" || a === "MM" || a === "DD"))
|
|
747
762
|
return `a time has no day: format "${t}" can't be written from one`;
|
|
748
763
|
}
|
|
749
|
-
function
|
|
764
|
+
function ve(e) {
|
|
750
765
|
const t = [], r = /* @__PURE__ */ new Map();
|
|
751
766
|
e.tables.forEach((n) => {
|
|
752
767
|
r.has(n.name) && t.push({
|
|
753
768
|
kind: "duplicateTable",
|
|
754
769
|
message: `Table "${n.name}" is declared more than once`
|
|
755
770
|
}), r.set(n.name, n);
|
|
756
|
-
const
|
|
757
|
-
n.columns.forEach((
|
|
758
|
-
|
|
771
|
+
const s = /* @__PURE__ */ new Set();
|
|
772
|
+
n.columns.forEach((l) => {
|
|
773
|
+
s.has(l.name) && t.push({
|
|
759
774
|
kind: "duplicateColumn",
|
|
760
|
-
message: `Column "${n.name}.${
|
|
761
|
-
}),
|
|
762
|
-
const f = P(
|
|
775
|
+
message: `Column "${n.name}.${l.name}" is declared more than once`
|
|
776
|
+
}), s.add(l.name);
|
|
777
|
+
const f = P(l);
|
|
763
778
|
f && t.push({
|
|
764
779
|
kind: "invalidFormat",
|
|
765
|
-
message: `Column "${n.name}.${
|
|
780
|
+
message: `Column "${n.name}.${l.name}": ${f}`
|
|
766
781
|
});
|
|
767
782
|
});
|
|
768
783
|
});
|
|
769
|
-
const a = (n,
|
|
770
|
-
const
|
|
771
|
-
|
|
784
|
+
const a = (n, s) => {
|
|
785
|
+
const l = r.get(n);
|
|
786
|
+
l ? l.columns.some((f) => f.name === s) || t.push({
|
|
772
787
|
kind: "unknownColumn",
|
|
773
|
-
message: `Relation references unknown column "${n}.${
|
|
788
|
+
message: `Relation references unknown column "${n}.${s}"`
|
|
774
789
|
}) : t.push({
|
|
775
790
|
kind: "unknownTable",
|
|
776
791
|
message: `Relation references unknown table "${n}"`
|
|
777
792
|
});
|
|
778
|
-
},
|
|
793
|
+
}, i = /* @__PURE__ */ new Set();
|
|
779
794
|
return e.relations.forEach((n) => {
|
|
780
795
|
a(n.fromTable, n.fromColumn), a(n.toTable, n.toColumn);
|
|
781
|
-
const
|
|
782
|
-
|
|
796
|
+
const s = A(n.fromTable, n.fromColumn), l = A(n.toTable, n.toColumn), f = [s, l].sort().join(" <-> ");
|
|
797
|
+
i.has(f) && t.push({
|
|
783
798
|
kind: "duplicateRelation",
|
|
784
|
-
message: `Relation ${
|
|
785
|
-
}),
|
|
799
|
+
message: `Relation ${s} -> ${l} is declared more than once (declare each foreign key once)`
|
|
800
|
+
}), i.add(f);
|
|
786
801
|
}), t;
|
|
787
802
|
}
|
|
788
803
|
export {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
804
|
+
q as A,
|
|
805
|
+
ge as B,
|
|
806
|
+
xe as C,
|
|
792
807
|
se as D,
|
|
793
808
|
me as E,
|
|
794
|
-
|
|
795
|
-
|
|
809
|
+
he as F,
|
|
810
|
+
Te as G,
|
|
796
811
|
T as H,
|
|
797
812
|
C as I,
|
|
798
813
|
k as J,
|
|
799
814
|
w as K,
|
|
800
815
|
le as L,
|
|
801
816
|
z as M,
|
|
802
|
-
|
|
817
|
+
D as N,
|
|
803
818
|
W as O,
|
|
804
819
|
re as P,
|
|
805
|
-
|
|
820
|
+
M as Q,
|
|
806
821
|
ie as R,
|
|
807
822
|
j as S,
|
|
808
823
|
te as T,
|
|
809
824
|
ae as U,
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
825
|
+
be as V,
|
|
826
|
+
N as W,
|
|
827
|
+
oe as X,
|
|
828
|
+
fe as Y,
|
|
813
829
|
ue as a,
|
|
814
830
|
X as b,
|
|
815
831
|
Y as c,
|
|
@@ -831,7 +847,7 @@ export {
|
|
|
831
847
|
ee as s,
|
|
832
848
|
I as t,
|
|
833
849
|
pe as u,
|
|
834
|
-
|
|
850
|
+
ve as v,
|
|
835
851
|
S as w,
|
|
836
852
|
K as x,
|
|
837
853
|
B as y,
|