drizzle-cube 0.1.41 → 0.1.42

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.
@@ -1,4 +1,4 @@
1
- import { sql as r, eq as x, and as p, StringChunk as xT, count as SE, sum as f, max as q, min as j, countDistinct as vT, SQL as QT, or as IE, isNotNull as yE, ne as KE, isNull as $E, notInArray as gE, inArray as OE, lt as NE, gt as tE, gte as $, lte as g, desc as ZT, asc as wE } from "drizzle-orm";
1
+ import { sql as n, eq as x, and as p, StringChunk as xT, count as SE, sum as f, max as q, min as j, countDistinct as vT, SQL as QT, or as IE, isNotNull as yE, ne as KE, isNull as $E, notInArray as gE, inArray as OE, lt as NE, gt as tE, gte as $, lte as g, desc as ZT, asc as wE } from "drizzle-orm";
2
2
  class fE {
3
3
  /**
4
4
  * Default implementation returns template unchanged
@@ -36,21 +36,21 @@ class qT extends fE {
36
36
  buildTimeDimension(E, T) {
37
37
  switch (E) {
38
38
  case "year":
39
- return r`DATE_TRUNC('year', ${T}::timestamp)`;
39
+ return n`DATE_TRUNC('year', ${T}::timestamp)`;
40
40
  case "quarter":
41
- return r`DATE_TRUNC('quarter', ${T}::timestamp)`;
41
+ return n`DATE_TRUNC('quarter', ${T}::timestamp)`;
42
42
  case "month":
43
- return r`DATE_TRUNC('month', ${T}::timestamp)`;
43
+ return n`DATE_TRUNC('month', ${T}::timestamp)`;
44
44
  case "week":
45
- return r`DATE_TRUNC('week', ${T}::timestamp)`;
45
+ return n`DATE_TRUNC('week', ${T}::timestamp)`;
46
46
  case "day":
47
- return r`DATE_TRUNC('day', ${T}::timestamp)::timestamp`;
47
+ return n`DATE_TRUNC('day', ${T}::timestamp)::timestamp`;
48
48
  case "hour":
49
- return r`DATE_TRUNC('hour', ${T}::timestamp)`;
49
+ return n`DATE_TRUNC('hour', ${T}::timestamp)`;
50
50
  case "minute":
51
- return r`DATE_TRUNC('minute', ${T}::timestamp)`;
51
+ return n`DATE_TRUNC('minute', ${T}::timestamp)`;
52
52
  case "second":
53
- return r`DATE_TRUNC('second', ${T}::timestamp)`;
53
+ return n`DATE_TRUNC('second', ${T}::timestamp)`;
54
54
  default:
55
55
  return T;
56
56
  }
@@ -62,23 +62,23 @@ class qT extends fE {
62
62
  buildStringCondition(E, T, A) {
63
63
  switch (T) {
64
64
  case "contains":
65
- return r`${E} ILIKE ${`%${A}%`}`;
65
+ return n`${E} ILIKE ${`%${A}%`}`;
66
66
  case "notContains":
67
- return r`${E} NOT ILIKE ${`%${A}%`}`;
67
+ return n`${E} NOT ILIKE ${`%${A}%`}`;
68
68
  case "startsWith":
69
- return r`${E} ILIKE ${`${A}%`}`;
69
+ return n`${E} ILIKE ${`${A}%`}`;
70
70
  case "endsWith":
71
- return r`${E} ILIKE ${`%${A}`}`;
71
+ return n`${E} ILIKE ${`%${A}`}`;
72
72
  case "like":
73
- return r`${E} LIKE ${A}`;
73
+ return n`${E} LIKE ${A}`;
74
74
  case "notLike":
75
- return r`${E} NOT LIKE ${A}`;
75
+ return n`${E} NOT LIKE ${A}`;
76
76
  case "ilike":
77
- return r`${E} ILIKE ${A}`;
77
+ return n`${E} ILIKE ${A}`;
78
78
  case "regex":
79
- return r`${E} ~* ${A}`;
79
+ return n`${E} ~* ${A}`;
80
80
  case "notRegex":
81
- return r`${E} !~* ${A}`;
81
+ return n`${E} !~* ${A}`;
82
82
  default:
83
83
  throw new Error(`Unsupported string operator: ${T}`);
84
84
  }
@@ -90,11 +90,11 @@ class qT extends fE {
90
90
  castToType(E, T) {
91
91
  switch (T) {
92
92
  case "timestamp":
93
- return r`${E}::timestamp`;
93
+ return n`${E}::timestamp`;
94
94
  case "decimal":
95
- return r`${E}::decimal`;
95
+ return n`${E}::decimal`;
96
96
  case "integer":
97
- return r`${E}::integer`;
97
+ return n`${E}::integer`;
98
98
  default:
99
99
  throw new Error(`Unsupported cast type: ${T}`);
100
100
  }
@@ -105,21 +105,21 @@ class qT extends fE {
105
105
  * Extracted from multi-cube-builder.ts:284
106
106
  */
107
107
  buildAvg(E) {
108
- return r`COALESCE(AVG(${E}), 0)`;
108
+ return n`COALESCE(AVG(${E}), 0)`;
109
109
  }
110
110
  /**
111
111
  * Build PostgreSQL CASE WHEN conditional expression
112
112
  */
113
113
  buildCaseWhen(E, T) {
114
- const A = E.map((e) => r`WHEN ${e.when} THEN ${e.then}`).reduce((e, S) => r`${e} ${S}`);
115
- return T !== void 0 ? r`CASE ${A} ELSE ${T} END` : r`CASE ${A} END`;
114
+ const A = E.map((e) => n`WHEN ${e.when} THEN ${e.then}`).reduce((e, S) => n`${e} ${S}`);
115
+ return T !== void 0 ? n`CASE ${A} ELSE ${T} END` : n`CASE ${A} END`;
116
116
  }
117
117
  /**
118
118
  * Build PostgreSQL boolean literal
119
119
  * PostgreSQL uses TRUE/FALSE keywords
120
120
  */
121
121
  buildBooleanLiteral(E) {
122
- return E ? r`TRUE` : r`FALSE`;
122
+ return E ? n`TRUE` : n`FALSE`;
123
123
  }
124
124
  /**
125
125
  * Convert filter values - PostgreSQL uses native types
@@ -172,12 +172,12 @@ class HT extends fE {
172
172
  };
173
173
  switch (E) {
174
174
  case "quarter":
175
- return r`DATE_ADD(MAKEDATE(YEAR(${T}), 1), INTERVAL (QUARTER(${T}) - 1) * 3 MONTH)`;
175
+ return n`DATE_ADD(MAKEDATE(YEAR(${T}), 1), INTERVAL (QUARTER(${T}) - 1) * 3 MONTH)`;
176
176
  case "week":
177
- return r`DATE_SUB(${T}, INTERVAL WEEKDAY(${T}) DAY)`;
177
+ return n`DATE_SUB(${T}, INTERVAL WEEKDAY(${T}) DAY)`;
178
178
  default:
179
179
  const e = A[E];
180
- return e ? r`STR_TO_DATE(DATE_FORMAT(${T}, ${e}), '%Y-%m-%d %H:%i:%s')` : T;
180
+ return e ? n`STR_TO_DATE(DATE_FORMAT(${T}, ${e}), '%Y-%m-%d %H:%i:%s')` : T;
181
181
  }
182
182
  }
183
183
  /**
@@ -188,23 +188,23 @@ class HT extends fE {
188
188
  buildStringCondition(E, T, A) {
189
189
  switch (T) {
190
190
  case "contains":
191
- return r`LOWER(${E}) LIKE ${`%${A.toLowerCase()}%`}`;
191
+ return n`LOWER(${E}) LIKE ${`%${A.toLowerCase()}%`}`;
192
192
  case "notContains":
193
- return r`LOWER(${E}) NOT LIKE ${`%${A.toLowerCase()}%`}`;
193
+ return n`LOWER(${E}) NOT LIKE ${`%${A.toLowerCase()}%`}`;
194
194
  case "startsWith":
195
- return r`LOWER(${E}) LIKE ${`${A.toLowerCase()}%`}`;
195
+ return n`LOWER(${E}) LIKE ${`${A.toLowerCase()}%`}`;
196
196
  case "endsWith":
197
- return r`LOWER(${E}) LIKE ${`%${A.toLowerCase()}`}`;
197
+ return n`LOWER(${E}) LIKE ${`%${A.toLowerCase()}`}`;
198
198
  case "like":
199
- return r`${E} LIKE ${A}`;
199
+ return n`${E} LIKE ${A}`;
200
200
  case "notLike":
201
- return r`${E} NOT LIKE ${A}`;
201
+ return n`${E} NOT LIKE ${A}`;
202
202
  case "ilike":
203
- return r`LOWER(${E}) LIKE ${A.toLowerCase()}`;
203
+ return n`LOWER(${E}) LIKE ${A.toLowerCase()}`;
204
204
  case "regex":
205
- return r`${E} REGEXP ${A}`;
205
+ return n`${E} REGEXP ${A}`;
206
206
  case "notRegex":
207
- return r`${E} NOT REGEXP ${A}`;
207
+ return n`${E} NOT REGEXP ${A}`;
208
208
  default:
209
209
  throw new Error(`Unsupported string operator: ${T}`);
210
210
  }
@@ -216,11 +216,11 @@ class HT extends fE {
216
216
  castToType(E, T) {
217
217
  switch (T) {
218
218
  case "timestamp":
219
- return r`CAST(${E} AS DATETIME)`;
219
+ return n`CAST(${E} AS DATETIME)`;
220
220
  case "decimal":
221
- return r`CAST(${E} AS DECIMAL(10,2))`;
221
+ return n`CAST(${E} AS DECIMAL(10,2))`;
222
222
  case "integer":
223
- return r`CAST(${E} AS SIGNED INTEGER)`;
223
+ return n`CAST(${E} AS SIGNED INTEGER)`;
224
224
  default:
225
225
  throw new Error(`Unsupported cast type: ${T}`);
226
226
  }
@@ -230,21 +230,21 @@ class HT extends fE {
230
230
  * MySQL AVG returns NULL for empty sets, using IFNULL for consistency
231
231
  */
232
232
  buildAvg(E) {
233
- return r`IFNULL(AVG(${E}), 0)`;
233
+ return n`IFNULL(AVG(${E}), 0)`;
234
234
  }
235
235
  /**
236
236
  * Build MySQL CASE WHEN conditional expression
237
237
  */
238
238
  buildCaseWhen(E, T) {
239
- const A = E.map((e) => r`WHEN ${e.when} THEN ${e.then}`).reduce((e, S) => r`${e} ${S}`);
240
- return T !== void 0 ? r`CASE ${A} ELSE ${T} END` : r`CASE ${A} END`;
239
+ const A = E.map((e) => n`WHEN ${e.when} THEN ${e.then}`).reduce((e, S) => n`${e} ${S}`);
240
+ return T !== void 0 ? n`CASE ${A} ELSE ${T} END` : n`CASE ${A} END`;
241
241
  }
242
242
  /**
243
243
  * Build MySQL boolean literal
244
244
  * MySQL uses TRUE/FALSE keywords (equivalent to 1/0)
245
245
  */
246
246
  buildBooleanLiteral(E) {
247
- return E ? r`TRUE` : r`FALSE`;
247
+ return E ? n`TRUE` : n`FALSE`;
248
248
  }
249
249
  /**
250
250
  * Convert filter values - MySQL uses native types
@@ -287,28 +287,28 @@ class jT extends fE {
287
287
  buildTimeDimension(E, T) {
288
288
  switch (E) {
289
289
  case "year":
290
- return r`datetime(${T}, 'unixepoch', 'start of year')`;
290
+ return n`datetime(${T}, 'unixepoch', 'start of year')`;
291
291
  case "quarter":
292
- const A = r`datetime(${T}, 'unixepoch')`;
293
- return r`datetime(${A}, 'start of year',
292
+ const A = n`datetime(${T}, 'unixepoch')`;
293
+ return n`datetime(${A}, 'start of year',
294
294
  '+' || (((CAST(strftime('%m', ${A}) AS INTEGER) - 1) / 3) * 3) || ' months')`;
295
295
  case "month":
296
- return r`datetime(${T}, 'unixepoch', 'start of month')`;
296
+ return n`datetime(${T}, 'unixepoch', 'start of month')`;
297
297
  case "week":
298
- return r`date(datetime(${T}, 'unixepoch'), 'weekday 1', '-6 days')`;
298
+ return n`date(datetime(${T}, 'unixepoch'), 'weekday 1', '-6 days')`;
299
299
  case "day":
300
- return r`datetime(${T}, 'unixepoch', 'start of day')`;
300
+ return n`datetime(${T}, 'unixepoch', 'start of day')`;
301
301
  case "hour":
302
- const e = r`datetime(${T}, 'unixepoch')`;
303
- return r`datetime(strftime('%Y-%m-%d %H:00:00', ${e}))`;
302
+ const e = n`datetime(${T}, 'unixepoch')`;
303
+ return n`datetime(strftime('%Y-%m-%d %H:00:00', ${e}))`;
304
304
  case "minute":
305
- const S = r`datetime(${T}, 'unixepoch')`;
306
- return r`datetime(strftime('%Y-%m-%d %H:%M:00', ${S}))`;
305
+ const S = n`datetime(${T}, 'unixepoch')`;
306
+ return n`datetime(strftime('%Y-%m-%d %H:%M:00', ${S}))`;
307
307
  case "second":
308
- const I = r`datetime(${T}, 'unixepoch')`;
309
- return r`datetime(strftime('%Y-%m-%d %H:%M:%S', ${I}))`;
308
+ const I = n`datetime(${T}, 'unixepoch')`;
309
+ return n`datetime(strftime('%Y-%m-%d %H:%M:%S', ${I}))`;
310
310
  default:
311
- return r`datetime(${T}, 'unixepoch')`;
311
+ return n`datetime(${T}, 'unixepoch')`;
312
312
  }
313
313
  }
314
314
  /**
@@ -318,23 +318,23 @@ class jT extends fE {
318
318
  buildStringCondition(E, T, A) {
319
319
  switch (T) {
320
320
  case "contains":
321
- return r`LOWER(${E}) LIKE ${`%${A.toLowerCase()}%`}`;
321
+ return n`LOWER(${E}) LIKE ${`%${A.toLowerCase()}%`}`;
322
322
  case "notContains":
323
- return r`LOWER(${E}) NOT LIKE ${`%${A.toLowerCase()}%`}`;
323
+ return n`LOWER(${E}) NOT LIKE ${`%${A.toLowerCase()}%`}`;
324
324
  case "startsWith":
325
- return r`LOWER(${E}) LIKE ${`${A.toLowerCase()}%`}`;
325
+ return n`LOWER(${E}) LIKE ${`${A.toLowerCase()}%`}`;
326
326
  case "endsWith":
327
- return r`LOWER(${E}) LIKE ${`%${A.toLowerCase()}`}`;
327
+ return n`LOWER(${E}) LIKE ${`%${A.toLowerCase()}`}`;
328
328
  case "like":
329
- return r`${E} LIKE ${A}`;
329
+ return n`${E} LIKE ${A}`;
330
330
  case "notLike":
331
- return r`${E} NOT LIKE ${A}`;
331
+ return n`${E} NOT LIKE ${A}`;
332
332
  case "ilike":
333
- return r`LOWER(${E}) LIKE ${A.toLowerCase()}`;
333
+ return n`LOWER(${E}) LIKE ${A.toLowerCase()}`;
334
334
  case "regex":
335
- return r`${E} GLOB ${A}`;
335
+ return n`${E} GLOB ${A}`;
336
336
  case "notRegex":
337
- return r`${E} NOT GLOB ${A}`;
337
+ return n`${E} NOT GLOB ${A}`;
338
338
  default:
339
339
  throw new Error(`Unsupported string operator: ${T}`);
340
340
  }
@@ -346,11 +346,11 @@ class jT extends fE {
346
346
  castToType(E, T) {
347
347
  switch (T) {
348
348
  case "timestamp":
349
- return r`datetime(${E} / 1000, 'unixepoch')`;
349
+ return n`datetime(${E} / 1000, 'unixepoch')`;
350
350
  case "decimal":
351
- return r`CAST(${E} AS REAL)`;
351
+ return n`CAST(${E} AS REAL)`;
352
352
  case "integer":
353
- return r`CAST(${E} AS INTEGER)`;
353
+ return n`CAST(${E} AS INTEGER)`;
354
354
  default:
355
355
  throw new Error(`Unsupported cast type: ${T}`);
356
356
  }
@@ -360,21 +360,21 @@ class jT extends fE {
360
360
  * SQLite AVG returns NULL for empty sets, using IFNULL for consistency
361
361
  */
362
362
  buildAvg(E) {
363
- return r`IFNULL(AVG(${E}), 0)`;
363
+ return n`IFNULL(AVG(${E}), 0)`;
364
364
  }
365
365
  /**
366
366
  * Build SQLite CASE WHEN conditional expression
367
367
  */
368
368
  buildCaseWhen(E, T) {
369
- const A = E.map((e) => e.then && typeof e.then == "object" && (e.then.queryChunks || e.then._ || e.then.sql) ? r`WHEN ${e.when} THEN ${r.raw("(")}${e.then}${r.raw(")")}` : r`WHEN ${e.when} THEN ${e.then}`).reduce((e, S) => r`${e} ${S}`);
370
- return T !== void 0 ? T && typeof T == "object" && (T.queryChunks || T._ || T.sql) ? r`CASE ${A} ELSE ${r.raw("(")}${T}${r.raw(")")} END` : r`CASE ${A} ELSE ${T} END` : r`CASE ${A} END`;
369
+ const A = E.map((e) => e.then && typeof e.then == "object" && (e.then.queryChunks || e.then._ || e.then.sql) ? n`WHEN ${e.when} THEN ${n.raw("(")}${e.then}${n.raw(")")}` : n`WHEN ${e.when} THEN ${e.then}`).reduce((e, S) => n`${e} ${S}`);
370
+ return T !== void 0 ? T && typeof T == "object" && (T.queryChunks || T._ || T.sql) ? n`CASE ${A} ELSE ${n.raw("(")}${T}${n.raw(")")} END` : n`CASE ${A} ELSE ${T} END` : n`CASE ${A} END`;
371
371
  }
372
372
  /**
373
373
  * Build SQLite boolean literal
374
374
  * SQLite uses 1/0 for true/false
375
375
  */
376
376
  buildBooleanLiteral(E) {
377
- return E ? r`1` : r`0`;
377
+ return E ? n`1` : n`0`;
378
378
  }
379
379
  /**
380
380
  * Preprocess calculated measure templates for SQLite-specific handling
@@ -657,7 +657,7 @@ function dT(R, E) {
657
657
  }
658
658
  }
659
659
  function SR(R) {
660
- return R && typeof R == "object" ? r`${r`${R}`}` : R;
660
+ return R && typeof R == "object" ? n`${n`${R}`}` : R;
661
661
  }
662
662
  function X(R, E) {
663
663
  const T = typeof R == "function" ? R(E) : R;
@@ -680,30 +680,30 @@ function IR(R, E) {
680
680
  if (R.relationship !== "belongsToMany" || !R.through)
681
681
  throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
682
682
  const { table: T, sourceKey: A, targetKey: e, securitySql: S } = R.through, I = [];
683
- for (const O of A) {
684
- const s = O.as || x;
685
- I.push(s(O.source, O.target));
683
+ for (const N of A) {
684
+ const s = N.as || x;
685
+ I.push(s(N.source, N.target));
686
686
  }
687
687
  const t = [];
688
- for (const O of e) {
689
- const s = O.as || x;
690
- t.push(s(O.source, O.target));
688
+ for (const N of e) {
689
+ const s = N.as || x;
690
+ t.push(s(N.source, N.target));
691
691
  }
692
692
  let C;
693
693
  if (S) {
694
- const O = S(E);
695
- C = Array.isArray(O) ? O : [O];
694
+ const N = S(E);
695
+ C = Array.isArray(N) ? N : [N];
696
696
  }
697
- const N = dT("belongsToMany", R.sqlJoinType);
697
+ const O = dT("belongsToMany", R.sqlJoinType);
698
698
  return {
699
699
  junctionJoins: [
700
700
  {
701
- joinType: N,
701
+ joinType: O,
702
702
  table: T,
703
703
  condition: p(...I)
704
704
  },
705
705
  {
706
- joinType: N,
706
+ joinType: O,
707
707
  table: T,
708
708
  // This will be replaced with target cube table in query planner
709
709
  condition: p(...t)
@@ -755,8 +755,8 @@ class b {
755
755
  if (A.type === "calculated" && A.calculatedSql) {
756
756
  const e = `${E.name}.${T}`, S = this.extractDependencies(A.calculatedSql), I = /* @__PURE__ */ new Set();
757
757
  for (const t of S) {
758
- const N = `${t.cubeName || E.name}.${t.fieldName}`;
759
- I.add(N);
758
+ const O = `${t.cubeName || E.name}.${t.fieldName}`;
759
+ I.add(O);
760
760
  }
761
761
  this.dependencyGraph.set(e, {
762
762
  id: e,
@@ -935,35 +935,35 @@ class b {
935
935
  function NR(R, E) {
936
936
  const { cube: T, allCubes: A, resolvedMeasures: e } = E, S = WE(R), I = /* @__PURE__ */ new Map();
937
937
  for (const s of S) {
938
- const { originalRef: _, cubeName: n, fieldName: D } = s, o = n || T.name;
938
+ const { originalRef: r, cubeName: L, fieldName: i } = s, o = L || T.name;
939
939
  if (!A.get(o))
940
940
  throw new Error(
941
- `Cannot substitute {${_}}: cube '${o}' not found`
941
+ `Cannot substitute {${r}}: cube '${o}' not found`
942
942
  );
943
- const P = `${o}.${D}`, c = e.get(P);
943
+ const P = `${o}.${i}`, c = e.get(P);
944
944
  if (!c)
945
945
  throw new Error(
946
- `Cannot substitute {${_}}: measure '${P}' not resolved yet. Ensure measures are resolved in dependency order.`
946
+ `Cannot substitute {${r}}: measure '${P}' not resolved yet. Ensure measures are resolved in dependency order.`
947
947
  );
948
- const M = c(), u = r`${M}`;
949
- I.set(_, u);
948
+ const M = c(), u = n`${M}`;
949
+ I.set(r, u);
950
950
  }
951
951
  const t = [], C = [];
952
- let N = 0;
952
+ let O = 0;
953
953
  for (const s of S) {
954
- const _ = `{${s.originalRef}}`, n = R.indexOf(_, N);
955
- if (n >= 0) {
956
- t.push(R.substring(N, n));
957
- const D = I.get(s.originalRef);
958
- D && C.push(D), N = n + _.length;
954
+ const r = `{${s.originalRef}}`, L = R.indexOf(r, O);
955
+ if (L >= 0) {
956
+ t.push(R.substring(O, L));
957
+ const i = I.get(s.originalRef);
958
+ i && C.push(i), O = L + r.length;
959
959
  }
960
960
  }
961
- if (t.push(R.substring(N)), C.length === 0)
962
- return r.raw(R);
963
- const O = [];
961
+ if (t.push(R.substring(O)), C.length === 0)
962
+ return n.raw(R);
963
+ const N = [];
964
964
  for (let s = 0; s < t.length; s++)
965
- t[s] && O.push(new xT(t[s])), s < C.length && O.push(C[s]);
966
- return r.join(O, r.raw(""));
965
+ t[s] && N.push(new xT(t[s])), s < C.length && N.push(C[s]);
966
+ return n.join(N, n.raw(""));
967
967
  }
968
968
  function WE(R) {
969
969
  const E = /\{([^}]+)\}/g, T = R.matchAll(E), A = [];
@@ -1034,44 +1034,44 @@ class sR {
1034
1034
  * @returns Map of measure names to SQL builder functions
1035
1035
  */
1036
1036
  buildResolvedMeasures(E, T, A, e) {
1037
- const S = /* @__PURE__ */ new Map(), I = [], t = [], C = new Set(E), N = new b(T);
1038
- for (const O of T.values())
1039
- N.buildGraph(O);
1040
- for (const O of E) {
1041
- const [s, _] = O.split("."), n = T.get(s);
1042
- if (n && n.measures && n.measures[_]) {
1043
- const D = n.measures[_];
1044
- b.isCalculatedMeasure(D) ? (t.push(O), sE(D.calculatedSql, s).forEach((P) => C.add(P)), N.getAllDependencies(O).forEach((P) => {
1037
+ const S = /* @__PURE__ */ new Map(), I = [], t = [], C = new Set(E), O = new b(T);
1038
+ for (const N of T.values())
1039
+ O.buildGraph(N);
1040
+ for (const N of E) {
1041
+ const [s, r] = N.split("."), L = T.get(s);
1042
+ if (L && L.measures && L.measures[r]) {
1043
+ const i = L.measures[r];
1044
+ b.isCalculatedMeasure(i) ? (t.push(N), sE(i.calculatedSql, s).forEach((P) => C.add(P)), O.getAllDependencies(N).forEach((P) => {
1045
1045
  const [c, M] = P.split("."), u = T.get(c);
1046
1046
  if (u && u.measures[M]) {
1047
1047
  const H = u.measures[M];
1048
1048
  b.isCalculatedMeasure(H) && sE(H.calculatedSql, c).forEach((Y) => C.add(Y));
1049
1049
  }
1050
- })) : I.push(O);
1050
+ })) : I.push(N);
1051
1051
  }
1052
1052
  }
1053
- for (const O of C) {
1054
- const [s, _] = O.split("."), n = T.get(s);
1055
- if (n && n.measures && n.measures[_]) {
1056
- const D = n.measures[_];
1057
- b.isCalculatedMeasure(D) ? t.includes(O) || t.push(O) : I.includes(O) || I.push(O);
1053
+ for (const N of C) {
1054
+ const [s, r] = N.split("."), L = T.get(s);
1055
+ if (L && L.measures && L.measures[r]) {
1056
+ const i = L.measures[r];
1057
+ b.isCalculatedMeasure(i) ? t.includes(N) || t.push(N) : I.includes(N) || I.push(N);
1058
1058
  }
1059
1059
  }
1060
- for (const O of I) {
1061
- const [s, _] = O.split("."), n = T.get(s), D = n.measures[_];
1060
+ for (const N of I) {
1061
+ const [s, r] = N.split("."), L = T.get(s), i = L.measures[r];
1062
1062
  if (e) {
1063
- const o = e(O, D, n);
1064
- S.set(O, () => o);
1063
+ const o = e(N, i, L);
1064
+ S.set(N, () => o);
1065
1065
  } else
1066
- S.set(O, () => this.buildMeasureExpression(D, A));
1066
+ S.set(N, () => this.buildMeasureExpression(i, A));
1067
1067
  }
1068
1068
  if (t.length > 0) {
1069
- const O = N.topologicalSort(t);
1070
- for (const s of O) {
1071
- const [_, n] = s.split("."), D = T.get(_), o = D.measures[n];
1069
+ const N = O.topologicalSort(t);
1070
+ for (const s of N) {
1071
+ const [r, L] = s.split("."), i = T.get(r), o = i.measures[L];
1072
1072
  S.set(s, () => this.buildCalculatedMeasure(
1073
1073
  o,
1074
- D,
1074
+ i,
1075
1075
  T,
1076
1076
  S,
1077
1077
  A
@@ -1089,10 +1089,10 @@ class sR {
1089
1089
  const e = {}, S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1090
1090
  if (T.dimensions)
1091
1091
  for (const I of T.dimensions) {
1092
- const [t, C] = I.split("."), N = S.get(t);
1093
- if (N && N.dimensions && N.dimensions[C]) {
1094
- const O = N.dimensions[C], s = X(O.sql, A);
1095
- e[I] = r`${s}`.as(I);
1092
+ const [t, C] = I.split("."), O = S.get(t);
1093
+ if (O && O.dimensions && O.dimensions[C]) {
1094
+ const N = O.dimensions[C], s = X(N.sql, A);
1095
+ e[I] = n`${s}`.as(I);
1096
1096
  }
1097
1097
  }
1098
1098
  if (T.measures) {
@@ -1104,21 +1104,21 @@ class sR {
1104
1104
  for (const t of T.measures) {
1105
1105
  const C = I.get(t);
1106
1106
  if (C) {
1107
- const N = C();
1108
- e[t] = r`${N}`.as(t);
1107
+ const O = C();
1108
+ e[t] = n`${O}`.as(t);
1109
1109
  }
1110
1110
  }
1111
1111
  }
1112
1112
  if (T.timeDimensions)
1113
1113
  for (const I of T.timeDimensions) {
1114
- const [t, C] = I.dimension.split("."), N = S.get(t);
1115
- if (N && N.dimensions && N.dimensions[C]) {
1116
- const O = N.dimensions[C], s = this.buildTimeDimensionExpression(
1117
- O.sql,
1114
+ const [t, C] = I.dimension.split("."), O = S.get(t);
1115
+ if (O && O.dimensions && O.dimensions[C]) {
1116
+ const N = O.dimensions[C], s = this.buildTimeDimensionExpression(
1117
+ N.sql,
1118
1118
  I.granularity,
1119
1119
  A
1120
1120
  );
1121
- e[I.dimension] = r`${s}`.as(I.dimension);
1121
+ e[I.dimension] = n`${s}`.as(I.dimension);
1122
1122
  }
1123
1123
  }
1124
1124
  return Object.keys(e).length === 0 && (e.count = SE()), e;
@@ -1160,34 +1160,34 @@ class sR {
1160
1160
  );
1161
1161
  const I = /* @__PURE__ */ new Map(), t = sE(E.calculatedSql, T.name);
1162
1162
  for (const C of t) {
1163
- const [N, O] = C.split("."), s = e.get(N);
1164
- if (s && s.measures[O]) {
1165
- const _ = s.measures[O];
1163
+ const [O, N] = C.split("."), s = e.get(O);
1164
+ if (s && s.measures[N]) {
1165
+ const r = s.measures[N];
1166
1166
  if (A.measures.includes(C)) {
1167
- const n = r`${r.identifier(A.cteAlias)}.${r.identifier(O)}`;
1168
- let D;
1169
- switch (_.type) {
1167
+ const L = n`${n.identifier(A.cteAlias)}.${n.identifier(N)}`;
1168
+ let i;
1169
+ switch (r.type) {
1170
1170
  case "count":
1171
1171
  case "countDistinct":
1172
1172
  case "sum":
1173
- D = f(n);
1173
+ i = f(L);
1174
1174
  break;
1175
1175
  case "avg":
1176
- D = this.databaseAdapter.buildAvg(n);
1176
+ i = this.databaseAdapter.buildAvg(L);
1177
1177
  break;
1178
1178
  case "min":
1179
- D = j(n);
1179
+ i = j(L);
1180
1180
  break;
1181
1181
  case "max":
1182
- D = q(n);
1182
+ i = q(L);
1183
1183
  break;
1184
1184
  case "number":
1185
- D = f(n);
1185
+ i = f(L);
1186
1186
  break;
1187
1187
  default:
1188
- D = f(n);
1188
+ i = f(L);
1189
1189
  }
1190
- I.set(C, () => D);
1190
+ I.set(C, () => i);
1191
1191
  }
1192
1192
  }
1193
1193
  }
@@ -1207,13 +1207,13 @@ class sR {
1207
1207
  const I = S.preAggregationCTEs.find((t) => t.cube.name === E);
1208
1208
  if (I && I.measures.includes(`${E}.${T}`))
1209
1209
  if (A.type === "calculated" && A.calculatedSql) {
1210
- const t = S.primaryCube.name === E ? S.primaryCube : S.joinCubes?.find((N) => N.cube.name === E)?.cube;
1210
+ const t = S.primaryCube.name === E ? S.primaryCube : S.joinCubes?.find((O) => O.cube.name === E)?.cube;
1211
1211
  if (!t)
1212
1212
  throw new Error(`Cube ${E} not found in query plan`);
1213
1213
  const C = /* @__PURE__ */ new Map([[S.primaryCube.name, S.primaryCube]]);
1214
1214
  if (S.joinCubes)
1215
- for (const N of S.joinCubes)
1216
- C.set(N.cube.name, N.cube);
1215
+ for (const O of S.joinCubes)
1216
+ C.set(O.cube.name, O.cube);
1217
1217
  return this.buildCTECalculatedMeasure(
1218
1218
  A,
1219
1219
  t,
@@ -1222,7 +1222,7 @@ class sR {
1222
1222
  e
1223
1223
  );
1224
1224
  } else {
1225
- const t = r`${r.identifier(I.cteAlias)}.${r.identifier(T)}`;
1225
+ const t = n`${n.identifier(I.cteAlias)}.${n.identifier(T)}`;
1226
1226
  switch (A.type) {
1227
1227
  case "count":
1228
1228
  case "countDistinct":
@@ -1260,7 +1260,7 @@ class sR {
1260
1260
  if (E.filters && E.filters.length > 0) {
1261
1261
  const e = E.filters.map((S) => {
1262
1262
  const I = S(T);
1263
- return I ? r`(${I})` : void 0;
1263
+ return I ? n`(${I})` : void 0;
1264
1264
  }).filter(Boolean);
1265
1265
  if (e.length > 0) {
1266
1266
  const S = e.length === 1 ? e[0] : p(...e);
@@ -1293,7 +1293,7 @@ class sR {
1293
1293
  */
1294
1294
  buildTimeDimensionExpression(E, T, A) {
1295
1295
  const e = X(E, A);
1296
- return T ? this.databaseAdapter.buildTimeDimension(T, e) : e instanceof QT ? e : r`${e}`;
1296
+ return T ? this.databaseAdapter.buildTimeDimension(T, e) : e instanceof QT ? e : n`${e}`;
1297
1297
  }
1298
1298
  /**
1299
1299
  * Build WHERE conditions from semantic query filters (dimensions only)
@@ -1308,12 +1308,12 @@ class sR {
1308
1308
  }
1309
1309
  if (T.timeDimensions)
1310
1310
  for (const t of T.timeDimensions) {
1311
- const [C, N] = t.dimension.split("."), O = I.get(C);
1312
- if (O && O.dimensions[N] && t.dateRange) {
1311
+ const [C, O] = t.dimension.split("."), N = I.get(C);
1312
+ if (N && N.dimensions[O] && t.dateRange) {
1313
1313
  if (e?.preAggregationCTEs && e.preAggregationCTEs.some((o) => o.cube.name === C))
1314
1314
  continue;
1315
- const s = O.dimensions[N], _ = X(s.sql, A), n = this.buildDateRangeCondition(_, t.dateRange);
1316
- n && S.push(n);
1315
+ const s = N.dimensions[O], r = X(s.sql, A), L = this.buildDateRangeCondition(r, t.dateRange);
1316
+ L && S.push(L);
1317
1317
  }
1318
1318
  }
1319
1319
  return S;
@@ -1337,31 +1337,43 @@ class sR {
1337
1337
  */
1338
1338
  processFilter(E, T, A, e, S) {
1339
1339
  if ("and" in E || "or" in E) {
1340
- const n = E;
1341
- if (n.and) {
1342
- const D = n.and.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
1343
- return D.length > 0 ? p(...D) : null;
1340
+ const L = E;
1341
+ if (L.and) {
1342
+ const i = L.and.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
1343
+ return i.length > 0 ? p(...i) : null;
1344
1344
  }
1345
- if (n.or) {
1346
- const D = n.or.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
1347
- return D.length > 0 ? IE(...D) : null;
1345
+ if (L.or) {
1346
+ const i = L.or.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
1347
+ return i.length > 0 ? IE(...i) : null;
1348
1348
  }
1349
1349
  }
1350
- const I = E, [t, C] = I.member.split("."), N = T.get(t);
1351
- if (!N) return null;
1352
- const O = N.dimensions[C], s = N.measures[C], _ = O || s;
1353
- if (!_) return null;
1354
- if (e === "where" && O) {
1350
+ const I = E, [t, C] = I.member.split("."), O = T.get(t);
1351
+ if (!O) return null;
1352
+ const N = O.dimensions[C], s = O.measures[C], r = N || s;
1353
+ if (!r) return null;
1354
+ if (e === "where" && N) {
1355
1355
  if (S?.preAggregationCTEs && S.preAggregationCTEs.some((o) => o.cube.name === t))
1356
1356
  return null;
1357
- const n = X(O.sql, A);
1358
- return this.buildFilterCondition(n, I.operator, I.values, _);
1357
+ const L = X(N.sql, A);
1358
+ return this.buildFilterCondition(
1359
+ L,
1360
+ I.operator,
1361
+ I.values,
1362
+ r,
1363
+ I.dateRange
1364
+ );
1359
1365
  } else {
1360
1366
  if (e === "where" && s)
1361
1367
  return null;
1362
1368
  if (e === "having" && s) {
1363
- const n = this.buildHavingMeasureExpression(t, C, s, A, S);
1364
- return this.buildFilterCondition(n, I.operator, I.values, _);
1369
+ const L = this.buildHavingMeasureExpression(t, C, s, A, S);
1370
+ return this.buildFilterCondition(
1371
+ L,
1372
+ I.operator,
1373
+ I.values,
1374
+ r,
1375
+ I.dateRange
1376
+ );
1365
1377
  }
1366
1378
  }
1367
1379
  return null;
@@ -1369,97 +1381,108 @@ class sR {
1369
1381
  /**
1370
1382
  * Build filter condition using Drizzle operators
1371
1383
  */
1372
- buildFilterCondition(E, T, A, e) {
1384
+ buildFilterCondition(E, T, A, e, S) {
1385
+ if (S !== void 0) {
1386
+ if (T !== "inDateRange")
1387
+ throw new Error(
1388
+ `dateRange can only be used with 'inDateRange' operator, but got '${T}'. Use explicit date values in the 'values' array for other date operators.`
1389
+ );
1390
+ if (e && e.type !== "time")
1391
+ throw new Error(
1392
+ `dateRange can only be used on time dimensions, but field '${e.name || "unknown"}' has type '${e.type}'`
1393
+ );
1394
+ return this.buildDateRangeCondition(E, S);
1395
+ }
1373
1396
  if (!A || A.length === 0)
1374
1397
  return T === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1375
- const S = A.filter((t) => !(t == null || t === "" || typeof t == "string" && t.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
1376
- if (S.length === 0 && !["set", "notSet"].includes(T))
1398
+ const I = A.filter((C) => !(C == null || C === "" || typeof C == "string" && C.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
1399
+ if (I.length === 0 && !["set", "notSet"].includes(T))
1377
1400
  return T === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1378
- const I = S[0];
1401
+ const t = I[0];
1379
1402
  switch (T) {
1380
1403
  case "equals":
1381
- if (S.length > 1) {
1404
+ if (I.length > 1) {
1382
1405
  if (e?.type === "time") {
1383
- const t = S.map((C) => this.normalizeDate(C) || C);
1384
- return OE(E, t);
1406
+ const C = I.map((O) => this.normalizeDate(O) || O);
1407
+ return OE(E, C);
1385
1408
  }
1386
- return OE(E, S);
1387
- } else if (S.length === 1) {
1388
- const t = e?.type === "time" && this.normalizeDate(I) || I;
1389
- return x(E, t);
1409
+ return OE(E, I);
1410
+ } else if (I.length === 1) {
1411
+ const C = e?.type === "time" && this.normalizeDate(t) || t;
1412
+ return x(E, C);
1390
1413
  }
1391
1414
  return this.databaseAdapter.buildBooleanLiteral(!1);
1392
1415
  case "notEquals":
1393
- return S.length > 1 ? gE(E, S) : S.length === 1 ? KE(E, I) : null;
1416
+ return I.length > 1 ? gE(E, I) : I.length === 1 ? KE(E, t) : null;
1394
1417
  case "contains":
1395
- return this.databaseAdapter.buildStringCondition(E, "contains", I);
1418
+ return this.databaseAdapter.buildStringCondition(E, "contains", t);
1396
1419
  case "notContains":
1397
- return this.databaseAdapter.buildStringCondition(E, "notContains", I);
1420
+ return this.databaseAdapter.buildStringCondition(E, "notContains", t);
1398
1421
  case "startsWith":
1399
- return this.databaseAdapter.buildStringCondition(E, "startsWith", I);
1422
+ return this.databaseAdapter.buildStringCondition(E, "startsWith", t);
1400
1423
  case "endsWith":
1401
- return this.databaseAdapter.buildStringCondition(E, "endsWith", I);
1424
+ return this.databaseAdapter.buildStringCondition(E, "endsWith", t);
1402
1425
  case "gt":
1403
- return tE(E, I);
1426
+ return tE(E, t);
1404
1427
  case "gte":
1405
- return $(E, I);
1428
+ return $(E, t);
1406
1429
  case "lt":
1407
- return NE(E, I);
1430
+ return NE(E, t);
1408
1431
  case "lte":
1409
- return g(E, I);
1432
+ return g(E, t);
1410
1433
  case "set":
1411
1434
  return yE(E);
1412
1435
  case "notSet":
1413
1436
  return $E(E);
1414
1437
  case "inDateRange":
1415
- if (S.length >= 2) {
1416
- const t = this.normalizeDate(S[0]);
1417
- let C = this.normalizeDate(S[1]);
1418
- if (t && C) {
1438
+ if (I.length >= 2) {
1439
+ const C = this.normalizeDate(I[0]);
1440
+ let O = this.normalizeDate(I[1]);
1441
+ if (C && O) {
1419
1442
  const N = A[1];
1420
1443
  if (typeof N == "string" && /^\d{4}-\d{2}-\d{2}$/.test(N.trim())) {
1421
- const O = typeof C == "number" ? new Date(C * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(C), s = new Date(O);
1422
- s.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? C = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(s.getTime() / 1e3) : s.getTime() : C = s.toISOString();
1444
+ const s = typeof O == "number" ? new Date(O * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(O), r = new Date(s);
1445
+ r.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? O = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(r.getTime() / 1e3) : r.getTime() : O = r.toISOString();
1423
1446
  }
1424
1447
  return p(
1425
- $(E, t),
1426
- g(E, C)
1448
+ $(E, C),
1449
+ g(E, O)
1427
1450
  );
1428
1451
  }
1429
1452
  }
1430
1453
  return null;
1431
1454
  case "beforeDate": {
1432
- const t = this.normalizeDate(I);
1433
- return t ? NE(E, t) : null;
1455
+ const C = this.normalizeDate(t);
1456
+ return C ? NE(E, C) : null;
1434
1457
  }
1435
1458
  case "afterDate": {
1436
- const t = this.normalizeDate(I);
1437
- return t ? tE(E, t) : null;
1459
+ const C = this.normalizeDate(t);
1460
+ return C ? tE(E, C) : null;
1438
1461
  }
1439
1462
  case "between":
1440
- return S.length >= 2 ? p(
1441
- $(E, S[0]),
1442
- g(E, S[1])
1463
+ return I.length >= 2 ? p(
1464
+ $(E, I[0]),
1465
+ g(E, I[1])
1443
1466
  ) : null;
1444
1467
  case "notBetween":
1445
- return S.length >= 2 ? IE(
1446
- NE(E, S[0]),
1447
- tE(E, S[1])
1468
+ return I.length >= 2 ? IE(
1469
+ NE(E, I[0]),
1470
+ tE(E, I[1])
1448
1471
  ) : null;
1449
1472
  case "in":
1450
- return S.length > 0 ? OE(E, S) : null;
1473
+ return I.length > 0 ? OE(E, I) : null;
1451
1474
  case "notIn":
1452
- return S.length > 0 ? gE(E, S) : null;
1475
+ return I.length > 0 ? gE(E, I) : null;
1453
1476
  case "like":
1454
- return this.databaseAdapter.buildStringCondition(E, "like", I);
1477
+ return this.databaseAdapter.buildStringCondition(E, "like", t);
1455
1478
  case "notLike":
1456
- return this.databaseAdapter.buildStringCondition(E, "notLike", I);
1479
+ return this.databaseAdapter.buildStringCondition(E, "notLike", t);
1457
1480
  case "ilike":
1458
- return this.databaseAdapter.buildStringCondition(E, "ilike", I);
1481
+ return this.databaseAdapter.buildStringCondition(E, "ilike", t);
1459
1482
  case "regex":
1460
- return this.databaseAdapter.buildStringCondition(E, "regex", I);
1483
+ return this.databaseAdapter.buildStringCondition(E, "regex", t);
1461
1484
  case "notRegex":
1462
- return this.databaseAdapter.buildStringCondition(E, "notRegex", I);
1485
+ return this.databaseAdapter.buildStringCondition(E, "notRegex", t);
1463
1486
  case "isEmpty":
1464
1487
  return IE(
1465
1488
  $E(E),
@@ -1495,9 +1518,9 @@ class sR {
1495
1518
  if (typeof T == "string") {
1496
1519
  const A = this.parseRelativeDateRange(T);
1497
1520
  if (A) {
1498
- let O, s;
1499
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (O = Math.floor(A.start.getTime() / 1e3), s = Math.floor(A.end.getTime() / 1e3)) : (O = A.start.getTime(), s = A.end.getTime()) : (O = A.start.toISOString(), s = A.end.toISOString()), p(
1500
- $(E, O),
1521
+ let N, s;
1522
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (N = Math.floor(A.start.getTime() / 1e3), s = Math.floor(A.end.getTime() / 1e3)) : (N = A.start.getTime(), s = A.end.getTime()) : (N = A.start.toISOString(), s = A.end.toISOString()), p(
1523
+ $(E, N),
1501
1524
  g(E, s)
1502
1525
  );
1503
1526
  }
@@ -1507,10 +1530,10 @@ class sR {
1507
1530
  I.setUTCHours(0, 0, 0, 0);
1508
1531
  const t = new Date(S);
1509
1532
  t.setUTCHours(23, 59, 59, 999);
1510
- let C, N;
1511
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (C = Math.floor(I.getTime() / 1e3), N = Math.floor(t.getTime() / 1e3)) : (C = I.getTime(), N = t.getTime()) : (C = I.toISOString(), N = t.toISOString()), p(
1533
+ let C, O;
1534
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (C = Math.floor(I.getTime() / 1e3), O = Math.floor(t.getTime() / 1e3)) : (C = I.getTime(), O = t.getTime()) : (C = I.toISOString(), O = t.toISOString()), p(
1512
1535
  $(E, C),
1513
- g(E, N)
1536
+ g(E, O)
1514
1537
  );
1515
1538
  }
1516
1539
  return null;
@@ -1522,73 +1545,80 @@ class sR {
1522
1545
  parseRelativeDateRange(E) {
1523
1546
  const T = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), e = T.getUTCFullYear(), S = T.getUTCMonth(), I = T.getUTCDate(), t = T.getUTCDay();
1524
1547
  if (A === "today") {
1525
- const s = new Date(T);
1526
- s.setUTCHours(0, 0, 0, 0);
1527
- const _ = new Date(T);
1528
- return _.setUTCHours(23, 59, 59, 999), { start: s, end: _ };
1548
+ const r = new Date(T);
1549
+ r.setUTCHours(0, 0, 0, 0);
1550
+ const L = new Date(T);
1551
+ return L.setUTCHours(23, 59, 59, 999), { start: r, end: L };
1529
1552
  }
1530
1553
  if (A === "yesterday") {
1531
- const s = new Date(T);
1532
- s.setUTCDate(I - 1), s.setUTCHours(0, 0, 0, 0);
1533
- const _ = new Date(T);
1534
- return _.setUTCDate(I - 1), _.setUTCHours(23, 59, 59, 999), { start: s, end: _ };
1554
+ const r = new Date(T);
1555
+ r.setUTCDate(I - 1), r.setUTCHours(0, 0, 0, 0);
1556
+ const L = new Date(T);
1557
+ return L.setUTCDate(I - 1), L.setUTCHours(23, 59, 59, 999), { start: r, end: L };
1535
1558
  }
1536
1559
  if (A === "this week") {
1537
- const s = t === 0 ? -6 : 1 - t, _ = new Date(T);
1538
- _.setUTCDate(I + s), _.setUTCHours(0, 0, 0, 0);
1539
- const n = new Date(_);
1540
- return n.setUTCDate(_.getUTCDate() + 6), n.setUTCHours(23, 59, 59, 999), { start: _, end: n };
1560
+ const r = t === 0 ? -6 : 1 - t, L = new Date(T);
1561
+ L.setUTCDate(I + r), L.setUTCHours(0, 0, 0, 0);
1562
+ const i = new Date(L);
1563
+ return i.setUTCDate(L.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
1541
1564
  }
1542
1565
  if (A === "this month") {
1543
- const s = new Date(Date.UTC(e, S, 1, 0, 0, 0, 0)), _ = new Date(Date.UTC(e, S + 1, 0, 23, 59, 59, 999));
1544
- return { start: s, end: _ };
1566
+ const r = new Date(Date.UTC(e, S, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, S + 1, 0, 23, 59, 59, 999));
1567
+ return { start: r, end: L };
1545
1568
  }
1546
1569
  if (A === "this quarter") {
1547
- const s = Math.floor(S / 3), _ = new Date(Date.UTC(e, s * 3, 1, 0, 0, 0, 0)), n = new Date(Date.UTC(e, s * 3 + 3, 0, 23, 59, 59, 999));
1548
- return { start: _, end: n };
1570
+ const r = Math.floor(S / 3), L = new Date(Date.UTC(e, r * 3, 1, 0, 0, 0, 0)), i = new Date(Date.UTC(e, r * 3 + 3, 0, 23, 59, 59, 999));
1571
+ return { start: L, end: i };
1549
1572
  }
1550
1573
  if (A === "this year") {
1551
- const s = new Date(Date.UTC(e, 0, 1, 0, 0, 0, 0)), _ = new Date(Date.UTC(e, 11, 31, 23, 59, 59, 999));
1552
- return { start: s, end: _ };
1574
+ const r = new Date(Date.UTC(e, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, 11, 31, 23, 59, 59, 999));
1575
+ return { start: r, end: L };
1553
1576
  }
1554
1577
  const C = A.match(/^last\s+(\d+)\s+days?$/);
1555
1578
  if (C) {
1556
- const s = parseInt(C[1], 10), _ = new Date(T);
1557
- _.setUTCDate(I - s + 1), _.setUTCHours(0, 0, 0, 0);
1558
- const n = new Date(T);
1559
- return n.setUTCHours(23, 59, 59, 999), { start: _, end: n };
1579
+ const r = parseInt(C[1], 10), L = new Date(T);
1580
+ L.setUTCDate(I - r + 1), L.setUTCHours(0, 0, 0, 0);
1581
+ const i = new Date(T);
1582
+ return i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
1583
+ }
1584
+ const O = A.match(/^last\s+(\d+)\s+weeks?$/);
1585
+ if (O) {
1586
+ const L = parseInt(O[1], 10) * 7, i = new Date(T);
1587
+ i.setUTCDate(I - L + 1), i.setUTCHours(0, 0, 0, 0);
1588
+ const o = new Date(T);
1589
+ return o.setUTCHours(23, 59, 59, 999), { start: i, end: o };
1560
1590
  }
1561
1591
  if (A === "last week") {
1562
- const s = t === 0 ? -13 : -6 - t, _ = new Date(T);
1563
- _.setUTCDate(I + s), _.setUTCHours(0, 0, 0, 0);
1564
- const n = new Date(_);
1565
- return n.setUTCDate(_.getUTCDate() + 6), n.setUTCHours(23, 59, 59, 999), { start: _, end: n };
1592
+ const r = t === 0 ? -13 : -6 - t, L = new Date(T);
1593
+ L.setUTCDate(I + r), L.setUTCHours(0, 0, 0, 0);
1594
+ const i = new Date(L);
1595
+ return i.setUTCDate(L.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
1566
1596
  }
1567
1597
  if (A === "last month") {
1568
- const s = new Date(Date.UTC(e, S - 1, 1, 0, 0, 0, 0)), _ = new Date(Date.UTC(e, S, 0, 23, 59, 59, 999));
1569
- return { start: s, end: _ };
1598
+ const r = new Date(Date.UTC(e, S - 1, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, S, 0, 23, 59, 59, 999));
1599
+ return { start: r, end: L };
1570
1600
  }
1571
1601
  if (A === "last quarter") {
1572
- const s = Math.floor(S / 3), _ = s === 0 ? 3 : s - 1, n = s === 0 ? e - 1 : e, D = new Date(Date.UTC(n, _ * 3, 1, 0, 0, 0, 0)), o = new Date(Date.UTC(n, _ * 3 + 3, 0, 23, 59, 59, 999));
1573
- return { start: D, end: o };
1602
+ const r = Math.floor(S / 3), L = r === 0 ? 3 : r - 1, i = r === 0 ? e - 1 : e, o = new Date(Date.UTC(i, L * 3, 1, 0, 0, 0, 0)), l = new Date(Date.UTC(i, L * 3 + 3, 0, 23, 59, 59, 999));
1603
+ return { start: o, end: l };
1574
1604
  }
1575
1605
  if (A === "last year") {
1576
- const s = new Date(Date.UTC(e - 1, 0, 1, 0, 0, 0, 0)), _ = new Date(Date.UTC(e - 1, 11, 31, 23, 59, 59, 999));
1577
- return { start: s, end: _ };
1606
+ const r = new Date(Date.UTC(e - 1, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e - 1, 11, 31, 23, 59, 59, 999));
1607
+ return { start: r, end: L };
1578
1608
  }
1579
1609
  if (A === "last 12 months") {
1580
- const s = new Date(Date.UTC(e, S - 11, 1, 0, 0, 0, 0)), _ = new Date(T);
1581
- return _.setUTCHours(23, 59, 59, 999), { start: s, end: _ };
1610
+ const r = new Date(Date.UTC(e, S - 11, 1, 0, 0, 0, 0)), L = new Date(T);
1611
+ return L.setUTCHours(23, 59, 59, 999), { start: r, end: L };
1582
1612
  }
1583
1613
  const N = A.match(/^last\s+(\d+)\s+months?$/);
1584
1614
  if (N) {
1585
- const s = parseInt(N[1], 10), _ = new Date(Date.UTC(e, S - s + 1, 1, 0, 0, 0, 0)), n = new Date(T);
1586
- return n.setUTCHours(23, 59, 59, 999), { start: _, end: n };
1615
+ const r = parseInt(N[1], 10), L = new Date(Date.UTC(e, S - r + 1, 1, 0, 0, 0, 0)), i = new Date(T);
1616
+ return i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
1587
1617
  }
1588
- const O = A.match(/^last\s+(\d+)\s+years?$/);
1589
- if (O) {
1590
- const s = parseInt(O[1], 10), _ = new Date(Date.UTC(e - s, 0, 1, 0, 0, 0, 0)), n = new Date(T);
1591
- return n.setUTCHours(23, 59, 59, 999), { start: _, end: n };
1618
+ const s = A.match(/^last\s+(\d+)\s+years?$/);
1619
+ if (s) {
1620
+ const r = parseInt(s[1], 10), L = new Date(Date.UTC(e - r, 0, 1, 0, 0, 0, 0)), i = new Date(T);
1621
+ return i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
1592
1622
  }
1593
1623
  return null;
1594
1624
  }
@@ -1627,45 +1657,45 @@ class sR {
1627
1657
  const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1628
1658
  if (T.dimensions)
1629
1659
  for (const C of T.dimensions) {
1630
- const [N, O] = C.split("."), s = t.get(N);
1631
- if (s && s.dimensions && s.dimensions[O])
1632
- if (e?.preAggregationCTEs?.some((n) => n.cube.name === N)) {
1633
- const n = e.preAggregationCTEs.find((o) => o.cube.name === N), D = n.joinKeys.find((o) => o.targetColumn === O);
1634
- if (D && D.sourceColumnObj)
1635
- S.push(D.sourceColumnObj);
1660
+ const [O, N] = C.split("."), s = t.get(O);
1661
+ if (s && s.dimensions && s.dimensions[N])
1662
+ if (e?.preAggregationCTEs?.some((L) => L.cube.name === O)) {
1663
+ const L = e.preAggregationCTEs.find((o) => o.cube.name === O), i = L.joinKeys.find((o) => o.targetColumn === N);
1664
+ if (i && i.sourceColumnObj)
1665
+ S.push(i.sourceColumnObj);
1636
1666
  else {
1637
- const o = r`${r.identifier(n.cteAlias)}.${r.identifier(O)}`;
1667
+ const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
1638
1668
  S.push(o);
1639
1669
  }
1640
1670
  } else {
1641
- const n = s.dimensions[O], D = X(n.sql, A);
1642
- S.push(D);
1671
+ const L = s.dimensions[N], i = X(L.sql, A);
1672
+ S.push(i);
1643
1673
  }
1644
1674
  }
1645
1675
  if (T.timeDimensions)
1646
1676
  for (const C of T.timeDimensions) {
1647
- const [N, O] = C.dimension.split("."), s = t.get(N);
1648
- if (s && s.dimensions && s.dimensions[O])
1649
- if (e?.preAggregationCTEs?.some((n) => n.cube.name === N)) {
1650
- const n = e.preAggregationCTEs.find((o) => o.cube.name === N), D = n.joinKeys.find((o) => o.targetColumn === O);
1651
- if (D && D.sourceColumnObj) {
1677
+ const [O, N] = C.dimension.split("."), s = t.get(O);
1678
+ if (s && s.dimensions && s.dimensions[N])
1679
+ if (e?.preAggregationCTEs?.some((L) => L.cube.name === O)) {
1680
+ const L = e.preAggregationCTEs.find((o) => o.cube.name === O), i = L.joinKeys.find((o) => o.targetColumn === N);
1681
+ if (i && i.sourceColumnObj) {
1652
1682
  const o = this.buildTimeDimensionExpression(
1653
- D.sourceColumnObj,
1683
+ i.sourceColumnObj,
1654
1684
  C.granularity,
1655
1685
  A
1656
1686
  );
1657
1687
  S.push(o);
1658
1688
  } else {
1659
- const o = r`${r.identifier(n.cteAlias)}.${r.identifier(O)}`;
1689
+ const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
1660
1690
  S.push(o);
1661
1691
  }
1662
1692
  } else {
1663
- const n = s.dimensions[O], D = this.buildTimeDimensionExpression(
1664
- n.sql,
1693
+ const L = s.dimensions[N], i = this.buildTimeDimensionExpression(
1694
+ L.sql,
1665
1695
  C.granularity,
1666
1696
  A
1667
1697
  );
1668
- S.push(D);
1698
+ S.push(i);
1669
1699
  }
1670
1700
  }
1671
1701
  return S;
@@ -1683,7 +1713,7 @@ class sR {
1683
1713
  for (const [S, I] of Object.entries(E.order)) {
1684
1714
  if (!e.includes(S))
1685
1715
  throw new Error(`Cannot order by '${S}': field is not selected in the query`);
1686
- const t = I === "desc" ? ZT(r.identifier(S)) : wE(r.identifier(S));
1716
+ const t = I === "desc" ? ZT(n.identifier(S)) : wE(n.identifier(S));
1687
1717
  A.push(t);
1688
1718
  }
1689
1719
  if (E.timeDimensions && E.timeDimensions.length > 0) {
@@ -1691,7 +1721,7 @@ class sR {
1691
1721
  (t, C) => t.dimension.localeCompare(C.dimension)
1692
1722
  );
1693
1723
  for (const t of I)
1694
- S.has(t.dimension) || A.push(wE(r.identifier(t.dimension)));
1724
+ S.has(t.dimension) || A.push(wE(n.identifier(t.dimension)));
1695
1725
  }
1696
1726
  return A;
1697
1727
  }
@@ -1705,8 +1735,8 @@ class sR {
1705
1735
  for (const S of T.dimensions) {
1706
1736
  const [I, t] = S.split("."), C = e.get(I);
1707
1737
  if (C) {
1708
- const N = C.dimensions[t];
1709
- N && N.type === "number" && A.push(S);
1738
+ const O = C.dimensions[t];
1739
+ O && O.type === "number" && A.push(S);
1710
1740
  }
1711
1741
  }
1712
1742
  return A;
@@ -1821,7 +1851,7 @@ class CR {
1821
1851
  groupByFields: []
1822
1852
  // Will be built by QueryBuilder
1823
1853
  };
1824
- const C = this.buildJoinPlan(E, t, S, A), N = this.planPreAggregationCTEs(E, t, C, T);
1854
+ const C = this.buildJoinPlan(E, t, S, A), O = this.planPreAggregationCTEs(E, t, C, T);
1825
1855
  return {
1826
1856
  primaryCube: t,
1827
1857
  joinCubes: C,
@@ -1831,7 +1861,7 @@ class CR {
1831
1861
  // Will be built by QueryBuilder
1832
1862
  groupByFields: [],
1833
1863
  // Will be built by QueryBuilder
1834
- preAggregationCTEs: N
1864
+ preAggregationCTEs: O
1835
1865
  };
1836
1866
  }
1837
1867
  /**
@@ -1885,48 +1915,48 @@ class CR {
1885
1915
  for (const C of t) {
1886
1916
  if (I.has(C))
1887
1917
  continue;
1888
- const N = this.findJoinPath(E, T.name, C, I);
1889
- if (!N || N.length === 0)
1918
+ const O = this.findJoinPath(E, T.name, C, I);
1919
+ if (!O || O.length === 0)
1890
1920
  throw new Error(`No join path found from '${T.name}' to '${C}'`);
1891
- for (const { toCube: O, joinDef: s } of N) {
1892
- if (I.has(O))
1921
+ for (const { toCube: N, joinDef: s } of O) {
1922
+ if (I.has(N))
1893
1923
  continue;
1894
- const _ = E.get(O);
1895
- if (!_)
1896
- throw new Error(`Cube '${O}' not found`);
1924
+ const r = E.get(N);
1925
+ if (!r)
1926
+ throw new Error(`Cube '${N}' not found`);
1897
1927
  if (s.relationship === "belongsToMany" && s.through) {
1898
- const n = IR(s, e.securityContext);
1928
+ const L = IR(s, e.securityContext);
1899
1929
  S.push({
1900
- cube: _,
1901
- alias: `${O.toLowerCase()}_cube`,
1902
- joinType: n.junctionJoins[1].joinType,
1930
+ cube: r,
1931
+ alias: `${N.toLowerCase()}_cube`,
1932
+ joinType: L.junctionJoins[1].joinType,
1903
1933
  // Use the target join type
1904
- joinCondition: n.junctionJoins[1].condition,
1934
+ joinCondition: L.junctionJoins[1].condition,
1905
1935
  // Target join condition
1906
1936
  junctionTable: {
1907
1937
  table: s.through.table,
1908
- alias: `junction_${O.toLowerCase()}`,
1909
- joinType: n.junctionJoins[0].joinType,
1910
- joinCondition: n.junctionJoins[0].condition,
1938
+ alias: `junction_${N.toLowerCase()}`,
1939
+ joinType: L.junctionJoins[0].joinType,
1940
+ joinCondition: L.junctionJoins[0].condition,
1911
1941
  securitySql: s.through.securitySql
1912
1942
  }
1913
1943
  });
1914
1944
  } else {
1915
- const n = this.buildJoinCondition(
1945
+ const L = this.buildJoinCondition(
1916
1946
  s,
1917
1947
  null,
1918
1948
  // No source alias needed - use the actual column
1919
1949
  null
1920
1950
  // No target alias needed - use the actual column
1921
- ), D = dT(s.relationship, s.sqlJoinType);
1951
+ ), i = dT(s.relationship, s.sqlJoinType);
1922
1952
  S.push({
1923
- cube: _,
1924
- alias: `${O.toLowerCase()}_cube`,
1925
- joinType: D,
1926
- joinCondition: n
1953
+ cube: r,
1954
+ alias: `${N.toLowerCase()}_cube`,
1955
+ joinType: i,
1956
+ joinCondition: L
1927
1957
  });
1928
1958
  }
1929
- I.add(O);
1959
+ I.add(N);
1930
1960
  }
1931
1961
  }
1932
1962
  return S;
@@ -1937,7 +1967,7 @@ class CR {
1937
1967
  buildJoinCondition(E, T, A) {
1938
1968
  const e = [];
1939
1969
  for (const S of E.on) {
1940
- const I = T ? r`${r.identifier(T)}.${r.identifier(S.source.name)}` : S.source, t = A ? r`${r.identifier(A)}.${r.identifier(S.target.name)}` : S.target, C = S.as || x;
1970
+ const I = T ? n`${n.identifier(T)}.${n.identifier(S.source.name)}` : S.source, t = A ? n`${n.identifier(A)}.${n.identifier(S.target.name)}` : S.target, C = S.as || x;
1941
1971
  e.push(C(I, t));
1942
1972
  }
1943
1973
  return p(...e);
@@ -1953,20 +1983,20 @@ class CR {
1953
1983
  { cube: T, path: [] }
1954
1984
  ], I = /* @__PURE__ */ new Set([T, ...e]);
1955
1985
  for (; S.length > 0; ) {
1956
- const { cube: t, path: C } = S.shift(), N = E.get(t);
1957
- if (N?.joins)
1958
- for (const [, O] of Object.entries(N.joins)) {
1959
- const _ = QE(O.targetCube).name;
1960
- if (I.has(_))
1986
+ const { cube: t, path: C } = S.shift(), O = E.get(t);
1987
+ if (O?.joins)
1988
+ for (const [, N] of Object.entries(O.joins)) {
1989
+ const r = QE(N.targetCube).name;
1990
+ if (I.has(r))
1961
1991
  continue;
1962
- const n = [...C, {
1992
+ const L = [...C, {
1963
1993
  fromCube: t,
1964
- toCube: _,
1965
- joinDef: O
1994
+ toCube: r,
1995
+ joinDef: N
1966
1996
  }];
1967
- if (_ === A)
1968
- return n;
1969
- I.add(_), S.push({ cube: _, path: n });
1997
+ if (r === A)
1998
+ return L;
1999
+ I.add(r), S.push({ cube: r, path: L });
1970
2000
  }
1971
2001
  }
1972
2002
  return null;
@@ -1985,24 +2015,24 @@ class CR {
1985
2015
  if (!t)
1986
2016
  continue;
1987
2017
  const C = e.measures ? e.measures.filter(
1988
- (n) => n.startsWith(I.cube.name + ".")
1989
- ) : [], N = this.extractMeasuresFromFilters(e, I.cube.name), O = [.../* @__PURE__ */ new Set([...C, ...N])];
1990
- if (O.length === 0)
2018
+ (L) => L.startsWith(I.cube.name + ".")
2019
+ ) : [], O = this.extractMeasuresFromFilters(e, I.cube.name), N = [.../* @__PURE__ */ new Set([...C, ...O])];
2020
+ if (N.length === 0)
1991
2021
  continue;
1992
2022
  const s = this.expandCalculatedMeasureDependencies(
1993
2023
  I.cube,
1994
- O
1995
- ), _ = t.on.map((n) => ({
1996
- sourceColumn: n.source.name,
1997
- targetColumn: n.target.name,
1998
- sourceColumnObj: n.source,
1999
- targetColumnObj: n.target
2024
+ N
2025
+ ), r = t.on.map((L) => ({
2026
+ sourceColumn: L.source.name,
2027
+ targetColumn: L.target.name,
2028
+ sourceColumnObj: L.source,
2029
+ targetColumnObj: L.target
2000
2030
  }));
2001
2031
  S.push({
2002
2032
  cube: I.cube,
2003
2033
  alias: I.alias,
2004
2034
  cteAlias: `${I.cube.name.toLowerCase()}_agg`,
2005
- joinKeys: _,
2035
+ joinKeys: r,
2006
2036
  measures: s
2007
2037
  });
2008
2038
  }
@@ -2024,8 +2054,8 @@ class CR {
2024
2054
  const t = E.measures[I];
2025
2055
  if (t.type === "calculated" && t.calculatedSql) {
2026
2056
  const C = this.extractDependenciesFromTemplate(t.calculatedSql, E.name);
2027
- for (const N of C)
2028
- A.has(N) || e.push(N);
2057
+ for (const O of C)
2058
+ A.has(O) || e.push(O);
2029
2059
  }
2030
2060
  }
2031
2061
  return Array.from(A);
@@ -2074,23 +2104,23 @@ class CE {
2074
2104
  db: this.dbExecutor.db,
2075
2105
  schema: this.dbExecutor.schema,
2076
2106
  securityContext: A
2077
- }, I = this.queryPlanner.createQueryPlan(E, T, S), t = this.buildUnifiedQuery(I, T, S), C = this.queryBuilder.collectNumericFields(E, T), N = await this.dbExecutor.execute(t, C), O = Array.isArray(N) ? N.map((_) => {
2078
- const n = { ..._ };
2107
+ }, I = this.queryPlanner.createQueryPlan(E, T, S), t = this.buildUnifiedQuery(I, T, S), C = this.queryBuilder.collectNumericFields(E, T), O = await this.dbExecutor.execute(t, C), N = Array.isArray(O) ? O.map((r) => {
2108
+ const L = { ...r };
2079
2109
  if (T.timeDimensions) {
2080
- for (const D of T.timeDimensions)
2081
- if (D.dimension in n) {
2082
- let o = n[D.dimension];
2110
+ for (const i of T.timeDimensions)
2111
+ if (i.dimension in L) {
2112
+ let o = L[i.dimension];
2083
2113
  if (typeof o == "string" && o.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
2084
2114
  const l = o.replace(" ", "T"), P = !l.endsWith("Z") && !l.includes("+") ? l + "Z" : l;
2085
2115
  o = new Date(P);
2086
2116
  }
2087
- o = this.databaseAdapter.convertTimeDimensionResult(o), n[D.dimension] = o;
2117
+ o = this.databaseAdapter.convertTimeDimensionResult(o), L[i.dimension] = o;
2088
2118
  }
2089
2119
  }
2090
- return n;
2091
- }) : [N], s = this.generateAnnotations(I, T);
2120
+ return L;
2121
+ }) : [O], s = this.generateAnnotations(I, T);
2092
2122
  return {
2093
- data: O,
2123
+ data: N,
2094
2124
  annotation: s
2095
2125
  };
2096
2126
  } catch (e) {
@@ -2113,18 +2143,18 @@ class CE {
2113
2143
  if (P.targetColumnObj) {
2114
2144
  t[P.targetColumn] = P.targetColumnObj;
2115
2145
  for (const [c, M] of Object.entries(S.dimensions || {}))
2116
- M.sql === P.targetColumnObj && c !== P.targetColumn && (t[c] = r`${P.targetColumnObj}`.as(c));
2146
+ M.sql === P.targetColumnObj && c !== P.targetColumn && (t[c] = n`${P.targetColumnObj}`.as(c));
2117
2147
  }
2118
- const C = S.name, N = /* @__PURE__ */ new Map([[C, S]]), O = this.queryBuilder.buildResolvedMeasures(
2148
+ const C = S.name, O = /* @__PURE__ */ new Map([[C, S]]), N = this.queryBuilder.buildResolvedMeasures(
2119
2149
  E.measures,
2120
- N,
2150
+ O,
2121
2151
  A
2122
2152
  );
2123
2153
  for (const P of E.measures) {
2124
- const [, c] = P.split("."), M = O.get(P);
2154
+ const [, c] = P.split("."), M = N.get(P);
2125
2155
  if (M) {
2126
2156
  const u = M();
2127
- t[c] = r`${u}`.as(c);
2157
+ t[c] = n`${u}`.as(c);
2128
2158
  }
2129
2159
  }
2130
2160
  if (T.dimensions)
@@ -2132,7 +2162,7 @@ class CE {
2132
2162
  const [c, M] = P.split(".");
2133
2163
  if (c === C && S.dimensions && S.dimensions[M]) {
2134
2164
  const u = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: u.sql, type: "number" }, A);
2135
- t[M] = r`${H}`.as(M);
2165
+ t[M] = n`${H}`.as(M);
2136
2166
  }
2137
2167
  }
2138
2168
  if (T.timeDimensions)
@@ -2140,22 +2170,22 @@ class CE {
2140
2170
  const [c, M] = P.dimension.split(".");
2141
2171
  if (c === C && S.dimensions && S.dimensions[M]) {
2142
2172
  const u = S.dimensions[M], H = this.queryBuilder.buildTimeDimensionExpression(u.sql, P.granularity, A);
2143
- t[M] = r`${H}`.as(M);
2173
+ t[M] = n`${H}`.as(M);
2144
2174
  }
2145
2175
  }
2146
2176
  if (Object.keys(t).length === 0)
2147
2177
  return null;
2148
2178
  let s = A.db.select(t).from(I.from);
2149
- const _ = e ? {
2179
+ const r = e ? {
2150
2180
  ...e,
2151
2181
  preAggregationCTEs: e.preAggregationCTEs?.filter((P) => P.cube.name !== S.name)
2152
- } : void 0, n = this.queryBuilder.buildWhereConditions(S, T, A, _), D = [];
2182
+ } : void 0, L = this.queryBuilder.buildWhereConditions(S, T, A, r), i = [];
2153
2183
  if (T.timeDimensions)
2154
2184
  for (const P of T.timeDimensions) {
2155
2185
  const [c, M] = P.dimension.split(".");
2156
2186
  if (c === C && S.dimensions && S.dimensions[M] && P.dateRange) {
2157
2187
  const u = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: u.sql, type: "number" }, A), B = this.queryBuilder.buildDateRangeCondition(H, P.dateRange);
2158
- B && D.push(B);
2188
+ B && i.push(B);
2159
2189
  }
2160
2190
  }
2161
2191
  if (T.filters) {
@@ -2166,13 +2196,13 @@ class CE {
2166
2196
  const H = S.dimensions[u];
2167
2197
  if (c.operator === "inDateRange") {
2168
2198
  const B = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, A), Y = this.queryBuilder.buildDateRangeCondition(B, c.values);
2169
- Y && D.push(Y);
2199
+ Y && i.push(Y);
2170
2200
  }
2171
2201
  }
2172
2202
  }
2173
2203
  }
2174
2204
  const o = [];
2175
- if (I.where && o.push(I.where), o.push(...n, ...D), o.length > 0) {
2205
+ if (I.where && o.push(I.where), o.push(...L, ...i), o.length > 0) {
2176
2206
  const P = o.length === 1 ? o[0] : p(...o);
2177
2207
  s = s.where(P);
2178
2208
  }
@@ -2207,7 +2237,7 @@ class CE {
2207
2237
  throw new Error(`CTE info not found for cube ${E.cube.name}`);
2208
2238
  const S = [];
2209
2239
  for (const I of e.joinKeys) {
2210
- const t = I.sourceColumnObj || r.identifier(I.sourceColumn), C = r`${r.identifier(T)}.${r.identifier(I.targetColumn)}`;
2240
+ const t = I.sourceColumnObj || n.identifier(I.sourceColumn), C = n`${n.identifier(T)}.${n.identifier(I.targetColumn)}`;
2211
2241
  S.push(x(t, C));
2212
2242
  }
2213
2243
  return S.length === 1 ? S[0] : p(...S);
@@ -2247,7 +2277,7 @@ class CE {
2247
2277
  A
2248
2278
  );
2249
2279
  } else {
2250
- const B = r`${r.identifier(o.cteAlias)}.${r.identifier(c)}`;
2280
+ const B = n`${n.identifier(o.cteAlias)}.${n.identifier(c)}`;
2251
2281
  switch (u.type) {
2252
2282
  case "count":
2253
2283
  case "countDistinct":
@@ -2270,7 +2300,7 @@ class CE {
2270
2300
  H = f(B);
2271
2301
  }
2272
2302
  }
2273
- C[P] = r`${H}`.as(P);
2303
+ C[P] = n`${H}`.as(P);
2274
2304
  }
2275
2305
  }
2276
2306
  for (const P in C) {
@@ -2283,27 +2313,27 @@ class CE {
2283
2313
  const eE = u.dimensions[M].sql;
2284
2314
  Y = o.joinKeys.find((JT) => JT.targetColumnObj === eE);
2285
2315
  }
2286
- Y ? C[P] = r`${r.identifier(o.cteAlias)}.${r.identifier(M)}`.as(P) : B && u?.dimensions?.[M] && (C[P] = r`${r.identifier(o.cteAlias)}.${r.identifier(M)}`.as(P));
2316
+ Y ? C[P] = n`${n.identifier(o.cteAlias)}.${n.identifier(M)}`.as(P) : B && u?.dimensions?.[M] && (C[P] = n`${n.identifier(o.cteAlias)}.${n.identifier(M)}`.as(P));
2287
2317
  }
2288
2318
  }
2289
2319
  }
2290
2320
  }
2291
- const N = [];
2292
- let O = A.db.select(C).from(I.from);
2293
- if (e.length > 0 && (O = A.db.with(...e).select(C).from(I.from)), I.joins)
2321
+ const O = [];
2322
+ let N = A.db.select(C).from(I.from);
2323
+ if (e.length > 0 && (N = A.db.with(...e).select(C).from(I.from)), I.joins)
2294
2324
  for (const o of I.joins)
2295
2325
  switch (o.type || "left") {
2296
2326
  case "left":
2297
- O = O.leftJoin(o.table, o.on);
2327
+ N = N.leftJoin(o.table, o.on);
2298
2328
  break;
2299
2329
  case "inner":
2300
- O = O.innerJoin(o.table, o.on);
2330
+ N = N.innerJoin(o.table, o.on);
2301
2331
  break;
2302
2332
  case "right":
2303
- O = O.rightJoin(o.table, o.on);
2333
+ N = N.rightJoin(o.table, o.on);
2304
2334
  break;
2305
2335
  case "full":
2306
- O = O.fullJoin(o.table, o.on);
2336
+ N = N.fullJoin(o.table, o.on);
2307
2337
  break;
2308
2338
  }
2309
2339
  if (E.joinCubes && E.joinCubes.length > 0)
@@ -2318,48 +2348,48 @@ class CE {
2318
2348
  try {
2319
2349
  switch (M.joinType || "left") {
2320
2350
  case "left":
2321
- O = O.leftJoin(M.table, M.joinCondition);
2351
+ N = N.leftJoin(M.table, M.joinCondition);
2322
2352
  break;
2323
2353
  case "inner":
2324
- O = O.innerJoin(M.table, M.joinCondition);
2354
+ N = N.innerJoin(M.table, M.joinCondition);
2325
2355
  break;
2326
2356
  case "right":
2327
- O = O.rightJoin(M.table, M.joinCondition);
2357
+ N = N.rightJoin(M.table, M.joinCondition);
2328
2358
  break;
2329
2359
  case "full":
2330
- O = O.fullJoin(M.table, M.joinCondition);
2360
+ N = N.fullJoin(M.table, M.joinCondition);
2331
2361
  break;
2332
2362
  }
2333
- u.length > 0 && N.push(...u);
2363
+ u.length > 0 && O.push(...u);
2334
2364
  } catch {
2335
2365
  }
2336
2366
  }
2337
2367
  let P, c;
2338
- l ? (P = r`${r.identifier(l)}`, c = this.buildCTEJoinCondition(o, l, E)) : (P = o.cube.sql(A).from, c = o.joinCondition);
2368
+ l ? (P = n`${n.identifier(l)}`, c = this.buildCTEJoinCondition(o, l, E)) : (P = o.cube.sql(A).from, c = o.joinCondition);
2339
2369
  try {
2340
2370
  switch (o.joinType || "left") {
2341
2371
  case "left":
2342
- O = O.leftJoin(P, c);
2372
+ N = N.leftJoin(P, c);
2343
2373
  break;
2344
2374
  case "inner":
2345
- O = O.innerJoin(P, c);
2375
+ N = N.innerJoin(P, c);
2346
2376
  break;
2347
2377
  case "right":
2348
- O = O.rightJoin(P, c);
2378
+ N = N.rightJoin(P, c);
2349
2379
  break;
2350
2380
  case "full":
2351
- O = O.fullJoin(P, c);
2381
+ N = N.fullJoin(P, c);
2352
2382
  break;
2353
2383
  }
2354
2384
  } catch {
2355
2385
  }
2356
2386
  }
2357
- if (I.where && N.push(I.where), E.joinCubes && E.joinCubes.length > 0)
2387
+ if (I.where && O.push(I.where), E.joinCubes && E.joinCubes.length > 0)
2358
2388
  for (const o of E.joinCubes) {
2359
2389
  if (S.get(o.cube.name))
2360
2390
  continue;
2361
2391
  const P = o.cube.sql(A);
2362
- P.where && N.push(P.where);
2392
+ P.where && O.push(P.where);
2363
2393
  }
2364
2394
  const s = this.queryBuilder.buildWhereConditions(
2365
2395
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
@@ -2369,11 +2399,11 @@ class CE {
2369
2399
  E
2370
2400
  // Pass the queryPlan to handle CTE scenarios
2371
2401
  );
2372
- if (s.length > 0 && N.push(...s), N.length > 0) {
2373
- const o = N.length === 1 ? N[0] : p(...N);
2374
- O = O.where(o);
2402
+ if (s.length > 0 && O.push(...s), O.length > 0) {
2403
+ const o = O.length === 1 ? O[0] : p(...O);
2404
+ N = N.where(o);
2375
2405
  }
2376
- const _ = this.queryBuilder.buildGroupByFields(
2406
+ const r = this.queryBuilder.buildGroupByFields(
2377
2407
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2378
2408
  // Single cube
2379
2409
  T,
@@ -2381,8 +2411,8 @@ class CE {
2381
2411
  E
2382
2412
  // Pass the queryPlan to handle CTE scenarios
2383
2413
  );
2384
- _.length > 0 && (O = O.groupBy(..._));
2385
- const n = this.queryBuilder.buildHavingConditions(
2414
+ r.length > 0 && (N = N.groupBy(...r));
2415
+ const L = this.queryBuilder.buildHavingConditions(
2386
2416
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2387
2417
  // Single cube
2388
2418
  T,
@@ -2390,12 +2420,12 @@ class CE {
2390
2420
  E
2391
2421
  // Pass the queryPlan to handle CTE scenarios
2392
2422
  );
2393
- if (n.length > 0) {
2394
- const o = n.length === 1 ? n[0] : p(...n);
2395
- O = O.having(o);
2423
+ if (L.length > 0) {
2424
+ const o = L.length === 1 ? L[0] : p(...L);
2425
+ N = N.having(o);
2396
2426
  }
2397
- const D = this.queryBuilder.buildOrderBy(T);
2398
- return D.length > 0 && (O = O.orderBy(...D)), O = this.queryBuilder.applyLimitAndOffset(O, T), O;
2427
+ const i = this.queryBuilder.buildOrderBy(T);
2428
+ return i.length > 0 && (N = N.orderBy(...i)), N = this.queryBuilder.applyLimitAndOffset(N, T), N;
2399
2429
  }
2400
2430
  /**
2401
2431
  * Convert query plan to cube map for QueryBuilder methods
@@ -2441,36 +2471,36 @@ class CE {
2441
2471
  const A = {}, e = {}, S = {}, I = [E.primaryCube];
2442
2472
  if (E.joinCubes && E.joinCubes.length > 0 && I.push(...E.joinCubes.map((t) => t.cube)), T.measures)
2443
2473
  for (const t of T.measures) {
2444
- const [C, N] = t.split("."), O = I.find((s) => s.name === C);
2445
- if (O && O.measures[N]) {
2446
- const s = O.measures[N];
2474
+ const [C, O] = t.split("."), N = I.find((s) => s.name === C);
2475
+ if (N && N.measures[O]) {
2476
+ const s = N.measures[O];
2447
2477
  A[t] = {
2448
- title: s.title || N,
2449
- shortTitle: s.title || N,
2478
+ title: s.title || O,
2479
+ shortTitle: s.title || O,
2450
2480
  type: s.type
2451
2481
  };
2452
2482
  }
2453
2483
  }
2454
2484
  if (T.dimensions)
2455
2485
  for (const t of T.dimensions) {
2456
- const [C, N] = t.split("."), O = I.find((s) => s.name === C);
2457
- if (O && O.dimensions[N]) {
2458
- const s = O.dimensions[N];
2486
+ const [C, O] = t.split("."), N = I.find((s) => s.name === C);
2487
+ if (N && N.dimensions[O]) {
2488
+ const s = N.dimensions[O];
2459
2489
  e[t] = {
2460
- title: s.title || N,
2461
- shortTitle: s.title || N,
2490
+ title: s.title || O,
2491
+ shortTitle: s.title || O,
2462
2492
  type: s.type
2463
2493
  };
2464
2494
  }
2465
2495
  }
2466
2496
  if (T.timeDimensions)
2467
2497
  for (const t of T.timeDimensions) {
2468
- const [C, N] = t.dimension.split("."), O = I.find((s) => s.name === C);
2469
- if (O && O.dimensions && O.dimensions[N]) {
2470
- const s = O.dimensions[N];
2498
+ const [C, O] = t.dimension.split("."), N = I.find((s) => s.name === C);
2499
+ if (N && N.dimensions && N.dimensions[O]) {
2500
+ const s = N.dimensions[O];
2471
2501
  S[t.dimension] = {
2472
- title: s.title || N,
2473
- shortTitle: s.title || N,
2502
+ title: s.title || O,
2503
+ shortTitle: s.title || O,
2474
2504
  type: s.type,
2475
2505
  granularity: t.granularity
2476
2506
  };
@@ -2484,7 +2514,7 @@ class CE {
2484
2514
  };
2485
2515
  }
2486
2516
  }
2487
- const L = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.replace(/ +/g, " ").trim(), rR = (R) => ({
2517
+ const _ = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.replace(/ +/g, " ").trim(), rR = (R) => ({
2488
2518
  type: "mandatory_block",
2489
2519
  items: XE(R, 0)[0]
2490
2520
  }), XE = (R, E, T) => {
@@ -2549,23 +2579,23 @@ const L = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.repl
2549
2579
  T.push(A + e);
2550
2580
  return T;
2551
2581
  };
2552
- var a;
2582
+ var D;
2553
2583
  (function(R) {
2554
2584
  R.QUOTED_IDENTIFIER = "QUOTED_IDENTIFIER", R.IDENTIFIER = "IDENTIFIER", R.STRING = "STRING", R.VARIABLE = "VARIABLE", R.RESERVED_DATA_TYPE = "RESERVED_DATA_TYPE", R.RESERVED_PARAMETERIZED_DATA_TYPE = "RESERVED_PARAMETERIZED_DATA_TYPE", R.RESERVED_KEYWORD = "RESERVED_KEYWORD", R.RESERVED_FUNCTION_NAME = "RESERVED_FUNCTION_NAME", R.RESERVED_KEYWORD_PHRASE = "RESERVED_KEYWORD_PHRASE", R.RESERVED_DATA_TYPE_PHRASE = "RESERVED_DATA_TYPE_PHRASE", R.RESERVED_SET_OPERATION = "RESERVED_SET_OPERATION", R.RESERVED_CLAUSE = "RESERVED_CLAUSE", R.RESERVED_SELECT = "RESERVED_SELECT", R.RESERVED_JOIN = "RESERVED_JOIN", R.ARRAY_IDENTIFIER = "ARRAY_IDENTIFIER", R.ARRAY_KEYWORD = "ARRAY_KEYWORD", R.CASE = "CASE", R.END = "END", R.WHEN = "WHEN", R.ELSE = "ELSE", R.THEN = "THEN", R.LIMIT = "LIMIT", R.BETWEEN = "BETWEEN", R.AND = "AND", R.OR = "OR", R.XOR = "XOR", R.OPERATOR = "OPERATOR", R.COMMA = "COMMA", R.ASTERISK = "ASTERISK", R.PROPERTY_ACCESS_OPERATOR = "PROPERTY_ACCESS_OPERATOR", R.OPEN_PAREN = "OPEN_PAREN", R.CLOSE_PAREN = "CLOSE_PAREN", R.LINE_COMMENT = "LINE_COMMENT", R.BLOCK_COMMENT = "BLOCK_COMMENT", R.DISABLE_COMMENT = "DISABLE_COMMENT", R.NUMBER = "NUMBER", R.NAMED_PARAMETER = "NAMED_PARAMETER", R.QUOTED_PARAMETER = "QUOTED_PARAMETER", R.NUMBERED_PARAMETER = "NUMBERED_PARAMETER", R.POSITIONAL_PARAMETER = "POSITIONAL_PARAMETER", R.CUSTOM_PARAMETER = "CUSTOM_PARAMETER", R.DELIMITER = "DELIMITER", R.EOF = "EOF";
2555
- })(a = a || (a = {}));
2585
+ })(D = D || (D = {}));
2556
2586
  const FT = (R) => ({
2557
- type: a.EOF,
2587
+ type: D.EOF,
2558
2588
  raw: "«EOF»",
2559
2589
  text: "«EOF»",
2560
2590
  start: R
2561
2591
  }), v = FT(1 / 0), w = (R) => (E) => E.type === R.type && E.text === R.text, y = {
2562
- ARRAY: w({ text: "ARRAY", type: a.RESERVED_DATA_TYPE }),
2563
- BY: w({ text: "BY", type: a.RESERVED_KEYWORD }),
2564
- SET: w({ text: "SET", type: a.RESERVED_CLAUSE }),
2565
- STRUCT: w({ text: "STRUCT", type: a.RESERVED_DATA_TYPE }),
2566
- WINDOW: w({ text: "WINDOW", type: a.RESERVED_CLAUSE }),
2567
- VALUES: w({ text: "VALUES", type: a.RESERVED_CLAUSE })
2568
- }, mT = (R) => R === a.RESERVED_DATA_TYPE || R === a.RESERVED_KEYWORD || R === a.RESERVED_FUNCTION_NAME || R === a.RESERVED_KEYWORD_PHRASE || R === a.RESERVED_DATA_TYPE_PHRASE || R === a.RESERVED_CLAUSE || R === a.RESERVED_SELECT || R === a.RESERVED_SET_OPERATION || R === a.RESERVED_JOIN || R === a.ARRAY_KEYWORD || R === a.CASE || R === a.END || R === a.WHEN || R === a.ELSE || R === a.THEN || R === a.LIMIT || R === a.BETWEEN || R === a.AND || R === a.OR || R === a.XOR, PR = (R) => R === a.AND || R === a.OR || R === a.XOR, MR = [
2592
+ ARRAY: w({ text: "ARRAY", type: D.RESERVED_DATA_TYPE }),
2593
+ BY: w({ text: "BY", type: D.RESERVED_KEYWORD }),
2594
+ SET: w({ text: "SET", type: D.RESERVED_CLAUSE }),
2595
+ STRUCT: w({ text: "STRUCT", type: D.RESERVED_DATA_TYPE }),
2596
+ WINDOW: w({ text: "WINDOW", type: D.RESERVED_CLAUSE }),
2597
+ VALUES: w({ text: "VALUES", type: D.RESERVED_CLAUSE })
2598
+ }, mT = (R) => R === D.RESERVED_DATA_TYPE || R === D.RESERVED_KEYWORD || R === D.RESERVED_FUNCTION_NAME || R === D.RESERVED_KEYWORD_PHRASE || R === D.RESERVED_DATA_TYPE_PHRASE || R === D.RESERVED_CLAUSE || R === D.RESERVED_SELECT || R === D.RESERVED_SET_OPERATION || R === D.RESERVED_JOIN || R === D.ARRAY_KEYWORD || R === D.CASE || R === D.END || R === D.WHEN || R === D.ELSE || R === D.THEN || R === D.LIMIT || R === D.BETWEEN || R === D.AND || R === D.OR || R === D.XOR, PR = (R) => R === D.AND || R === D.OR || R === D.XOR, MR = [
2569
2599
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
2570
2600
  "KEYS.NEW_KEYSET",
2571
2601
  "KEYS.ADD_KEY_FROM_RAW_BYTES",
@@ -3242,7 +3272,7 @@ const FT = (R) => ({
3242
3272
  "STRUCT",
3243
3273
  "TIME",
3244
3274
  "TIMEZONE"
3245
- ], GR = L(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), lR = L([
3275
+ ], GR = _(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), lR = _([
3246
3276
  // Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
3247
3277
  "WITH [RECURSIVE]",
3248
3278
  "FROM",
@@ -3271,9 +3301,9 @@ const FT = (R) => ({
3271
3301
  "WITH CONNECTION",
3272
3302
  "WITH PARTITION COLUMNS",
3273
3303
  "REMOTE WITH CONNECTION"
3274
- ]), ZE = L([
3304
+ ]), ZE = _([
3275
3305
  "CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
3276
- ]), LE = L([
3306
+ ]), LE = _([
3277
3307
  // - create:
3278
3308
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
3279
3309
  "CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
@@ -3361,15 +3391,15 @@ const FT = (R) => ({
3361
3391
  "ASSERT",
3362
3392
  // Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
3363
3393
  "EXPORT DATA"
3364
- ]), uR = L([
3394
+ ]), uR = _([
3365
3395
  "UNION {ALL | DISTINCT}",
3366
3396
  "EXCEPT DISTINCT",
3367
3397
  "INTERSECT DISTINCT"
3368
- ]), HR = L([
3398
+ ]), HR = _([
3369
3399
  "JOIN",
3370
3400
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
3371
3401
  "{INNER | CROSS} JOIN"
3372
- ]), BR = L([
3402
+ ]), BR = _([
3373
3403
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
3374
3404
  "TABLESAMPLE SYSTEM",
3375
3405
  // From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
@@ -3380,7 +3410,7 @@ const FT = (R) => ({
3380
3410
  "{ROWS | RANGE} BETWEEN",
3381
3411
  // comparison operator
3382
3412
  "IS [NOT] DISTINCT FROM"
3383
- ]), dR = L([]), FR = {
3413
+ ]), dR = _([]), FR = {
3384
3414
  name: "bigquery",
3385
3415
  tokenizerOptions: {
3386
3416
  reservedSelect: GR,
@@ -3421,7 +3451,7 @@ function mR(R) {
3421
3451
  }
3422
3452
  function pR(R) {
3423
3453
  let E = v;
3424
- return R.map((T) => T.text === "OFFSET" && E.text === "[" ? (E = T, Object.assign(Object.assign({}, T), { type: a.RESERVED_FUNCTION_NAME })) : (E = T, T));
3454
+ return R.map((T) => T.text === "OFFSET" && E.text === "[" ? (E = T, Object.assign(Object.assign({}, T), { type: D.RESERVED_FUNCTION_NAME })) : (E = T, T));
3425
3455
  }
3426
3456
  function YR(R) {
3427
3457
  var E;
@@ -3431,7 +3461,7 @@ function YR(R) {
3431
3461
  if ((y.ARRAY(e) || y.STRUCT(e)) && ((E = R[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
3432
3462
  const S = hR(R, A + 1), I = R.slice(A, S + 1);
3433
3463
  T.push({
3434
- type: a.IDENTIFIER,
3464
+ type: D.IDENTIFIER,
3435
3465
  raw: I.map(qE("raw")).join(""),
3436
3466
  text: I.map(qE("text")).join(""),
3437
3467
  start: e.start
@@ -3441,7 +3471,7 @@ function YR(R) {
3441
3471
  }
3442
3472
  return T;
3443
3473
  }
3444
- const qE = (R) => (E) => E.type === a.IDENTIFIER || E.type === a.COMMA ? E[R] + " " : E[R];
3474
+ const qE = (R) => (E) => E.type === D.IDENTIFIER || E.type === D.COMMA ? E[R] + " " : E[R];
3445
3475
  function hR(R, E) {
3446
3476
  let T = 0;
3447
3477
  for (let A = E; A < R.length; A++) {
@@ -4214,7 +4244,7 @@ const fR = [
4214
4244
  "VARBINARY",
4215
4245
  "VARCHAR",
4216
4246
  "VARGRAPHIC"
4217
- ], XR = L(["SELECT [ALL | DISTINCT]"]), bR = L([
4247
+ ], XR = _(["SELECT [ALL | DISTINCT]"]), bR = _([
4218
4248
  // queries
4219
4249
  "WITH",
4220
4250
  "FROM",
@@ -4243,9 +4273,9 @@ const fR = [
4243
4273
  "WHEN [NOT] MATCHED [THEN]",
4244
4274
  "UPDATE SET",
4245
4275
  "INSERT"
4246
- ]), jE = L([
4276
+ ]), jE = _([
4247
4277
  "CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
4248
- ]), _E = L([
4278
+ ]), _E = _([
4249
4279
  // - create:
4250
4280
  "CREATE [OR REPLACE] VIEW",
4251
4281
  // - update:
@@ -4448,16 +4478,16 @@ const fR = [
4448
4478
  "TRANSFER OWNERSHIP OF",
4449
4479
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
4450
4480
  "WHILE"
4451
- ]), yR = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), KR = L([
4481
+ ]), yR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), KR = _([
4452
4482
  "JOIN",
4453
4483
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
4454
4484
  "{INNER | CROSS} JOIN"
4455
- ]), $R = L([
4485
+ ]), $R = _([
4456
4486
  "ON DELETE",
4457
4487
  "ON UPDATE",
4458
4488
  "SET NULL",
4459
4489
  "{ROWS | RANGE} BETWEEN"
4460
- ]), gR = L([]), wR = {
4490
+ ]), gR = _([]), wR = {
4461
4491
  name: "db2",
4462
4492
  tokenizerOptions: {
4463
4493
  reservedSelect: XR,
@@ -5368,7 +5398,7 @@ const fR = [
5368
5398
  "VARCHAR",
5369
5399
  "VARGRAPHIC",
5370
5400
  "XML"
5371
- ], QR = L(["SELECT [ALL | DISTINCT]"]), ZR = L([
5401
+ ], QR = _(["SELECT [ALL | DISTINCT]"]), ZR = _([
5372
5402
  // queries
5373
5403
  "WITH [RECURSIVE]",
5374
5404
  "INTO",
@@ -5398,7 +5428,7 @@ const fR = [
5398
5428
  "INSERT",
5399
5429
  // Data definition - table
5400
5430
  "FOR SYSTEM NAME"
5401
- ]), kE = L(["CREATE [OR REPLACE] TABLE"]), rE = L([
5431
+ ]), kE = _(["CREATE [OR REPLACE] TABLE"]), rE = _([
5402
5432
  // - create:
5403
5433
  "CREATE [OR REPLACE] [RECURSIVE] VIEW",
5404
5434
  // - update:
@@ -5494,17 +5524,17 @@ const fR = [
5494
5524
  "TAG",
5495
5525
  "TRANSFER OWNERSHIP OF",
5496
5526
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
5497
- ]), qR = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), jR = L([
5527
+ ]), qR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), jR = _([
5498
5528
  "JOIN",
5499
5529
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
5500
5530
  "[LEFT | RIGHT] EXCEPTION JOIN",
5501
5531
  "{INNER | CROSS} JOIN"
5502
- ]), kR = L([
5532
+ ]), kR = _([
5503
5533
  "ON DELETE",
5504
5534
  "ON UPDATE",
5505
5535
  "SET NULL",
5506
5536
  "{ROWS | RANGE} BETWEEN"
5507
- ]), zR = L([]), EA = {
5537
+ ]), zR = _([]), EA = {
5508
5538
  name: "db2i",
5509
5539
  tokenizerOptions: {
5510
5540
  reservedSelect: QR,
@@ -6357,7 +6387,7 @@ const fR = [
6357
6387
  "UUID",
6358
6388
  "VARBINARY",
6359
6389
  "VARCHAR"
6360
- ], eA = L(["SELECT [ALL | DISTINCT]"]), SA = L([
6390
+ ], eA = _(["SELECT [ALL | DISTINCT]"]), SA = _([
6361
6391
  // queries
6362
6392
  "WITH [RECURSIVE]",
6363
6393
  "FROM",
@@ -6381,9 +6411,9 @@ const fR = [
6381
6411
  "SET",
6382
6412
  // other:
6383
6413
  "RETURNING"
6384
- ]), zE = L([
6414
+ ]), zE = _([
6385
6415
  "CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
6386
- ]), nE = L([
6416
+ ]), nE = _([
6387
6417
  // TABLE
6388
6418
  // - update:
6389
6419
  "UPDATE",
@@ -6461,11 +6491,11 @@ const fR = [
6461
6491
  "PREPARE",
6462
6492
  "EXECUTE",
6463
6493
  "DEALLOCATE [PREPARE]"
6464
- ]), IA = L([
6494
+ ]), IA = _([
6465
6495
  "UNION [ALL | BY NAME]",
6466
6496
  "EXCEPT [ALL]",
6467
6497
  "INTERSECT [ALL]"
6468
- ]), OA = L([
6498
+ ]), OA = _([
6469
6499
  "JOIN",
6470
6500
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
6471
6501
  "{INNER | CROSS} JOIN",
@@ -6474,11 +6504,11 @@ const fR = [
6474
6504
  "POSITIONAL JOIN",
6475
6505
  "ANTI JOIN",
6476
6506
  "SEMI JOIN"
6477
- ]), NA = L([
6507
+ ]), NA = _([
6478
6508
  "{ROWS | RANGE | GROUPS} BETWEEN",
6479
6509
  "SIMILAR TO",
6480
6510
  "IS [NOT] DISTINCT FROM"
6481
- ]), tA = L(["TIMESTAMP WITH TIME ZONE"]), sA = {
6511
+ ]), tA = _(["TIMESTAMP WITH TIME ZONE"]), sA = {
6482
6512
  name: "duckdb",
6483
6513
  tokenizerOptions: {
6484
6514
  reservedSelect: eA,
@@ -7098,7 +7128,7 @@ const fR = [
7098
7128
  "STRUCT",
7099
7129
  "TIMESTAMP",
7100
7130
  "VARCHAR"
7101
- ], rA = L(["SELECT [ALL | DISTINCT]"]), nA = L([
7131
+ ], rA = _(["SELECT [ALL | DISTINCT]"]), nA = _([
7102
7132
  // queries
7103
7133
  "WITH",
7104
7134
  "FROM",
@@ -7132,9 +7162,9 @@ const fR = [
7132
7162
  // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
7133
7163
  "LOAD DATA [LOCAL] INPATH",
7134
7164
  "[OVERWRITE] INTO TABLE"
7135
- ]), ET = L([
7165
+ ]), ET = _([
7136
7166
  "CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
7137
- ]), iE = L([
7167
+ ]), iE = _([
7138
7168
  // - create:
7139
7169
  "CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
7140
7170
  // - update:
@@ -7159,13 +7189,13 @@ const fR = [
7159
7189
  "STORED AS",
7160
7190
  "STORED BY",
7161
7191
  "ROW FORMAT"
7162
- ]), iA = L(["UNION [ALL | DISTINCT]"]), aA = L([
7192
+ ]), iA = _(["UNION [ALL | DISTINCT]"]), aA = _([
7163
7193
  "JOIN",
7164
7194
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
7165
7195
  "{INNER | CROSS} JOIN",
7166
7196
  // non-standard joins
7167
7197
  "LEFT SEMI JOIN"
7168
- ]), oA = L(["{ROWS | RANGE} BETWEEN"]), DA = L([]), PA = {
7198
+ ]), oA = _(["{ROWS | RANGE} BETWEEN"]), DA = _([]), PA = {
7169
7199
  name: "hive",
7170
7200
  tokenizerOptions: {
7171
7201
  reservedSelect: rA,
@@ -7192,9 +7222,9 @@ function AE(R) {
7192
7222
  return R.map((E, T) => {
7193
7223
  const A = R[T + 1] || v;
7194
7224
  if (y.SET(E) && A.text === "(")
7195
- return Object.assign(Object.assign({}, E), { type: a.RESERVED_FUNCTION_NAME });
7225
+ return Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME });
7196
7226
  const e = R[T - 1] || v;
7197
- return y.VALUES(E) && e.text === "=" ? Object.assign(Object.assign({}, E), { type: a.RESERVED_FUNCTION_NAME }) : E;
7227
+ return y.VALUES(E) && e.text === "=" ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E;
7198
7228
  });
7199
7229
  }
7200
7230
  const MA = [
@@ -7703,7 +7733,7 @@ const MA = [
7703
7733
  // CASE expression shorthands
7704
7734
  "COALESCE",
7705
7735
  "NULLIF"
7706
- ], GA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), lA = L([
7736
+ ], GA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), lA = _([
7707
7737
  // queries
7708
7738
  "WITH [RECURSIVE]",
7709
7739
  "FROM",
@@ -7725,9 +7755,9 @@ const MA = [
7725
7755
  "SET",
7726
7756
  // other
7727
7757
  "RETURNING"
7728
- ]), TT = L([
7758
+ ]), TT = _([
7729
7759
  "CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
7730
- ]), aE = L([
7760
+ ]), aE = _([
7731
7761
  // - create:
7732
7762
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
7733
7763
  // - update:
@@ -7934,12 +7964,12 @@ const MA = [
7934
7964
  "XA RECOVER",
7935
7965
  "XA ROLLBACK",
7936
7966
  "XA START"
7937
- ]), uA = L([
7967
+ ]), uA = _([
7938
7968
  "UNION [ALL | DISTINCT]",
7939
7969
  "EXCEPT [ALL | DISTINCT]",
7940
7970
  "INTERSECT [ALL | DISTINCT]",
7941
7971
  "MINUS [ALL | DISTINCT]"
7942
- ]), HA = L([
7972
+ ]), HA = _([
7943
7973
  "JOIN",
7944
7974
  "{LEFT | RIGHT} [OUTER] JOIN",
7945
7975
  "{INNER | CROSS} JOIN",
@@ -7947,12 +7977,12 @@ const MA = [
7947
7977
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
7948
7978
  // non-standard joins
7949
7979
  "STRAIGHT_JOIN"
7950
- ]), BA = L([
7980
+ ]), BA = _([
7951
7981
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
7952
7982
  "CHARACTER SET",
7953
7983
  "{ROWS | RANGE} BETWEEN",
7954
7984
  "IDENTIFIED BY"
7955
- ]), dA = L([]), FA = {
7985
+ ]), dA = _([]), FA = {
7956
7986
  name: "mariadb",
7957
7987
  tokenizerOptions: {
7958
7988
  reservedSelect: GA,
@@ -8709,7 +8739,7 @@ const MA = [
8709
8739
  // 'XOR',
8710
8740
  "YEAR",
8711
8741
  "YEARWEEK"
8712
- ], hA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), fA = L([
8742
+ ], hA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), fA = _([
8713
8743
  // queries
8714
8744
  "WITH [RECURSIVE]",
8715
8745
  "FROM",
@@ -8729,7 +8759,7 @@ const MA = [
8729
8759
  "ON DUPLICATE KEY UPDATE",
8730
8760
  // - update:
8731
8761
  "SET"
8732
- ]), RT = L(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), oE = L([
8762
+ ]), RT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), oE = _([
8733
8763
  // - create:
8734
8764
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
8735
8765
  // - update:
@@ -8910,7 +8940,7 @@ const MA = [
8910
8940
  "REPEAT",
8911
8941
  "RETURN",
8912
8942
  "WHILE"
8913
- ]), VA = L(["UNION [ALL | DISTINCT]"]), WA = L([
8943
+ ]), VA = _(["UNION [ALL | DISTINCT]"]), WA = _([
8914
8944
  "JOIN",
8915
8945
  "{LEFT | RIGHT} [OUTER] JOIN",
8916
8946
  "{INNER | CROSS} JOIN",
@@ -8918,12 +8948,12 @@ const MA = [
8918
8948
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
8919
8949
  // non-standard joins
8920
8950
  "STRAIGHT_JOIN"
8921
- ]), XA = L([
8951
+ ]), XA = _([
8922
8952
  "ON {UPDATE | DELETE} [SET NULL]",
8923
8953
  "CHARACTER SET",
8924
8954
  "{ROWS | RANGE} BETWEEN",
8925
8955
  "IDENTIFIED BY"
8926
- ]), bA = L([]), yA = {
8956
+ ]), bA = _([]), yA = {
8927
8957
  name: "mysql",
8928
8958
  tokenizerOptions: {
8929
8959
  reservedSelect: hA,
@@ -9541,7 +9571,7 @@ const MA = [
9541
9571
  // 'XOR',
9542
9572
  "YEAR",
9543
9573
  "YEARWEEK"
9544
- ], wA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), JA = L([
9574
+ ], wA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), JA = _([
9545
9575
  // queries
9546
9576
  "WITH [RECURSIVE]",
9547
9577
  "FROM",
@@ -9561,7 +9591,7 @@ const MA = [
9561
9591
  "ON DUPLICATE KEY UPDATE",
9562
9592
  // - update:
9563
9593
  "SET"
9564
- ]), AT = L(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), DE = L([
9594
+ ]), AT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), DE = _([
9565
9595
  // https://docs.pingcap.com/tidb/stable/sql-statement-create-view
9566
9596
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
9567
9597
  // https://docs.pingcap.com/tidb/stable/sql-statement-update
@@ -9676,7 +9706,7 @@ const MA = [
9676
9706
  "UNLOCK TABLES",
9677
9707
  // https://docs.pingcap.com/tidb/stable/sql-statement-use
9678
9708
  "USE"
9679
- ]), xA = L(["UNION [ALL | DISTINCT]"]), vA = L([
9709
+ ]), xA = _(["UNION [ALL | DISTINCT]"]), vA = _([
9680
9710
  "JOIN",
9681
9711
  "{LEFT | RIGHT} [OUTER] JOIN",
9682
9712
  "{INNER | CROSS} JOIN",
@@ -9684,12 +9714,12 @@ const MA = [
9684
9714
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
9685
9715
  // non-standard joins
9686
9716
  "STRAIGHT_JOIN"
9687
- ]), QA = L([
9717
+ ]), QA = _([
9688
9718
  "ON {UPDATE | DELETE} [SET NULL]",
9689
9719
  "CHARACTER SET",
9690
9720
  "{ROWS | RANGE} BETWEEN",
9691
9721
  "IDENTIFIED BY"
9692
- ]), ZA = L([]), qA = {
9722
+ ]), ZA = _([]), qA = {
9693
9723
  name: "tidb",
9694
9724
  tokenizerOptions: {
9695
9725
  reservedSelect: wA,
@@ -10187,7 +10217,7 @@ const MA = [
10187
10217
  // which it actually doesn't use.
10188
10218
  //
10189
10219
  // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
10190
- ], Ee = L(["SELECT [ALL | DISTINCT]"]), Te = L([
10220
+ ], Ee = _(["SELECT [ALL | DISTINCT]"]), Te = _([
10191
10221
  // queries
10192
10222
  "WITH",
10193
10223
  "FROM",
@@ -10214,7 +10244,7 @@ const MA = [
10214
10244
  "NEST",
10215
10245
  "UNNEST",
10216
10246
  "RETURNING"
10217
- ]), eT = L([
10247
+ ]), eT = _([
10218
10248
  // - update:
10219
10249
  "UPDATE",
10220
10250
  // - delete:
@@ -10254,7 +10284,7 @@ const MA = [
10254
10284
  "SET CURRENT SCHEMA",
10255
10285
  "SHOW",
10256
10286
  "USE [PRIMARY] KEYS"
10257
- ]), Re = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), Ae = L(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), ee = L(["{ROWS | RANGE | GROUPS} BETWEEN"]), Se = L([]), Ie = {
10287
+ ]), Re = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), Ae = _(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), ee = _(["{ROWS | RANGE | GROUPS} BETWEEN"]), Se = _([]), Ie = {
10258
10288
  name: "n1ql",
10259
10289
  tokenizerOptions: {
10260
10290
  reservedSelect: Ee,
@@ -10888,7 +10918,7 @@ const MA = [
10888
10918
  "PRESENTNNV",
10889
10919
  "PRESENTV",
10890
10920
  "PREVIOUS"
10891
- ], se = L(["SELECT [ALL | DISTINCT | UNIQUE]"]), Ce = L([
10921
+ ], se = _(["SELECT [ALL | DISTINCT | UNIQUE]"]), Ce = _([
10892
10922
  // queries
10893
10923
  "WITH",
10894
10924
  "FROM",
@@ -10912,9 +10942,9 @@ const MA = [
10912
10942
  "UPDATE SET",
10913
10943
  // other
10914
10944
  "RETURNING"
10915
- ]), ST = L([
10945
+ ]), ST = _([
10916
10946
  "CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
10917
- ]), PE = L([
10947
+ ]), PE = _([
10918
10948
  // - create:
10919
10949
  "CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
10920
10950
  "CREATE MATERIALIZED VIEW",
@@ -10942,7 +10972,7 @@ const MA = [
10942
10972
  "EXCEPTION",
10943
10973
  "LOOP",
10944
10974
  "START WITH"
10945
- ]), Le = L(["UNION [ALL]", "MINUS", "INTERSECT"]), _e = L([
10975
+ ]), Le = _(["UNION [ALL]", "MINUS", "INTERSECT"]), _e = _([
10946
10976
  "JOIN",
10947
10977
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
10948
10978
  "{INNER | CROSS} JOIN",
@@ -10950,11 +10980,11 @@ const MA = [
10950
10980
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
10951
10981
  // non-standard joins
10952
10982
  "{CROSS | OUTER} APPLY"
10953
- ]), re = L([
10983
+ ]), re = _([
10954
10984
  "ON {UPDATE | DELETE} [SET NULL]",
10955
10985
  "ON COMMIT",
10956
10986
  "{ROWS | RANGE} BETWEEN"
10957
- ]), ne = L([]), ie = {
10987
+ ]), ne = _([]), ie = {
10958
10988
  name: "plsql",
10959
10989
  tokenizerOptions: {
10960
10990
  reservedSelect: se,
@@ -11001,7 +11031,7 @@ const MA = [
11001
11031
  };
11002
11032
  function ae(R) {
11003
11033
  let E = v;
11004
- return R.map((T) => y.SET(T) && y.BY(E) ? Object.assign(Object.assign({}, T), { type: a.RESERVED_KEYWORD }) : (mT(T.type) && (E = T), T));
11034
+ return R.map((T) => y.SET(T) && y.BY(E) ? Object.assign(Object.assign({}, T), { type: D.RESERVED_KEYWORD }) : (mT(T.type) && (E = T), T));
11005
11035
  }
11006
11036
  const oe = [
11007
11037
  // https://www.postgresql.org/docs/14/functions.html
@@ -11840,7 +11870,7 @@ const oe = [
11840
11870
  "VARCHAR",
11841
11871
  "XML",
11842
11872
  "ZONE"
11843
- ], Me = L(["SELECT [ALL | DISTINCT]"]), Ue = L([
11873
+ ], Me = _(["SELECT [ALL | DISTINCT]"]), Ue = _([
11844
11874
  // queries
11845
11875
  "WITH [RECURSIVE]",
11846
11876
  "FROM",
@@ -11863,9 +11893,9 @@ const oe = [
11863
11893
  "SET",
11864
11894
  // other
11865
11895
  "RETURNING"
11866
- ]), IT = L([
11896
+ ]), IT = _([
11867
11897
  "CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
11868
- ]), ME = L([
11898
+ ]), ME = _([
11869
11899
  // - create
11870
11900
  "CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
11871
11901
  "CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
@@ -12063,17 +12093,17 @@ const oe = [
12063
12093
  "START TRANSACTION",
12064
12094
  "UNLISTEN",
12065
12095
  "VACUUM"
12066
- ]), ce = L([
12096
+ ]), ce = _([
12067
12097
  "UNION [ALL | DISTINCT]",
12068
12098
  "EXCEPT [ALL | DISTINCT]",
12069
12099
  "INTERSECT [ALL | DISTINCT]"
12070
- ]), Ge = L([
12100
+ ]), Ge = _([
12071
12101
  "JOIN",
12072
12102
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
12073
12103
  "{INNER | CROSS} JOIN",
12074
12104
  "NATURAL [INNER] JOIN",
12075
12105
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
12076
- ]), le = L([
12106
+ ]), le = _([
12077
12107
  "PRIMARY KEY",
12078
12108
  "GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
12079
12109
  "ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
@@ -12084,7 +12114,7 @@ const oe = [
12084
12114
  "IS [NOT] DISTINCT FROM",
12085
12115
  "NULLS {FIRST | LAST}",
12086
12116
  "WITH ORDINALITY"
12087
- ]), ue = L([
12117
+ ]), ue = _([
12088
12118
  // https://www.postgresql.org/docs/current/datatype-datetime.html
12089
12119
  "[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
12090
12120
  ]), He = {
@@ -12769,7 +12799,7 @@ const oe = [
12769
12799
  "TEXT",
12770
12800
  "VARBYTE",
12771
12801
  "VARCHAR"
12772
- ], me = L(["SELECT [ALL | DISTINCT]"]), pe = L([
12802
+ ], me = _(["SELECT [ALL | DISTINCT]"]), pe = _([
12773
12803
  // queries
12774
12804
  "WITH [RECURSIVE]",
12775
12805
  "FROM",
@@ -12787,9 +12817,9 @@ const oe = [
12787
12817
  "VALUES",
12788
12818
  // - update:
12789
12819
  "SET"
12790
- ]), OT = L([
12820
+ ]), OT = _([
12791
12821
  "CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
12792
- ]), UE = L([
12822
+ ]), UE = _([
12793
12823
  // - create:
12794
12824
  "CREATE [OR REPLACE | MATERIALIZED] VIEW",
12795
12825
  // - update:
@@ -12880,13 +12910,13 @@ const oe = [
12880
12910
  "START TRANSACTION",
12881
12911
  "UNLOAD",
12882
12912
  "VACUUM"
12883
- ]), Ye = L(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), he = L([
12913
+ ]), Ye = _(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), he = _([
12884
12914
  "JOIN",
12885
12915
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
12886
12916
  "{INNER | CROSS} JOIN",
12887
12917
  "NATURAL [INNER] JOIN",
12888
12918
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
12889
- ]), fe = L([
12919
+ ]), fe = _([
12890
12920
  // https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
12891
12921
  "NULL AS",
12892
12922
  // https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
@@ -12894,7 +12924,7 @@ const oe = [
12894
12924
  "HIVE METASTORE",
12895
12925
  // in window specifications
12896
12926
  "{ROWS | RANGE} BETWEEN"
12897
- ]), Ve = L([]), We = {
12927
+ ]), Ve = _([]), We = {
12898
12928
  name: "redshift",
12899
12929
  tokenizerOptions: {
12900
12930
  reservedSelect: me,
@@ -13550,7 +13580,7 @@ const oe = [
13550
13580
  // Shorthand functions to use in place of CASE expression
13551
13581
  "COALESCE",
13552
13582
  "NULLIF"
13553
- ], Ke = L(["SELECT [ALL | DISTINCT]"]), $e = L([
13583
+ ], Ke = _(["SELECT [ALL | DISTINCT]"]), $e = _([
13554
13584
  // queries
13555
13585
  "WITH",
13556
13586
  "FROM",
@@ -13575,7 +13605,7 @@ const oe = [
13575
13605
  // https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
13576
13606
  "LOAD DATA [LOCAL] INPATH",
13577
13607
  "[OVERWRITE] INTO TABLE"
13578
- ]), NT = L(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), cE = L([
13608
+ ]), NT = _(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), cE = _([
13579
13609
  // - create:
13580
13610
  "CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
13581
13611
  // - drop table:
@@ -13631,11 +13661,11 @@ const oe = [
13631
13661
  "SHOW TBLPROPERTIES",
13632
13662
  "SHOW VIEWS",
13633
13663
  "UNCACHE TABLE"
13634
- ]), ge = L([
13664
+ ]), ge = _([
13635
13665
  "UNION [ALL | DISTINCT]",
13636
13666
  "EXCEPT [ALL | DISTINCT]",
13637
13667
  "INTERSECT [ALL | DISTINCT]"
13638
- ]), we = L([
13668
+ ]), we = _([
13639
13669
  "JOIN",
13640
13670
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
13641
13671
  "{INNER | CROSS} JOIN",
@@ -13644,12 +13674,12 @@ const oe = [
13644
13674
  // non-standard-joins
13645
13675
  "[LEFT] {ANTI | SEMI} JOIN",
13646
13676
  "NATURAL [LEFT] {ANTI | SEMI} JOIN"
13647
- ]), Je = L([
13677
+ ]), Je = _([
13648
13678
  "ON DELETE",
13649
13679
  "ON UPDATE",
13650
13680
  "CURRENT ROW",
13651
13681
  "{ROWS | RANGE} BETWEEN"
13652
- ]), xe = L([]), ve = {
13682
+ ]), xe = _([]), ve = {
13653
13683
  name: "spark",
13654
13684
  tokenizerOptions: {
13655
13685
  reservedSelect: Ke,
@@ -13683,7 +13713,7 @@ const oe = [
13683
13713
  function Qe(R) {
13684
13714
  return R.map((E, T) => {
13685
13715
  const A = R[T - 1] || v, e = R[T + 1] || v;
13686
- return y.WINDOW(E) && e.type === a.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: a.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === a.RESERVED_KEYWORD && !(A.text === "COLLECTION" && e.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: a.IDENTIFIER, text: E.raw }) : E;
13716
+ return y.WINDOW(E) && e.type === D.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === D.RESERVED_KEYWORD && !(A.text === "COLLECTION" && e.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: D.IDENTIFIER, text: E.raw }) : E;
13687
13717
  });
13688
13718
  }
13689
13719
  const Ze = [
@@ -13984,7 +14014,7 @@ const Ze = [
13984
14014
  "TEXT",
13985
14015
  "VARCHAR",
13986
14016
  "VARYING CHARACTER"
13987
- ], ke = L(["SELECT [ALL | DISTINCT]"]), ze = L([
14017
+ ], ke = _(["SELECT [ALL | DISTINCT]"]), ze = _([
13988
14018
  // queries
13989
14019
  "WITH [RECURSIVE]",
13990
14020
  "FROM",
@@ -14005,7 +14035,7 @@ const Ze = [
14005
14035
  "SET",
14006
14036
  // other:
14007
14037
  "RETURNING"
14008
- ]), tT = L(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), GE = L([
14038
+ ]), tT = _(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), GE = _([
14009
14039
  // - create:
14010
14040
  "CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
14011
14041
  // - update:
@@ -14024,17 +14054,17 @@ const Ze = [
14024
14054
  "RENAME TO",
14025
14055
  // - set schema
14026
14056
  "SET SCHEMA"
14027
- ]), ES = L(["UNION [ALL]", "EXCEPT", "INTERSECT"]), TS = L([
14057
+ ]), ES = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), TS = _([
14028
14058
  "JOIN",
14029
14059
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14030
14060
  "{INNER | CROSS} JOIN",
14031
14061
  "NATURAL [INNER] JOIN",
14032
14062
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
14033
- ]), RS = L([
14063
+ ]), RS = _([
14034
14064
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
14035
14065
  "{ROWS | RANGE | GROUPS} BETWEEN",
14036
14066
  "DO UPDATE"
14037
- ]), AS = L([]), eS = {
14067
+ ]), AS = _([]), eS = {
14038
14068
  name: "sqlite",
14039
14069
  tokenizerOptions: {
14040
14070
  reservedSelect: ke,
@@ -14396,7 +14426,7 @@ const Ze = [
14396
14426
  "TIMESTAMP",
14397
14427
  "VARBINARY",
14398
14428
  "VARCHAR"
14399
- ], NS = L(["SELECT [ALL | DISTINCT]"]), tS = L([
14429
+ ], NS = _(["SELECT [ALL | DISTINCT]"]), tS = _([
14400
14430
  // queries
14401
14431
  "WITH [RECURSIVE]",
14402
14432
  "FROM",
@@ -14415,7 +14445,7 @@ const Ze = [
14415
14445
  "VALUES",
14416
14446
  // - update:
14417
14447
  "SET"
14418
- ]), sT = L(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), lE = L([
14448
+ ]), sT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), lE = _([
14419
14449
  // - create:
14420
14450
  "CREATE [RECURSIVE] VIEW",
14421
14451
  // - update:
@@ -14440,20 +14470,20 @@ const Ze = [
14440
14470
  "TRUNCATE TABLE",
14441
14471
  // other
14442
14472
  "SET SCHEMA"
14443
- ]), sS = L([
14473
+ ]), sS = _([
14444
14474
  "UNION [ALL | DISTINCT]",
14445
14475
  "EXCEPT [ALL | DISTINCT]",
14446
14476
  "INTERSECT [ALL | DISTINCT]"
14447
- ]), CS = L([
14477
+ ]), CS = _([
14448
14478
  "JOIN",
14449
14479
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14450
14480
  "{INNER | CROSS} JOIN",
14451
14481
  "NATURAL [INNER] JOIN",
14452
14482
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
14453
- ]), LS = L([
14483
+ ]), LS = _([
14454
14484
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
14455
14485
  "{ROWS | RANGE} BETWEEN"
14456
- ]), _S = L([]), rS = {
14486
+ ]), _S = _([]), rS = {
14457
14487
  name: "sql",
14458
14488
  tokenizerOptions: {
14459
14489
  reservedSelect: NS,
@@ -15187,7 +15217,7 @@ const Ze = [
15187
15217
  "CODEPOINTS",
15188
15218
  "FUNCTION",
15189
15219
  "JSONPATH"
15190
- ], oS = L(["SELECT [ALL | DISTINCT]"]), DS = L([
15220
+ ], oS = _(["SELECT [ALL | DISTINCT]"]), DS = _([
15191
15221
  // queries
15192
15222
  "WITH [RECURSIVE]",
15193
15223
  "FROM",
@@ -15215,7 +15245,7 @@ const Ze = [
15215
15245
  "PATTERN",
15216
15246
  "SUBSET",
15217
15247
  "DEFINE"
15218
- ]), CT = L(["CREATE TABLE [IF NOT EXISTS]"]), uE = L([
15248
+ ]), CT = _(["CREATE TABLE [IF NOT EXISTS]"]), uE = _([
15219
15249
  // - create:
15220
15250
  "CREATE [OR REPLACE] [MATERIALIZED] VIEW",
15221
15251
  // - update:
@@ -15273,21 +15303,21 @@ const Ze = [
15273
15303
  "SHOW ROLE GRANTS",
15274
15304
  "SHOW FUNCTIONS",
15275
15305
  "SHOW SESSION"
15276
- ]), PS = L([
15306
+ ]), PS = _([
15277
15307
  "UNION [ALL | DISTINCT]",
15278
15308
  "EXCEPT [ALL | DISTINCT]",
15279
15309
  "INTERSECT [ALL | DISTINCT]"
15280
- ]), MS = L([
15310
+ ]), MS = _([
15281
15311
  "JOIN",
15282
15312
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
15283
15313
  "{INNER | CROSS} JOIN",
15284
15314
  "NATURAL [INNER] JOIN",
15285
15315
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
15286
- ]), US = L([
15316
+ ]), US = _([
15287
15317
  "{ROWS | RANGE | GROUPS} BETWEEN",
15288
15318
  // comparison operator
15289
15319
  "IS [NOT] DISTINCT FROM"
15290
- ]), cS = L([]), GS = {
15320
+ ]), cS = _([]), GS = {
15291
15321
  name: "trino",
15292
15322
  tokenizerOptions: {
15293
15323
  reservedSelect: oS,
@@ -15843,7 +15873,7 @@ const Ze = [
15843
15873
  "TIMESTAMP",
15844
15874
  "VARBINARY",
15845
15875
  "VARCHAR"
15846
- ], BS = L(["SELECT [ALL | DISTINCT]"]), dS = L([
15876
+ ], BS = _(["SELECT [ALL | DISTINCT]"]), dS = _([
15847
15877
  // queries
15848
15878
  "WITH",
15849
15879
  "INTO",
@@ -15868,7 +15898,7 @@ const Ze = [
15868
15898
  "MERGE [INTO]",
15869
15899
  "WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
15870
15900
  "UPDATE SET"
15871
- ]), LT = L(["CREATE TABLE"]), HE = L([
15901
+ ]), LT = _(["CREATE TABLE"]), HE = _([
15872
15902
  // - create:
15873
15903
  "CREATE [OR ALTER] [MATERIALIZED] VIEW",
15874
15904
  // - update:
@@ -16048,16 +16078,16 @@ const Ze = [
16048
16078
  "XACT_ABORT",
16049
16079
  "XML INDEX",
16050
16080
  "XML SCHEMA COLLECTION"
16051
- ]), FS = L(["UNION [ALL]", "EXCEPT", "INTERSECT"]), mS = L([
16081
+ ]), FS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), mS = _([
16052
16082
  "JOIN",
16053
16083
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
16054
16084
  "{INNER | CROSS} JOIN",
16055
16085
  // non-standard joins
16056
16086
  "{CROSS | OUTER} APPLY"
16057
- ]), pS = L([
16087
+ ]), pS = _([
16058
16088
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
16059
16089
  "{ROWS | RANGE} BETWEEN"
16060
- ]), YS = L([]), hS = {
16090
+ ]), YS = _([]), hS = {
16061
16091
  name: "transactsql",
16062
16092
  tokenizerOptions: {
16063
16093
  reservedSelect: BS,
@@ -16643,7 +16673,7 @@ const Ze = [
16643
16673
  "WEEKDAY",
16644
16674
  "WEEKOFYEAR",
16645
16675
  "YEAR"
16646
- ], XS = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), bS = L([
16676
+ ], XS = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), bS = _([
16647
16677
  // queries
16648
16678
  "WITH",
16649
16679
  "FROM",
@@ -16665,9 +16695,9 @@ const Ze = [
16665
16695
  // Data definition
16666
16696
  "CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
16667
16697
  "CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
16668
- ]), _T = L([
16698
+ ]), _T = _([
16669
16699
  "CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
16670
- ]), BE = L([
16700
+ ]), BE = _([
16671
16701
  // - create:
16672
16702
  "CREATE VIEW",
16673
16703
  // - update:
@@ -16844,25 +16874,25 @@ const Ze = [
16844
16874
  "REPEAT",
16845
16875
  "RETURN",
16846
16876
  "WHILE"
16847
- ]), yS = L([
16877
+ ]), yS = _([
16848
16878
  "UNION [ALL | DISTINCT]",
16849
16879
  "EXCEPT",
16850
16880
  "INTERSECT",
16851
16881
  "MINUS"
16852
- ]), KS = L([
16882
+ ]), KS = _([
16853
16883
  "JOIN",
16854
16884
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
16855
16885
  "{INNER | CROSS} JOIN",
16856
16886
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
16857
16887
  // non-standard joins
16858
16888
  "STRAIGHT_JOIN"
16859
- ]), $S = L([
16889
+ ]), $S = _([
16860
16890
  "ON DELETE",
16861
16891
  "ON UPDATE",
16862
16892
  "CHARACTER SET",
16863
16893
  "{ROWS | RANGE} BETWEEN",
16864
16894
  "IDENTIFIED BY"
16865
- ]), gS = L([]), wS = {
16895
+ ]), gS = _([]), wS = {
16866
16896
  name: "singlestoredb",
16867
16897
  tokenizerOptions: {
16868
16898
  reservedSelect: XS,
@@ -17655,7 +17685,7 @@ const Ze = [
17655
17685
  "ARRAY",
17656
17686
  "GEOGRAPHY",
17657
17687
  "GEOMETRY"
17658
- ], QS = L(["SELECT [ALL | DISTINCT]"]), ZS = L([
17688
+ ], QS = _(["SELECT [ALL | DISTINCT]"]), ZS = _([
17659
17689
  // queries
17660
17690
  "WITH [RECURSIVE]",
17661
17691
  "FROM",
@@ -17683,10 +17713,10 @@ const Ze = [
17683
17713
  "WHEN MATCHED [AND]",
17684
17714
  "THEN {UPDATE SET | DELETE}",
17685
17715
  "WHEN NOT MATCHED THEN INSERT"
17686
- ]), rT = L([
17716
+ ]), rT = _([
17687
17717
  "CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
17688
17718
  "CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
17689
- ]), dE = L([
17719
+ ]), dE = _([
17690
17720
  // - create:
17691
17721
  "CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
17692
17722
  // - update:
@@ -17927,14 +17957,14 @@ const Ze = [
17927
17957
  "USE SCHEMA",
17928
17958
  "USE SECONDARY ROLES",
17929
17959
  "USE WAREHOUSE"
17930
- ]), qS = L(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), jS = L([
17960
+ ]), qS = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), jS = _([
17931
17961
  "[INNER] JOIN",
17932
17962
  "[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
17933
17963
  "{CROSS | NATURAL} JOIN"
17934
- ]), kS = L([
17964
+ ]), kS = _([
17935
17965
  "{ROWS | RANGE} BETWEEN",
17936
17966
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
17937
- ]), zS = L([]), EI = {
17967
+ ]), zS = _([]), EI = {
17938
17968
  name: "snowflake",
17939
17969
  tokenizerOptions: {
17940
17970
  reservedSelect: QS,
@@ -18163,125 +18193,125 @@ class rI {
18163
18193
  var T, A, e;
18164
18194
  return this.validRules([
18165
18195
  {
18166
- type: a.DISABLE_COMMENT,
18196
+ type: D.DISABLE_COMMENT,
18167
18197
  regex: /(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy
18168
18198
  },
18169
18199
  {
18170
- type: a.BLOCK_COMMENT,
18200
+ type: D.BLOCK_COMMENT,
18171
18201
  regex: E.nestedBlockComments ? new _I() : /(\/\*[^]*?\*\/)/uy
18172
18202
  },
18173
18203
  {
18174
- type: a.LINE_COMMENT,
18204
+ type: D.LINE_COMMENT,
18175
18205
  regex: SI((T = E.lineCommentTypes) !== null && T !== void 0 ? T : ["--"])
18176
18206
  },
18177
18207
  {
18178
- type: a.QUOTED_IDENTIFIER,
18208
+ type: D.QUOTED_IDENTIFIER,
18179
18209
  regex: DT(E.identTypes)
18180
18210
  },
18181
18211
  {
18182
- type: a.NUMBER,
18212
+ type: D.NUMBER,
18183
18213
  regex: E.underscoresInNumbers ? /(?:0x[0-9a-fA-F_]+|0b[01_]+|(?:-\s*)?(?:[0-9_]*\.[0-9_]+|[0-9_]+(?:\.[0-9_]*)?)(?:[eE][-+]?[0-9_]+(?:\.[0-9_]+)?)?)(?![\w\p{Alphabetic}])/uy : /(?:0x[0-9a-fA-F]+|0b[01]+|(?:-\s*)?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+(?:\.[0-9]+)?)?)(?![\w\p{Alphabetic}])/uy
18184
18214
  },
18185
18215
  // RESERVED_KEYWORD_PHRASE and RESERVED_DATA_TYPE_PHRASE is matched before all other keyword tokens
18186
18216
  // to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
18187
18217
  {
18188
- type: a.RESERVED_KEYWORD_PHRASE,
18218
+ type: D.RESERVED_KEYWORD_PHRASE,
18189
18219
  regex: V((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
18190
18220
  text: d
18191
18221
  },
18192
18222
  {
18193
- type: a.RESERVED_DATA_TYPE_PHRASE,
18223
+ type: D.RESERVED_DATA_TYPE_PHRASE,
18194
18224
  regex: V((e = E.reservedDataTypePhrases) !== null && e !== void 0 ? e : [], E.identChars),
18195
18225
  text: d
18196
18226
  },
18197
18227
  {
18198
- type: a.CASE,
18228
+ type: D.CASE,
18199
18229
  regex: /CASE\b/iuy,
18200
18230
  text: d
18201
18231
  },
18202
18232
  {
18203
- type: a.END,
18233
+ type: D.END,
18204
18234
  regex: /END\b/iuy,
18205
18235
  text: d
18206
18236
  },
18207
18237
  {
18208
- type: a.BETWEEN,
18238
+ type: D.BETWEEN,
18209
18239
  regex: /BETWEEN\b/iuy,
18210
18240
  text: d
18211
18241
  },
18212
18242
  {
18213
- type: a.LIMIT,
18243
+ type: D.LIMIT,
18214
18244
  regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
18215
18245
  text: d
18216
18246
  },
18217
18247
  {
18218
- type: a.RESERVED_CLAUSE,
18248
+ type: D.RESERVED_CLAUSE,
18219
18249
  regex: V(E.reservedClauses, E.identChars),
18220
18250
  text: d
18221
18251
  },
18222
18252
  {
18223
- type: a.RESERVED_SELECT,
18253
+ type: D.RESERVED_SELECT,
18224
18254
  regex: V(E.reservedSelect, E.identChars),
18225
18255
  text: d
18226
18256
  },
18227
18257
  {
18228
- type: a.RESERVED_SET_OPERATION,
18258
+ type: D.RESERVED_SET_OPERATION,
18229
18259
  regex: V(E.reservedSetOperations, E.identChars),
18230
18260
  text: d
18231
18261
  },
18232
18262
  {
18233
- type: a.WHEN,
18263
+ type: D.WHEN,
18234
18264
  regex: /WHEN\b/iuy,
18235
18265
  text: d
18236
18266
  },
18237
18267
  {
18238
- type: a.ELSE,
18268
+ type: D.ELSE,
18239
18269
  regex: /ELSE\b/iuy,
18240
18270
  text: d
18241
18271
  },
18242
18272
  {
18243
- type: a.THEN,
18273
+ type: D.THEN,
18244
18274
  regex: /THEN\b/iuy,
18245
18275
  text: d
18246
18276
  },
18247
18277
  {
18248
- type: a.RESERVED_JOIN,
18278
+ type: D.RESERVED_JOIN,
18249
18279
  regex: V(E.reservedJoins, E.identChars),
18250
18280
  text: d
18251
18281
  },
18252
18282
  {
18253
- type: a.AND,
18283
+ type: D.AND,
18254
18284
  regex: /AND\b/iuy,
18255
18285
  text: d
18256
18286
  },
18257
18287
  {
18258
- type: a.OR,
18288
+ type: D.OR,
18259
18289
  regex: /OR\b/iuy,
18260
18290
  text: d
18261
18291
  },
18262
18292
  {
18263
- type: a.XOR,
18293
+ type: D.XOR,
18264
18294
  regex: E.supportsXor ? /XOR\b/iuy : void 0,
18265
18295
  text: d
18266
18296
  },
18267
18297
  ...E.operatorKeyword ? [
18268
18298
  {
18269
- type: a.OPERATOR,
18299
+ type: D.OPERATOR,
18270
18300
  regex: /OPERATOR *\([^)]+\)/iuy
18271
18301
  }
18272
18302
  ] : [],
18273
18303
  {
18274
- type: a.RESERVED_FUNCTION_NAME,
18304
+ type: D.RESERVED_FUNCTION_NAME,
18275
18305
  regex: V(E.reservedFunctionNames, E.identChars),
18276
18306
  text: d
18277
18307
  },
18278
18308
  {
18279
- type: a.RESERVED_DATA_TYPE,
18309
+ type: D.RESERVED_DATA_TYPE,
18280
18310
  regex: V(E.reservedDataTypes, E.identChars),
18281
18311
  text: d
18282
18312
  },
18283
18313
  {
18284
- type: a.RESERVED_KEYWORD,
18314
+ type: D.RESERVED_KEYWORD,
18285
18315
  regex: V(E.reservedKeywords, E.identChars),
18286
18316
  text: d
18287
18317
  }
@@ -18293,26 +18323,26 @@ class rI {
18293
18323
  var T, A;
18294
18324
  return this.validRules([
18295
18325
  {
18296
- type: a.VARIABLE,
18326
+ type: D.VARIABLE,
18297
18327
  regex: E.variableTypes ? NI(E.variableTypes) : void 0
18298
18328
  },
18299
- { type: a.STRING, regex: DT(E.stringTypes) },
18329
+ { type: D.STRING, regex: DT(E.stringTypes) },
18300
18330
  {
18301
- type: a.IDENTIFIER,
18331
+ type: D.IDENTIFIER,
18302
18332
  regex: tI(E.identChars)
18303
18333
  },
18304
- { type: a.DELIMITER, regex: /[;]/uy },
18305
- { type: a.COMMA, regex: /[,]/y },
18334
+ { type: D.DELIMITER, regex: /[;]/uy },
18335
+ { type: D.COMMA, regex: /[,]/y },
18306
18336
  {
18307
- type: a.OPEN_PAREN,
18337
+ type: D.OPEN_PAREN,
18308
18338
  regex: iT("open", E.extraParens)
18309
18339
  },
18310
18340
  {
18311
- type: a.CLOSE_PAREN,
18341
+ type: D.CLOSE_PAREN,
18312
18342
  regex: iT("close", E.extraParens)
18313
18343
  },
18314
18344
  {
18315
- type: a.OPERATOR,
18345
+ type: D.OPERATOR,
18316
18346
  regex: aT([
18317
18347
  // standard operators
18318
18348
  "+",
@@ -18328,9 +18358,9 @@ class rI {
18328
18358
  ...(T = E.operators) !== null && T !== void 0 ? T : []
18329
18359
  ])
18330
18360
  },
18331
- { type: a.ASTERISK, regex: /[*]/uy },
18361
+ { type: D.ASTERISK, regex: /[*]/uy },
18332
18362
  {
18333
- type: a.PROPERTY_ACCESS_OPERATOR,
18363
+ type: D.PROPERTY_ACCESS_OPERATOR,
18334
18364
  regex: aT([".", ...(A = E.propertyAccessOperators) !== null && A !== void 0 ? A : []])
18335
18365
  }
18336
18366
  ]);
@@ -18348,33 +18378,33 @@ class rI {
18348
18378
  };
18349
18379
  return this.validRules([
18350
18380
  {
18351
- type: a.NAMED_PARAMETER,
18381
+ type: D.NAMED_PARAMETER,
18352
18382
  regex: mE(C.named, fT(E.paramChars || E.identChars)),
18353
- key: (N) => N.slice(1)
18383
+ key: (O) => O.slice(1)
18354
18384
  },
18355
18385
  {
18356
- type: a.QUOTED_PARAMETER,
18386
+ type: D.QUOTED_PARAMETER,
18357
18387
  regex: mE(C.quoted, hT(E.identTypes)),
18358
- key: (N) => (({ tokenKey: O, quoteChar: s }) => O.replace(new RegExp(h("\\" + s), "gu"), s))({
18359
- tokenKey: N.slice(2, -1),
18360
- quoteChar: N.slice(-1)
18388
+ key: (O) => (({ tokenKey: N, quoteChar: s }) => N.replace(new RegExp(h("\\" + s), "gu"), s))({
18389
+ tokenKey: O.slice(2, -1),
18390
+ quoteChar: O.slice(-1)
18361
18391
  })
18362
18392
  },
18363
18393
  {
18364
- type: a.NUMBERED_PARAMETER,
18394
+ type: D.NUMBERED_PARAMETER,
18365
18395
  regex: mE(C.numbered, "[0-9]+"),
18366
- key: (N) => N.slice(1)
18396
+ key: (O) => O.slice(1)
18367
18397
  },
18368
18398
  {
18369
- type: a.POSITIONAL_PARAMETER,
18399
+ type: D.POSITIONAL_PARAMETER,
18370
18400
  regex: C.positional ? /[?]/y : void 0
18371
18401
  },
18372
- ...C.custom.map((N) => {
18373
- var O;
18402
+ ...C.custom.map((O) => {
18403
+ var N;
18374
18404
  return {
18375
- type: a.CUSTOM_PARAMETER,
18376
- regex: K(N.regex),
18377
- key: (O = N.key) !== null && O !== void 0 ? O : ((s) => s)
18405
+ type: D.CUSTOM_PARAMETER,
18406
+ regex: K(O.regex),
18407
+ key: (N = O.key) !== null && N !== void 0 ? N : ((s) => s)
18378
18408
  };
18379
18409
  })
18380
18410
  ]);
@@ -18436,195 +18466,195 @@ function UI() {
18436
18466
  (function(E, T) {
18437
18467
  R.exports ? R.exports = T() : E.nearley = T();
18438
18468
  })(MI, function() {
18439
- function E(N, O, s) {
18440
- return this.id = ++E.highestId, this.name = N, this.symbols = O, this.postprocess = s, this;
18469
+ function E(O, N, s) {
18470
+ return this.id = ++E.highestId, this.name = O, this.symbols = N, this.postprocess = s, this;
18441
18471
  }
18442
- E.highestId = 0, E.prototype.toString = function(N) {
18443
- var O = typeof N > "u" ? this.symbols.map(C).join(" ") : this.symbols.slice(0, N).map(C).join(" ") + " ● " + this.symbols.slice(N).map(C).join(" ");
18444
- return this.name + " → " + O;
18472
+ E.highestId = 0, E.prototype.toString = function(O) {
18473
+ var N = typeof O > "u" ? this.symbols.map(C).join(" ") : this.symbols.slice(0, O).map(C).join(" ") + " ● " + this.symbols.slice(O).map(C).join(" ");
18474
+ return this.name + " → " + N;
18445
18475
  };
18446
- function T(N, O, s, _) {
18447
- this.rule = N, this.dot = O, this.reference = s, this.data = [], this.wantedBy = _, this.isComplete = this.dot === N.symbols.length;
18476
+ function T(O, N, s, r) {
18477
+ this.rule = O, this.dot = N, this.reference = s, this.data = [], this.wantedBy = r, this.isComplete = this.dot === O.symbols.length;
18448
18478
  }
18449
18479
  T.prototype.toString = function() {
18450
18480
  return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
18451
- }, T.prototype.nextState = function(N) {
18452
- var O = new T(this.rule, this.dot + 1, this.reference, this.wantedBy);
18453
- return O.left = this, O.right = N, O.isComplete && (O.data = O.build(), O.right = void 0), O;
18481
+ }, T.prototype.nextState = function(O) {
18482
+ var N = new T(this.rule, this.dot + 1, this.reference, this.wantedBy);
18483
+ return N.left = this, N.right = O, N.isComplete && (N.data = N.build(), N.right = void 0), N;
18454
18484
  }, T.prototype.build = function() {
18455
- var N = [], O = this;
18485
+ var O = [], N = this;
18456
18486
  do
18457
- N.push(O.right.data), O = O.left;
18458
- while (O.left);
18459
- return N.reverse(), N;
18487
+ O.push(N.right.data), N = N.left;
18488
+ while (N.left);
18489
+ return O.reverse(), O;
18460
18490
  }, T.prototype.finish = function() {
18461
18491
  this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, I.fail));
18462
18492
  };
18463
- function A(N, O) {
18464
- this.grammar = N, this.index = O, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
18493
+ function A(O, N) {
18494
+ this.grammar = O, this.index = N, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
18465
18495
  }
18466
- A.prototype.process = function(N) {
18467
- for (var O = this.states, s = this.wants, _ = this.completed, n = 0; n < O.length; n++) {
18468
- var D = O[n];
18469
- if (D.isComplete) {
18470
- if (D.finish(), D.data !== I.fail) {
18471
- for (var o = D.wantedBy, l = o.length; l--; ) {
18496
+ A.prototype.process = function(O) {
18497
+ for (var N = this.states, s = this.wants, r = this.completed, L = 0; L < N.length; L++) {
18498
+ var i = N[L];
18499
+ if (i.isComplete) {
18500
+ if (i.finish(), i.data !== I.fail) {
18501
+ for (var o = i.wantedBy, l = o.length; l--; ) {
18472
18502
  var P = o[l];
18473
- this.complete(P, D);
18503
+ this.complete(P, i);
18474
18504
  }
18475
- if (D.reference === this.index) {
18476
- var c = D.rule.name;
18477
- (this.completed[c] = this.completed[c] || []).push(D);
18505
+ if (i.reference === this.index) {
18506
+ var c = i.rule.name;
18507
+ (this.completed[c] = this.completed[c] || []).push(i);
18478
18508
  }
18479
18509
  }
18480
18510
  } else {
18481
- var c = D.rule.symbols[D.dot];
18511
+ var c = i.rule.symbols[i.dot];
18482
18512
  if (typeof c != "string") {
18483
- this.scannable.push(D);
18513
+ this.scannable.push(i);
18484
18514
  continue;
18485
18515
  }
18486
18516
  if (s[c]) {
18487
- if (s[c].push(D), _.hasOwnProperty(c))
18488
- for (var M = _[c], l = 0; l < M.length; l++) {
18517
+ if (s[c].push(i), r.hasOwnProperty(c))
18518
+ for (var M = r[c], l = 0; l < M.length; l++) {
18489
18519
  var u = M[l];
18490
- this.complete(D, u);
18520
+ this.complete(i, u);
18491
18521
  }
18492
18522
  } else
18493
- s[c] = [D], this.predict(c);
18523
+ s[c] = [i], this.predict(c);
18494
18524
  }
18495
18525
  }
18496
- }, A.prototype.predict = function(N) {
18497
- for (var O = this.grammar.byName[N] || [], s = 0; s < O.length; s++) {
18498
- var _ = O[s], n = this.wants[N], D = new T(_, 0, this.index, n);
18499
- this.states.push(D);
18526
+ }, A.prototype.predict = function(O) {
18527
+ for (var N = this.grammar.byName[O] || [], s = 0; s < N.length; s++) {
18528
+ var r = N[s], L = this.wants[O], i = new T(r, 0, this.index, L);
18529
+ this.states.push(i);
18500
18530
  }
18501
- }, A.prototype.complete = function(N, O) {
18502
- var s = N.nextState(O);
18531
+ }, A.prototype.complete = function(O, N) {
18532
+ var s = O.nextState(N);
18503
18533
  this.states.push(s);
18504
18534
  };
18505
- function e(N, O) {
18506
- this.rules = N, this.start = O || this.rules[0].name;
18535
+ function e(O, N) {
18536
+ this.rules = O, this.start = N || this.rules[0].name;
18507
18537
  var s = this.byName = {};
18508
- this.rules.forEach(function(_) {
18509
- s.hasOwnProperty(_.name) || (s[_.name] = []), s[_.name].push(_);
18538
+ this.rules.forEach(function(r) {
18539
+ s.hasOwnProperty(r.name) || (s[r.name] = []), s[r.name].push(r);
18510
18540
  });
18511
18541
  }
18512
- e.fromCompiled = function(_, O) {
18513
- var s = _.Lexer;
18514
- _.ParserStart && (O = _.ParserStart, _ = _.ParserRules);
18515
- var _ = _.map(function(D) {
18516
- return new E(D.name, D.symbols, D.postprocess);
18517
- }), n = new e(_, O);
18518
- return n.lexer = s, n;
18542
+ e.fromCompiled = function(r, N) {
18543
+ var s = r.Lexer;
18544
+ r.ParserStart && (N = r.ParserStart, r = r.ParserRules);
18545
+ var r = r.map(function(i) {
18546
+ return new E(i.name, i.symbols, i.postprocess);
18547
+ }), L = new e(r, N);
18548
+ return L.lexer = s, L;
18519
18549
  };
18520
18550
  function S() {
18521
18551
  this.reset("");
18522
18552
  }
18523
- S.prototype.reset = function(N, O) {
18524
- this.buffer = N, this.index = 0, this.line = O ? O.line : 1, this.lastLineBreak = O ? -O.col : 0;
18553
+ S.prototype.reset = function(O, N) {
18554
+ this.buffer = O, this.index = 0, this.line = N ? N.line : 1, this.lastLineBreak = N ? -N.col : 0;
18525
18555
  }, S.prototype.next = function() {
18526
18556
  if (this.index < this.buffer.length) {
18527
- var N = this.buffer[this.index++];
18528
- return N === `
18529
- ` && (this.line += 1, this.lastLineBreak = this.index), { value: N };
18557
+ var O = this.buffer[this.index++];
18558
+ return O === `
18559
+ ` && (this.line += 1, this.lastLineBreak = this.index), { value: O };
18530
18560
  }
18531
18561
  }, S.prototype.save = function() {
18532
18562
  return {
18533
18563
  line: this.line,
18534
18564
  col: this.index - this.lastLineBreak
18535
18565
  };
18536
- }, S.prototype.formatError = function(N, O) {
18566
+ }, S.prototype.formatError = function(O, N) {
18537
18567
  var s = this.buffer;
18538
18568
  if (typeof s == "string") {
18539
- var _ = s.split(`
18569
+ var r = s.split(`
18540
18570
  `).slice(
18541
18571
  Math.max(0, this.line - 5),
18542
18572
  this.line
18543
- ), n = s.indexOf(`
18573
+ ), L = s.indexOf(`
18544
18574
  `, this.index);
18545
- n === -1 && (n = s.length);
18546
- var D = this.index - this.lastLineBreak, o = String(this.line).length;
18547
- return O += " at line " + this.line + " col " + D + `:
18575
+ L === -1 && (L = s.length);
18576
+ var i = this.index - this.lastLineBreak, o = String(this.line).length;
18577
+ return N += " at line " + this.line + " col " + i + `:
18548
18578
 
18549
- `, O += _.map(function(P, c) {
18550
- return l(this.line - _.length + c + 1, o) + " " + P;
18579
+ `, N += r.map(function(P, c) {
18580
+ return l(this.line - r.length + c + 1, o) + " " + P;
18551
18581
  }, this).join(`
18552
- `), O += `
18553
- ` + l("", o + D) + `^
18554
- `, O;
18582
+ `), N += `
18583
+ ` + l("", o + i) + `^
18584
+ `, N;
18555
18585
  } else
18556
- return O + " at index " + (this.index - 1);
18586
+ return N + " at index " + (this.index - 1);
18557
18587
  function l(P, c) {
18558
18588
  var M = String(P);
18559
18589
  return Array(c - M.length + 1).join(" ") + M;
18560
18590
  }
18561
18591
  };
18562
- function I(N, O, s) {
18563
- if (N instanceof e)
18564
- var _ = N, s = O;
18592
+ function I(O, N, s) {
18593
+ if (O instanceof e)
18594
+ var r = O, s = N;
18565
18595
  else
18566
- var _ = e.fromCompiled(N, O);
18567
- this.grammar = _, this.options = {
18596
+ var r = e.fromCompiled(O, N);
18597
+ this.grammar = r, this.options = {
18568
18598
  keepHistory: !1,
18569
- lexer: _.lexer || new S()
18599
+ lexer: r.lexer || new S()
18570
18600
  };
18571
- for (var n in s || {})
18572
- this.options[n] = s[n];
18601
+ for (var L in s || {})
18602
+ this.options[L] = s[L];
18573
18603
  this.lexer = this.options.lexer, this.lexerState = void 0;
18574
- var D = new A(_, 0);
18575
- this.table = [D], D.wants[_.start] = [], D.predict(_.start), D.process(), this.current = 0;
18604
+ var i = new A(r, 0);
18605
+ this.table = [i], i.wants[r.start] = [], i.predict(r.start), i.process(), this.current = 0;
18576
18606
  }
18577
- I.fail = {}, I.prototype.feed = function(N) {
18578
- var O = this.lexer;
18579
- O.reset(N, this.lexerState);
18607
+ I.fail = {}, I.prototype.feed = function(O) {
18608
+ var N = this.lexer;
18609
+ N.reset(O, this.lexerState);
18580
18610
  for (var s; ; ) {
18581
18611
  try {
18582
- if (s = O.next(), !s)
18612
+ if (s = N.next(), !s)
18583
18613
  break;
18584
18614
  } catch (Y) {
18585
18615
  var o = new A(this.grammar, this.current + 1);
18586
18616
  this.table.push(o);
18587
- var _ = new Error(this.reportLexerError(Y));
18588
- throw _.offset = this.current, _.token = Y.token, _;
18617
+ var r = new Error(this.reportLexerError(Y));
18618
+ throw r.offset = this.current, r.token = Y.token, r;
18589
18619
  }
18590
- var n = this.table[this.current];
18620
+ var L = this.table[this.current];
18591
18621
  this.options.keepHistory || delete this.table[this.current - 1];
18592
- var D = this.current + 1, o = new A(this.grammar, D);
18622
+ var i = this.current + 1, o = new A(this.grammar, i);
18593
18623
  this.table.push(o);
18594
- for (var l = s.text !== void 0 ? s.text : s.value, P = O.constructor === S ? s.value : s, c = n.scannable, M = c.length; M--; ) {
18624
+ for (var l = s.text !== void 0 ? s.text : s.value, P = N.constructor === S ? s.value : s, c = L.scannable, M = c.length; M--; ) {
18595
18625
  var u = c[M], H = u.rule.symbols[u.dot];
18596
18626
  if (H.test ? H.test(P) : H.type ? H.type === s.type : H.literal === l) {
18597
- var B = u.nextState({ data: P, token: s, isToken: !0, reference: D - 1 });
18627
+ var B = u.nextState({ data: P, token: s, isToken: !0, reference: i - 1 });
18598
18628
  o.states.push(B);
18599
18629
  }
18600
18630
  }
18601
18631
  if (o.process(), o.states.length === 0) {
18602
- var _ = new Error(this.reportError(s));
18603
- throw _.offset = this.current, _.token = s, _;
18632
+ var r = new Error(this.reportError(s));
18633
+ throw r.offset = this.current, r.token = s, r;
18604
18634
  }
18605
- this.options.keepHistory && (n.lexerState = O.save()), this.current++;
18635
+ this.options.keepHistory && (L.lexerState = N.save()), this.current++;
18606
18636
  }
18607
- return n && (this.lexerState = O.save()), this.results = this.finish(), this;
18608
- }, I.prototype.reportLexerError = function(N) {
18609
- var O, s, _ = N.token;
18610
- return _ ? (O = "input " + JSON.stringify(_.text[0]) + " (lexer error)", s = this.lexer.formatError(_, "Syntax error")) : (O = "input (lexer error)", s = N.message), this.reportErrorCommon(s, O);
18611
- }, I.prototype.reportError = function(N) {
18612
- var O = (N.type ? N.type + " token: " : "") + JSON.stringify(N.value !== void 0 ? N.value : N), s = this.lexer.formatError(N, "Syntax error");
18613
- return this.reportErrorCommon(s, O);
18614
- }, I.prototype.reportErrorCommon = function(N, O) {
18637
+ return L && (this.lexerState = N.save()), this.results = this.finish(), this;
18638
+ }, I.prototype.reportLexerError = function(O) {
18639
+ var N, s, r = O.token;
18640
+ return r ? (N = "input " + JSON.stringify(r.text[0]) + " (lexer error)", s = this.lexer.formatError(r, "Syntax error")) : (N = "input (lexer error)", s = O.message), this.reportErrorCommon(s, N);
18641
+ }, I.prototype.reportError = function(O) {
18642
+ var N = (O.type ? O.type + " token: " : "") + JSON.stringify(O.value !== void 0 ? O.value : O), s = this.lexer.formatError(O, "Syntax error");
18643
+ return this.reportErrorCommon(s, N);
18644
+ }, I.prototype.reportErrorCommon = function(O, N) {
18615
18645
  var s = [];
18616
- s.push(N);
18617
- var _ = this.table.length - 2, n = this.table[_], D = n.states.filter(function(l) {
18646
+ s.push(O);
18647
+ var r = this.table.length - 2, L = this.table[r], i = L.states.filter(function(l) {
18618
18648
  var P = l.rule.symbols[l.dot];
18619
18649
  return P && typeof P != "string";
18620
18650
  });
18621
- if (D.length === 0)
18622
- s.push("Unexpected " + O + `. I did not expect any more input. Here is the state of my parse table:
18623
- `), this.displayStateStack(n.states, s);
18651
+ if (i.length === 0)
18652
+ s.push("Unexpected " + N + `. I did not expect any more input. Here is the state of my parse table:
18653
+ `), this.displayStateStack(L.states, s);
18624
18654
  else {
18625
- s.push("Unexpected " + O + `. Instead, I was expecting to see one of the following:
18655
+ s.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
18626
18656
  `);
18627
- var o = D.map(function(l) {
18657
+ var o = i.map(function(l) {
18628
18658
  return this.buildFirstStateStack(l, []) || [l];
18629
18659
  }, this);
18630
18660
  o.forEach(function(l) {
@@ -18634,68 +18664,68 @@ function UI() {
18634
18664
  }
18635
18665
  return s.push(""), s.join(`
18636
18666
  `);
18637
- }, I.prototype.displayStateStack = function(N, O) {
18638
- for (var s, _ = 0, n = 0; n < N.length; n++) {
18639
- var D = N[n], o = D.rule.toString(D.dot);
18640
- o === s ? _++ : (_ > 0 && O.push(" ^ " + _ + " more lines identical to this"), _ = 0, O.push(" " + o)), s = o;
18667
+ }, I.prototype.displayStateStack = function(O, N) {
18668
+ for (var s, r = 0, L = 0; L < O.length; L++) {
18669
+ var i = O[L], o = i.rule.toString(i.dot);
18670
+ o === s ? r++ : (r > 0 && N.push(" ^ " + r + " more lines identical to this"), r = 0, N.push(" " + o)), s = o;
18641
18671
  }
18642
- }, I.prototype.getSymbolDisplay = function(N) {
18643
- return t(N);
18644
- }, I.prototype.buildFirstStateStack = function(N, O) {
18645
- if (O.indexOf(N) !== -1)
18672
+ }, I.prototype.getSymbolDisplay = function(O) {
18673
+ return t(O);
18674
+ }, I.prototype.buildFirstStateStack = function(O, N) {
18675
+ if (N.indexOf(O) !== -1)
18646
18676
  return null;
18647
- if (N.wantedBy.length === 0)
18648
- return [N];
18649
- var s = N.wantedBy[0], _ = [N].concat(O), n = this.buildFirstStateStack(s, _);
18650
- return n === null ? null : [N].concat(n);
18677
+ if (O.wantedBy.length === 0)
18678
+ return [O];
18679
+ var s = O.wantedBy[0], r = [O].concat(N), L = this.buildFirstStateStack(s, r);
18680
+ return L === null ? null : [O].concat(L);
18651
18681
  }, I.prototype.save = function() {
18652
- var N = this.table[this.current];
18653
- return N.lexerState = this.lexerState, N;
18654
- }, I.prototype.restore = function(N) {
18655
- var O = N.index;
18656
- this.current = O, this.table[O] = N, this.table.splice(O + 1), this.lexerState = N.lexerState, this.results = this.finish();
18657
- }, I.prototype.rewind = function(N) {
18682
+ var O = this.table[this.current];
18683
+ return O.lexerState = this.lexerState, O;
18684
+ }, I.prototype.restore = function(O) {
18685
+ var N = O.index;
18686
+ this.current = N, this.table[N] = O, this.table.splice(N + 1), this.lexerState = O.lexerState, this.results = this.finish();
18687
+ }, I.prototype.rewind = function(O) {
18658
18688
  if (!this.options.keepHistory)
18659
18689
  throw new Error("set option `keepHistory` to enable rewinding");
18660
- this.restore(this.table[N]);
18690
+ this.restore(this.table[O]);
18661
18691
  }, I.prototype.finish = function() {
18662
- var N = [], O = this.grammar.start, s = this.table[this.table.length - 1];
18663
- return s.states.forEach(function(_) {
18664
- _.rule.name === O && _.dot === _.rule.symbols.length && _.reference === 0 && _.data !== I.fail && N.push(_);
18665
- }), N.map(function(_) {
18666
- return _.data;
18692
+ var O = [], N = this.grammar.start, s = this.table[this.table.length - 1];
18693
+ return s.states.forEach(function(r) {
18694
+ r.rule.name === N && r.dot === r.rule.symbols.length && r.reference === 0 && r.data !== I.fail && O.push(r);
18695
+ }), O.map(function(r) {
18696
+ return r.data;
18667
18697
  });
18668
18698
  };
18669
- function t(N) {
18670
- var O = typeof N;
18671
- if (O === "string")
18672
- return N;
18673
- if (O === "object") {
18674
- if (N.literal)
18675
- return JSON.stringify(N.literal);
18676
- if (N instanceof RegExp)
18677
- return "character matching " + N;
18678
- if (N.type)
18679
- return N.type + " token";
18680
- if (N.test)
18681
- return "token matching " + String(N.test);
18682
- throw new Error("Unknown symbol type: " + N);
18699
+ function t(O) {
18700
+ var N = typeof O;
18701
+ if (N === "string")
18702
+ return O;
18703
+ if (N === "object") {
18704
+ if (O.literal)
18705
+ return JSON.stringify(O.literal);
18706
+ if (O instanceof RegExp)
18707
+ return "character matching " + O;
18708
+ if (O.type)
18709
+ return O.type + " token";
18710
+ if (O.test)
18711
+ return "token matching " + String(O.test);
18712
+ throw new Error("Unknown symbol type: " + O);
18683
18713
  }
18684
18714
  }
18685
- function C(N) {
18686
- var O = typeof N;
18687
- if (O === "string")
18688
- return N;
18689
- if (O === "object") {
18690
- if (N.literal)
18691
- return JSON.stringify(N.literal);
18692
- if (N instanceof RegExp)
18693
- return N.toString();
18694
- if (N.type)
18695
- return "%" + N.type;
18696
- if (N.test)
18697
- return "<" + String(N.test) + ">";
18698
- throw new Error("Unknown symbol type: " + N);
18715
+ function C(O) {
18716
+ var N = typeof O;
18717
+ if (N === "string")
18718
+ return O;
18719
+ if (N === "object") {
18720
+ if (O.literal)
18721
+ return JSON.stringify(O.literal);
18722
+ if (O instanceof RegExp)
18723
+ return O.toString();
18724
+ if (O.type)
18725
+ return "%" + O.type;
18726
+ if (O.test)
18727
+ return "<" + String(O.test) + ">";
18728
+ throw new Error("Unknown symbol type: " + O);
18699
18729
  }
18700
18730
  }
18701
18731
  return {
@@ -18714,39 +18744,39 @@ function lI(R) {
18714
18744
  const uI = (R, E, T) => {
18715
18745
  if (mT(R.type)) {
18716
18746
  const A = mI(T, E);
18717
- if (A && A.type === a.PROPERTY_ACCESS_OPERATOR)
18718
- return Object.assign(Object.assign({}, R), { type: a.IDENTIFIER, text: R.raw });
18747
+ if (A && A.type === D.PROPERTY_ACCESS_OPERATOR)
18748
+ return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
18719
18749
  const e = Q(T, E);
18720
- if (e && e.type === a.PROPERTY_ACCESS_OPERATOR)
18721
- return Object.assign(Object.assign({}, R), { type: a.IDENTIFIER, text: R.raw });
18750
+ if (e && e.type === D.PROPERTY_ACCESS_OPERATOR)
18751
+ return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
18722
18752
  }
18723
18753
  return R;
18724
18754
  }, HI = (R, E, T) => {
18725
- if (R.type === a.RESERVED_FUNCTION_NAME) {
18755
+ if (R.type === D.RESERVED_FUNCTION_NAME) {
18726
18756
  const A = Q(T, E);
18727
18757
  if (!A || !WT(A))
18728
- return Object.assign(Object.assign({}, R), { type: a.IDENTIFIER, text: R.raw });
18758
+ return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
18729
18759
  }
18730
18760
  return R;
18731
18761
  }, BI = (R, E, T) => {
18732
- if (R.type === a.RESERVED_DATA_TYPE) {
18762
+ if (R.type === D.RESERVED_DATA_TYPE) {
18733
18763
  const A = Q(T, E);
18734
18764
  if (A && WT(A))
18735
- return Object.assign(Object.assign({}, R), { type: a.RESERVED_PARAMETERIZED_DATA_TYPE });
18765
+ return Object.assign(Object.assign({}, R), { type: D.RESERVED_PARAMETERIZED_DATA_TYPE });
18736
18766
  }
18737
18767
  return R;
18738
18768
  }, dI = (R, E, T) => {
18739
- if (R.type === a.IDENTIFIER) {
18769
+ if (R.type === D.IDENTIFIER) {
18740
18770
  const A = Q(T, E);
18741
18771
  if (A && XT(A))
18742
- return Object.assign(Object.assign({}, R), { type: a.ARRAY_IDENTIFIER });
18772
+ return Object.assign(Object.assign({}, R), { type: D.ARRAY_IDENTIFIER });
18743
18773
  }
18744
18774
  return R;
18745
18775
  }, FI = (R, E, T) => {
18746
- if (R.type === a.RESERVED_DATA_TYPE) {
18776
+ if (R.type === D.RESERVED_DATA_TYPE) {
18747
18777
  const A = Q(T, E);
18748
18778
  if (A && XT(A))
18749
- return Object.assign(Object.assign({}, R), { type: a.ARRAY_KEYWORD });
18779
+ return Object.assign(Object.assign({}, R), { type: D.ARRAY_KEYWORD });
18750
18780
  }
18751
18781
  return R;
18752
18782
  }, mI = (R, E) => Q(R, E, -1), Q = (R, E, T = 1) => {
@@ -18754,7 +18784,7 @@ const uI = (R, E, T) => {
18754
18784
  for (; R[E + A * T] && pI(R[E + A * T]); )
18755
18785
  A++;
18756
18786
  return R[E + A * T];
18757
- }, WT = (R) => R.type === a.OPEN_PAREN && R.text === "(", XT = (R) => R.type === a.OPEN_PAREN && R.text === "[", pI = (R) => R.type === a.BLOCK_COMMENT || R.type === a.LINE_COMMENT;
18787
+ }, WT = (R) => R.type === D.OPEN_PAREN && R.text === "(", XT = (R) => R.type === D.OPEN_PAREN && R.text === "[", pI = (R) => R.type === D.BLOCK_COMMENT || R.type === D.LINE_COMMENT;
18758
18788
  class bT {
18759
18789
  constructor(E) {
18760
18790
  this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
@@ -18772,7 +18802,7 @@ class bT {
18772
18802
  return `Parse error at token: ${E.text} at line ${T} column ${A}`;
18773
18803
  }
18774
18804
  has(E) {
18775
- return E in a;
18805
+ return E in D;
18776
18806
  }
18777
18807
  }
18778
18808
  var U;
@@ -18822,7 +18852,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
18822
18852
  postprocess: ([R, [E]]) => ({
18823
18853
  type: U.statement,
18824
18854
  children: R,
18825
- hasSemicolon: E.type === a.DELIMITER
18855
+ hasSemicolon: E.type === D.DELIMITER
18826
18856
  })
18827
18857
  },
18828
18858
  { name: "expressions_or_clauses$ebnf$1", symbols: [] },
@@ -19216,10 +19246,10 @@ ${JSON.stringify(I, void 0, 2)}`);
19216
19246
  }
19217
19247
  };
19218
19248
  }
19219
- var i;
19249
+ var a;
19220
19250
  (function(R) {
19221
19251
  R[R.SPACE = 0] = "SPACE", R[R.NO_SPACE = 1] = "NO_SPACE", R[R.NO_NEWLINE = 2] = "NO_NEWLINE", R[R.NEWLINE = 3] = "NEWLINE", R[R.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", R[R.INDENT = 5] = "INDENT", R[R.SINGLE_INDENT = 6] = "SINGLE_INDENT";
19222
- })(i = i || (i = {}));
19252
+ })(a = a || (a = {}));
19223
19253
  class yT {
19224
19254
  constructor(E) {
19225
19255
  this.indentation = E, this.items = [];
@@ -19230,26 +19260,26 @@ class yT {
19230
19260
  add(...E) {
19231
19261
  for (const T of E)
19232
19262
  switch (T) {
19233
- case i.SPACE:
19234
- this.items.push(i.SPACE);
19263
+ case a.SPACE:
19264
+ this.items.push(a.SPACE);
19235
19265
  break;
19236
- case i.NO_SPACE:
19266
+ case a.NO_SPACE:
19237
19267
  this.trimHorizontalWhitespace();
19238
19268
  break;
19239
- case i.NO_NEWLINE:
19269
+ case a.NO_NEWLINE:
19240
19270
  this.trimWhitespace();
19241
19271
  break;
19242
- case i.NEWLINE:
19243
- this.trimHorizontalWhitespace(), this.addNewline(i.NEWLINE);
19272
+ case a.NEWLINE:
19273
+ this.trimHorizontalWhitespace(), this.addNewline(a.NEWLINE);
19244
19274
  break;
19245
- case i.MANDATORY_NEWLINE:
19246
- this.trimHorizontalWhitespace(), this.addNewline(i.MANDATORY_NEWLINE);
19275
+ case a.MANDATORY_NEWLINE:
19276
+ this.trimHorizontalWhitespace(), this.addNewline(a.MANDATORY_NEWLINE);
19247
19277
  break;
19248
- case i.INDENT:
19278
+ case a.INDENT:
19249
19279
  this.addIndentation();
19250
19280
  break;
19251
- case i.SINGLE_INDENT:
19252
- this.items.push(i.SINGLE_INDENT);
19281
+ case a.SINGLE_INDENT:
19282
+ this.items.push(a.SINGLE_INDENT);
19253
19283
  break;
19254
19284
  default:
19255
19285
  this.items.push(T);
@@ -19266,10 +19296,10 @@ class yT {
19266
19296
  addNewline(E) {
19267
19297
  if (this.items.length > 0)
19268
19298
  switch (Z(this.items)) {
19269
- case i.NEWLINE:
19299
+ case a.NEWLINE:
19270
19300
  this.items.pop(), this.items.push(E);
19271
19301
  break;
19272
- case i.MANDATORY_NEWLINE:
19302
+ case a.MANDATORY_NEWLINE:
19273
19303
  break;
19274
19304
  default:
19275
19305
  this.items.push(E);
@@ -19278,7 +19308,7 @@ class yT {
19278
19308
  }
19279
19309
  addIndentation() {
19280
19310
  for (let E = 0; E < this.indentation.getLevel(); E++)
19281
- this.items.push(i.SINGLE_INDENT);
19311
+ this.items.push(a.SINGLE_INDENT);
19282
19312
  }
19283
19313
  /**
19284
19314
  * Returns the final SQL string.
@@ -19294,20 +19324,20 @@ class yT {
19294
19324
  }
19295
19325
  itemToString(E) {
19296
19326
  switch (E) {
19297
- case i.SPACE:
19327
+ case a.SPACE:
19298
19328
  return " ";
19299
- case i.NEWLINE:
19300
- case i.MANDATORY_NEWLINE:
19329
+ case a.NEWLINE:
19330
+ case a.MANDATORY_NEWLINE:
19301
19331
  return `
19302
19332
  `;
19303
- case i.SINGLE_INDENT:
19333
+ case a.SINGLE_INDENT:
19304
19334
  return this.indentation.getSingleIndent();
19305
19335
  default:
19306
19336
  return E;
19307
19337
  }
19308
19338
  }
19309
19339
  }
19310
- const XI = (R) => R === i.SPACE || R === i.SINGLE_INDENT, bI = (R) => R === i.SPACE || R === i.SINGLE_INDENT || R === i.NEWLINE;
19340
+ const XI = (R) => R === a.SPACE || R === a.SINGLE_INDENT, bI = (R) => R === a.SPACE || R === a.SINGLE_INDENT || R === a.NEWLINE;
19311
19341
  function GT(R, E) {
19312
19342
  if (E === "standard")
19313
19343
  return R;
@@ -19315,7 +19345,7 @@ function GT(R, E) {
19315
19345
  return R.length >= 10 && R.includes(" ") && ([R, ...T] = R.split(" ")), E === "tabularLeft" ? R = R.padEnd(9, " ") : R = R.padStart(9, " "), R + ["", ...T].join(" ");
19316
19346
  }
19317
19347
  function lT(R) {
19318
- return PR(R) || R === a.RESERVED_CLAUSE || R === a.RESERVED_SELECT || R === a.RESERVED_SET_OPERATION || R === a.RESERVED_JOIN || R === a.LIMIT;
19348
+ return PR(R) || R === D.RESERVED_CLAUSE || R === D.RESERVED_SELECT || R === D.RESERVED_SET_OPERATION || R === D.RESERVED_JOIN || R === D.LIMIT;
19319
19349
  }
19320
19350
  const YE = "top-level", yI = "block-level";
19321
19351
  class KT {
@@ -19379,9 +19409,9 @@ class KI extends yT {
19379
19409
  if (typeof E == "string")
19380
19410
  this.length += E.length, this.trailingSpace = !1;
19381
19411
  else {
19382
- if (E === i.MANDATORY_NEWLINE || E === i.NEWLINE)
19412
+ if (E === a.MANDATORY_NEWLINE || E === a.NEWLINE)
19383
19413
  throw new hE();
19384
- E === i.INDENT || E === i.SINGLE_INDENT || E === i.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (E === i.NO_NEWLINE || E === i.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
19414
+ E === a.INDENT || E === a.SINGLE_INDENT || E === a.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (E === a.NO_NEWLINE || E === a.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
19385
19415
  }
19386
19416
  }
19387
19417
  }
@@ -19477,23 +19507,23 @@ class RE {
19477
19507
  }), this.formatNode(E.parenthesis);
19478
19508
  }
19479
19509
  formatPropertyAccess(E) {
19480
- this.formatNode(E.object), this.layout.add(i.NO_SPACE, E.operator), this.formatNode(E.property);
19510
+ this.formatNode(E.object), this.layout.add(a.NO_SPACE, E.operator), this.formatNode(E.property);
19481
19511
  }
19482
19512
  formatParenthesis(E) {
19483
19513
  const T = this.formatInlineExpression(E.children);
19484
- T ? (this.layout.add(E.openParen), this.layout.add(...T.getLayoutItems()), this.layout.add(i.NO_SPACE, E.closeParen, i.SPACE)) : (this.layout.add(E.openParen, i.NEWLINE), J(this.cfg) ? (this.layout.add(i.INDENT), this.layout = this.formatSubExpression(E.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(i.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(i.NEWLINE, i.INDENT, E.closeParen, i.SPACE));
19514
+ T ? (this.layout.add(E.openParen), this.layout.add(...T.getLayoutItems()), this.layout.add(a.NO_SPACE, E.closeParen, a.SPACE)) : (this.layout.add(E.openParen, a.NEWLINE), J(this.cfg) ? (this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(a.NEWLINE, a.INDENT, E.closeParen, a.SPACE));
19485
19515
  }
19486
19516
  formatBetweenPredicate(E) {
19487
- this.layout.add(this.showKw(E.betweenKw), i.SPACE), this.layout = this.formatSubExpression(E.expr1), this.layout.add(i.NO_SPACE, i.SPACE, this.showNonTabularKw(E.andKw), i.SPACE), this.layout = this.formatSubExpression(E.expr2), this.layout.add(i.SPACE);
19517
+ this.layout.add(this.showKw(E.betweenKw), a.SPACE), this.layout = this.formatSubExpression(E.expr1), this.layout.add(a.NO_SPACE, a.SPACE, this.showNonTabularKw(E.andKw), a.SPACE), this.layout = this.formatSubExpression(E.expr2), this.layout.add(a.SPACE);
19488
19518
  }
19489
19519
  formatCaseExpression(E) {
19490
- this.formatNode(E.caseKw), this.layout.indentation.increaseBlockLevel(), this.layout = this.formatSubExpression(E.expr), this.layout = this.formatSubExpression(E.clauses), this.layout.indentation.decreaseBlockLevel(), this.layout.add(i.NEWLINE, i.INDENT), this.formatNode(E.endKw);
19520
+ this.formatNode(E.caseKw), this.layout.indentation.increaseBlockLevel(), this.layout = this.formatSubExpression(E.expr), this.layout = this.formatSubExpression(E.clauses), this.layout.indentation.decreaseBlockLevel(), this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(E.endKw);
19491
19521
  }
19492
19522
  formatCaseWhen(E) {
19493
- this.layout.add(i.NEWLINE, i.INDENT), this.formatNode(E.whenKw), this.layout = this.formatSubExpression(E.condition), this.formatNode(E.thenKw), this.layout = this.formatSubExpression(E.result);
19523
+ this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(E.whenKw), this.layout = this.formatSubExpression(E.condition), this.formatNode(E.thenKw), this.layout = this.formatSubExpression(E.result);
19494
19524
  }
19495
19525
  formatCaseElse(E) {
19496
- this.layout.add(i.NEWLINE, i.INDENT), this.formatNode(E.elseKw), this.layout = this.formatSubExpression(E.result);
19526
+ this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(E.elseKw), this.layout = this.formatSubExpression(E.result);
19497
19527
  }
19498
19528
  formatClause(E) {
19499
19529
  this.isOnelineClause(E) ? this.formatClauseInOnelineStyle(E) : J(this.cfg) ? this.formatClauseInTabularStyle(E) : this.formatClauseInIndentedStyle(E);
@@ -19502,39 +19532,39 @@ class RE {
19502
19532
  return J(this.cfg) ? this.dialectCfg.tabularOnelineClauses[E.nameKw.text] : this.dialectCfg.onelineClauses[E.nameKw.text];
19503
19533
  }
19504
19534
  formatClauseInIndentedStyle(E) {
19505
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(i.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
19535
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
19506
19536
  }
19507
19537
  formatClauseInOnelineStyle(E) {
19508
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.SPACE), this.layout = this.formatSubExpression(E.children);
19538
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.SPACE), this.layout = this.formatSubExpression(E.children);
19509
19539
  }
19510
19540
  formatClauseInTabularStyle(E) {
19511
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
19541
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
19512
19542
  }
19513
19543
  formatSetOperation(E) {
19514
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.NEWLINE), this.layout.add(i.INDENT), this.layout = this.formatSubExpression(E.children);
19544
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.NEWLINE), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children);
19515
19545
  }
19516
19546
  formatLimitClause(E) {
19517
19547
  this.withComments(E.limitKw, () => {
19518
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.limitKw));
19519
- }), this.layout.indentation.increaseTopLevel(), J(this.cfg) ? this.layout.add(i.SPACE) : this.layout.add(i.NEWLINE, i.INDENT), E.offset ? (this.layout = this.formatSubExpression(E.offset), this.layout.add(i.NO_SPACE, ",", i.SPACE), this.layout = this.formatSubExpression(E.count)) : this.layout = this.formatSubExpression(E.count), this.layout.indentation.decreaseTopLevel();
19548
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.limitKw));
19549
+ }), this.layout.indentation.increaseTopLevel(), J(this.cfg) ? this.layout.add(a.SPACE) : this.layout.add(a.NEWLINE, a.INDENT), E.offset ? (this.layout = this.formatSubExpression(E.offset), this.layout.add(a.NO_SPACE, ",", a.SPACE), this.layout = this.formatSubExpression(E.count)) : this.layout = this.formatSubExpression(E.count), this.layout.indentation.decreaseTopLevel();
19520
19550
  }
19521
19551
  formatAllColumnsAsterisk(E) {
19522
- this.layout.add("*", i.SPACE);
19552
+ this.layout.add("*", a.SPACE);
19523
19553
  }
19524
19554
  formatLiteral(E) {
19525
- this.layout.add(E.text, i.SPACE);
19555
+ this.layout.add(E.text, a.SPACE);
19526
19556
  }
19527
19557
  formatIdentifier(E) {
19528
- this.layout.add(this.showIdentifier(E), i.SPACE);
19558
+ this.layout.add(this.showIdentifier(E), a.SPACE);
19529
19559
  }
19530
19560
  formatParameter(E) {
19531
- this.layout.add(this.params.get(E), i.SPACE);
19561
+ this.layout.add(this.params.get(E), a.SPACE);
19532
19562
  }
19533
19563
  formatOperator({ text: E }) {
19534
- this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(E) ? this.layout.add(i.NO_SPACE, E) : E === ":" ? this.layout.add(i.NO_SPACE, E, i.SPACE) : this.layout.add(E, i.SPACE);
19564
+ this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(E) ? this.layout.add(a.NO_SPACE, E) : E === ":" ? this.layout.add(a.NO_SPACE, E, a.SPACE) : this.layout.add(E, a.SPACE);
19535
19565
  }
19536
19566
  formatComma(E) {
19537
- this.inline ? this.layout.add(i.NO_SPACE, ",", i.SPACE) : this.layout.add(i.NO_SPACE, ",", i.NEWLINE, i.INDENT);
19567
+ this.inline ? this.layout.add(a.NO_SPACE, ",", a.SPACE) : this.layout.add(a.NO_SPACE, ",", a.NEWLINE, a.INDENT);
19538
19568
  }
19539
19569
  withComments(E, T) {
19540
19570
  this.formatComments(E.leadingComments), T(), this.formatComments(E.trailingComments);
@@ -19545,12 +19575,12 @@ class RE {
19545
19575
  });
19546
19576
  }
19547
19577
  formatLineComment(E) {
19548
- FE(E.precedingWhitespace || "") ? this.layout.add(i.NEWLINE, i.INDENT, E.text, i.MANDATORY_NEWLINE, i.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(i.NO_NEWLINE, i.SPACE, E.text, i.MANDATORY_NEWLINE, i.INDENT) : this.layout.add(E.text, i.MANDATORY_NEWLINE, i.INDENT);
19578
+ FE(E.precedingWhitespace || "") ? this.layout.add(a.NEWLINE, a.INDENT, E.text, a.MANDATORY_NEWLINE, a.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(a.NO_NEWLINE, a.SPACE, E.text, a.MANDATORY_NEWLINE, a.INDENT) : this.layout.add(E.text, a.MANDATORY_NEWLINE, a.INDENT);
19549
19579
  }
19550
19580
  formatBlockComment(E) {
19551
19581
  E.type === U.block_comment && this.isMultilineBlockComment(E) ? (this.splitBlockComment(E.text).forEach((T) => {
19552
- this.layout.add(i.NEWLINE, i.INDENT, T);
19553
- }), this.layout.add(i.NEWLINE, i.INDENT)) : this.layout.add(E.text, i.SPACE);
19582
+ this.layout.add(a.NEWLINE, a.INDENT, T);
19583
+ }), this.layout.add(a.NEWLINE, a.INDENT)) : this.layout.add(E.text, a.SPACE);
19554
19584
  }
19555
19585
  isMultilineBlockComment(E) {
19556
19586
  return FE(E.text) || FE(E.precedingWhitespace || "");
@@ -19623,27 +19653,27 @@ class RE {
19623
19653
  }
19624
19654
  formatKeywordNode(E) {
19625
19655
  switch (E.tokenType) {
19626
- case a.RESERVED_JOIN:
19656
+ case D.RESERVED_JOIN:
19627
19657
  return this.formatJoin(E);
19628
- case a.AND:
19629
- case a.OR:
19630
- case a.XOR:
19658
+ case D.AND:
19659
+ case D.OR:
19660
+ case D.XOR:
19631
19661
  return this.formatLogicalOperator(E);
19632
19662
  default:
19633
19663
  return this.formatKeyword(E);
19634
19664
  }
19635
19665
  }
19636
19666
  formatJoin(E) {
19637
- J(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E), i.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E), i.SPACE);
19667
+ J(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE);
19638
19668
  }
19639
19669
  formatKeyword(E) {
19640
- this.layout.add(this.showKw(E), i.SPACE);
19670
+ this.layout.add(this.showKw(E), a.SPACE);
19641
19671
  }
19642
19672
  formatLogicalOperator(E) {
19643
- this.cfg.logicalOperatorNewline === "before" ? J(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E), i.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E), i.SPACE) : this.layout.add(this.showKw(E), i.NEWLINE, i.INDENT);
19673
+ this.cfg.logicalOperatorNewline === "before" ? J(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE) : this.layout.add(this.showKw(E), a.NEWLINE, a.INDENT);
19644
19674
  }
19645
19675
  formatDataType(E) {
19646
- this.layout.add(this.showDataType(E), i.SPACE);
19676
+ this.layout.add(this.showDataType(E), a.SPACE);
19647
19677
  }
19648
19678
  showKw(E) {
19649
19679
  return lT(E.tokenType) ? GT(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
@@ -19723,7 +19753,7 @@ class $I {
19723
19753
  params: this.params,
19724
19754
  layout: new yT(new KT(oI(this.cfg)))
19725
19755
  }).format(E.children);
19726
- return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? T.add(i.NEWLINE, ";") : T.add(i.NO_NEWLINE, ";")), T.toString();
19756
+ return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? T.add(a.NEWLINE, ";") : T.add(a.NO_NEWLINE, ";")), T.toString();
19727
19757
  }
19728
19758
  }
19729
19759
  class TE extends Error {
@@ -19990,27 +20020,27 @@ ${T.join(`
19990
20020
  generateCubeMetadata(E) {
19991
20021
  const T = Object.keys(E.measures), A = Object.keys(E.dimensions), e = new Array(T.length), S = new Array(A.length);
19992
20022
  for (let t = 0; t < T.length; t++) {
19993
- const C = T[t], N = E.measures[C];
20023
+ const C = T[t], O = E.measures[C];
19994
20024
  e[t] = {
19995
20025
  name: `${E.name}.${C}`,
19996
- title: N.title || C,
19997
- shortTitle: N.title || C,
19998
- type: N.type,
20026
+ title: O.title || C,
20027
+ shortTitle: O.title || C,
20028
+ type: O.type,
19999
20029
  format: void 0,
20000
20030
  // Measure doesn't have format field
20001
- description: N.description
20031
+ description: O.description
20002
20032
  };
20003
20033
  }
20004
20034
  for (let t = 0; t < A.length; t++) {
20005
- const C = A[t], N = E.dimensions[C];
20035
+ const C = A[t], O = E.dimensions[C];
20006
20036
  S[t] = {
20007
20037
  name: `${E.name}.${C}`,
20008
- title: N.title || C,
20009
- shortTitle: N.title || C,
20010
- type: N.type,
20038
+ title: O.title || C,
20039
+ shortTitle: O.title || C,
20040
+ type: O.type,
20011
20041
  format: void 0,
20012
20042
  // Dimension doesn't have format field
20013
- description: N.description
20043
+ description: O.description
20014
20044
  };
20015
20045
  }
20016
20046
  const I = [];
@@ -20020,9 +20050,9 @@ ${T.join(`
20020
20050
  I.push({
20021
20051
  targetCube: C.name,
20022
20052
  relationship: t.relationship,
20023
- joinFields: t.on.map((N) => ({
20024
- sourceField: this.getColumnName(N.source),
20025
- targetField: this.getColumnName(N.target)
20053
+ joinFields: t.on.map((O) => ({
20054
+ sourceField: this.getColumnName(O.source),
20055
+ targetField: this.getColumnName(O.target)
20026
20056
  }))
20027
20057
  });
20028
20058
  }