drizzle-cube 0.3.32 → 0.3.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { sql as o, eq as K, and as G, SQL as HE, gte as Ae, lte as Re, arrayContained as YE, arrayOverlaps as VE, arrayContains as $E, isNotNull as Lt, ne as _t, or as le, isNull as ct, notInArray as dt, inArray as be, lt as ye, gt as Fe, StringChunk as wE, sum as q, max as ee, min as ue, count as Tt, countDistinct as WE, desc as vE, asc as Dt } from "drizzle-orm";
1
+ import { sql as o, eq as K, and as b, SQL as HE, gte as Ae, lte as Re, arrayContained as YE, arrayOverlaps as VE, arrayContains as $E, isNotNull as Lt, ne as _t, or as le, isNull as ct, notInArray as dt, inArray as be, lt as ye, gt as Fe, StringChunk as wE, sum as q, max as ee, min as ue, count as Tt, countDistinct as WE, desc as vE, asc as Dt } from "drizzle-orm";
2
2
  class fe {
3
3
  /**
4
4
  * Default implementation returns template unchanged
@@ -2032,7 +2032,7 @@ function at(n, e) {
2032
2032
  function ot(n) {
2033
2033
  return n && typeof n == "object" ? o`${o`${n}`}` : n;
2034
2034
  }
2035
- function F(n, e) {
2035
+ function y(n, e) {
2036
2036
  const t = typeof n == "function" ? n(e) : n;
2037
2037
  return ot(t);
2038
2038
  }
@@ -2073,13 +2073,13 @@ function Rs(n, e) {
2073
2073
  {
2074
2074
  joinType: a,
2075
2075
  table: t,
2076
- condition: G(...r)
2076
+ condition: b(...r)
2077
2077
  },
2078
2078
  {
2079
2079
  joinType: a,
2080
2080
  table: t,
2081
2081
  // This will be replaced with target cube table in query planner
2082
- condition: G(...T)
2082
+ condition: b(...T)
2083
2083
  }
2084
2084
  ],
2085
2085
  junctionSecurityConditions: A
@@ -2288,7 +2288,7 @@ class Ce {
2288
2288
  * Build time dimension expression with granularity using database adapter
2289
2289
  */
2290
2290
  buildTimeDimensionExpression(e, t, E) {
2291
- const s = F(e, E);
2291
+ const s = y(e, E);
2292
2292
  return t ? this.databaseAdapter.buildTimeDimension(t, s) : s instanceof HE ? s : o`${s}`;
2293
2293
  }
2294
2294
  /**
@@ -2304,7 +2304,7 @@ class Ce {
2304
2304
  const i = typeof s == "number" ? new Date(s * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(s), r = new Date(i);
2305
2305
  r.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? s = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(r.getTime() / 1e3) : r.getTime() : s = r.toISOString();
2306
2306
  }
2307
- return G(
2307
+ return b(
2308
2308
  Ae(e, E),
2309
2309
  Re(e, s)
2310
2310
  );
@@ -2313,7 +2313,7 @@ class Ce {
2313
2313
  const E = this.parseRelativeDateRange(t);
2314
2314
  if (E) {
2315
2315
  let R, S;
2316
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (R = Math.floor(E.start.getTime() / 1e3), S = Math.floor(E.end.getTime() / 1e3)) : (R = E.start.getTime(), S = E.end.getTime()) : (R = E.start.toISOString(), S = E.end.toISOString()), G(
2316
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (R = Math.floor(E.start.getTime() / 1e3), S = Math.floor(E.end.getTime() / 1e3)) : (R = E.start.getTime(), S = E.end.getTime()) : (R = E.start.toISOString(), S = E.end.toISOString()), b(
2317
2317
  Ae(e, R),
2318
2318
  Re(e, S)
2319
2319
  );
@@ -2325,7 +2325,7 @@ class Ce {
2325
2325
  const T = new Date(i);
2326
2326
  T.setUTCHours(23, 59, 59, 999);
2327
2327
  let A, a;
2328
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (A = Math.floor(r.getTime() / 1e3), a = Math.floor(T.getTime() / 1e3)) : (A = r.getTime(), a = T.getTime()) : (A = r.toISOString(), a = T.toISOString()), G(
2328
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (A = Math.floor(r.getTime() / 1e3), a = Math.floor(T.getTime() / 1e3)) : (A = r.getTime(), a = T.getTime()) : (A = r.toISOString(), a = T.toISOString()), b(
2329
2329
  Ae(e, A),
2330
2330
  Re(e, a)
2331
2331
  );
@@ -2511,7 +2511,7 @@ class ge {
2511
2511
  const S = typeof a == "number" ? new Date(a * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(a), I = new Date(S);
2512
2512
  I.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? a = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(I.getTime() / 1e3) : I.getTime() : a = I.toISOString();
2513
2513
  }
2514
- return G(
2514
+ return b(
2515
2515
  Ae(e, A),
2516
2516
  Re(e, a)
2517
2517
  );
@@ -2527,7 +2527,7 @@ class ge {
2527
2527
  return A ? Fe(e, A) : null;
2528
2528
  }
2529
2529
  case "between":
2530
- return r.length >= 2 ? G(
2530
+ return r.length >= 2 ? b(
2531
2531
  Ae(e, r[0]),
2532
2532
  Re(e, r[1])
2533
2533
  ) : null;
@@ -2556,7 +2556,7 @@ class ge {
2556
2556
  K(e, "")
2557
2557
  );
2558
2558
  case "isNotEmpty":
2559
- return G(
2559
+ return b(
2560
2560
  Lt(e),
2561
2561
  _t(e, "")
2562
2562
  );
@@ -2579,7 +2579,7 @@ class ge {
2579
2579
  buildLogicalFilter(e, t, E) {
2580
2580
  if ("and" in e && e.and) {
2581
2581
  const s = e.and.map((i) => this.buildSingleFilter(i, t, E)).filter((i) => i !== null);
2582
- return s.length > 0 ? s.length === 1 ? s[0] : G(...s) : null;
2582
+ return s.length > 0 ? s.length === 1 ? s[0] : b(...s) : null;
2583
2583
  }
2584
2584
  if ("or" in e && e.or) {
2585
2585
  const s = e.or.map((i) => this.buildSingleFilter(i, t, E)).filter((i) => i !== null);
@@ -2598,7 +2598,7 @@ class ge {
2598
2598
  if (!T) return null;
2599
2599
  const A = T.dimensions?.[r];
2600
2600
  if (!A) return null;
2601
- const a = F(A.sql, E);
2601
+ const a = y(A.sql, E);
2602
2602
  return this.buildFilterCondition(
2603
2603
  a,
2604
2604
  s.operator,
@@ -2836,12 +2836,12 @@ function us(n, e) {
2836
2836
  throw new Error(
2837
2837
  `Cannot substitute {${I}}: cube '${l}' not found`
2838
2838
  );
2839
- const C = `${l}.${O}`, c = s.get(C);
2840
- if (!c)
2839
+ const C = `${l}.${O}`, _ = s.get(C);
2840
+ if (!_)
2841
2841
  throw new Error(
2842
2842
  `Cannot substitute {${I}}: measure '${C}' not resolved yet. Ensure measures are resolved in dependency order.`
2843
2843
  );
2844
- const U = c(), D = o`${U}`;
2844
+ const U = _(), D = o`${U}`;
2845
2845
  r.set(I, D);
2846
2846
  }
2847
2847
  const T = [], A = [];
@@ -2943,10 +2943,10 @@ class H {
2943
2943
  continue;
2944
2944
  }
2945
2945
  re.isCalculatedMeasure(O) ? (T.push(R), Be(O.calculatedSql, S).forEach((C) => A.add(C)), a.getAllDependencies(R).forEach((C) => {
2946
- const [c, U] = C.split("."), D = t.get(c);
2946
+ const [_, U] = C.split("."), D = t.get(_);
2947
2947
  if (D && D.measures[U]) {
2948
2948
  const m = D.measures[U];
2949
- re.isCalculatedMeasure(m) && Be(m.calculatedSql, c).forEach((M) => A.add(M));
2949
+ re.isCalculatedMeasure(m) && Be(m.calculatedSql, _).forEach((M) => A.add(M));
2950
2950
  }
2951
2951
  })) : r.push(R);
2952
2952
  }
@@ -3124,14 +3124,14 @@ class H {
3124
3124
  throw new Error(
3125
3125
  `Measure '${e.name}' of type '${e.type}' is missing required 'sql' property. Only calculated measures and post-aggregation window functions can omit 'sql'.`
3126
3126
  );
3127
- let s = F(e.sql, t);
3127
+ let s = y(e.sql, t);
3128
3128
  if (e.filters && e.filters.length > 0) {
3129
3129
  const i = e.filters.map((r) => {
3130
3130
  const T = r(t);
3131
3131
  return T ? o`(${T})` : void 0;
3132
3132
  }).filter(Boolean);
3133
3133
  if (i.length > 0) {
3134
- const r = i.length === 1 ? i[0] : G(...i);
3134
+ const r = i.length === 1 ? i[0] : b(...i);
3135
3135
  s = this.databaseAdapter.buildCaseWhen([
3136
3136
  { when: r, then: s }
3137
3137
  ]);
@@ -3200,7 +3200,7 @@ class H {
3200
3200
  if (i.partitionBy && i.partitionBy.length > 0 && E) {
3201
3201
  const a = i.partitionBy.map((R) => {
3202
3202
  const S = R.includes(".") ? R.split(".")[1] : R, I = E.dimensions?.[S];
3203
- return I ? F(I.sql, t) : (console.warn(`[drizzle-cube] Window function partition dimension '${R}' not found in cube '${E.name}'`), null);
3203
+ return I ? y(I.sql, t) : (console.warn(`[drizzle-cube] Window function partition dimension '${R}' not found in cube '${E.name}'`), null);
3204
3204
  }).filter((R) => R !== null);
3205
3205
  a.length > 0 && (r = a);
3206
3206
  }
@@ -3210,12 +3210,12 @@ class H {
3210
3210
  const S = R.field.includes(".") ? R.field.split(".")[1] : R.field, I = E.dimensions?.[S];
3211
3211
  if (I)
3212
3212
  return {
3213
- field: F(I.sql, t),
3213
+ field: y(I.sql, t),
3214
3214
  direction: R.direction
3215
3215
  };
3216
3216
  const N = E.measures?.[S];
3217
3217
  return N && N.sql ? {
3218
- field: F(N.sql, t),
3218
+ field: y(N.sql, t),
3219
3219
  direction: R.direction
3220
3220
  } : (console.warn(`[drizzle-cube] Window function order field '${R.field}' not found in cube '${E.name}'`), null);
3221
3221
  }).filter((R) => R !== null);
@@ -3450,7 +3450,7 @@ class _s {
3450
3450
  if (H.isPostAggregationWindow(l)) {
3451
3451
  const u = H.getWindowBaseMeasure(l, I);
3452
3452
  if (u) {
3453
- const [C, c] = u.split("."), D = r.get(C)?.measures?.[c];
3453
+ const [C, _] = u.split("."), D = r.get(C)?.measures?.[_];
3454
3454
  if (D && this.isAggregateFunctionType(D.type)) {
3455
3455
  R = !0;
3456
3456
  break;
@@ -3466,15 +3466,15 @@ class _s {
3466
3466
  const [I, N] = S.split("."), O = r.get(I);
3467
3467
  if (O && O.dimensions && O.dimensions[N])
3468
3468
  if (s?.preAggregationCTEs?.some((u) => u.cube.name === I)) {
3469
- const u = s.preAggregationCTEs.find((c) => c.cube.name === I), C = u.joinKeys.find((c) => c.targetColumn === N);
3469
+ const u = s.preAggregationCTEs.find((_) => _.cube.name === I), C = u.joinKeys.find((_) => _.targetColumn === N);
3470
3470
  if (C && C.sourceColumnObj)
3471
3471
  i.push(C.sourceColumnObj);
3472
3472
  else {
3473
- const c = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
3474
- i.push(c);
3473
+ const _ = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
3474
+ i.push(_);
3475
3475
  }
3476
3476
  } else {
3477
- const u = O.dimensions[N], C = F(u.sql, E);
3477
+ const u = O.dimensions[N], C = y(u.sql, E);
3478
3478
  i.push(C);
3479
3479
  }
3480
3480
  }
@@ -3483,17 +3483,17 @@ class _s {
3483
3483
  const [I, N] = S.dimension.split("."), O = r.get(I);
3484
3484
  if (O && O.dimensions && O.dimensions[N])
3485
3485
  if (s?.preAggregationCTEs?.some((u) => u.cube.name === I)) {
3486
- const u = s.preAggregationCTEs.find((c) => c.cube.name === I), C = u.joinKeys.find((c) => c.targetColumn === N);
3486
+ const u = s.preAggregationCTEs.find((_) => _.cube.name === I), C = u.joinKeys.find((_) => _.targetColumn === N);
3487
3487
  if (C && C.sourceColumnObj) {
3488
- const c = this.dateTimeBuilder.buildTimeDimensionExpression(
3488
+ const _ = this.dateTimeBuilder.buildTimeDimensionExpression(
3489
3489
  C.sourceColumnObj,
3490
3490
  S.granularity,
3491
3491
  E
3492
3492
  );
3493
- i.push(c);
3493
+ i.push(_);
3494
3494
  } else {
3495
- const c = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
3496
- i.push(c);
3495
+ const _ = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
3496
+ i.push(_);
3497
3497
  }
3498
3498
  } else {
3499
3499
  const u = O.dimensions[N], C = this.dateTimeBuilder.buildTimeDimensionExpression(
@@ -3533,7 +3533,7 @@ class cs {
3533
3533
  for (const r of t.dimensions) {
3534
3534
  const [T, A] = r.split("."), a = i.get(T);
3535
3535
  if (a && a.dimensions && a.dimensions[A]) {
3536
- const R = a.dimensions[A], S = F(R.sql, E);
3536
+ const R = a.dimensions[A], S = y(R.sql, E);
3537
3537
  s[r] = o`${S}`.as(r);
3538
3538
  }
3539
3539
  }
@@ -3634,7 +3634,7 @@ class cs {
3634
3634
  continue;
3635
3635
  }
3636
3636
  }
3637
- const N = I.dimensions[S], O = F(N.sql, E), l = this.buildDateRangeCondition(O, a.dateRange);
3637
+ const N = I.dimensions[S], O = y(N.sql, E), l = this.buildDateRangeCondition(O, a.dateRange);
3638
3638
  l && r.push(l);
3639
3639
  }
3640
3640
  }
@@ -3662,7 +3662,7 @@ class cs {
3662
3662
  const N = e;
3663
3663
  if (N.and) {
3664
3664
  const O = N.and.map((l) => this.processFilter(l, t, E, s, i)).filter((l) => l !== null);
3665
- return O.length > 0 ? G(...O) : null;
3665
+ return O.length > 0 ? b(...O) : null;
3666
3666
  }
3667
3667
  if (N.or) {
3668
3668
  const O = N.or.map((l) => this.processFilter(l, t, E, s, i)).filter((l) => l !== null);
@@ -3682,7 +3682,7 @@ class cs {
3682
3682
  if (u)
3683
3683
  return u;
3684
3684
  }
3685
- const O = N ? typeof R.sql == "function" ? R.sql(E) : R.sql : F(R.sql, E);
3685
+ const O = N ? typeof R.sql == "function" ? R.sql(E) : R.sql : y(R.sql, E);
3686
3686
  return this.buildFilterCondition(
3687
3687
  O,
3688
3688
  r.operator,
@@ -3966,7 +3966,7 @@ class Le {
3966
3966
  const r = t ? o`${o.identifier(t)}.${o.identifier(i.source.name)}` : ot(i.source), T = E ? o`${o.identifier(E)}.${o.identifier(i.target.name)}` : ot(i.target), A = i.as || K;
3967
3967
  s.push(A(r, T));
3968
3968
  }
3969
- return G(...s);
3969
+ return b(...s);
3970
3970
  }
3971
3971
  /**
3972
3972
  * Get all reachable cubes from a starting cube
@@ -4161,13 +4161,13 @@ class LE {
4161
4161
  for (const { fromCube: l, toCube: u, joinDef: C } of O) {
4162
4162
  if (A.has(u))
4163
4163
  continue;
4164
- const c = e.get(u);
4165
- if (!c)
4164
+ const _ = e.get(u);
4165
+ if (!_)
4166
4166
  throw new Error(`Cube '${u}' not found`);
4167
4167
  if (C.relationship === "belongsToMany" && C.through) {
4168
4168
  const U = Rs(C, s.securityContext);
4169
4169
  T.push({
4170
- cube: c,
4170
+ cube: _,
4171
4171
  alias: `${u.toLowerCase()}_cube`,
4172
4172
  joinType: U.junctionJoins[1].joinType,
4173
4173
  // Use the target join type
@@ -4191,7 +4191,7 @@ class LE {
4191
4191
  // No target alias needed - use the actual column
4192
4192
  ), D = at(C.relationship, C.sqlJoinType);
4193
4193
  T.push({
4194
- cube: c,
4194
+ cube: _,
4195
4195
  alias: `${u.toLowerCase()}_cube`,
4196
4196
  joinType: D,
4197
4197
  joinCondition: U
@@ -4253,28 +4253,35 @@ class LE {
4253
4253
  if (u.length === 0)
4254
4254
  continue;
4255
4255
  const C = this.analyzeJoinPathToPrimary(e, t, R.name, i);
4256
- let c, U;
4256
+ let _, U;
4257
4257
  if (C?.hasIntermediateHasMany && C.intermediateJoins.length > 0)
4258
- c = C.correctJoinKeys, U = C.intermediateJoins;
4258
+ _ = C.correctJoinKeys, U = C.intermediateJoins;
4259
4259
  else {
4260
4260
  const f = I ? this.findJoinInfoToCube(e, t.name) : this.findJoinInfoForCube(e, t, R.name);
4261
4261
  if (!f)
4262
4262
  continue;
4263
- f.joinDef.relationship === "belongsToMany" && f.joinDef.through ? c = f.joinDef.through.sourceKey.map((b) => ({
4264
- sourceColumn: b.target.name,
4265
- targetColumn: b.source.name,
4266
- sourceColumnObj: b.target,
4267
- targetColumnObj: b.source
4268
- })) : c = I || "reversed" in f && f.reversed ? f.joinDef.on.map((y) => ({
4269
- sourceColumn: y.target.name,
4270
- targetColumn: y.source.name,
4271
- sourceColumnObj: y.target,
4272
- targetColumnObj: y.source
4273
- })) : f.joinDef.on.map((y) => ({
4274
- sourceColumn: y.source.name,
4275
- targetColumn: y.target.name,
4276
- sourceColumnObj: y.source,
4277
- targetColumnObj: y.target
4263
+ f.joinDef.relationship === "belongsToMany" && f.joinDef.through ? f.sourceCube?.name === t.name && !("reversed" in f && f.reversed) ? _ = f.joinDef.through.targetKey.map((G) => ({
4264
+ sourceColumn: G.source.name,
4265
+ // junction table column
4266
+ targetColumn: G.target.name,
4267
+ // CTE cube column
4268
+ sourceColumnObj: G.source,
4269
+ targetColumnObj: G.target
4270
+ })) : _ = f.joinDef.through.sourceKey.map((G) => ({
4271
+ sourceColumn: G.target.name,
4272
+ targetColumn: G.source.name,
4273
+ sourceColumnObj: G.target,
4274
+ targetColumnObj: G.source
4275
+ })) : _ = I || "reversed" in f && f.reversed ? f.joinDef.on.map((G) => ({
4276
+ sourceColumn: G.target.name,
4277
+ targetColumn: G.source.name,
4278
+ sourceColumnObj: G.target,
4279
+ targetColumnObj: G.source
4280
+ })) : f.joinDef.on.map((G) => ({
4281
+ sourceColumn: G.source.name,
4282
+ targetColumn: G.target.name,
4283
+ sourceColumnObj: G.source,
4284
+ targetColumnObj: G.target
4278
4285
  })), U = void 0;
4279
4286
  }
4280
4287
  const D = this.findPropagatingFilters(s, R, e), m = /* @__PURE__ */ new Map([[R.name, R]]), { aggregateMeasures: P, requiredBaseMeasures: M } = H.categorizeForPostAggregation(
@@ -4288,7 +4295,7 @@ class LE {
4288
4295
  const f = this.expandCalculatedMeasureDependencies(
4289
4296
  R,
4290
4297
  g
4291
- ), b = this.findDownstreamJoinKeys(
4298
+ ), F = this.findDownstreamJoinKeys(
4292
4299
  R,
4293
4300
  s,
4294
4301
  e
@@ -4297,10 +4304,10 @@ class LE {
4297
4304
  cube: R,
4298
4305
  alias: S,
4299
4306
  cteAlias: `${R.name.toLowerCase()}_agg`,
4300
- joinKeys: c,
4307
+ joinKeys: _,
4301
4308
  measures: f,
4302
4309
  propagatingFilters: D.length > 0 ? D : void 0,
4303
- downstreamJoinKeys: b.length > 0 ? b : void 0,
4310
+ downstreamJoinKeys: F.length > 0 ? F : void 0,
4304
4311
  intermediateJoins: U && U.length > 0 ? U : void 0,
4305
4312
  cteType: "aggregate",
4306
4313
  cteReason: N
@@ -4357,11 +4364,11 @@ class LE {
4357
4364
  for (let N = 0; N < T.length - 1; N++) {
4358
4365
  const O = T[N], l = T[N + 1], u = e.get(O.toCube);
4359
4366
  if (!u) continue;
4360
- const c = u.sql(s).where, U = l.joinDef.on[0]?.source, D = O.joinDef.on[0]?.target;
4367
+ const _ = u.sql(s).where, U = l.joinDef.on[0]?.source, D = O.joinDef.on[0]?.target;
4361
4368
  R.push({
4362
4369
  cube: u,
4363
4370
  joinDef: l.joinDef,
4364
- securityFilter: c,
4371
+ securityFilter: _,
4365
4372
  primaryJoinColumn: D,
4366
4373
  cteJoinColumn: U
4367
4374
  });
@@ -4876,26 +4883,26 @@ class LE {
4876
4883
  if (!A)
4877
4884
  continue;
4878
4885
  const a = s.measures.filter(
4879
- (c) => c.startsWith(r + ".")
4886
+ (_) => _.startsWith(r + ".")
4880
4887
  ), R = this.extractMeasuresFromFilters(s, A), S = [.../* @__PURE__ */ new Set([...a, ...R])];
4881
4888
  if (S.length === 0)
4882
4889
  continue;
4883
- const I = T.on.map((c) => ({
4884
- sourceColumn: c.source.name,
4885
- targetColumn: c.target.name
4890
+ const I = T.on.map((_) => ({
4891
+ sourceColumn: _.source.name,
4892
+ targetColumn: _.target.name
4886
4893
  })), N = /* @__PURE__ */ new Map([[r, A]]), { aggregateMeasures: O, postAggWindowMeasures: l, requiredBaseMeasures: u } = H.categorizeForPostAggregation(
4887
4894
  S,
4888
4895
  N
4889
4896
  ), C = [.../* @__PURE__ */ new Set([
4890
4897
  ...O,
4891
- ...Array.from(u).filter((c) => c.startsWith(r + "."))
4898
+ ...Array.from(u).filter((_) => _.startsWith(r + "."))
4892
4899
  ])];
4893
4900
  if (C.length > 0) {
4894
- const c = l.length > 0;
4901
+ const _ = l.length > 0;
4895
4902
  i.push({
4896
4903
  cubeName: r,
4897
4904
  cteAlias: `${r.toLowerCase()}_agg`,
4898
- reason: c ? `hasMany relationship from ${t.name} - requires pre-aggregation; includes base measures for post-aggregation window functions` : `hasMany relationship from ${t.name} - requires pre-aggregation to prevent row duplication (fan-out)`,
4905
+ reason: _ ? `hasMany relationship from ${t.name} - requires pre-aggregation; includes base measures for post-aggregation window functions` : `hasMany relationship from ${t.name} - requires pre-aggregation to prevent row duplication (fan-out)`,
4899
4906
  reasonType: "hasMany",
4900
4907
  measures: C,
4901
4908
  joinKeys: I,
@@ -5022,7 +5029,7 @@ class ds {
5022
5029
  const P = m.cube.sql(E), g = [K(m.cteJoinColumn, m.joinDef.on[0]?.target)];
5023
5030
  m.securityFilter && g.push(m.securityFilter), N = N.leftJoin(
5024
5031
  P.from,
5025
- G(...g)
5032
+ b(...g)
5026
5033
  );
5027
5034
  }
5028
5035
  const O = s ? {
@@ -5033,8 +5040,8 @@ class ds {
5033
5040
  for (const m of t.timeDimensions) {
5034
5041
  const [P, M] = m.dimension.split(".");
5035
5042
  if (P === R && r.dimensions && r.dimensions[M] && m.dateRange) {
5036
- const g = r.dimensions[M], f = this.queryBuilder.buildMeasureExpression({ sql: g.sql, type: "number" }, E), b = this.queryBuilder.buildDateRangeCondition(f, m.dateRange);
5037
- b && u.push(b);
5043
+ const g = r.dimensions[M], f = this.queryBuilder.buildMeasureExpression({ sql: g.sql, type: "number" }, E), F = this.queryBuilder.buildDateRangeCondition(f, m.dateRange);
5044
+ F && u.push(F);
5038
5045
  }
5039
5046
  }
5040
5047
  if (t.filters) {
@@ -5044,8 +5051,8 @@ class ds {
5044
5051
  if (M === R && r.dimensions && r.dimensions[g]) {
5045
5052
  const f = r.dimensions[g];
5046
5053
  if (P.operator === "inDateRange") {
5047
- const b = this.queryBuilder.buildMeasureExpression({ sql: f.sql, type: "number" }, E), y = this.queryBuilder.buildDateRangeCondition(b, P.values);
5048
- y && u.push(y);
5054
+ const F = this.queryBuilder.buildMeasureExpression({ sql: f.sql, type: "number" }, E), G = this.queryBuilder.buildDateRangeCondition(F, P.values);
5055
+ G && u.push(G);
5049
5056
  }
5050
5057
  }
5051
5058
  }
@@ -5060,12 +5067,12 @@ class ds {
5060
5067
  }
5061
5068
  const C = [];
5062
5069
  if (T.where && C.push(T.where), C.push(...l, ...u), C.length > 0) {
5063
- const m = C.length === 1 ? C[0] : G(...C);
5070
+ const m = C.length === 1 ? C[0] : b(...C);
5064
5071
  N = N.where(m);
5065
5072
  }
5066
- const c = [], U = /* @__PURE__ */ new Set(), D = (m) => {
5073
+ const _ = [], U = /* @__PURE__ */ new Set(), D = (m) => {
5067
5074
  const P = m?.name || (typeof m == "string" ? m : null);
5068
- P && !U.has(P) ? (U.add(P), c.push(m)) : P || c.push(m);
5075
+ P && !U.has(P) ? (U.add(P), _.push(m)) : P || _.push(m);
5069
5076
  };
5070
5077
  if (A && e.intermediateJoins) {
5071
5078
  const m = e.intermediateJoins[0];
@@ -5081,8 +5088,8 @@ class ds {
5081
5088
  for (const m of t.dimensions) {
5082
5089
  const [P, M] = m.split(".");
5083
5090
  if (P === R && r.dimensions && r.dimensions[M]) {
5084
- const g = r.dimensions[M], f = F(g.sql, E);
5085
- c.push(f);
5091
+ const g = r.dimensions[M], f = y(g.sql, E);
5092
+ _.push(f);
5086
5093
  }
5087
5094
  }
5088
5095
  if (t.timeDimensions)
@@ -5090,10 +5097,10 @@ class ds {
5090
5097
  const [P, M] = m.dimension.split(".");
5091
5098
  if (P === R && r.dimensions && r.dimensions[M]) {
5092
5099
  const g = r.dimensions[M], f = this.queryBuilder.buildTimeDimensionExpression(g.sql, m.granularity, E);
5093
- c.push(f);
5100
+ _.push(f);
5094
5101
  }
5095
5102
  }
5096
- return c.length > 0 && (N = N.groupBy(...c)), E.db.$with(e.cteAlias).as(N);
5103
+ return _.length > 0 && (N = N.groupBy(..._)), E.db.$with(e.cteAlias).as(N);
5097
5104
  }
5098
5105
  /**
5099
5106
  * Build join condition for CTE
@@ -5119,7 +5126,7 @@ class ds {
5119
5126
  const T = r.sourceColumnObj || o.identifier(r.sourceColumn), A = o`${o.identifier(t)}.${o.identifier(r.targetColumn)}`;
5120
5127
  i.push(K(T, A));
5121
5128
  }
5122
- return i.length === 1 ? i[0] : G(...i);
5129
+ return i.length === 1 ? i[0] : b(...i);
5123
5130
  }
5124
5131
  /**
5125
5132
  * Build a subquery filter for propagating filters from related cubes.
@@ -5148,12 +5155,12 @@ class ds {
5148
5155
  }
5149
5156
  if (i.length === 0)
5150
5157
  return null;
5151
- const r = i.length === 1 ? i[0] : G(...i), T = e.joinConditions;
5158
+ const r = i.length === 1 ? i[0] : b(...i), T = e.joinConditions;
5152
5159
  if (T.length === 1) {
5153
5160
  const { source: A, target: a } = T[0], R = t.db.select({ pk: A }).from(s.from).where(r);
5154
5161
  return o`${a} IN ${R}`;
5155
5162
  } else {
5156
- const A = T.map((S) => K(S.source, S.target)), a = G(
5163
+ const A = T.map((S) => K(S.source, S.target)), a = b(
5157
5164
  ...A,
5158
5165
  r
5159
5166
  ), R = t.db.select({ one: o`1` }).from(s.from).where(a);
@@ -5268,10 +5275,10 @@ function Ms(n, e) {
5268
5275
  [t]: l
5269
5276
  };
5270
5277
  if (N)
5271
- for (const c of T)
5272
- C[c] = N[c];
5273
- for (const c of r)
5274
- C[c] = i;
5278
+ for (const _ of T)
5279
+ C[_] = N[_];
5280
+ for (const _ of r)
5281
+ C[_] = i;
5275
5282
  R.push(C);
5276
5283
  }
5277
5284
  }
@@ -5687,7 +5694,7 @@ class hs {
5687
5694
  const [, T] = e.bindingKey.split("."), A = t.dimensions?.[T];
5688
5695
  if (!A)
5689
5696
  throw new Error(`Binding key dimension not found: ${e.bindingKey}`);
5690
- return F(A.sql, E);
5697
+ return y(A.sql, E);
5691
5698
  }
5692
5699
  const s = e.bindingKey.find((T) => T.cube === t.name);
5693
5700
  if (!s)
@@ -5695,7 +5702,7 @@ class hs {
5695
5702
  const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
5696
5703
  if (!r)
5697
5704
  throw new Error(`Binding key dimension not found: ${s.dimension}`);
5698
- return F(r.sql, E);
5705
+ return y(r.sql, E);
5699
5706
  }
5700
5707
  /**
5701
5708
  * Resolve time dimension expression for a cube
@@ -5705,7 +5712,7 @@ class hs {
5705
5712
  const [, T] = e.timeDimension.split("."), A = t.dimensions?.[T];
5706
5713
  if (!A)
5707
5714
  throw new Error(`Time dimension not found: ${e.timeDimension}`);
5708
- return F(A.sql, E);
5715
+ return y(A.sql, E);
5709
5716
  }
5710
5717
  const s = e.timeDimension.find((T) => T.cube === t.name);
5711
5718
  if (!s)
@@ -5713,7 +5720,7 @@ class hs {
5713
5720
  const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
5714
5721
  if (!r)
5715
5722
  throw new Error(`Time dimension not found: ${s.dimension}`);
5716
- return F(r.sql, E);
5723
+ return y(r.sql, E);
5717
5724
  }
5718
5725
  /**
5719
5726
  * Build filter conditions for a step
@@ -5747,20 +5754,20 @@ class hs {
5747
5754
  if (r) {
5748
5755
  const C = e;
5749
5756
  u = C.type === "and";
5750
- for (const c of C.filters || []) {
5751
- const U = this.buildFilterCondition(c, t, E, s);
5757
+ for (const _ of C.filters || []) {
5758
+ const U = this.buildFilterCondition(_, t, E, s);
5752
5759
  U && l.push(U);
5753
5760
  }
5754
5761
  } else {
5755
5762
  const C = e;
5756
5763
  u = "and" in C && !!C.and;
5757
- const c = C.and || C.or || [];
5758
- for (const U of c) {
5764
+ const _ = C.and || C.or || [];
5765
+ for (const U of _) {
5759
5766
  const D = this.buildFilterCondition(U, t, E, s);
5760
5767
  D && l.push(D);
5761
5768
  }
5762
5769
  }
5763
- return l.length === 0 ? null : l.length === 1 ? l[0] : u ? G(...l) : o`(${o.join(l, o` OR `)})`;
5770
+ return l.length === 0 ? null : l.length === 1 ? l[0] : u ? b(...l) : o`(${o.join(l, o` OR `)})`;
5764
5771
  }
5765
5772
  const T = e, [A, a] = T.member.split("."), R = T.dateRange !== void 0;
5766
5773
  if (T.operator !== "set" && T.operator !== "notSet" && !R && (!T.values || T.values.length === 0 || T.values[0] === void 0 || T.values[0] === ""))
@@ -5777,7 +5784,7 @@ class hs {
5777
5784
  }
5778
5785
  const N = I.dimensions?.[a];
5779
5786
  if (!N) return null;
5780
- const O = F(N.sql, s);
5787
+ const O = y(N.sql, s);
5781
5788
  return this.filterBuilder.buildFilterCondition(
5782
5789
  O,
5783
5790
  T.operator,
@@ -5816,7 +5823,7 @@ class hs {
5816
5823
  step_time: o`MIN(${e.timeExpr})`.as("step_time")
5817
5824
  }).from(s.from);
5818
5825
  if (r = this.addCrossJoinsToQuery(r, e, t, i), i.length > 0) {
5819
- const T = i.length === 1 ? i[0] : G(...i);
5826
+ const T = i.length === 1 ? i[0] : b(...i);
5820
5827
  r = r.where(T);
5821
5828
  }
5822
5829
  return r = r.groupBy(e.bindingKeyExpr), t.db.$with(E).as(r);
@@ -5849,7 +5856,7 @@ class hs {
5849
5856
  o`${e.bindingKeyExpr} = ${o.identifier(i)}.binding_key`
5850
5857
  );
5851
5858
  if (R = this.addCrossJoinsToQuery(R, e, t, T), T.length > 0) {
5852
- const S = T.length === 1 ? T[0] : G(...T);
5859
+ const S = T.length === 1 ? T[0] : b(...T);
5853
5860
  R = R.where(S);
5854
5861
  }
5855
5862
  return R = R.groupBy(e.bindingKeyExpr), t.db.$with(s).as(R);
@@ -5866,7 +5873,7 @@ class hs {
5866
5873
  const T = r.joinDef, A = [];
5867
5874
  for (const I of T.on)
5868
5875
  I.as ? A.push(I.as(I.source, I.target)) : A.push(K(I.source, I.target));
5869
- const a = A.length === 1 ? A[0] : G(...A), S = i.cube.sql(E);
5876
+ const a = A.length === 1 ? A[0] : b(...A), S = i.cube.sql(E);
5870
5877
  e = e.leftJoin(S.from, a), S.where && s.push(S.where);
5871
5878
  }
5872
5879
  return e;
@@ -6115,7 +6122,7 @@ class gs {
6115
6122
  const [, T] = e.bindingKey.split("."), A = t.dimensions?.[T];
6116
6123
  if (!A)
6117
6124
  throw new Error(`Binding key dimension not found: ${e.bindingKey}`);
6118
- return F(A.sql, E);
6125
+ return y(A.sql, E);
6119
6126
  }
6120
6127
  const s = e.bindingKey.find((T) => T.cube === t.name);
6121
6128
  if (!s)
@@ -6123,7 +6130,7 @@ class gs {
6123
6130
  const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
6124
6131
  if (!r)
6125
6132
  throw new Error(`Binding key dimension not found: ${s.dimension}`);
6126
- return F(r.sql, E);
6133
+ return y(r.sql, E);
6127
6134
  }
6128
6135
  /**
6129
6136
  * Resolve time dimension expression
@@ -6133,7 +6140,7 @@ class gs {
6133
6140
  const [, T] = e.timeDimension.split("."), A = t.dimensions?.[T];
6134
6141
  if (!A)
6135
6142
  throw new Error(`Time dimension not found: ${e.timeDimension}`);
6136
- return F(A.sql, E);
6143
+ return y(A.sql, E);
6137
6144
  }
6138
6145
  const s = e.timeDimension.find((T) => T.cube === t.name);
6139
6146
  if (!s)
@@ -6141,7 +6148,7 @@ class gs {
6141
6148
  const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
6142
6149
  if (!r)
6143
6150
  throw new Error(`Time dimension not found: ${s.dimension}`);
6144
- return F(r.sql, E);
6151
+ return y(r.sql, E);
6145
6152
  }
6146
6153
  /**
6147
6154
  * Resolve event dimension expression
@@ -6150,7 +6157,7 @@ class gs {
6150
6157
  const [, s] = e.eventDimension.split("."), i = t.dimensions?.[s];
6151
6158
  if (!i)
6152
6159
  throw new Error(`Event dimension not found: ${e.eventDimension}`);
6153
- return F(i.sql, E);
6160
+ return y(i.sql, E);
6154
6161
  }
6155
6162
  /**
6156
6163
  * Build filter conditions for the starting step
@@ -6175,7 +6182,7 @@ class gs {
6175
6182
  const I = this.buildFilterCondition(S, t, E);
6176
6183
  I && a.push(I);
6177
6184
  }
6178
- return a.length === 0 ? null : a.length === 1 ? a[0] : "and" in e ? G(...a) : o`(${o.join(a, o` OR `)})`;
6185
+ return a.length === 0 ? null : a.length === 1 ? a[0] : "and" in e ? b(...a) : o`(${o.join(a, o` OR `)})`;
6179
6186
  }
6180
6187
  if ("type" in e && "filters" in e) {
6181
6188
  const A = e, a = [];
@@ -6183,11 +6190,11 @@ class gs {
6183
6190
  const S = this.buildFilterCondition(R, t, E);
6184
6191
  S && a.push(S);
6185
6192
  }
6186
- return a.length === 0 ? null : a.length === 1 ? a[0] : A.type === "and" ? G(...a) : o`(${o.join(a, o` OR `)})`;
6193
+ return a.length === 0 ? null : a.length === 1 ? a[0] : A.type === "and" ? b(...a) : o`(${o.join(a, o` OR `)})`;
6187
6194
  }
6188
6195
  const s = e, [, i] = s.member.split("."), r = t.dimensions?.[i];
6189
6196
  if (!r) return null;
6190
- const T = F(r.sql, E);
6197
+ const T = y(r.sql, E);
6191
6198
  return this.filterBuilder.buildFilterCondition(
6192
6199
  T,
6193
6200
  s.operator,
@@ -6215,7 +6222,7 @@ class gs {
6215
6222
  event_path: o`${T}`.as("event_path")
6216
6223
  }).from(s.from);
6217
6224
  if (a.length > 0) {
6218
- const S = a.length === 1 ? a[0] : G(...a);
6225
+ const S = a.length === 1 ? a[0] : b(...a);
6219
6226
  R = R.where(S);
6220
6227
  }
6221
6228
  return R = R.groupBy(i, T), e.entityLimit && (R = R.limit(e.entityLimit)), E.db.$with("starting_entities").as(R);
@@ -6232,12 +6239,12 @@ class gs {
6232
6239
  o`${i} = ${o.identifier(S)}.binding_key`,
6233
6240
  o`${r} < ${o.identifier(S)}.${o.identifier(I)}`
6234
6241
  );
6235
- const l = O.length === 1 ? O[0] : G(...O), u = a ? o`${T} || ${"→"} || ${o.identifier(S)}.event_path` : o`${T}`, C = E.db.select({
6242
+ const l = O.length === 1 ? O[0] : b(...O), u = a ? o`${T} || ${"→"} || ${o.identifier(S)}.event_path` : o`${T}`, C = E.db.select({
6236
6243
  binding_key: o`${i}`.as("binding_key"),
6237
6244
  step_time: o`${r}`.as("step_time"),
6238
6245
  event_type: o`${T}`.as("event_type"),
6239
6246
  event_path: u.as("event_path")
6240
- }).from(s.from).where(l).orderBy(o`${r} DESC`).limit(1), c = E.db.$with(N).as(
6247
+ }).from(s.from).where(l).orderBy(o`${r} DESC`).limit(1), _ = E.db.$with(N).as(
6241
6248
  E.db.select({
6242
6249
  binding_key: o`e.binding_key`.as("binding_key"),
6243
6250
  step_time: o`e.step_time`.as("step_time"),
@@ -6245,7 +6252,7 @@ class gs {
6245
6252
  event_path: o`e.event_path`.as("event_path")
6246
6253
  }).from(o`${o.identifier(S)}`).crossJoinLateral(C.as("e"))
6247
6254
  );
6248
- A.push(c);
6255
+ A.push(_);
6249
6256
  }
6250
6257
  return A;
6251
6258
  }
@@ -6261,12 +6268,12 @@ class gs {
6261
6268
  o`${i} = ${o.identifier(S)}.binding_key`,
6262
6269
  o`${r} > ${o.identifier(S)}.${o.identifier(I)}`
6263
6270
  );
6264
- const l = O.length === 1 ? O[0] : G(...O), u = a ? o`${o.identifier(S)}.event_path || ${"→"} || ${T}` : o`${T}`, C = E.db.select({
6271
+ const l = O.length === 1 ? O[0] : b(...O), u = a ? o`${o.identifier(S)}.event_path || ${"→"} || ${T}` : o`${T}`, C = E.db.select({
6265
6272
  binding_key: o`${i}`.as("binding_key"),
6266
6273
  step_time: o`${r}`.as("step_time"),
6267
6274
  event_type: o`${T}`.as("event_type"),
6268
6275
  event_path: u.as("event_path")
6269
- }).from(s.from).where(l).orderBy(o`${r} ASC`).limit(1), c = E.db.$with(N).as(
6276
+ }).from(s.from).where(l).orderBy(o`${r} ASC`).limit(1), _ = E.db.$with(N).as(
6270
6277
  E.db.select({
6271
6278
  binding_key: o`e.binding_key`.as("binding_key"),
6272
6279
  step_time: o`e.step_time`.as("step_time"),
@@ -6274,7 +6281,7 @@ class gs {
6274
6281
  event_path: o`e.event_path`.as("event_path")
6275
6282
  }).from(o`${o.identifier(S)}`).crossJoinLateral(C.as("e"))
6276
6283
  );
6277
- A.push(c);
6284
+ A.push(_);
6278
6285
  }
6279
6286
  return A;
6280
6287
  }
@@ -6292,7 +6299,7 @@ class gs {
6292
6299
  s.where && O.push(s.where), O.push(
6293
6300
  o`${r} < ${o.identifier(S)}.${o.identifier(I)}`
6294
6301
  );
6295
- const l = O.length === 1 ? O[0] : G(...O), u = a ? o`${T} || ${"→"} || ${o.identifier(S)}.event_path` : o`${T}`, C = E.db.select({
6302
+ const l = O.length === 1 ? O[0] : b(...O), u = a ? o`${T} || ${"→"} || ${o.identifier(S)}.event_path` : o`${T}`, C = E.db.select({
6296
6303
  binding_key: o`${i}`.as("binding_key"),
6297
6304
  step_time: o`${r}`.as("step_time"),
6298
6305
  event_type: o`${T}`.as("event_type"),
@@ -6301,13 +6308,13 @@ class gs {
6301
6308
  }).from(s.from).innerJoin(
6302
6309
  o`${o.identifier(S)}`,
6303
6310
  o`${i} = ${o.identifier(S)}.binding_key`
6304
- ).where(l), c = E.db.select({
6311
+ ).where(l), _ = E.db.select({
6305
6312
  binding_key: o`binding_key`.as("binding_key"),
6306
6313
  step_time: o`step_time`.as("step_time"),
6307
6314
  event_type: o`event_type`.as("event_type"),
6308
6315
  event_path: o`event_path`.as("event_path")
6309
6316
  }).from(C.as("ranked")).where(o`rn = 1`);
6310
- A.push(E.db.$with(N).as(c));
6317
+ A.push(E.db.$with(N).as(_));
6311
6318
  }
6312
6319
  return A;
6313
6320
  }
@@ -6325,7 +6332,7 @@ class gs {
6325
6332
  s.where && O.push(s.where), O.push(
6326
6333
  o`${r} > ${o.identifier(S)}.${o.identifier(I)}`
6327
6334
  );
6328
- const l = O.length === 1 ? O[0] : G(...O), u = a ? o`${o.identifier(S)}.event_path || ${"→"} || ${T}` : o`${T}`, C = E.db.select({
6335
+ const l = O.length === 1 ? O[0] : b(...O), u = a ? o`${o.identifier(S)}.event_path || ${"→"} || ${T}` : o`${T}`, C = E.db.select({
6329
6336
  binding_key: o`${i}`.as("binding_key"),
6330
6337
  step_time: o`${r}`.as("step_time"),
6331
6338
  event_type: o`${T}`.as("event_type"),
@@ -6334,13 +6341,13 @@ class gs {
6334
6341
  }).from(s.from).innerJoin(
6335
6342
  o`${o.identifier(S)}`,
6336
6343
  o`${i} = ${o.identifier(S)}.binding_key`
6337
- ).where(l), c = E.db.select({
6344
+ ).where(l), _ = E.db.select({
6338
6345
  binding_key: o`binding_key`.as("binding_key"),
6339
6346
  step_time: o`step_time`.as("step_time"),
6340
6347
  event_type: o`event_type`.as("event_type"),
6341
6348
  event_path: o`event_path`.as("event_path")
6342
6349
  }).from(C.as("ranked")).where(o`rn = 1`);
6343
- A.push(E.db.$with(N).as(c));
6350
+ A.push(E.db.$with(N).as(_));
6344
6351
  }
6345
6352
  return A;
6346
6353
  }
@@ -6704,12 +6711,12 @@ class Gs {
6704
6711
  const T = r.dimensions?.[i];
6705
6712
  if (!T)
6706
6713
  throw new Error(`Time dimension not found: ${i}`);
6707
- const A = F(T.sql, E), a = this.resolveBindingKey(e.bindingKey, r, t, E), R = this.buildFilterConditions(e.cohortFilters, r, t, E), S = this.buildFilterConditions(e.activityFilters, r, t, E), I = [];
6714
+ const A = y(T.sql, E), a = this.resolveBindingKey(e.bindingKey, r, t, E), R = this.buildFilterConditions(e.cohortFilters, r, t, E), S = this.buildFilterConditions(e.activityFilters, r, t, E), I = [];
6708
6715
  if (e.breakdownDimensions && e.breakdownDimensions.length > 0)
6709
6716
  for (const N of e.breakdownDimensions) {
6710
6717
  const [O, l] = N.split("."), u = t.get(O);
6711
6718
  if (u && u.dimensions?.[l]) {
6712
- const C = F(u.dimensions[l].sql, E);
6719
+ const C = y(u.dimensions[l].sql, E);
6713
6720
  I.push({ dimension: N, expr: C });
6714
6721
  }
6715
6722
  }
@@ -6729,7 +6736,7 @@ class Gs {
6729
6736
  const I = S.dimensions?.[R];
6730
6737
  if (!I)
6731
6738
  throw new Error(`Binding key dimension not found: ${a.dimension}`);
6732
- return F(I.sql, s);
6739
+ return y(I.sql, s);
6733
6740
  }
6734
6741
  const [i, r] = e.split("."), T = E.get(i);
6735
6742
  if (!T)
@@ -6737,7 +6744,7 @@ class Gs {
6737
6744
  const A = T.dimensions?.[r];
6738
6745
  if (!A)
6739
6746
  throw new Error(`Binding key dimension not found: ${e}`);
6740
- return F(A.sql, s);
6747
+ return y(A.sql, s);
6741
6748
  }
6742
6749
  /**
6743
6750
  * Build filter conditions from config filters
@@ -6761,13 +6768,13 @@ class Gs {
6761
6768
  const u = this.buildSingleFilterCondition(l, t, E, s);
6762
6769
  u && I.push(u);
6763
6770
  }
6764
- return I.length === 0 ? null : I.length === 1 ? I[0] : N ? G(...I) : o`(${o.join(I, o` OR `)})`;
6771
+ return I.length === 0 ? null : I.length === 1 ? I[0] : N ? b(...I) : o`(${o.join(I, o` OR `)})`;
6765
6772
  }
6766
6773
  const i = e, [r, T] = i.member.split("."), A = E.get(r);
6767
6774
  if (!A) return null;
6768
6775
  const a = A.dimensions?.[T];
6769
6776
  if (!a) return null;
6770
- const R = F(a.sql, s);
6777
+ const R = y(a.sql, s);
6771
6778
  return this.filterBuilder.buildFilterCondition(
6772
6779
  R,
6773
6780
  i.operator,
@@ -6803,7 +6810,7 @@ class Gs {
6803
6810
  }
6804
6811
  let A = E.db.select(T).from(s.from);
6805
6812
  if (i.length > 0) {
6806
- const R = i.length === 1 ? i[0] : G(...i);
6813
+ const R = i.length === 1 ? i[0] : b(...i);
6807
6814
  A = A.where(R);
6808
6815
  }
6809
6816
  const a = [t.bindingKeyExpr];
@@ -6858,7 +6865,7 @@ class Gs {
6858
6865
  o`${t.bindingKeyExpr} = cohort_base.binding_key`
6859
6866
  );
6860
6867
  if (i.length > 0) {
6861
- const S = i.length === 1 ? i[0] : G(...i);
6868
+ const S = i.length === 1 ? i[0] : b(...i);
6862
6869
  a = a.where(S);
6863
6870
  }
6864
6871
  const R = [
@@ -6999,19 +7006,19 @@ class ne {
6999
7006
  });
7000
7007
  else
7001
7008
  try {
7002
- const C = Date.now(), c = await this.cacheConfig.provider.get(i);
7003
- if (c)
7009
+ const C = Date.now(), _ = await this.cacheConfig.provider.get(i);
7010
+ if (_)
7004
7011
  return this.cacheConfig.onCacheEvent?.({
7005
7012
  type: "hit",
7006
7013
  key: i,
7007
7014
  durationMs: Date.now() - C
7008
7015
  }), {
7009
- ...c.value,
7010
- cache: c.metadata ? {
7016
+ ..._.value,
7017
+ cache: _.metadata ? {
7011
7018
  hit: !0,
7012
- cachedAt: new Date(c.metadata.cachedAt).toISOString(),
7013
- ttlMs: c.metadata.ttlMs,
7014
- ttlRemainingMs: c.metadata.ttlRemainingMs
7019
+ cachedAt: new Date(_.metadata.cachedAt).toISOString(),
7020
+ ttlMs: _.metadata.ttlMs,
7021
+ ttlRemainingMs: _.metadata.ttlRemainingMs
7015
7022
  } : {
7016
7023
  hit: !0,
7017
7024
  cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -7045,19 +7052,19 @@ class ne {
7045
7052
  const A = this.queryPlanner.createQueryPlan(e, t, T);
7046
7053
  this.validateSecurityContext(A, T);
7047
7054
  const a = this.buildUnifiedQuery(A, t, T), R = this.queryBuilder.collectNumericFields(e, t), S = await this.dbExecutor.execute(a, R), I = Array.isArray(S) ? S.map((C) => {
7048
- const c = { ...C };
7055
+ const _ = { ...C };
7049
7056
  if (t.timeDimensions) {
7050
7057
  for (const U of t.timeDimensions)
7051
- if (U.dimension in c) {
7052
- let D = c[U.dimension];
7058
+ if (U.dimension in _) {
7059
+ let D = _[U.dimension];
7053
7060
  if (typeof D == "string" && D.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
7054
7061
  const m = D.replace(" ", "T"), P = !m.endsWith("Z") && !m.includes("+") ? m + "Z" : m;
7055
7062
  D = new Date(P);
7056
7063
  }
7057
- D = this.databaseAdapter.convertTimeDimensionResult(D), c[U.dimension] = D;
7064
+ D = this.databaseAdapter.convertTimeDimensionResult(D), _[U.dimension] = D;
7058
7065
  }
7059
7066
  }
7060
- return c;
7067
+ return _;
7061
7068
  }) : [S], N = t.measures || [], O = ht(I, t, N), l = this.generateAnnotations(A, t), u = {
7062
7069
  data: O,
7063
7070
  annotation: l,
@@ -7336,7 +7343,7 @@ class ne {
7336
7343
  if (u.dimension in l) {
7337
7344
  let C = l[u.dimension];
7338
7345
  if (typeof C == "string" && C.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
7339
- const c = C.replace(" ", "T"), U = !c.endsWith("Z") && !c.includes("+") ? c + "Z" : c;
7346
+ const _ = C.replace(" ", "T"), U = !_.endsWith("Z") && !_.includes("+") ? _ + "Z" : _;
7340
7347
  C = new Date(U);
7341
7348
  }
7342
7349
  C = this.databaseAdapter.convertTimeDimensionResult(C), l[u.dimension] = C;
@@ -7391,15 +7398,15 @@ class ne {
7391
7398
  if (!s.has(P)) {
7392
7399
  const g = {
7393
7400
  filters: m.filters
7394
- }, f = /* @__PURE__ */ new Map([[P, m.sourceCube]]), b = this.queryBuilder.buildWhereConditions(
7401
+ }, f = /* @__PURE__ */ new Map([[P, m.sourceCube]]), F = this.queryBuilder.buildWhereConditions(
7395
7402
  f,
7396
7403
  g,
7397
7404
  E
7398
7405
  );
7399
- s.set(P, b);
7406
+ s.set(P, F);
7400
7407
  }
7401
7408
  const M = s.get(P);
7402
- M && M.length > 0 && (m.preBuiltFilterSQL = M.length === 1 ? M[0] : G(...M));
7409
+ M && M.length > 0 && (m.preBuiltFilterSQL = M.length === 1 ? M[0] : b(...M));
7403
7410
  }
7404
7411
  }
7405
7412
  const i = [], r = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map();
@@ -7426,10 +7433,10 @@ class ne {
7426
7433
  if (S[P]) {
7427
7434
  const [, M] = P.split("."), g = a.get(m);
7428
7435
  if (g && g.measures && g.measures[M]) {
7429
- const f = g.measures[M], b = o`${o.identifier(D.cteAlias)}.${o.identifier(M)}`;
7430
- let y;
7436
+ const f = g.measures[M], F = o`${o.identifier(D.cteAlias)}.${o.identifier(M)}`;
7437
+ let G;
7431
7438
  if (f.type === "calculated" && f.calculatedSql)
7432
- y = this.queryBuilder.buildCTECalculatedMeasure(
7439
+ G = this.queryBuilder.buildCTECalculatedMeasure(
7433
7440
  f,
7434
7441
  g,
7435
7442
  D,
@@ -7446,38 +7453,38 @@ class ne {
7446
7453
  case "count":
7447
7454
  case "countDistinct":
7448
7455
  case "sum":
7449
- y = w ? ee(b) : q(b);
7456
+ G = w ? ee(F) : q(F);
7450
7457
  break;
7451
7458
  case "avg":
7452
- y = w ? ee(b) : this.databaseAdapter.buildAvg(b);
7459
+ G = w ? ee(F) : this.databaseAdapter.buildAvg(F);
7453
7460
  break;
7454
7461
  case "min":
7455
- y = ue(b);
7462
+ G = ue(F);
7456
7463
  break;
7457
7464
  case "max":
7458
- y = ee(b);
7465
+ G = ee(F);
7459
7466
  break;
7460
7467
  case "number":
7461
- y = w ? ee(b) : q(b);
7468
+ G = w ? ee(F) : q(F);
7462
7469
  break;
7463
7470
  default:
7464
- y = w ? ee(b) : q(b);
7471
+ G = w ? ee(F) : q(F);
7465
7472
  }
7466
7473
  }
7467
- S[P] = o`${y}`.as(P);
7474
+ S[P] = o`${G}`.as(P);
7468
7475
  }
7469
7476
  }
7470
7477
  for (const P in S) {
7471
7478
  const [M, g] = P.split(".");
7472
7479
  if (M === m) {
7473
- const f = a.get(m), b = f && f.dimensions?.[g], y = P.startsWith(m + ".");
7474
- if (b || y) {
7480
+ const f = a.get(m), F = f && f.dimensions?.[g], G = P.startsWith(m + ".");
7481
+ if (F || G) {
7475
7482
  let B = D.joinKeys.find((W) => W.targetColumn === g);
7476
7483
  if (!B && f?.dimensions?.[g]) {
7477
7484
  const W = f.dimensions[g].sql;
7478
7485
  B = D.joinKeys.find((w) => w.targetColumnObj === W);
7479
7486
  }
7480
- B ? S[P] = o`${o.identifier(D.cteAlias)}.${o.identifier(g)}`.as(P) : y && f?.dimensions?.[g] && (S[P] = o`${o.identifier(D.cteAlias)}.${o.identifier(g)}`.as(P));
7487
+ B ? S[P] = o`${o.identifier(D.cteAlias)}.${o.identifier(g)}`.as(P) : G && f?.dimensions?.[g] && (S[P] = o`${o.identifier(D.cteAlias)}.${o.identifier(g)}`.as(P));
7481
7488
  }
7482
7489
  }
7483
7490
  }
@@ -7490,14 +7497,14 @@ class ne {
7490
7497
  if (H.isPostAggregationWindow(g)) {
7491
7498
  const f = H.getWindowBaseMeasure(g, m);
7492
7499
  if (f) {
7493
- const [b, y] = f.split("."), B = a.get(b);
7494
- if (B?.measures?.[y]) {
7495
- const W = B.measures[y], w = e.preAggregationCTEs?.find(
7496
- (k) => k.cube?.name === b && k.measures?.includes(f)
7500
+ const [F, G] = f.split("."), B = a.get(F);
7501
+ if (B?.measures?.[G]) {
7502
+ const W = B.measures[G], w = e.preAggregationCTEs?.find(
7503
+ (k) => k.cube?.name === F && k.measures?.includes(f)
7497
7504
  );
7498
7505
  let X;
7499
7506
  if (w) {
7500
- const k = o`${o.identifier(w.cteAlias)}.${o.identifier(y)}`;
7507
+ const k = o`${o.identifier(w.cteAlias)}.${o.identifier(G)}`;
7501
7508
  X = o`sum(${k})`;
7502
7509
  } else
7503
7510
  X = this.queryBuilder.buildMeasureExpression(W, E, B);
@@ -7563,7 +7570,7 @@ class ne {
7563
7570
  const BE = o`${o.identifier(w)}.${o.identifier(lt.sourceColumn)}`, ut = lt.targetColumnObj;
7564
7571
  ut && se.push(K(ut, BE));
7565
7572
  }
7566
- se.length > 0 && (W = G(...se));
7573
+ se.length > 0 && (W = b(...se));
7567
7574
  }
7568
7575
  }
7569
7576
  const X = [];
@@ -7601,24 +7608,24 @@ class ne {
7601
7608
  const j = o`${o.identifier(B.cteAlias)}.${o.identifier(X.sourceColumn)}`, k = X.targetColumnObj || o.identifier(X.targetColumn);
7602
7609
  w.push(K(j, k));
7603
7610
  }
7604
- g = w.length === 1 ? w[0] : G(...w);
7611
+ g = w.length === 1 ? w[0] : b(...w);
7605
7612
  } else
7606
7613
  g = D.joinCondition;
7607
7614
  }
7608
- const b = D.joinType || "left", y = b !== "inner" && f ? G(g, f) : g;
7615
+ const F = D.joinType || "left", G = F !== "inner" && f ? b(g, f) : g;
7609
7616
  try {
7610
- switch (b) {
7617
+ switch (F) {
7611
7618
  case "left":
7612
- N = N.leftJoin(M, y), f && O.add(D.cube.name);
7619
+ N = N.leftJoin(M, G), f && O.add(D.cube.name);
7613
7620
  break;
7614
7621
  case "inner":
7615
7622
  N = N.innerJoin(M, g);
7616
7623
  break;
7617
7624
  case "right":
7618
- N = N.rightJoin(M, y), f && O.add(D.cube.name);
7625
+ N = N.rightJoin(M, G), f && O.add(D.cube.name);
7619
7626
  break;
7620
7627
  case "full":
7621
- N = N.fullJoin(M, y), f && O.add(D.cube.name);
7628
+ N = N.fullJoin(M, G), f && O.add(D.cube.name);
7622
7629
  break;
7623
7630
  }
7624
7631
  } catch {
@@ -7643,7 +7650,7 @@ class ne {
7643
7650
  // Reuse pre-built filters for parameter deduplication
7644
7651
  );
7645
7652
  if (u.length > 0 && I.push(...u), I.length > 0) {
7646
- const D = I.length === 1 ? I[0] : G(...I);
7653
+ const D = I.length === 1 ? I[0] : b(...I);
7647
7654
  N = N.where(D);
7648
7655
  }
7649
7656
  const C = this.queryBuilder.buildGroupByFields(
@@ -7655,7 +7662,7 @@ class ne {
7655
7662
  // Pass the queryPlan to handle CTE scenarios
7656
7663
  );
7657
7664
  C.length > 0 && (N = N.groupBy(...C));
7658
- const c = this.queryBuilder.buildHavingConditions(
7665
+ const _ = this.queryBuilder.buildHavingConditions(
7659
7666
  e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
7660
7667
  // Single cube
7661
7668
  t,
@@ -7663,8 +7670,8 @@ class ne {
7663
7670
  e
7664
7671
  // Pass the queryPlan to handle CTE scenarios
7665
7672
  );
7666
- if (c.length > 0) {
7667
- const D = c.length === 1 ? c[0] : G(...c);
7673
+ if (_.length > 0) {
7674
+ const D = _.length === 1 ? _[0] : b(..._);
7668
7675
  N = N.having(D);
7669
7676
  }
7670
7677
  const U = this.queryBuilder.buildOrderBy(t);
@@ -7875,7 +7882,7 @@ class ne {
7875
7882
  const S = R.dimensions?.[a];
7876
7883
  if (!S || ["arrayContains", "arrayOverlaps", "arrayContained"].includes(r.operator))
7877
7884
  continue;
7878
- const N = F(S.sql, s), O = this.queryBuilder.buildFilterConditionPublic(
7885
+ const N = y(S.sql, s), O = this.queryBuilder.buildFilterConditionPublic(
7879
7886
  N,
7880
7887
  r.operator,
7881
7888
  r.values,
@@ -7894,7 +7901,7 @@ class ne {
7894
7901
  if (!a) continue;
7895
7902
  const R = a.dimensions?.[A];
7896
7903
  if (!R) continue;
7897
- const S = F(R.sql, s), I = this.queryBuilder.buildDateRangeCondition(S, i.dateRange);
7904
+ const S = y(R.sql, s), I = this.queryBuilder.buildDateRangeCondition(S, i.dateRange);
7898
7905
  I && t.set(r, I);
7899
7906
  }
7900
7907
  }
@@ -7926,9 +7933,9 @@ class ne {
7926
7933
  const O = N.field.includes(".") ? N.field.split(".")[1] : N.field;
7927
7934
  if (E.timeDimensions)
7928
7935
  for (const C of E.timeDimensions) {
7929
- const [c, U] = C.dimension.split(".");
7936
+ const [_, U] = C.dimension.split(".");
7930
7937
  if (U === O) {
7931
- const D = A(c, O);
7938
+ const D = A(_, O);
7932
7939
  if (D)
7933
7940
  return {
7934
7941
  field: D,
@@ -7949,7 +7956,7 @@ class ne {
7949
7956
  const l = i.dimensions?.[O];
7950
7957
  if (l)
7951
7958
  return {
7952
- field: F(l.sql, s),
7959
+ field: y(l.sql, s),
7953
7960
  direction: N.direction
7954
7961
  };
7955
7962
  const u = T.measure?.includes(".") ? T.measure.split(".")[1] : T.measure;
@@ -7968,10 +7975,10 @@ class ne {
7968
7975
  else {
7969
7976
  const C = i.name === O ? i : void 0;
7970
7977
  if (C?.dimensions?.[l]) {
7971
- const c = C.dimensions[l];
7978
+ const _ = C.dimensions[l];
7972
7979
  a = [{
7973
7980
  field: this.queryBuilder.buildTimeDimensionExpression(
7974
- c.sql,
7981
+ _.sql,
7975
7982
  N.granularity,
7976
7983
  s
7977
7984
  ),
@@ -7983,7 +7990,7 @@ class ne {
7983
7990
  let R;
7984
7991
  T.partitionBy && T.partitionBy.length > 0 && (R = T.partitionBy.map((N) => {
7985
7992
  const O = N.includes(".") ? N.split(".")[1] : N, l = i.dimensions?.[O];
7986
- return l ? F(l.sql, s) : null;
7993
+ return l ? y(l.sql, s) : null;
7987
7994
  }).filter((N) => N !== null));
7988
7995
  const S = this.databaseAdapter.buildWindowFunction(
7989
7996
  e.type,
@@ -26578,24 +26585,24 @@ function ea() {
26578
26585
  this.complete(C, O);
26579
26586
  }
26580
26587
  if (O.reference === this.index) {
26581
- var c = O.rule.name;
26582
- (this.completed[c] = this.completed[c] || []).push(O);
26588
+ var _ = O.rule.name;
26589
+ (this.completed[_] = this.completed[_] || []).push(O);
26583
26590
  }
26584
26591
  }
26585
26592
  } else {
26586
- var c = O.rule.symbols[O.dot];
26587
- if (typeof c != "string") {
26593
+ var _ = O.rule.symbols[O.dot];
26594
+ if (typeof _ != "string") {
26588
26595
  this.scannable.push(O);
26589
26596
  continue;
26590
26597
  }
26591
- if (S[c]) {
26592
- if (S[c].push(O), I.hasOwnProperty(c))
26593
- for (var U = I[c], u = 0; u < U.length; u++) {
26598
+ if (S[_]) {
26599
+ if (S[_].push(O), I.hasOwnProperty(_))
26600
+ for (var U = I[_], u = 0; u < U.length; u++) {
26594
26601
  var D = U[u];
26595
26602
  this.complete(O, D);
26596
26603
  }
26597
26604
  } else
26598
- S[c] = [O], this.predict(c);
26605
+ S[_] = [O], this.predict(_);
26599
26606
  }
26600
26607
  }
26601
26608
  }, E.prototype.predict = function(a) {
@@ -26651,17 +26658,17 @@ function ea() {
26651
26658
  var O = this.index - this.lastLineBreak, l = String(this.line).length;
26652
26659
  return R += " at line " + this.line + " col " + O + `:
26653
26660
 
26654
- `, R += I.map(function(C, c) {
26655
- return u(this.line - I.length + c + 1, l) + " " + C;
26661
+ `, R += I.map(function(C, _) {
26662
+ return u(this.line - I.length + _ + 1, l) + " " + C;
26656
26663
  }, this).join(`
26657
26664
  `), R += `
26658
26665
  ` + u("", l + O) + `^
26659
26666
  `, R;
26660
26667
  } else
26661
26668
  return R + " at index " + (this.index - 1);
26662
- function u(C, c) {
26669
+ function u(C, _) {
26663
26670
  var U = String(C);
26664
- return Array(c - U.length + 1).join(" ") + U;
26671
+ return Array(_ - U.length + 1).join(" ") + U;
26665
26672
  }
26666
26673
  };
26667
26674
  function r(a, R, S) {
@@ -26696,8 +26703,8 @@ function ea() {
26696
26703
  this.options.keepHistory || delete this.table[this.current - 1];
26697
26704
  var O = this.current + 1, l = new E(this.grammar, O);
26698
26705
  this.table.push(l);
26699
- for (var u = S.text !== void 0 ? S.text : S.value, C = R.constructor === i ? S.value : S, c = N.scannable, U = c.length; U--; ) {
26700
- var D = c[U], m = D.rule.symbols[D.dot];
26706
+ for (var u = S.text !== void 0 ? S.text : S.value, C = R.constructor === i ? S.value : S, _ = N.scannable, U = _.length; U--; ) {
26707
+ var D = _[U], m = D.rule.symbols[D.dot];
26701
26708
  if (m.test ? m.test(C) : m.type ? m.type === S.type : m.literal === u) {
26702
26709
  var P = D.nextState({ data: C, token: S, isToken: !0, reference: O - 1 });
26703
26710
  l.states.push(P);
@@ -26733,7 +26740,7 @@ function ea() {
26733
26740
  return this.buildFirstStateStack(u, []) || [u];
26734
26741
  }, this);
26735
26742
  l.forEach(function(u) {
26736
- var C = u[0], c = C.rule.symbols[C.dot], U = this.getSymbolDisplay(c);
26743
+ var C = u[0], _ = C.rule.symbols[C.dot], U = this.getSymbolDisplay(_);
26737
26744
  S.push("A " + U + " based on:"), this.displayStateStack(u, S);
26738
26745
  }, this);
26739
26746
  }
@@ -27321,10 +27328,10 @@ ${JSON.stringify(r, void 0, 2)}`);
27321
27328
  }
27322
27329
  };
27323
27330
  }
27324
- var _;
27331
+ var c;
27325
27332
  (function(n) {
27326
27333
  n[n.SPACE = 0] = "SPACE", n[n.NO_SPACE = 1] = "NO_SPACE", n[n.NO_NEWLINE = 2] = "NO_NEWLINE", n[n.NEWLINE = 3] = "NEWLINE", n[n.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", n[n.INDENT = 5] = "INDENT", n[n.SINGLE_INDENT = 6] = "SINGLE_INDENT";
27327
- })(_ = _ || (_ = {}));
27334
+ })(c = c || (c = {}));
27328
27335
  class gE {
27329
27336
  constructor(e) {
27330
27337
  this.indentation = e, this.items = [];
@@ -27335,26 +27342,26 @@ class gE {
27335
27342
  add(...e) {
27336
27343
  for (const t of e)
27337
27344
  switch (t) {
27338
- case _.SPACE:
27339
- this.items.push(_.SPACE);
27345
+ case c.SPACE:
27346
+ this.items.push(c.SPACE);
27340
27347
  break;
27341
- case _.NO_SPACE:
27348
+ case c.NO_SPACE:
27342
27349
  this.trimHorizontalWhitespace();
27343
27350
  break;
27344
- case _.NO_NEWLINE:
27351
+ case c.NO_NEWLINE:
27345
27352
  this.trimWhitespace();
27346
27353
  break;
27347
- case _.NEWLINE:
27348
- this.trimHorizontalWhitespace(), this.addNewline(_.NEWLINE);
27354
+ case c.NEWLINE:
27355
+ this.trimHorizontalWhitespace(), this.addNewline(c.NEWLINE);
27349
27356
  break;
27350
- case _.MANDATORY_NEWLINE:
27351
- this.trimHorizontalWhitespace(), this.addNewline(_.MANDATORY_NEWLINE);
27357
+ case c.MANDATORY_NEWLINE:
27358
+ this.trimHorizontalWhitespace(), this.addNewline(c.MANDATORY_NEWLINE);
27352
27359
  break;
27353
- case _.INDENT:
27360
+ case c.INDENT:
27354
27361
  this.addIndentation();
27355
27362
  break;
27356
- case _.SINGLE_INDENT:
27357
- this.items.push(_.SINGLE_INDENT);
27363
+ case c.SINGLE_INDENT:
27364
+ this.items.push(c.SINGLE_INDENT);
27358
27365
  break;
27359
27366
  default:
27360
27367
  this.items.push(t);
@@ -27371,10 +27378,10 @@ class gE {
27371
27378
  addNewline(e) {
27372
27379
  if (this.items.length > 0)
27373
27380
  switch (Oe(this.items)) {
27374
- case _.NEWLINE:
27381
+ case c.NEWLINE:
27375
27382
  this.items.pop(), this.items.push(e);
27376
27383
  break;
27377
- case _.MANDATORY_NEWLINE:
27384
+ case c.MANDATORY_NEWLINE:
27378
27385
  break;
27379
27386
  default:
27380
27387
  this.items.push(e);
@@ -27383,7 +27390,7 @@ class gE {
27383
27390
  }
27384
27391
  addIndentation() {
27385
27392
  for (let e = 0; e < this.indentation.getLevel(); e++)
27386
- this.items.push(_.SINGLE_INDENT);
27393
+ this.items.push(c.SINGLE_INDENT);
27387
27394
  }
27388
27395
  /**
27389
27396
  * Returns the final SQL string.
@@ -27399,20 +27406,20 @@ class gE {
27399
27406
  }
27400
27407
  itemToString(e) {
27401
27408
  switch (e) {
27402
- case _.SPACE:
27409
+ case c.SPACE:
27403
27410
  return " ";
27404
- case _.NEWLINE:
27405
- case _.MANDATORY_NEWLINE:
27411
+ case c.NEWLINE:
27412
+ case c.MANDATORY_NEWLINE:
27406
27413
  return `
27407
27414
  `;
27408
- case _.SINGLE_INDENT:
27415
+ case c.SINGLE_INDENT:
27409
27416
  return this.indentation.getSingleIndent();
27410
27417
  default:
27411
27418
  return e;
27412
27419
  }
27413
27420
  }
27414
27421
  }
27415
- const Ca = (n) => n === _.SPACE || n === _.SINGLE_INDENT, la = (n) => n === _.SPACE || n === _.SINGLE_INDENT || n === _.NEWLINE;
27422
+ const Ca = (n) => n === c.SPACE || n === c.SINGLE_INDENT, la = (n) => n === c.SPACE || n === c.SINGLE_INDENT || n === c.NEWLINE;
27416
27423
  function AE(n, e) {
27417
27424
  if (e === "standard")
27418
27425
  return n;
@@ -27484,9 +27491,9 @@ class La extends gE {
27484
27491
  if (typeof e == "string")
27485
27492
  this.length += e.length, this.trailingSpace = !1;
27486
27493
  else {
27487
- if (e === _.MANDATORY_NEWLINE || e === _.NEWLINE)
27494
+ if (e === c.MANDATORY_NEWLINE || e === c.NEWLINE)
27488
27495
  throw new Rt();
27489
- e === _.INDENT || e === _.SINGLE_INDENT || e === _.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (e === _.NO_NEWLINE || e === _.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
27496
+ e === c.INDENT || e === c.SINGLE_INDENT || e === c.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (e === c.NO_NEWLINE || e === c.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
27490
27497
  }
27491
27498
  }
27492
27499
  }
@@ -27582,23 +27589,23 @@ class pe {
27582
27589
  }), this.formatNode(e.parenthesis);
27583
27590
  }
27584
27591
  formatPropertyAccess(e) {
27585
- this.formatNode(e.object), this.layout.add(_.NO_SPACE, e.operator), this.formatNode(e.property);
27592
+ this.formatNode(e.object), this.layout.add(c.NO_SPACE, e.operator), this.formatNode(e.property);
27586
27593
  }
27587
27594
  formatParenthesis(e) {
27588
27595
  const t = this.formatInlineExpression(e.children);
27589
- t ? (this.layout.add(e.openParen), this.layout.add(...t.getLayoutItems()), this.layout.add(_.NO_SPACE, e.closeParen, _.SPACE)) : (this.layout.add(e.openParen, _.NEWLINE), oe(this.cfg) ? (this.layout.add(_.INDENT), this.layout = this.formatSubExpression(e.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(_.INDENT), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(_.NEWLINE, _.INDENT, e.closeParen, _.SPACE));
27596
+ t ? (this.layout.add(e.openParen), this.layout.add(...t.getLayoutItems()), this.layout.add(c.NO_SPACE, e.closeParen, c.SPACE)) : (this.layout.add(e.openParen, c.NEWLINE), oe(this.cfg) ? (this.layout.add(c.INDENT), this.layout = this.formatSubExpression(e.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(c.INDENT), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(c.NEWLINE, c.INDENT, e.closeParen, c.SPACE));
27590
27597
  }
27591
27598
  formatBetweenPredicate(e) {
27592
- this.layout.add(this.showKw(e.betweenKw), _.SPACE), this.layout = this.formatSubExpression(e.expr1), this.layout.add(_.NO_SPACE, _.SPACE, this.showNonTabularKw(e.andKw), _.SPACE), this.layout = this.formatSubExpression(e.expr2), this.layout.add(_.SPACE);
27599
+ this.layout.add(this.showKw(e.betweenKw), c.SPACE), this.layout = this.formatSubExpression(e.expr1), this.layout.add(c.NO_SPACE, c.SPACE, this.showNonTabularKw(e.andKw), c.SPACE), this.layout = this.formatSubExpression(e.expr2), this.layout.add(c.SPACE);
27593
27600
  }
27594
27601
  formatCaseExpression(e) {
27595
- 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(_.NEWLINE, _.INDENT), this.formatNode(e.endKw);
27602
+ 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(c.NEWLINE, c.INDENT), this.formatNode(e.endKw);
27596
27603
  }
27597
27604
  formatCaseWhen(e) {
27598
- this.layout.add(_.NEWLINE, _.INDENT), this.formatNode(e.whenKw), this.layout = this.formatSubExpression(e.condition), this.formatNode(e.thenKw), this.layout = this.formatSubExpression(e.result);
27605
+ this.layout.add(c.NEWLINE, c.INDENT), this.formatNode(e.whenKw), this.layout = this.formatSubExpression(e.condition), this.formatNode(e.thenKw), this.layout = this.formatSubExpression(e.result);
27599
27606
  }
27600
27607
  formatCaseElse(e) {
27601
- this.layout.add(_.NEWLINE, _.INDENT), this.formatNode(e.elseKw), this.layout = this.formatSubExpression(e.result);
27608
+ this.layout.add(c.NEWLINE, c.INDENT), this.formatNode(e.elseKw), this.layout = this.formatSubExpression(e.result);
27602
27609
  }
27603
27610
  formatClause(e) {
27604
27611
  this.isOnelineClause(e) ? this.formatClauseInOnelineStyle(e) : oe(this.cfg) ? this.formatClauseInTabularStyle(e) : this.formatClauseInIndentedStyle(e);
@@ -27607,39 +27614,39 @@ class pe {
27607
27614
  return oe(this.cfg) ? this.dialectCfg.tabularOnelineClauses[e.nameKw.text] : this.dialectCfg.onelineClauses[e.nameKw.text];
27608
27615
  }
27609
27616
  formatClauseInIndentedStyle(e) {
27610
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.nameKw), _.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(_.INDENT), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseTopLevel();
27617
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.nameKw), c.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(c.INDENT), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseTopLevel();
27611
27618
  }
27612
27619
  formatClauseInOnelineStyle(e) {
27613
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.nameKw), _.SPACE), this.layout = this.formatSubExpression(e.children);
27620
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.nameKw), c.SPACE), this.layout = this.formatSubExpression(e.children);
27614
27621
  }
27615
27622
  formatClauseInTabularStyle(e) {
27616
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.nameKw), _.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseTopLevel();
27623
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.nameKw), c.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseTopLevel();
27617
27624
  }
27618
27625
  formatSetOperation(e) {
27619
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.nameKw), _.NEWLINE), this.layout.add(_.INDENT), this.layout = this.formatSubExpression(e.children);
27626
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.nameKw), c.NEWLINE), this.layout.add(c.INDENT), this.layout = this.formatSubExpression(e.children);
27620
27627
  }
27621
27628
  formatLimitClause(e) {
27622
27629
  this.withComments(e.limitKw, () => {
27623
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.limitKw));
27624
- }), this.layout.indentation.increaseTopLevel(), oe(this.cfg) ? this.layout.add(_.SPACE) : this.layout.add(_.NEWLINE, _.INDENT), e.offset ? (this.layout = this.formatSubExpression(e.offset), this.layout.add(_.NO_SPACE, ",", _.SPACE), this.layout = this.formatSubExpression(e.count)) : this.layout = this.formatSubExpression(e.count), this.layout.indentation.decreaseTopLevel();
27630
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.limitKw));
27631
+ }), this.layout.indentation.increaseTopLevel(), oe(this.cfg) ? this.layout.add(c.SPACE) : this.layout.add(c.NEWLINE, c.INDENT), e.offset ? (this.layout = this.formatSubExpression(e.offset), this.layout.add(c.NO_SPACE, ",", c.SPACE), this.layout = this.formatSubExpression(e.count)) : this.layout = this.formatSubExpression(e.count), this.layout.indentation.decreaseTopLevel();
27625
27632
  }
27626
27633
  formatAllColumnsAsterisk(e) {
27627
- this.layout.add("*", _.SPACE);
27634
+ this.layout.add("*", c.SPACE);
27628
27635
  }
27629
27636
  formatLiteral(e) {
27630
- this.layout.add(e.text, _.SPACE);
27637
+ this.layout.add(e.text, c.SPACE);
27631
27638
  }
27632
27639
  formatIdentifier(e) {
27633
- this.layout.add(this.showIdentifier(e), _.SPACE);
27640
+ this.layout.add(this.showIdentifier(e), c.SPACE);
27634
27641
  }
27635
27642
  formatParameter(e) {
27636
- this.layout.add(this.params.get(e), _.SPACE);
27643
+ this.layout.add(this.params.get(e), c.SPACE);
27637
27644
  }
27638
27645
  formatOperator({ text: e }) {
27639
- this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(e) ? this.layout.add(_.NO_SPACE, e) : e === ":" ? this.layout.add(_.NO_SPACE, e, _.SPACE) : this.layout.add(e, _.SPACE);
27646
+ this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(e) ? this.layout.add(c.NO_SPACE, e) : e === ":" ? this.layout.add(c.NO_SPACE, e, c.SPACE) : this.layout.add(e, c.SPACE);
27640
27647
  }
27641
27648
  formatComma(e) {
27642
- this.inline ? this.layout.add(_.NO_SPACE, ",", _.SPACE) : this.layout.add(_.NO_SPACE, ",", _.NEWLINE, _.INDENT);
27649
+ this.inline ? this.layout.add(c.NO_SPACE, ",", c.SPACE) : this.layout.add(c.NO_SPACE, ",", c.NEWLINE, c.INDENT);
27643
27650
  }
27644
27651
  withComments(e, t) {
27645
27652
  this.formatComments(e.leadingComments), t(), this.formatComments(e.trailingComments);
@@ -27650,12 +27657,12 @@ class pe {
27650
27657
  });
27651
27658
  }
27652
27659
  formatLineComment(e) {
27653
- Et(e.precedingWhitespace || "") ? this.layout.add(_.NEWLINE, _.INDENT, e.text, _.MANDATORY_NEWLINE, _.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(_.NO_NEWLINE, _.SPACE, e.text, _.MANDATORY_NEWLINE, _.INDENT) : this.layout.add(e.text, _.MANDATORY_NEWLINE, _.INDENT);
27660
+ Et(e.precedingWhitespace || "") ? this.layout.add(c.NEWLINE, c.INDENT, e.text, c.MANDATORY_NEWLINE, c.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(c.NO_NEWLINE, c.SPACE, e.text, c.MANDATORY_NEWLINE, c.INDENT) : this.layout.add(e.text, c.MANDATORY_NEWLINE, c.INDENT);
27654
27661
  }
27655
27662
  formatBlockComment(e) {
27656
27663
  e.type === p.block_comment && this.isMultilineBlockComment(e) ? (this.splitBlockComment(e.text).forEach((t) => {
27657
- this.layout.add(_.NEWLINE, _.INDENT, t);
27658
- }), this.layout.add(_.NEWLINE, _.INDENT)) : this.layout.add(e.text, _.SPACE);
27664
+ this.layout.add(c.NEWLINE, c.INDENT, t);
27665
+ }), this.layout.add(c.NEWLINE, c.INDENT)) : this.layout.add(e.text, c.SPACE);
27659
27666
  }
27660
27667
  isMultilineBlockComment(e) {
27661
27668
  return Et(e.text) || Et(e.precedingWhitespace || "");
@@ -27739,16 +27746,16 @@ class pe {
27739
27746
  }
27740
27747
  }
27741
27748
  formatJoin(e) {
27742
- oe(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e), _.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e), _.SPACE);
27749
+ oe(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e), c.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e), c.SPACE);
27743
27750
  }
27744
27751
  formatKeyword(e) {
27745
- this.layout.add(this.showKw(e), _.SPACE);
27752
+ this.layout.add(this.showKw(e), c.SPACE);
27746
27753
  }
27747
27754
  formatLogicalOperator(e) {
27748
- this.cfg.logicalOperatorNewline === "before" ? oe(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e), _.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e), _.SPACE) : this.layout.add(this.showKw(e), _.NEWLINE, _.INDENT);
27755
+ this.cfg.logicalOperatorNewline === "before" ? oe(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e), c.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e), c.SPACE) : this.layout.add(this.showKw(e), c.NEWLINE, c.INDENT);
27749
27756
  }
27750
27757
  formatDataType(e) {
27751
- this.layout.add(this.showDataType(e), _.SPACE);
27758
+ this.layout.add(this.showDataType(e), c.SPACE);
27752
27759
  }
27753
27760
  showKw(e) {
27754
27761
  return RE(e.tokenType) ? AE(this.showNonTabularKw(e), this.cfg.indentStyle) : this.showNonTabularKw(e);
@@ -27828,7 +27835,7 @@ class _a {
27828
27835
  params: this.params,
27829
27836
  layout: new gE(new GE(qT(this.cfg)))
27830
27837
  }).format(e.children);
27831
- return e.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? t.add(_.NEWLINE, ";") : t.add(_.NO_NEWLINE, ";")), t.toString();
27838
+ return e.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? t.add(c.NEWLINE, ";") : t.add(c.NO_NEWLINE, ";")), t.toString();
27832
27839
  }
27833
27840
  }
27834
27841
  class De extends Error {
@@ -29710,7 +29717,7 @@ function To(n, e, t) {
29710
29717
  const u = n.find((C) => C.name === t);
29711
29718
  u ? (T = [u], E.push(`Using specified cube: ${t}`)) : (s.push(`Specified cube '${t}' not found`), T = []);
29712
29719
  } else
29713
- T = Ya(n, { intent: e, limit: 3 }).map((C) => n.find((c) => c.name === C.cube)).filter((C) => C !== void 0), T.length > 0 && E.push(`Identified relevant cubes: ${T.map((C) => C.name).join(", ")}`);
29720
+ T = Ya(n, { intent: e, limit: 3 }).map((C) => n.find((_) => _.name === C.cube)).filter((C) => C !== void 0), T.length > 0 && E.push(`Identified relevant cubes: ${T.map((C) => C.name).join(", ")}`);
29714
29721
  if (T.length === 0) {
29715
29722
  const u = r !== "query", C = u ? OE(r, void 0) : void 0;
29716
29723
  return {
@@ -29728,12 +29735,12 @@ function To(n, e, t) {
29728
29735
  R && (E.push(`Detected ${R.type} aggregation intent`), a += 0.1);
29729
29736
  const S = [], I = e.toLowerCase();
29730
29737
  for (const u of A.measures) {
29731
- const c = [
29738
+ const _ = [
29732
29739
  (u.name.split(".").pop() || u.name).toLowerCase(),
29733
29740
  u.title.toLowerCase(),
29734
29741
  ...(u.synonyms || []).map((U) => U.toLowerCase())
29735
29742
  ];
29736
- for (const U of c)
29743
+ for (const U of _)
29737
29744
  if (I.includes(U)) {
29738
29745
  S.push(u.name), E.push(`Matched measure '${u.name}' via keyword '${U}'`), a += 0.15;
29739
29746
  break;
@@ -29745,7 +29752,7 @@ function To(n, e, t) {
29745
29752
  S.push(u[0].name), E.push(`Suggested ${u[0].name} based on ${R.type} intent`);
29746
29753
  else if (R.type === "count") {
29747
29754
  const C = A.measures.find(
29748
- (c) => c.type === "count" || c.type === "countDistinct"
29755
+ (_) => _.type === "count" || _.type === "countDistinct"
29749
29756
  );
29750
29757
  C && (S.push(C.name), E.push(`Suggested ${C.name} for counting`));
29751
29758
  }
@@ -30181,6 +30188,6 @@ export {
30181
30188
  at as getJoinType,
30182
30189
  Is as normalizeQuery,
30183
30190
  x as resolveCubeReference,
30184
- F as resolveSqlExpression,
30191
+ y as resolveSqlExpression,
30185
30192
  To as suggestQuery
30186
30193
  };