drizzle-cube 0.1.40 → 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":
@@ -1252,11 +1252,15 @@ class sR {
1252
1252
  throw new Error(
1253
1253
  `Cannot build calculated measure '${E.name}' directly. Use buildCalculatedMeasure instead.`
1254
1254
  );
1255
+ if (!E.sql)
1256
+ throw new Error(
1257
+ `Measure '${E.name}' of type '${E.type}' is missing required 'sql' property. Only calculated measures can omit 'sql'.`
1258
+ );
1255
1259
  let A = X(E.sql, T);
1256
1260
  if (E.filters && E.filters.length > 0) {
1257
1261
  const e = E.filters.map((S) => {
1258
1262
  const I = S(T);
1259
- return I ? r`(${I})` : void 0;
1263
+ return I ? n`(${I})` : void 0;
1260
1264
  }).filter(Boolean);
1261
1265
  if (e.length > 0) {
1262
1266
  const S = e.length === 1 ? e[0] : p(...e);
@@ -1289,7 +1293,7 @@ class sR {
1289
1293
  */
1290
1294
  buildTimeDimensionExpression(E, T, A) {
1291
1295
  const e = X(E, A);
1292
- 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}`;
1293
1297
  }
1294
1298
  /**
1295
1299
  * Build WHERE conditions from semantic query filters (dimensions only)
@@ -1304,12 +1308,12 @@ class sR {
1304
1308
  }
1305
1309
  if (T.timeDimensions)
1306
1310
  for (const t of T.timeDimensions) {
1307
- const [C, N] = t.dimension.split("."), O = I.get(C);
1308
- 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) {
1309
1313
  if (e?.preAggregationCTEs && e.preAggregationCTEs.some((o) => o.cube.name === C))
1310
1314
  continue;
1311
- const s = O.dimensions[N], _ = X(s.sql, A), n = this.buildDateRangeCondition(_, t.dateRange);
1312
- 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);
1313
1317
  }
1314
1318
  }
1315
1319
  return S;
@@ -1333,31 +1337,43 @@ class sR {
1333
1337
  */
1334
1338
  processFilter(E, T, A, e, S) {
1335
1339
  if ("and" in E || "or" in E) {
1336
- const n = E;
1337
- if (n.and) {
1338
- const D = n.and.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
1339
- 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;
1340
1344
  }
1341
- if (n.or) {
1342
- const D = n.or.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
1343
- 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;
1344
1348
  }
1345
1349
  }
1346
- const I = E, [t, C] = I.member.split("."), N = T.get(t);
1347
- if (!N) return null;
1348
- const O = N.dimensions[C], s = N.measures[C], _ = O || s;
1349
- if (!_) return null;
1350
- 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) {
1351
1355
  if (S?.preAggregationCTEs && S.preAggregationCTEs.some((o) => o.cube.name === t))
1352
1356
  return null;
1353
- const n = X(O.sql, A);
1354
- 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
+ );
1355
1365
  } else {
1356
1366
  if (e === "where" && s)
1357
1367
  return null;
1358
1368
  if (e === "having" && s) {
1359
- const n = this.buildHavingMeasureExpression(t, C, s, A, S);
1360
- 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
+ );
1361
1377
  }
1362
1378
  }
1363
1379
  return null;
@@ -1365,97 +1381,108 @@ class sR {
1365
1381
  /**
1366
1382
  * Build filter condition using Drizzle operators
1367
1383
  */
1368
- 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
+ }
1369
1396
  if (!A || A.length === 0)
1370
1397
  return T === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1371
- const S = A.filter((t) => !(t == null || t === "" || typeof t == "string" && t.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
1372
- 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))
1373
1400
  return T === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1374
- const I = S[0];
1401
+ const t = I[0];
1375
1402
  switch (T) {
1376
1403
  case "equals":
1377
- if (S.length > 1) {
1404
+ if (I.length > 1) {
1378
1405
  if (e?.type === "time") {
1379
- const t = S.map((C) => this.normalizeDate(C) || C);
1380
- return OE(E, t);
1406
+ const C = I.map((O) => this.normalizeDate(O) || O);
1407
+ return OE(E, C);
1381
1408
  }
1382
- return OE(E, S);
1383
- } else if (S.length === 1) {
1384
- const t = e?.type === "time" && this.normalizeDate(I) || I;
1385
- 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);
1386
1413
  }
1387
1414
  return this.databaseAdapter.buildBooleanLiteral(!1);
1388
1415
  case "notEquals":
1389
- 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;
1390
1417
  case "contains":
1391
- return this.databaseAdapter.buildStringCondition(E, "contains", I);
1418
+ return this.databaseAdapter.buildStringCondition(E, "contains", t);
1392
1419
  case "notContains":
1393
- return this.databaseAdapter.buildStringCondition(E, "notContains", I);
1420
+ return this.databaseAdapter.buildStringCondition(E, "notContains", t);
1394
1421
  case "startsWith":
1395
- return this.databaseAdapter.buildStringCondition(E, "startsWith", I);
1422
+ return this.databaseAdapter.buildStringCondition(E, "startsWith", t);
1396
1423
  case "endsWith":
1397
- return this.databaseAdapter.buildStringCondition(E, "endsWith", I);
1424
+ return this.databaseAdapter.buildStringCondition(E, "endsWith", t);
1398
1425
  case "gt":
1399
- return tE(E, I);
1426
+ return tE(E, t);
1400
1427
  case "gte":
1401
- return $(E, I);
1428
+ return $(E, t);
1402
1429
  case "lt":
1403
- return NE(E, I);
1430
+ return NE(E, t);
1404
1431
  case "lte":
1405
- return g(E, I);
1432
+ return g(E, t);
1406
1433
  case "set":
1407
1434
  return yE(E);
1408
1435
  case "notSet":
1409
1436
  return $E(E);
1410
1437
  case "inDateRange":
1411
- if (S.length >= 2) {
1412
- const t = this.normalizeDate(S[0]);
1413
- let C = this.normalizeDate(S[1]);
1414
- 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) {
1415
1442
  const N = A[1];
1416
1443
  if (typeof N == "string" && /^\d{4}-\d{2}-\d{2}$/.test(N.trim())) {
1417
- const O = typeof C == "number" ? new Date(C * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(C), s = new Date(O);
1418
- 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();
1419
1446
  }
1420
1447
  return p(
1421
- $(E, t),
1422
- g(E, C)
1448
+ $(E, C),
1449
+ g(E, O)
1423
1450
  );
1424
1451
  }
1425
1452
  }
1426
1453
  return null;
1427
1454
  case "beforeDate": {
1428
- const t = this.normalizeDate(I);
1429
- return t ? NE(E, t) : null;
1455
+ const C = this.normalizeDate(t);
1456
+ return C ? NE(E, C) : null;
1430
1457
  }
1431
1458
  case "afterDate": {
1432
- const t = this.normalizeDate(I);
1433
- return t ? tE(E, t) : null;
1459
+ const C = this.normalizeDate(t);
1460
+ return C ? tE(E, C) : null;
1434
1461
  }
1435
1462
  case "between":
1436
- return S.length >= 2 ? p(
1437
- $(E, S[0]),
1438
- g(E, S[1])
1463
+ return I.length >= 2 ? p(
1464
+ $(E, I[0]),
1465
+ g(E, I[1])
1439
1466
  ) : null;
1440
1467
  case "notBetween":
1441
- return S.length >= 2 ? IE(
1442
- NE(E, S[0]),
1443
- tE(E, S[1])
1468
+ return I.length >= 2 ? IE(
1469
+ NE(E, I[0]),
1470
+ tE(E, I[1])
1444
1471
  ) : null;
1445
1472
  case "in":
1446
- return S.length > 0 ? OE(E, S) : null;
1473
+ return I.length > 0 ? OE(E, I) : null;
1447
1474
  case "notIn":
1448
- return S.length > 0 ? gE(E, S) : null;
1475
+ return I.length > 0 ? gE(E, I) : null;
1449
1476
  case "like":
1450
- return this.databaseAdapter.buildStringCondition(E, "like", I);
1477
+ return this.databaseAdapter.buildStringCondition(E, "like", t);
1451
1478
  case "notLike":
1452
- return this.databaseAdapter.buildStringCondition(E, "notLike", I);
1479
+ return this.databaseAdapter.buildStringCondition(E, "notLike", t);
1453
1480
  case "ilike":
1454
- return this.databaseAdapter.buildStringCondition(E, "ilike", I);
1481
+ return this.databaseAdapter.buildStringCondition(E, "ilike", t);
1455
1482
  case "regex":
1456
- return this.databaseAdapter.buildStringCondition(E, "regex", I);
1483
+ return this.databaseAdapter.buildStringCondition(E, "regex", t);
1457
1484
  case "notRegex":
1458
- return this.databaseAdapter.buildStringCondition(E, "notRegex", I);
1485
+ return this.databaseAdapter.buildStringCondition(E, "notRegex", t);
1459
1486
  case "isEmpty":
1460
1487
  return IE(
1461
1488
  $E(E),
@@ -1491,9 +1518,9 @@ class sR {
1491
1518
  if (typeof T == "string") {
1492
1519
  const A = this.parseRelativeDateRange(T);
1493
1520
  if (A) {
1494
- let O, s;
1495
- 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(
1496
- $(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),
1497
1524
  g(E, s)
1498
1525
  );
1499
1526
  }
@@ -1503,10 +1530,10 @@ class sR {
1503
1530
  I.setUTCHours(0, 0, 0, 0);
1504
1531
  const t = new Date(S);
1505
1532
  t.setUTCHours(23, 59, 59, 999);
1506
- let C, N;
1507
- 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(
1508
1535
  $(E, C),
1509
- g(E, N)
1536
+ g(E, O)
1510
1537
  );
1511
1538
  }
1512
1539
  return null;
@@ -1518,73 +1545,80 @@ class sR {
1518
1545
  parseRelativeDateRange(E) {
1519
1546
  const T = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), e = T.getUTCFullYear(), S = T.getUTCMonth(), I = T.getUTCDate(), t = T.getUTCDay();
1520
1547
  if (A === "today") {
1521
- const s = new Date(T);
1522
- s.setUTCHours(0, 0, 0, 0);
1523
- const _ = new Date(T);
1524
- 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 };
1525
1552
  }
1526
1553
  if (A === "yesterday") {
1527
- const s = new Date(T);
1528
- s.setUTCDate(I - 1), s.setUTCHours(0, 0, 0, 0);
1529
- const _ = new Date(T);
1530
- 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 };
1531
1558
  }
1532
1559
  if (A === "this week") {
1533
- const s = t === 0 ? -6 : 1 - t, _ = new Date(T);
1534
- _.setUTCDate(I + s), _.setUTCHours(0, 0, 0, 0);
1535
- const n = new Date(_);
1536
- 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 };
1537
1564
  }
1538
1565
  if (A === "this month") {
1539
- 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));
1540
- 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 };
1541
1568
  }
1542
1569
  if (A === "this quarter") {
1543
- 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));
1544
- 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 };
1545
1572
  }
1546
1573
  if (A === "this year") {
1547
- const s = new Date(Date.UTC(e, 0, 1, 0, 0, 0, 0)), _ = new Date(Date.UTC(e, 11, 31, 23, 59, 59, 999));
1548
- 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 };
1549
1576
  }
1550
1577
  const C = A.match(/^last\s+(\d+)\s+days?$/);
1551
1578
  if (C) {
1552
- const s = parseInt(C[1], 10), _ = new Date(T);
1553
- _.setUTCDate(I - s + 1), _.setUTCHours(0, 0, 0, 0);
1554
- const n = new Date(T);
1555
- 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 };
1556
1590
  }
1557
1591
  if (A === "last week") {
1558
- const s = t === 0 ? -13 : -6 - t, _ = new Date(T);
1559
- _.setUTCDate(I + s), _.setUTCHours(0, 0, 0, 0);
1560
- const n = new Date(_);
1561
- 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 };
1562
1596
  }
1563
1597
  if (A === "last month") {
1564
- 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));
1565
- 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 };
1566
1600
  }
1567
1601
  if (A === "last quarter") {
1568
- 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));
1569
- 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 };
1570
1604
  }
1571
1605
  if (A === "last year") {
1572
- 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));
1573
- 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 };
1574
1608
  }
1575
1609
  if (A === "last 12 months") {
1576
- const s = new Date(Date.UTC(e, S - 11, 1, 0, 0, 0, 0)), _ = new Date(T);
1577
- 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 };
1578
1612
  }
1579
1613
  const N = A.match(/^last\s+(\d+)\s+months?$/);
1580
1614
  if (N) {
1581
- const s = parseInt(N[1], 10), _ = new Date(Date.UTC(e, S - s + 1, 1, 0, 0, 0, 0)), n = new Date(T);
1582
- 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 };
1583
1617
  }
1584
- const O = A.match(/^last\s+(\d+)\s+years?$/);
1585
- if (O) {
1586
- const s = parseInt(O[1], 10), _ = new Date(Date.UTC(e - s, 0, 1, 0, 0, 0, 0)), n = new Date(T);
1587
- 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 };
1588
1622
  }
1589
1623
  return null;
1590
1624
  }
@@ -1623,45 +1657,45 @@ class sR {
1623
1657
  const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1624
1658
  if (T.dimensions)
1625
1659
  for (const C of T.dimensions) {
1626
- const [N, O] = C.split("."), s = t.get(N);
1627
- if (s && s.dimensions && s.dimensions[O])
1628
- if (e?.preAggregationCTEs?.some((n) => n.cube.name === N)) {
1629
- const n = e.preAggregationCTEs.find((o) => o.cube.name === N), D = n.joinKeys.find((o) => o.targetColumn === O);
1630
- if (D && D.sourceColumnObj)
1631
- 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);
1632
1666
  else {
1633
- const o = r`${r.identifier(n.cteAlias)}.${r.identifier(O)}`;
1667
+ const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
1634
1668
  S.push(o);
1635
1669
  }
1636
1670
  } else {
1637
- const n = s.dimensions[O], D = X(n.sql, A);
1638
- S.push(D);
1671
+ const L = s.dimensions[N], i = X(L.sql, A);
1672
+ S.push(i);
1639
1673
  }
1640
1674
  }
1641
1675
  if (T.timeDimensions)
1642
1676
  for (const C of T.timeDimensions) {
1643
- const [N, O] = C.dimension.split("."), s = t.get(N);
1644
- if (s && s.dimensions && s.dimensions[O])
1645
- if (e?.preAggregationCTEs?.some((n) => n.cube.name === N)) {
1646
- const n = e.preAggregationCTEs.find((o) => o.cube.name === N), D = n.joinKeys.find((o) => o.targetColumn === O);
1647
- 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) {
1648
1682
  const o = this.buildTimeDimensionExpression(
1649
- D.sourceColumnObj,
1683
+ i.sourceColumnObj,
1650
1684
  C.granularity,
1651
1685
  A
1652
1686
  );
1653
1687
  S.push(o);
1654
1688
  } else {
1655
- const o = r`${r.identifier(n.cteAlias)}.${r.identifier(O)}`;
1689
+ const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
1656
1690
  S.push(o);
1657
1691
  }
1658
1692
  } else {
1659
- const n = s.dimensions[O], D = this.buildTimeDimensionExpression(
1660
- n.sql,
1693
+ const L = s.dimensions[N], i = this.buildTimeDimensionExpression(
1694
+ L.sql,
1661
1695
  C.granularity,
1662
1696
  A
1663
1697
  );
1664
- S.push(D);
1698
+ S.push(i);
1665
1699
  }
1666
1700
  }
1667
1701
  return S;
@@ -1679,7 +1713,7 @@ class sR {
1679
1713
  for (const [S, I] of Object.entries(E.order)) {
1680
1714
  if (!e.includes(S))
1681
1715
  throw new Error(`Cannot order by '${S}': field is not selected in the query`);
1682
- 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));
1683
1717
  A.push(t);
1684
1718
  }
1685
1719
  if (E.timeDimensions && E.timeDimensions.length > 0) {
@@ -1687,7 +1721,7 @@ class sR {
1687
1721
  (t, C) => t.dimension.localeCompare(C.dimension)
1688
1722
  );
1689
1723
  for (const t of I)
1690
- S.has(t.dimension) || A.push(wE(r.identifier(t.dimension)));
1724
+ S.has(t.dimension) || A.push(wE(n.identifier(t.dimension)));
1691
1725
  }
1692
1726
  return A;
1693
1727
  }
@@ -1701,8 +1735,8 @@ class sR {
1701
1735
  for (const S of T.dimensions) {
1702
1736
  const [I, t] = S.split("."), C = e.get(I);
1703
1737
  if (C) {
1704
- const N = C.dimensions[t];
1705
- N && N.type === "number" && A.push(S);
1738
+ const O = C.dimensions[t];
1739
+ O && O.type === "number" && A.push(S);
1706
1740
  }
1707
1741
  }
1708
1742
  return A;
@@ -1817,7 +1851,7 @@ class CR {
1817
1851
  groupByFields: []
1818
1852
  // Will be built by QueryBuilder
1819
1853
  };
1820
- 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);
1821
1855
  return {
1822
1856
  primaryCube: t,
1823
1857
  joinCubes: C,
@@ -1827,7 +1861,7 @@ class CR {
1827
1861
  // Will be built by QueryBuilder
1828
1862
  groupByFields: [],
1829
1863
  // Will be built by QueryBuilder
1830
- preAggregationCTEs: N
1864
+ preAggregationCTEs: O
1831
1865
  };
1832
1866
  }
1833
1867
  /**
@@ -1881,48 +1915,48 @@ class CR {
1881
1915
  for (const C of t) {
1882
1916
  if (I.has(C))
1883
1917
  continue;
1884
- const N = this.findJoinPath(E, T.name, C, I);
1885
- if (!N || N.length === 0)
1918
+ const O = this.findJoinPath(E, T.name, C, I);
1919
+ if (!O || O.length === 0)
1886
1920
  throw new Error(`No join path found from '${T.name}' to '${C}'`);
1887
- for (const { toCube: O, joinDef: s } of N) {
1888
- if (I.has(O))
1921
+ for (const { toCube: N, joinDef: s } of O) {
1922
+ if (I.has(N))
1889
1923
  continue;
1890
- const _ = E.get(O);
1891
- if (!_)
1892
- throw new Error(`Cube '${O}' not found`);
1924
+ const r = E.get(N);
1925
+ if (!r)
1926
+ throw new Error(`Cube '${N}' not found`);
1893
1927
  if (s.relationship === "belongsToMany" && s.through) {
1894
- const n = IR(s, e.securityContext);
1928
+ const L = IR(s, e.securityContext);
1895
1929
  S.push({
1896
- cube: _,
1897
- alias: `${O.toLowerCase()}_cube`,
1898
- joinType: n.junctionJoins[1].joinType,
1930
+ cube: r,
1931
+ alias: `${N.toLowerCase()}_cube`,
1932
+ joinType: L.junctionJoins[1].joinType,
1899
1933
  // Use the target join type
1900
- joinCondition: n.junctionJoins[1].condition,
1934
+ joinCondition: L.junctionJoins[1].condition,
1901
1935
  // Target join condition
1902
1936
  junctionTable: {
1903
1937
  table: s.through.table,
1904
- alias: `junction_${O.toLowerCase()}`,
1905
- joinType: n.junctionJoins[0].joinType,
1906
- joinCondition: n.junctionJoins[0].condition,
1938
+ alias: `junction_${N.toLowerCase()}`,
1939
+ joinType: L.junctionJoins[0].joinType,
1940
+ joinCondition: L.junctionJoins[0].condition,
1907
1941
  securitySql: s.through.securitySql
1908
1942
  }
1909
1943
  });
1910
1944
  } else {
1911
- const n = this.buildJoinCondition(
1945
+ const L = this.buildJoinCondition(
1912
1946
  s,
1913
1947
  null,
1914
1948
  // No source alias needed - use the actual column
1915
1949
  null
1916
1950
  // No target alias needed - use the actual column
1917
- ), D = dT(s.relationship, s.sqlJoinType);
1951
+ ), i = dT(s.relationship, s.sqlJoinType);
1918
1952
  S.push({
1919
- cube: _,
1920
- alias: `${O.toLowerCase()}_cube`,
1921
- joinType: D,
1922
- joinCondition: n
1953
+ cube: r,
1954
+ alias: `${N.toLowerCase()}_cube`,
1955
+ joinType: i,
1956
+ joinCondition: L
1923
1957
  });
1924
1958
  }
1925
- I.add(O);
1959
+ I.add(N);
1926
1960
  }
1927
1961
  }
1928
1962
  return S;
@@ -1933,7 +1967,7 @@ class CR {
1933
1967
  buildJoinCondition(E, T, A) {
1934
1968
  const e = [];
1935
1969
  for (const S of E.on) {
1936
- 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;
1937
1971
  e.push(C(I, t));
1938
1972
  }
1939
1973
  return p(...e);
@@ -1949,20 +1983,20 @@ class CR {
1949
1983
  { cube: T, path: [] }
1950
1984
  ], I = /* @__PURE__ */ new Set([T, ...e]);
1951
1985
  for (; S.length > 0; ) {
1952
- const { cube: t, path: C } = S.shift(), N = E.get(t);
1953
- if (N?.joins)
1954
- for (const [, O] of Object.entries(N.joins)) {
1955
- const _ = QE(O.targetCube).name;
1956
- 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))
1957
1991
  continue;
1958
- const n = [...C, {
1992
+ const L = [...C, {
1959
1993
  fromCube: t,
1960
- toCube: _,
1961
- joinDef: O
1994
+ toCube: r,
1995
+ joinDef: N
1962
1996
  }];
1963
- if (_ === A)
1964
- return n;
1965
- I.add(_), S.push({ cube: _, path: n });
1997
+ if (r === A)
1998
+ return L;
1999
+ I.add(r), S.push({ cube: r, path: L });
1966
2000
  }
1967
2001
  }
1968
2002
  return null;
@@ -1981,24 +2015,24 @@ class CR {
1981
2015
  if (!t)
1982
2016
  continue;
1983
2017
  const C = e.measures ? e.measures.filter(
1984
- (n) => n.startsWith(I.cube.name + ".")
1985
- ) : [], N = this.extractMeasuresFromFilters(e, I.cube.name), O = [.../* @__PURE__ */ new Set([...C, ...N])];
1986
- 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)
1987
2021
  continue;
1988
2022
  const s = this.expandCalculatedMeasureDependencies(
1989
2023
  I.cube,
1990
- O
1991
- ), _ = t.on.map((n) => ({
1992
- sourceColumn: n.source.name,
1993
- targetColumn: n.target.name,
1994
- sourceColumnObj: n.source,
1995
- 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
1996
2030
  }));
1997
2031
  S.push({
1998
2032
  cube: I.cube,
1999
2033
  alias: I.alias,
2000
2034
  cteAlias: `${I.cube.name.toLowerCase()}_agg`,
2001
- joinKeys: _,
2035
+ joinKeys: r,
2002
2036
  measures: s
2003
2037
  });
2004
2038
  }
@@ -2020,8 +2054,8 @@ class CR {
2020
2054
  const t = E.measures[I];
2021
2055
  if (t.type === "calculated" && t.calculatedSql) {
2022
2056
  const C = this.extractDependenciesFromTemplate(t.calculatedSql, E.name);
2023
- for (const N of C)
2024
- A.has(N) || e.push(N);
2057
+ for (const O of C)
2058
+ A.has(O) || e.push(O);
2025
2059
  }
2026
2060
  }
2027
2061
  return Array.from(A);
@@ -2070,23 +2104,23 @@ class CE {
2070
2104
  db: this.dbExecutor.db,
2071
2105
  schema: this.dbExecutor.schema,
2072
2106
  securityContext: A
2073
- }, 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((_) => {
2074
- 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 };
2075
2109
  if (T.timeDimensions) {
2076
- for (const D of T.timeDimensions)
2077
- if (D.dimension in n) {
2078
- let o = n[D.dimension];
2110
+ for (const i of T.timeDimensions)
2111
+ if (i.dimension in L) {
2112
+ let o = L[i.dimension];
2079
2113
  if (typeof o == "string" && o.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
2080
2114
  const l = o.replace(" ", "T"), P = !l.endsWith("Z") && !l.includes("+") ? l + "Z" : l;
2081
2115
  o = new Date(P);
2082
2116
  }
2083
- o = this.databaseAdapter.convertTimeDimensionResult(o), n[D.dimension] = o;
2117
+ o = this.databaseAdapter.convertTimeDimensionResult(o), L[i.dimension] = o;
2084
2118
  }
2085
2119
  }
2086
- return n;
2087
- }) : [N], s = this.generateAnnotations(I, T);
2120
+ return L;
2121
+ }) : [O], s = this.generateAnnotations(I, T);
2088
2122
  return {
2089
- data: O,
2123
+ data: N,
2090
2124
  annotation: s
2091
2125
  };
2092
2126
  } catch (e) {
@@ -2109,18 +2143,18 @@ class CE {
2109
2143
  if (P.targetColumnObj) {
2110
2144
  t[P.targetColumn] = P.targetColumnObj;
2111
2145
  for (const [c, M] of Object.entries(S.dimensions || {}))
2112
- 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));
2113
2147
  }
2114
- 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(
2115
2149
  E.measures,
2116
- N,
2150
+ O,
2117
2151
  A
2118
2152
  );
2119
2153
  for (const P of E.measures) {
2120
- const [, c] = P.split("."), M = O.get(P);
2154
+ const [, c] = P.split("."), M = N.get(P);
2121
2155
  if (M) {
2122
2156
  const u = M();
2123
- t[c] = r`${u}`.as(c);
2157
+ t[c] = n`${u}`.as(c);
2124
2158
  }
2125
2159
  }
2126
2160
  if (T.dimensions)
@@ -2128,7 +2162,7 @@ class CE {
2128
2162
  const [c, M] = P.split(".");
2129
2163
  if (c === C && S.dimensions && S.dimensions[M]) {
2130
2164
  const u = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: u.sql, type: "number" }, A);
2131
- t[M] = r`${H}`.as(M);
2165
+ t[M] = n`${H}`.as(M);
2132
2166
  }
2133
2167
  }
2134
2168
  if (T.timeDimensions)
@@ -2136,22 +2170,22 @@ class CE {
2136
2170
  const [c, M] = P.dimension.split(".");
2137
2171
  if (c === C && S.dimensions && S.dimensions[M]) {
2138
2172
  const u = S.dimensions[M], H = this.queryBuilder.buildTimeDimensionExpression(u.sql, P.granularity, A);
2139
- t[M] = r`${H}`.as(M);
2173
+ t[M] = n`${H}`.as(M);
2140
2174
  }
2141
2175
  }
2142
2176
  if (Object.keys(t).length === 0)
2143
2177
  return null;
2144
2178
  let s = A.db.select(t).from(I.from);
2145
- const _ = e ? {
2179
+ const r = e ? {
2146
2180
  ...e,
2147
2181
  preAggregationCTEs: e.preAggregationCTEs?.filter((P) => P.cube.name !== S.name)
2148
- } : void 0, n = this.queryBuilder.buildWhereConditions(S, T, A, _), D = [];
2182
+ } : void 0, L = this.queryBuilder.buildWhereConditions(S, T, A, r), i = [];
2149
2183
  if (T.timeDimensions)
2150
2184
  for (const P of T.timeDimensions) {
2151
2185
  const [c, M] = P.dimension.split(".");
2152
2186
  if (c === C && S.dimensions && S.dimensions[M] && P.dateRange) {
2153
2187
  const u = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: u.sql, type: "number" }, A), B = this.queryBuilder.buildDateRangeCondition(H, P.dateRange);
2154
- B && D.push(B);
2188
+ B && i.push(B);
2155
2189
  }
2156
2190
  }
2157
2191
  if (T.filters) {
@@ -2162,13 +2196,13 @@ class CE {
2162
2196
  const H = S.dimensions[u];
2163
2197
  if (c.operator === "inDateRange") {
2164
2198
  const B = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, A), Y = this.queryBuilder.buildDateRangeCondition(B, c.values);
2165
- Y && D.push(Y);
2199
+ Y && i.push(Y);
2166
2200
  }
2167
2201
  }
2168
2202
  }
2169
2203
  }
2170
2204
  const o = [];
2171
- 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) {
2172
2206
  const P = o.length === 1 ? o[0] : p(...o);
2173
2207
  s = s.where(P);
2174
2208
  }
@@ -2203,7 +2237,7 @@ class CE {
2203
2237
  throw new Error(`CTE info not found for cube ${E.cube.name}`);
2204
2238
  const S = [];
2205
2239
  for (const I of e.joinKeys) {
2206
- 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)}`;
2207
2241
  S.push(x(t, C));
2208
2242
  }
2209
2243
  return S.length === 1 ? S[0] : p(...S);
@@ -2243,7 +2277,7 @@ class CE {
2243
2277
  A
2244
2278
  );
2245
2279
  } else {
2246
- const B = r`${r.identifier(o.cteAlias)}.${r.identifier(c)}`;
2280
+ const B = n`${n.identifier(o.cteAlias)}.${n.identifier(c)}`;
2247
2281
  switch (u.type) {
2248
2282
  case "count":
2249
2283
  case "countDistinct":
@@ -2266,7 +2300,7 @@ class CE {
2266
2300
  H = f(B);
2267
2301
  }
2268
2302
  }
2269
- C[P] = r`${H}`.as(P);
2303
+ C[P] = n`${H}`.as(P);
2270
2304
  }
2271
2305
  }
2272
2306
  for (const P in C) {
@@ -2279,27 +2313,27 @@ class CE {
2279
2313
  const eE = u.dimensions[M].sql;
2280
2314
  Y = o.joinKeys.find((JT) => JT.targetColumnObj === eE);
2281
2315
  }
2282
- 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));
2283
2317
  }
2284
2318
  }
2285
2319
  }
2286
2320
  }
2287
- const N = [];
2288
- let O = A.db.select(C).from(I.from);
2289
- 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)
2290
2324
  for (const o of I.joins)
2291
2325
  switch (o.type || "left") {
2292
2326
  case "left":
2293
- O = O.leftJoin(o.table, o.on);
2327
+ N = N.leftJoin(o.table, o.on);
2294
2328
  break;
2295
2329
  case "inner":
2296
- O = O.innerJoin(o.table, o.on);
2330
+ N = N.innerJoin(o.table, o.on);
2297
2331
  break;
2298
2332
  case "right":
2299
- O = O.rightJoin(o.table, o.on);
2333
+ N = N.rightJoin(o.table, o.on);
2300
2334
  break;
2301
2335
  case "full":
2302
- O = O.fullJoin(o.table, o.on);
2336
+ N = N.fullJoin(o.table, o.on);
2303
2337
  break;
2304
2338
  }
2305
2339
  if (E.joinCubes && E.joinCubes.length > 0)
@@ -2314,48 +2348,48 @@ class CE {
2314
2348
  try {
2315
2349
  switch (M.joinType || "left") {
2316
2350
  case "left":
2317
- O = O.leftJoin(M.table, M.joinCondition);
2351
+ N = N.leftJoin(M.table, M.joinCondition);
2318
2352
  break;
2319
2353
  case "inner":
2320
- O = O.innerJoin(M.table, M.joinCondition);
2354
+ N = N.innerJoin(M.table, M.joinCondition);
2321
2355
  break;
2322
2356
  case "right":
2323
- O = O.rightJoin(M.table, M.joinCondition);
2357
+ N = N.rightJoin(M.table, M.joinCondition);
2324
2358
  break;
2325
2359
  case "full":
2326
- O = O.fullJoin(M.table, M.joinCondition);
2360
+ N = N.fullJoin(M.table, M.joinCondition);
2327
2361
  break;
2328
2362
  }
2329
- u.length > 0 && N.push(...u);
2363
+ u.length > 0 && O.push(...u);
2330
2364
  } catch {
2331
2365
  }
2332
2366
  }
2333
2367
  let P, c;
2334
- 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);
2335
2369
  try {
2336
2370
  switch (o.joinType || "left") {
2337
2371
  case "left":
2338
- O = O.leftJoin(P, c);
2372
+ N = N.leftJoin(P, c);
2339
2373
  break;
2340
2374
  case "inner":
2341
- O = O.innerJoin(P, c);
2375
+ N = N.innerJoin(P, c);
2342
2376
  break;
2343
2377
  case "right":
2344
- O = O.rightJoin(P, c);
2378
+ N = N.rightJoin(P, c);
2345
2379
  break;
2346
2380
  case "full":
2347
- O = O.fullJoin(P, c);
2381
+ N = N.fullJoin(P, c);
2348
2382
  break;
2349
2383
  }
2350
2384
  } catch {
2351
2385
  }
2352
2386
  }
2353
- 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)
2354
2388
  for (const o of E.joinCubes) {
2355
2389
  if (S.get(o.cube.name))
2356
2390
  continue;
2357
2391
  const P = o.cube.sql(A);
2358
- P.where && N.push(P.where);
2392
+ P.where && O.push(P.where);
2359
2393
  }
2360
2394
  const s = this.queryBuilder.buildWhereConditions(
2361
2395
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
@@ -2365,11 +2399,11 @@ class CE {
2365
2399
  E
2366
2400
  // Pass the queryPlan to handle CTE scenarios
2367
2401
  );
2368
- if (s.length > 0 && N.push(...s), N.length > 0) {
2369
- const o = N.length === 1 ? N[0] : p(...N);
2370
- 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);
2371
2405
  }
2372
- const _ = this.queryBuilder.buildGroupByFields(
2406
+ const r = this.queryBuilder.buildGroupByFields(
2373
2407
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2374
2408
  // Single cube
2375
2409
  T,
@@ -2377,8 +2411,8 @@ class CE {
2377
2411
  E
2378
2412
  // Pass the queryPlan to handle CTE scenarios
2379
2413
  );
2380
- _.length > 0 && (O = O.groupBy(..._));
2381
- const n = this.queryBuilder.buildHavingConditions(
2414
+ r.length > 0 && (N = N.groupBy(...r));
2415
+ const L = this.queryBuilder.buildHavingConditions(
2382
2416
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2383
2417
  // Single cube
2384
2418
  T,
@@ -2386,12 +2420,12 @@ class CE {
2386
2420
  E
2387
2421
  // Pass the queryPlan to handle CTE scenarios
2388
2422
  );
2389
- if (n.length > 0) {
2390
- const o = n.length === 1 ? n[0] : p(...n);
2391
- O = O.having(o);
2423
+ if (L.length > 0) {
2424
+ const o = L.length === 1 ? L[0] : p(...L);
2425
+ N = N.having(o);
2392
2426
  }
2393
- const D = this.queryBuilder.buildOrderBy(T);
2394
- 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;
2395
2429
  }
2396
2430
  /**
2397
2431
  * Convert query plan to cube map for QueryBuilder methods
@@ -2437,36 +2471,36 @@ class CE {
2437
2471
  const A = {}, e = {}, S = {}, I = [E.primaryCube];
2438
2472
  if (E.joinCubes && E.joinCubes.length > 0 && I.push(...E.joinCubes.map((t) => t.cube)), T.measures)
2439
2473
  for (const t of T.measures) {
2440
- const [C, N] = t.split("."), O = I.find((s) => s.name === C);
2441
- if (O && O.measures[N]) {
2442
- 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];
2443
2477
  A[t] = {
2444
- title: s.title || N,
2445
- shortTitle: s.title || N,
2478
+ title: s.title || O,
2479
+ shortTitle: s.title || O,
2446
2480
  type: s.type
2447
2481
  };
2448
2482
  }
2449
2483
  }
2450
2484
  if (T.dimensions)
2451
2485
  for (const t of T.dimensions) {
2452
- const [C, N] = t.split("."), O = I.find((s) => s.name === C);
2453
- if (O && O.dimensions[N]) {
2454
- 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];
2455
2489
  e[t] = {
2456
- title: s.title || N,
2457
- shortTitle: s.title || N,
2490
+ title: s.title || O,
2491
+ shortTitle: s.title || O,
2458
2492
  type: s.type
2459
2493
  };
2460
2494
  }
2461
2495
  }
2462
2496
  if (T.timeDimensions)
2463
2497
  for (const t of T.timeDimensions) {
2464
- const [C, N] = t.dimension.split("."), O = I.find((s) => s.name === C);
2465
- if (O && O.dimensions && O.dimensions[N]) {
2466
- 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];
2467
2501
  S[t.dimension] = {
2468
- title: s.title || N,
2469
- shortTitle: s.title || N,
2502
+ title: s.title || O,
2503
+ shortTitle: s.title || O,
2470
2504
  type: s.type,
2471
2505
  granularity: t.granularity
2472
2506
  };
@@ -2480,7 +2514,7 @@ class CE {
2480
2514
  };
2481
2515
  }
2482
2516
  }
2483
- 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) => ({
2484
2518
  type: "mandatory_block",
2485
2519
  items: XE(R, 0)[0]
2486
2520
  }), XE = (R, E, T) => {
@@ -2545,23 +2579,23 @@ const L = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.repl
2545
2579
  T.push(A + e);
2546
2580
  return T;
2547
2581
  };
2548
- var a;
2582
+ var D;
2549
2583
  (function(R) {
2550
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";
2551
- })(a = a || (a = {}));
2585
+ })(D = D || (D = {}));
2552
2586
  const FT = (R) => ({
2553
- type: a.EOF,
2587
+ type: D.EOF,
2554
2588
  raw: "«EOF»",
2555
2589
  text: "«EOF»",
2556
2590
  start: R
2557
2591
  }), v = FT(1 / 0), w = (R) => (E) => E.type === R.type && E.text === R.text, y = {
2558
- ARRAY: w({ text: "ARRAY", type: a.RESERVED_DATA_TYPE }),
2559
- BY: w({ text: "BY", type: a.RESERVED_KEYWORD }),
2560
- SET: w({ text: "SET", type: a.RESERVED_CLAUSE }),
2561
- STRUCT: w({ text: "STRUCT", type: a.RESERVED_DATA_TYPE }),
2562
- WINDOW: w({ text: "WINDOW", type: a.RESERVED_CLAUSE }),
2563
- VALUES: w({ text: "VALUES", type: a.RESERVED_CLAUSE })
2564
- }, 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 = [
2565
2599
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
2566
2600
  "KEYS.NEW_KEYSET",
2567
2601
  "KEYS.ADD_KEY_FROM_RAW_BYTES",
@@ -3238,7 +3272,7 @@ const FT = (R) => ({
3238
3272
  "STRUCT",
3239
3273
  "TIME",
3240
3274
  "TIMEZONE"
3241
- ], GR = L(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), lR = L([
3275
+ ], GR = _(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), lR = _([
3242
3276
  // Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
3243
3277
  "WITH [RECURSIVE]",
3244
3278
  "FROM",
@@ -3267,9 +3301,9 @@ const FT = (R) => ({
3267
3301
  "WITH CONNECTION",
3268
3302
  "WITH PARTITION COLUMNS",
3269
3303
  "REMOTE WITH CONNECTION"
3270
- ]), ZE = L([
3304
+ ]), ZE = _([
3271
3305
  "CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
3272
- ]), LE = L([
3306
+ ]), LE = _([
3273
3307
  // - create:
3274
3308
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
3275
3309
  "CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
@@ -3357,15 +3391,15 @@ const FT = (R) => ({
3357
3391
  "ASSERT",
3358
3392
  // Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
3359
3393
  "EXPORT DATA"
3360
- ]), uR = L([
3394
+ ]), uR = _([
3361
3395
  "UNION {ALL | DISTINCT}",
3362
3396
  "EXCEPT DISTINCT",
3363
3397
  "INTERSECT DISTINCT"
3364
- ]), HR = L([
3398
+ ]), HR = _([
3365
3399
  "JOIN",
3366
3400
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
3367
3401
  "{INNER | CROSS} JOIN"
3368
- ]), BR = L([
3402
+ ]), BR = _([
3369
3403
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
3370
3404
  "TABLESAMPLE SYSTEM",
3371
3405
  // From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
@@ -3376,7 +3410,7 @@ const FT = (R) => ({
3376
3410
  "{ROWS | RANGE} BETWEEN",
3377
3411
  // comparison operator
3378
3412
  "IS [NOT] DISTINCT FROM"
3379
- ]), dR = L([]), FR = {
3413
+ ]), dR = _([]), FR = {
3380
3414
  name: "bigquery",
3381
3415
  tokenizerOptions: {
3382
3416
  reservedSelect: GR,
@@ -3417,7 +3451,7 @@ function mR(R) {
3417
3451
  }
3418
3452
  function pR(R) {
3419
3453
  let E = v;
3420
- 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));
3421
3455
  }
3422
3456
  function YR(R) {
3423
3457
  var E;
@@ -3427,7 +3461,7 @@ function YR(R) {
3427
3461
  if ((y.ARRAY(e) || y.STRUCT(e)) && ((E = R[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
3428
3462
  const S = hR(R, A + 1), I = R.slice(A, S + 1);
3429
3463
  T.push({
3430
- type: a.IDENTIFIER,
3464
+ type: D.IDENTIFIER,
3431
3465
  raw: I.map(qE("raw")).join(""),
3432
3466
  text: I.map(qE("text")).join(""),
3433
3467
  start: e.start
@@ -3437,7 +3471,7 @@ function YR(R) {
3437
3471
  }
3438
3472
  return T;
3439
3473
  }
3440
- 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];
3441
3475
  function hR(R, E) {
3442
3476
  let T = 0;
3443
3477
  for (let A = E; A < R.length; A++) {
@@ -4210,7 +4244,7 @@ const fR = [
4210
4244
  "VARBINARY",
4211
4245
  "VARCHAR",
4212
4246
  "VARGRAPHIC"
4213
- ], XR = L(["SELECT [ALL | DISTINCT]"]), bR = L([
4247
+ ], XR = _(["SELECT [ALL | DISTINCT]"]), bR = _([
4214
4248
  // queries
4215
4249
  "WITH",
4216
4250
  "FROM",
@@ -4239,9 +4273,9 @@ const fR = [
4239
4273
  "WHEN [NOT] MATCHED [THEN]",
4240
4274
  "UPDATE SET",
4241
4275
  "INSERT"
4242
- ]), jE = L([
4276
+ ]), jE = _([
4243
4277
  "CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
4244
- ]), _E = L([
4278
+ ]), _E = _([
4245
4279
  // - create:
4246
4280
  "CREATE [OR REPLACE] VIEW",
4247
4281
  // - update:
@@ -4444,16 +4478,16 @@ const fR = [
4444
4478
  "TRANSFER OWNERSHIP OF",
4445
4479
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
4446
4480
  "WHILE"
4447
- ]), yR = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), KR = L([
4481
+ ]), yR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), KR = _([
4448
4482
  "JOIN",
4449
4483
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
4450
4484
  "{INNER | CROSS} JOIN"
4451
- ]), $R = L([
4485
+ ]), $R = _([
4452
4486
  "ON DELETE",
4453
4487
  "ON UPDATE",
4454
4488
  "SET NULL",
4455
4489
  "{ROWS | RANGE} BETWEEN"
4456
- ]), gR = L([]), wR = {
4490
+ ]), gR = _([]), wR = {
4457
4491
  name: "db2",
4458
4492
  tokenizerOptions: {
4459
4493
  reservedSelect: XR,
@@ -5364,7 +5398,7 @@ const fR = [
5364
5398
  "VARCHAR",
5365
5399
  "VARGRAPHIC",
5366
5400
  "XML"
5367
- ], QR = L(["SELECT [ALL | DISTINCT]"]), ZR = L([
5401
+ ], QR = _(["SELECT [ALL | DISTINCT]"]), ZR = _([
5368
5402
  // queries
5369
5403
  "WITH [RECURSIVE]",
5370
5404
  "INTO",
@@ -5394,7 +5428,7 @@ const fR = [
5394
5428
  "INSERT",
5395
5429
  // Data definition - table
5396
5430
  "FOR SYSTEM NAME"
5397
- ]), kE = L(["CREATE [OR REPLACE] TABLE"]), rE = L([
5431
+ ]), kE = _(["CREATE [OR REPLACE] TABLE"]), rE = _([
5398
5432
  // - create:
5399
5433
  "CREATE [OR REPLACE] [RECURSIVE] VIEW",
5400
5434
  // - update:
@@ -5490,17 +5524,17 @@ const fR = [
5490
5524
  "TAG",
5491
5525
  "TRANSFER OWNERSHIP OF",
5492
5526
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
5493
- ]), qR = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), jR = L([
5527
+ ]), qR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), jR = _([
5494
5528
  "JOIN",
5495
5529
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
5496
5530
  "[LEFT | RIGHT] EXCEPTION JOIN",
5497
5531
  "{INNER | CROSS} JOIN"
5498
- ]), kR = L([
5532
+ ]), kR = _([
5499
5533
  "ON DELETE",
5500
5534
  "ON UPDATE",
5501
5535
  "SET NULL",
5502
5536
  "{ROWS | RANGE} BETWEEN"
5503
- ]), zR = L([]), EA = {
5537
+ ]), zR = _([]), EA = {
5504
5538
  name: "db2i",
5505
5539
  tokenizerOptions: {
5506
5540
  reservedSelect: QR,
@@ -6353,7 +6387,7 @@ const fR = [
6353
6387
  "UUID",
6354
6388
  "VARBINARY",
6355
6389
  "VARCHAR"
6356
- ], eA = L(["SELECT [ALL | DISTINCT]"]), SA = L([
6390
+ ], eA = _(["SELECT [ALL | DISTINCT]"]), SA = _([
6357
6391
  // queries
6358
6392
  "WITH [RECURSIVE]",
6359
6393
  "FROM",
@@ -6377,9 +6411,9 @@ const fR = [
6377
6411
  "SET",
6378
6412
  // other:
6379
6413
  "RETURNING"
6380
- ]), zE = L([
6414
+ ]), zE = _([
6381
6415
  "CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
6382
- ]), nE = L([
6416
+ ]), nE = _([
6383
6417
  // TABLE
6384
6418
  // - update:
6385
6419
  "UPDATE",
@@ -6457,11 +6491,11 @@ const fR = [
6457
6491
  "PREPARE",
6458
6492
  "EXECUTE",
6459
6493
  "DEALLOCATE [PREPARE]"
6460
- ]), IA = L([
6494
+ ]), IA = _([
6461
6495
  "UNION [ALL | BY NAME]",
6462
6496
  "EXCEPT [ALL]",
6463
6497
  "INTERSECT [ALL]"
6464
- ]), OA = L([
6498
+ ]), OA = _([
6465
6499
  "JOIN",
6466
6500
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
6467
6501
  "{INNER | CROSS} JOIN",
@@ -6470,11 +6504,11 @@ const fR = [
6470
6504
  "POSITIONAL JOIN",
6471
6505
  "ANTI JOIN",
6472
6506
  "SEMI JOIN"
6473
- ]), NA = L([
6507
+ ]), NA = _([
6474
6508
  "{ROWS | RANGE | GROUPS} BETWEEN",
6475
6509
  "SIMILAR TO",
6476
6510
  "IS [NOT] DISTINCT FROM"
6477
- ]), tA = L(["TIMESTAMP WITH TIME ZONE"]), sA = {
6511
+ ]), tA = _(["TIMESTAMP WITH TIME ZONE"]), sA = {
6478
6512
  name: "duckdb",
6479
6513
  tokenizerOptions: {
6480
6514
  reservedSelect: eA,
@@ -7094,7 +7128,7 @@ const fR = [
7094
7128
  "STRUCT",
7095
7129
  "TIMESTAMP",
7096
7130
  "VARCHAR"
7097
- ], rA = L(["SELECT [ALL | DISTINCT]"]), nA = L([
7131
+ ], rA = _(["SELECT [ALL | DISTINCT]"]), nA = _([
7098
7132
  // queries
7099
7133
  "WITH",
7100
7134
  "FROM",
@@ -7128,9 +7162,9 @@ const fR = [
7128
7162
  // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
7129
7163
  "LOAD DATA [LOCAL] INPATH",
7130
7164
  "[OVERWRITE] INTO TABLE"
7131
- ]), ET = L([
7165
+ ]), ET = _([
7132
7166
  "CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
7133
- ]), iE = L([
7167
+ ]), iE = _([
7134
7168
  // - create:
7135
7169
  "CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
7136
7170
  // - update:
@@ -7155,13 +7189,13 @@ const fR = [
7155
7189
  "STORED AS",
7156
7190
  "STORED BY",
7157
7191
  "ROW FORMAT"
7158
- ]), iA = L(["UNION [ALL | DISTINCT]"]), aA = L([
7192
+ ]), iA = _(["UNION [ALL | DISTINCT]"]), aA = _([
7159
7193
  "JOIN",
7160
7194
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
7161
7195
  "{INNER | CROSS} JOIN",
7162
7196
  // non-standard joins
7163
7197
  "LEFT SEMI JOIN"
7164
- ]), oA = L(["{ROWS | RANGE} BETWEEN"]), DA = L([]), PA = {
7198
+ ]), oA = _(["{ROWS | RANGE} BETWEEN"]), DA = _([]), PA = {
7165
7199
  name: "hive",
7166
7200
  tokenizerOptions: {
7167
7201
  reservedSelect: rA,
@@ -7188,9 +7222,9 @@ function AE(R) {
7188
7222
  return R.map((E, T) => {
7189
7223
  const A = R[T + 1] || v;
7190
7224
  if (y.SET(E) && A.text === "(")
7191
- return Object.assign(Object.assign({}, E), { type: a.RESERVED_FUNCTION_NAME });
7225
+ return Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME });
7192
7226
  const e = R[T - 1] || v;
7193
- 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;
7194
7228
  });
7195
7229
  }
7196
7230
  const MA = [
@@ -7699,7 +7733,7 @@ const MA = [
7699
7733
  // CASE expression shorthands
7700
7734
  "COALESCE",
7701
7735
  "NULLIF"
7702
- ], GA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), lA = L([
7736
+ ], GA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), lA = _([
7703
7737
  // queries
7704
7738
  "WITH [RECURSIVE]",
7705
7739
  "FROM",
@@ -7721,9 +7755,9 @@ const MA = [
7721
7755
  "SET",
7722
7756
  // other
7723
7757
  "RETURNING"
7724
- ]), TT = L([
7758
+ ]), TT = _([
7725
7759
  "CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
7726
- ]), aE = L([
7760
+ ]), aE = _([
7727
7761
  // - create:
7728
7762
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
7729
7763
  // - update:
@@ -7930,12 +7964,12 @@ const MA = [
7930
7964
  "XA RECOVER",
7931
7965
  "XA ROLLBACK",
7932
7966
  "XA START"
7933
- ]), uA = L([
7967
+ ]), uA = _([
7934
7968
  "UNION [ALL | DISTINCT]",
7935
7969
  "EXCEPT [ALL | DISTINCT]",
7936
7970
  "INTERSECT [ALL | DISTINCT]",
7937
7971
  "MINUS [ALL | DISTINCT]"
7938
- ]), HA = L([
7972
+ ]), HA = _([
7939
7973
  "JOIN",
7940
7974
  "{LEFT | RIGHT} [OUTER] JOIN",
7941
7975
  "{INNER | CROSS} JOIN",
@@ -7943,12 +7977,12 @@ const MA = [
7943
7977
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
7944
7978
  // non-standard joins
7945
7979
  "STRAIGHT_JOIN"
7946
- ]), BA = L([
7980
+ ]), BA = _([
7947
7981
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
7948
7982
  "CHARACTER SET",
7949
7983
  "{ROWS | RANGE} BETWEEN",
7950
7984
  "IDENTIFIED BY"
7951
- ]), dA = L([]), FA = {
7985
+ ]), dA = _([]), FA = {
7952
7986
  name: "mariadb",
7953
7987
  tokenizerOptions: {
7954
7988
  reservedSelect: GA,
@@ -8705,7 +8739,7 @@ const MA = [
8705
8739
  // 'XOR',
8706
8740
  "YEAR",
8707
8741
  "YEARWEEK"
8708
- ], hA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), fA = L([
8742
+ ], hA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), fA = _([
8709
8743
  // queries
8710
8744
  "WITH [RECURSIVE]",
8711
8745
  "FROM",
@@ -8725,7 +8759,7 @@ const MA = [
8725
8759
  "ON DUPLICATE KEY UPDATE",
8726
8760
  // - update:
8727
8761
  "SET"
8728
- ]), RT = L(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), oE = L([
8762
+ ]), RT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), oE = _([
8729
8763
  // - create:
8730
8764
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
8731
8765
  // - update:
@@ -8906,7 +8940,7 @@ const MA = [
8906
8940
  "REPEAT",
8907
8941
  "RETURN",
8908
8942
  "WHILE"
8909
- ]), VA = L(["UNION [ALL | DISTINCT]"]), WA = L([
8943
+ ]), VA = _(["UNION [ALL | DISTINCT]"]), WA = _([
8910
8944
  "JOIN",
8911
8945
  "{LEFT | RIGHT} [OUTER] JOIN",
8912
8946
  "{INNER | CROSS} JOIN",
@@ -8914,12 +8948,12 @@ const MA = [
8914
8948
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
8915
8949
  // non-standard joins
8916
8950
  "STRAIGHT_JOIN"
8917
- ]), XA = L([
8951
+ ]), XA = _([
8918
8952
  "ON {UPDATE | DELETE} [SET NULL]",
8919
8953
  "CHARACTER SET",
8920
8954
  "{ROWS | RANGE} BETWEEN",
8921
8955
  "IDENTIFIED BY"
8922
- ]), bA = L([]), yA = {
8956
+ ]), bA = _([]), yA = {
8923
8957
  name: "mysql",
8924
8958
  tokenizerOptions: {
8925
8959
  reservedSelect: hA,
@@ -9537,7 +9571,7 @@ const MA = [
9537
9571
  // 'XOR',
9538
9572
  "YEAR",
9539
9573
  "YEARWEEK"
9540
- ], wA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), JA = L([
9574
+ ], wA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), JA = _([
9541
9575
  // queries
9542
9576
  "WITH [RECURSIVE]",
9543
9577
  "FROM",
@@ -9557,7 +9591,7 @@ const MA = [
9557
9591
  "ON DUPLICATE KEY UPDATE",
9558
9592
  // - update:
9559
9593
  "SET"
9560
- ]), AT = L(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), DE = L([
9594
+ ]), AT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), DE = _([
9561
9595
  // https://docs.pingcap.com/tidb/stable/sql-statement-create-view
9562
9596
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
9563
9597
  // https://docs.pingcap.com/tidb/stable/sql-statement-update
@@ -9672,7 +9706,7 @@ const MA = [
9672
9706
  "UNLOCK TABLES",
9673
9707
  // https://docs.pingcap.com/tidb/stable/sql-statement-use
9674
9708
  "USE"
9675
- ]), xA = L(["UNION [ALL | DISTINCT]"]), vA = L([
9709
+ ]), xA = _(["UNION [ALL | DISTINCT]"]), vA = _([
9676
9710
  "JOIN",
9677
9711
  "{LEFT | RIGHT} [OUTER] JOIN",
9678
9712
  "{INNER | CROSS} JOIN",
@@ -9680,12 +9714,12 @@ const MA = [
9680
9714
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
9681
9715
  // non-standard joins
9682
9716
  "STRAIGHT_JOIN"
9683
- ]), QA = L([
9717
+ ]), QA = _([
9684
9718
  "ON {UPDATE | DELETE} [SET NULL]",
9685
9719
  "CHARACTER SET",
9686
9720
  "{ROWS | RANGE} BETWEEN",
9687
9721
  "IDENTIFIED BY"
9688
- ]), ZA = L([]), qA = {
9722
+ ]), ZA = _([]), qA = {
9689
9723
  name: "tidb",
9690
9724
  tokenizerOptions: {
9691
9725
  reservedSelect: wA,
@@ -10183,7 +10217,7 @@ const MA = [
10183
10217
  // which it actually doesn't use.
10184
10218
  //
10185
10219
  // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
10186
- ], Ee = L(["SELECT [ALL | DISTINCT]"]), Te = L([
10220
+ ], Ee = _(["SELECT [ALL | DISTINCT]"]), Te = _([
10187
10221
  // queries
10188
10222
  "WITH",
10189
10223
  "FROM",
@@ -10210,7 +10244,7 @@ const MA = [
10210
10244
  "NEST",
10211
10245
  "UNNEST",
10212
10246
  "RETURNING"
10213
- ]), eT = L([
10247
+ ]), eT = _([
10214
10248
  // - update:
10215
10249
  "UPDATE",
10216
10250
  // - delete:
@@ -10250,7 +10284,7 @@ const MA = [
10250
10284
  "SET CURRENT SCHEMA",
10251
10285
  "SHOW",
10252
10286
  "USE [PRIMARY] KEYS"
10253
- ]), 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 = {
10254
10288
  name: "n1ql",
10255
10289
  tokenizerOptions: {
10256
10290
  reservedSelect: Ee,
@@ -10884,7 +10918,7 @@ const MA = [
10884
10918
  "PRESENTNNV",
10885
10919
  "PRESENTV",
10886
10920
  "PREVIOUS"
10887
- ], se = L(["SELECT [ALL | DISTINCT | UNIQUE]"]), Ce = L([
10921
+ ], se = _(["SELECT [ALL | DISTINCT | UNIQUE]"]), Ce = _([
10888
10922
  // queries
10889
10923
  "WITH",
10890
10924
  "FROM",
@@ -10908,9 +10942,9 @@ const MA = [
10908
10942
  "UPDATE SET",
10909
10943
  // other
10910
10944
  "RETURNING"
10911
- ]), ST = L([
10945
+ ]), ST = _([
10912
10946
  "CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
10913
- ]), PE = L([
10947
+ ]), PE = _([
10914
10948
  // - create:
10915
10949
  "CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
10916
10950
  "CREATE MATERIALIZED VIEW",
@@ -10938,7 +10972,7 @@ const MA = [
10938
10972
  "EXCEPTION",
10939
10973
  "LOOP",
10940
10974
  "START WITH"
10941
- ]), Le = L(["UNION [ALL]", "MINUS", "INTERSECT"]), _e = L([
10975
+ ]), Le = _(["UNION [ALL]", "MINUS", "INTERSECT"]), _e = _([
10942
10976
  "JOIN",
10943
10977
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
10944
10978
  "{INNER | CROSS} JOIN",
@@ -10946,11 +10980,11 @@ const MA = [
10946
10980
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
10947
10981
  // non-standard joins
10948
10982
  "{CROSS | OUTER} APPLY"
10949
- ]), re = L([
10983
+ ]), re = _([
10950
10984
  "ON {UPDATE | DELETE} [SET NULL]",
10951
10985
  "ON COMMIT",
10952
10986
  "{ROWS | RANGE} BETWEEN"
10953
- ]), ne = L([]), ie = {
10987
+ ]), ne = _([]), ie = {
10954
10988
  name: "plsql",
10955
10989
  tokenizerOptions: {
10956
10990
  reservedSelect: se,
@@ -10997,7 +11031,7 @@ const MA = [
10997
11031
  };
10998
11032
  function ae(R) {
10999
11033
  let E = v;
11000
- 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));
11001
11035
  }
11002
11036
  const oe = [
11003
11037
  // https://www.postgresql.org/docs/14/functions.html
@@ -11836,7 +11870,7 @@ const oe = [
11836
11870
  "VARCHAR",
11837
11871
  "XML",
11838
11872
  "ZONE"
11839
- ], Me = L(["SELECT [ALL | DISTINCT]"]), Ue = L([
11873
+ ], Me = _(["SELECT [ALL | DISTINCT]"]), Ue = _([
11840
11874
  // queries
11841
11875
  "WITH [RECURSIVE]",
11842
11876
  "FROM",
@@ -11859,9 +11893,9 @@ const oe = [
11859
11893
  "SET",
11860
11894
  // other
11861
11895
  "RETURNING"
11862
- ]), IT = L([
11896
+ ]), IT = _([
11863
11897
  "CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
11864
- ]), ME = L([
11898
+ ]), ME = _([
11865
11899
  // - create
11866
11900
  "CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
11867
11901
  "CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
@@ -12059,17 +12093,17 @@ const oe = [
12059
12093
  "START TRANSACTION",
12060
12094
  "UNLISTEN",
12061
12095
  "VACUUM"
12062
- ]), ce = L([
12096
+ ]), ce = _([
12063
12097
  "UNION [ALL | DISTINCT]",
12064
12098
  "EXCEPT [ALL | DISTINCT]",
12065
12099
  "INTERSECT [ALL | DISTINCT]"
12066
- ]), Ge = L([
12100
+ ]), Ge = _([
12067
12101
  "JOIN",
12068
12102
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
12069
12103
  "{INNER | CROSS} JOIN",
12070
12104
  "NATURAL [INNER] JOIN",
12071
12105
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
12072
- ]), le = L([
12106
+ ]), le = _([
12073
12107
  "PRIMARY KEY",
12074
12108
  "GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
12075
12109
  "ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
@@ -12080,7 +12114,7 @@ const oe = [
12080
12114
  "IS [NOT] DISTINCT FROM",
12081
12115
  "NULLS {FIRST | LAST}",
12082
12116
  "WITH ORDINALITY"
12083
- ]), ue = L([
12117
+ ]), ue = _([
12084
12118
  // https://www.postgresql.org/docs/current/datatype-datetime.html
12085
12119
  "[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
12086
12120
  ]), He = {
@@ -12765,7 +12799,7 @@ const oe = [
12765
12799
  "TEXT",
12766
12800
  "VARBYTE",
12767
12801
  "VARCHAR"
12768
- ], me = L(["SELECT [ALL | DISTINCT]"]), pe = L([
12802
+ ], me = _(["SELECT [ALL | DISTINCT]"]), pe = _([
12769
12803
  // queries
12770
12804
  "WITH [RECURSIVE]",
12771
12805
  "FROM",
@@ -12783,9 +12817,9 @@ const oe = [
12783
12817
  "VALUES",
12784
12818
  // - update:
12785
12819
  "SET"
12786
- ]), OT = L([
12820
+ ]), OT = _([
12787
12821
  "CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
12788
- ]), UE = L([
12822
+ ]), UE = _([
12789
12823
  // - create:
12790
12824
  "CREATE [OR REPLACE | MATERIALIZED] VIEW",
12791
12825
  // - update:
@@ -12876,13 +12910,13 @@ const oe = [
12876
12910
  "START TRANSACTION",
12877
12911
  "UNLOAD",
12878
12912
  "VACUUM"
12879
- ]), Ye = L(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), he = L([
12913
+ ]), Ye = _(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), he = _([
12880
12914
  "JOIN",
12881
12915
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
12882
12916
  "{INNER | CROSS} JOIN",
12883
12917
  "NATURAL [INNER] JOIN",
12884
12918
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
12885
- ]), fe = L([
12919
+ ]), fe = _([
12886
12920
  // https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
12887
12921
  "NULL AS",
12888
12922
  // https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
@@ -12890,7 +12924,7 @@ const oe = [
12890
12924
  "HIVE METASTORE",
12891
12925
  // in window specifications
12892
12926
  "{ROWS | RANGE} BETWEEN"
12893
- ]), Ve = L([]), We = {
12927
+ ]), Ve = _([]), We = {
12894
12928
  name: "redshift",
12895
12929
  tokenizerOptions: {
12896
12930
  reservedSelect: me,
@@ -13546,7 +13580,7 @@ const oe = [
13546
13580
  // Shorthand functions to use in place of CASE expression
13547
13581
  "COALESCE",
13548
13582
  "NULLIF"
13549
- ], Ke = L(["SELECT [ALL | DISTINCT]"]), $e = L([
13583
+ ], Ke = _(["SELECT [ALL | DISTINCT]"]), $e = _([
13550
13584
  // queries
13551
13585
  "WITH",
13552
13586
  "FROM",
@@ -13571,7 +13605,7 @@ const oe = [
13571
13605
  // https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
13572
13606
  "LOAD DATA [LOCAL] INPATH",
13573
13607
  "[OVERWRITE] INTO TABLE"
13574
- ]), NT = L(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), cE = L([
13608
+ ]), NT = _(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), cE = _([
13575
13609
  // - create:
13576
13610
  "CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
13577
13611
  // - drop table:
@@ -13627,11 +13661,11 @@ const oe = [
13627
13661
  "SHOW TBLPROPERTIES",
13628
13662
  "SHOW VIEWS",
13629
13663
  "UNCACHE TABLE"
13630
- ]), ge = L([
13664
+ ]), ge = _([
13631
13665
  "UNION [ALL | DISTINCT]",
13632
13666
  "EXCEPT [ALL | DISTINCT]",
13633
13667
  "INTERSECT [ALL | DISTINCT]"
13634
- ]), we = L([
13668
+ ]), we = _([
13635
13669
  "JOIN",
13636
13670
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
13637
13671
  "{INNER | CROSS} JOIN",
@@ -13640,12 +13674,12 @@ const oe = [
13640
13674
  // non-standard-joins
13641
13675
  "[LEFT] {ANTI | SEMI} JOIN",
13642
13676
  "NATURAL [LEFT] {ANTI | SEMI} JOIN"
13643
- ]), Je = L([
13677
+ ]), Je = _([
13644
13678
  "ON DELETE",
13645
13679
  "ON UPDATE",
13646
13680
  "CURRENT ROW",
13647
13681
  "{ROWS | RANGE} BETWEEN"
13648
- ]), xe = L([]), ve = {
13682
+ ]), xe = _([]), ve = {
13649
13683
  name: "spark",
13650
13684
  tokenizerOptions: {
13651
13685
  reservedSelect: Ke,
@@ -13679,7 +13713,7 @@ const oe = [
13679
13713
  function Qe(R) {
13680
13714
  return R.map((E, T) => {
13681
13715
  const A = R[T - 1] || v, e = R[T + 1] || v;
13682
- 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;
13683
13717
  });
13684
13718
  }
13685
13719
  const Ze = [
@@ -13980,7 +14014,7 @@ const Ze = [
13980
14014
  "TEXT",
13981
14015
  "VARCHAR",
13982
14016
  "VARYING CHARACTER"
13983
- ], ke = L(["SELECT [ALL | DISTINCT]"]), ze = L([
14017
+ ], ke = _(["SELECT [ALL | DISTINCT]"]), ze = _([
13984
14018
  // queries
13985
14019
  "WITH [RECURSIVE]",
13986
14020
  "FROM",
@@ -14001,7 +14035,7 @@ const Ze = [
14001
14035
  "SET",
14002
14036
  // other:
14003
14037
  "RETURNING"
14004
- ]), tT = L(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), GE = L([
14038
+ ]), tT = _(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), GE = _([
14005
14039
  // - create:
14006
14040
  "CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
14007
14041
  // - update:
@@ -14020,17 +14054,17 @@ const Ze = [
14020
14054
  "RENAME TO",
14021
14055
  // - set schema
14022
14056
  "SET SCHEMA"
14023
- ]), ES = L(["UNION [ALL]", "EXCEPT", "INTERSECT"]), TS = L([
14057
+ ]), ES = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), TS = _([
14024
14058
  "JOIN",
14025
14059
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14026
14060
  "{INNER | CROSS} JOIN",
14027
14061
  "NATURAL [INNER] JOIN",
14028
14062
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
14029
- ]), RS = L([
14063
+ ]), RS = _([
14030
14064
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
14031
14065
  "{ROWS | RANGE | GROUPS} BETWEEN",
14032
14066
  "DO UPDATE"
14033
- ]), AS = L([]), eS = {
14067
+ ]), AS = _([]), eS = {
14034
14068
  name: "sqlite",
14035
14069
  tokenizerOptions: {
14036
14070
  reservedSelect: ke,
@@ -14392,7 +14426,7 @@ const Ze = [
14392
14426
  "TIMESTAMP",
14393
14427
  "VARBINARY",
14394
14428
  "VARCHAR"
14395
- ], NS = L(["SELECT [ALL | DISTINCT]"]), tS = L([
14429
+ ], NS = _(["SELECT [ALL | DISTINCT]"]), tS = _([
14396
14430
  // queries
14397
14431
  "WITH [RECURSIVE]",
14398
14432
  "FROM",
@@ -14411,7 +14445,7 @@ const Ze = [
14411
14445
  "VALUES",
14412
14446
  // - update:
14413
14447
  "SET"
14414
- ]), sT = L(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), lE = L([
14448
+ ]), sT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), lE = _([
14415
14449
  // - create:
14416
14450
  "CREATE [RECURSIVE] VIEW",
14417
14451
  // - update:
@@ -14436,20 +14470,20 @@ const Ze = [
14436
14470
  "TRUNCATE TABLE",
14437
14471
  // other
14438
14472
  "SET SCHEMA"
14439
- ]), sS = L([
14473
+ ]), sS = _([
14440
14474
  "UNION [ALL | DISTINCT]",
14441
14475
  "EXCEPT [ALL | DISTINCT]",
14442
14476
  "INTERSECT [ALL | DISTINCT]"
14443
- ]), CS = L([
14477
+ ]), CS = _([
14444
14478
  "JOIN",
14445
14479
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14446
14480
  "{INNER | CROSS} JOIN",
14447
14481
  "NATURAL [INNER] JOIN",
14448
14482
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
14449
- ]), LS = L([
14483
+ ]), LS = _([
14450
14484
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
14451
14485
  "{ROWS | RANGE} BETWEEN"
14452
- ]), _S = L([]), rS = {
14486
+ ]), _S = _([]), rS = {
14453
14487
  name: "sql",
14454
14488
  tokenizerOptions: {
14455
14489
  reservedSelect: NS,
@@ -15183,7 +15217,7 @@ const Ze = [
15183
15217
  "CODEPOINTS",
15184
15218
  "FUNCTION",
15185
15219
  "JSONPATH"
15186
- ], oS = L(["SELECT [ALL | DISTINCT]"]), DS = L([
15220
+ ], oS = _(["SELECT [ALL | DISTINCT]"]), DS = _([
15187
15221
  // queries
15188
15222
  "WITH [RECURSIVE]",
15189
15223
  "FROM",
@@ -15211,7 +15245,7 @@ const Ze = [
15211
15245
  "PATTERN",
15212
15246
  "SUBSET",
15213
15247
  "DEFINE"
15214
- ]), CT = L(["CREATE TABLE [IF NOT EXISTS]"]), uE = L([
15248
+ ]), CT = _(["CREATE TABLE [IF NOT EXISTS]"]), uE = _([
15215
15249
  // - create:
15216
15250
  "CREATE [OR REPLACE] [MATERIALIZED] VIEW",
15217
15251
  // - update:
@@ -15269,21 +15303,21 @@ const Ze = [
15269
15303
  "SHOW ROLE GRANTS",
15270
15304
  "SHOW FUNCTIONS",
15271
15305
  "SHOW SESSION"
15272
- ]), PS = L([
15306
+ ]), PS = _([
15273
15307
  "UNION [ALL | DISTINCT]",
15274
15308
  "EXCEPT [ALL | DISTINCT]",
15275
15309
  "INTERSECT [ALL | DISTINCT]"
15276
- ]), MS = L([
15310
+ ]), MS = _([
15277
15311
  "JOIN",
15278
15312
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
15279
15313
  "{INNER | CROSS} JOIN",
15280
15314
  "NATURAL [INNER] JOIN",
15281
15315
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
15282
- ]), US = L([
15316
+ ]), US = _([
15283
15317
  "{ROWS | RANGE | GROUPS} BETWEEN",
15284
15318
  // comparison operator
15285
15319
  "IS [NOT] DISTINCT FROM"
15286
- ]), cS = L([]), GS = {
15320
+ ]), cS = _([]), GS = {
15287
15321
  name: "trino",
15288
15322
  tokenizerOptions: {
15289
15323
  reservedSelect: oS,
@@ -15839,7 +15873,7 @@ const Ze = [
15839
15873
  "TIMESTAMP",
15840
15874
  "VARBINARY",
15841
15875
  "VARCHAR"
15842
- ], BS = L(["SELECT [ALL | DISTINCT]"]), dS = L([
15876
+ ], BS = _(["SELECT [ALL | DISTINCT]"]), dS = _([
15843
15877
  // queries
15844
15878
  "WITH",
15845
15879
  "INTO",
@@ -15864,7 +15898,7 @@ const Ze = [
15864
15898
  "MERGE [INTO]",
15865
15899
  "WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
15866
15900
  "UPDATE SET"
15867
- ]), LT = L(["CREATE TABLE"]), HE = L([
15901
+ ]), LT = _(["CREATE TABLE"]), HE = _([
15868
15902
  // - create:
15869
15903
  "CREATE [OR ALTER] [MATERIALIZED] VIEW",
15870
15904
  // - update:
@@ -16044,16 +16078,16 @@ const Ze = [
16044
16078
  "XACT_ABORT",
16045
16079
  "XML INDEX",
16046
16080
  "XML SCHEMA COLLECTION"
16047
- ]), FS = L(["UNION [ALL]", "EXCEPT", "INTERSECT"]), mS = L([
16081
+ ]), FS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), mS = _([
16048
16082
  "JOIN",
16049
16083
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
16050
16084
  "{INNER | CROSS} JOIN",
16051
16085
  // non-standard joins
16052
16086
  "{CROSS | OUTER} APPLY"
16053
- ]), pS = L([
16087
+ ]), pS = _([
16054
16088
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
16055
16089
  "{ROWS | RANGE} BETWEEN"
16056
- ]), YS = L([]), hS = {
16090
+ ]), YS = _([]), hS = {
16057
16091
  name: "transactsql",
16058
16092
  tokenizerOptions: {
16059
16093
  reservedSelect: BS,
@@ -16639,7 +16673,7 @@ const Ze = [
16639
16673
  "WEEKDAY",
16640
16674
  "WEEKOFYEAR",
16641
16675
  "YEAR"
16642
- ], XS = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), bS = L([
16676
+ ], XS = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), bS = _([
16643
16677
  // queries
16644
16678
  "WITH",
16645
16679
  "FROM",
@@ -16661,9 +16695,9 @@ const Ze = [
16661
16695
  // Data definition
16662
16696
  "CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
16663
16697
  "CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
16664
- ]), _T = L([
16698
+ ]), _T = _([
16665
16699
  "CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
16666
- ]), BE = L([
16700
+ ]), BE = _([
16667
16701
  // - create:
16668
16702
  "CREATE VIEW",
16669
16703
  // - update:
@@ -16840,25 +16874,25 @@ const Ze = [
16840
16874
  "REPEAT",
16841
16875
  "RETURN",
16842
16876
  "WHILE"
16843
- ]), yS = L([
16877
+ ]), yS = _([
16844
16878
  "UNION [ALL | DISTINCT]",
16845
16879
  "EXCEPT",
16846
16880
  "INTERSECT",
16847
16881
  "MINUS"
16848
- ]), KS = L([
16882
+ ]), KS = _([
16849
16883
  "JOIN",
16850
16884
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
16851
16885
  "{INNER | CROSS} JOIN",
16852
16886
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
16853
16887
  // non-standard joins
16854
16888
  "STRAIGHT_JOIN"
16855
- ]), $S = L([
16889
+ ]), $S = _([
16856
16890
  "ON DELETE",
16857
16891
  "ON UPDATE",
16858
16892
  "CHARACTER SET",
16859
16893
  "{ROWS | RANGE} BETWEEN",
16860
16894
  "IDENTIFIED BY"
16861
- ]), gS = L([]), wS = {
16895
+ ]), gS = _([]), wS = {
16862
16896
  name: "singlestoredb",
16863
16897
  tokenizerOptions: {
16864
16898
  reservedSelect: XS,
@@ -17651,7 +17685,7 @@ const Ze = [
17651
17685
  "ARRAY",
17652
17686
  "GEOGRAPHY",
17653
17687
  "GEOMETRY"
17654
- ], QS = L(["SELECT [ALL | DISTINCT]"]), ZS = L([
17688
+ ], QS = _(["SELECT [ALL | DISTINCT]"]), ZS = _([
17655
17689
  // queries
17656
17690
  "WITH [RECURSIVE]",
17657
17691
  "FROM",
@@ -17679,10 +17713,10 @@ const Ze = [
17679
17713
  "WHEN MATCHED [AND]",
17680
17714
  "THEN {UPDATE SET | DELETE}",
17681
17715
  "WHEN NOT MATCHED THEN INSERT"
17682
- ]), rT = L([
17716
+ ]), rT = _([
17683
17717
  "CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
17684
17718
  "CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
17685
- ]), dE = L([
17719
+ ]), dE = _([
17686
17720
  // - create:
17687
17721
  "CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
17688
17722
  // - update:
@@ -17923,14 +17957,14 @@ const Ze = [
17923
17957
  "USE SCHEMA",
17924
17958
  "USE SECONDARY ROLES",
17925
17959
  "USE WAREHOUSE"
17926
- ]), qS = L(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), jS = L([
17960
+ ]), qS = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), jS = _([
17927
17961
  "[INNER] JOIN",
17928
17962
  "[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
17929
17963
  "{CROSS | NATURAL} JOIN"
17930
- ]), kS = L([
17964
+ ]), kS = _([
17931
17965
  "{ROWS | RANGE} BETWEEN",
17932
17966
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
17933
- ]), zS = L([]), EI = {
17967
+ ]), zS = _([]), EI = {
17934
17968
  name: "snowflake",
17935
17969
  tokenizerOptions: {
17936
17970
  reservedSelect: QS,
@@ -18159,125 +18193,125 @@ class rI {
18159
18193
  var T, A, e;
18160
18194
  return this.validRules([
18161
18195
  {
18162
- type: a.DISABLE_COMMENT,
18196
+ type: D.DISABLE_COMMENT,
18163
18197
  regex: /(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy
18164
18198
  },
18165
18199
  {
18166
- type: a.BLOCK_COMMENT,
18200
+ type: D.BLOCK_COMMENT,
18167
18201
  regex: E.nestedBlockComments ? new _I() : /(\/\*[^]*?\*\/)/uy
18168
18202
  },
18169
18203
  {
18170
- type: a.LINE_COMMENT,
18204
+ type: D.LINE_COMMENT,
18171
18205
  regex: SI((T = E.lineCommentTypes) !== null && T !== void 0 ? T : ["--"])
18172
18206
  },
18173
18207
  {
18174
- type: a.QUOTED_IDENTIFIER,
18208
+ type: D.QUOTED_IDENTIFIER,
18175
18209
  regex: DT(E.identTypes)
18176
18210
  },
18177
18211
  {
18178
- type: a.NUMBER,
18212
+ type: D.NUMBER,
18179
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
18180
18214
  },
18181
18215
  // RESERVED_KEYWORD_PHRASE and RESERVED_DATA_TYPE_PHRASE is matched before all other keyword tokens
18182
18216
  // to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
18183
18217
  {
18184
- type: a.RESERVED_KEYWORD_PHRASE,
18218
+ type: D.RESERVED_KEYWORD_PHRASE,
18185
18219
  regex: V((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
18186
18220
  text: d
18187
18221
  },
18188
18222
  {
18189
- type: a.RESERVED_DATA_TYPE_PHRASE,
18223
+ type: D.RESERVED_DATA_TYPE_PHRASE,
18190
18224
  regex: V((e = E.reservedDataTypePhrases) !== null && e !== void 0 ? e : [], E.identChars),
18191
18225
  text: d
18192
18226
  },
18193
18227
  {
18194
- type: a.CASE,
18228
+ type: D.CASE,
18195
18229
  regex: /CASE\b/iuy,
18196
18230
  text: d
18197
18231
  },
18198
18232
  {
18199
- type: a.END,
18233
+ type: D.END,
18200
18234
  regex: /END\b/iuy,
18201
18235
  text: d
18202
18236
  },
18203
18237
  {
18204
- type: a.BETWEEN,
18238
+ type: D.BETWEEN,
18205
18239
  regex: /BETWEEN\b/iuy,
18206
18240
  text: d
18207
18241
  },
18208
18242
  {
18209
- type: a.LIMIT,
18243
+ type: D.LIMIT,
18210
18244
  regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
18211
18245
  text: d
18212
18246
  },
18213
18247
  {
18214
- type: a.RESERVED_CLAUSE,
18248
+ type: D.RESERVED_CLAUSE,
18215
18249
  regex: V(E.reservedClauses, E.identChars),
18216
18250
  text: d
18217
18251
  },
18218
18252
  {
18219
- type: a.RESERVED_SELECT,
18253
+ type: D.RESERVED_SELECT,
18220
18254
  regex: V(E.reservedSelect, E.identChars),
18221
18255
  text: d
18222
18256
  },
18223
18257
  {
18224
- type: a.RESERVED_SET_OPERATION,
18258
+ type: D.RESERVED_SET_OPERATION,
18225
18259
  regex: V(E.reservedSetOperations, E.identChars),
18226
18260
  text: d
18227
18261
  },
18228
18262
  {
18229
- type: a.WHEN,
18263
+ type: D.WHEN,
18230
18264
  regex: /WHEN\b/iuy,
18231
18265
  text: d
18232
18266
  },
18233
18267
  {
18234
- type: a.ELSE,
18268
+ type: D.ELSE,
18235
18269
  regex: /ELSE\b/iuy,
18236
18270
  text: d
18237
18271
  },
18238
18272
  {
18239
- type: a.THEN,
18273
+ type: D.THEN,
18240
18274
  regex: /THEN\b/iuy,
18241
18275
  text: d
18242
18276
  },
18243
18277
  {
18244
- type: a.RESERVED_JOIN,
18278
+ type: D.RESERVED_JOIN,
18245
18279
  regex: V(E.reservedJoins, E.identChars),
18246
18280
  text: d
18247
18281
  },
18248
18282
  {
18249
- type: a.AND,
18283
+ type: D.AND,
18250
18284
  regex: /AND\b/iuy,
18251
18285
  text: d
18252
18286
  },
18253
18287
  {
18254
- type: a.OR,
18288
+ type: D.OR,
18255
18289
  regex: /OR\b/iuy,
18256
18290
  text: d
18257
18291
  },
18258
18292
  {
18259
- type: a.XOR,
18293
+ type: D.XOR,
18260
18294
  regex: E.supportsXor ? /XOR\b/iuy : void 0,
18261
18295
  text: d
18262
18296
  },
18263
18297
  ...E.operatorKeyword ? [
18264
18298
  {
18265
- type: a.OPERATOR,
18299
+ type: D.OPERATOR,
18266
18300
  regex: /OPERATOR *\([^)]+\)/iuy
18267
18301
  }
18268
18302
  ] : [],
18269
18303
  {
18270
- type: a.RESERVED_FUNCTION_NAME,
18304
+ type: D.RESERVED_FUNCTION_NAME,
18271
18305
  regex: V(E.reservedFunctionNames, E.identChars),
18272
18306
  text: d
18273
18307
  },
18274
18308
  {
18275
- type: a.RESERVED_DATA_TYPE,
18309
+ type: D.RESERVED_DATA_TYPE,
18276
18310
  regex: V(E.reservedDataTypes, E.identChars),
18277
18311
  text: d
18278
18312
  },
18279
18313
  {
18280
- type: a.RESERVED_KEYWORD,
18314
+ type: D.RESERVED_KEYWORD,
18281
18315
  regex: V(E.reservedKeywords, E.identChars),
18282
18316
  text: d
18283
18317
  }
@@ -18289,26 +18323,26 @@ class rI {
18289
18323
  var T, A;
18290
18324
  return this.validRules([
18291
18325
  {
18292
- type: a.VARIABLE,
18326
+ type: D.VARIABLE,
18293
18327
  regex: E.variableTypes ? NI(E.variableTypes) : void 0
18294
18328
  },
18295
- { type: a.STRING, regex: DT(E.stringTypes) },
18329
+ { type: D.STRING, regex: DT(E.stringTypes) },
18296
18330
  {
18297
- type: a.IDENTIFIER,
18331
+ type: D.IDENTIFIER,
18298
18332
  regex: tI(E.identChars)
18299
18333
  },
18300
- { type: a.DELIMITER, regex: /[;]/uy },
18301
- { type: a.COMMA, regex: /[,]/y },
18334
+ { type: D.DELIMITER, regex: /[;]/uy },
18335
+ { type: D.COMMA, regex: /[,]/y },
18302
18336
  {
18303
- type: a.OPEN_PAREN,
18337
+ type: D.OPEN_PAREN,
18304
18338
  regex: iT("open", E.extraParens)
18305
18339
  },
18306
18340
  {
18307
- type: a.CLOSE_PAREN,
18341
+ type: D.CLOSE_PAREN,
18308
18342
  regex: iT("close", E.extraParens)
18309
18343
  },
18310
18344
  {
18311
- type: a.OPERATOR,
18345
+ type: D.OPERATOR,
18312
18346
  regex: aT([
18313
18347
  // standard operators
18314
18348
  "+",
@@ -18324,9 +18358,9 @@ class rI {
18324
18358
  ...(T = E.operators) !== null && T !== void 0 ? T : []
18325
18359
  ])
18326
18360
  },
18327
- { type: a.ASTERISK, regex: /[*]/uy },
18361
+ { type: D.ASTERISK, regex: /[*]/uy },
18328
18362
  {
18329
- type: a.PROPERTY_ACCESS_OPERATOR,
18363
+ type: D.PROPERTY_ACCESS_OPERATOR,
18330
18364
  regex: aT([".", ...(A = E.propertyAccessOperators) !== null && A !== void 0 ? A : []])
18331
18365
  }
18332
18366
  ]);
@@ -18344,33 +18378,33 @@ class rI {
18344
18378
  };
18345
18379
  return this.validRules([
18346
18380
  {
18347
- type: a.NAMED_PARAMETER,
18381
+ type: D.NAMED_PARAMETER,
18348
18382
  regex: mE(C.named, fT(E.paramChars || E.identChars)),
18349
- key: (N) => N.slice(1)
18383
+ key: (O) => O.slice(1)
18350
18384
  },
18351
18385
  {
18352
- type: a.QUOTED_PARAMETER,
18386
+ type: D.QUOTED_PARAMETER,
18353
18387
  regex: mE(C.quoted, hT(E.identTypes)),
18354
- key: (N) => (({ tokenKey: O, quoteChar: s }) => O.replace(new RegExp(h("\\" + s), "gu"), s))({
18355
- tokenKey: N.slice(2, -1),
18356
- 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)
18357
18391
  })
18358
18392
  },
18359
18393
  {
18360
- type: a.NUMBERED_PARAMETER,
18394
+ type: D.NUMBERED_PARAMETER,
18361
18395
  regex: mE(C.numbered, "[0-9]+"),
18362
- key: (N) => N.slice(1)
18396
+ key: (O) => O.slice(1)
18363
18397
  },
18364
18398
  {
18365
- type: a.POSITIONAL_PARAMETER,
18399
+ type: D.POSITIONAL_PARAMETER,
18366
18400
  regex: C.positional ? /[?]/y : void 0
18367
18401
  },
18368
- ...C.custom.map((N) => {
18369
- var O;
18402
+ ...C.custom.map((O) => {
18403
+ var N;
18370
18404
  return {
18371
- type: a.CUSTOM_PARAMETER,
18372
- regex: K(N.regex),
18373
- 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)
18374
18408
  };
18375
18409
  })
18376
18410
  ]);
@@ -18432,195 +18466,195 @@ function UI() {
18432
18466
  (function(E, T) {
18433
18467
  R.exports ? R.exports = T() : E.nearley = T();
18434
18468
  })(MI, function() {
18435
- function E(N, O, s) {
18436
- 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;
18437
18471
  }
18438
- E.highestId = 0, E.prototype.toString = function(N) {
18439
- 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(" ");
18440
- 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;
18441
18475
  };
18442
- function T(N, O, s, _) {
18443
- 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;
18444
18478
  }
18445
18479
  T.prototype.toString = function() {
18446
18480
  return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
18447
- }, T.prototype.nextState = function(N) {
18448
- var O = new T(this.rule, this.dot + 1, this.reference, this.wantedBy);
18449
- 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;
18450
18484
  }, T.prototype.build = function() {
18451
- var N = [], O = this;
18485
+ var O = [], N = this;
18452
18486
  do
18453
- N.push(O.right.data), O = O.left;
18454
- while (O.left);
18455
- return N.reverse(), N;
18487
+ O.push(N.right.data), N = N.left;
18488
+ while (N.left);
18489
+ return O.reverse(), O;
18456
18490
  }, T.prototype.finish = function() {
18457
18491
  this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, I.fail));
18458
18492
  };
18459
- function A(N, O) {
18460
- 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 = {};
18461
18495
  }
18462
- A.prototype.process = function(N) {
18463
- for (var O = this.states, s = this.wants, _ = this.completed, n = 0; n < O.length; n++) {
18464
- var D = O[n];
18465
- if (D.isComplete) {
18466
- if (D.finish(), D.data !== I.fail) {
18467
- 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--; ) {
18468
18502
  var P = o[l];
18469
- this.complete(P, D);
18503
+ this.complete(P, i);
18470
18504
  }
18471
- if (D.reference === this.index) {
18472
- var c = D.rule.name;
18473
- (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);
18474
18508
  }
18475
18509
  }
18476
18510
  } else {
18477
- var c = D.rule.symbols[D.dot];
18511
+ var c = i.rule.symbols[i.dot];
18478
18512
  if (typeof c != "string") {
18479
- this.scannable.push(D);
18513
+ this.scannable.push(i);
18480
18514
  continue;
18481
18515
  }
18482
18516
  if (s[c]) {
18483
- if (s[c].push(D), _.hasOwnProperty(c))
18484
- 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++) {
18485
18519
  var u = M[l];
18486
- this.complete(D, u);
18520
+ this.complete(i, u);
18487
18521
  }
18488
18522
  } else
18489
- s[c] = [D], this.predict(c);
18523
+ s[c] = [i], this.predict(c);
18490
18524
  }
18491
18525
  }
18492
- }, A.prototype.predict = function(N) {
18493
- for (var O = this.grammar.byName[N] || [], s = 0; s < O.length; s++) {
18494
- var _ = O[s], n = this.wants[N], D = new T(_, 0, this.index, n);
18495
- 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);
18496
18530
  }
18497
- }, A.prototype.complete = function(N, O) {
18498
- var s = N.nextState(O);
18531
+ }, A.prototype.complete = function(O, N) {
18532
+ var s = O.nextState(N);
18499
18533
  this.states.push(s);
18500
18534
  };
18501
- function e(N, O) {
18502
- 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;
18503
18537
  var s = this.byName = {};
18504
- this.rules.forEach(function(_) {
18505
- 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);
18506
18540
  });
18507
18541
  }
18508
- e.fromCompiled = function(_, O) {
18509
- var s = _.Lexer;
18510
- _.ParserStart && (O = _.ParserStart, _ = _.ParserRules);
18511
- var _ = _.map(function(D) {
18512
- return new E(D.name, D.symbols, D.postprocess);
18513
- }), n = new e(_, O);
18514
- 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;
18515
18549
  };
18516
18550
  function S() {
18517
18551
  this.reset("");
18518
18552
  }
18519
- S.prototype.reset = function(N, O) {
18520
- 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;
18521
18555
  }, S.prototype.next = function() {
18522
18556
  if (this.index < this.buffer.length) {
18523
- var N = this.buffer[this.index++];
18524
- return N === `
18525
- ` && (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 };
18526
18560
  }
18527
18561
  }, S.prototype.save = function() {
18528
18562
  return {
18529
18563
  line: this.line,
18530
18564
  col: this.index - this.lastLineBreak
18531
18565
  };
18532
- }, S.prototype.formatError = function(N, O) {
18566
+ }, S.prototype.formatError = function(O, N) {
18533
18567
  var s = this.buffer;
18534
18568
  if (typeof s == "string") {
18535
- var _ = s.split(`
18569
+ var r = s.split(`
18536
18570
  `).slice(
18537
18571
  Math.max(0, this.line - 5),
18538
18572
  this.line
18539
- ), n = s.indexOf(`
18573
+ ), L = s.indexOf(`
18540
18574
  `, this.index);
18541
- n === -1 && (n = s.length);
18542
- var D = this.index - this.lastLineBreak, o = String(this.line).length;
18543
- 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 + `:
18544
18578
 
18545
- `, O += _.map(function(P, c) {
18546
- 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;
18547
18581
  }, this).join(`
18548
- `), O += `
18549
- ` + l("", o + D) + `^
18550
- `, O;
18582
+ `), N += `
18583
+ ` + l("", o + i) + `^
18584
+ `, N;
18551
18585
  } else
18552
- return O + " at index " + (this.index - 1);
18586
+ return N + " at index " + (this.index - 1);
18553
18587
  function l(P, c) {
18554
18588
  var M = String(P);
18555
18589
  return Array(c - M.length + 1).join(" ") + M;
18556
18590
  }
18557
18591
  };
18558
- function I(N, O, s) {
18559
- if (N instanceof e)
18560
- var _ = N, s = O;
18592
+ function I(O, N, s) {
18593
+ if (O instanceof e)
18594
+ var r = O, s = N;
18561
18595
  else
18562
- var _ = e.fromCompiled(N, O);
18563
- this.grammar = _, this.options = {
18596
+ var r = e.fromCompiled(O, N);
18597
+ this.grammar = r, this.options = {
18564
18598
  keepHistory: !1,
18565
- lexer: _.lexer || new S()
18599
+ lexer: r.lexer || new S()
18566
18600
  };
18567
- for (var n in s || {})
18568
- this.options[n] = s[n];
18601
+ for (var L in s || {})
18602
+ this.options[L] = s[L];
18569
18603
  this.lexer = this.options.lexer, this.lexerState = void 0;
18570
- var D = new A(_, 0);
18571
- 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;
18572
18606
  }
18573
- I.fail = {}, I.prototype.feed = function(N) {
18574
- var O = this.lexer;
18575
- O.reset(N, this.lexerState);
18607
+ I.fail = {}, I.prototype.feed = function(O) {
18608
+ var N = this.lexer;
18609
+ N.reset(O, this.lexerState);
18576
18610
  for (var s; ; ) {
18577
18611
  try {
18578
- if (s = O.next(), !s)
18612
+ if (s = N.next(), !s)
18579
18613
  break;
18580
18614
  } catch (Y) {
18581
18615
  var o = new A(this.grammar, this.current + 1);
18582
18616
  this.table.push(o);
18583
- var _ = new Error(this.reportLexerError(Y));
18584
- 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;
18585
18619
  }
18586
- var n = this.table[this.current];
18620
+ var L = this.table[this.current];
18587
18621
  this.options.keepHistory || delete this.table[this.current - 1];
18588
- var D = this.current + 1, o = new A(this.grammar, D);
18622
+ var i = this.current + 1, o = new A(this.grammar, i);
18589
18623
  this.table.push(o);
18590
- 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--; ) {
18591
18625
  var u = c[M], H = u.rule.symbols[u.dot];
18592
18626
  if (H.test ? H.test(P) : H.type ? H.type === s.type : H.literal === l) {
18593
- 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 });
18594
18628
  o.states.push(B);
18595
18629
  }
18596
18630
  }
18597
18631
  if (o.process(), o.states.length === 0) {
18598
- var _ = new Error(this.reportError(s));
18599
- throw _.offset = this.current, _.token = s, _;
18632
+ var r = new Error(this.reportError(s));
18633
+ throw r.offset = this.current, r.token = s, r;
18600
18634
  }
18601
- this.options.keepHistory && (n.lexerState = O.save()), this.current++;
18635
+ this.options.keepHistory && (L.lexerState = N.save()), this.current++;
18602
18636
  }
18603
- return n && (this.lexerState = O.save()), this.results = this.finish(), this;
18604
- }, I.prototype.reportLexerError = function(N) {
18605
- var O, s, _ = N.token;
18606
- 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);
18607
- }, I.prototype.reportError = function(N) {
18608
- var O = (N.type ? N.type + " token: " : "") + JSON.stringify(N.value !== void 0 ? N.value : N), s = this.lexer.formatError(N, "Syntax error");
18609
- return this.reportErrorCommon(s, O);
18610
- }, 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) {
18611
18645
  var s = [];
18612
- s.push(N);
18613
- 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) {
18614
18648
  var P = l.rule.symbols[l.dot];
18615
18649
  return P && typeof P != "string";
18616
18650
  });
18617
- if (D.length === 0)
18618
- s.push("Unexpected " + O + `. I did not expect any more input. Here is the state of my parse table:
18619
- `), 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);
18620
18654
  else {
18621
- 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:
18622
18656
  `);
18623
- var o = D.map(function(l) {
18657
+ var o = i.map(function(l) {
18624
18658
  return this.buildFirstStateStack(l, []) || [l];
18625
18659
  }, this);
18626
18660
  o.forEach(function(l) {
@@ -18630,68 +18664,68 @@ function UI() {
18630
18664
  }
18631
18665
  return s.push(""), s.join(`
18632
18666
  `);
18633
- }, I.prototype.displayStateStack = function(N, O) {
18634
- for (var s, _ = 0, n = 0; n < N.length; n++) {
18635
- var D = N[n], o = D.rule.toString(D.dot);
18636
- 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;
18637
18671
  }
18638
- }, I.prototype.getSymbolDisplay = function(N) {
18639
- return t(N);
18640
- }, I.prototype.buildFirstStateStack = function(N, O) {
18641
- 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)
18642
18676
  return null;
18643
- if (N.wantedBy.length === 0)
18644
- return [N];
18645
- var s = N.wantedBy[0], _ = [N].concat(O), n = this.buildFirstStateStack(s, _);
18646
- 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);
18647
18681
  }, I.prototype.save = function() {
18648
- var N = this.table[this.current];
18649
- return N.lexerState = this.lexerState, N;
18650
- }, I.prototype.restore = function(N) {
18651
- var O = N.index;
18652
- this.current = O, this.table[O] = N, this.table.splice(O + 1), this.lexerState = N.lexerState, this.results = this.finish();
18653
- }, 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) {
18654
18688
  if (!this.options.keepHistory)
18655
18689
  throw new Error("set option `keepHistory` to enable rewinding");
18656
- this.restore(this.table[N]);
18690
+ this.restore(this.table[O]);
18657
18691
  }, I.prototype.finish = function() {
18658
- var N = [], O = this.grammar.start, s = this.table[this.table.length - 1];
18659
- return s.states.forEach(function(_) {
18660
- _.rule.name === O && _.dot === _.rule.symbols.length && _.reference === 0 && _.data !== I.fail && N.push(_);
18661
- }), N.map(function(_) {
18662
- 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;
18663
18697
  });
18664
18698
  };
18665
- function t(N) {
18666
- var O = typeof N;
18667
- if (O === "string")
18668
- return N;
18669
- if (O === "object") {
18670
- if (N.literal)
18671
- return JSON.stringify(N.literal);
18672
- if (N instanceof RegExp)
18673
- return "character matching " + N;
18674
- if (N.type)
18675
- return N.type + " token";
18676
- if (N.test)
18677
- return "token matching " + String(N.test);
18678
- 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);
18679
18713
  }
18680
18714
  }
18681
- function C(N) {
18682
- var O = typeof N;
18683
- if (O === "string")
18684
- return N;
18685
- if (O === "object") {
18686
- if (N.literal)
18687
- return JSON.stringify(N.literal);
18688
- if (N instanceof RegExp)
18689
- return N.toString();
18690
- if (N.type)
18691
- return "%" + N.type;
18692
- if (N.test)
18693
- return "<" + String(N.test) + ">";
18694
- 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);
18695
18729
  }
18696
18730
  }
18697
18731
  return {
@@ -18710,39 +18744,39 @@ function lI(R) {
18710
18744
  const uI = (R, E, T) => {
18711
18745
  if (mT(R.type)) {
18712
18746
  const A = mI(T, E);
18713
- if (A && A.type === a.PROPERTY_ACCESS_OPERATOR)
18714
- 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 });
18715
18749
  const e = Q(T, E);
18716
- if (e && e.type === a.PROPERTY_ACCESS_OPERATOR)
18717
- 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 });
18718
18752
  }
18719
18753
  return R;
18720
18754
  }, HI = (R, E, T) => {
18721
- if (R.type === a.RESERVED_FUNCTION_NAME) {
18755
+ if (R.type === D.RESERVED_FUNCTION_NAME) {
18722
18756
  const A = Q(T, E);
18723
18757
  if (!A || !WT(A))
18724
- 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 });
18725
18759
  }
18726
18760
  return R;
18727
18761
  }, BI = (R, E, T) => {
18728
- if (R.type === a.RESERVED_DATA_TYPE) {
18762
+ if (R.type === D.RESERVED_DATA_TYPE) {
18729
18763
  const A = Q(T, E);
18730
18764
  if (A && WT(A))
18731
- 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 });
18732
18766
  }
18733
18767
  return R;
18734
18768
  }, dI = (R, E, T) => {
18735
- if (R.type === a.IDENTIFIER) {
18769
+ if (R.type === D.IDENTIFIER) {
18736
18770
  const A = Q(T, E);
18737
18771
  if (A && XT(A))
18738
- return Object.assign(Object.assign({}, R), { type: a.ARRAY_IDENTIFIER });
18772
+ return Object.assign(Object.assign({}, R), { type: D.ARRAY_IDENTIFIER });
18739
18773
  }
18740
18774
  return R;
18741
18775
  }, FI = (R, E, T) => {
18742
- if (R.type === a.RESERVED_DATA_TYPE) {
18776
+ if (R.type === D.RESERVED_DATA_TYPE) {
18743
18777
  const A = Q(T, E);
18744
18778
  if (A && XT(A))
18745
- return Object.assign(Object.assign({}, R), { type: a.ARRAY_KEYWORD });
18779
+ return Object.assign(Object.assign({}, R), { type: D.ARRAY_KEYWORD });
18746
18780
  }
18747
18781
  return R;
18748
18782
  }, mI = (R, E) => Q(R, E, -1), Q = (R, E, T = 1) => {
@@ -18750,7 +18784,7 @@ const uI = (R, E, T) => {
18750
18784
  for (; R[E + A * T] && pI(R[E + A * T]); )
18751
18785
  A++;
18752
18786
  return R[E + A * T];
18753
- }, 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;
18754
18788
  class bT {
18755
18789
  constructor(E) {
18756
18790
  this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
@@ -18768,7 +18802,7 @@ class bT {
18768
18802
  return `Parse error at token: ${E.text} at line ${T} column ${A}`;
18769
18803
  }
18770
18804
  has(E) {
18771
- return E in a;
18805
+ return E in D;
18772
18806
  }
18773
18807
  }
18774
18808
  var U;
@@ -18818,7 +18852,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
18818
18852
  postprocess: ([R, [E]]) => ({
18819
18853
  type: U.statement,
18820
18854
  children: R,
18821
- hasSemicolon: E.type === a.DELIMITER
18855
+ hasSemicolon: E.type === D.DELIMITER
18822
18856
  })
18823
18857
  },
18824
18858
  { name: "expressions_or_clauses$ebnf$1", symbols: [] },
@@ -19212,10 +19246,10 @@ ${JSON.stringify(I, void 0, 2)}`);
19212
19246
  }
19213
19247
  };
19214
19248
  }
19215
- var i;
19249
+ var a;
19216
19250
  (function(R) {
19217
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";
19218
- })(i = i || (i = {}));
19252
+ })(a = a || (a = {}));
19219
19253
  class yT {
19220
19254
  constructor(E) {
19221
19255
  this.indentation = E, this.items = [];
@@ -19226,26 +19260,26 @@ class yT {
19226
19260
  add(...E) {
19227
19261
  for (const T of E)
19228
19262
  switch (T) {
19229
- case i.SPACE:
19230
- this.items.push(i.SPACE);
19263
+ case a.SPACE:
19264
+ this.items.push(a.SPACE);
19231
19265
  break;
19232
- case i.NO_SPACE:
19266
+ case a.NO_SPACE:
19233
19267
  this.trimHorizontalWhitespace();
19234
19268
  break;
19235
- case i.NO_NEWLINE:
19269
+ case a.NO_NEWLINE:
19236
19270
  this.trimWhitespace();
19237
19271
  break;
19238
- case i.NEWLINE:
19239
- this.trimHorizontalWhitespace(), this.addNewline(i.NEWLINE);
19272
+ case a.NEWLINE:
19273
+ this.trimHorizontalWhitespace(), this.addNewline(a.NEWLINE);
19240
19274
  break;
19241
- case i.MANDATORY_NEWLINE:
19242
- this.trimHorizontalWhitespace(), this.addNewline(i.MANDATORY_NEWLINE);
19275
+ case a.MANDATORY_NEWLINE:
19276
+ this.trimHorizontalWhitespace(), this.addNewline(a.MANDATORY_NEWLINE);
19243
19277
  break;
19244
- case i.INDENT:
19278
+ case a.INDENT:
19245
19279
  this.addIndentation();
19246
19280
  break;
19247
- case i.SINGLE_INDENT:
19248
- this.items.push(i.SINGLE_INDENT);
19281
+ case a.SINGLE_INDENT:
19282
+ this.items.push(a.SINGLE_INDENT);
19249
19283
  break;
19250
19284
  default:
19251
19285
  this.items.push(T);
@@ -19262,10 +19296,10 @@ class yT {
19262
19296
  addNewline(E) {
19263
19297
  if (this.items.length > 0)
19264
19298
  switch (Z(this.items)) {
19265
- case i.NEWLINE:
19299
+ case a.NEWLINE:
19266
19300
  this.items.pop(), this.items.push(E);
19267
19301
  break;
19268
- case i.MANDATORY_NEWLINE:
19302
+ case a.MANDATORY_NEWLINE:
19269
19303
  break;
19270
19304
  default:
19271
19305
  this.items.push(E);
@@ -19274,7 +19308,7 @@ class yT {
19274
19308
  }
19275
19309
  addIndentation() {
19276
19310
  for (let E = 0; E < this.indentation.getLevel(); E++)
19277
- this.items.push(i.SINGLE_INDENT);
19311
+ this.items.push(a.SINGLE_INDENT);
19278
19312
  }
19279
19313
  /**
19280
19314
  * Returns the final SQL string.
@@ -19290,20 +19324,20 @@ class yT {
19290
19324
  }
19291
19325
  itemToString(E) {
19292
19326
  switch (E) {
19293
- case i.SPACE:
19327
+ case a.SPACE:
19294
19328
  return " ";
19295
- case i.NEWLINE:
19296
- case i.MANDATORY_NEWLINE:
19329
+ case a.NEWLINE:
19330
+ case a.MANDATORY_NEWLINE:
19297
19331
  return `
19298
19332
  `;
19299
- case i.SINGLE_INDENT:
19333
+ case a.SINGLE_INDENT:
19300
19334
  return this.indentation.getSingleIndent();
19301
19335
  default:
19302
19336
  return E;
19303
19337
  }
19304
19338
  }
19305
19339
  }
19306
- 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;
19307
19341
  function GT(R, E) {
19308
19342
  if (E === "standard")
19309
19343
  return R;
@@ -19311,7 +19345,7 @@ function GT(R, E) {
19311
19345
  return R.length >= 10 && R.includes(" ") && ([R, ...T] = R.split(" ")), E === "tabularLeft" ? R = R.padEnd(9, " ") : R = R.padStart(9, " "), R + ["", ...T].join(" ");
19312
19346
  }
19313
19347
  function lT(R) {
19314
- 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;
19315
19349
  }
19316
19350
  const YE = "top-level", yI = "block-level";
19317
19351
  class KT {
@@ -19375,9 +19409,9 @@ class KI extends yT {
19375
19409
  if (typeof E == "string")
19376
19410
  this.length += E.length, this.trailingSpace = !1;
19377
19411
  else {
19378
- if (E === i.MANDATORY_NEWLINE || E === i.NEWLINE)
19412
+ if (E === a.MANDATORY_NEWLINE || E === a.NEWLINE)
19379
19413
  throw new hE();
19380
- 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--);
19381
19415
  }
19382
19416
  }
19383
19417
  }
@@ -19473,23 +19507,23 @@ class RE {
19473
19507
  }), this.formatNode(E.parenthesis);
19474
19508
  }
19475
19509
  formatPropertyAccess(E) {
19476
- 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);
19477
19511
  }
19478
19512
  formatParenthesis(E) {
19479
19513
  const T = this.formatInlineExpression(E.children);
19480
- 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));
19481
19515
  }
19482
19516
  formatBetweenPredicate(E) {
19483
- 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);
19484
19518
  }
19485
19519
  formatCaseExpression(E) {
19486
- 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);
19487
19521
  }
19488
19522
  formatCaseWhen(E) {
19489
- 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);
19490
19524
  }
19491
19525
  formatCaseElse(E) {
19492
- 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);
19493
19527
  }
19494
19528
  formatClause(E) {
19495
19529
  this.isOnelineClause(E) ? this.formatClauseInOnelineStyle(E) : J(this.cfg) ? this.formatClauseInTabularStyle(E) : this.formatClauseInIndentedStyle(E);
@@ -19498,39 +19532,39 @@ class RE {
19498
19532
  return J(this.cfg) ? this.dialectCfg.tabularOnelineClauses[E.nameKw.text] : this.dialectCfg.onelineClauses[E.nameKw.text];
19499
19533
  }
19500
19534
  formatClauseInIndentedStyle(E) {
19501
- 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();
19502
19536
  }
19503
19537
  formatClauseInOnelineStyle(E) {
19504
- 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);
19505
19539
  }
19506
19540
  formatClauseInTabularStyle(E) {
19507
- 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();
19508
19542
  }
19509
19543
  formatSetOperation(E) {
19510
- 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);
19511
19545
  }
19512
19546
  formatLimitClause(E) {
19513
19547
  this.withComments(E.limitKw, () => {
19514
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.limitKw));
19515
- }), 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();
19516
19550
  }
19517
19551
  formatAllColumnsAsterisk(E) {
19518
- this.layout.add("*", i.SPACE);
19552
+ this.layout.add("*", a.SPACE);
19519
19553
  }
19520
19554
  formatLiteral(E) {
19521
- this.layout.add(E.text, i.SPACE);
19555
+ this.layout.add(E.text, a.SPACE);
19522
19556
  }
19523
19557
  formatIdentifier(E) {
19524
- this.layout.add(this.showIdentifier(E), i.SPACE);
19558
+ this.layout.add(this.showIdentifier(E), a.SPACE);
19525
19559
  }
19526
19560
  formatParameter(E) {
19527
- this.layout.add(this.params.get(E), i.SPACE);
19561
+ this.layout.add(this.params.get(E), a.SPACE);
19528
19562
  }
19529
19563
  formatOperator({ text: E }) {
19530
- 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);
19531
19565
  }
19532
19566
  formatComma(E) {
19533
- 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);
19534
19568
  }
19535
19569
  withComments(E, T) {
19536
19570
  this.formatComments(E.leadingComments), T(), this.formatComments(E.trailingComments);
@@ -19541,12 +19575,12 @@ class RE {
19541
19575
  });
19542
19576
  }
19543
19577
  formatLineComment(E) {
19544
- 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);
19545
19579
  }
19546
19580
  formatBlockComment(E) {
19547
19581
  E.type === U.block_comment && this.isMultilineBlockComment(E) ? (this.splitBlockComment(E.text).forEach((T) => {
19548
- this.layout.add(i.NEWLINE, i.INDENT, T);
19549
- }), 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);
19550
19584
  }
19551
19585
  isMultilineBlockComment(E) {
19552
19586
  return FE(E.text) || FE(E.precedingWhitespace || "");
@@ -19619,27 +19653,27 @@ class RE {
19619
19653
  }
19620
19654
  formatKeywordNode(E) {
19621
19655
  switch (E.tokenType) {
19622
- case a.RESERVED_JOIN:
19656
+ case D.RESERVED_JOIN:
19623
19657
  return this.formatJoin(E);
19624
- case a.AND:
19625
- case a.OR:
19626
- case a.XOR:
19658
+ case D.AND:
19659
+ case D.OR:
19660
+ case D.XOR:
19627
19661
  return this.formatLogicalOperator(E);
19628
19662
  default:
19629
19663
  return this.formatKeyword(E);
19630
19664
  }
19631
19665
  }
19632
19666
  formatJoin(E) {
19633
- 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);
19634
19668
  }
19635
19669
  formatKeyword(E) {
19636
- this.layout.add(this.showKw(E), i.SPACE);
19670
+ this.layout.add(this.showKw(E), a.SPACE);
19637
19671
  }
19638
19672
  formatLogicalOperator(E) {
19639
- 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);
19640
19674
  }
19641
19675
  formatDataType(E) {
19642
- this.layout.add(this.showDataType(E), i.SPACE);
19676
+ this.layout.add(this.showDataType(E), a.SPACE);
19643
19677
  }
19644
19678
  showKw(E) {
19645
19679
  return lT(E.tokenType) ? GT(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
@@ -19719,7 +19753,7 @@ class $I {
19719
19753
  params: this.params,
19720
19754
  layout: new yT(new KT(oI(this.cfg)))
19721
19755
  }).format(E.children);
19722
- 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();
19723
19757
  }
19724
19758
  }
19725
19759
  class TE extends Error {
@@ -19986,27 +20020,27 @@ ${T.join(`
19986
20020
  generateCubeMetadata(E) {
19987
20021
  const T = Object.keys(E.measures), A = Object.keys(E.dimensions), e = new Array(T.length), S = new Array(A.length);
19988
20022
  for (let t = 0; t < T.length; t++) {
19989
- const C = T[t], N = E.measures[C];
20023
+ const C = T[t], O = E.measures[C];
19990
20024
  e[t] = {
19991
20025
  name: `${E.name}.${C}`,
19992
- title: N.title || C,
19993
- shortTitle: N.title || C,
19994
- type: N.type,
20026
+ title: O.title || C,
20027
+ shortTitle: O.title || C,
20028
+ type: O.type,
19995
20029
  format: void 0,
19996
20030
  // Measure doesn't have format field
19997
- description: N.description
20031
+ description: O.description
19998
20032
  };
19999
20033
  }
20000
20034
  for (let t = 0; t < A.length; t++) {
20001
- const C = A[t], N = E.dimensions[C];
20035
+ const C = A[t], O = E.dimensions[C];
20002
20036
  S[t] = {
20003
20037
  name: `${E.name}.${C}`,
20004
- title: N.title || C,
20005
- shortTitle: N.title || C,
20006
- type: N.type,
20038
+ title: O.title || C,
20039
+ shortTitle: O.title || C,
20040
+ type: O.type,
20007
20041
  format: void 0,
20008
20042
  // Dimension doesn't have format field
20009
- description: N.description
20043
+ description: O.description
20010
20044
  };
20011
20045
  }
20012
20046
  const I = [];
@@ -20016,9 +20050,9 @@ ${T.join(`
20016
20050
  I.push({
20017
20051
  targetCube: C.name,
20018
20052
  relationship: t.relationship,
20019
- joinFields: t.on.map((N) => ({
20020
- sourceField: this.getColumnName(N.source),
20021
- targetField: this.getColumnName(N.target)
20053
+ joinFields: t.on.map((O) => ({
20054
+ sourceField: this.getColumnName(O.source),
20055
+ targetField: this.getColumnName(O.target)
20022
20056
  }))
20023
20057
  });
20024
20058
  }