drizzle-cube 0.1.18 → 0.1.20

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.
@@ -81,9 +81,9 @@ const dR = {
81
81
  startActiveSpan(T, E) {
82
82
  return E();
83
83
  }
84
- }, SE = Symbol.for("drizzle:ViewBaseConfig"), aE = Symbol.for("drizzle:Schema"), TT = Symbol.for("drizzle:Columns"), RT = Symbol.for("drizzle:ExtraConfigColumns"), oE = Symbol.for("drizzle:OriginalName"), PE = Symbol.for("drizzle:BaseName"), CE = Symbol.for("drizzle:IsAlias"), AT = Symbol.for("drizzle:ExtraConfigBuilder"), fR = Symbol.for("drizzle:IsDrizzleTable");
84
+ }, SE = Symbol.for("drizzle:ViewBaseConfig"), aE = Symbol.for("drizzle:Schema"), TT = Symbol.for("drizzle:Columns"), RT = Symbol.for("drizzle:ExtraConfigColumns"), PE = Symbol.for("drizzle:OriginalName"), oE = Symbol.for("drizzle:BaseName"), CE = Symbol.for("drizzle:IsAlias"), AT = Symbol.for("drizzle:ExtraConfigBuilder"), fR = Symbol.for("drizzle:IsDrizzleTable");
85
85
  var wT, xT, vT, QT, ZT, qT, jT, kT, zT, ER;
86
- ER = X, zT = DE, kT = oE, jT = aE, qT = TT, ZT = RT, QT = PE, vT = CE, xT = fR, wT = AT;
86
+ ER = X, zT = DE, kT = PE, jT = aE, qT = TT, ZT = RT, QT = oE, vT = CE, xT = fR, wT = AT;
87
87
  class W {
88
88
  constructor(E, R, A) {
89
89
  /**
@@ -113,17 +113,17 @@ class W {
113
113
  l(this, xT, !0);
114
114
  /** @internal */
115
115
  l(this, wT);
116
- this[DE] = this[oE] = E, this[aE] = R, this[PE] = A;
116
+ this[DE] = this[PE] = E, this[aE] = R, this[oE] = A;
117
117
  }
118
118
  }
119
119
  l(W, ER, "Table"), /** @internal */
120
120
  l(W, "Symbol", {
121
121
  Name: DE,
122
122
  Schema: aE,
123
- OriginalName: oE,
123
+ OriginalName: PE,
124
124
  Columns: TT,
125
125
  ExtraConfigColumns: RT,
126
- BaseName: PE,
126
+ BaseName: oE,
127
127
  IsAlias: CE,
128
128
  ExtraConfigBuilder: AT
129
129
  });
@@ -186,75 +186,75 @@ const v = class v {
186
186
  }), {
187
187
  casing: S,
188
188
  escapeName: e,
189
- escapeParam: O,
190
- prepareTyping: C,
189
+ escapeParam: N,
190
+ prepareTyping: s,
191
191
  inlineParams: _,
192
192
  paramStartIndex: I
193
193
  } = A;
194
- return hR(E.map((N) => {
195
- var s;
196
- if (F(N, h))
197
- return { sql: N.value.join(""), params: [] };
198
- if (F(N, LE))
199
- return { sql: e(N.value), params: [] };
200
- if (N === void 0)
194
+ return hR(E.map((O) => {
195
+ var C;
196
+ if (F(O, h))
197
+ return { sql: O.value.join(""), params: [] };
198
+ if (F(O, LE))
199
+ return { sql: e(O.value), params: [] };
200
+ if (O === void 0)
201
201
  return { sql: "", params: [] };
202
- if (Array.isArray(N)) {
202
+ if (Array.isArray(O)) {
203
203
  const t = [new h("(")];
204
- for (const [n, P] of N.entries())
205
- t.push(P), n < N.length - 1 && t.push(new h(", "));
204
+ for (const [i, o] of O.entries())
205
+ t.push(o), i < O.length - 1 && t.push(new h(", "));
206
206
  return t.push(new h(")")), this.buildQueryFromSourceParams(t, A);
207
207
  }
208
- if (F(N, v))
209
- return this.buildQueryFromSourceParams(N.queryChunks, {
208
+ if (F(O, v))
209
+ return this.buildQueryFromSourceParams(O.queryChunks, {
210
210
  ...A,
211
- inlineParams: _ || N.shouldInlineParams
211
+ inlineParams: _ || O.shouldInlineParams
212
212
  });
213
- if (F(N, W)) {
214
- const t = N[W.Symbol.Schema], n = N[W.Symbol.Name];
213
+ if (F(O, W)) {
214
+ const t = O[W.Symbol.Schema], i = O[W.Symbol.Name];
215
215
  return {
216
- sql: t === void 0 || N[CE] ? e(n) : e(t) + "." + e(n),
216
+ sql: t === void 0 || O[CE] ? e(i) : e(t) + "." + e(i),
217
217
  params: []
218
218
  };
219
219
  }
220
- if (F(N, EE)) {
221
- const t = S.getColumnCasing(N);
220
+ if (F(O, EE)) {
221
+ const t = S.getColumnCasing(O);
222
222
  if (R.invokeSource === "indexes")
223
223
  return { sql: e(t), params: [] };
224
- const n = N.table[W.Symbol.Schema];
224
+ const i = O.table[W.Symbol.Schema];
225
225
  return {
226
- sql: N.table[CE] || n === void 0 ? e(N.table[W.Symbol.Name]) + "." + e(t) : e(n) + "." + e(N.table[W.Symbol.Name]) + "." + e(t),
226
+ sql: O.table[CE] || i === void 0 ? e(O.table[W.Symbol.Name]) + "." + e(t) : e(i) + "." + e(O.table[W.Symbol.Name]) + "." + e(t),
227
227
  params: []
228
228
  };
229
229
  }
230
- if (F(N, ZE)) {
231
- const t = N[SE].schema, n = N[SE].name;
230
+ if (F(O, ZE)) {
231
+ const t = O[SE].schema, i = O[SE].name;
232
232
  return {
233
- sql: t === void 0 || N[SE].isAlias ? e(n) : e(t) + "." + e(n),
233
+ sql: t === void 0 || O[SE].isAlias ? e(i) : e(t) + "." + e(i),
234
234
  params: []
235
235
  };
236
236
  }
237
- if (F(N, IE)) {
238
- if (F(N.value, OE))
239
- return { sql: O(I.value++, N), params: [N], typings: ["none"] };
240
- const t = N.value === null ? null : N.encoder.mapToDriverValue(N.value);
237
+ if (F(O, IE)) {
238
+ if (F(O.value, OE))
239
+ return { sql: N(I.value++, O), params: [O], typings: ["none"] };
240
+ const t = O.value === null ? null : O.encoder.mapToDriverValue(O.value);
241
241
  if (F(t, v))
242
242
  return this.buildQueryFromSourceParams([t], A);
243
243
  if (_)
244
244
  return { sql: this.mapInlineParam(t, A), params: [] };
245
- let n = ["none"];
246
- return C && (n = [C(N.encoder)]), { sql: O(I.value++, t), params: [t], typings: n };
245
+ let i = ["none"];
246
+ return s && (i = [s(O.encoder)]), { sql: N(I.value++, t), params: [t], typings: i };
247
247
  }
248
- return F(N, OE) ? { sql: O(I.value++, N), params: [N], typings: ["none"] } : F(N, v.Aliased) && N.fieldAlias !== void 0 ? { sql: e(N.fieldAlias), params: [] } : F(N, QE) ? N._.isWith ? { sql: e(N._.alias), params: [] } : this.buildQueryFromSourceParams([
248
+ return F(O, OE) ? { sql: N(I.value++, O), params: [O], typings: ["none"] } : F(O, v.Aliased) && O.fieldAlias !== void 0 ? { sql: e(O.fieldAlias), params: [] } : F(O, QE) ? O._.isWith ? { sql: e(O._.alias), params: [] } : this.buildQueryFromSourceParams([
249
249
  new h("("),
250
- N._.sql,
250
+ O._.sql,
251
251
  new h(") "),
252
- new LE(N._.alias)
253
- ], A) : pR(N) ? N.schema ? { sql: e(N.schema) + "." + e(N.enumName), params: [] } : { sql: e(N.enumName), params: [] } : sR(N) ? (s = N.shouldOmitSQLParens) != null && s.call(N) ? this.buildQueryFromSourceParams([N.getSQL()], A) : this.buildQueryFromSourceParams([
252
+ new LE(O._.alias)
253
+ ], A) : pR(O) ? O.schema ? { sql: e(O.schema) + "." + e(O.enumName), params: [] } : { sql: e(O.enumName), params: [] } : sR(O) ? (C = O.shouldOmitSQLParens) != null && C.call(O) ? this.buildQueryFromSourceParams([O.getSQL()], A) : this.buildQueryFromSourceParams([
254
254
  new h("("),
255
- N.getSQL(),
255
+ O.getSQL(),
256
256
  new h(")")
257
- ], A) : _ ? { sql: this.mapInlineParam(N, A), params: [] } : { sql: O(I.value++, N), params: [N], typings: ["none"] };
257
+ ], A) : _ ? { sql: this.mapInlineParam(O, A), params: [] } : { sql: N(I.value++, O), params: [O], typings: ["none"] };
258
258
  }));
259
259
  }
260
260
  mapInlineParam(E, { escapeString: R }) {
@@ -355,33 +355,33 @@ function L(T, ...E) {
355
355
  }
356
356
  T.raw = A;
357
357
  function S(_, I) {
358
- const N = [];
359
- for (const [s, t] of _.entries())
360
- s > 0 && I !== void 0 && N.push(I), N.push(t);
361
- return new m(N);
358
+ const O = [];
359
+ for (const [C, t] of _.entries())
360
+ C > 0 && I !== void 0 && O.push(I), O.push(t);
361
+ return new m(O);
362
362
  }
363
363
  T.join = S;
364
364
  function e(_) {
365
365
  return new LE(_);
366
366
  }
367
367
  T.identifier = e;
368
- function O(_) {
368
+ function N(_) {
369
369
  return new OE(_);
370
370
  }
371
- T.placeholder = O;
372
- function C(_, I) {
371
+ T.placeholder = N;
372
+ function s(_, I) {
373
373
  return new IE(_, I);
374
374
  }
375
- T.param = C;
375
+ T.param = s;
376
376
  })(L || (L = {}));
377
377
  ((T) => {
378
378
  var R;
379
379
  R = X;
380
380
  const A = class A {
381
- constructor(e, O) {
381
+ constructor(e, N) {
382
382
  /** @internal */
383
383
  l(this, "isSelectionField", !1);
384
- this.sql = e, this.fieldAlias = O;
384
+ this.sql = e, this.fieldAlias = N;
385
385
  }
386
386
  getSQL() {
387
387
  return this.sql;
@@ -780,8 +780,8 @@ class vR extends jE {
780
780
  const e = L`datetime(${R}, 'unixepoch')`;
781
781
  return L`datetime(strftime('%Y-%m-%d %H:%M:00', ${e}))`;
782
782
  case "second":
783
- const O = L`datetime(${R}, 'unixepoch')`;
784
- return L`datetime(strftime('%Y-%m-%d %H:%M:%S', ${O}))`;
783
+ const N = L`datetime(${R}, 'unixepoch')`;
784
+ return L`datetime(strftime('%Y-%m-%d %H:%M:%S', ${N}))`;
785
785
  default:
786
786
  return L`datetime(${R}, 'unixepoch')`;
787
787
  }
@@ -909,8 +909,8 @@ class ZR extends kE {
909
909
  return Array.isArray(S) ? S.map((e) => this.convertNumericFields(e, R)) : S;
910
910
  } catch (S) {
911
911
  if (typeof E.getSQL == "function") {
912
- const e = E.getSQL(), O = await this.db.execute(e);
913
- return Array.isArray(O) ? O.map((C) => this.convertNumericFields(C, R)) : O;
912
+ const e = E.getSQL(), N = await this.db.execute(e);
913
+ return Array.isArray(N) ? N.map((s) => this.convertNumericFields(s, R)) : N;
914
914
  }
915
915
  throw S;
916
916
  }
@@ -961,27 +961,22 @@ class ZR extends kE {
961
961
  return "postgres";
962
962
  }
963
963
  }
964
+ function NT(T, E) {
965
+ return new ZR(T, E, "postgres");
966
+ }
964
967
  class qR extends kE {
965
968
  async execute(E, R) {
966
969
  if (E && typeof E == "object" && typeof E.execute == "function") {
967
- const A = await E.execute();
968
- return Array.isArray(A) ? A.map((S) => this.convertNumericFields(S, R)) : A;
969
- }
970
- try {
971
- if (this.db.all) {
972
- const A = this.db.all(E);
973
- return Array.isArray(A) ? A.map((S) => this.convertNumericFields(S, R)) : A;
974
- } else {
975
- if (this.db.run)
976
- return this.db.run(E);
977
- throw new Error("SQLite database instance must have an all() or run() method");
978
- }
979
- } catch (A) {
980
- throw new Error(`SQLite execution failed: ${A instanceof Error ? A.message : "Unknown error"}`);
970
+ const S = await E.execute();
971
+ return Array.isArray(S) ? S.map((e) => this.convertNumericFields(e, R)) : S;
981
972
  }
973
+ if (!this.db.execute)
974
+ throw new Error("MySQL database instance must have an execute method");
975
+ const A = await this.db.execute(E);
976
+ return Array.isArray(A) ? A.map((S) => this.convertNumericFields(S, R)) : A;
982
977
  }
983
978
  /**
984
- * Convert numeric string fields to numbers (only for measure fields)
979
+ * Convert numeric string fields to numbers (measure fields + numeric dimensions)
985
980
  */
986
981
  convertNumericFields(E, R) {
987
982
  if (!E || typeof E != "object") return E;
@@ -1004,22 +999,33 @@ class qR extends kE {
1004
999
  return E;
1005
1000
  }
1006
1001
  getEngineType() {
1007
- return "sqlite";
1002
+ return "mysql";
1008
1003
  }
1009
1004
  }
1010
- class jR extends kE {
1005
+ function jR(T, E) {
1006
+ return new qR(T, E, "mysql");
1007
+ }
1008
+ class kR extends kE {
1011
1009
  async execute(E, R) {
1012
1010
  if (E && typeof E == "object" && typeof E.execute == "function") {
1013
- const S = await E.execute();
1014
- return Array.isArray(S) ? S.map((e) => this.convertNumericFields(e, R)) : S;
1011
+ const A = await E.execute();
1012
+ return Array.isArray(A) ? A.map((S) => this.convertNumericFields(S, R)) : A;
1013
+ }
1014
+ try {
1015
+ if (this.db.all) {
1016
+ const A = this.db.all(E);
1017
+ return Array.isArray(A) ? A.map((S) => this.convertNumericFields(S, R)) : A;
1018
+ } else {
1019
+ if (this.db.run)
1020
+ return this.db.run(E);
1021
+ throw new Error("SQLite database instance must have an all() or run() method");
1022
+ }
1023
+ } catch (A) {
1024
+ throw new Error(`SQLite execution failed: ${A instanceof Error ? A.message : "Unknown error"}`);
1015
1025
  }
1016
- if (!this.db.execute)
1017
- throw new Error("MySQL database instance must have an execute method");
1018
- const A = await this.db.execute(E);
1019
- return Array.isArray(A) ? A.map((S) => this.convertNumericFields(S, R)) : A;
1020
1026
  }
1021
1027
  /**
1022
- * Convert numeric string fields to numbers (measure fields + numeric dimensions)
1028
+ * Convert numeric string fields to numbers (only for measure fields)
1023
1029
  */
1024
1030
  convertNumericFields(E, R) {
1025
1031
  if (!E || typeof E != "object") return E;
@@ -1042,17 +1048,11 @@ class jR extends kE {
1042
1048
  return E;
1043
1049
  }
1044
1050
  getEngineType() {
1045
- return "mysql";
1051
+ return "sqlite";
1046
1052
  }
1047
1053
  }
1048
- function NT(T, E) {
1049
- return new ZR(T, E, "postgres");
1050
- }
1051
1054
  function tT(T, E) {
1052
- return new qR(T, E, "sqlite");
1053
- }
1054
- function kR(T, E) {
1055
- return new jR(T, E, "mysql");
1055
+ return new kR(T, E, "sqlite");
1056
1056
  }
1057
1057
  function sT(T, E, R) {
1058
1058
  if (R)
@@ -1060,7 +1060,7 @@ function sT(T, E, R) {
1060
1060
  case "postgres":
1061
1061
  return NT(T, E);
1062
1062
  case "mysql":
1063
- return kR(T, E);
1063
+ return jR(T, E);
1064
1064
  case "sqlite":
1065
1065
  return tT(T, E);
1066
1066
  }
@@ -1100,31 +1100,31 @@ class EA {
1100
1100
  buildSelections(E, R, A) {
1101
1101
  const S = {}, e = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1102
1102
  if (R.dimensions)
1103
- for (const O of R.dimensions) {
1104
- const [C, _] = O.split("."), I = e.get(C);
1103
+ for (const N of R.dimensions) {
1104
+ const [s, _] = N.split("."), I = e.get(s);
1105
1105
  if (I && I.dimensions && I.dimensions[_]) {
1106
- const N = I.dimensions[_], s = x(N.sql, A);
1107
- S[O] = L`${s}`.as(O);
1106
+ const O = I.dimensions[_], C = x(O.sql, A);
1107
+ S[N] = L`${C}`.as(N);
1108
1108
  }
1109
1109
  }
1110
1110
  if (R.measures)
1111
- for (const O of R.measures) {
1112
- const [C, _] = O.split("."), I = e.get(C);
1111
+ for (const N of R.measures) {
1112
+ const [s, _] = N.split("."), I = e.get(s);
1113
1113
  if (I && I.measures && I.measures[_]) {
1114
- const N = I.measures[_], s = this.buildMeasureExpression(N, A);
1115
- S[O] = L`${s}`.as(O);
1114
+ const O = I.measures[_], C = this.buildMeasureExpression(O, A);
1115
+ S[N] = L`${C}`.as(N);
1116
1116
  }
1117
1117
  }
1118
1118
  if (R.timeDimensions)
1119
- for (const O of R.timeDimensions) {
1120
- const [C, _] = O.dimension.split("."), I = e.get(C);
1119
+ for (const N of R.timeDimensions) {
1120
+ const [s, _] = N.dimension.split("."), I = e.get(s);
1121
1121
  if (I && I.dimensions && I.dimensions[_]) {
1122
- const N = I.dimensions[_], s = this.buildTimeDimensionExpression(
1123
- N.sql,
1124
- O.granularity,
1122
+ const O = I.dimensions[_], C = this.buildTimeDimensionExpression(
1123
+ O.sql,
1124
+ N.granularity,
1125
1125
  A
1126
1126
  );
1127
- S[O.dimension] = L`${s}`.as(O.dimension);
1127
+ S[N.dimension] = L`${C}`.as(N.dimension);
1128
1128
  }
1129
1129
  }
1130
1130
  return Object.keys(S).length === 0 && (S.count = ME()), S;
@@ -1134,24 +1134,24 @@ class EA {
1134
1134
  */
1135
1135
  buildHavingMeasureExpression(E, R, A, S, e) {
1136
1136
  if (e && e.preAggregationCTEs) {
1137
- const O = e.preAggregationCTEs.find((C) => C.cube.name === E);
1138
- if (O && O.measures.includes(`${E}.${R}`)) {
1139
- const C = L`${L.identifier(O.cteAlias)}.${L.identifier(R)}`;
1137
+ const N = e.preAggregationCTEs.find((s) => s.cube.name === E);
1138
+ if (N && N.measures.includes(`${E}.${R}`)) {
1139
+ const s = L`${L.identifier(N.cteAlias)}.${L.identifier(R)}`;
1140
1140
  switch (A.type) {
1141
1141
  case "count":
1142
1142
  case "countDistinct":
1143
1143
  case "sum":
1144
- return Q(C);
1144
+ return Q(s);
1145
1145
  case "avg":
1146
- return this.databaseAdapter.buildAvg(C);
1146
+ return this.databaseAdapter.buildAvg(s);
1147
1147
  case "min":
1148
- return xE(C);
1148
+ return xE(s);
1149
1149
  case "max":
1150
- return wE(C);
1150
+ return wE(s);
1151
1151
  case "number":
1152
- return Q(C);
1152
+ return Q(s);
1153
1153
  default:
1154
- return Q(C);
1154
+ return Q(s);
1155
1155
  }
1156
1156
  }
1157
1157
  }
@@ -1202,20 +1202,20 @@ class EA {
1202
1202
  * Works for both single and multi-cube queries
1203
1203
  */
1204
1204
  buildWhereConditions(E, R, A, S) {
1205
- const e = [], O = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1205
+ const e = [], N = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1206
1206
  if (R.filters && R.filters.length > 0)
1207
- for (const C of R.filters) {
1208
- const _ = this.processFilter(C, O, A, "where", S);
1207
+ for (const s of R.filters) {
1208
+ const _ = this.processFilter(s, N, A, "where", S);
1209
1209
  _ && e.push(_);
1210
1210
  }
1211
1211
  if (R.timeDimensions)
1212
- for (const C of R.timeDimensions) {
1213
- const [_, I] = C.dimension.split("."), N = O.get(_);
1214
- if (N && N.dimensions[I] && C.dateRange) {
1212
+ for (const s of R.timeDimensions) {
1213
+ const [_, I] = s.dimension.split("."), O = N.get(_);
1214
+ if (O && O.dimensions[I] && s.dateRange) {
1215
1215
  if (S != null && S.preAggregationCTEs && S.preAggregationCTEs.some((M) => M.cube.name === _))
1216
1216
  continue;
1217
- const s = N.dimensions[I], t = x(s.sql, A), n = this.buildDateRangeCondition(t, C.dateRange);
1218
- n && e.push(n);
1217
+ const C = O.dimensions[I], t = x(C.sql, A), i = this.buildDateRangeCondition(t, s.dateRange);
1218
+ i && e.push(i);
1219
1219
  }
1220
1220
  }
1221
1221
  return e;
@@ -1225,10 +1225,10 @@ class EA {
1225
1225
  * Works for both single and multi-cube queries
1226
1226
  */
1227
1227
  buildHavingConditions(E, R, A, S) {
1228
- const e = [], O = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1228
+ const e = [], N = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1229
1229
  if (R.filters && R.filters.length > 0)
1230
- for (const C of R.filters) {
1231
- const _ = this.processFilter(C, O, A, "having", S);
1230
+ for (const s of R.filters) {
1231
+ const _ = this.processFilter(s, N, A, "having", S);
1232
1232
  _ && e.push(_);
1233
1233
  }
1234
1234
  return e;
@@ -1239,31 +1239,31 @@ class EA {
1239
1239
  */
1240
1240
  processFilter(E, R, A, S, e) {
1241
1241
  if ("and" in E || "or" in E) {
1242
- const n = E;
1243
- if (n.and) {
1244
- const P = n.and.map((M) => this.processFilter(M, R, A, S, e)).filter((M) => M !== null);
1245
- return P.length > 0 ? b(...P) : null;
1242
+ const i = E;
1243
+ if (i.and) {
1244
+ const o = i.and.map((M) => this.processFilter(M, R, A, S, e)).filter((M) => M !== null);
1245
+ return o.length > 0 ? b(...o) : null;
1246
1246
  }
1247
- if (n.or) {
1248
- const P = n.or.map((M) => this.processFilter(M, R, A, S, e)).filter((M) => M !== null);
1249
- return P.length > 0 ? bR(...P) : null;
1247
+ if (i.or) {
1248
+ const o = i.or.map((M) => this.processFilter(M, R, A, S, e)).filter((M) => M !== null);
1249
+ return o.length > 0 ? bR(...o) : null;
1250
1250
  }
1251
1251
  }
1252
- const O = E, [C, _] = O.member.split("."), I = R.get(C);
1252
+ const N = E, [s, _] = N.member.split("."), I = R.get(s);
1253
1253
  if (!I) return null;
1254
- const N = I.dimensions[_], s = I.measures[_], t = N || s;
1254
+ const O = I.dimensions[_], C = I.measures[_], t = O || C;
1255
1255
  if (!t) return null;
1256
- if (S === "where" && N) {
1257
- if (e != null && e.preAggregationCTEs && e.preAggregationCTEs.some((M) => M.cube.name === C))
1256
+ if (S === "where" && O) {
1257
+ if (e != null && e.preAggregationCTEs && e.preAggregationCTEs.some((M) => M.cube.name === s))
1258
1258
  return null;
1259
- const n = x(N.sql, A);
1260
- return this.buildFilterCondition(n, O.operator, O.values, t);
1259
+ const i = x(O.sql, A);
1260
+ return this.buildFilterCondition(i, N.operator, N.values, t);
1261
1261
  } else {
1262
- if (S === "where" && s)
1262
+ if (S === "where" && C)
1263
1263
  return null;
1264
- if (S === "having" && s) {
1265
- const n = this.buildHavingMeasureExpression(C, _, s, A, e);
1266
- return this.buildFilterCondition(n, O.operator, O.values, t);
1264
+ if (S === "having" && C) {
1265
+ const i = this.buildHavingMeasureExpression(s, _, C, A, e);
1266
+ return this.buildFilterCondition(i, N.operator, N.values, t);
1267
1267
  }
1268
1268
  }
1269
1269
  return null;
@@ -1274,62 +1274,62 @@ class EA {
1274
1274
  buildFilterCondition(E, R, A, S) {
1275
1275
  if (!A || A.length === 0)
1276
1276
  return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1277
- const e = A.filter((C) => !(C == null || C === "" || typeof C == "string" && C.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
1277
+ const e = A.filter((s) => !(s == null || s === "" || typeof s == "string" && s.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
1278
1278
  if (e.length === 0 && !["set", "notSet"].includes(R))
1279
1279
  return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1280
- const O = e[0];
1280
+ const N = e[0];
1281
1281
  switch (R) {
1282
1282
  case "equals":
1283
1283
  if (e.length > 1) {
1284
1284
  if ((S == null ? void 0 : S.type) === "time") {
1285
- const C = e.map((_) => this.normalizeDate(_) || _);
1286
- return IT(E, C);
1285
+ const s = e.map((_) => this.normalizeDate(_) || _);
1286
+ return IT(E, s);
1287
1287
  }
1288
1288
  return IT(E, e);
1289
1289
  } else if (e.length === 1) {
1290
- const C = (S == null ? void 0 : S.type) === "time" && this.normalizeDate(O) || O;
1291
- return qE(E, C);
1290
+ const s = (S == null ? void 0 : S.type) === "time" && this.normalizeDate(N) || N;
1291
+ return qE(E, s);
1292
1292
  }
1293
1293
  return this.databaseAdapter.buildBooleanLiteral(!1);
1294
1294
  case "notEquals":
1295
- return e.length > 1 ? yR(E, e) : e.length === 1 ? XR(E, O) : null;
1295
+ return e.length > 1 ? yR(E, e) : e.length === 1 ? XR(E, N) : null;
1296
1296
  case "contains":
1297
- return this.databaseAdapter.buildStringCondition(E, "contains", O);
1297
+ return this.databaseAdapter.buildStringCondition(E, "contains", N);
1298
1298
  case "notContains":
1299
- return this.databaseAdapter.buildStringCondition(E, "notContains", O);
1299
+ return this.databaseAdapter.buildStringCondition(E, "notContains", N);
1300
1300
  case "startsWith":
1301
- return this.databaseAdapter.buildStringCondition(E, "startsWith", O);
1301
+ return this.databaseAdapter.buildStringCondition(E, "startsWith", N);
1302
1302
  case "endsWith":
1303
- return this.databaseAdapter.buildStringCondition(E, "endsWith", O);
1303
+ return this.databaseAdapter.buildStringCondition(E, "endsWith", N);
1304
1304
  case "gt":
1305
- return ST(E, O);
1305
+ return ST(E, N);
1306
1306
  case "gte":
1307
- return RE(E, O);
1307
+ return RE(E, N);
1308
1308
  case "lt":
1309
- return eT(E, O);
1309
+ return eT(E, N);
1310
1310
  case "lte":
1311
- return AE(E, O);
1311
+ return AE(E, N);
1312
1312
  case "set":
1313
1313
  return $R(E);
1314
1314
  case "notSet":
1315
1315
  return KR(E);
1316
1316
  case "inDateRange":
1317
1317
  if (e.length >= 2) {
1318
- const C = this.normalizeDate(e[0]), _ = this.normalizeDate(e[1]);
1319
- if (C && _)
1318
+ const s = this.normalizeDate(e[0]), _ = this.normalizeDate(e[1]);
1319
+ if (s && _)
1320
1320
  return b(
1321
- RE(E, C),
1321
+ RE(E, s),
1322
1322
  AE(E, _)
1323
1323
  );
1324
1324
  }
1325
1325
  return null;
1326
1326
  case "beforeDate": {
1327
- const C = this.normalizeDate(O);
1328
- return C ? eT(E, C) : null;
1327
+ const s = this.normalizeDate(N);
1328
+ return s ? eT(E, s) : null;
1329
1329
  }
1330
1330
  case "afterDate": {
1331
- const C = this.normalizeDate(O);
1332
- return C ? ST(E, C) : null;
1331
+ const s = this.normalizeDate(N);
1332
+ return s ? ST(E, s) : null;
1333
1333
  }
1334
1334
  default:
1335
1335
  return null;
@@ -1358,10 +1358,10 @@ class EA {
1358
1358
  if (!S) return null;
1359
1359
  const e = new Date(S);
1360
1360
  e.setUTCHours(0, 0, 0, 0);
1361
- const O = new Date(S);
1362
- return O.setUTCHours(23, 59, 59, 999), b(
1361
+ const N = new Date(S);
1362
+ return N.setUTCHours(23, 59, 59, 999), b(
1363
1363
  RE(E, e),
1364
- AE(E, O)
1364
+ AE(E, N)
1365
1365
  );
1366
1366
  }
1367
1367
  return null;
@@ -1371,75 +1371,75 @@ class EA {
1371
1371
  * Handles all 14 DATE_RANGE_OPTIONS from the client
1372
1372
  */
1373
1373
  parseRelativeDateRange(E) {
1374
- const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), S = R.getUTCFullYear(), e = R.getUTCMonth(), O = R.getUTCDate(), C = R.getUTCDay();
1374
+ const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), S = R.getUTCFullYear(), e = R.getUTCMonth(), N = R.getUTCDate(), s = R.getUTCDay();
1375
1375
  if (A === "today") {
1376
- const s = new Date(R);
1377
- s.setUTCHours(0, 0, 0, 0);
1376
+ const C = new Date(R);
1377
+ C.setUTCHours(0, 0, 0, 0);
1378
1378
  const t = new Date(R);
1379
- return t.setUTCHours(23, 59, 59, 999), { start: s, end: t };
1379
+ return t.setUTCHours(23, 59, 59, 999), { start: C, end: t };
1380
1380
  }
1381
1381
  if (A === "yesterday") {
1382
- const s = new Date(R);
1383
- s.setUTCDate(O - 1), s.setUTCHours(0, 0, 0, 0);
1382
+ const C = new Date(R);
1383
+ C.setUTCDate(N - 1), C.setUTCHours(0, 0, 0, 0);
1384
1384
  const t = new Date(R);
1385
- return t.setUTCDate(O - 1), t.setUTCHours(23, 59, 59, 999), { start: s, end: t };
1385
+ return t.setUTCDate(N - 1), t.setUTCHours(23, 59, 59, 999), { start: C, end: t };
1386
1386
  }
1387
1387
  if (A === "this week") {
1388
- const s = C === 0 ? -6 : 1 - C, t = new Date(R);
1389
- t.setUTCDate(O + s), t.setUTCHours(0, 0, 0, 0);
1390
- const n = new Date(t);
1391
- return n.setUTCDate(t.getUTCDate() + 6), n.setUTCHours(23, 59, 59, 999), { start: t, end: n };
1388
+ const C = s === 0 ? -6 : 1 - s, t = new Date(R);
1389
+ t.setUTCDate(N + C), t.setUTCHours(0, 0, 0, 0);
1390
+ const i = new Date(t);
1391
+ return i.setUTCDate(t.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: t, end: i };
1392
1392
  }
1393
1393
  if (A === "this month") {
1394
- const s = new Date(Date.UTC(S, e, 1, 0, 0, 0, 0)), t = new Date(Date.UTC(S, e + 1, 0, 23, 59, 59, 999));
1395
- return { start: s, end: t };
1394
+ const C = new Date(Date.UTC(S, e, 1, 0, 0, 0, 0)), t = new Date(Date.UTC(S, e + 1, 0, 23, 59, 59, 999));
1395
+ return { start: C, end: t };
1396
1396
  }
1397
1397
  if (A === "this quarter") {
1398
- const s = Math.floor(e / 3), t = new Date(Date.UTC(S, s * 3, 1, 0, 0, 0, 0)), n = new Date(Date.UTC(S, s * 3 + 3, 0, 23, 59, 59, 999));
1399
- return { start: t, end: n };
1398
+ const C = Math.floor(e / 3), t = new Date(Date.UTC(S, C * 3, 1, 0, 0, 0, 0)), i = new Date(Date.UTC(S, C * 3 + 3, 0, 23, 59, 59, 999));
1399
+ return { start: t, end: i };
1400
1400
  }
1401
1401
  if (A === "this year") {
1402
- const s = new Date(Date.UTC(S, 0, 1, 0, 0, 0, 0)), t = new Date(Date.UTC(S, 11, 31, 23, 59, 59, 999));
1403
- return { start: s, end: t };
1402
+ const C = new Date(Date.UTC(S, 0, 1, 0, 0, 0, 0)), t = new Date(Date.UTC(S, 11, 31, 23, 59, 59, 999));
1403
+ return { start: C, end: t };
1404
1404
  }
1405
1405
  const _ = A.match(/^last\s+(\d+)\s+days?$/);
1406
1406
  if (_) {
1407
- const s = parseInt(_[1], 10), t = new Date(R);
1408
- t.setUTCDate(O - s + 1), t.setUTCHours(0, 0, 0, 0);
1409
- const n = new Date(R);
1410
- return n.setUTCHours(23, 59, 59, 999), { start: t, end: n };
1407
+ const C = parseInt(_[1], 10), t = new Date(R);
1408
+ t.setUTCDate(N - C + 1), t.setUTCHours(0, 0, 0, 0);
1409
+ const i = new Date(R);
1410
+ return i.setUTCHours(23, 59, 59, 999), { start: t, end: i };
1411
1411
  }
1412
1412
  if (A === "last week") {
1413
- const s = C === 0 ? -13 : -6 - C, t = new Date(R);
1414
- t.setUTCDate(O + s), t.setUTCHours(0, 0, 0, 0);
1415
- const n = new Date(t);
1416
- return n.setUTCDate(t.getUTCDate() + 6), n.setUTCHours(23, 59, 59, 999), { start: t, end: n };
1413
+ const C = s === 0 ? -13 : -6 - s, t = new Date(R);
1414
+ t.setUTCDate(N + C), t.setUTCHours(0, 0, 0, 0);
1415
+ const i = new Date(t);
1416
+ return i.setUTCDate(t.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: t, end: i };
1417
1417
  }
1418
1418
  if (A === "last month") {
1419
- const s = new Date(Date.UTC(S, e - 1, 1, 0, 0, 0, 0)), t = new Date(Date.UTC(S, e, 0, 23, 59, 59, 999));
1420
- return { start: s, end: t };
1419
+ const C = new Date(Date.UTC(S, e - 1, 1, 0, 0, 0, 0)), t = new Date(Date.UTC(S, e, 0, 23, 59, 59, 999));
1420
+ return { start: C, end: t };
1421
1421
  }
1422
1422
  if (A === "last quarter") {
1423
- const s = Math.floor(e / 3), t = s === 0 ? 3 : s - 1, n = s === 0 ? S - 1 : S, P = new Date(Date.UTC(n, t * 3, 1, 0, 0, 0, 0)), M = new Date(Date.UTC(n, t * 3 + 3, 0, 23, 59, 59, 999));
1424
- return { start: P, end: M };
1423
+ const C = Math.floor(e / 3), t = C === 0 ? 3 : C - 1, i = C === 0 ? S - 1 : S, o = new Date(Date.UTC(i, t * 3, 1, 0, 0, 0, 0)), M = new Date(Date.UTC(i, t * 3 + 3, 0, 23, 59, 59, 999));
1424
+ return { start: o, end: M };
1425
1425
  }
1426
1426
  if (A === "last year") {
1427
- const s = new Date(Date.UTC(S - 1, 0, 1, 0, 0, 0, 0)), t = new Date(Date.UTC(S - 1, 11, 31, 23, 59, 59, 999));
1428
- return { start: s, end: t };
1427
+ const C = new Date(Date.UTC(S - 1, 0, 1, 0, 0, 0, 0)), t = new Date(Date.UTC(S - 1, 11, 31, 23, 59, 59, 999));
1428
+ return { start: C, end: t };
1429
1429
  }
1430
1430
  if (A === "last 12 months") {
1431
- const s = new Date(Date.UTC(S, e - 11, 1, 0, 0, 0, 0)), t = new Date(R);
1432
- return t.setUTCHours(23, 59, 59, 999), { start: s, end: t };
1431
+ const C = new Date(Date.UTC(S, e - 11, 1, 0, 0, 0, 0)), t = new Date(R);
1432
+ return t.setUTCHours(23, 59, 59, 999), { start: C, end: t };
1433
1433
  }
1434
1434
  const I = A.match(/^last\s+(\d+)\s+months?$/);
1435
1435
  if (I) {
1436
- const s = parseInt(I[1], 10), t = new Date(Date.UTC(S, e - s + 1, 1, 0, 0, 0, 0)), n = new Date(R);
1437
- return n.setUTCHours(23, 59, 59, 999), { start: t, end: n };
1436
+ const C = parseInt(I[1], 10), t = new Date(Date.UTC(S, e - C + 1, 1, 0, 0, 0, 0)), i = new Date(R);
1437
+ return i.setUTCHours(23, 59, 59, 999), { start: t, end: i };
1438
1438
  }
1439
- const N = A.match(/^last\s+(\d+)\s+years?$/);
1440
- if (N) {
1441
- const s = parseInt(N[1], 10), t = new Date(Date.UTC(S - s, 0, 1, 0, 0, 0, 0)), n = new Date(R);
1442
- return n.setUTCHours(23, 59, 59, 999), { start: t, end: n };
1439
+ const O = A.match(/^last\s+(\d+)\s+years?$/);
1440
+ if (O) {
1441
+ const C = parseInt(O[1], 10), t = new Date(Date.UTC(S - C, 0, 1, 0, 0, 0, 0)), i = new Date(R);
1442
+ return i.setUTCHours(23, 59, 59, 999), { start: t, end: i };
1443
1443
  }
1444
1444
  return null;
1445
1445
  }
@@ -1472,34 +1472,34 @@ class EA {
1472
1472
  const e = [];
1473
1473
  if (!(R.measures && R.measures.length > 0))
1474
1474
  return [];
1475
- const C = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1475
+ const s = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1476
1476
  if (R.dimensions)
1477
- for (const N of R.dimensions) {
1478
- const [s, t] = N.split("."), n = C.get(s);
1479
- if (n && n.dimensions && n.dimensions[t])
1480
- if ((_ = S == null ? void 0 : S.preAggregationCTEs) == null ? void 0 : _.some((M) => M.cube.name === s)) {
1481
- const M = S.preAggregationCTEs.find((G) => G.cube.name === s), o = M.joinKeys.find((G) => G.targetColumn === t);
1482
- if (o && o.sourceColumnObj)
1483
- e.push(o.sourceColumnObj);
1477
+ for (const O of R.dimensions) {
1478
+ const [C, t] = O.split("."), i = s.get(C);
1479
+ if (i && i.dimensions && i.dimensions[t])
1480
+ if ((_ = S == null ? void 0 : S.preAggregationCTEs) == null ? void 0 : _.some((M) => M.cube.name === C)) {
1481
+ const M = S.preAggregationCTEs.find((G) => G.cube.name === C), P = M.joinKeys.find((G) => G.targetColumn === t);
1482
+ if (P && P.sourceColumnObj)
1483
+ e.push(P.sourceColumnObj);
1484
1484
  else {
1485
1485
  const G = L`${L.identifier(M.cteAlias)}.${L.identifier(t)}`;
1486
1486
  e.push(G);
1487
1487
  }
1488
1488
  } else {
1489
- const M = n.dimensions[t], o = x(M.sql, A);
1490
- e.push(o);
1489
+ const M = i.dimensions[t], P = x(M.sql, A);
1490
+ e.push(P);
1491
1491
  }
1492
1492
  }
1493
1493
  if (R.timeDimensions)
1494
- for (const N of R.timeDimensions) {
1495
- const [s, t] = N.dimension.split("."), n = C.get(s);
1496
- if (n && n.dimensions && n.dimensions[t])
1497
- if ((I = S == null ? void 0 : S.preAggregationCTEs) == null ? void 0 : I.some((M) => M.cube.name === s)) {
1498
- const M = S.preAggregationCTEs.find((G) => G.cube.name === s), o = M.joinKeys.find((G) => G.targetColumn === t);
1499
- if (o && o.sourceColumnObj) {
1494
+ for (const O of R.timeDimensions) {
1495
+ const [C, t] = O.dimension.split("."), i = s.get(C);
1496
+ if (i && i.dimensions && i.dimensions[t])
1497
+ if ((I = S == null ? void 0 : S.preAggregationCTEs) == null ? void 0 : I.some((M) => M.cube.name === C)) {
1498
+ const M = S.preAggregationCTEs.find((G) => G.cube.name === C), P = M.joinKeys.find((G) => G.targetColumn === t);
1499
+ if (P && P.sourceColumnObj) {
1500
1500
  const G = this.buildTimeDimensionExpression(
1501
- o.sourceColumnObj,
1502
- N.granularity,
1501
+ P.sourceColumnObj,
1502
+ O.granularity,
1503
1503
  A
1504
1504
  );
1505
1505
  e.push(G);
@@ -1508,12 +1508,12 @@ class EA {
1508
1508
  e.push(G);
1509
1509
  }
1510
1510
  } else {
1511
- const M = n.dimensions[t], o = this.buildTimeDimensionExpression(
1511
+ const M = i.dimensions[t], P = this.buildTimeDimensionExpression(
1512
1512
  M.sql,
1513
- N.granularity,
1513
+ O.granularity,
1514
1514
  A
1515
1515
  );
1516
- e.push(o);
1516
+ e.push(P);
1517
1517
  }
1518
1518
  }
1519
1519
  return e;
@@ -1526,21 +1526,21 @@ class EA {
1526
1526
  const A = [], S = R || [
1527
1527
  ...E.measures || [],
1528
1528
  ...E.dimensions || [],
1529
- ...((e = E.timeDimensions) == null ? void 0 : e.map((O) => O.dimension)) || []
1529
+ ...((e = E.timeDimensions) == null ? void 0 : e.map((N) => N.dimension)) || []
1530
1530
  ];
1531
1531
  if (E.order && Object.keys(E.order).length > 0)
1532
- for (const [O, C] of Object.entries(E.order)) {
1533
- if (!S.includes(O))
1534
- throw new Error(`Cannot order by '${O}': field is not selected in the query`);
1535
- const _ = C === "desc" ? gR(L.identifier(O)) : OT(L.identifier(O));
1532
+ for (const [N, s] of Object.entries(E.order)) {
1533
+ if (!S.includes(N))
1534
+ throw new Error(`Cannot order by '${N}': field is not selected in the query`);
1535
+ const _ = s === "desc" ? gR(L.identifier(N)) : OT(L.identifier(N));
1536
1536
  A.push(_);
1537
1537
  }
1538
1538
  if (E.timeDimensions && E.timeDimensions.length > 0) {
1539
- const O = new Set(Object.keys(E.order || {})), C = [...E.timeDimensions].sort(
1539
+ const N = new Set(Object.keys(E.order || {})), s = [...E.timeDimensions].sort(
1540
1540
  (_, I) => _.dimension.localeCompare(I.dimension)
1541
1541
  );
1542
- for (const _ of C)
1543
- O.has(_.dimension) || A.push(OT(L.identifier(_.dimension)));
1542
+ for (const _ of s)
1543
+ N.has(_.dimension) || A.push(OT(L.identifier(_.dimension)));
1544
1544
  }
1545
1545
  return A;
1546
1546
  }
@@ -1552,9 +1552,9 @@ class EA {
1552
1552
  const A = [], S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1553
1553
  if (R.measures && A.push(...R.measures), R.dimensions)
1554
1554
  for (const e of R.dimensions) {
1555
- const [O, C] = e.split("."), _ = S.get(O);
1555
+ const [N, s] = e.split("."), _ = S.get(N);
1556
1556
  if (_) {
1557
- const I = _.dimensions[C];
1557
+ const I = _.dimensions[s];
1558
1558
  I && I.type === "number" && A.push(e);
1559
1559
  }
1560
1560
  }
@@ -1655,12 +1655,12 @@ class TA {
1655
1655
  const S = this.analyzeCubeUsage(R), e = Array.from(S);
1656
1656
  if (e.length === 0)
1657
1657
  throw new Error("No cubes found in query");
1658
- const O = this.choosePrimaryCube(e, R, E), C = E.get(O);
1659
- if (!C)
1660
- throw new Error(`Primary cube '${O}' not found`);
1658
+ const N = this.choosePrimaryCube(e, R, E), s = E.get(N);
1659
+ if (!s)
1660
+ throw new Error(`Primary cube '${N}' not found`);
1661
1661
  if (e.length === 1)
1662
1662
  return {
1663
- primaryCube: C,
1663
+ primaryCube: s,
1664
1664
  joinCubes: [],
1665
1665
  // Empty for single cube
1666
1666
  selections: {},
@@ -1670,9 +1670,9 @@ class TA {
1670
1670
  groupByFields: []
1671
1671
  // Will be built by QueryBuilder
1672
1672
  };
1673
- const _ = this.buildJoinPlan(E, C, e, A), I = this.planPreAggregationCTEs(E, C, _, R);
1673
+ const _ = this.buildJoinPlan(E, s, e), I = this.planPreAggregationCTEs(E, s, _, R);
1674
1674
  return {
1675
- primaryCube: C,
1675
+ primaryCube: s,
1676
1676
  joinCubes: _,
1677
1677
  selections: {},
1678
1678
  // Will be built by QueryBuilder
@@ -1689,12 +1689,12 @@ class TA {
1689
1689
  */
1690
1690
  choosePrimaryCube(E, R, A) {
1691
1691
  if (R.dimensions && R.dimensions.length > 0 && A) {
1692
- const S = R.dimensions.map((O) => O.split(".")[0]), e = /* @__PURE__ */ new Map();
1693
- for (const O of S)
1694
- e.set(O, (e.get(O) || 0) + 1);
1692
+ const S = R.dimensions.map((N) => N.split(".")[0]), e = /* @__PURE__ */ new Map();
1693
+ for (const N of S)
1694
+ e.set(N, (e.get(N) || 0) + 1);
1695
1695
  if (e.size > 0) {
1696
- const O = Math.max(...e.values()), C = [...e.entries()].filter(([_, I]) => I === O).map(([_, I]) => _).sort();
1697
- for (const _ of C)
1696
+ const N = Math.max(...e.values()), s = [...e.entries()].filter(([, _]) => _ === N).map(([_]) => _).sort();
1697
+ for (const _ of s)
1698
1698
  if (this.canReachAllCubes(_, E, A))
1699
1699
  return _;
1700
1700
  }
@@ -1703,12 +1703,12 @@ class TA {
1703
1703
  const S = /* @__PURE__ */ new Map();
1704
1704
  for (const e of E)
1705
1705
  if (this.canReachAllCubes(e, E, A)) {
1706
- const O = A.get(e), C = O != null && O.joins ? Object.keys(O.joins).length : 0;
1707
- S.set(e, C);
1706
+ const N = A.get(e), s = N != null && N.joins ? Object.keys(N.joins).length : 0;
1707
+ S.set(e, s);
1708
1708
  }
1709
1709
  if (S.size > 0) {
1710
1710
  const e = Math.max(...S.values());
1711
- return [...S.entries()].filter(([C, _]) => _ === e).map(([C, _]) => C).sort()[0];
1711
+ return [...S.entries()].filter(([, s]) => s === e).map(([s]) => s).sort()[0];
1712
1712
  }
1713
1713
  }
1714
1714
  return [...E].sort()[0];
@@ -1719,8 +1719,8 @@ class TA {
1719
1719
  canReachAllCubes(E, R, A) {
1720
1720
  const S = R.filter((e) => e !== E);
1721
1721
  for (const e of S) {
1722
- const O = this.findJoinPath(A, E, e, /* @__PURE__ */ new Set());
1723
- if (!O || O.length === 0)
1722
+ const N = this.findJoinPath(A, E, e, /* @__PURE__ */ new Set());
1723
+ if (!N || N.length === 0)
1724
1724
  return !1;
1725
1725
  }
1726
1726
  return !0;
@@ -1729,48 +1729,47 @@ class TA {
1729
1729
  * Build join plan for multi-cube query
1730
1730
  * Supports both direct joins and transitive joins through intermediate cubes
1731
1731
  */
1732
- buildJoinPlan(E, R, A, S) {
1733
- const e = [], O = /* @__PURE__ */ new Set([R.name]), C = A.filter((_) => _ !== R.name);
1734
- for (const _ of C) {
1735
- if (O.has(_))
1732
+ buildJoinPlan(E, R, A) {
1733
+ const S = [], e = /* @__PURE__ */ new Set([R.name]), N = A.filter((s) => s !== R.name);
1734
+ for (const s of N) {
1735
+ if (e.has(s))
1736
1736
  continue;
1737
- const I = this.findJoinPath(E, R.name, _, O);
1738
- if (!I || I.length === 0)
1739
- throw new Error(`No join path found from '${R.name}' to '${_}'`);
1740
- for (const { fromCube: N, toCube: s, joinDef: t } of I) {
1741
- if (O.has(s))
1737
+ const _ = this.findJoinPath(E, R.name, s, e);
1738
+ if (!_ || _.length === 0)
1739
+ throw new Error(`No join path found from '${R.name}' to '${s}'`);
1740
+ for (const { toCube: I, joinDef: O } of _) {
1741
+ if (e.has(I))
1742
1742
  continue;
1743
- const n = E.get(s);
1744
- if (!n)
1745
- throw new Error(`Cube '${s}' not found`);
1746
- const P = this.buildJoinCondition(
1747
- t,
1743
+ const C = E.get(I);
1744
+ if (!C)
1745
+ throw new Error(`Cube '${I}' not found`);
1746
+ const t = this.buildJoinCondition(
1747
+ O,
1748
1748
  null,
1749
1749
  // No source alias needed - use the actual column
1750
- null,
1750
+ null
1751
1751
  // No target alias needed - use the actual column
1752
- S
1753
- ), M = zR(t.relationship, t.sqlJoinType);
1754
- e.push({
1755
- cube: n,
1756
- alias: `${s.toLowerCase()}_cube`,
1757
- joinType: M,
1758
- joinCondition: P
1759
- }), O.add(s);
1752
+ ), i = zR(O.relationship, O.sqlJoinType);
1753
+ S.push({
1754
+ cube: C,
1755
+ alias: `${I.toLowerCase()}_cube`,
1756
+ joinType: i,
1757
+ joinCondition: t
1758
+ }), e.add(I);
1760
1759
  }
1761
1760
  }
1762
- return e;
1761
+ return S;
1763
1762
  }
1764
1763
  /**
1765
1764
  * Build join condition from new array-based join definition
1766
1765
  */
1767
- buildJoinCondition(E, R, A, S) {
1768
- const e = [];
1769
- for (const O of E.on) {
1770
- const C = R ? L`${L.identifier(R)}.${L.identifier(O.source.name)}` : O.source, _ = A ? L`${L.identifier(A)}.${L.identifier(O.target.name)}` : O.target, I = O.as || qE;
1771
- e.push(I(C, _));
1766
+ buildJoinCondition(E, R, A) {
1767
+ const S = [];
1768
+ for (const e of E.on) {
1769
+ const N = R ? L`${L.identifier(R)}.${L.identifier(e.source.name)}` : e.source, s = A ? L`${L.identifier(A)}.${L.identifier(e.target.name)}` : e.target, _ = e.as || qE;
1770
+ S.push(_(N, s));
1772
1771
  }
1773
- return b(...e);
1772
+ return b(...S);
1774
1773
  }
1775
1774
  /**
1776
1775
  * Find join path from source cube to target cube
@@ -1781,22 +1780,22 @@ class TA {
1781
1780
  return [];
1782
1781
  const e = [
1783
1782
  { cube: R, path: [] }
1784
- ], O = /* @__PURE__ */ new Set([R, ...S]);
1783
+ ], N = /* @__PURE__ */ new Set([R, ...S]);
1785
1784
  for (; e.length > 0; ) {
1786
- const { cube: C, path: _ } = e.shift(), I = E.get(C);
1785
+ const { cube: s, path: _ } = e.shift(), I = E.get(s);
1787
1786
  if (I != null && I.joins)
1788
- for (const [N, s] of Object.entries(I.joins)) {
1789
- const n = CT(s.targetCube).name;
1790
- if (O.has(n))
1787
+ for (const [, O] of Object.entries(I.joins)) {
1788
+ const t = CT(O.targetCube).name;
1789
+ if (N.has(t))
1791
1790
  continue;
1792
- const P = [..._, {
1793
- fromCube: C,
1794
- toCube: n,
1795
- joinDef: s
1791
+ const i = [..._, {
1792
+ fromCube: s,
1793
+ toCube: t,
1794
+ joinDef: O
1796
1795
  }];
1797
- if (n === A)
1798
- return P;
1799
- O.add(n), e.push({ cube: n, path: P });
1796
+ if (t === A)
1797
+ return i;
1798
+ N.add(t), e.push({ cube: t, path: i });
1800
1799
  }
1801
1800
  }
1802
1801
  return null;
@@ -1808,27 +1807,27 @@ class TA {
1808
1807
  const e = [];
1809
1808
  if (!S.measures || S.measures.length === 0)
1810
1809
  return e;
1811
- for (const O of A) {
1812
- const C = this.findHasManyJoinDef(R, O.cube.name);
1813
- if (!C)
1810
+ for (const N of A) {
1811
+ const s = this.findHasManyJoinDef(R, N.cube.name);
1812
+ if (!s)
1814
1813
  continue;
1815
1814
  const _ = S.measures ? S.measures.filter(
1816
- (t) => t.startsWith(O.cube.name + ".")
1817
- ) : [], I = this.extractMeasuresFromFilters(S, O.cube.name), N = [.../* @__PURE__ */ new Set([..._, ...I])];
1818
- if (N.length === 0)
1815
+ (t) => t.startsWith(N.cube.name + ".")
1816
+ ) : [], I = this.extractMeasuresFromFilters(S, N.cube.name), O = [.../* @__PURE__ */ new Set([..._, ...I])];
1817
+ if (O.length === 0)
1819
1818
  continue;
1820
- const s = C.on.map((t) => ({
1819
+ const C = s.on.map((t) => ({
1821
1820
  sourceColumn: t.source.name,
1822
1821
  targetColumn: t.target.name,
1823
1822
  sourceColumnObj: t.source,
1824
1823
  targetColumnObj: t.target
1825
1824
  }));
1826
1825
  e.push({
1827
- cube: O.cube,
1828
- alias: O.alias,
1829
- cteAlias: `${O.cube.name.toLowerCase()}_agg`,
1830
- joinKeys: s,
1831
- measures: N
1826
+ cube: N.cube,
1827
+ alias: N.alias,
1828
+ cteAlias: `${N.cube.name.toLowerCase()}_agg`,
1829
+ joinKeys: C,
1830
+ measures: O
1832
1831
  });
1833
1832
  }
1834
1833
  return e;
@@ -1839,9 +1838,9 @@ class TA {
1839
1838
  findHasManyJoinDef(E, R) {
1840
1839
  if (!E.joins)
1841
1840
  return null;
1842
- for (const [A, S] of Object.entries(E.joins))
1843
- if (CT(S.targetCube).name === R && S.relationship === "hasMany")
1844
- return S;
1841
+ for (const [, A] of Object.entries(E.joins))
1842
+ if (CT(A.targetCube).name === R && A.relationship === "hasMany")
1843
+ return A;
1845
1844
  return null;
1846
1845
  }
1847
1846
  }
@@ -1866,24 +1865,24 @@ class UE {
1866
1865
  db: this.dbExecutor.db,
1867
1866
  schema: this.dbExecutor.schema,
1868
1867
  securityContext: A
1869
- }, O = this.queryPlanner.createQueryPlan(E, R, e), C = this.buildUnifiedQuery(O, R, e), _ = this.queryBuilder.collectNumericFields(E, R), I = await this.dbExecutor.execute(C, _), N = Array.isArray(I) ? I.map((t) => {
1870
- const n = { ...t };
1868
+ }, N = this.queryPlanner.createQueryPlan(E, R, e), s = this.buildUnifiedQuery(N, R, e), _ = this.queryBuilder.collectNumericFields(E, R), I = await this.dbExecutor.execute(s, _), O = Array.isArray(I) ? I.map((t) => {
1869
+ const i = { ...t };
1871
1870
  if (R.timeDimensions) {
1872
- for (const P of R.timeDimensions)
1873
- if (P.dimension in n) {
1874
- let M = n[P.dimension];
1871
+ for (const o of R.timeDimensions)
1872
+ if (o.dimension in i) {
1873
+ let M = i[o.dimension];
1875
1874
  if (typeof M == "string" && M.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
1876
- const o = M.replace(" ", "T"), G = !o.endsWith("Z") && !o.includes("+") ? o + "Z" : o;
1875
+ const P = M.replace(" ", "T"), G = !P.endsWith("Z") && !P.includes("+") ? P + "Z" : P;
1877
1876
  M = new Date(G);
1878
1877
  }
1879
- M = this.databaseAdapter.convertTimeDimensionResult(M), n[P.dimension] = M;
1878
+ M = this.databaseAdapter.convertTimeDimensionResult(M), i[o.dimension] = M;
1880
1879
  }
1881
1880
  }
1882
- return n;
1883
- }) : [I], s = this.generateAnnotations(O, R);
1881
+ return i;
1882
+ }) : [I], C = this.generateAnnotations(N, R);
1884
1883
  return {
1885
- data: N,
1886
- annotation: s
1884
+ data: O,
1885
+ annotation: C
1887
1886
  };
1888
1887
  } catch (S) {
1889
1888
  throw new Error(`Query execution failed: ${S instanceof Error ? S.message : "Unknown error"}`);
@@ -1901,56 +1900,56 @@ class UE {
1901
1900
  */
1902
1901
  buildPreAggregationCTE(E, R, A, S) {
1903
1902
  var M;
1904
- const e = E.cube, O = e.sql(A), C = {};
1905
- for (const o of E.joinKeys)
1906
- if (o.targetColumnObj) {
1907
- C[o.targetColumn] = o.targetColumnObj;
1903
+ const e = E.cube, N = e.sql(A), s = {};
1904
+ for (const P of E.joinKeys)
1905
+ if (P.targetColumnObj) {
1906
+ s[P.targetColumn] = P.targetColumnObj;
1908
1907
  for (const [G, a] of Object.entries(e.dimensions || {}))
1909
- a.sql === o.targetColumnObj && G !== o.targetColumn && (C[G] = L`${o.targetColumnObj}`.as(G));
1908
+ a.sql === P.targetColumnObj && G !== P.targetColumn && (s[G] = L`${P.targetColumnObj}`.as(G));
1910
1909
  }
1911
- for (const o of E.measures) {
1912
- const [, G] = o.split(".");
1910
+ for (const P of E.measures) {
1911
+ const [, G] = P.split(".");
1913
1912
  if (e.measures && e.measures[G]) {
1914
1913
  const a = e.measures[G], H = this.queryBuilder.buildMeasureExpression(a, A);
1915
- C[G] = L`${H}`.as(G);
1914
+ s[G] = L`${H}`.as(G);
1916
1915
  }
1917
1916
  }
1918
1917
  const _ = e.name;
1919
1918
  if (R.dimensions)
1920
- for (const o of R.dimensions) {
1921
- const [G, a] = o.split(".");
1919
+ for (const P of R.dimensions) {
1920
+ const [G, a] = P.split(".");
1922
1921
  if (G === _ && e.dimensions && e.dimensions[a]) {
1923
1922
  const H = e.dimensions[a], u = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, A);
1924
- C[a] = L`${u}`.as(a);
1923
+ s[a] = L`${u}`.as(a);
1925
1924
  }
1926
1925
  }
1927
1926
  if (R.timeDimensions)
1928
- for (const o of R.timeDimensions) {
1929
- const [G, a] = o.dimension.split(".");
1927
+ for (const P of R.timeDimensions) {
1928
+ const [G, a] = P.dimension.split(".");
1930
1929
  if (G === _ && e.dimensions && e.dimensions[a]) {
1931
- const H = e.dimensions[a], u = this.queryBuilder.buildTimeDimensionExpression(H.sql, o.granularity, A);
1932
- C[a] = L`${u}`.as(a);
1930
+ const H = e.dimensions[a], u = this.queryBuilder.buildTimeDimensionExpression(H.sql, P.granularity, A);
1931
+ s[a] = L`${u}`.as(a);
1933
1932
  }
1934
1933
  }
1935
- if (Object.keys(C).length === 0)
1934
+ if (Object.keys(s).length === 0)
1936
1935
  return null;
1937
- let I = A.db.select(C).from(O.from);
1938
- const N = S ? {
1936
+ let I = A.db.select(s).from(N.from);
1937
+ const O = S ? {
1939
1938
  ...S,
1940
- preAggregationCTEs: (M = S.preAggregationCTEs) == null ? void 0 : M.filter((o) => o.cube.name !== e.name)
1941
- } : void 0, s = this.queryBuilder.buildWhereConditions(e, R, A, N), t = [];
1939
+ preAggregationCTEs: (M = S.preAggregationCTEs) == null ? void 0 : M.filter((P) => P.cube.name !== e.name)
1940
+ } : void 0, C = this.queryBuilder.buildWhereConditions(e, R, A, O), t = [];
1942
1941
  if (R.timeDimensions)
1943
- for (const o of R.timeDimensions) {
1944
- const [G, a] = o.dimension.split(".");
1945
- if (G === _ && e.dimensions && e.dimensions[a] && o.dateRange) {
1946
- const H = e.dimensions[a], u = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, A), B = this.queryBuilder.buildDateRangeCondition(u, o.dateRange);
1942
+ for (const P of R.timeDimensions) {
1943
+ const [G, a] = P.dimension.split(".");
1944
+ if (G === _ && e.dimensions && e.dimensions[a] && P.dateRange) {
1945
+ const H = e.dimensions[a], u = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, A), B = this.queryBuilder.buildDateRangeCondition(u, P.dateRange);
1947
1946
  B && t.push(B);
1948
1947
  }
1949
1948
  }
1950
1949
  if (R.filters) {
1951
- for (const o of R.filters)
1952
- if (!("and" in o) && !("or" in o) && "member" in o && "operator" in o) {
1953
- const G = o, [a, H] = G.member.split(".");
1950
+ for (const P of R.filters)
1951
+ if (!("and" in P) && !("or" in P) && "member" in P && "operator" in P) {
1952
+ const G = P, [a, H] = G.member.split(".");
1954
1953
  if (a === _ && e.dimensions && e.dimensions[H]) {
1955
1954
  const u = e.dimensions[H];
1956
1955
  if (G.operator === "inDateRange") {
@@ -1960,44 +1959,44 @@ class UE {
1960
1959
  }
1961
1960
  }
1962
1961
  }
1963
- const n = [];
1964
- if (O.where && n.push(O.where), n.push(...s, ...t), n.length > 0) {
1965
- const o = n.length === 1 ? n[0] : b(...n);
1966
- I = I.where(o);
1962
+ const i = [];
1963
+ if (N.where && i.push(N.where), i.push(...C, ...t), i.length > 0) {
1964
+ const P = i.length === 1 ? i[0] : b(...i);
1965
+ I = I.where(P);
1967
1966
  }
1968
- const P = [];
1969
- for (const o of E.joinKeys)
1970
- o.targetColumnObj && P.push(o.targetColumnObj);
1967
+ const o = [];
1968
+ for (const P of E.joinKeys)
1969
+ P.targetColumnObj && o.push(P.targetColumnObj);
1971
1970
  if (R.dimensions)
1972
- for (const o of R.dimensions) {
1973
- const [G, a] = o.split(".");
1971
+ for (const P of R.dimensions) {
1972
+ const [G, a] = P.split(".");
1974
1973
  if (G === _ && e.dimensions && e.dimensions[a]) {
1975
1974
  const H = e.dimensions[a], u = x(H.sql, A);
1976
- P.push(u);
1975
+ o.push(u);
1977
1976
  }
1978
1977
  }
1979
1978
  if (R.timeDimensions)
1980
- for (const o of R.timeDimensions) {
1981
- const [G, a] = o.dimension.split(".");
1979
+ for (const P of R.timeDimensions) {
1980
+ const [G, a] = P.dimension.split(".");
1982
1981
  if (G === _ && e.dimensions && e.dimensions[a]) {
1983
- const H = e.dimensions[a], u = this.queryBuilder.buildTimeDimensionExpression(H.sql, o.granularity, A);
1984
- P.push(u);
1982
+ const H = e.dimensions[a], u = this.queryBuilder.buildTimeDimensionExpression(H.sql, P.granularity, A);
1983
+ o.push(u);
1985
1984
  }
1986
1985
  }
1987
- return P.length > 0 && (I = I.groupBy(...P)), A.db.$with(E.cteAlias).as(I);
1986
+ return o.length > 0 && (I = I.groupBy(...o)), A.db.$with(E.cteAlias).as(I);
1988
1987
  }
1989
1988
  // Removed unused getActualJoinTargetColumn method
1990
1989
  /**
1991
1990
  * Build join condition for CTE
1992
1991
  */
1993
1992
  buildCTEJoinCondition(E, R, A) {
1994
- var O;
1995
- const S = (O = A.preAggregationCTEs) == null ? void 0 : O.find((C) => C.cube.name === E.cube.name);
1993
+ var N;
1994
+ const S = (N = A.preAggregationCTEs) == null ? void 0 : N.find((s) => s.cube.name === E.cube.name);
1996
1995
  if (!S)
1997
1996
  throw new Error(`CTE info not found for cube ${E.cube.name}`);
1998
1997
  const e = [];
1999
- for (const C of S.joinKeys) {
2000
- const _ = C.sourceColumnObj || L.identifier(C.sourceColumn), I = L`${L.identifier(R)}.${L.identifier(C.targetColumn)}`;
1998
+ for (const s of S.joinKeys) {
1999
+ const _ = s.sourceColumnObj || L.identifier(s.sourceColumn), I = L`${L.identifier(R)}.${L.identifier(s.targetColumn)}`;
2001
2000
  e.push(qE(_, I));
2002
2001
  }
2003
2002
  return e.length === 1 ? e[0] : b(...e);
@@ -2006,14 +2005,14 @@ class UE {
2006
2005
  * Build unified query that works for both single and multi-cube queries
2007
2006
  */
2008
2007
  buildUnifiedQuery(E, R, A) {
2009
- var M, o, G;
2008
+ var M, P, G;
2010
2009
  const S = [], e = /* @__PURE__ */ new Map();
2011
2010
  if (E.preAggregationCTEs && E.preAggregationCTEs.length > 0)
2012
2011
  for (const a of E.preAggregationCTEs) {
2013
2012
  const H = this.buildPreAggregationCTE(a, R, A, E);
2014
2013
  H && (S.push(H), e.set(a.cube.name, a.cteAlias));
2015
2014
  }
2016
- const O = E.primaryCube.sql(A), _ = { ...this.queryBuilder.buildSelections(
2015
+ const N = E.primaryCube.sql(A), _ = { ...this.queryBuilder.buildSelections(
2017
2016
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2018
2017
  // Single cube
2019
2018
  R,
@@ -2058,7 +2057,7 @@ class UE {
2058
2057
  const V = this.getCubesFromPlan(E).get(H), g = V && ((M = V.dimensions) == null ? void 0 : M[Y]), K = u.startsWith(H + ".");
2059
2058
  if (g || K) {
2060
2059
  let nE = a.joinKeys.find((iE) => iE.targetColumn === Y);
2061
- if (!nE && ((o = V == null ? void 0 : V.dimensions) != null && o[Y])) {
2060
+ if (!nE && ((P = V == null ? void 0 : V.dimensions) != null && P[Y])) {
2062
2061
  const iE = V.dimensions[Y].sql;
2063
2062
  nE = a.joinKeys.find((mR) => mR.targetColumnObj === iE);
2064
2063
  }
@@ -2067,9 +2066,9 @@ class UE {
2067
2066
  }
2068
2067
  }
2069
2068
  }
2070
- let I = A.db.select(_).from(O.from);
2071
- if (S.length > 0 && (I = A.db.with(...S).select(_).from(O.from)), O.joins)
2072
- for (const a of O.joins)
2069
+ let I = A.db.select(_).from(N.from);
2070
+ if (S.length > 0 && (I = A.db.with(...S).select(_).from(N.from)), N.joins)
2071
+ for (const a of N.joins)
2073
2072
  switch (a.type || "left") {
2074
2073
  case "left":
2075
2074
  I = I.leftJoin(a.table, a.on);
@@ -2107,15 +2106,15 @@ class UE {
2107
2106
  } catch {
2108
2107
  }
2109
2108
  }
2110
- const N = [];
2111
- if (O.where && N.push(O.where), E.joinCubes && E.joinCubes.length > 0)
2109
+ const O = [];
2110
+ if (N.where && O.push(N.where), E.joinCubes && E.joinCubes.length > 0)
2112
2111
  for (const a of E.joinCubes) {
2113
2112
  if (e.get(a.cube.name))
2114
2113
  continue;
2115
2114
  const u = a.cube.sql(A);
2116
- u.where && N.push(u.where);
2115
+ u.where && O.push(u.where);
2117
2116
  }
2118
- const s = this.queryBuilder.buildWhereConditions(
2117
+ const C = this.queryBuilder.buildWhereConditions(
2119
2118
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2120
2119
  // Single cube
2121
2120
  R,
@@ -2123,8 +2122,8 @@ class UE {
2123
2122
  E
2124
2123
  // Pass the queryPlan to handle CTE scenarios
2125
2124
  );
2126
- if (s.length > 0 && N.push(...s), N.length > 0) {
2127
- const a = N.length === 1 ? N[0] : b(...N);
2125
+ if (C.length > 0 && O.push(...C), O.length > 0) {
2126
+ const a = O.length === 1 ? O[0] : b(...O);
2128
2127
  I = I.where(a);
2129
2128
  }
2130
2129
  const t = this.queryBuilder.buildGroupByFields(
@@ -2136,7 +2135,7 @@ class UE {
2136
2135
  // Pass the queryPlan to handle CTE scenarios
2137
2136
  );
2138
2137
  t.length > 0 && (I = I.groupBy(...t));
2139
- const n = this.queryBuilder.buildHavingConditions(
2138
+ const i = this.queryBuilder.buildHavingConditions(
2140
2139
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2141
2140
  // Single cube
2142
2141
  R,
@@ -2144,12 +2143,12 @@ class UE {
2144
2143
  E
2145
2144
  // Pass the queryPlan to handle CTE scenarios
2146
2145
  );
2147
- if (n.length > 0) {
2148
- const a = n.length === 1 ? n[0] : b(...n);
2146
+ if (i.length > 0) {
2147
+ const a = i.length === 1 ? i[0] : b(...i);
2149
2148
  I = I.having(a);
2150
2149
  }
2151
- const P = this.queryBuilder.buildOrderBy(R);
2152
- return P.length > 0 && (I = I.orderBy(...P)), I = this.queryBuilder.applyLimitAndOffset(I, R), I;
2150
+ const o = this.queryBuilder.buildOrderBy(R);
2151
+ return o.length > 0 && (I = I.orderBy(...o)), I = this.queryBuilder.applyLimitAndOffset(I, R), I;
2153
2152
  }
2154
2153
  /**
2155
2154
  * Convert query plan to cube map for QueryBuilder methods
@@ -2182,51 +2181,51 @@ class UE {
2182
2181
  db: this.dbExecutor.db,
2183
2182
  schema: this.dbExecutor.schema,
2184
2183
  securityContext: A
2185
- }, e = this.queryPlanner.createQueryPlan(E, R, S), C = this.buildUnifiedQuery(e, R, S).toSQL();
2184
+ }, e = this.queryPlanner.createQueryPlan(E, R, S), s = this.buildUnifiedQuery(e, R, S).toSQL();
2186
2185
  return {
2187
- sql: C.sql,
2188
- params: C.params
2186
+ sql: s.sql,
2187
+ params: s.params
2189
2188
  };
2190
2189
  }
2191
2190
  /**
2192
2191
  * Generate annotations for UI metadata - unified approach
2193
2192
  */
2194
2193
  generateAnnotations(E, R) {
2195
- const A = {}, S = {}, e = {}, O = [E.primaryCube];
2196
- if (E.joinCubes && E.joinCubes.length > 0 && O.push(...E.joinCubes.map((C) => C.cube)), R.measures)
2197
- for (const C of R.measures) {
2198
- const [_, I] = C.split("."), N = O.find((s) => s.name === _);
2199
- if (N && N.measures[I]) {
2200
- const s = N.measures[I];
2201
- A[C] = {
2202
- title: s.title || I,
2203
- shortTitle: s.title || I,
2204
- type: s.type
2194
+ const A = {}, S = {}, e = {}, N = [E.primaryCube];
2195
+ if (E.joinCubes && E.joinCubes.length > 0 && N.push(...E.joinCubes.map((s) => s.cube)), R.measures)
2196
+ for (const s of R.measures) {
2197
+ const [_, I] = s.split("."), O = N.find((C) => C.name === _);
2198
+ if (O && O.measures[I]) {
2199
+ const C = O.measures[I];
2200
+ A[s] = {
2201
+ title: C.title || I,
2202
+ shortTitle: C.title || I,
2203
+ type: C.type
2205
2204
  };
2206
2205
  }
2207
2206
  }
2208
2207
  if (R.dimensions)
2209
- for (const C of R.dimensions) {
2210
- const [_, I] = C.split("."), N = O.find((s) => s.name === _);
2211
- if (N && N.dimensions[I]) {
2212
- const s = N.dimensions[I];
2213
- S[C] = {
2214
- title: s.title || I,
2215
- shortTitle: s.title || I,
2216
- type: s.type
2208
+ for (const s of R.dimensions) {
2209
+ const [_, I] = s.split("."), O = N.find((C) => C.name === _);
2210
+ if (O && O.dimensions[I]) {
2211
+ const C = O.dimensions[I];
2212
+ S[s] = {
2213
+ title: C.title || I,
2214
+ shortTitle: C.title || I,
2215
+ type: C.type
2217
2216
  };
2218
2217
  }
2219
2218
  }
2220
2219
  if (R.timeDimensions)
2221
- for (const C of R.timeDimensions) {
2222
- const [_, I] = C.dimension.split("."), N = O.find((s) => s.name === _);
2223
- if (N && N.dimensions && N.dimensions[I]) {
2224
- const s = N.dimensions[I];
2225
- e[C.dimension] = {
2226
- title: s.title || I,
2227
- shortTitle: s.title || I,
2228
- type: s.type,
2229
- granularity: C.granularity
2220
+ for (const s of R.timeDimensions) {
2221
+ const [_, I] = s.dimension.split("."), O = N.find((C) => C.name === _);
2222
+ if (O && O.dimensions && O.dimensions[I]) {
2223
+ const C = O.dimensions[I];
2224
+ e[s.dimension] = {
2225
+ title: C.title || I,
2226
+ shortTitle: C.title || I,
2227
+ type: C.type,
2228
+ granularity: s.granularity
2230
2229
  };
2231
2230
  }
2232
2231
  }
@@ -3134,7 +3133,7 @@ const _R = (T) => ({
3134
3133
  "{ROWS | RANGE} BETWEEN",
3135
3134
  // comparison operator
3136
3135
  "IS [NOT] DISTINCT FROM"
3137
- ]), oA = {
3136
+ ]), PA = {
3138
3137
  name: "bigquery",
3139
3138
  tokenizerOptions: {
3140
3139
  reservedSelect: rA,
@@ -3162,14 +3161,14 @@ const _R = (T) => ({
3162
3161
  variableTypes: [{ regex: String.raw`@@\w+` }],
3163
3162
  lineCommentTypes: ["--", "#"],
3164
3163
  operators: ["&", "|", "^", "~", ">>", "<<", "||", "=>"],
3165
- postProcess: PA
3164
+ postProcess: oA
3166
3165
  },
3167
3166
  formatOptions: {
3168
3167
  onelineClauses: [...LT, ...GE],
3169
3168
  tabularOnelineClauses: GE
3170
3169
  }
3171
3170
  };
3172
- function PA(T) {
3171
+ function oA(T) {
3173
3172
  return MA(UA(T));
3174
3173
  }
3175
3174
  function MA(T) {
@@ -3182,11 +3181,11 @@ function UA(T) {
3182
3181
  for (let A = 0; A < T.length; A++) {
3183
3182
  const S = T[A];
3184
3183
  if ((Z.ARRAY(S) || Z.STRUCT(S)) && ((E = T[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
3185
- const e = GA(T, A + 1), O = T.slice(A, e + 1);
3184
+ const e = GA(T, A + 1), N = T.slice(A, e + 1);
3186
3185
  R.push({
3187
3186
  type: D.IDENTIFIER,
3188
- raw: O.map(_T("raw")).join(""),
3189
- text: O.map(_T("text")).join(""),
3187
+ raw: N.map(_T("raw")).join(""),
3188
+ text: N.map(_T("text")).join(""),
3190
3189
  start: S.start
3191
3190
  }), A = e;
3192
3191
  } else
@@ -8457,7 +8456,7 @@ const IS = [
8457
8456
  // 'XOR',
8458
8457
  "YEAR",
8459
8458
  "YEARWEEK"
8460
- ], aS = r(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), oS = r([
8459
+ ], aS = r(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), PS = r([
8461
8460
  // queries
8462
8461
  "WITH [RECURSIVE]",
8463
8462
  "FROM",
@@ -8477,7 +8476,7 @@ const IS = [
8477
8476
  "ON DUPLICATE KEY UPDATE",
8478
8477
  // - update:
8479
8478
  "SET"
8480
- ]), oT = r(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), mE = r([
8479
+ ]), PT = r(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), mE = r([
8481
8480
  // - create:
8482
8481
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
8483
8482
  // - update:
@@ -8658,7 +8657,7 @@ const IS = [
8658
8657
  "REPEAT",
8659
8658
  "RETURN",
8660
8659
  "WHILE"
8661
- ]), PS = r(["UNION [ALL | DISTINCT]"]), MS = r([
8660
+ ]), oS = r(["UNION [ALL | DISTINCT]"]), MS = r([
8662
8661
  "JOIN",
8663
8662
  "{LEFT | RIGHT} [OUTER] JOIN",
8664
8663
  "{INNER | CROSS} JOIN",
@@ -8675,8 +8674,8 @@ const IS = [
8675
8674
  name: "mysql",
8676
8675
  tokenizerOptions: {
8677
8676
  reservedSelect: aS,
8678
- reservedClauses: [...oS, ...oT, ...mE],
8679
- reservedSetOperations: PS,
8677
+ reservedClauses: [...PS, ...PT, ...mE],
8678
+ reservedSetOperations: oS,
8680
8679
  reservedJoins: MS,
8681
8680
  reservedPhrases: US,
8682
8681
  supportsXor: !0,
@@ -8720,7 +8719,7 @@ const IS = [
8720
8719
  postProcess: rE
8721
8720
  },
8722
8721
  formatOptions: {
8723
- onelineClauses: [...oT, ...mE],
8722
+ onelineClauses: [...PT, ...mE],
8724
8723
  tabularOnelineClauses: mE
8725
8724
  }
8726
8725
  }, lS = [
@@ -9308,7 +9307,7 @@ const IS = [
9308
9307
  "ON DUPLICATE KEY UPDATE",
9309
9308
  // - update:
9310
9309
  "SET"
9311
- ]), PT = r(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), FE = r([
9310
+ ]), oT = r(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), FE = r([
9312
9311
  // https://docs.pingcap.com/tidb/stable/sql-statement-create-view
9313
9312
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
9314
9313
  // https://docs.pingcap.com/tidb/stable/sql-statement-update
@@ -9440,7 +9439,7 @@ const IS = [
9440
9439
  name: "tidb",
9441
9440
  tokenizerOptions: {
9442
9441
  reservedSelect: HS,
9443
- reservedClauses: [...BS, ...PT, ...FE],
9442
+ reservedClauses: [...BS, ...oT, ...FE],
9444
9443
  reservedSetOperations: mS,
9445
9444
  reservedJoins: FS,
9446
9445
  reservedPhrases: YS,
@@ -9485,7 +9484,7 @@ const IS = [
9485
9484
  postProcess: rE
9486
9485
  },
9487
9486
  formatOptions: {
9488
- onelineClauses: [...PT, ...FE],
9487
+ onelineClauses: [...oT, ...FE],
9489
9488
  tabularOnelineClauses: FE
9490
9489
  }
9491
9490
  }, dS = [
@@ -13289,7 +13288,7 @@ const kS = [
13289
13288
  // Shorthand functions to use in place of CASE expression
13290
13289
  "COALESCE",
13291
13290
  "NULLIF"
13292
- ], oe = r(["SELECT [ALL | DISTINCT]"]), Pe = r([
13291
+ ], Pe = r(["SELECT [ALL | DISTINCT]"]), oe = r([
13293
13292
  // queries
13294
13293
  "WITH",
13295
13294
  "FROM",
@@ -13391,8 +13390,8 @@ const kS = [
13391
13390
  ]), le = {
13392
13391
  name: "spark",
13393
13392
  tokenizerOptions: {
13394
- reservedSelect: oe,
13395
- reservedClauses: [...Pe, ...cT, ...fE],
13393
+ reservedSelect: Pe,
13394
+ reservedClauses: [...oe, ...cT, ...fE],
13396
13395
  reservedSetOperations: Me,
13397
13396
  reservedJoins: Ue,
13398
13397
  reservedPhrases: Ge,
@@ -17350,7 +17349,7 @@ const ue = [
17350
17349
  "WITH",
17351
17350
  // These are definitely keywords, but haven't found a definite list in the docs
17352
17351
  "COMMENT"
17353
- ], oI = [
17352
+ ], PI = [
17354
17353
  "NUMBER",
17355
17354
  "DECIMAL",
17356
17355
  "NUMERIC",
@@ -17387,7 +17386,7 @@ const ue = [
17387
17386
  "ARRAY",
17388
17387
  "GEOGRAPHY",
17389
17388
  "GEOMETRY"
17390
- ], PI = r(["SELECT [ALL | DISTINCT]"]), MI = r([
17389
+ ], oI = r(["SELECT [ALL | DISTINCT]"]), MI = r([
17391
17390
  // queries
17392
17391
  "WITH [RECURSIVE]",
17393
17392
  "FROM",
@@ -17669,13 +17668,13 @@ const ue = [
17669
17668
  ]), cI = {
17670
17669
  name: "snowflake",
17671
17670
  tokenizerOptions: {
17672
- reservedSelect: PI,
17671
+ reservedSelect: oI,
17673
17672
  reservedClauses: [...MI, ...YT, ...yE],
17674
17673
  reservedSetOperations: UI,
17675
17674
  reservedJoins: GI,
17676
17675
  reservedPhrases: lI,
17677
17676
  reservedKeywords: aI,
17678
- reservedDataTypes: oI,
17677
+ reservedDataTypes: PI,
17679
17678
  reservedFunctionNames: DI,
17680
17679
  stringTypes: ["$$", "''-qq-bs"],
17681
17680
  identTypes: ['""-qq'],
@@ -17711,7 +17710,7 @@ const ue = [
17711
17710
  }
17712
17711
  }, uI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
17713
17712
  __proto__: null,
17714
- bigquery: oA,
17713
+ bigquery: PA,
17715
17714
  db2: pA,
17716
17715
  db2i: KA,
17717
17716
  duckdb: qA,
@@ -17751,7 +17750,7 @@ const ue = [
17751
17750
  "[": "]",
17752
17751
  "(": ")",
17753
17752
  "{": "}"
17754
- }, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([O, C]) => E.replace(/{left}/g, y(O)).replace(/{right}/g, y(C))), A = y(Object.keys(T).join(""));
17753
+ }, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([N, s]) => E.replace(/{left}/g, y(N)).replace(/{right}/g, y(s))), A = y(Object.keys(T).join(""));
17755
17754
  return `[Qq]'(?:${String.raw`(?<tag>[^\s${A}])(?:(?!\k<tag>').)*?\k<tag>`}|${R.join("|")})'`;
17756
17755
  }, hT = {
17757
17756
  // - backtick quoted (using `` to escape)
@@ -17779,10 +17778,10 @@ const ue = [
17779
17778
  // Oracle q'' strings: q'<text>' q'|text|' ...
17780
17779
  "q''": pI()
17781
17780
  }, iR = (T) => typeof T == "string" ? hT[T] : "regex" in T ? T.regex : mI(T) + hT[T.quote], dI = (T) => q(T.map((E) => "regex" in E ? E.regex : iR(E)).join("|")), DR = (T) => T.map(iR).join("|"), VT = (T) => q(DR(T)), fI = (T = {}) => q(aR(T)), aR = ({ first: T, rest: E, dashes: R, allowFirstCharNumber: A } = {}) => {
17782
- const S = "\\p{Alphabetic}\\p{Mark}_", e = "\\p{Decimal_Number}", O = y(T ?? ""), C = y(E ?? ""), _ = A ? `[${S}${e}${O}][${S}${e}${C}]*` : `[${S}${O}][${S}${e}${C}]*`;
17781
+ const S = "\\p{Alphabetic}\\p{Mark}_", e = "\\p{Decimal_Number}", N = y(T ?? ""), s = y(E ?? ""), _ = A ? `[${S}${e}${N}][${S}${e}${s}]*` : `[${S}${N}][${S}${e}${s}]*`;
17783
17782
  return R ? BI(_) : _;
17784
17783
  };
17785
- function oR(T, E) {
17784
+ function PR(T, E) {
17786
17785
  const R = T.slice(0, E).split(/\n/);
17787
17786
  return { line: R.length, col: R[R.length - 1].length + 1 };
17788
17787
  }
@@ -17812,7 +17811,7 @@ class hI {
17812
17811
  return R;
17813
17812
  }
17814
17813
  createParseError() {
17815
- const E = this.input.slice(this.index, this.index + 10), { line: R, col: A } = oR(this.input, this.index);
17814
+ const E = this.input.slice(this.index, this.index + 10), { line: R, col: A } = PR(this.input, this.index);
17816
17815
  return new Error(`Parse error: Unexpected "${E}" at line ${R} column ${A}.
17817
17816
  ${this.dialectInfo()}`);
17818
17817
  }
@@ -18064,13 +18063,13 @@ class bI {
18064
18063
  // These rules can't be blindly cached as the paramTypesOverrides object
18065
18064
  // can differ on each invocation of the format() function.
18066
18065
  buildParamRules(E, R) {
18067
- var A, S, e, O, C;
18066
+ var A, S, e, N, s;
18068
18067
  const _ = {
18069
18068
  named: (R == null ? void 0 : R.named) || ((A = E.paramTypes) === null || A === void 0 ? void 0 : A.named) || [],
18070
18069
  quoted: (R == null ? void 0 : R.quoted) || ((S = E.paramTypes) === null || S === void 0 ? void 0 : S.quoted) || [],
18071
18070
  numbered: (R == null ? void 0 : R.numbered) || ((e = E.paramTypes) === null || e === void 0 ? void 0 : e.numbered) || [],
18072
- positional: typeof (R == null ? void 0 : R.positional) == "boolean" ? R.positional : (O = E.paramTypes) === null || O === void 0 ? void 0 : O.positional,
18073
- custom: (R == null ? void 0 : R.custom) || ((C = E.paramTypes) === null || C === void 0 ? void 0 : C.custom) || []
18071
+ positional: typeof (R == null ? void 0 : R.positional) == "boolean" ? R.positional : (N = E.paramTypes) === null || N === void 0 ? void 0 : N.positional,
18072
+ custom: (R == null ? void 0 : R.custom) || ((s = E.paramTypes) === null || s === void 0 ? void 0 : s.custom) || []
18074
18073
  };
18075
18074
  return this.validRules([
18076
18075
  {
@@ -18081,7 +18080,7 @@ class bI {
18081
18080
  {
18082
18081
  type: D.QUOTED_PARAMETER,
18083
18082
  regex: $E(_.quoted, DR(E.identTypes)),
18084
- key: (I) => (({ tokenKey: N, quoteChar: s }) => N.replace(new RegExp(y("\\" + s), "gu"), s))({
18083
+ key: (I) => (({ tokenKey: O, quoteChar: C }) => O.replace(new RegExp(y("\\" + C), "gu"), C))({
18085
18084
  tokenKey: I.slice(2, -1),
18086
18085
  quoteChar: I.slice(-1)
18087
18086
  })
@@ -18096,11 +18095,11 @@ class bI {
18096
18095
  regex: _.positional ? /[?]/y : void 0
18097
18096
  },
18098
18097
  ..._.custom.map((I) => {
18099
- var N;
18098
+ var O;
18100
18099
  return {
18101
18100
  type: D.CUSTOM_PARAMETER,
18102
18101
  regex: q(I.regex),
18103
- key: (N = I.key) !== null && N !== void 0 ? N : (s) => s
18102
+ key: (O = I.key) !== null && O !== void 0 ? O : (C) => C
18104
18103
  };
18105
18104
  })
18106
18105
  ]);
@@ -18157,97 +18156,97 @@ var wI = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
18157
18156
  function xI(T) {
18158
18157
  return T && T.__esModule && Object.prototype.hasOwnProperty.call(T, "default") ? T.default : T;
18159
18158
  }
18160
- var PR = { exports: {} };
18159
+ var oR = { exports: {} };
18161
18160
  (function(T) {
18162
18161
  (function(E, R) {
18163
18162
  T.exports ? T.exports = R() : E.nearley = R();
18164
18163
  })(wI, function() {
18165
- function E(I, N, s) {
18166
- return this.id = ++E.highestId, this.name = I, this.symbols = N, this.postprocess = s, this;
18164
+ function E(I, O, C) {
18165
+ return this.id = ++E.highestId, this.name = I, this.symbols = O, this.postprocess = C, this;
18167
18166
  }
18168
18167
  E.highestId = 0, E.prototype.toString = function(I) {
18169
- var N = typeof I > "u" ? this.symbols.map(_).join(" ") : this.symbols.slice(0, I).map(_).join(" ") + " ● " + this.symbols.slice(I).map(_).join(" ");
18170
- return this.name + " → " + N;
18168
+ var O = typeof I > "u" ? this.symbols.map(_).join(" ") : this.symbols.slice(0, I).map(_).join(" ") + " ● " + this.symbols.slice(I).map(_).join(" ");
18169
+ return this.name + " → " + O;
18171
18170
  };
18172
- function R(I, N, s, t) {
18173
- this.rule = I, this.dot = N, this.reference = s, this.data = [], this.wantedBy = t, this.isComplete = this.dot === I.symbols.length;
18171
+ function R(I, O, C, t) {
18172
+ this.rule = I, this.dot = O, this.reference = C, this.data = [], this.wantedBy = t, this.isComplete = this.dot === I.symbols.length;
18174
18173
  }
18175
18174
  R.prototype.toString = function() {
18176
18175
  return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
18177
18176
  }, R.prototype.nextState = function(I) {
18178
- var N = new R(this.rule, this.dot + 1, this.reference, this.wantedBy);
18179
- return N.left = this, N.right = I, N.isComplete && (N.data = N.build(), N.right = void 0), N;
18177
+ var O = new R(this.rule, this.dot + 1, this.reference, this.wantedBy);
18178
+ return O.left = this, O.right = I, O.isComplete && (O.data = O.build(), O.right = void 0), O;
18180
18179
  }, R.prototype.build = function() {
18181
- var I = [], N = this;
18180
+ var I = [], O = this;
18182
18181
  do
18183
- I.push(N.right.data), N = N.left;
18184
- while (N.left);
18182
+ I.push(O.right.data), O = O.left;
18183
+ while (O.left);
18185
18184
  return I.reverse(), I;
18186
18185
  }, R.prototype.finish = function() {
18187
- this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, O.fail));
18186
+ this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, N.fail));
18188
18187
  };
18189
- function A(I, N) {
18190
- this.grammar = I, this.index = N, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
18188
+ function A(I, O) {
18189
+ this.grammar = I, this.index = O, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
18191
18190
  }
18192
18191
  A.prototype.process = function(I) {
18193
- for (var N = this.states, s = this.wants, t = this.completed, n = 0; n < N.length; n++) {
18194
- var P = N[n];
18195
- if (P.isComplete) {
18196
- if (P.finish(), P.data !== O.fail) {
18197
- for (var M = P.wantedBy, o = M.length; o--; ) {
18198
- var G = M[o];
18199
- this.complete(G, P);
18192
+ for (var O = this.states, C = this.wants, t = this.completed, i = 0; i < O.length; i++) {
18193
+ var o = O[i];
18194
+ if (o.isComplete) {
18195
+ if (o.finish(), o.data !== N.fail) {
18196
+ for (var M = o.wantedBy, P = M.length; P--; ) {
18197
+ var G = M[P];
18198
+ this.complete(G, o);
18200
18199
  }
18201
- if (P.reference === this.index) {
18202
- var a = P.rule.name;
18203
- (this.completed[a] = this.completed[a] || []).push(P);
18200
+ if (o.reference === this.index) {
18201
+ var a = o.rule.name;
18202
+ (this.completed[a] = this.completed[a] || []).push(o);
18204
18203
  }
18205
18204
  }
18206
18205
  } else {
18207
- var a = P.rule.symbols[P.dot];
18206
+ var a = o.rule.symbols[o.dot];
18208
18207
  if (typeof a != "string") {
18209
- this.scannable.push(P);
18208
+ this.scannable.push(o);
18210
18209
  continue;
18211
18210
  }
18212
- if (s[a]) {
18213
- if (s[a].push(P), t.hasOwnProperty(a))
18214
- for (var H = t[a], o = 0; o < H.length; o++) {
18215
- var u = H[o];
18216
- this.complete(P, u);
18211
+ if (C[a]) {
18212
+ if (C[a].push(o), t.hasOwnProperty(a))
18213
+ for (var H = t[a], P = 0; P < H.length; P++) {
18214
+ var u = H[P];
18215
+ this.complete(o, u);
18217
18216
  }
18218
18217
  } else
18219
- s[a] = [P], this.predict(a);
18218
+ C[a] = [o], this.predict(a);
18220
18219
  }
18221
18220
  }
18222
18221
  }, A.prototype.predict = function(I) {
18223
- for (var N = this.grammar.byName[I] || [], s = 0; s < N.length; s++) {
18224
- var t = N[s], n = this.wants[I], P = new R(t, 0, this.index, n);
18225
- this.states.push(P);
18222
+ for (var O = this.grammar.byName[I] || [], C = 0; C < O.length; C++) {
18223
+ var t = O[C], i = this.wants[I], o = new R(t, 0, this.index, i);
18224
+ this.states.push(o);
18226
18225
  }
18227
- }, A.prototype.complete = function(I, N) {
18228
- var s = I.nextState(N);
18229
- this.states.push(s);
18226
+ }, A.prototype.complete = function(I, O) {
18227
+ var C = I.nextState(O);
18228
+ this.states.push(C);
18230
18229
  };
18231
- function S(I, N) {
18232
- this.rules = I, this.start = N || this.rules[0].name;
18233
- var s = this.byName = {};
18230
+ function S(I, O) {
18231
+ this.rules = I, this.start = O || this.rules[0].name;
18232
+ var C = this.byName = {};
18234
18233
  this.rules.forEach(function(t) {
18235
- s.hasOwnProperty(t.name) || (s[t.name] = []), s[t.name].push(t);
18234
+ C.hasOwnProperty(t.name) || (C[t.name] = []), C[t.name].push(t);
18236
18235
  });
18237
18236
  }
18238
- S.fromCompiled = function(t, N) {
18239
- var s = t.Lexer;
18240
- t.ParserStart && (N = t.ParserStart, t = t.ParserRules);
18241
- var t = t.map(function(P) {
18242
- return new E(P.name, P.symbols, P.postprocess);
18243
- }), n = new S(t, N);
18244
- return n.lexer = s, n;
18237
+ S.fromCompiled = function(t, O) {
18238
+ var C = t.Lexer;
18239
+ t.ParserStart && (O = t.ParserStart, t = t.ParserRules);
18240
+ var t = t.map(function(o) {
18241
+ return new E(o.name, o.symbols, o.postprocess);
18242
+ }), i = new S(t, O);
18243
+ return i.lexer = C, i;
18245
18244
  };
18246
18245
  function e() {
18247
18246
  this.reset("");
18248
18247
  }
18249
- e.prototype.reset = function(I, N) {
18250
- this.buffer = I, this.index = 0, this.line = N ? N.line : 1, this.lastLineBreak = N ? -N.col : 0;
18248
+ e.prototype.reset = function(I, O) {
18249
+ this.buffer = I, this.index = 0, this.line = O ? O.line : 1, this.lastLineBreak = O ? -O.col : 0;
18251
18250
  }, e.prototype.next = function() {
18252
18251
  if (this.index < this.buffer.length) {
18253
18252
  var I = this.buffer[this.index++];
@@ -18259,53 +18258,53 @@ var PR = { exports: {} };
18259
18258
  line: this.line,
18260
18259
  col: this.index - this.lastLineBreak
18261
18260
  };
18262
- }, e.prototype.formatError = function(I, N) {
18263
- var s = this.buffer;
18264
- if (typeof s == "string") {
18265
- var t = s.split(`
18261
+ }, e.prototype.formatError = function(I, O) {
18262
+ var C = this.buffer;
18263
+ if (typeof C == "string") {
18264
+ var t = C.split(`
18266
18265
  `).slice(
18267
18266
  Math.max(0, this.line - 5),
18268
18267
  this.line
18269
- ), n = s.indexOf(`
18268
+ ), i = C.indexOf(`
18270
18269
  `, this.index);
18271
- n === -1 && (n = s.length);
18272
- var P = this.index - this.lastLineBreak, M = String(this.line).length;
18273
- return N += " at line " + this.line + " col " + P + `:
18270
+ i === -1 && (i = C.length);
18271
+ var o = this.index - this.lastLineBreak, M = String(this.line).length;
18272
+ return O += " at line " + this.line + " col " + o + `:
18274
18273
 
18275
- `, N += t.map(function(G, a) {
18276
- return o(this.line - t.length + a + 1, M) + " " + G;
18274
+ `, O += t.map(function(G, a) {
18275
+ return P(this.line - t.length + a + 1, M) + " " + G;
18277
18276
  }, this).join(`
18278
- `), N += `
18279
- ` + o("", M + P) + `^
18280
- `, N;
18277
+ `), O += `
18278
+ ` + P("", M + o) + `^
18279
+ `, O;
18281
18280
  } else
18282
- return N + " at index " + (this.index - 1);
18283
- function o(G, a) {
18281
+ return O + " at index " + (this.index - 1);
18282
+ function P(G, a) {
18284
18283
  var H = String(G);
18285
18284
  return Array(a - H.length + 1).join(" ") + H;
18286
18285
  }
18287
18286
  };
18288
- function O(I, N, s) {
18287
+ function N(I, O, C) {
18289
18288
  if (I instanceof S)
18290
- var t = I, s = N;
18289
+ var t = I, C = O;
18291
18290
  else
18292
- var t = S.fromCompiled(I, N);
18291
+ var t = S.fromCompiled(I, O);
18293
18292
  this.grammar = t, this.options = {
18294
18293
  keepHistory: !1,
18295
18294
  lexer: t.lexer || new e()
18296
18295
  };
18297
- for (var n in s || {})
18298
- this.options[n] = s[n];
18296
+ for (var i in C || {})
18297
+ this.options[i] = C[i];
18299
18298
  this.lexer = this.options.lexer, this.lexerState = void 0;
18300
- var P = new A(t, 0);
18301
- this.table = [P], P.wants[t.start] = [], P.predict(t.start), P.process(), this.current = 0;
18299
+ var o = new A(t, 0);
18300
+ this.table = [o], o.wants[t.start] = [], o.predict(t.start), o.process(), this.current = 0;
18302
18301
  }
18303
- O.fail = {}, O.prototype.feed = function(I) {
18304
- var N = this.lexer;
18305
- N.reset(I, this.lexerState);
18306
- for (var s; ; ) {
18302
+ N.fail = {}, N.prototype.feed = function(I) {
18303
+ var O = this.lexer;
18304
+ O.reset(I, this.lexerState);
18305
+ for (var C; ; ) {
18307
18306
  try {
18308
- if (s = N.next(), !s)
18307
+ if (C = O.next(), !C)
18309
18308
  break;
18310
18309
  } catch (V) {
18311
18310
  var M = new A(this.grammar, this.current + 1);
@@ -18313,90 +18312,90 @@ var PR = { exports: {} };
18313
18312
  var t = new Error(this.reportLexerError(V));
18314
18313
  throw t.offset = this.current, t.token = V.token, t;
18315
18314
  }
18316
- var n = this.table[this.current];
18315
+ var i = this.table[this.current];
18317
18316
  this.options.keepHistory || delete this.table[this.current - 1];
18318
- var P = this.current + 1, M = new A(this.grammar, P);
18317
+ var o = this.current + 1, M = new A(this.grammar, o);
18319
18318
  this.table.push(M);
18320
- for (var o = s.text !== void 0 ? s.text : s.value, G = N.constructor === e ? s.value : s, a = n.scannable, H = a.length; H--; ) {
18319
+ for (var P = C.text !== void 0 ? C.text : C.value, G = O.constructor === e ? C.value : C, a = i.scannable, H = a.length; H--; ) {
18321
18320
  var u = a[H], B = u.rule.symbols[u.dot];
18322
- if (B.test ? B.test(G) : B.type ? B.type === s.type : B.literal === o) {
18323
- var Y = u.nextState({ data: G, token: s, isToken: !0, reference: P - 1 });
18321
+ if (B.test ? B.test(G) : B.type ? B.type === C.type : B.literal === P) {
18322
+ var Y = u.nextState({ data: G, token: C, isToken: !0, reference: o - 1 });
18324
18323
  M.states.push(Y);
18325
18324
  }
18326
18325
  }
18327
18326
  if (M.process(), M.states.length === 0) {
18328
- var t = new Error(this.reportError(s));
18329
- throw t.offset = this.current, t.token = s, t;
18327
+ var t = new Error(this.reportError(C));
18328
+ throw t.offset = this.current, t.token = C, t;
18330
18329
  }
18331
- this.options.keepHistory && (n.lexerState = N.save()), this.current++;
18330
+ this.options.keepHistory && (i.lexerState = O.save()), this.current++;
18332
18331
  }
18333
- return n && (this.lexerState = N.save()), this.results = this.finish(), this;
18334
- }, O.prototype.reportLexerError = function(I) {
18335
- var N, s, t = I.token;
18336
- return t ? (N = "input " + JSON.stringify(t.text[0]) + " (lexer error)", s = this.lexer.formatError(t, "Syntax error")) : (N = "input (lexer error)", s = I.message), this.reportErrorCommon(s, N);
18337
- }, O.prototype.reportError = function(I) {
18338
- var N = (I.type ? I.type + " token: " : "") + JSON.stringify(I.value !== void 0 ? I.value : I), s = this.lexer.formatError(I, "Syntax error");
18339
- return this.reportErrorCommon(s, N);
18340
- }, O.prototype.reportErrorCommon = function(I, N) {
18341
- var s = [];
18342
- s.push(I);
18343
- var t = this.table.length - 2, n = this.table[t], P = n.states.filter(function(o) {
18344
- var G = o.rule.symbols[o.dot];
18332
+ return i && (this.lexerState = O.save()), this.results = this.finish(), this;
18333
+ }, N.prototype.reportLexerError = function(I) {
18334
+ var O, C, t = I.token;
18335
+ return t ? (O = "input " + JSON.stringify(t.text[0]) + " (lexer error)", C = this.lexer.formatError(t, "Syntax error")) : (O = "input (lexer error)", C = I.message), this.reportErrorCommon(C, O);
18336
+ }, N.prototype.reportError = function(I) {
18337
+ var O = (I.type ? I.type + " token: " : "") + JSON.stringify(I.value !== void 0 ? I.value : I), C = this.lexer.formatError(I, "Syntax error");
18338
+ return this.reportErrorCommon(C, O);
18339
+ }, N.prototype.reportErrorCommon = function(I, O) {
18340
+ var C = [];
18341
+ C.push(I);
18342
+ var t = this.table.length - 2, i = this.table[t], o = i.states.filter(function(P) {
18343
+ var G = P.rule.symbols[P.dot];
18345
18344
  return G && typeof G != "string";
18346
18345
  });
18347
- if (P.length === 0)
18348
- s.push("Unexpected " + N + `. I did not expect any more input. Here is the state of my parse table:
18349
- `), this.displayStateStack(n.states, s);
18346
+ if (o.length === 0)
18347
+ C.push("Unexpected " + O + `. I did not expect any more input. Here is the state of my parse table:
18348
+ `), this.displayStateStack(i.states, C);
18350
18349
  else {
18351
- s.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
18350
+ C.push("Unexpected " + O + `. Instead, I was expecting to see one of the following:
18352
18351
  `);
18353
- var M = P.map(function(o) {
18354
- return this.buildFirstStateStack(o, []) || [o];
18352
+ var M = o.map(function(P) {
18353
+ return this.buildFirstStateStack(P, []) || [P];
18355
18354
  }, this);
18356
- M.forEach(function(o) {
18357
- var G = o[0], a = G.rule.symbols[G.dot], H = this.getSymbolDisplay(a);
18358
- s.push("A " + H + " based on:"), this.displayStateStack(o, s);
18355
+ M.forEach(function(P) {
18356
+ var G = P[0], a = G.rule.symbols[G.dot], H = this.getSymbolDisplay(a);
18357
+ C.push("A " + H + " based on:"), this.displayStateStack(P, C);
18359
18358
  }, this);
18360
18359
  }
18361
- return s.push(""), s.join(`
18360
+ return C.push(""), C.join(`
18362
18361
  `);
18363
- }, O.prototype.displayStateStack = function(I, N) {
18364
- for (var s, t = 0, n = 0; n < I.length; n++) {
18365
- var P = I[n], M = P.rule.toString(P.dot);
18366
- M === s ? t++ : (t > 0 && N.push(" ^ " + t + " more lines identical to this"), t = 0, N.push(" " + M)), s = M;
18362
+ }, N.prototype.displayStateStack = function(I, O) {
18363
+ for (var C, t = 0, i = 0; i < I.length; i++) {
18364
+ var o = I[i], M = o.rule.toString(o.dot);
18365
+ M === C ? t++ : (t > 0 && O.push(" ^ " + t + " more lines identical to this"), t = 0, O.push(" " + M)), C = M;
18367
18366
  }
18368
- }, O.prototype.getSymbolDisplay = function(I) {
18369
- return C(I);
18370
- }, O.prototype.buildFirstStateStack = function(I, N) {
18371
- if (N.indexOf(I) !== -1)
18367
+ }, N.prototype.getSymbolDisplay = function(I) {
18368
+ return s(I);
18369
+ }, N.prototype.buildFirstStateStack = function(I, O) {
18370
+ if (O.indexOf(I) !== -1)
18372
18371
  return null;
18373
18372
  if (I.wantedBy.length === 0)
18374
18373
  return [I];
18375
- var s = I.wantedBy[0], t = [I].concat(N), n = this.buildFirstStateStack(s, t);
18376
- return n === null ? null : [I].concat(n);
18377
- }, O.prototype.save = function() {
18374
+ var C = I.wantedBy[0], t = [I].concat(O), i = this.buildFirstStateStack(C, t);
18375
+ return i === null ? null : [I].concat(i);
18376
+ }, N.prototype.save = function() {
18378
18377
  var I = this.table[this.current];
18379
18378
  return I.lexerState = this.lexerState, I;
18380
- }, O.prototype.restore = function(I) {
18381
- var N = I.index;
18382
- this.current = N, this.table[N] = I, this.table.splice(N + 1), this.lexerState = I.lexerState, this.results = this.finish();
18383
- }, O.prototype.rewind = function(I) {
18379
+ }, N.prototype.restore = function(I) {
18380
+ var O = I.index;
18381
+ this.current = O, this.table[O] = I, this.table.splice(O + 1), this.lexerState = I.lexerState, this.results = this.finish();
18382
+ }, N.prototype.rewind = function(I) {
18384
18383
  if (!this.options.keepHistory)
18385
18384
  throw new Error("set option `keepHistory` to enable rewinding");
18386
18385
  this.restore(this.table[I]);
18387
- }, O.prototype.finish = function() {
18388
- var I = [], N = this.grammar.start, s = this.table[this.table.length - 1];
18389
- return s.states.forEach(function(t) {
18390
- t.rule.name === N && t.dot === t.rule.symbols.length && t.reference === 0 && t.data !== O.fail && I.push(t);
18386
+ }, N.prototype.finish = function() {
18387
+ var I = [], O = this.grammar.start, C = this.table[this.table.length - 1];
18388
+ return C.states.forEach(function(t) {
18389
+ t.rule.name === O && t.dot === t.rule.symbols.length && t.reference === 0 && t.data !== N.fail && I.push(t);
18391
18390
  }), I.map(function(t) {
18392
18391
  return t.data;
18393
18392
  });
18394
18393
  };
18395
- function C(I) {
18396
- var N = typeof I;
18397
- if (N === "string")
18394
+ function s(I) {
18395
+ var O = typeof I;
18396
+ if (O === "string")
18398
18397
  return I;
18399
- if (N === "object") {
18398
+ if (O === "object") {
18400
18399
  if (I.literal)
18401
18400
  return JSON.stringify(I.literal);
18402
18401
  if (I instanceof RegExp)
@@ -18409,10 +18408,10 @@ var PR = { exports: {} };
18409
18408
  }
18410
18409
  }
18411
18410
  function _(I) {
18412
- var N = typeof I;
18413
- if (N === "string")
18411
+ var O = typeof I;
18412
+ if (O === "string")
18414
18413
  return I;
18415
- if (N === "object") {
18414
+ if (O === "object") {
18416
18415
  if (I.literal)
18417
18416
  return JSON.stringify(I.literal);
18418
18417
  if (I instanceof RegExp)
@@ -18425,13 +18424,13 @@ var PR = { exports: {} };
18425
18424
  }
18426
18425
  }
18427
18426
  return {
18428
- Parser: O,
18427
+ Parser: N,
18429
18428
  Grammar: S,
18430
18429
  Rule: E
18431
18430
  };
18432
18431
  });
18433
- })(PR);
18434
- var vI = PR.exports;
18432
+ })(oR);
18433
+ var vI = oR.exports;
18435
18434
  const QI = /* @__PURE__ */ xI(vI);
18436
18435
  function ZI(T) {
18437
18436
  return T.map(qI).map(jI).map(kI).map(zI).map(EO);
@@ -18493,7 +18492,7 @@ class GR {
18493
18492
  save() {
18494
18493
  }
18495
18494
  formatError(E) {
18496
- const { line: R, col: A } = oR(this.input, E.start);
18495
+ const { line: R, col: A } = PR(this.input, E.start);
18497
18496
  return `Parse error at token: ${E.text} at line ${R} column ${A}`;
18498
18497
  }
18499
18498
  has(E) {
@@ -18788,12 +18787,12 @@ const c = new GR((T) => []), w = ([[T]]) => T, d = (T) => ({
18788
18787
  {
18789
18788
  name: "between_predicate",
18790
18789
  symbols: [c.has("BETWEEN") ? { type: "BETWEEN" } : BETWEEN, "_", "andless_expression_chain", "_", c.has("AND") ? { type: "AND" } : AND, "_", "andless_expression"],
18791
- postprocess: ([T, E, R, A, S, e, O]) => ({
18790
+ postprocess: ([T, E, R, A, S, e, N]) => ({
18792
18791
  type: U.between_predicate,
18793
18792
  betweenKw: d(T),
18794
18793
  expr1: AO(R, { leading: E, trailing: A }),
18795
18794
  andKw: d(S),
18796
- expr2: [f(O, { leading: e })]
18795
+ expr2: [f(N, { leading: e })]
18797
18796
  })
18798
18797
  },
18799
18798
  { name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: gE },
@@ -18932,18 +18931,18 @@ function OO(T) {
18932
18931
  return {
18933
18932
  parse: (S, e) => {
18934
18933
  E = e;
18935
- const { results: O } = A.feed(S);
18936
- if (O.length === 1)
18937
- return O[0];
18938
- throw O.length === 0 ? new Error("Parse error: Invalid SQL") : new Error(`Parse error: Ambiguous grammar
18939
- ${JSON.stringify(O, void 0, 2)}`);
18934
+ const { results: N } = A.feed(S);
18935
+ if (N.length === 1)
18936
+ return N[0];
18937
+ throw N.length === 0 ? new Error("Parse error: Invalid SQL") : new Error(`Parse error: Ambiguous grammar
18938
+ ${JSON.stringify(N, void 0, 2)}`);
18940
18939
  }
18941
18940
  };
18942
18941
  }
18943
- var i;
18942
+ var n;
18944
18943
  (function(T) {
18945
18944
  T[T.SPACE = 0] = "SPACE", T[T.NO_SPACE = 1] = "NO_SPACE", T[T.NO_NEWLINE = 2] = "NO_NEWLINE", T[T.NEWLINE = 3] = "NEWLINE", T[T.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", T[T.INDENT = 5] = "INDENT", T[T.SINGLE_INDENT = 6] = "SINGLE_INDENT";
18946
- })(i = i || (i = {}));
18945
+ })(n = n || (n = {}));
18947
18946
  class lR {
18948
18947
  constructor(E) {
18949
18948
  this.indentation = E, this.items = [];
@@ -18954,26 +18953,26 @@ class lR {
18954
18953
  add(...E) {
18955
18954
  for (const R of E)
18956
18955
  switch (R) {
18957
- case i.SPACE:
18958
- this.items.push(i.SPACE);
18956
+ case n.SPACE:
18957
+ this.items.push(n.SPACE);
18959
18958
  break;
18960
- case i.NO_SPACE:
18959
+ case n.NO_SPACE:
18961
18960
  this.trimHorizontalWhitespace();
18962
18961
  break;
18963
- case i.NO_NEWLINE:
18962
+ case n.NO_NEWLINE:
18964
18963
  this.trimWhitespace();
18965
18964
  break;
18966
- case i.NEWLINE:
18967
- this.trimHorizontalWhitespace(), this.addNewline(i.NEWLINE);
18965
+ case n.NEWLINE:
18966
+ this.trimHorizontalWhitespace(), this.addNewline(n.NEWLINE);
18968
18967
  break;
18969
- case i.MANDATORY_NEWLINE:
18970
- this.trimHorizontalWhitespace(), this.addNewline(i.MANDATORY_NEWLINE);
18968
+ case n.MANDATORY_NEWLINE:
18969
+ this.trimHorizontalWhitespace(), this.addNewline(n.MANDATORY_NEWLINE);
18971
18970
  break;
18972
- case i.INDENT:
18971
+ case n.INDENT:
18973
18972
  this.addIndentation();
18974
18973
  break;
18975
- case i.SINGLE_INDENT:
18976
- this.items.push(i.SINGLE_INDENT);
18974
+ case n.SINGLE_INDENT:
18975
+ this.items.push(n.SINGLE_INDENT);
18977
18976
  break;
18978
18977
  default:
18979
18978
  this.items.push(R);
@@ -18990,10 +18989,10 @@ class lR {
18990
18989
  addNewline(E) {
18991
18990
  if (this.items.length > 0)
18992
18991
  switch (eE(this.items)) {
18993
- case i.NEWLINE:
18992
+ case n.NEWLINE:
18994
18993
  this.items.pop(), this.items.push(E);
18995
18994
  break;
18996
- case i.MANDATORY_NEWLINE:
18995
+ case n.MANDATORY_NEWLINE:
18997
18996
  break;
18998
18997
  default:
18999
18998
  this.items.push(E);
@@ -19002,7 +19001,7 @@ class lR {
19002
19001
  }
19003
19002
  addIndentation() {
19004
19003
  for (let E = 0; E < this.indentation.getLevel(); E++)
19005
- this.items.push(i.SINGLE_INDENT);
19004
+ this.items.push(n.SINGLE_INDENT);
19006
19005
  }
19007
19006
  /**
19008
19007
  * Returns the final SQL string.
@@ -19018,20 +19017,20 @@ class lR {
19018
19017
  }
19019
19018
  itemToString(E) {
19020
19019
  switch (E) {
19021
- case i.SPACE:
19020
+ case n.SPACE:
19022
19021
  return " ";
19023
- case i.NEWLINE:
19024
- case i.MANDATORY_NEWLINE:
19022
+ case n.NEWLINE:
19023
+ case n.MANDATORY_NEWLINE:
19025
19024
  return `
19026
19025
  `;
19027
- case i.SINGLE_INDENT:
19026
+ case n.SINGLE_INDENT:
19028
19027
  return this.indentation.getSingleIndent();
19029
19028
  default:
19030
19029
  return E;
19031
19030
  }
19032
19031
  }
19033
19032
  }
19034
- const NO = (T) => T === i.SPACE || T === i.SINGLE_INDENT, tO = (T) => T === i.SPACE || T === i.SINGLE_INDENT || T === i.NEWLINE;
19033
+ const NO = (T) => T === n.SPACE || T === n.SINGLE_INDENT, tO = (T) => T === n.SPACE || T === n.SINGLE_INDENT || T === n.NEWLINE;
19035
19034
  function yT(T, E) {
19036
19035
  if (E === "standard")
19037
19036
  return T;
@@ -19103,9 +19102,9 @@ class CO extends lR {
19103
19102
  if (typeof E == "string")
19104
19103
  this.length += E.length, this.trailingSpace = !1;
19105
19104
  else {
19106
- if (E === i.MANDATORY_NEWLINE || E === i.NEWLINE)
19105
+ if (E === n.MANDATORY_NEWLINE || E === n.NEWLINE)
19107
19106
  throw new vE();
19108
- 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--);
19107
+ E === n.INDENT || E === n.SINGLE_INDENT || E === n.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (E === n.NO_NEWLINE || E === n.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
19109
19108
  }
19110
19109
  }
19111
19110
  }
@@ -19201,23 +19200,23 @@ class _E {
19201
19200
  }), this.formatNode(E.parenthesis);
19202
19201
  }
19203
19202
  formatPropertyAccess(E) {
19204
- this.formatNode(E.object), this.layout.add(i.NO_SPACE, E.operator), this.formatNode(E.property);
19203
+ this.formatNode(E.object), this.layout.add(n.NO_SPACE, E.operator), this.formatNode(E.property);
19205
19204
  }
19206
19205
  formatParenthesis(E) {
19207
19206
  const R = this.formatInlineExpression(E.children);
19208
- R ? (this.layout.add(E.openParen), this.layout.add(...R.getLayoutItems()), this.layout.add(i.NO_SPACE, E.closeParen, i.SPACE)) : (this.layout.add(E.openParen, i.NEWLINE), k(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));
19207
+ R ? (this.layout.add(E.openParen), this.layout.add(...R.getLayoutItems()), this.layout.add(n.NO_SPACE, E.closeParen, n.SPACE)) : (this.layout.add(E.openParen, n.NEWLINE), k(this.cfg) ? (this.layout.add(n.INDENT), this.layout = this.formatSubExpression(E.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(n.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(n.NEWLINE, n.INDENT, E.closeParen, n.SPACE));
19209
19208
  }
19210
19209
  formatBetweenPredicate(E) {
19211
- 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);
19210
+ this.layout.add(this.showKw(E.betweenKw), n.SPACE), this.layout = this.formatSubExpression(E.expr1), this.layout.add(n.NO_SPACE, n.SPACE, this.showNonTabularKw(E.andKw), n.SPACE), this.layout = this.formatSubExpression(E.expr2), this.layout.add(n.SPACE);
19212
19211
  }
19213
19212
  formatCaseExpression(E) {
19214
- 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);
19213
+ 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(n.NEWLINE, n.INDENT), this.formatNode(E.endKw);
19215
19214
  }
19216
19215
  formatCaseWhen(E) {
19217
- 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);
19216
+ this.layout.add(n.NEWLINE, n.INDENT), this.formatNode(E.whenKw), this.layout = this.formatSubExpression(E.condition), this.formatNode(E.thenKw), this.layout = this.formatSubExpression(E.result);
19218
19217
  }
19219
19218
  formatCaseElse(E) {
19220
- this.layout.add(i.NEWLINE, i.INDENT), this.formatNode(E.elseKw), this.layout = this.formatSubExpression(E.result);
19219
+ this.layout.add(n.NEWLINE, n.INDENT), this.formatNode(E.elseKw), this.layout = this.formatSubExpression(E.result);
19221
19220
  }
19222
19221
  formatClause(E) {
19223
19222
  this.isOnelineClause(E) ? this.formatClauseInOnelineStyle(E) : k(this.cfg) ? this.formatClauseInTabularStyle(E) : this.formatClauseInIndentedStyle(E);
@@ -19226,39 +19225,39 @@ class _E {
19226
19225
  return k(this.cfg) ? this.dialectCfg.tabularOnelineClauses[E.nameKw.text] : this.dialectCfg.onelineClauses[E.nameKw.text];
19227
19226
  }
19228
19227
  formatClauseInIndentedStyle(E) {
19229
- 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();
19228
+ this.layout.add(n.NEWLINE, n.INDENT, this.showKw(E.nameKw), n.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(n.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
19230
19229
  }
19231
19230
  formatClauseInOnelineStyle(E) {
19232
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.SPACE), this.layout = this.formatSubExpression(E.children);
19231
+ this.layout.add(n.NEWLINE, n.INDENT, this.showKw(E.nameKw), n.SPACE), this.layout = this.formatSubExpression(E.children);
19233
19232
  }
19234
19233
  formatClauseInTabularStyle(E) {
19235
- 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();
19234
+ this.layout.add(n.NEWLINE, n.INDENT, this.showKw(E.nameKw), n.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
19236
19235
  }
19237
19236
  formatSetOperation(E) {
19238
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.NEWLINE), this.layout.add(i.INDENT), this.layout = this.formatSubExpression(E.children);
19237
+ this.layout.add(n.NEWLINE, n.INDENT, this.showKw(E.nameKw), n.NEWLINE), this.layout.add(n.INDENT), this.layout = this.formatSubExpression(E.children);
19239
19238
  }
19240
19239
  formatLimitClause(E) {
19241
19240
  this.withComments(E.limitKw, () => {
19242
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.limitKw));
19243
- }), this.layout.indentation.increaseTopLevel(), k(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();
19241
+ this.layout.add(n.NEWLINE, n.INDENT, this.showKw(E.limitKw));
19242
+ }), this.layout.indentation.increaseTopLevel(), k(this.cfg) ? this.layout.add(n.SPACE) : this.layout.add(n.NEWLINE, n.INDENT), E.offset ? (this.layout = this.formatSubExpression(E.offset), this.layout.add(n.NO_SPACE, ",", n.SPACE), this.layout = this.formatSubExpression(E.count)) : this.layout = this.formatSubExpression(E.count), this.layout.indentation.decreaseTopLevel();
19244
19243
  }
19245
19244
  formatAllColumnsAsterisk(E) {
19246
- this.layout.add("*", i.SPACE);
19245
+ this.layout.add("*", n.SPACE);
19247
19246
  }
19248
19247
  formatLiteral(E) {
19249
- this.layout.add(E.text, i.SPACE);
19248
+ this.layout.add(E.text, n.SPACE);
19250
19249
  }
19251
19250
  formatIdentifier(E) {
19252
- this.layout.add(this.showIdentifier(E), i.SPACE);
19251
+ this.layout.add(this.showIdentifier(E), n.SPACE);
19253
19252
  }
19254
19253
  formatParameter(E) {
19255
- this.layout.add(this.params.get(E), i.SPACE);
19254
+ this.layout.add(this.params.get(E), n.SPACE);
19256
19255
  }
19257
19256
  formatOperator({ text: E }) {
19258
- 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);
19257
+ this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(E) ? this.layout.add(n.NO_SPACE, E) : E === ":" ? this.layout.add(n.NO_SPACE, E, n.SPACE) : this.layout.add(E, n.SPACE);
19259
19258
  }
19260
19259
  formatComma(E) {
19261
- this.inline ? this.layout.add(i.NO_SPACE, ",", i.SPACE) : this.layout.add(i.NO_SPACE, ",", i.NEWLINE, i.INDENT);
19260
+ this.inline ? this.layout.add(n.NO_SPACE, ",", n.SPACE) : this.layout.add(n.NO_SPACE, ",", n.NEWLINE, n.INDENT);
19262
19261
  }
19263
19262
  withComments(E, R) {
19264
19263
  this.formatComments(E.leadingComments), R(), this.formatComments(E.trailingComments);
@@ -19269,12 +19268,12 @@ class _E {
19269
19268
  });
19270
19269
  }
19271
19270
  formatLineComment(E) {
19272
- KE(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);
19271
+ KE(E.precedingWhitespace || "") ? this.layout.add(n.NEWLINE, n.INDENT, E.text, n.MANDATORY_NEWLINE, n.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(n.NO_NEWLINE, n.SPACE, E.text, n.MANDATORY_NEWLINE, n.INDENT) : this.layout.add(E.text, n.MANDATORY_NEWLINE, n.INDENT);
19273
19272
  }
19274
19273
  formatBlockComment(E) {
19275
19274
  E.type === U.block_comment && this.isMultilineBlockComment(E) ? (this.splitBlockComment(E.text).forEach((R) => {
19276
- this.layout.add(i.NEWLINE, i.INDENT, R);
19277
- }), this.layout.add(i.NEWLINE, i.INDENT)) : this.layout.add(E.text, i.SPACE);
19275
+ this.layout.add(n.NEWLINE, n.INDENT, R);
19276
+ }), this.layout.add(n.NEWLINE, n.INDENT)) : this.layout.add(E.text, n.SPACE);
19278
19277
  }
19279
19278
  isMultilineBlockComment(E) {
19280
19279
  return KE(E.text) || KE(E.precedingWhitespace || "");
@@ -19358,16 +19357,16 @@ class _E {
19358
19357
  }
19359
19358
  }
19360
19359
  formatJoin(E) {
19361
- k(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);
19360
+ k(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(n.NEWLINE, n.INDENT, this.showKw(E), n.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(n.NEWLINE, n.INDENT, this.showKw(E), n.SPACE);
19362
19361
  }
19363
19362
  formatKeyword(E) {
19364
- this.layout.add(this.showKw(E), i.SPACE);
19363
+ this.layout.add(this.showKw(E), n.SPACE);
19365
19364
  }
19366
19365
  formatLogicalOperator(E) {
19367
- this.cfg.logicalOperatorNewline === "before" ? k(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);
19366
+ this.cfg.logicalOperatorNewline === "before" ? k(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(n.NEWLINE, n.INDENT, this.showKw(E), n.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(n.NEWLINE, n.INDENT, this.showKw(E), n.SPACE) : this.layout.add(this.showKw(E), n.NEWLINE, n.INDENT);
19368
19367
  }
19369
19368
  formatDataType(E) {
19370
- this.layout.add(this.showDataType(E), i.SPACE);
19369
+ this.layout.add(this.showDataType(E), n.SPACE);
19371
19370
  }
19372
19371
  showKw(E) {
19373
19372
  return KT(E.tokenType) ? yT(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
@@ -19447,7 +19446,7 @@ class LO {
19447
19446
  params: this.params,
19448
19447
  layout: new lR(new cR(gI(this.cfg)))
19449
19448
  }).format(E.children);
19450
- return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? R.add(i.NEWLINE, ";") : R.add(i.NO_NEWLINE, ";")), R.toString();
19449
+ return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? R.add(n.NEWLINE, ";") : R.add(n.NO_NEWLINE, ";")), R.toString();
19451
19450
  }
19452
19451
  }
19453
19452
  class sE extends Error {
@@ -19518,12 +19517,12 @@ const uR = {
19518
19517
  linesBetweenQueries: 1,
19519
19518
  denseOperators: !1,
19520
19519
  newlineBeforeSemicolon: !1
19521
- }, oO = (T, E = {}) => {
19520
+ }, PO = (T, E = {}) => {
19522
19521
  if (typeof E.language == "string" && !DO.includes(E.language))
19523
19522
  throw new sE(`Unsupported SQL dialect: ${E.language}`);
19524
19523
  const R = uR[E.language || "sql"];
19525
- return PO(T, Object.assign(Object.assign({}, E), { dialect: uI[R] }));
19526
- }, PO = (T, E) => {
19524
+ return oO(T, Object.assign(Object.assign({}, E), { dialect: uI[R] }));
19525
+ }, oO = (T, E) => {
19527
19526
  var { dialect: R } = E, A = iO(E, ["dialect"]);
19528
19527
  if (typeof T != "string")
19529
19528
  throw new Error("Invalid query argument. Expected string, instead got " + typeof T);
@@ -19573,41 +19572,41 @@ function lO(T) {
19573
19572
  return "postgres";
19574
19573
  }
19575
19574
  async function HO(T, E, R) {
19576
- var _, I, N, s;
19575
+ var _, I, O, C;
19577
19576
  const A = R.validateQuery(T);
19578
19577
  if (!A.isValid)
19579
19578
  throw new Error(`Query validation failed: ${A.errors.join(", ")}`);
19580
19579
  const S = /* @__PURE__ */ new Set();
19581
19580
  (_ = T.measures) == null || _.forEach((t) => {
19582
- const n = t.split(".")[0];
19583
- S.add(n);
19581
+ const i = t.split(".")[0];
19582
+ S.add(i);
19584
19583
  }), (I = T.dimensions) == null || I.forEach((t) => {
19585
- const n = t.split(".")[0];
19586
- S.add(n);
19587
- }), (N = T.timeDimensions) == null || N.forEach((t) => {
19588
- const n = t.dimension.split(".")[0];
19589
- S.add(n);
19590
- }), (s = T.filters) == null || s.forEach((t) => {
19584
+ const i = t.split(".")[0];
19585
+ S.add(i);
19586
+ }), (O = T.timeDimensions) == null || O.forEach((t) => {
19587
+ const i = t.dimension.split(".")[0];
19588
+ S.add(i);
19589
+ }), (C = T.filters) == null || C.forEach((t) => {
19591
19590
  if ("member" in t) {
19592
- const n = t.member.split(".")[0];
19593
- S.add(n);
19591
+ const i = t.member.split(".")[0];
19592
+ S.add(i);
19594
19593
  }
19595
19594
  });
19596
19595
  const e = S.size > 1;
19597
- let O;
19596
+ let N;
19598
19597
  if (e)
19599
- O = await R.generateMultiCubeSQL(T, E);
19598
+ N = await R.generateMultiCubeSQL(T, E);
19600
19599
  else {
19601
19600
  const t = Array.from(S)[0];
19602
- O = await R.generateSQL(t, T, E);
19601
+ N = await R.generateSQL(t, T, E);
19603
19602
  }
19604
- const C = Array.from(S).map((t) => {
19605
- var n, P;
19603
+ const s = Array.from(S).map((t) => {
19604
+ var i, o;
19606
19605
  return {
19607
19606
  cube: t,
19608
19607
  query: {
19609
- measures: ((n = T.measures) == null ? void 0 : n.filter((M) => M.startsWith(t + "."))) || [],
19610
- dimensions: ((P = T.dimensions) == null ? void 0 : P.filter((M) => M.startsWith(t + "."))) || [],
19608
+ measures: ((i = T.measures) == null ? void 0 : i.filter((M) => M.startsWith(t + "."))) || [],
19609
+ dimensions: ((o = T.dimensions) == null ? void 0 : o.filter((M) => M.startsWith(t + "."))) || [],
19611
19610
  filters: T.filters || [],
19612
19611
  timeDimensions: T.timeDimensions || [],
19613
19612
  order: T.order || {},
@@ -19618,16 +19617,16 @@ async function HO(T, E, R) {
19618
19617
  });
19619
19618
  return {
19620
19619
  queryType: "regularQuery",
19621
- normalizedQueries: C,
19620
+ normalizedQueries: s,
19622
19621
  queryOrder: Array.from(S),
19623
- transformedQueries: C,
19622
+ transformedQueries: s,
19624
19623
  pivotQuery: {
19625
19624
  query: T,
19626
19625
  cubes: Array.from(S)
19627
19626
  },
19628
19627
  sql: {
19629
- sql: [O.sql],
19630
- params: O.params || []
19628
+ sql: [N.sql],
19629
+ params: N.params || []
19631
19630
  },
19632
19631
  complexity: MO(T),
19633
19632
  valid: !0,
@@ -19637,14 +19636,14 @@ async function HO(T, E, R) {
19637
19636
  };
19638
19637
  }
19639
19638
  function BO(T, E, R) {
19640
- const A = lO(R), S = UO(), e = (/* @__PURE__ */ new Date()).toISOString(), O = GO(T);
19639
+ const A = lO(R), S = UO(), e = (/* @__PURE__ */ new Date()).toISOString(), N = GO(T);
19641
19640
  return {
19642
19641
  queryType: "regularQuery",
19643
19642
  results: [{
19644
19643
  query: T,
19645
19644
  lastRefreshTime: e,
19646
19645
  usedPreAggregations: {},
19647
- transformedQuery: O,
19646
+ transformedQuery: N,
19648
19647
  requestId: S,
19649
19648
  annotation: E.annotation,
19650
19649
  dataSource: "default",
@@ -19663,7 +19662,7 @@ function BO(T, E, R) {
19663
19662
  }
19664
19663
  function $T(T, E) {
19665
19664
  try {
19666
- return oO(T, {
19665
+ return PO(T, {
19667
19666
  language: {
19668
19667
  postgres: "postgresql",
19669
19668
  mysql: "mysql",
@@ -19797,24 +19796,24 @@ class cO {
19797
19796
  */
19798
19797
  generateCubeMetadata(E) {
19799
19798
  const R = Object.keys(E.measures), A = Object.keys(E.dimensions), S = new Array(R.length), e = new Array(A.length);
19800
- for (let O = 0; O < R.length; O++) {
19801
- const C = R[O], _ = E.measures[C];
19802
- S[O] = {
19803
- name: `${E.name}.${C}`,
19804
- title: _.title || C,
19805
- shortTitle: _.title || C,
19799
+ for (let N = 0; N < R.length; N++) {
19800
+ const s = R[N], _ = E.measures[s];
19801
+ S[N] = {
19802
+ name: `${E.name}.${s}`,
19803
+ title: _.title || s,
19804
+ shortTitle: _.title || s,
19806
19805
  type: _.type,
19807
19806
  format: void 0,
19808
19807
  // Measure doesn't have format field
19809
19808
  description: _.description
19810
19809
  };
19811
19810
  }
19812
- for (let O = 0; O < A.length; O++) {
19813
- const C = A[O], _ = E.dimensions[C];
19814
- e[O] = {
19815
- name: `${E.name}.${C}`,
19816
- title: _.title || C,
19817
- shortTitle: _.title || C,
19811
+ for (let N = 0; N < A.length; N++) {
19812
+ const s = A[N], _ = E.dimensions[s];
19813
+ e[N] = {
19814
+ name: `${E.name}.${s}`,
19815
+ title: _.title || s,
19816
+ shortTitle: _.title || s,
19818
19817
  type: _.type,
19819
19818
  format: void 0,
19820
19819
  // Dimension doesn't have format field
@@ -19840,10 +19839,10 @@ class cO {
19840
19839
  throw new Error(`Cube '${E}' not found`);
19841
19840
  if (!this.dbExecutor)
19842
19841
  throw new Error("Database executor not configured");
19843
- const O = await new UE(this.dbExecutor).generateSQL(S, R, A), C = this.dbExecutor.getEngineType();
19842
+ const N = await new UE(this.dbExecutor).generateSQL(S, R, A), s = this.dbExecutor.getEngineType();
19844
19843
  return {
19845
- sql: $T(O.sql, C),
19846
- params: O.params
19844
+ sql: $T(N.sql, s),
19845
+ params: N.params
19847
19846
  };
19848
19847
  }
19849
19848
  /**
@@ -19902,48 +19901,48 @@ function HR(T, E) {
19902
19901
  const R = [], A = /* @__PURE__ */ new Set();
19903
19902
  if (E.measures)
19904
19903
  for (const S of E.measures) {
19905
- const [e, O] = S.split(".");
19906
- if (!e || !O) {
19904
+ const [e, N] = S.split(".");
19905
+ if (!e || !N) {
19907
19906
  R.push(`Invalid measure format: ${S}. Expected format: 'CubeName.fieldName'`);
19908
19907
  continue;
19909
19908
  }
19910
19909
  A.add(e);
19911
- const C = T.get(e);
19912
- if (!C) {
19910
+ const s = T.get(e);
19911
+ if (!s) {
19913
19912
  R.push(`Cube '${e}' not found (referenced in measure '${S}')`);
19914
19913
  continue;
19915
19914
  }
19916
- C.measures[O] || R.push(`Measure '${O}' not found on cube '${e}'`);
19915
+ s.measures[N] || R.push(`Measure '${N}' not found on cube '${e}'`);
19917
19916
  }
19918
19917
  if (E.dimensions)
19919
19918
  for (const S of E.dimensions) {
19920
- const [e, O] = S.split(".");
19921
- if (!e || !O) {
19919
+ const [e, N] = S.split(".");
19920
+ if (!e || !N) {
19922
19921
  R.push(`Invalid dimension format: ${S}. Expected format: 'CubeName.fieldName'`);
19923
19922
  continue;
19924
19923
  }
19925
19924
  A.add(e);
19926
- const C = T.get(e);
19927
- if (!C) {
19925
+ const s = T.get(e);
19926
+ if (!s) {
19928
19927
  R.push(`Cube '${e}' not found (referenced in dimension '${S}')`);
19929
19928
  continue;
19930
19929
  }
19931
- C.dimensions[O] || R.push(`Dimension '${O}' not found on cube '${e}'`);
19930
+ s.dimensions[N] || R.push(`Dimension '${N}' not found on cube '${e}'`);
19932
19931
  }
19933
19932
  if (E.timeDimensions)
19934
19933
  for (const S of E.timeDimensions) {
19935
- const [e, O] = S.dimension.split(".");
19936
- if (!e || !O) {
19934
+ const [e, N] = S.dimension.split(".");
19935
+ if (!e || !N) {
19937
19936
  R.push(`Invalid timeDimension format: ${S.dimension}. Expected format: 'CubeName.fieldName'`);
19938
19937
  continue;
19939
19938
  }
19940
19939
  A.add(e);
19941
- const C = T.get(e);
19942
- if (!C) {
19940
+ const s = T.get(e);
19941
+ if (!s) {
19943
19942
  R.push(`Cube '${e}' not found (referenced in timeDimension '${S.dimension}')`);
19944
19943
  continue;
19945
19944
  }
19946
- C.dimensions[O] || R.push(`TimeDimension '${O}' not found on cube '${e}' (must be a dimension with time type)`);
19945
+ s.dimensions[N] || R.push(`TimeDimension '${N}' not found on cube '${e}' (must be a dimension with time type)`);
19947
19946
  }
19948
19947
  if (E.filters)
19949
19948
  for (const S of E.filters)
@@ -19955,8 +19954,8 @@ function HR(T, E) {
19955
19954
  }
19956
19955
  function BR(T, E, R, A) {
19957
19956
  if ("and" in T || "or" in T) {
19958
- const C = T.and || T.or || [];
19959
- for (const _ of C)
19957
+ const s = T.and || T.or || [];
19958
+ for (const _ of s)
19960
19959
  BR(_, E, R, A);
19961
19960
  return;
19962
19961
  }
@@ -19970,12 +19969,12 @@ function BR(T, E, R, A) {
19970
19969
  return;
19971
19970
  }
19972
19971
  A.add(S);
19973
- const O = E.get(S);
19974
- if (!O) {
19972
+ const N = E.get(S);
19973
+ if (!N) {
19975
19974
  R.push(`Cube '${S}' not found (referenced in filter '${T.member}')`);
19976
19975
  return;
19977
19976
  }
19978
- !O.dimensions[e] && !O.measures[e] && R.push(`Filter field '${e}' not found on cube '${S}' (must be a dimension or measure)`);
19977
+ !N.dimensions[e] && !N.measures[e] && R.push(`Filter field '${e}' not found on cube '${S}' (must be a dimension or measure)`);
19979
19978
  }
19980
19979
  new cO();
19981
19980
  export {