drizzle-cube 0.1.34 → 0.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  const h = Symbol.for("drizzle:entityKind");
2
- function H(T, E) {
2
+ function m(T, E) {
3
3
  if (!T || typeof T != "object")
4
4
  return !1;
5
5
  if (T instanceof E)
@@ -142,7 +142,7 @@ class u {
142
142
  constructor(E) {
143
143
  this.queryChunks = E;
144
144
  for (const R of E)
145
- if (H(R, W)) {
145
+ if (m(R, W)) {
146
146
  const A = R[W.Symbol.Schema];
147
147
  this.usedTables.push(
148
148
  A === void 0 ? R[W.Symbol.Name] : A + "." + R[W.Symbol.Name]
@@ -177,71 +177,71 @@ class u {
177
177
  escapeParam: N,
178
178
  prepareTyping: t,
179
179
  inlineParams: r,
180
- paramStartIndex: I
180
+ paramStartIndex: O
181
181
  } = A;
182
- return iR(E.map((O) => {
183
- if (H(O, d))
184
- return { sql: O.value.join(""), params: [] };
185
- if (H(O, JE))
186
- return { sql: S(O.value), params: [] };
187
- if (O === void 0)
182
+ return iR(E.map((I) => {
183
+ if (m(I, d))
184
+ return { sql: I.value.join(""), params: [] };
185
+ if (m(I, JE))
186
+ return { sql: S(I.value), params: [] };
187
+ if (I === void 0)
188
188
  return { sql: "", params: [] };
189
- if (Array.isArray(O)) {
189
+ if (Array.isArray(I)) {
190
190
  const s = [new d("(")];
191
- for (const [L, a] of O.entries())
192
- s.push(a), L < O.length - 1 && s.push(new d(", "));
191
+ for (const [L, a] of I.entries())
192
+ s.push(a), L < I.length - 1 && s.push(new d(", "));
193
193
  return s.push(new d(")")), this.buildQueryFromSourceParams(s, A);
194
194
  }
195
- if (H(O, u))
196
- return this.buildQueryFromSourceParams(O.queryChunks, {
195
+ if (m(I, u))
196
+ return this.buildQueryFromSourceParams(I.queryChunks, {
197
197
  ...A,
198
- inlineParams: r || O.shouldInlineParams
198
+ inlineParams: r || I.shouldInlineParams
199
199
  });
200
- if (H(O, W)) {
201
- const s = O[W.Symbol.Schema], L = O[W.Symbol.Name];
200
+ if (m(I, W)) {
201
+ const s = I[W.Symbol.Schema], L = I[W.Symbol.Name];
202
202
  return {
203
- sql: s === void 0 || O[IE] ? S(L) : S(s) + "." + S(L),
203
+ sql: s === void 0 || I[IE] ? S(L) : S(s) + "." + S(L),
204
204
  params: []
205
205
  };
206
206
  }
207
- if (H(O, TE)) {
208
- const s = e.getColumnCasing(O);
207
+ if (m(I, TE)) {
208
+ const s = e.getColumnCasing(I);
209
209
  if (R.invokeSource === "indexes")
210
210
  return { sql: S(s), params: [] };
211
- const L = O.table[W.Symbol.Schema];
211
+ const L = I.table[W.Symbol.Schema];
212
212
  return {
213
- sql: O.table[IE] || L === void 0 ? S(O.table[W.Symbol.Name]) + "." + S(s) : S(L) + "." + S(O.table[W.Symbol.Name]) + "." + S(s),
213
+ sql: I.table[IE] || L === void 0 ? S(I.table[W.Symbol.Name]) + "." + S(s) : S(L) + "." + S(I.table[W.Symbol.Name]) + "." + S(s),
214
214
  params: []
215
215
  };
216
216
  }
217
- if (H(O, vT)) {
218
- const s = O[z].schema, L = O[z].name;
217
+ if (m(I, vT)) {
218
+ const s = I[z].schema, L = I[z].name;
219
219
  return {
220
- sql: s === void 0 || O[z].isAlias ? S(L) : S(s) + "." + S(L),
220
+ sql: s === void 0 || I[z].isAlias ? S(L) : S(s) + "." + S(L),
221
221
  params: []
222
222
  };
223
223
  }
224
- if (H(O, OE)) {
225
- if (H(O.value, NE))
226
- return { sql: N(I.value++, O), params: [O], typings: ["none"] };
227
- const s = O.value === null ? null : O.encoder.mapToDriverValue(O.value);
228
- if (H(s, u))
224
+ if (m(I, OE)) {
225
+ if (m(I.value, NE))
226
+ return { sql: N(O.value++, I), params: [I], typings: ["none"] };
227
+ const s = I.value === null ? null : I.encoder.mapToDriverValue(I.value);
228
+ if (m(s, u))
229
229
  return this.buildQueryFromSourceParams([s], A);
230
230
  if (r)
231
231
  return { sql: this.mapInlineParam(s, A), params: [] };
232
232
  let L = ["none"];
233
- return t && (L = [t(O.encoder)]), { sql: N(I.value++, s), params: [s], typings: L };
233
+ return t && (L = [t(I.encoder)]), { sql: N(O.value++, s), params: [s], typings: L };
234
234
  }
235
- return H(O, NE) ? { sql: N(I.value++, O), params: [O], typings: ["none"] } : H(O, u.Aliased) && O.fieldAlias !== void 0 ? { sql: S(O.fieldAlias), params: [] } : H(O, gT) ? O._.isWith ? { sql: S(O._.alias), params: [] } : this.buildQueryFromSourceParams([
235
+ return m(I, NE) ? { sql: N(O.value++, I), params: [I], typings: ["none"] } : m(I, u.Aliased) && I.fieldAlias !== void 0 ? { sql: S(I.fieldAlias), params: [] } : m(I, gT) ? I._.isWith ? { sql: S(I._.alias), params: [] } : this.buildQueryFromSourceParams([
236
236
  new d("("),
237
- O._.sql,
237
+ I._.sql,
238
238
  new d(") "),
239
- new JE(O._.alias)
240
- ], A) : _R(O) ? O.schema ? { sql: S(O.schema) + "." + S(O.enumName), params: [] } : { sql: S(O.enumName), params: [] } : wT(O) ? O.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([O.getSQL()], A) : this.buildQueryFromSourceParams([
239
+ new JE(I._.alias)
240
+ ], A) : _R(I) ? I.schema ? { sql: S(I.schema) + "." + S(I.enumName), params: [] } : { sql: S(I.enumName), params: [] } : wT(I) ? I.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([I.getSQL()], A) : this.buildQueryFromSourceParams([
241
241
  new d("("),
242
- O.getSQL(),
242
+ I.getSQL(),
243
243
  new d(")")
244
- ], A) : r ? { sql: this.mapInlineParam(O, A), params: [] } : { sql: N(I.value++, O), params: [O], typings: ["none"] };
244
+ ], A) : r ? { sql: this.mapInlineParam(I, A), params: [] } : { sql: N(O.value++, I), params: [I], typings: ["none"] };
245
245
  }));
246
246
  }
247
247
  mapInlineParam(E, { escapeString: R }) {
@@ -335,11 +335,11 @@ function C(T, ...E) {
335
335
  return new u([new d(r)]);
336
336
  }
337
337
  T.raw = A;
338
- function e(r, I) {
339
- const O = [];
338
+ function e(r, O) {
339
+ const I = [];
340
340
  for (const [s, L] of r.entries())
341
- s > 0 && I !== void 0 && O.push(I), O.push(L);
342
- return new u(O);
341
+ s > 0 && O !== void 0 && I.push(O), I.push(L);
342
+ return new u(I);
343
343
  }
344
344
  T.join = e;
345
345
  function S(r) {
@@ -350,8 +350,8 @@ function C(T, ...E) {
350
350
  return new NE(r);
351
351
  }
352
352
  T.placeholder = N;
353
- function t(r, I) {
354
- return new OE(r, I);
353
+ function t(r, O) {
354
+ return new OE(r, O);
355
355
  }
356
356
  T.param = t;
357
357
  })(C || (C = {}));
@@ -414,7 +414,7 @@ gT.prototype.getSQL = function() {
414
414
  return new u([this]);
415
415
  };
416
416
  function b(T, E) {
417
- return DR(E) && !wT(T) && !H(T, OE) && !H(T, NE) && !H(T, TE) && !H(T, W) && !H(T, vT) ? new OE(T, E) : T;
417
+ return DR(E) && !wT(T) && !m(T, OE) && !m(T, NE) && !m(T, TE) && !m(T, W) && !m(T, vT) ? new OE(T, E) : T;
418
418
  }
419
419
  const sE = (T, E) => C`${T} = ${b(E, T)}`, RT = (T, E) => C`${T} <> ${b(E, T)}`;
420
420
  function f(...T) {
@@ -468,10 +468,10 @@ function g(T) {
468
468
  return C`sum(${T})`.mapWith(String);
469
469
  }
470
470
  function xE(T) {
471
- return C`max(${T})`.mapWith(H(T, TE) ? T : String);
471
+ return C`max(${T})`.mapWith(m(T, TE) ? T : String);
472
472
  }
473
473
  function vE(T) {
474
- return C`min(${T})`.mapWith(H(T, TE) ? T : String);
474
+ return C`min(${T})`.mapWith(m(T, TE) ? T : String);
475
475
  }
476
476
  class ZE {
477
477
  /**
@@ -1100,6 +1100,9 @@ function FR(T, E) {
1100
1100
  case "hasMany":
1101
1101
  return "left";
1102
1102
  // Parent may have no children
1103
+ case "belongsToMany":
1104
+ return "left";
1105
+ // Many-to-many through junction table
1103
1106
  default:
1104
1107
  return "left";
1105
1108
  }
@@ -1119,26 +1122,26 @@ class YR {
1119
1122
  const e = {}, S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1120
1123
  if (R.dimensions)
1121
1124
  for (const N of R.dimensions) {
1122
- const [t, r] = N.split("."), I = S.get(t);
1123
- if (I && I.dimensions && I.dimensions[r]) {
1124
- const O = I.dimensions[r], s = $(O.sql, A);
1125
+ const [t, r] = N.split("."), O = S.get(t);
1126
+ if (O && O.dimensions && O.dimensions[r]) {
1127
+ const I = O.dimensions[r], s = $(I.sql, A);
1125
1128
  e[N] = C`${s}`.as(N);
1126
1129
  }
1127
1130
  }
1128
1131
  if (R.measures)
1129
1132
  for (const N of R.measures) {
1130
- const [t, r] = N.split("."), I = S.get(t);
1131
- if (I && I.measures && I.measures[r]) {
1132
- const O = I.measures[r], s = this.buildMeasureExpression(O, A);
1133
+ const [t, r] = N.split("."), O = S.get(t);
1134
+ if (O && O.measures && O.measures[r]) {
1135
+ const I = O.measures[r], s = this.buildMeasureExpression(I, A);
1133
1136
  e[N] = C`${s}`.as(N);
1134
1137
  }
1135
1138
  }
1136
1139
  if (R.timeDimensions)
1137
1140
  for (const N of R.timeDimensions) {
1138
- const [t, r] = N.dimension.split("."), I = S.get(t);
1139
- if (I && I.dimensions && I.dimensions[r]) {
1140
- const O = I.dimensions[r], s = this.buildTimeDimensionExpression(
1141
- O.sql,
1141
+ const [t, r] = N.dimension.split("."), O = S.get(t);
1142
+ if (O && O.dimensions && O.dimensions[r]) {
1143
+ const I = O.dimensions[r], s = this.buildTimeDimensionExpression(
1144
+ I.sql,
1142
1145
  N.granularity,
1143
1146
  A
1144
1147
  );
@@ -1228,11 +1231,11 @@ class YR {
1228
1231
  }
1229
1232
  if (R.timeDimensions)
1230
1233
  for (const t of R.timeDimensions) {
1231
- const [r, I] = t.dimension.split("."), O = N.get(r);
1232
- if (O && O.dimensions[I] && t.dateRange) {
1234
+ const [r, O] = t.dimension.split("."), I = N.get(r);
1235
+ if (I && I.dimensions[O] && t.dateRange) {
1233
1236
  if (e?.preAggregationCTEs && e.preAggregationCTEs.some((n) => n.cube.name === r))
1234
1237
  continue;
1235
- const s = O.dimensions[I], L = $(s.sql, A), a = this.buildDateRangeCondition(L, t.dateRange);
1238
+ const s = I.dimensions[O], L = $(s.sql, A), a = this.buildDateRangeCondition(L, t.dateRange);
1236
1239
  a && S.push(a);
1237
1240
  }
1238
1241
  }
@@ -1267,14 +1270,14 @@ class YR {
1267
1270
  return o.length > 0 ? DE(...o) : null;
1268
1271
  }
1269
1272
  }
1270
- const N = E, [t, r] = N.member.split("."), I = R.get(t);
1271
- if (!I) return null;
1272
- const O = I.dimensions[r], s = I.measures[r], L = O || s;
1273
+ const N = E, [t, r] = N.member.split("."), O = R.get(t);
1274
+ if (!O) return null;
1275
+ const I = O.dimensions[r], s = O.measures[r], L = I || s;
1273
1276
  if (!L) return null;
1274
- if (e === "where" && O) {
1277
+ if (e === "where" && I) {
1275
1278
  if (S?.preAggregationCTEs && S.preAggregationCTEs.some((n) => n.cube.name === t))
1276
1279
  return null;
1277
- const a = $(O.sql, A);
1280
+ const a = $(I.sql, A);
1278
1281
  return this.buildFilterCondition(a, N.operator, N.values, L);
1279
1282
  } else {
1280
1283
  if (e === "where" && s)
@@ -1483,14 +1486,14 @@ class YR {
1483
1486
  const s = new Date(Date.UTC(e, S - 11, 1, 0, 0, 0, 0)), L = new Date(R);
1484
1487
  return L.setUTCHours(23, 59, 59, 999), { start: s, end: L };
1485
1488
  }
1486
- const I = A.match(/^last\s+(\d+)\s+months?$/);
1487
- if (I) {
1488
- const s = parseInt(I[1], 10), L = new Date(Date.UTC(e, S - s + 1, 1, 0, 0, 0, 0)), a = new Date(R);
1489
+ const O = A.match(/^last\s+(\d+)\s+months?$/);
1490
+ if (O) {
1491
+ const s = parseInt(O[1], 10), L = new Date(Date.UTC(e, S - s + 1, 1, 0, 0, 0, 0)), a = new Date(R);
1489
1492
  return a.setUTCHours(23, 59, 59, 999), { start: L, end: a };
1490
1493
  }
1491
- const O = A.match(/^last\s+(\d+)\s+years?$/);
1492
- if (O) {
1493
- const s = parseInt(O[1], 10), L = new Date(Date.UTC(e - s, 0, 1, 0, 0, 0, 0)), a = new Date(R);
1494
+ const I = A.match(/^last\s+(\d+)\s+years?$/);
1495
+ if (I) {
1496
+ const s = parseInt(I[1], 10), L = new Date(Date.UTC(e - s, 0, 1, 0, 0, 0, 0)), a = new Date(R);
1494
1497
  return a.setUTCHours(23, 59, 59, 999), { start: L, end: a };
1495
1498
  }
1496
1499
  return null;
@@ -1526,27 +1529,27 @@ class YR {
1526
1529
  const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1527
1530
  if (R.dimensions)
1528
1531
  for (const r of R.dimensions) {
1529
- const [I, O] = r.split("."), s = t.get(I);
1530
- if (s && s.dimensions && s.dimensions[O])
1531
- if (e?.preAggregationCTEs?.some((a) => a.cube.name === I)) {
1532
- const a = e.preAggregationCTEs.find((n) => n.cube.name === I), o = a.joinKeys.find((n) => n.targetColumn === O);
1532
+ const [O, I] = r.split("."), s = t.get(O);
1533
+ if (s && s.dimensions && s.dimensions[I])
1534
+ if (e?.preAggregationCTEs?.some((a) => a.cube.name === O)) {
1535
+ const a = e.preAggregationCTEs.find((n) => n.cube.name === O), o = a.joinKeys.find((n) => n.targetColumn === I);
1533
1536
  if (o && o.sourceColumnObj)
1534
1537
  S.push(o.sourceColumnObj);
1535
1538
  else {
1536
- const n = C`${C.identifier(a.cteAlias)}.${C.identifier(O)}`;
1539
+ const n = C`${C.identifier(a.cteAlias)}.${C.identifier(I)}`;
1537
1540
  S.push(n);
1538
1541
  }
1539
1542
  } else {
1540
- const a = s.dimensions[O], o = $(a.sql, A);
1543
+ const a = s.dimensions[I], o = $(a.sql, A);
1541
1544
  S.push(o);
1542
1545
  }
1543
1546
  }
1544
1547
  if (R.timeDimensions)
1545
1548
  for (const r of R.timeDimensions) {
1546
- const [I, O] = r.dimension.split("."), s = t.get(I);
1547
- if (s && s.dimensions && s.dimensions[O])
1548
- if (e?.preAggregationCTEs?.some((a) => a.cube.name === I)) {
1549
- const a = e.preAggregationCTEs.find((n) => n.cube.name === I), o = a.joinKeys.find((n) => n.targetColumn === O);
1549
+ const [O, I] = r.dimension.split("."), s = t.get(O);
1550
+ if (s && s.dimensions && s.dimensions[I])
1551
+ if (e?.preAggregationCTEs?.some((a) => a.cube.name === O)) {
1552
+ const a = e.preAggregationCTEs.find((n) => n.cube.name === O), o = a.joinKeys.find((n) => n.targetColumn === I);
1550
1553
  if (o && o.sourceColumnObj) {
1551
1554
  const n = this.buildTimeDimensionExpression(
1552
1555
  o.sourceColumnObj,
@@ -1555,11 +1558,11 @@ class YR {
1555
1558
  );
1556
1559
  S.push(n);
1557
1560
  } else {
1558
- const n = C`${C.identifier(a.cteAlias)}.${C.identifier(O)}`;
1561
+ const n = C`${C.identifier(a.cteAlias)}.${C.identifier(I)}`;
1559
1562
  S.push(n);
1560
1563
  }
1561
1564
  } else {
1562
- const a = s.dimensions[O], o = this.buildTimeDimensionExpression(
1565
+ const a = s.dimensions[I], o = this.buildTimeDimensionExpression(
1563
1566
  a.sql,
1564
1567
  r.granularity,
1565
1568
  A
@@ -1604,8 +1607,8 @@ class YR {
1604
1607
  for (const S of R.dimensions) {
1605
1608
  const [N, t] = S.split("."), r = e.get(N);
1606
1609
  if (r) {
1607
- const I = r.dimensions[t];
1608
- I && I.type === "number" && A.push(S);
1610
+ const O = r.dimensions[t];
1611
+ O && O.type === "number" && A.push(S);
1609
1612
  }
1610
1613
  }
1611
1614
  return A;
@@ -1720,7 +1723,7 @@ class pR {
1720
1723
  groupByFields: []
1721
1724
  // Will be built by QueryBuilder
1722
1725
  };
1723
- const r = this.buildJoinPlan(E, t, S), I = this.planPreAggregationCTEs(E, t, r, R);
1726
+ const r = this.buildJoinPlan(E, t, S), O = this.planPreAggregationCTEs(E, t, r, R);
1724
1727
  return {
1725
1728
  primaryCube: t,
1726
1729
  joinCubes: r,
@@ -1730,7 +1733,7 @@ class pR {
1730
1733
  // Will be built by QueryBuilder
1731
1734
  groupByFields: [],
1732
1735
  // Will be built by QueryBuilder
1733
- preAggregationCTEs: I
1736
+ preAggregationCTEs: O
1734
1737
  };
1735
1738
  }
1736
1739
  /**
@@ -1787,25 +1790,25 @@ class pR {
1787
1790
  const r = this.findJoinPath(E, R.name, t, S);
1788
1791
  if (!r || r.length === 0)
1789
1792
  throw new Error(`No join path found from '${R.name}' to '${t}'`);
1790
- for (const { toCube: I, joinDef: O } of r) {
1791
- if (S.has(I))
1793
+ for (const { toCube: O, joinDef: I } of r) {
1794
+ if (S.has(O))
1792
1795
  continue;
1793
- const s = E.get(I);
1796
+ const s = E.get(O);
1794
1797
  if (!s)
1795
- throw new Error(`Cube '${I}' not found`);
1798
+ throw new Error(`Cube '${O}' not found`);
1796
1799
  const L = this.buildJoinCondition(
1797
- O,
1800
+ I,
1798
1801
  null,
1799
1802
  // No source alias needed - use the actual column
1800
1803
  null
1801
1804
  // No target alias needed - use the actual column
1802
- ), a = FR(O.relationship, O.sqlJoinType);
1805
+ ), a = FR(I.relationship, I.sqlJoinType);
1803
1806
  e.push({
1804
1807
  cube: s,
1805
- alias: `${I.toLowerCase()}_cube`,
1808
+ alias: `${O.toLowerCase()}_cube`,
1806
1809
  joinType: a,
1807
1810
  joinCondition: L
1808
- }), S.add(I);
1811
+ }), S.add(O);
1809
1812
  }
1810
1813
  }
1811
1814
  return e;
@@ -1832,16 +1835,16 @@ class pR {
1832
1835
  { cube: R, path: [] }
1833
1836
  ], N = /* @__PURE__ */ new Set([R, ...e]);
1834
1837
  for (; S.length > 0; ) {
1835
- const { cube: t, path: r } = S.shift(), I = E.get(t);
1836
- if (I?.joins)
1837
- for (const [, O] of Object.entries(I.joins)) {
1838
- const L = tT(O.targetCube).name;
1838
+ const { cube: t, path: r } = S.shift(), O = E.get(t);
1839
+ if (O?.joins)
1840
+ for (const [, I] of Object.entries(O.joins)) {
1841
+ const L = tT(I.targetCube).name;
1839
1842
  if (N.has(L))
1840
1843
  continue;
1841
1844
  const a = [...r, {
1842
1845
  fromCube: t,
1843
1846
  toCube: L,
1844
- joinDef: O
1847
+ joinDef: I
1845
1848
  }];
1846
1849
  if (L === A)
1847
1850
  return a;
@@ -1863,8 +1866,8 @@ class pR {
1863
1866
  continue;
1864
1867
  const r = e.measures ? e.measures.filter(
1865
1868
  (L) => L.startsWith(N.cube.name + ".")
1866
- ) : [], I = this.extractMeasuresFromFilters(e, N.cube.name), O = [.../* @__PURE__ */ new Set([...r, ...I])];
1867
- if (O.length === 0)
1869
+ ) : [], O = this.extractMeasuresFromFilters(e, N.cube.name), I = [.../* @__PURE__ */ new Set([...r, ...O])];
1870
+ if (I.length === 0)
1868
1871
  continue;
1869
1872
  const s = t.on.map((L) => ({
1870
1873
  sourceColumn: L.source.name,
@@ -1877,7 +1880,7 @@ class pR {
1877
1880
  alias: N.alias,
1878
1881
  cteAlias: `${N.cube.name.toLowerCase()}_agg`,
1879
1882
  joinKeys: s,
1880
- measures: O
1883
+ measures: I
1881
1884
  });
1882
1885
  }
1883
1886
  return S;
@@ -1915,7 +1918,7 @@ class UE {
1915
1918
  db: this.dbExecutor.db,
1916
1919
  schema: this.dbExecutor.schema,
1917
1920
  securityContext: A
1918
- }, N = this.queryPlanner.createQueryPlan(E, R, S), t = this.buildUnifiedQuery(N, R, S), r = this.queryBuilder.collectNumericFields(E, R), I = await this.dbExecutor.execute(t, r), O = Array.isArray(I) ? I.map((L) => {
1921
+ }, N = this.queryPlanner.createQueryPlan(E, R, S), t = this.buildUnifiedQuery(N, R, S), r = this.queryBuilder.collectNumericFields(E, R), O = await this.dbExecutor.execute(t, r), I = Array.isArray(O) ? O.map((L) => {
1919
1922
  const a = { ...L };
1920
1923
  if (R.timeDimensions) {
1921
1924
  for (const o of R.timeDimensions)
@@ -1929,9 +1932,9 @@ class UE {
1929
1932
  }
1930
1933
  }
1931
1934
  return a;
1932
- }) : [I], s = this.generateAnnotations(N, R);
1935
+ }) : [O], s = this.generateAnnotations(N, R);
1933
1936
  return {
1934
- data: O,
1937
+ data: I,
1935
1938
  annotation: s
1936
1939
  };
1937
1940
  } catch (e) {
@@ -1959,8 +1962,8 @@ class UE {
1959
1962
  for (const n of E.measures) {
1960
1963
  const [, U] = n.split(".");
1961
1964
  if (S.measures && S.measures[U]) {
1962
- const P = S.measures[U], l = this.queryBuilder.buildMeasureExpression(P, A);
1963
- t[U] = C`${l}`.as(U);
1965
+ const P = S.measures[U], c = this.queryBuilder.buildMeasureExpression(P, A);
1966
+ t[U] = C`${c}`.as(U);
1964
1967
  }
1965
1968
  }
1966
1969
  const r = S.name;
@@ -1968,42 +1971,42 @@ class UE {
1968
1971
  for (const n of R.dimensions) {
1969
1972
  const [U, P] = n.split(".");
1970
1973
  if (U === r && S.dimensions && S.dimensions[P]) {
1971
- const l = S.dimensions[P], c = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A);
1972
- t[P] = C`${c}`.as(P);
1974
+ const c = S.dimensions[P], l = this.queryBuilder.buildMeasureExpression({ sql: c.sql, type: "number" }, A);
1975
+ t[P] = C`${l}`.as(P);
1973
1976
  }
1974
1977
  }
1975
1978
  if (R.timeDimensions)
1976
1979
  for (const n of R.timeDimensions) {
1977
1980
  const [U, P] = n.dimension.split(".");
1978
1981
  if (U === r && S.dimensions && S.dimensions[P]) {
1979
- const l = S.dimensions[P], c = this.queryBuilder.buildTimeDimensionExpression(l.sql, n.granularity, A);
1980
- t[P] = C`${c}`.as(P);
1982
+ const c = S.dimensions[P], l = this.queryBuilder.buildTimeDimensionExpression(c.sql, n.granularity, A);
1983
+ t[P] = C`${l}`.as(P);
1981
1984
  }
1982
1985
  }
1983
1986
  if (Object.keys(t).length === 0)
1984
1987
  return null;
1985
- let I = A.db.select(t).from(N.from);
1986
- const O = e ? {
1988
+ let O = A.db.select(t).from(N.from);
1989
+ const I = e ? {
1987
1990
  ...e,
1988
1991
  preAggregationCTEs: e.preAggregationCTEs?.filter((n) => n.cube.name !== S.name)
1989
- } : void 0, s = this.queryBuilder.buildWhereConditions(S, R, A, O), L = [];
1992
+ } : void 0, s = this.queryBuilder.buildWhereConditions(S, R, A, I), L = [];
1990
1993
  if (R.timeDimensions)
1991
1994
  for (const n of R.timeDimensions) {
1992
1995
  const [U, P] = n.dimension.split(".");
1993
1996
  if (U === r && S.dimensions && S.dimensions[P] && n.dateRange) {
1994
- const l = S.dimensions[P], c = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A), m = this.queryBuilder.buildDateRangeCondition(c, n.dateRange);
1995
- m && L.push(m);
1997
+ const c = S.dimensions[P], l = this.queryBuilder.buildMeasureExpression({ sql: c.sql, type: "number" }, A), H = this.queryBuilder.buildDateRangeCondition(l, n.dateRange);
1998
+ H && L.push(H);
1996
1999
  }
1997
2000
  }
1998
2001
  if (R.filters) {
1999
2002
  for (const n of R.filters)
2000
2003
  if (!("and" in n) && !("or" in n) && "member" in n && "operator" in n) {
2001
- const U = n, [P, l] = U.member.split(".");
2002
- if (P === r && S.dimensions && S.dimensions[l]) {
2003
- const c = S.dimensions[l];
2004
+ const U = n, [P, c] = U.member.split(".");
2005
+ if (P === r && S.dimensions && S.dimensions[c]) {
2006
+ const l = S.dimensions[c];
2004
2007
  if (U.operator === "inDateRange") {
2005
- const m = this.queryBuilder.buildMeasureExpression({ sql: c.sql, type: "number" }, A), p = this.queryBuilder.buildDateRangeCondition(m, U.values);
2006
- p && L.push(p);
2008
+ const H = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A), B = this.queryBuilder.buildDateRangeCondition(H, U.values);
2009
+ B && L.push(B);
2007
2010
  }
2008
2011
  }
2009
2012
  }
@@ -2011,7 +2014,7 @@ class UE {
2011
2014
  const a = [];
2012
2015
  if (N.where && a.push(N.where), a.push(...s, ...L), a.length > 0) {
2013
2016
  const n = a.length === 1 ? a[0] : f(...a);
2014
- I = I.where(n);
2017
+ O = O.where(n);
2015
2018
  }
2016
2019
  const o = [];
2017
2020
  for (const n of E.joinKeys)
@@ -2020,19 +2023,19 @@ class UE {
2020
2023
  for (const n of R.dimensions) {
2021
2024
  const [U, P] = n.split(".");
2022
2025
  if (U === r && S.dimensions && S.dimensions[P]) {
2023
- const l = S.dimensions[P], c = $(l.sql, A);
2024
- o.push(c);
2026
+ const c = S.dimensions[P], l = $(c.sql, A);
2027
+ o.push(l);
2025
2028
  }
2026
2029
  }
2027
2030
  if (R.timeDimensions)
2028
2031
  for (const n of R.timeDimensions) {
2029
2032
  const [U, P] = n.dimension.split(".");
2030
2033
  if (U === r && S.dimensions && S.dimensions[P]) {
2031
- const l = S.dimensions[P], c = this.queryBuilder.buildTimeDimensionExpression(l.sql, n.granularity, A);
2032
- o.push(c);
2034
+ const c = S.dimensions[P], l = this.queryBuilder.buildTimeDimensionExpression(c.sql, n.granularity, A);
2035
+ o.push(l);
2033
2036
  }
2034
2037
  }
2035
- return o.length > 0 && (I = I.groupBy(...o)), A.db.$with(E.cteAlias).as(I);
2038
+ return o.length > 0 && (O = O.groupBy(...o)), A.db.$with(E.cteAlias).as(O);
2036
2039
  }
2037
2040
  // Removed unused getActualJoinTargetColumn method
2038
2041
  /**
@@ -2070,49 +2073,50 @@ class UE {
2070
2073
  const U = n.cube.name;
2071
2074
  for (const P of n.measures)
2072
2075
  if (r[P]) {
2073
- const [, l] = P.split("."), c = this.getCubesFromPlan(E).get(U);
2074
- if (c && c.measures && c.measures[l]) {
2075
- const m = c.measures[l], p = C`${C.identifier(n.cteAlias)}.${C.identifier(l)}`;
2076
+ const [, c] = P.split("."), l = this.getCubesFromPlan(E).get(U);
2077
+ if (l && l.measures && l.measures[c]) {
2078
+ const H = l.measures[c], B = C`${C.identifier(n.cteAlias)}.${C.identifier(c)}`;
2076
2079
  let V;
2077
- switch (m.type) {
2080
+ switch (H.type) {
2078
2081
  case "count":
2079
2082
  case "countDistinct":
2080
2083
  case "sum":
2081
- V = g(p);
2084
+ V = g(B);
2082
2085
  break;
2083
2086
  case "avg":
2084
- V = this.databaseAdapter.buildAvg(p);
2087
+ V = this.databaseAdapter.buildAvg(B);
2085
2088
  break;
2086
2089
  case "min":
2087
- V = vE(p);
2090
+ V = vE(B);
2088
2091
  break;
2089
2092
  case "max":
2090
- V = xE(p);
2093
+ V = xE(B);
2091
2094
  break;
2092
2095
  case "number":
2093
- V = g(p);
2096
+ V = g(B);
2094
2097
  break;
2095
2098
  default:
2096
- V = g(p);
2099
+ V = g(B);
2097
2100
  }
2098
2101
  r[P] = C`${V}`.as(P);
2099
2102
  }
2100
2103
  }
2101
2104
  for (const P in r) {
2102
- const [l, c] = P.split(".");
2103
- if (l === U) {
2104
- const m = this.getCubesFromPlan(E).get(U), p = m && m.dimensions?.[c], V = P.startsWith(U + ".");
2105
- if (p || V) {
2106
- let x = n.joinKeys.find((LE) => LE.targetColumn === c);
2107
- if (!x && m?.dimensions?.[c]) {
2108
- const LE = m.dimensions[c].sql;
2105
+ const [c, l] = P.split(".");
2106
+ if (c === U) {
2107
+ const H = this.getCubesFromPlan(E).get(U), B = H && H.dimensions?.[l], V = P.startsWith(U + ".");
2108
+ if (B || V) {
2109
+ let x = n.joinKeys.find((LE) => LE.targetColumn === l);
2110
+ if (!x && H?.dimensions?.[l]) {
2111
+ const LE = H.dimensions[l].sql;
2109
2112
  x = n.joinKeys.find((LR) => LR.targetColumnObj === LE);
2110
2113
  }
2111
- x ? r[P] = C`${C.identifier(n.cteAlias)}.${C.identifier(c)}`.as(P) : V && m?.dimensions?.[c] && (r[P] = C`${C.identifier(n.cteAlias)}.${C.identifier(c)}`.as(P));
2114
+ x ? r[P] = C`${C.identifier(n.cteAlias)}.${C.identifier(l)}`.as(P) : V && H?.dimensions?.[l] && (r[P] = C`${C.identifier(n.cteAlias)}.${C.identifier(l)}`.as(P));
2112
2115
  }
2113
2116
  }
2114
2117
  }
2115
2118
  }
2119
+ const O = [];
2116
2120
  let I = A.db.select(r).from(N.from);
2117
2121
  if (e.length > 0 && (I = A.db.with(...e).select(r).from(N.from)), N.joins)
2118
2122
  for (const n of N.joins)
@@ -2133,27 +2137,51 @@ class UE {
2133
2137
  if (E.joinCubes && E.joinCubes.length > 0)
2134
2138
  for (const n of E.joinCubes) {
2135
2139
  const U = S.get(n.cube.name);
2136
- let P, l;
2137
- U ? (P = C`${C.identifier(U)}`, l = this.buildCTEJoinCondition(n, U, E)) : (P = n.cube.sql(A).from, l = n.joinCondition);
2140
+ if (n.junctionTable) {
2141
+ const l = n.junctionTable, H = [];
2142
+ if (l.securitySql) {
2143
+ const B = l.securitySql(A.securityContext);
2144
+ Array.isArray(B) ? H.push(...B) : H.push(B);
2145
+ }
2146
+ try {
2147
+ switch (l.joinType || "left") {
2148
+ case "left":
2149
+ I = I.leftJoin(l.table, l.joinCondition);
2150
+ break;
2151
+ case "inner":
2152
+ I = I.innerJoin(l.table, l.joinCondition);
2153
+ break;
2154
+ case "right":
2155
+ I = I.rightJoin(l.table, l.joinCondition);
2156
+ break;
2157
+ case "full":
2158
+ I = I.fullJoin(l.table, l.joinCondition);
2159
+ break;
2160
+ }
2161
+ H.length > 0 && O.push(...H);
2162
+ } catch {
2163
+ }
2164
+ }
2165
+ let P, c;
2166
+ U ? (P = C`${C.identifier(U)}`, c = this.buildCTEJoinCondition(n, U, E)) : (P = n.cube.sql(A).from, c = n.joinCondition);
2138
2167
  try {
2139
2168
  switch (n.joinType || "left") {
2140
2169
  case "left":
2141
- I = I.leftJoin(P, l);
2170
+ I = I.leftJoin(P, c);
2142
2171
  break;
2143
2172
  case "inner":
2144
- I = I.innerJoin(P, l);
2173
+ I = I.innerJoin(P, c);
2145
2174
  break;
2146
2175
  case "right":
2147
- I = I.rightJoin(P, l);
2176
+ I = I.rightJoin(P, c);
2148
2177
  break;
2149
2178
  case "full":
2150
- I = I.fullJoin(P, l);
2179
+ I = I.fullJoin(P, c);
2151
2180
  break;
2152
2181
  }
2153
2182
  } catch {
2154
2183
  }
2155
2184
  }
2156
- const O = [];
2157
2185
  if (N.where && O.push(N.where), E.joinCubes && E.joinCubes.length > 0)
2158
2186
  for (const n of E.joinCubes) {
2159
2187
  if (S.get(n.cube.name))
@@ -2241,36 +2269,36 @@ class UE {
2241
2269
  const A = {}, e = {}, S = {}, N = [E.primaryCube];
2242
2270
  if (E.joinCubes && E.joinCubes.length > 0 && N.push(...E.joinCubes.map((t) => t.cube)), R.measures)
2243
2271
  for (const t of R.measures) {
2244
- const [r, I] = t.split("."), O = N.find((s) => s.name === r);
2245
- if (O && O.measures[I]) {
2246
- const s = O.measures[I];
2272
+ const [r, O] = t.split("."), I = N.find((s) => s.name === r);
2273
+ if (I && I.measures[O]) {
2274
+ const s = I.measures[O];
2247
2275
  A[t] = {
2248
- title: s.title || I,
2249
- shortTitle: s.title || I,
2276
+ title: s.title || O,
2277
+ shortTitle: s.title || O,
2250
2278
  type: s.type
2251
2279
  };
2252
2280
  }
2253
2281
  }
2254
2282
  if (R.dimensions)
2255
2283
  for (const t of R.dimensions) {
2256
- const [r, I] = t.split("."), O = N.find((s) => s.name === r);
2257
- if (O && O.dimensions[I]) {
2258
- const s = O.dimensions[I];
2284
+ const [r, O] = t.split("."), I = N.find((s) => s.name === r);
2285
+ if (I && I.dimensions[O]) {
2286
+ const s = I.dimensions[O];
2259
2287
  e[t] = {
2260
- title: s.title || I,
2261
- shortTitle: s.title || I,
2288
+ title: s.title || O,
2289
+ shortTitle: s.title || O,
2262
2290
  type: s.type
2263
2291
  };
2264
2292
  }
2265
2293
  }
2266
2294
  if (R.timeDimensions)
2267
2295
  for (const t of R.timeDimensions) {
2268
- const [r, I] = t.dimension.split("."), O = N.find((s) => s.name === r);
2269
- if (O && O.dimensions && O.dimensions[I]) {
2270
- const s = O.dimensions[I];
2296
+ const [r, O] = t.dimension.split("."), I = N.find((s) => s.name === r);
2297
+ if (I && I.dimensions && I.dimensions[O]) {
2298
+ const s = I.dimensions[O];
2271
2299
  S[t.dimension] = {
2272
- title: s.title || I,
2273
- shortTitle: s.title || I,
2300
+ title: s.title || O,
2301
+ shortTitle: s.title || O,
2274
2302
  type: s.type,
2275
2303
  granularity: t.granularity
2276
2304
  };
@@ -17987,82 +18015,82 @@ class fI {
17987
18015
  {
17988
18016
  type: D.RESERVED_KEYWORD_PHRASE,
17989
18017
  regex: y((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
17990
- text: B
18018
+ text: F
17991
18019
  },
17992
18020
  {
17993
18021
  type: D.RESERVED_DATA_TYPE_PHRASE,
17994
18022
  regex: y((e = E.reservedDataTypePhrases) !== null && e !== void 0 ? e : [], E.identChars),
17995
- text: B
18023
+ text: F
17996
18024
  },
17997
18025
  {
17998
18026
  type: D.CASE,
17999
18027
  regex: /CASE\b/iuy,
18000
- text: B
18028
+ text: F
18001
18029
  },
18002
18030
  {
18003
18031
  type: D.END,
18004
18032
  regex: /END\b/iuy,
18005
- text: B
18033
+ text: F
18006
18034
  },
18007
18035
  {
18008
18036
  type: D.BETWEEN,
18009
18037
  regex: /BETWEEN\b/iuy,
18010
- text: B
18038
+ text: F
18011
18039
  },
18012
18040
  {
18013
18041
  type: D.LIMIT,
18014
18042
  regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
18015
- text: B
18043
+ text: F
18016
18044
  },
18017
18045
  {
18018
18046
  type: D.RESERVED_CLAUSE,
18019
18047
  regex: y(E.reservedClauses, E.identChars),
18020
- text: B
18048
+ text: F
18021
18049
  },
18022
18050
  {
18023
18051
  type: D.RESERVED_SELECT,
18024
18052
  regex: y(E.reservedSelect, E.identChars),
18025
- text: B
18053
+ text: F
18026
18054
  },
18027
18055
  {
18028
18056
  type: D.RESERVED_SET_OPERATION,
18029
18057
  regex: y(E.reservedSetOperations, E.identChars),
18030
- text: B
18058
+ text: F
18031
18059
  },
18032
18060
  {
18033
18061
  type: D.WHEN,
18034
18062
  regex: /WHEN\b/iuy,
18035
- text: B
18063
+ text: F
18036
18064
  },
18037
18065
  {
18038
18066
  type: D.ELSE,
18039
18067
  regex: /ELSE\b/iuy,
18040
- text: B
18068
+ text: F
18041
18069
  },
18042
18070
  {
18043
18071
  type: D.THEN,
18044
18072
  regex: /THEN\b/iuy,
18045
- text: B
18073
+ text: F
18046
18074
  },
18047
18075
  {
18048
18076
  type: D.RESERVED_JOIN,
18049
18077
  regex: y(E.reservedJoins, E.identChars),
18050
- text: B
18078
+ text: F
18051
18079
  },
18052
18080
  {
18053
18081
  type: D.AND,
18054
18082
  regex: /AND\b/iuy,
18055
- text: B
18083
+ text: F
18056
18084
  },
18057
18085
  {
18058
18086
  type: D.OR,
18059
18087
  regex: /OR\b/iuy,
18060
- text: B
18088
+ text: F
18061
18089
  },
18062
18090
  {
18063
18091
  type: D.XOR,
18064
18092
  regex: E.supportsXor ? /XOR\b/iuy : void 0,
18065
- text: B
18093
+ text: F
18066
18094
  },
18067
18095
  ...E.operatorKeyword ? [
18068
18096
  {
@@ -18073,17 +18101,17 @@ class fI {
18073
18101
  {
18074
18102
  type: D.RESERVED_FUNCTION_NAME,
18075
18103
  regex: y(E.reservedFunctionNames, E.identChars),
18076
- text: B
18104
+ text: F
18077
18105
  },
18078
18106
  {
18079
18107
  type: D.RESERVED_DATA_TYPE,
18080
18108
  regex: y(E.reservedDataTypes, E.identChars),
18081
- text: B
18109
+ text: F
18082
18110
  },
18083
18111
  {
18084
18112
  type: D.RESERVED_KEYWORD,
18085
18113
  regex: y(E.reservedKeywords, E.identChars),
18086
- text: B
18114
+ text: F
18087
18115
  }
18088
18116
  ]);
18089
18117
  }
@@ -18150,31 +18178,31 @@ class fI {
18150
18178
  {
18151
18179
  type: D.NAMED_PARAMETER,
18152
18180
  regex: $E(r.named, TR(E.paramChars || E.identChars)),
18153
- key: (I) => I.slice(1)
18181
+ key: (O) => O.slice(1)
18154
18182
  },
18155
18183
  {
18156
18184
  type: D.QUOTED_PARAMETER,
18157
18185
  regex: $E(r.quoted, ER(E.identTypes)),
18158
- key: (I) => (({ tokenKey: O, quoteChar: s }) => O.replace(new RegExp(X("\\" + s), "gu"), s))({
18159
- tokenKey: I.slice(2, -1),
18160
- quoteChar: I.slice(-1)
18186
+ key: (O) => (({ tokenKey: I, quoteChar: s }) => I.replace(new RegExp(X("\\" + s), "gu"), s))({
18187
+ tokenKey: O.slice(2, -1),
18188
+ quoteChar: O.slice(-1)
18161
18189
  })
18162
18190
  },
18163
18191
  {
18164
18192
  type: D.NUMBERED_PARAMETER,
18165
18193
  regex: $E(r.numbered, "[0-9]+"),
18166
- key: (I) => I.slice(1)
18194
+ key: (O) => O.slice(1)
18167
18195
  },
18168
18196
  {
18169
18197
  type: D.POSITIONAL_PARAMETER,
18170
18198
  regex: r.positional ? /[?]/y : void 0
18171
18199
  },
18172
- ...r.custom.map((I) => {
18173
- var O;
18200
+ ...r.custom.map((O) => {
18201
+ var I;
18174
18202
  return {
18175
18203
  type: D.CUSTOM_PARAMETER,
18176
- regex: J(I.regex),
18177
- key: (O = I.key) !== null && O !== void 0 ? O : ((s) => s)
18204
+ regex: J(O.regex),
18205
+ key: (I = O.key) !== null && I !== void 0 ? I : ((s) => s)
18178
18206
  };
18179
18207
  })
18180
18208
  ]);
@@ -18184,7 +18212,7 @@ class fI {
18184
18212
  return E.filter((R) => !!R.regex);
18185
18213
  }
18186
18214
  }
18187
- const B = (T) => AE(T.toUpperCase()), WT = /* @__PURE__ */ new Map(), VI = (T) => {
18215
+ const F = (T) => AE(T.toUpperCase()), WT = /* @__PURE__ */ new Map(), VI = (T) => {
18188
18216
  let E = WT.get(T);
18189
18217
  return E || (E = WI(T), WT.set(T, E)), E;
18190
18218
  }, WI = (T) => ({
@@ -18236,36 +18264,36 @@ function gI() {
18236
18264
  (function(E, R) {
18237
18265
  T.exports ? T.exports = R() : E.nearley = R();
18238
18266
  })($I, function() {
18239
- function E(I, O, s) {
18240
- return this.id = ++E.highestId, this.name = I, this.symbols = O, this.postprocess = s, this;
18267
+ function E(O, I, s) {
18268
+ return this.id = ++E.highestId, this.name = O, this.symbols = I, this.postprocess = s, this;
18241
18269
  }
18242
- E.highestId = 0, E.prototype.toString = function(I) {
18243
- var O = typeof I > "u" ? this.symbols.map(r).join(" ") : this.symbols.slice(0, I).map(r).join(" ") + " ● " + this.symbols.slice(I).map(r).join(" ");
18244
- return this.name + " → " + O;
18270
+ E.highestId = 0, E.prototype.toString = function(O) {
18271
+ var I = typeof O > "u" ? this.symbols.map(r).join(" ") : this.symbols.slice(0, O).map(r).join(" ") + " ● " + this.symbols.slice(O).map(r).join(" ");
18272
+ return this.name + " → " + I;
18245
18273
  };
18246
- function R(I, O, s, L) {
18247
- this.rule = I, this.dot = O, this.reference = s, this.data = [], this.wantedBy = L, this.isComplete = this.dot === I.symbols.length;
18274
+ function R(O, I, s, L) {
18275
+ this.rule = O, this.dot = I, this.reference = s, this.data = [], this.wantedBy = L, this.isComplete = this.dot === O.symbols.length;
18248
18276
  }
18249
18277
  R.prototype.toString = function() {
18250
18278
  return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
18251
- }, R.prototype.nextState = function(I) {
18252
- var O = new R(this.rule, this.dot + 1, this.reference, this.wantedBy);
18253
- return O.left = this, O.right = I, O.isComplete && (O.data = O.build(), O.right = void 0), O;
18279
+ }, R.prototype.nextState = function(O) {
18280
+ var I = new R(this.rule, this.dot + 1, this.reference, this.wantedBy);
18281
+ return I.left = this, I.right = O, I.isComplete && (I.data = I.build(), I.right = void 0), I;
18254
18282
  }, R.prototype.build = function() {
18255
- var I = [], O = this;
18283
+ var O = [], I = this;
18256
18284
  do
18257
- I.push(O.right.data), O = O.left;
18258
- while (O.left);
18259
- return I.reverse(), I;
18285
+ O.push(I.right.data), I = I.left;
18286
+ while (I.left);
18287
+ return O.reverse(), O;
18260
18288
  }, R.prototype.finish = function() {
18261
18289
  this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, N.fail));
18262
18290
  };
18263
- function A(I, O) {
18264
- this.grammar = I, this.index = O, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
18291
+ function A(O, I) {
18292
+ this.grammar = O, this.index = I, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
18265
18293
  }
18266
- A.prototype.process = function(I) {
18267
- for (var O = this.states, s = this.wants, L = this.completed, a = 0; a < O.length; a++) {
18268
- var o = O[a];
18294
+ A.prototype.process = function(O) {
18295
+ for (var I = this.states, s = this.wants, L = this.completed, a = 0; a < I.length; a++) {
18296
+ var o = I[a];
18269
18297
  if (o.isComplete) {
18270
18298
  if (o.finish(), o.data !== N.fail) {
18271
18299
  for (var n = o.wantedBy, U = n.length; U--; ) {
@@ -18273,67 +18301,67 @@ function gI() {
18273
18301
  this.complete(P, o);
18274
18302
  }
18275
18303
  if (o.reference === this.index) {
18276
- var l = o.rule.name;
18277
- (this.completed[l] = this.completed[l] || []).push(o);
18304
+ var c = o.rule.name;
18305
+ (this.completed[c] = this.completed[c] || []).push(o);
18278
18306
  }
18279
18307
  }
18280
18308
  } else {
18281
- var l = o.rule.symbols[o.dot];
18282
- if (typeof l != "string") {
18309
+ var c = o.rule.symbols[o.dot];
18310
+ if (typeof c != "string") {
18283
18311
  this.scannable.push(o);
18284
18312
  continue;
18285
18313
  }
18286
- if (s[l]) {
18287
- if (s[l].push(o), L.hasOwnProperty(l))
18288
- for (var c = L[l], U = 0; U < c.length; U++) {
18289
- var m = c[U];
18290
- this.complete(o, m);
18314
+ if (s[c]) {
18315
+ if (s[c].push(o), L.hasOwnProperty(c))
18316
+ for (var l = L[c], U = 0; U < l.length; U++) {
18317
+ var H = l[U];
18318
+ this.complete(o, H);
18291
18319
  }
18292
18320
  } else
18293
- s[l] = [o], this.predict(l);
18321
+ s[c] = [o], this.predict(c);
18294
18322
  }
18295
18323
  }
18296
- }, A.prototype.predict = function(I) {
18297
- for (var O = this.grammar.byName[I] || [], s = 0; s < O.length; s++) {
18298
- var L = O[s], a = this.wants[I], o = new R(L, 0, this.index, a);
18324
+ }, A.prototype.predict = function(O) {
18325
+ for (var I = this.grammar.byName[O] || [], s = 0; s < I.length; s++) {
18326
+ var L = I[s], a = this.wants[O], o = new R(L, 0, this.index, a);
18299
18327
  this.states.push(o);
18300
18328
  }
18301
- }, A.prototype.complete = function(I, O) {
18302
- var s = I.nextState(O);
18329
+ }, A.prototype.complete = function(O, I) {
18330
+ var s = O.nextState(I);
18303
18331
  this.states.push(s);
18304
18332
  };
18305
- function e(I, O) {
18306
- this.rules = I, this.start = O || this.rules[0].name;
18333
+ function e(O, I) {
18334
+ this.rules = O, this.start = I || this.rules[0].name;
18307
18335
  var s = this.byName = {};
18308
18336
  this.rules.forEach(function(L) {
18309
18337
  s.hasOwnProperty(L.name) || (s[L.name] = []), s[L.name].push(L);
18310
18338
  });
18311
18339
  }
18312
- e.fromCompiled = function(L, O) {
18340
+ e.fromCompiled = function(L, I) {
18313
18341
  var s = L.Lexer;
18314
- L.ParserStart && (O = L.ParserStart, L = L.ParserRules);
18342
+ L.ParserStart && (I = L.ParserStart, L = L.ParserRules);
18315
18343
  var L = L.map(function(o) {
18316
18344
  return new E(o.name, o.symbols, o.postprocess);
18317
- }), a = new e(L, O);
18345
+ }), a = new e(L, I);
18318
18346
  return a.lexer = s, a;
18319
18347
  };
18320
18348
  function S() {
18321
18349
  this.reset("");
18322
18350
  }
18323
- S.prototype.reset = function(I, O) {
18324
- this.buffer = I, this.index = 0, this.line = O ? O.line : 1, this.lastLineBreak = O ? -O.col : 0;
18351
+ S.prototype.reset = function(O, I) {
18352
+ this.buffer = O, this.index = 0, this.line = I ? I.line : 1, this.lastLineBreak = I ? -I.col : 0;
18325
18353
  }, S.prototype.next = function() {
18326
18354
  if (this.index < this.buffer.length) {
18327
- var I = this.buffer[this.index++];
18328
- return I === `
18329
- ` && (this.line += 1, this.lastLineBreak = this.index), { value: I };
18355
+ var O = this.buffer[this.index++];
18356
+ return O === `
18357
+ ` && (this.line += 1, this.lastLineBreak = this.index), { value: O };
18330
18358
  }
18331
18359
  }, S.prototype.save = function() {
18332
18360
  return {
18333
18361
  line: this.line,
18334
18362
  col: this.index - this.lastLineBreak
18335
18363
  };
18336
- }, S.prototype.formatError = function(I, O) {
18364
+ }, S.prototype.formatError = function(O, I) {
18337
18365
  var s = this.buffer;
18338
18366
  if (typeof s == "string") {
18339
18367
  var L = s.split(`
@@ -18344,26 +18372,26 @@ function gI() {
18344
18372
  `, this.index);
18345
18373
  a === -1 && (a = s.length);
18346
18374
  var o = this.index - this.lastLineBreak, n = String(this.line).length;
18347
- return O += " at line " + this.line + " col " + o + `:
18375
+ return I += " at line " + this.line + " col " + o + `:
18348
18376
 
18349
- `, O += L.map(function(P, l) {
18350
- return U(this.line - L.length + l + 1, n) + " " + P;
18377
+ `, I += L.map(function(P, c) {
18378
+ return U(this.line - L.length + c + 1, n) + " " + P;
18351
18379
  }, this).join(`
18352
- `), O += `
18380
+ `), I += `
18353
18381
  ` + U("", n + o) + `^
18354
- `, O;
18382
+ `, I;
18355
18383
  } else
18356
- return O + " at index " + (this.index - 1);
18357
- function U(P, l) {
18358
- var c = String(P);
18359
- return Array(l - c.length + 1).join(" ") + c;
18384
+ return I + " at index " + (this.index - 1);
18385
+ function U(P, c) {
18386
+ var l = String(P);
18387
+ return Array(c - l.length + 1).join(" ") + l;
18360
18388
  }
18361
18389
  };
18362
- function N(I, O, s) {
18363
- if (I instanceof e)
18364
- var L = I, s = O;
18390
+ function N(O, I, s) {
18391
+ if (O instanceof e)
18392
+ var L = O, s = I;
18365
18393
  else
18366
- var L = e.fromCompiled(I, O);
18394
+ var L = e.fromCompiled(O, I);
18367
18395
  this.grammar = L, this.options = {
18368
18396
  keepHistory: !1,
18369
18397
  lexer: L.lexer || new S()
@@ -18374,12 +18402,12 @@ function gI() {
18374
18402
  var o = new A(L, 0);
18375
18403
  this.table = [o], o.wants[L.start] = [], o.predict(L.start), o.process(), this.current = 0;
18376
18404
  }
18377
- N.fail = {}, N.prototype.feed = function(I) {
18378
- var O = this.lexer;
18379
- O.reset(I, this.lexerState);
18405
+ N.fail = {}, N.prototype.feed = function(O) {
18406
+ var I = this.lexer;
18407
+ I.reset(O, this.lexerState);
18380
18408
  for (var s; ; ) {
18381
18409
  try {
18382
- if (s = O.next(), !s)
18410
+ if (s = I.next(), !s)
18383
18411
  break;
18384
18412
  } catch (x) {
18385
18413
  var n = new A(this.grammar, this.current + 1);
@@ -18391,10 +18419,10 @@ function gI() {
18391
18419
  this.options.keepHistory || delete this.table[this.current - 1];
18392
18420
  var o = this.current + 1, n = new A(this.grammar, o);
18393
18421
  this.table.push(n);
18394
- for (var U = s.text !== void 0 ? s.text : s.value, P = O.constructor === S ? s.value : s, l = a.scannable, c = l.length; c--; ) {
18395
- var m = l[c], p = m.rule.symbols[m.dot];
18396
- if (p.test ? p.test(P) : p.type ? p.type === s.type : p.literal === U) {
18397
- var V = m.nextState({ data: P, token: s, isToken: !0, reference: o - 1 });
18422
+ for (var U = s.text !== void 0 ? s.text : s.value, P = I.constructor === S ? s.value : s, c = a.scannable, l = c.length; l--; ) {
18423
+ var H = c[l], B = H.rule.symbols[H.dot];
18424
+ if (B.test ? B.test(P) : B.type ? B.type === s.type : B.literal === U) {
18425
+ var V = H.nextState({ data: P, token: s, isToken: !0, reference: o - 1 });
18398
18426
  n.states.push(V);
18399
18427
  }
18400
18428
  }
@@ -18402,100 +18430,100 @@ function gI() {
18402
18430
  var L = new Error(this.reportError(s));
18403
18431
  throw L.offset = this.current, L.token = s, L;
18404
18432
  }
18405
- this.options.keepHistory && (a.lexerState = O.save()), this.current++;
18433
+ this.options.keepHistory && (a.lexerState = I.save()), this.current++;
18406
18434
  }
18407
- return a && (this.lexerState = O.save()), this.results = this.finish(), this;
18408
- }, N.prototype.reportLexerError = function(I) {
18409
- var O, s, L = I.token;
18410
- return L ? (O = "input " + JSON.stringify(L.text[0]) + " (lexer error)", s = this.lexer.formatError(L, "Syntax error")) : (O = "input (lexer error)", s = I.message), this.reportErrorCommon(s, O);
18411
- }, N.prototype.reportError = function(I) {
18412
- var O = (I.type ? I.type + " token: " : "") + JSON.stringify(I.value !== void 0 ? I.value : I), s = this.lexer.formatError(I, "Syntax error");
18413
- return this.reportErrorCommon(s, O);
18414
- }, N.prototype.reportErrorCommon = function(I, O) {
18435
+ return a && (this.lexerState = I.save()), this.results = this.finish(), this;
18436
+ }, N.prototype.reportLexerError = function(O) {
18437
+ var I, s, L = O.token;
18438
+ return L ? (I = "input " + JSON.stringify(L.text[0]) + " (lexer error)", s = this.lexer.formatError(L, "Syntax error")) : (I = "input (lexer error)", s = O.message), this.reportErrorCommon(s, I);
18439
+ }, N.prototype.reportError = function(O) {
18440
+ var I = (O.type ? O.type + " token: " : "") + JSON.stringify(O.value !== void 0 ? O.value : O), s = this.lexer.formatError(O, "Syntax error");
18441
+ return this.reportErrorCommon(s, I);
18442
+ }, N.prototype.reportErrorCommon = function(O, I) {
18415
18443
  var s = [];
18416
- s.push(I);
18444
+ s.push(O);
18417
18445
  var L = this.table.length - 2, a = this.table[L], o = a.states.filter(function(U) {
18418
18446
  var P = U.rule.symbols[U.dot];
18419
18447
  return P && typeof P != "string";
18420
18448
  });
18421
18449
  if (o.length === 0)
18422
- s.push("Unexpected " + O + `. I did not expect any more input. Here is the state of my parse table:
18450
+ s.push("Unexpected " + I + `. I did not expect any more input. Here is the state of my parse table:
18423
18451
  `), this.displayStateStack(a.states, s);
18424
18452
  else {
18425
- s.push("Unexpected " + O + `. Instead, I was expecting to see one of the following:
18453
+ s.push("Unexpected " + I + `. Instead, I was expecting to see one of the following:
18426
18454
  `);
18427
18455
  var n = o.map(function(U) {
18428
18456
  return this.buildFirstStateStack(U, []) || [U];
18429
18457
  }, this);
18430
18458
  n.forEach(function(U) {
18431
- var P = U[0], l = P.rule.symbols[P.dot], c = this.getSymbolDisplay(l);
18432
- s.push("A " + c + " based on:"), this.displayStateStack(U, s);
18459
+ var P = U[0], c = P.rule.symbols[P.dot], l = this.getSymbolDisplay(c);
18460
+ s.push("A " + l + " based on:"), this.displayStateStack(U, s);
18433
18461
  }, this);
18434
18462
  }
18435
18463
  return s.push(""), s.join(`
18436
18464
  `);
18437
- }, N.prototype.displayStateStack = function(I, O) {
18438
- for (var s, L = 0, a = 0; a < I.length; a++) {
18439
- var o = I[a], n = o.rule.toString(o.dot);
18440
- n === s ? L++ : (L > 0 && O.push(" ^ " + L + " more lines identical to this"), L = 0, O.push(" " + n)), s = n;
18465
+ }, N.prototype.displayStateStack = function(O, I) {
18466
+ for (var s, L = 0, a = 0; a < O.length; a++) {
18467
+ var o = O[a], n = o.rule.toString(o.dot);
18468
+ n === s ? L++ : (L > 0 && I.push(" ^ " + L + " more lines identical to this"), L = 0, I.push(" " + n)), s = n;
18441
18469
  }
18442
- }, N.prototype.getSymbolDisplay = function(I) {
18443
- return t(I);
18444
- }, N.prototype.buildFirstStateStack = function(I, O) {
18445
- if (O.indexOf(I) !== -1)
18470
+ }, N.prototype.getSymbolDisplay = function(O) {
18471
+ return t(O);
18472
+ }, N.prototype.buildFirstStateStack = function(O, I) {
18473
+ if (I.indexOf(O) !== -1)
18446
18474
  return null;
18447
- if (I.wantedBy.length === 0)
18448
- return [I];
18449
- var s = I.wantedBy[0], L = [I].concat(O), a = this.buildFirstStateStack(s, L);
18450
- return a === null ? null : [I].concat(a);
18475
+ if (O.wantedBy.length === 0)
18476
+ return [O];
18477
+ var s = O.wantedBy[0], L = [O].concat(I), a = this.buildFirstStateStack(s, L);
18478
+ return a === null ? null : [O].concat(a);
18451
18479
  }, N.prototype.save = function() {
18452
- var I = this.table[this.current];
18453
- return I.lexerState = this.lexerState, I;
18454
- }, N.prototype.restore = function(I) {
18455
- var O = I.index;
18456
- this.current = O, this.table[O] = I, this.table.splice(O + 1), this.lexerState = I.lexerState, this.results = this.finish();
18457
- }, N.prototype.rewind = function(I) {
18480
+ var O = this.table[this.current];
18481
+ return O.lexerState = this.lexerState, O;
18482
+ }, N.prototype.restore = function(O) {
18483
+ var I = O.index;
18484
+ this.current = I, this.table[I] = O, this.table.splice(I + 1), this.lexerState = O.lexerState, this.results = this.finish();
18485
+ }, N.prototype.rewind = function(O) {
18458
18486
  if (!this.options.keepHistory)
18459
18487
  throw new Error("set option `keepHistory` to enable rewinding");
18460
- this.restore(this.table[I]);
18488
+ this.restore(this.table[O]);
18461
18489
  }, N.prototype.finish = function() {
18462
- var I = [], O = this.grammar.start, s = this.table[this.table.length - 1];
18490
+ var O = [], I = this.grammar.start, s = this.table[this.table.length - 1];
18463
18491
  return s.states.forEach(function(L) {
18464
- L.rule.name === O && L.dot === L.rule.symbols.length && L.reference === 0 && L.data !== N.fail && I.push(L);
18465
- }), I.map(function(L) {
18492
+ L.rule.name === I && L.dot === L.rule.symbols.length && L.reference === 0 && L.data !== N.fail && O.push(L);
18493
+ }), O.map(function(L) {
18466
18494
  return L.data;
18467
18495
  });
18468
18496
  };
18469
- function t(I) {
18470
- var O = typeof I;
18471
- if (O === "string")
18472
- return I;
18473
- if (O === "object") {
18474
- if (I.literal)
18475
- return JSON.stringify(I.literal);
18476
- if (I instanceof RegExp)
18477
- return "character matching " + I;
18478
- if (I.type)
18479
- return I.type + " token";
18480
- if (I.test)
18481
- return "token matching " + String(I.test);
18482
- throw new Error("Unknown symbol type: " + I);
18497
+ function t(O) {
18498
+ var I = typeof O;
18499
+ if (I === "string")
18500
+ return O;
18501
+ if (I === "object") {
18502
+ if (O.literal)
18503
+ return JSON.stringify(O.literal);
18504
+ if (O instanceof RegExp)
18505
+ return "character matching " + O;
18506
+ if (O.type)
18507
+ return O.type + " token";
18508
+ if (O.test)
18509
+ return "token matching " + String(O.test);
18510
+ throw new Error("Unknown symbol type: " + O);
18483
18511
  }
18484
18512
  }
18485
- function r(I) {
18486
- var O = typeof I;
18487
- if (O === "string")
18488
- return I;
18489
- if (O === "object") {
18490
- if (I.literal)
18491
- return JSON.stringify(I.literal);
18492
- if (I instanceof RegExp)
18493
- return I.toString();
18494
- if (I.type)
18495
- return "%" + I.type;
18496
- if (I.test)
18497
- return "<" + String(I.test) + ">";
18498
- throw new Error("Unknown symbol type: " + I);
18513
+ function r(O) {
18514
+ var I = typeof O;
18515
+ if (I === "string")
18516
+ return O;
18517
+ if (I === "object") {
18518
+ if (O.literal)
18519
+ return JSON.stringify(O.literal);
18520
+ if (O instanceof RegExp)
18521
+ return O.toString();
18522
+ if (O.type)
18523
+ return "%" + O.type;
18524
+ if (O.test)
18525
+ return "<" + String(O.test) + ">";
18526
+ throw new Error("Unknown symbol type: " + O);
18499
18527
  }
18500
18528
  }
18501
18529
  return {
@@ -18582,7 +18610,7 @@ var M;
18582
18610
  function gE(T) {
18583
18611
  return T[0];
18584
18612
  }
18585
- const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18613
+ const G = new SR((T) => []), K = ([[T]]) => T, Y = (T) => ({
18586
18614
  type: M.keyword,
18587
18615
  tokenType: T.type,
18588
18616
  text: T.text,
@@ -18591,14 +18619,14 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18591
18619
  type: M.data_type,
18592
18620
  text: T.text,
18593
18621
  raw: T.raw
18594
- }), Y = (T, { leading: E, trailing: R }) => (E?.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), R?.length && (T = Object.assign(Object.assign({}, T), { trailingComments: R })), T), EO = (T, { leading: E, trailing: R }) => {
18622
+ }), p = (T, { leading: E, trailing: R }) => (E?.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), R?.length && (T = Object.assign(Object.assign({}, T), { trailingComments: R })), T), EO = (T, { leading: E, trailing: R }) => {
18595
18623
  if (E?.length) {
18596
18624
  const [A, ...e] = T;
18597
- T = [Y(A, { leading: E }), ...e];
18625
+ T = [p(A, { leading: E }), ...e];
18598
18626
  }
18599
18627
  if (R?.length) {
18600
18628
  const A = T.slice(0, -1), e = T[T.length - 1];
18601
- T = [...A, Y(e, { trailing: R })];
18629
+ T = [...A, p(e, { trailing: R })];
18602
18630
  }
18603
18631
  return T;
18604
18632
  }, TO = {
@@ -18652,14 +18680,14 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18652
18680
  const [e, S] = A;
18653
18681
  return {
18654
18682
  type: M.limit_clause,
18655
- limitKw: Y(F(T), { trailing: E }),
18683
+ limitKw: p(Y(T), { trailing: E }),
18656
18684
  offset: R,
18657
18685
  count: S
18658
18686
  };
18659
18687
  } else
18660
18688
  return {
18661
18689
  type: M.limit_clause,
18662
- limitKw: Y(F(T), { trailing: E }),
18690
+ limitKw: p(Y(T), { trailing: E }),
18663
18691
  count: R
18664
18692
  };
18665
18693
  }
@@ -18675,7 +18703,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18675
18703
  symbols: [G.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT, "select_clause$subexpression$1"],
18676
18704
  postprocess: ([T, [E, R]]) => ({
18677
18705
  type: M.clause,
18678
- nameKw: F(T),
18706
+ nameKw: Y(T),
18679
18707
  children: [E, ...R]
18680
18708
  })
18681
18709
  },
@@ -18684,7 +18712,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18684
18712
  symbols: [G.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT],
18685
18713
  postprocess: ([T]) => ({
18686
18714
  type: M.clause,
18687
- nameKw: F(T),
18715
+ nameKw: Y(T),
18688
18716
  children: []
18689
18717
  })
18690
18718
  },
@@ -18700,7 +18728,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18700
18728
  symbols: [G.has("RESERVED_CLAUSE") ? { type: "RESERVED_CLAUSE" } : RESERVED_CLAUSE, "other_clause$ebnf$1"],
18701
18729
  postprocess: ([T, E]) => ({
18702
18730
  type: M.clause,
18703
- nameKw: F(T),
18731
+ nameKw: Y(T),
18704
18732
  children: E
18705
18733
  })
18706
18734
  },
@@ -18711,7 +18739,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18711
18739
  symbols: [G.has("RESERVED_SET_OPERATION") ? { type: "RESERVED_SET_OPERATION" } : RESERVED_SET_OPERATION, "set_operation$ebnf$1"],
18712
18740
  postprocess: ([T, E]) => ({
18713
18741
  type: M.set_operation,
18714
- nameKw: F(T),
18742
+ nameKw: Y(T),
18715
18743
  children: E
18716
18744
  })
18717
18745
  },
@@ -18735,17 +18763,17 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18735
18763
  {
18736
18764
  name: "expression_with_comments_",
18737
18765
  symbols: ["expression", "_"],
18738
- postprocess: ([T, E]) => Y(T, { trailing: E })
18766
+ postprocess: ([T, E]) => p(T, { trailing: E })
18739
18767
  },
18740
18768
  {
18741
18769
  name: "_expression_with_comments",
18742
18770
  symbols: ["_", "expression"],
18743
- postprocess: ([T, E]) => Y(E, { leading: T })
18771
+ postprocess: ([T, E]) => p(E, { leading: T })
18744
18772
  },
18745
18773
  {
18746
18774
  name: "_andless_expression_with_comments",
18747
18775
  symbols: ["_", "andless_expression"],
18748
- postprocess: ([T, E]) => Y(E, { leading: T })
18776
+ postprocess: ([T, E]) => p(E, { leading: T })
18749
18777
  },
18750
18778
  { name: "free_form_sql$subexpression$1", symbols: ["asteriskless_free_form_sql"] },
18751
18779
  { name: "free_form_sql$subexpression$1", symbols: ["asterisk"] },
@@ -18784,7 +18812,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18784
18812
  symbols: [G.has("ARRAY_IDENTIFIER") ? { type: "ARRAY_IDENTIFIER" } : ARRAY_IDENTIFIER, "_", "square_brackets"],
18785
18813
  postprocess: ([T, E, R]) => ({
18786
18814
  type: M.array_subscript,
18787
- array: Y({ type: M.identifier, quoted: !1, text: T.text }, { trailing: E }),
18815
+ array: p({ type: M.identifier, quoted: !1, text: T.text }, { trailing: E }),
18788
18816
  parenthesis: R
18789
18817
  })
18790
18818
  },
@@ -18793,7 +18821,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18793
18821
  symbols: [G.has("ARRAY_KEYWORD") ? { type: "ARRAY_KEYWORD" } : ARRAY_KEYWORD, "_", "square_brackets"],
18794
18822
  postprocess: ([T, E, R]) => ({
18795
18823
  type: M.array_subscript,
18796
- array: Y(F(T), { trailing: E }),
18824
+ array: p(Y(T), { trailing: E }),
18797
18825
  parenthesis: R
18798
18826
  })
18799
18827
  },
@@ -18802,7 +18830,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18802
18830
  symbols: [G.has("RESERVED_FUNCTION_NAME") ? { type: "RESERVED_FUNCTION_NAME" } : RESERVED_FUNCTION_NAME, "_", "parenthesis"],
18803
18831
  postprocess: ([T, E, R]) => ({
18804
18832
  type: M.function_call,
18805
- nameKw: Y(F(T), { trailing: E }),
18833
+ nameKw: p(Y(T), { trailing: E }),
18806
18834
  parenthesis: R
18807
18835
  })
18808
18836
  },
@@ -18854,9 +18882,9 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18854
18882
  // %ARRAY_IDENTIFIER on the left side of <array_subscript>.
18855
18883
  ([T, E, R, A, [e]]) => ({
18856
18884
  type: M.property_access,
18857
- object: Y(T, { trailing: E }),
18885
+ object: p(T, { trailing: E }),
18858
18886
  operator: R.text,
18859
- property: Y(e, { leading: A })
18887
+ property: p(e, { leading: A })
18860
18888
  })
18861
18889
  )
18862
18890
  },
@@ -18865,10 +18893,10 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18865
18893
  symbols: [G.has("BETWEEN") ? { type: "BETWEEN" } : BETWEEN, "_", "andless_expression_chain", "_", G.has("AND") ? { type: "AND" } : AND, "_", "andless_expression"],
18866
18894
  postprocess: ([T, E, R, A, e, S, N]) => ({
18867
18895
  type: M.between_predicate,
18868
- betweenKw: F(T),
18896
+ betweenKw: Y(T),
18869
18897
  expr1: EO(R, { leading: E, trailing: A }),
18870
- andKw: F(e),
18871
- expr2: [Y(N, { leading: S })]
18898
+ andKw: Y(e),
18899
+ expr2: [p(N, { leading: S })]
18872
18900
  })
18873
18901
  },
18874
18902
  { name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: gE },
@@ -18880,8 +18908,8 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18880
18908
  symbols: [G.has("CASE") ? { type: "CASE" } : CASE, "_", "case_expression$ebnf$1", "case_expression$ebnf$2", G.has("END") ? { type: "END" } : END],
18881
18909
  postprocess: ([T, E, R, A, e]) => ({
18882
18910
  type: M.case_expression,
18883
- caseKw: Y(F(T), { trailing: E }),
18884
- endKw: F(e),
18911
+ caseKw: p(Y(T), { trailing: E }),
18912
+ endKw: Y(e),
18885
18913
  expr: R || [],
18886
18914
  clauses: A
18887
18915
  })
@@ -18891,8 +18919,8 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18891
18919
  symbols: [G.has("WHEN") ? { type: "WHEN" } : WHEN, "_", "expression_chain_", G.has("THEN") ? { type: "THEN" } : THEN, "_", "expression_chain_"],
18892
18920
  postprocess: ([T, E, R, A, e, S]) => ({
18893
18921
  type: M.case_when,
18894
- whenKw: Y(F(T), { trailing: E }),
18895
- thenKw: Y(F(A), { trailing: e }),
18922
+ whenKw: p(Y(T), { trailing: E }),
18923
+ thenKw: p(Y(A), { trailing: e }),
18896
18924
  condition: R,
18897
18925
  result: S
18898
18926
  })
@@ -18902,7 +18930,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18902
18930
  symbols: [G.has("ELSE") ? { type: "ELSE" } : ELSE, "_", "expression_chain_"],
18903
18931
  postprocess: ([T, E, R]) => ({
18904
18932
  type: M.case_else,
18905
- elseKw: Y(F(T), { trailing: E }),
18933
+ elseKw: p(Y(T), { trailing: E }),
18906
18934
  result: R
18907
18935
  })
18908
18936
  },
@@ -18931,7 +18959,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18931
18959
  {
18932
18960
  name: "keyword",
18933
18961
  symbols: ["keyword$subexpression$1"],
18934
- postprocess: ([[T]]) => F(T)
18962
+ postprocess: ([[T]]) => Y(T)
18935
18963
  },
18936
18964
  { name: "data_type$subexpression$1", symbols: [G.has("RESERVED_DATA_TYPE") ? { type: "RESERVED_DATA_TYPE" } : RESERVED_DATA_TYPE] },
18937
18965
  { name: "data_type$subexpression$1", symbols: [G.has("RESERVED_DATA_TYPE_PHRASE") ? { type: "RESERVED_DATA_TYPE_PHRASE" } : RESERVED_DATA_TYPE_PHRASE] },
@@ -18945,7 +18973,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18945
18973
  symbols: [G.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
18946
18974
  postprocess: ([T, E, R]) => ({
18947
18975
  type: M.parameterized_data_type,
18948
- dataType: Y(bT(T), { trailing: E }),
18976
+ dataType: p(bT(T), { trailing: E }),
18949
18977
  parenthesis: R
18950
18978
  })
18951
18979
  },
@@ -18955,7 +18983,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18955
18983
  {
18956
18984
  name: "logic_operator",
18957
18985
  symbols: ["logic_operator$subexpression$1"],
18958
- postprocess: ([[T]]) => F(T)
18986
+ postprocess: ([[T]]) => Y(T)
18959
18987
  },
18960
18988
  { name: "other_keyword$subexpression$1", symbols: [G.has("WHEN") ? { type: "WHEN" } : WHEN] },
18961
18989
  { name: "other_keyword$subexpression$1", symbols: [G.has("THEN") ? { type: "THEN" } : THEN] },
@@ -18964,7 +18992,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18964
18992
  {
18965
18993
  name: "other_keyword",
18966
18994
  symbols: ["other_keyword$subexpression$1"],
18967
- postprocess: ([[T]]) => F(T)
18995
+ postprocess: ([[T]]) => Y(T)
18968
18996
  },
18969
18997
  { name: "_$ebnf$1", symbols: [] },
18970
18998
  { name: "_$ebnf$1", symbols: ["_$ebnf$1", "comment"], postprocess: (T) => T[0].concat([T[1]]) },
@@ -19653,18 +19681,18 @@ async function GO(T, E, R) {
19653
19681
  throw new Error(`Query validation failed: ${A.errors.join(", ")}`);
19654
19682
  const e = /* @__PURE__ */ new Set();
19655
19683
  T.measures?.forEach((r) => {
19656
- const I = r.split(".")[0];
19657
- e.add(I);
19684
+ const O = r.split(".")[0];
19685
+ e.add(O);
19658
19686
  }), T.dimensions?.forEach((r) => {
19659
- const I = r.split(".")[0];
19660
- e.add(I);
19687
+ const O = r.split(".")[0];
19688
+ e.add(O);
19661
19689
  }), T.timeDimensions?.forEach((r) => {
19662
- const I = r.dimension.split(".")[0];
19663
- e.add(I);
19690
+ const O = r.dimension.split(".")[0];
19691
+ e.add(O);
19664
19692
  }), T.filters?.forEach((r) => {
19665
19693
  if ("member" in r) {
19666
- const I = r.member.split(".")[0];
19667
- e.add(I);
19694
+ const O = r.member.split(".")[0];
19695
+ e.add(O);
19668
19696
  }
19669
19697
  });
19670
19698
  const S = e.size > 1;
@@ -19678,8 +19706,8 @@ async function GO(T, E, R) {
19678
19706
  const t = Array.from(e).map((r) => ({
19679
19707
  cube: r,
19680
19708
  query: {
19681
- measures: T.measures?.filter((I) => I.startsWith(r + ".")) || [],
19682
- dimensions: T.dimensions?.filter((I) => I.startsWith(r + ".")) || [],
19709
+ measures: T.measures?.filter((O) => O.startsWith(r + ".")) || [],
19710
+ dimensions: T.dimensions?.filter((O) => O.startsWith(r + ".")) || [],
19683
19711
  filters: T.filters || [],
19684
19712
  timeDimensions: T.timeDimensions || [],
19685
19713
  order: T.order || {},
@@ -19886,27 +19914,27 @@ class UO {
19886
19914
  generateCubeMetadata(E) {
19887
19915
  const R = Object.keys(E.measures), A = Object.keys(E.dimensions), e = new Array(R.length), S = new Array(A.length);
19888
19916
  for (let t = 0; t < R.length; t++) {
19889
- const r = R[t], I = E.measures[r];
19917
+ const r = R[t], O = E.measures[r];
19890
19918
  e[t] = {
19891
19919
  name: `${E.name}.${r}`,
19892
- title: I.title || r,
19893
- shortTitle: I.title || r,
19894
- type: I.type,
19920
+ title: O.title || r,
19921
+ shortTitle: O.title || r,
19922
+ type: O.type,
19895
19923
  format: void 0,
19896
19924
  // Measure doesn't have format field
19897
- description: I.description
19925
+ description: O.description
19898
19926
  };
19899
19927
  }
19900
19928
  for (let t = 0; t < A.length; t++) {
19901
- const r = A[t], I = E.dimensions[r];
19929
+ const r = A[t], O = E.dimensions[r];
19902
19930
  S[t] = {
19903
19931
  name: `${E.name}.${r}`,
19904
- title: I.title || r,
19905
- shortTitle: I.title || r,
19906
- type: I.type,
19932
+ title: O.title || r,
19933
+ shortTitle: O.title || r,
19934
+ type: O.type,
19907
19935
  format: void 0,
19908
19936
  // Dimension doesn't have format field
19909
- description: I.description
19937
+ description: O.description
19910
19938
  };
19911
19939
  }
19912
19940
  const N = [];
@@ -19916,9 +19944,9 @@ class UO {
19916
19944
  N.push({
19917
19945
  targetCube: r.name,
19918
19946
  relationship: t.relationship,
19919
- joinFields: t.on.map((I) => ({
19920
- sourceField: this.getColumnName(I.source),
19921
- targetField: this.getColumnName(I.target)
19947
+ joinFields: t.on.map((O) => ({
19948
+ sourceField: this.getColumnName(O.source),
19949
+ targetField: this.getColumnName(O.target)
19922
19950
  }))
19923
19951
  });
19924
19952
  }